How to use the @angular-devkit/schematics/tasks.RunSchematicTask 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 manfredsteyer / ngx-build-plus / lib / schematics / externals / index.ts View on Github external
function updateScripts(path: string, config: any, tree: Tree, _options: any, _context: SchematicContext) {
  const project = getProject(tree, _options);
  
  if (!config['scripts']) {
    config.scripts = {};
  }

  let additionalFlags = '';

  // Ivy support
  const postInstall: string = config.scripts['postinstall'] || '';
  if (postInstall.startsWith('ngcc')) {
    config.scripts['postinstall:bak'] = postInstall;
    config.scripts['postinstall'] = 'ngcc';

    _context.addTask(new RunSchematicTask('npmRun', {script: 'postinstall'}));
  } 

  if (!_options.host) {
    // external web components need single bundle 
    additionalFlags = '--single-bundle';
  }

  // Heuristic for default project
  if (!project.root) {
    config.scripts['build:externals'] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod ${additionalFlags}`;
  }

  if (_options.project) {
    config.scripts[`build:${_options.project}:externals`] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod --project ${_options.project} ${additionalFlags}`;
  }
}
github ionic-team / capacitor / capacitor-angular-toolkit / schematics / add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    const packageInstall = context.addTask(new NodePackageInstallTask());
    context.addTask(new RunSchematicTask('cap-init', { command: 'npx', args: ['cap', 'init', projectName, '--npm-client', npmTool, '--web-dir', webDir] }), [packageInstall]);
    return host;
  };
}
github IgniteUI / igniteui-cli / packages / ng-schematics / src / ng-new / index.ts View on Github external
(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) {
					context.addTask(new RunSchematicTask("start", { directory: options.name }), installChain);
				}
				return tree;
			}
		]);
github scullyio / scully / schematics / scully / src / ng-add / index.ts View on Github external
nextRules.push((tree: Tree, context: SchematicContext) => {
      const installTaskId = context.addTask(new NodePackageInstallTask());
      context.addTask(new RunSchematicTask('scully', options), [installTaskId]);
    });
github Tibing / nyan-builder / projects / nyan-builder / schematics / ng-add / index.ts View on Github external
return (tree: Tree, context: SchematicContext) => {
    const v = version();
    const angularCoreVersion = getPeerDependencyVersionFromPackageJson('@angular/core');
    const angularCdkVersion = getPeerDependencyVersionFromPackageJson('@angular/cdk');

    addDevDependencyToPackageJson(tree, 'nyan-builder', v);
    addDevDependencyToPackageJson(tree, '@angular/cdk', angularCdkVersion);
    addDevDependencyToPackageJson(tree, '@schematics/angular', angularCoreVersion);

    const installTaskId = context.addTask(new NodePackageInstallTask());
    context.addTask(new RunSchematicTask('setup', options), [installTaskId]);
  };
}
github nrwl / nx / packages / angular / src / migrations / update-9-0-0 / update-9-0-0.ts View on Github external
return (_, context: SchematicContext) => {
    const postInstallTask = context.addTask(
      new RunSchematicTask(
        join(__dirname, '../../../migrations.json'),
        'add-postinstall',
        {}
      )
    );
    return chain([
      addUpdateTask('@angular/core', '9.0.0-rc.4', [postInstallTask]),
      addUpdateTask('@angular/cli', '9.0.0-rc.4', [postInstallTask])
    ])
  };
}
github Alorel / ngforage / projects / ngforage / schematics / ng-add / index.ts View on Github external
return (tree, context) => {
    const pkgJson = require('../../package.json');

    const taskDeps: TaskId[] = [];
    const addedLocalforage = addToPackageJson(tree, 'localforage', pkgJson.peerDependencies.localforage);
    const hasNgforage = hasDependency(tree, 'ngforage');
    if (addedLocalforage || !hasNgforage) {
      taskDeps.push(context.addTask(new NodePackageInstallTask()));
    }

    context.addTask(new RunSchematicTask('ng-add-setup-project', options), taskDeps);
  };
}
github rxweb / rxweb / rxweb.io / node_modules / @schematics / update / update / index.js View on Github external
function _migrateOnly(info, context, from, to) {
    if (!info) {
        return rxjs_1.of();
    }
    const target = info.installed;
    if (!target || !target.updateMetadata.migrations) {
        return rxjs_1.of(undefined);
    }
    const collection = (target.updateMetadata.migrations.match(/^[./]/)
        ? info.name + '/'
        : '') + target.updateMetadata.migrations;
    context.addTask(new tasks_1.RunSchematicTask('@schematics/update', 'migrate', {
        package: info.name,
        collection,
        from: from,
        to: to || target.version,
    }));
    return rxjs_1.of(undefined);
}
function _getUpdateMetadata(packageJson, logger) {
github johandb / svg-drawing-tool / node_modules / @schematics / update / update / index.js View on Github external
function _migrateOnly(info, context, from, to) {
    if (!info) {
        return rxjs_1.of();
    }
    const target = info.installed;
    if (!target || !target.updateMetadata.migrations) {
        return rxjs_1.of(undefined);
    }
    const collection = (target.updateMetadata.migrations.match(/^[./]/)
        ? info.name + '/'
        : '') + target.updateMetadata.migrations;
    context.addTask(new tasks_1.RunSchematicTask('@schematics/update', 'migrate', {
        package: info.name,
        collection,
        from: from,
        to: to || target.version,
    }));
    return rxjs_1.of(undefined);
}
function _getUpdateMetadata(packageJson, logger) {
github NG-ZORRO / ng-zorro-antd / schematics / ng-add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    if (!options.skipPackageJson) {
      addPackageToPackageJson(host, 'ng-zorro-antd', zorroVersion);
      if (options.gestures) {
        addPackageToPackageJson(host, 'hammerjs', hammerjsVersion);
      }
    }

    const installTaskId = context.addTask(new NodePackageInstallTask());

    context.addTask(new RunSchematicTask('ng-add-setup-project', options), [installTaskId]);

    if (options.template) {
      const workspace = getWorkspace(host);
      const project = getProjectFromWorkspace(workspace, options.project);
      const style = getProjectStyle(project);
      context.addTask(new RunSchematicTask(options.template, {...options, style: style}));
    }

  };
}