How to use the @ngrx/schematics/schematics-core.buildRelativePath 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
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(
      source,
      modulePath,
      effectsName,
      relativePath
    );

    const effectsSetup =
      options.root && options.minimal ? `[]` : `[${effectsName}]`;
    const [effectsNgModuleImport] = addImportToModule(
      source,
      modulePath,
      `EffectsModule.for${options.root ? 'Root' : 'Feature'}(${effectsSetup})`,
      relativePath
    );
github ngrx / platform / modules / schematics / src / container / index.ts View on Github external
const text = host.read(componentPath);

    if (text === null) {
      throw new SchematicsException(`File ${componentPath} does not exist.`);
    }

    const sourceText = text.toString('utf-8');

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

    const stateImportPath = buildRelativePath(componentPath, statePath);
    const storeImport = insertImport(
      source,
      componentPath,
      'Store',
      '@ngrx/store'
    );
    const stateImport = options.state
      ? insertImport(
          source,
          componentPath,
          `* as fromStore`,
          stateImportPath,
          true
        )
      : new NoopChange();
github ngrx / platform / modules / schematics / src / store / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    if (!options.name && !options.root) {
      throw new Error(`Please provide a name for the feature state`);
    }

    options.path = getProjectPath(host, options);

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

    const statePath = `/${options.path}/${options.statePath}/index.ts`;
    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);
    }
github ngrx / platform / modules / schematics / src / store / index.ts View on Github external
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 statePath = `${options.path}/${options.statePath}`;
    const relativePath = buildRelativePath(modulePath, statePath);

    const environmentsPath = buildRelativePath(
      statePath,
      `${options.path}/environments/environment`
    );

    const runtimeChecks = `
      runtimeChecks: {
        strictStateImmutability: true,
        strictActionImmutability: true,
      }
   `;

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

    const rootStoreConfig = options.minimal
      ? `{ ${runtimeChecks} }`
      : `{
github ngrx / platform / modules / schematics / src / store / 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 statePath = `${options.path}/${options.statePath}`;
    const relativePath = buildRelativePath(modulePath, statePath);

    const environmentsPath = buildRelativePath(
      statePath,
      `${options.path}/environments/environment`
    );

    const runtimeChecks = `
      runtimeChecks: {
        strictStateImmutability: true,
        strictActionImmutability: true,
      }
   `;

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

    const rootStoreConfig = options.minimal