How to use the @angular-devkit/schematics.filter function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/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 nrwl / nx / packages / schematics / src / collection / ngrx / index.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('./files'), [
    !options.facade ? filter(excludeFacade) : noop(),
    excludeUnnecessaryFiles(),
    template({ ...options, tmpl: '', ...names(name) }),
    move(moduleDir)
  ]);

  return mergeWith(templateSource);
}
github ng-alain / delon / packages / schematics / application / index.ts View on Github external
function mergeFiles(options: ApplicationOptions, from: string, to: string) {
  return mergeWith(
    apply(url(from), [
      options.i18n ? noop() : filter(p => p.indexOf('i18n') === -1),
      options.form ? noop() : filter(p => p.indexOf('json-schema') === -1),
      template({
        utils: strings,
        ...options,
        dot: '.',
        VERSION,
        ZORROVERSION,
      }),
      move(to),
    ]),
  );
}
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);
}
github xmlking / ngx-starter-kit / tools / src / utils / templates.ts View on Github external
export function renderTemplates(path: string, target: string, options: Options = {}): Rule {
  return chain([
    mergeWith(
      apply(url(path), [
        options.filter ? filter(options.filter) : noop(),
        template({
          ...strings,
          ...(options.params ? options.params : {}),
        }),
        move(target),
      ]),
    ),
  ]);
}
github nestjs / schematics / src / lib / class / class.factory.ts View on Github external
function generate(options: ClassOptions): Source {
  return apply(url(join('./files' as Path, options.language)), [
    options.spec === 'true'
      ? noop()
      : filter(path => !path.endsWith('.spec.ts')),
    template({
      ...strings,
      ...options,
    }),
    move(options.path),
  ]);
}
github dynatrace-oss / barista / src / schematics / dt-linting-rule / index.ts View on Github external
export default function(options: DtLintingRuleOptions): Rule {
  options.name = _createRuleName(options.name, options.alttext);

  if (options.category) {
    options.category = strings.dasherize(options.category);
  }

  const templateRules = options.alttext
    ? [
        filter(_altTextFilterPredicate),
        template({
          ...strings,
          ...options,
          ...{ squigglyLine: _squigglyLine(options.alttext) },
        }),
        move('src'),
      ]
    : [template({ ...strings, ...options }), move('src')];
  const templateSource = apply(url('./files'), templateRules);

  const rules = [
    mergeWith(templateSource),
    _addLintingRuleToTslintJson(
      options.name,
      options.severity === 'warning',
      BARISTA_EXAMPLES_TSLINT_CONFIG,
github nestjs / schematics / src / lib / controller / controller.factory.ts View on Github external
function generate(options: ControllerOptions) {
  return apply(url(join('./files' as Path, options.language)), [
    options.spec === 'true'
      ? noop()
      : filter(path => !path.endsWith('.spec.ts')),
    template({
      ...strings,
      ...options,
    }),
    move(options.path),
  ]);
}
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 feloy / angular-cli-collection / application / index.js View on Github external
])),
            schematics_1.schematic('module', {
                name: 'app',
                commonModule: false,
                flat: true,
                routing: options.routing,
                routingScope: 'Root',
                sourceDir: options.directory + '/' + sourceDir,
                spec: false,
            }),
            schematics_1.schematic('component', Object.assign({ name: 'app', selector: appRootSelector, sourceDir: options.directory + '/' + sourceDir, flat: true }, componentOptions)),
            addBootstrapToNgModule(options.directory, sourceDir),
            schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./other-files'), [
                componentOptions.inlineTemplate ? schematics_1.filter(path => !path.endsWith('.html')) : schematics_1.noop(),
                !componentOptions.spec ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
                !options.material ? schematics_1.filter(materialPathFilter) : schematics_1.noop(),
		!options.ssr ? schematics_1.filter(ssrPathOtherFilter) : schematics_1.noop(),
                schematics_1.template(Object.assign({ utils: stringUtils }, options, { selector: appRootSelector }, componentOptions)),
                schematics_1.move(options.directory + '/' + sourceDir + '/app'),
            ]), schematics_1.MergeStrategy.Overwrite),
        ])(host, context);
    };
}
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'))
    ])
  );
}