How to use the @angular-devkit/core/src/utils/strings.dasherize function in @angular-devkit/core

To help you get started, we’ve selected a few @angular-devkit/core 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 NativeScript / nativescript-schematics / src / migrate-component / component-info-utils.ts View on Github external
if (tree.exists(componentPath)) {
      console.log(`${componentClassName} file found at: ${componentPath}`);
    } else {
      throw new SchematicsException(`Cannot locate Component ${componentClassName} at: ${componentPath}`);
    }
  } else {
    console.log(`Trying to deduct ${componentClassName} location following Angular best practices`);

    const fileName = `${dasherize(options.name)}.component.ts`;
    const app = join(projectSettings.sourceRoot, 'app');

    // search at src/app/file-name
    if (tree.exists(join(app, fileName))) {
      componentPath = join(app, fileName);
    } else if (tree.exists(join(app, dasherize(options.name), fileName))) {
      componentPath = join(app, dasherize(options.name), fileName);
    } else {
      throw new SchematicsException(`Couldn't find component's .ts file.
  You can use --component-path parameter to provide the path to the component.
  Hint. don't include src/app with --component-path`);
    }
  }

  return componentPath;
};
github NativeScript / nativescript-schematics / src / migrate-component / component-info-utils.ts View on Github external
componentPath = projectSettings.tsResolver(componentImportPath, modulePath);

    if (!componentPath.endsWith('.ts')) {
      componentPath = componentPath + '.ts';
    }

    if (tree.exists(componentPath)) {
      console.log(`${componentClassName} file found at: ${componentPath}`);
    } else {
      throw new SchematicsException(`Cannot locate Component ${componentClassName} at: ${componentPath}`);
    }
  } else {
    console.log(`Trying to deduct ${componentClassName} location following Angular best practices`);

    const fileName = `${dasherize(options.name)}.component.ts`;
    const app = join(projectSettings.sourceRoot, 'app');

    // search at src/app/file-name
    if (tree.exists(join(app, fileName))) {
      componentPath = join(app, fileName);
    } else if (tree.exists(join(app, dasherize(options.name), fileName))) {
      componentPath = join(app, dasherize(options.name), fileName);
    } else {
      throw new SchematicsException(`Couldn't find component's .ts file.
  You can use --component-path parameter to provide the path to the component.
  Hint. don't include src/app with --component-path`);
    }
  }

  return componentPath;
};
github NativeScript / nativescript-schematics / src / generate-template / master-detail / index.ts View on Github external
const generateTemplate = (options: MasterDetailSchema) => (tree: Tree, context: SchematicContext) => {
  context.logger.info('Generating Master Detail template');

  context.logger.info(`Project Params: ${JSON.stringify(projectParams, null, 2)}`);

  const templateOptions = {
    prefix: 'app', // options.prefix,
    name: dasherize(options.master),
    master: dasherize(options.master),
    detail: dasherize(options.detail),
    masterClassName: classify(options.master),
    detailClassName: classify(options.detail),
    nsext: projectParams.nsext,
  };

  const templatePath = projectParams.shared ? './_files-shared' : './_files-nsonly';

  const templateSource = apply(
    url(templatePath), [
      template(templateOptions),
      move(projectParams.appPath),
    ]);

  return mergeWith(templateSource);
github NativeScript / nativescript-schematics / src / module / index.ts View on Github external
const dest = ({ name, sourceDir, path, flat }: ModuleOptions) =>
  `${sourceDir}/${path}/${flat ? '' : dasherize(name)}`;
const getModuleBasename = (options: ModuleOptions) =>
github NativeScript / nativescript-schematics / src / generate / component / index.ts View on Github external
const parseComponentInfo = (tree: Tree, options: ComponentOptions): ComponentInfo => {
  const component = new ComponentInfo();

  const parsedPath = parseName(options.path || '', options.name);
  component.name = dasherize(parsedPath.name);

  const getGeneratedFilePath = (searchPath: string) => {
    const action = tree.actions.find(({ path }) => path.endsWith(searchPath));
    if (!action) {
      throw new SchematicsException(
        `Failed to find generated component file ${searchPath}. ` +
        `Please contact the @nativescript/schematics author.`);
    }

    return action.path;
  };

  const className = `/${component.name}.component.ts`;
  component.classPath = getGeneratedFilePath(className);

  const templateName = `/${component.name}.component.html`;
github akveo / nebular / scripts / gulp / tasks / change-prefix.ts View on Github external
function applyDefaults(parsedArguments: ParsedArguments): PackageNamesConfig {
  const { prefix } = parsedArguments;
  const config = {
    prefix,
    unscopedPrefix: prefix.replace(/^@/, ''),
    unprefixed: {},
  };

  for (const nbPackageName of NEBULAR_PACKAGES) {
    const packageName = parsedArguments[nbPackageName] || dasherize(nbPackageName);
    config.unprefixed[nbPackageName] = packageName;
    config[nbPackageName] = `${prefix}/${packageName}`;
  }

  return config as PackageNamesConfig;
}
github NativeScript / nativescript-schematics / src / generate / module / index.ts View on Github external
const getParsedName = (options: ModuleOptions): { name: string, moduleName: string, routingName: string } => {
  const parsedPath = parseName(options.path || '', options.name);
  const name = dasherize(parsedPath.name);

  return {
    name,
    moduleName: `/${name}.module.ts`,
    routingName: `/${name}-routing.module.ts`,
  };
};
github nestjs / nest-cli / actions / new.action.ts View on Github external
public async handle(inputs: Input[], options: Input[]) {
    const dryRunOption = options.find(option => option.name === 'dry-run');
    const isDryRunEnabled = dryRunOption && dryRunOption.value;

    await askForMissingInformation(inputs);
    await generateApplicationFiles(inputs, options).catch(exit);

    const shouldSkipInstall = options.some(
      option => option.name === 'skip-install' && option.value === true,
    );
    const shouldSkipGit = options.some(
      option => option.name === 'skip-git' && option.value === true,
    );
    const projectDirectory = dasherize(
      getApplicationNameInput(inputs)!.value as string,
    );

    if (!shouldSkipInstall) {
      await installPackages(
        options,
        isDryRunEnabled as boolean,
        projectDirectory,
      );
    }
    if (!isDryRunEnabled) {
      if (!shouldSkipGit) {
        await initializeGitRepository(projectDirectory);
        await createGitIgnoreFile(projectDirectory);
      }
github ngxs / schematics / src / utils / transform-options.ts View on Github external
function setOptionsValue(target, defaultSourceRoot: string) {
  target.path =
    target.path !== undefined
      ? join(normalize(defaultSourceRoot), target.path)
      : normalize(defaultSourceRoot);

  if (target.name) {
    const location: Location = new Parser().nameParser(target);
    target.name = strings.dasherize(location.name);
    target.path = join(strings.dasherize(location.path) as Path, target.name);
  }

  return target;
}