How to use the @angular-devkit/schematics.chain 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 xmlking / ngx-starter-kit / tools / src / schematics / store / index.ts View on Github external
const parsedPath = parseName(options.path, options.name);
    options.name = parsedPath.name;
    options.path = parsedPath.path;

    validateName(options.name);
    console.log(options);

    const templateSource = apply(url('./_files'), [
      template({
        ...strings,
        ...options,
      }),
      // move(parsedPath.path),
    ]);

    const rule = chain([branchAndMerge(chain([mergeWith(templateSource)]))]);

    return rule(host, context);
  };
}
github johandb / svg-drawing-tool / node_modules / @schematics / angular / component / index.js View on Github external
options.selector = options.selector || buildSelector(options, project.prefix);
        // todo remove these when we remove the deprecations
        options.style = (options.style && options.style !== 'css'
            ? options.style : options.styleext) || 'css';
        options.skipTests = options.skipTests || !options.spec;
        validation_1.validateName(options.name);
        validation_1.validateHtmlSelector(options.selector);
        const templateSource = schematics_1.apply(schematics_1.url('./files'), [
            options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
            options.inlineStyle ? schematics_1.filter(path => !path.endsWith('.__style__')) : schematics_1.noop(),
            options.inlineTemplate ? schematics_1.filter(path => !path.endsWith('.html')) : schematics_1.noop(),
            schematics_1.template(Object.assign({}, core_1.strings, { 'if-flat': (s) => options.flat ? '' : s }, options)),
            schematics_1.move(parsedPath.path),
        ]);
        return schematics_1.chain([
            schematics_1.branchAndMerge(schematics_1.chain([
                addDeclarationToNgModule(options),
                schematics_1.mergeWith(templateSource),
            ])),
            options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
        ]);
    };
}
github johandb / svg-drawing-tool / node_modules / @schematics / angular / pipe / index.js View on Github external
const project = project_1.getProject(host, options.project);
        if (options.path === undefined) {
            options.path = project_1.buildDefaultPath(project);
        }
        options.module = find_module_1.findModuleFromOptions(host, options);
        const parsedPath = parse_name_1.parseName(options.path, options.name);
        options.name = parsedPath.name;
        options.path = parsedPath.path;
        // todo remove these when we remove the deprecations
        options.skipTests = options.skipTests || !options.spec;
        const templateSource = schematics_1.apply(schematics_1.url('./files'), [
            options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
            schematics_1.template(Object.assign({}, core_1.strings, { 'if-flat': (s) => options.flat ? '' : s }, options)),
            schematics_1.move(parsedPath.path),
        ]);
        return schematics_1.branchAndMerge(schematics_1.chain([
            addDeclarationToNgModule(options),
            schematics_1.mergeWith(templateSource),
            options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
        ]));
    };
}
github Sitecore / jss / packages / sitecore-jss-angular-schematics / src / jss-component / index.ts View on Github external
}
    console.log(`* Implement the Angular component in ${chalk.green(`${parsedPath.path}/${parsedPath.name}`)}`);
    if (!options.noManifest) {
      console.log(`* Add the component to a route layout (/data/routes) and test it with ${chalk.green('jss start')}`);
    } else {
      console.log(
        `* Deploy your app with the new component to Sitecore (${chalk.green(
          'jss deploy:watch'
        )} or ${chalk.green('jss deploy files')})`
      );
      console.log(`* Add the component to a route using Sitecore Experience Editor, and test it.`);
    }

    console.log();

    return branchAndMerge(chain(sources));
  };
}
github maciejtreder / ng-toolkit / schematics / init / src / ng-new / index.ts View on Github external
function updatePackageJson(options: any): Rule {
    console.log(options);
    return chain([
        (tree) => {
            addDependencyToPackageJson(tree, options, '@angular/service-worker', '^6.0.0');
            addDependencyToPackageJson(tree, options, '@angular/platform-server', '^6.0.0');
            addDependencyToPackageJson(tree, options, '@angular/cdk', '^6.0.0');
            addDependencyToPackageJson(tree, options, '@angular/material', '^6.0.0');
            addDependencyToPackageJson(tree, options, 'webpack-cli', '2.1.2');
            addDependencyToPackageJson(tree, options, 'ts-loader', '4.2.0', true);
            addDependencyToPackageJson(tree, options, '@ngx-translate/core', '^10.0.1');
            addDependencyToPackageJson(tree, options, '@ngx-translate/http-loader', '^3.0.1');
            return tree;
        },
        addOrReplaceScriptInPackageJson(options, 'build:client-and-server-bundles', 'ng build --prod && ng run __projectName__:server'),
        addOrReplaceScriptInPackageJson(options, 'build:prod', 'npm run build:client-and-server-bundles && npm run webpack:server'),
        addOrReplaceScriptInPackageJson(options, 'test', 'ng test --code-coverage'),
        addOrReplaceScriptInPackageJson(options, 'test:watch', 'ng test --watch --code-coverage'),
github apollographql / apollo-angular / packages / apollo-angular / schematics / install / index.ts View on Github external
export default function install(options: Schema): Rule {
  return chain([
    assertTypescriptVersion(),
    addDependencies(),
    inludeAsyncIterableLib,
    addSetupFiles(options),
    importSetupModule(options),
    importHttpClientModule(options),
  ]);
}
github nrwl / nx / packages / schematics / src / collection / lib / index.ts View on Github external
}

    const templateSource = apply(
      url(options.nomodule ? './files' : './ngfiles'),
      [
        template({
          ...names(options.moduleName),
          dot: '.',
          tmpl: '',
          ...(options as object)
        })
      ]
    );

    return chain([
      branchAndMerge(chain([mergeWith(templateSource)])),
      addLibToAngularCliJson(options),
      options.routing && options.lazy
        ? addLazyLoadedRouterConfiguration(modulePath)
        : noop(),
      options.routing && options.lazy && options.parentModule
        ? addLoadChildren(options)
        : noop(),

      options.routing && !options.lazy
        ? addRouterConfiguration(options, indexFile, moduleFileName, modulePath)
        : noop(),
      options.routing && !options.lazy && options.parentModule
        ? addChildren(options)
        : noop()
    ]);
  });
github nestjs / schematics / src / lib / interceptor / interceptor.factory.ts View on Github external
export function main(options: InterceptorOptions): Rule {
  options = transform(options);
  return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
}
github nayfin / tft-library / projects / tft-library / schematics / component / index.js View on Github external
return (host, context) => {
        const project = utils_1.getProject(host, options.project);
        options.path = utils_1.getProjectPath(host, options);
        const parsedPath = utils_1.parseName(options);
        parsedPath.path = parsedPath.path.replace(`${options.dirName}`, `${parsedPath.name}/`);
        options.name = parsedPath.name;
        options.path = parsedPath.path;
        options.selector =
            options.selector || buildSelector(options, project.prefix);
        const templateSource = schematics_1.apply(schematics_1.url("./files"), [
            schematics_1.template(Object.assign({}, utils_1.stringUtils, options)),
            schematics_1.move(parsedPath.path)
        ]);
        return schematics_1.chain([schematics_1.branchAndMerge(schematics_1.chain([schematics_1.mergeWith(templateSource)]))])(host, context);
    };
}
github sbb-design-systems / sbb-angular / schematics / generate-icon-modules / index.js View on Github external
apply(root) {
        const directory = this.name ? root.dir(core.fragment(this.filename)) : root;
        return schematics.chain([
            schematics.mergeWith(schematics.apply(schematics.url('./files/collection'), [
                schematics.template(Object.assign({}, core.strings, this)),
                schematics.move(directory.path)
            ])),
            ...this.collections.map(c => c.apply(directory)),
            ...this.icons.map(i => i.apply(directory))
        ]);
    }
}