How to use the @angular-devkit/schematics.mergeWith 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 ng-matero / ng-matero / schematics / ng-generate / module / index.ts View on Github external
//   ? noop()
      //   : filter(path => !path.endsWith('-routing.module.ts.template')),
      applyTemplates({
        ...strings,
        'if-flat': (s: string) => (options.flat ? '' : s),
        // lazyRoute: isLazyLoadedModuleGen,
        // lazyRouteWithoutRouteModule: isLazyLoadedModuleGen && !routingModulePath,
        // lazyRouteWithRouteModule: isLazyLoadedModuleGen && routingModulePath,
        ...options,
      }),
      move(parsedPath.path),
    ]);

    return chain([
      addRouteDeclarationToNgModule(options, routingModulePath),
      mergeWith(templateSource),
    ]);
  };
}
github intershop / intershop-pwa / schematics / src / extension / factory.js View on Github external
return host => {
        if (!options.project) {
            throw new schematics_1.SchematicsException('Option (project) is required.');
        }
        // tslint:disable:no-parameter-reassignment
        options = common_1.detectExtension('extension', host, options);
        options = common_1.applyNameAndPath('extension', host, options);
        options = common_1.determineArtifactName('extension', host, options);
        const operations = [];
        operations.push(schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
            schematics_1.template(Object.assign({}, core_1.strings, options)),
            schematics_1.move(options.path),
        ])));
        const projectRoot = project_1.buildDefaultPath(project_1.getProject(host, options.project));
        const artifactName = core_1.strings.classify(options.name) + 'ExportsModule';
        const moduleImportPath = `${projectRoot}/extensions/${core_1.strings.dasherize(options.name)}/exports/${core_1.strings.dasherize(options.name)}-exports.module`;
        const sharedModuleOptions = {
            module: `${projectRoot}/shared/shared.module.ts`,
            artifactName,
            moduleImportPath,
        };
        operations.push(registration_1.addExportToNgModule(sharedModuleOptions));
        operations.push(registration_1.addImportToNgModule(sharedModuleOptions));
        const appModuleOptions = {
            module: `${projectRoot}/app.module.ts`,
            artifactName,
github nrwl / nx / packages / web / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/app`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.unitTestRunner === 'none'
        ? filter(file => file !== '/src/app/app.spec.ts')
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github maciejtreder / ng-toolkit / schematics / init / src / utils / firebug / index.ts View on Github external
export function addFireBug(options: any): Rule {

    const source = apply(url('../utils/firebug/files'), [
        move(`${options.directory}/src/bootstrapScripts`)
    ]);

    return chain([
        mergeWith(source),
        tree => {
            addDependencyToPackageJson(tree, options, 'node-wget', '^0.4.2', true);
            addDependencyToPackageJson(tree, options, 'decompress', '^4.2.0', true);
            addDependencyToPackageJson(tree, options, 'decompress-targz', '^4.1.1', true);
        },
        tree => {
            let indexContent = '';
            if (tree.exists(`${options.directory}/src/bootstrapScripts/index.ts`)) {
                indexContent = getFileContent(tree, `${options.directory}/src/bootstrapScripts/index.ts`);
            }
            createOrOverwriteFile(tree,`${options.directory}/src/bootstrapScripts/index.ts`, indexContent + 'export * from \'./firebug\';\n');

            //find and overwrite environment files

            createOrOverwriteFile(tree, `${options.directory}/src/environments/environment.firebug.ts`, getFileContent(tree, `${options.directory}/src/environments/environment.ts`));
github nstudio / xplat / packages / angular / src / utils / xplat.ts View on Github external
return (tree: Tree, context: SchematicContext) => {
      if (
        tree.exists(`libs/core/base/base-component.ts`) ||
        tree.exists(`libs/features/index.ts`)
      ) {
        return noop();
      }

      return branchAndMerge(
        mergeWith(
          apply(url(`./_lib_files`), [
            template({
              ...(options as any),
              ...getDefaultTemplateOptions()
            }),
            move('libs')
          ])
        )
      );
    };
  }
github rangle / augury-labs / packages / schematics / src / rules / add-augury-main.rule.ts View on Github external
if (!project || !project.sourceRoot) {
      throw new SchematicsException(`Project root could not be found`);
    }

    const sourceDir = normalize(project.sourceRoot);
    const templateSource = apply(url('./files'), [
      template({
        options,
      }),
      move(sourceDir),
    ]);

    context.logger.info(`✅️ Adding main.augury.ts...`);

    return branchAndMerge(mergeWith(templateSource))(tree, context);
  };
}
github rxweb / rxweb / rxweb.io / node_modules / @schematics / angular / application / index.js View on Github external
const e2eOptions = {
            name: `${options.name}-e2e`,
            relatedAppName: options.name,
            rootSelector: appRootSelector,
        };
        if (options.projectRoot !== undefined) {
            e2eOptions.projectRoot = 'e2e';
        }
        return schematics_1.chain([
            addAppToWorkspaceFile(options, workspace),
            options.skipPackageJson ? schematics_1.noop() : addDependenciesToPackageJson(),
            schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/src'), [
                schematics_1.template(Object.assign({ utils: core_1.strings }, options, { 'dot': '.', relativePathToWorkspaceRoot })),
                schematics_1.move(sourceRoot),
            ])),
            schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/root'), [
                schematics_1.template(Object.assign({ utils: core_1.strings }, options, { 'dot': '.', relativePathToWorkspaceRoot,
                    rootInSrc })),
                schematics_1.move(appDir),
            ])),
            schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/lint'), [
                schematics_1.template(Object.assign({ utils: core_1.strings }, options, { tsLintRoot,
                    relativePathToWorkspaceRoot,
                    prefix })),
            ])),
            schematics_1.schematic('module', {
                name: 'app',
                commonModule: false,
                flat: true,
                routing: options.routing,
                routingScope: 'Root',
                path: sourceDir,
github nestjs / schematics / src / lib / library / library.factory.ts View on Github external
export function main(options: LibraryOptions): Rule {
  options = transform(options);
  return chain([
    addLibraryToCliOptions(options.path, options.name),
    updatePackageJson(options),
    updateTsConfig(options.name, options.prefix, options.path),
    branchAndMerge(mergeWith(generate(options))),
  ]);
}
github fossasia / susper.com / node_modules / @schematics / angular / pipe / index.js View on Github external
return (host, context) => {
        options.module = find_module_1.findModuleFromOptions(host, options);
        const templateSource = schematics_1.apply(schematics_1.url('./files'), [
            options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
            schematics_1.template(Object.assign({}, stringUtils, { 'if-flat': (s) => options.flat ? '' : s }, options)),
            schematics_1.move(sourceDir),
        ]);
        return schematics_1.chain([
            schematics_1.branchAndMerge(schematics_1.chain([
                addDeclarationToNgModule(options),
                schematics_1.mergeWith(templateSource),
            ])),
        ])(host, context);
    };
}
github nrwl / nx / packages / workspace / 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)
    ])
  );
}