How to use the @ngrx/schematics/schematics-core.stringUtils.classify function in @ngrx/schematics

To help you get started, we’ve selected a few @ngrx/schematics 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 ngrx / platform / modules / schematics / src / effect / index.ts View on Github external
function getEffectStart(name: string, creators?: boolean): string {
  const effectName = stringUtils.classify(name);
  return creators
    ? `load${effectName}s$ = createEffect(() => {` +
        '\n    return this.actions$.pipe( \n'
    : '@Effect()\n' + `  load${effectName}s$ = this.actions$.pipe(`;
}
github ngrx / platform / modules / schematics / src / effect / index.ts View on Github external
}

    const text = host.read(modulePath);
    if (text === null) {
      throw new SchematicsException(`File ${modulePath} does not exist.`);
    }
    const sourceText = text.toString('utf-8');

    const source = ts.createSourceFile(
      modulePath,
      sourceText,
      ts.ScriptTarget.Latest,
      true
    );

    const effectsName = `${stringUtils.classify(`${options.name}Effects`)}`;

    const effectsModuleImport = insertImport(
      source,
      modulePath,
      'EffectsModule',
      '@ngrx/effects'
    );

    const effectsPath =
      `/${options.path}/` +
      (options.flat ? '' : stringUtils.dasherize(options.name) + '/') +
      (options.group ? 'effects/' : '') +
      stringUtils.dasherize(options.name) +
      '.effects';
    const relativePath = buildRelativePath(modulePath, effectsPath);
    const effectsImport = insertImport(
github ngrx / platform / modules / schematics / src / store / index.ts View on Github external
}
   `;

    const rootStoreReducers = options.minimal ? `{}` : `reducers`;

    const rootStoreConfig = options.minimal
      ? `{ ${runtimeChecks} }`
      : `{
      metaReducers, ${runtimeChecks} }`;

    const storeNgModuleImport = addImportToModule(
      source,
      modulePath,
      options.root
        ? `StoreModule.forRoot(${rootStoreReducers}, ${rootStoreConfig})`
        : `StoreModule.forFeature(from${stringUtils.classify(
            options.name
          )}.${stringUtils.camelize(
            options.name
          )}FeatureKey, from${stringUtils.classify(
            options.name
          )}.reducers, { metaReducers: from${stringUtils.classify(
            options.name
          )}.metaReducers })`,
      relativePath
    ).shift();

    let commonImports = [
      insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
      storeNgModuleImport,
    ];
github ngrx / platform / modules / schematics / src / store / index.ts View on Github external
const srcPath = dirname(options.path as Path);
    const environmentsPath = buildRelativePath(
      statePath,
      `${srcPath}/environments/environment`
    );

    if (options.module) {
      options.module = findModuleFromOptions(host, options);
    }

    if (
      options.root &&
      options.stateInterface &&
      options.stateInterface !== 'State'
    ) {
      options.stateInterface = stringUtils.classify(options.stateInterface);
    }

    const templateSource = apply(url('./files'), [
      options.root && options.minimal ? filter(_ => false) : noop(),
      applyTemplates({
        ...stringUtils,
        ...(options as object),
        isLib: isLib(host, options),
        environmentsPath,
      }),
      move(parsedPath.path),
    ]);

    return chain([
      branchAndMerge(
        chain([addImportToNgModule(options), mergeWith(templateSource)])