How to use the @nrwl/workspace.getProjectConfig 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 nrwl / nx / packages / storybook / src / schematics / cypress-project / cypress-project.spec.ts View on Github external
it('should update `angular.json` file', async () => {
    const tree = await runSchematic(
      'cypress-project',
      { name: 'test-ui-lib' },
      appTree
    );
    const project = getProjectConfig(tree, 'test-ui-lib-e2e');

    expect(project.architect.e2e.options.devServerTarget).toEqual(
      'test-ui-lib:storybook'
    );
    expect(project.architect.e2e.options.headless).toBeUndefined();
    expect(project.architect.e2e.options.watch).toBeUndefined();
    expect(project.architect.e2e.configurations.headless).toBeUndefined();
  });
});
github nrwl / nx / packages / angular / src / schematics / karma-project / karma-project.ts View on Github external
return (host: Tree) => {
    const projectConfig = getProjectConfig(host, options.project);
    if (projectConfig.architect.test) {
      throw new Error(
        `${options.project} already has a test architect option.`
      );
    }
  };
}
github nrwl / nx / packages / angular / src / schematics / stories / stories.ts View on Github external
return (tree: Tree, context: SchematicContext) => {
    context.logger.debug('adding .storybook folder to lib');

    const libPath = getProjectConfig(tree, projectName).sourceRoot + '/lib';
    return chain(
      tree
        .getDir(libPath)
        .subfiles.filter(fileName => fileName.endsWith('.module.ts'))
        .map(fileName => {
          const filePath = libPath + '/' + fileName;
          const file = getTsSourceFile(tree, filePath);

          const ngModuleDecorators = getDecoratorMetadata(
            file,
            'NgModule',
            '@angular/core'
          );
          if (ngModuleDecorators.length === 0) {
            throw new SchematicsException(
              `No @NgModule decorator in ${filePath}`
github nrwl / nx / packages / storybook / src / schematics / configuration / configuration.ts View on Github external
return (tree: Tree, context: SchematicContext) => {
    context.logger.debug('adding .storybook folder to lib');
    const projectConfig = getProjectConfig(tree, projectName);

    return chain([
      applyWithSkipExisting(url('./lib-files'), [
        template({
          tmpl: '',
          uiFramework,
          offsetFromRoot: offsetFromRoot(projectConfig.root)
        }),
        move(projectConfig.root)
      ])
    ])(tree, context);
  };
}
github nrwl / nx / packages / node / src / schematics / library / library.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    const projectConfig = getProjectConfig(host, options.name);
    return updateJsonInTree(`${projectConfig.root}/tsconfig.json`, json => {
      json.compilerOptions.types.push('jest');
      return json;
    });
  };
}
github nrwl / nx / packages / storybook / src / schematics / configuration / configuration.ts View on Github external
return (tree: Tree) => {
    const projectPath = getProjectConfig(tree, projectName).root;
    const tsConfigPath = projectPath + '/tsconfig.lib.json';
    const projectTsConfig = parseJsonAtPath(tree, tsConfigPath);

    let tsConfigContent: any;

    if (projectTsConfig && projectTsConfig.value) {
      tsConfigContent = projectTsConfig.value;
    } else {
      return tree;
    }

    tsConfigContent.exclude = [...tsConfigContent.exclude, '**/*.stories.ts'];

    tree.overwrite(
      tsConfigPath,
      JSON.stringify(tsConfigContent, null, 2) + '\n'
github nrwl / nx / packages / angular / src / schematics / karma-project / karma-project.ts View on Github external
return (host: Tree) => {
    const projectConfig = getProjectConfig(host, options.project);
    return updateJsonInTree(join(projectConfig.root, 'tsconfig.json'), json => {
      return {
        ...json,
        compilerOptions: {
          ...json.compilerOptions,
          types: Array.from(
            new Set([...(json.compilerOptions.types || []), 'jasmine'])
          )
        }
      };
    });
  };
}
github nrwl / nx / packages / jest / src / schematics / jest-project / jest-project.ts View on Github external
return (host: Tree) => {
    const projectConfig = getProjectConfig(host, options.project);
    if (!host.exists(join(projectConfig.root, 'tsconfig.json'))) {
      throw new Error(
        `Expected ${join(
          projectConfig.root,
          'tsconfig.json'
        )} to exist. Please create one.`
      );
    }
    return updateJsonInTree(join(projectConfig.root, 'tsconfig.json'), json => {
      return {
        ...json,
        compilerOptions: {
          ...json.compilerOptions,
          types: Array.from(
            new Set([...(json.compilerOptions.types || []), 'node', 'jest'])
          )