How to use the @nrwl/workspace.serializeJson function in @nrwl/workspace

To help you get started, weโ€™ve selected a few @nrwl/workspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nstudio / xplat / packages / xplat / src / utils / general.ts View on Github external
export function updateJsonFile(tree: Tree, path: string, jsonData: any) {
  try {
    // if (tree.exists(path)) {
    tree.overwrite(path, serializeJson(jsonData));
    // }
    return tree;
  } catch (err) {
    // console.warn(err);
    throw new SchematicsException(`${path}: ${err}`);
  }
}
github nrwl / nx / packages / angular / src / migrations / update-8-5-0 / update-8-5-0.spec.ts View on Github external
it('should coerce a version with a tilde into a valid version', async () => {
      tree.create(
        'package.json',
        serializeJson({
          devDependencies: {
            '@angular/cli': '~8.0.0'
          }
        })
      );

      const result = await schematicRunner
        .runSchematicAsync('upgrade-cli-8-3', {}, tree)
        .toPromise();

      expect(
        readJsonInTree(result, 'package.json').devDependencies['@angular/cli']
      ).toEqual('^8.3.3');
    });
github nrwl / nx / packages / workspace / src / schematics / init / init.ts View on Github external
tap(existingPrettierConfig => {
        if (!existingPrettierConfig) {
          host.create(
            '.prettierrc',
            serializeJson(DEFAULT_NRWL_PRETTIER_CONFIG)
          );
        }
      }),
      mapTo(host)
github nrwl / nx / packages / schematics / migrations / update-6-0-0 / update-6-0-0.ts View on Github external
function createDefaultAppTsConfig(host: Tree, project: any) {
  const offset = offsetFromRoot(project.root);

  const defaultAppTsConfig = {
    extends: `${offset}tsconfig.json`,
    compilerOptions: {
      outDir: `${offset}dist/out-tsc/${project.root}`,
      module: 'es2015'
    },
    include: ['**/*.ts'],
    exclude: ['src/test.ts', '**/*.spec.ts']
  };
  createOrUpdate(
    host,
    `${project.root}/tsconfig.app.json`,
    serializeJson(defaultAppTsConfig)
  );
}
github nrwl / nx / packages / schematics / migrations / update-6-0-0 / update-6-0-0.ts View on Github external
const tsConfig = readJsonInTree(
          host,
          `${project.root}/src/tsconfig.e2e.json`
        );
        tsConfig.extends = `${offset}tsconfig.json`;
        tsConfig.compilerOptions = {
          ...tsConfig.compilerOptions,
          outDir: `${offset}dist/out-tsc/${project.root}`
        };
        delete tsConfig.include;
        delete tsConfig.exclude;
        createOrUpdate(
          host,

          `${project.root}/tsconfig.e2e.json`,
          serializeJson(tsConfig)
        );
        host.delete(`${project.root}/src/tsconfig.e2e.json`);
      } else {
        createDefaultE2eTsConfig(host, project);
      }
    }
  });
  return host;
github nrwl / nx / packages / schematics / migrations / update-6-0-0 / update-6-0-0.ts View on Github external
function createTslintJson(host: Tree, project: any) {
  const offset = offsetFromRoot(project.root);

  createOrUpdate(
    host,
    `${project.root}/tslint.json`,
    serializeJson({
      extends: `${offset}tslint.json`,
      rules: {
        'directive-selector': [true, 'attribute', project.prefix, 'camelCase'],
        'component-selector': [true, 'element', project.prefix, 'kebab-case']
      }
    })
  );
}
github nrwl / nx / packages / schematics / migrations / update-6-0-0 / update-6-0-0.ts View on Github external
project.architect.build &&
      project.architect.build.options.main.startsWith('apps')
    ) {
      const offset = offsetFromRoot(project.root);
      const originalTsConfigPath = `${project.root}/src/tsconfig.app.json`;
      if (host.exists(originalTsConfigPath)) {
        const tsConfig = readJsonInTree(host, originalTsConfigPath);
        if (!(tsConfig.exclude as string[]).includes('src/test.ts')) {
          tsConfig.exclude.push('src/test.ts');
        }

        createOrUpdate(
          host,

          `${project.root}/tsconfig.app.json`,
          serializeJson({
            ...tsConfig,
            extends: `${offset}tsconfig.json`,
            compilerOptions: {
              ...tsConfig.compilerOptions,
              outDir: `${offset}dist/out-tsc/${project.root}`
            },
            include: tsConfig.include.map((include: string) => {
              if (include.startsWith('../../../')) {
                include = include.substring(3);
              }

              if (include.includes('/libs/') && include.endsWith('index.ts')) {
                include = include.replace('index.ts', 'src/index.ts');
              }
              return include;
            })
github nrwl / nx / packages / schematics / migrations / update-7-7-0 / update-7-7-0.spec.ts View on Github external
beforeEach(() => {
      initialTree.overwrite(
        'package.json',
        serializeJson({
          devDependencies: {
            jest: '23.10.5',
            'jest-preset-angular': '6.0.2'
          }
        })
      );
      initialTree.create(
        'jest.config.js',
        `module.exports = {
          testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
          transform: {
            '^.+\\.(ts|js|html)$': 'jest-preset-angular/preprocessor.js'
          },
          resolver: '@nrwl/builders/plugins/jest/resolver',
          moduleFileExtensions: ['ts', 'js', 'html'],
          coverageReporters: ['html']
github nrwl / nx / packages / workspace / src / schematics / init / init.ts View on Github external
return (host: Tree, _context: SchematicContext) => {
    const workspaceJson = readJsonInTree(host, 'angular.json');
    host.create(
      'nx.json',
      serializeJson({
        npmScope: options.npmScope,
        implicitDependencies: {
          'angular.json': '*',
          'package.json': '*',
          'tsconfig.json': '*',
          'tslint.json': '*',
          'nx.json': '*'
        },
        projects: {
          [options.name]: {
            tags: []
          },
          [getE2eKey(workspaceJson) + '-e2e']: {
            tags: []
          }
        }