How to use the @angular-devkit/schematics.MergeStrategy.Overwrite 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 maciejtreder / ng-toolkit / schematics / serverless / src / index.ts View on Github external
rules.push((tree: Tree, context: SchematicContext) => {
        // update project name
        updateProject(tree, options);
            
        const ngToolkitSettings = getNgToolkitInfo(tree, options);
        if (!ngToolkitSettings.universal) {
            return chain([
                mergeWith(templateSource, MergeStrategy.Overwrite),
                tree => {
                    if (isUniversal(tree, options)) {
                        tree.rename(`${options.directory}/server_universal.ts`, `${options.directory}/server.ts`);
                        tree.rename(`${options.directory}/server_static.ts`, `${options.directory}/temp/server_static.ts${new Date().getDate()}`);
                    } else {
                        tree.rename(`${options.directory}/server_universal.ts`, `${options.directory}temp/server_universal.ts${new Date().getDate()}`);
                        tree.rename(`${options.directory}/server_static.ts`, `${options.directory}/server.ts`);
                    }

                    const serverFileContent = getFileContent(tree, `${options.directory}/server.ts`);

                    tree.overwrite(`${options.directory}/server.ts`, serverFileContent
                        .replace('__distBrowserFolder__', getBrowserDistFolder(tree, options))
                        .replace('__distServerFolder__', getServerDistFolder(tree, options))
                    );
                }
github nrwl / nx / packages / node / src / schematics / library / library.ts View on Github external
apply(url(`./files/lib`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.projectRoot)
      }),
      move(options.projectRoot),
      options.unitTestRunner === 'none'
        ? filter(file => !file.endsWith('spec.ts'))
        : noop(),
      options.publishable
        ? noop()
        : filter(file => !file.endsWith('package.json'))
    ]),
    MergeStrategy.Overwrite
  );
}
github SAP / cloud-commerce-spartacus-storefront / projects / schematics / src / add-ssr / index.ts View on Github external
);
    const templates = provideServerAndWebpackServerConfigs(options);

    return chain([
      addPackageJsonDependencies(),
      externalSchematic('@nguniversal/express-engine', 'ng-add', {
        clientProject: options.project,
      }),
      addPackageJsonScripts(options),
      addServerConfigInAngularJsonFile(options),
      modifyTSConfigServerFile(),
      modifyAppServerModuleFile(),
      modifyIndexHtmlFile(project, options),
      branchAndMerge(
        chain([mergeWith(templates, MergeStrategy.Overwrite)]),
        MergeStrategy.Overwrite
      ),
      modifyMainServerTSFile(),
      installPackageJsonDependencies(),
    ])(tree, context);
  };
}
github mselerin / yang-schematics / src / init / index.ts View on Github external
options.name = options.name || path.basename(process.cwd());
    if (!options.name) {
      throw new SchematicsException(`Invalid options, "name" is required.`);
    }

    return chain([
      mergeWith(apply(url('./files/root'), [
        template({
          ...strings,
          ...options,
          buildDate: new Date().toISOString()
        }),
        move(''),
        forceOverwrite(host)
      ]), MergeStrategy.Overwrite),

      updatePackageJson(),
      updateTsConfig(),
      updateGitIgnore(),
      updatePolyfills(),
      updateEnvironments(),
      updateAngularJson(),

      schematic('feature', {
        name: 'home',
        component: true,
        template: true,
        styles: true
      }),

      mergeWith(apply(url('./files/home'), [
github CanopyTax / single-spa-angular / src / schematics / ng-add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {

    const project = getClientProject(host, options);
    const path = normalize(project.workspace.root);

    const templateSource = apply(url('./_files'), [
      applyTemplates({
        atLeastAngular8: atLeastAngular8(),
        prefix: project.workspace.prefix,
        routing: options.routing,
        usingBrowserAnimationsModule: options.usingBrowserAnimationsModule,
      }),
      move(path)
    ]);
    const rule = mergeWith(templateSource, MergeStrategy.Overwrite);
    context.logger.info(`Generated 'main.single-spa.ts`);
    context.logger.info(`Generated 'single-spa-props.ts`);
    context.logger.info(`Generated asset-url.ts`);
    context.logger.info(`Generated extra-webpack.config.js`);
    return rule(host, context);
  }
}
github SAP / cloud-commerce-spartacus-storefront / projects / schematics / src / add-ssr / index.ts View on Github external
possibleProjectFiles
    );
    const templates = provideServerAndWebpackServerConfigs(options);

    return chain([
      addPackageJsonDependencies(),
      externalSchematic('@nguniversal/express-engine', 'ng-add', {
        clientProject: options.project,
      }),
      addPackageJsonScripts(options),
      addServerConfigInAngularJsonFile(options),
      modifyTSConfigServerFile(),
      modifyAppServerModuleFile(),
      modifyIndexHtmlFile(project, options),
      branchAndMerge(
        chain([mergeWith(templates, MergeStrategy.Overwrite)]),
        MergeStrategy.Overwrite
      ),
      modifyMainServerTSFile(),
      installPackageJsonDependencies(),
    ])(tree, context);
  };
}
github IgniteUI / igniteui-cli / packages / ng-schematics / src / ng-new / index.ts View on Github external
tree.rename("gitignore", ".gitignore");
						}
					},
					(tree: Tree, context: IgxSchematicContext) => {
						if (!allOptionsProvided) {
							return defer(async () => {
								prompt.setContext(context, tree, options.name as string);
								await prompt.chooseActionLoop(projLibrary);
								return tree;
							});
						}
					},
					(_tree: Tree, _context: IgxSchematicContext) => {
						return move(options.name!);
					}
				]), MergeStrategy.Overwrite
			),
			(tree: Tree, context: IgxSchematicContext) => {
				const installChain = [];
				if (!options.skipInstall) {
					const installTask = context.addTask(new NodePackageInstallTask(options.name));
					installChain.push(installTask);
				}
				if (!options.skipGit) {
					const gitTask = context.addTask(
						new RepositoryInitializerTask(options.name, { message: `Initial commit for project: ${options.name}` }),
						[...installChain] //copy
					);
					installChain.push(gitTask);
				}

				if (!options.skipInstall && !allOptionsProvided) {
github mselerin / yang-schematics / src / ng-new / index.ts View on Github external
routing: options.routing,
            style: options.style,
            skipTests: options.skipTests
        };

        const yangInitOptions: YangInitOptions = {
            name: options.name
        };

        return chain([
            mergeWith(
                apply(empty(), [
                    externalSchematic('@schematics/angular', 'ng-new', ngNewOptions),
                    schematic('init', yangInitOptions),
                    move(options.directory),
                ]), MergeStrategy.Overwrite
            ),
            (host: Tree, context: SchematicContext) => {
                let packageTask;
                if (!options.skipInstall) {
                    packageTask = context.addTask(new NodePackageInstallTask(options.directory));
                    if (options.linkCli) {
                        packageTask = context.addTask(
                            new NodePackageLinkTask('@angular/cli', options.directory),
                            [packageTask],
                        );
                    }
                }
                if (!options.skipGit) {
                    const commit = typeof options.commit == 'object'
                        ? options.commit
                        : (!!options.commit ? {} : false);
github co-IT / schematics / packages / schematics / src / jest / rules / jest / configure-jest.ts View on Github external
);
        return tree;
      }),
      mergeWith(
        apply(url(`./templates/jest`), [
          forEach(template => {
            const templatePath = config.app
              ? `${template.path}`
              : `src/${template.path}`;
            tree.exists(`${root}${templatePath}`)
              ? tree.overwrite(`${root}${templatePath}`, template.content)
              : tree.create(`${root}${templatePath}`, template.content);
            return null;
          })
        ]),
        MergeStrategy.Overwrite
      )
    ]);
  };
}