How to use the @nrwl/workspace.names 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 / react / src / schematics / redux / redux.ts View on Github external
async function normalizeOptions(
  host: Tree,
  options: Schema
): Promise {
  let appProjectSourcePath: Path;
  let appMainFilePath: string;
  const extraNames = names(options.name);
  const { sourceRoot } = getProjectConfig(host, options.project);
  const workspace = await getWorkspace(host);
  const projectType = workspace.projects.get(options.project).extensions
    .projectType as string;
  const tsConfigJson = readJsonInTree(host, 'tsconfig.json');
  const tsPaths: { [module: string]: string[] } = tsConfigJson.compilerOptions
    ? tsConfigJson.compilerOptions.paths || {}
    : {};
  const modulePath =
    projectType === 'application'
      ? `./app/${extraNames.fileName}.slice`
      : Object.keys(tsPaths).find(k =>
          tsPaths[k].some(s => s.includes(sourceRoot))
        );
  // If --project is set to an app, automatically configure store
  // for it without needing to specify --appProject.
github nrwl / nx / packages / angular / src / schematics / ngrx / rules / add-exports-barrel.ts View on Github external
const className = `${toClassName(options.name)}`;
      const exportBarrels = options.barrels === true;

      const buffer = host.read(indexFilePath);
      if (!!buffer) {
        // AST to 'index.ts' barrel for the public API
        const indexSource = buffer!.toString('utf-8');
        const indexSourceFile = ts.createSourceFile(
          indexFilePath,
          indexSource,
          ts.ScriptTarget.Latest,
          true
        );

        // Public API for the feature interfaces, selectors, and facade
        const { fileName } = names(options.name);
        const statePath = `./lib/${options.directory}/${fileName}`;

        insert(host, indexFilePath, [
          ...addGlobal(
            indexSourceFile,
            indexFilePath,
            exportBarrels
              ? `import * as ${className}Actions from '${statePath}.actions';`
              : `export * from '${statePath}.actions';`
          ),
          ...addGlobal(
            indexSourceFile,
            indexFilePath,
            exportBarrels
              ? `import * as ${className}Feature from '${statePath}.reducer';`
              : `export * from '${statePath}.reducer';`
github nrwl / nx / packages / react / src / schematics / component / component.ts View on Github external
function normalizeOptions(
  host: Tree,
  options: Schema,
  context: SchematicContext
): NormalizedSchema {
  const { className, fileName } = names(options.name);
  const componentFileName = options.pascalCaseFiles ? className : fileName;
  const { sourceRoot: projectSourceRoot, projectType } = getProjectConfig(
    host,
    options.project
  );

  const styledModule = /^(css|scss|less|styl)$/.test(options.style)
    ? null
    : options.style;

  assertValidStyle(options.style);

  if (options.export && projectType === 'application') {
    context.logger.warn(
      `The "--export" option should not be used with applications and will do nothing.`
    );
github nrwl / nx / packages / react / src / schematics / library / library.ts View on Github external
function createFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/lib`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.projectRoot)
      }),
      move(options.projectRoot),
      options.publishable
        ? noop()
        : filter(file => !file.endsWith('package.json'))
    ])
  );
}
github nrwl / nx / packages / next / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files`), [
      template({
        ...names(options.name),
        ...options,
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.styledModule
        ? filter(file => !file.endsWith(`.${options.style}`))
        : noop(),
      options.unitTestRunner === 'none'
        ? filter(file => file !== `/specs/index.spec.tsx`)
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github nrwl / nx / packages / node / src / schematics / library / library.ts View on Github external
function createFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/lib`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.projectRoot)
      }),
      move(options.projectRoot),
      options.unitTestRunner === 'none'
        ? filter(file => !file.endsWith('spec.ts'))
        : noop(),
      options.publishable
        ? noop()
        : filter(file => !file.endsWith('package.json'))
    ]),
    MergeStrategy.Overwrite
  );
}
github nrwl / nx / packages / react / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/app`), [
      template({
        ...names(options.name),
        ...options,
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.styledModule
        ? filter(file => !file.endsWith(`.${options.style}`))
        : noop(),
      options.unitTestRunner === 'none'
        ? filter(file => file !== `/src/app/${options.fileName}.spec.tsx`)
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github nrwl / nx / packages / web / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/app`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.unitTestRunner === 'none'
        ? filter(file => file !== '/src/app/app.spec.ts')
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github nrwl / nx / packages / angular / src / schematics / ngrx / ngrx.ts View on Github external
function generateNgrxFilesFromTemplates(options: Schema) {
  const name = options.name;
  const moduleDir = path.dirname(options.module);
  const excludeFacade = path => path.match(/^((?!facade).)*$/);

  const templateSource = apply(
    url(options.syntax === 'creators' ? './creator-files' : './files'),
    [
      !options.facade ? filter(excludeFacade) : noop(),
      template({ ...options, tmpl: '', ...names(name) }),
      move(moduleDir)
    ]
  );

  return mergeWith(templateSource);
}