当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SchematicContext.addTask方法代码示例

本文整理汇总了TypeScript中@angular-devkit/schematics.SchematicContext.addTask方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SchematicContext.addTask方法的具体用法?TypeScript SchematicContext.addTask怎么用?TypeScript SchematicContext.addTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular-devkit/schematics.SchematicContext的用法示例。


在下文中一共展示了SchematicContext.addTask方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: return

  return (tree: Tree, context: SchematicContext) => {

    const projectTsConfigPaths = getProjectTsConfigPaths(tree);
    const tslintFixTasks: TaskId[] = [];

    if (!projectTsConfigPaths.length) {
      throw new Error('Could not find any tsconfig file. Please submit an issue on the Angular ' +
        'Material repository that includes the name of your TypeScript configuration.');
    }
    // In some applications, developers will have global stylesheets which are not specified in any
    // Angular component. Therefore we glob up all CSS and SCSS files outside of node_modules and
    // dist. The files will be read by the individual stylesheet rules and checked.
    const extraStyleFiles = globSync('!(node_modules|dist)/**/*.+(css|scss)', {absolute: true});
    const tslintConfig = createTslintConfig(targetVersion, {
      // Default options that can be overwritten if specified explicitly. e.g. if the
      // Material update schematic wants to specify a different upgrade data.
      extraStyleFiles: extraStyleFiles,
      // Custom upgrade configuration options.
      ...upgradeConfig,
    });

    for (const tsconfig of projectTsConfigPaths) {
      // Run the update tslint rules.
      tslintFixTasks.push(context.addTask(new TslintFixTask(tslintConfig, {
        silent: false,
        ignoreErrors: true,
        tsConfigPath: tsconfig,
      })));
    }

    // Delete the temporary schematics directory.
    context.addTask(new RunSchematicTask('ng-post-update', {}), tslintFixTasks);
  };
开发者ID:ozee,项目名称:material2,代码行数:33,代码来源:index.ts

示例2: return

  return (tree: Tree, context: SchematicContext) => {
    installMainPeerDependencies(tree);

    const installTaskId = context.addTask(new NodePackageInstallTask());
    const postInstallTaskId = context.addTask(new RunSchematicTask('post-install', options), [installTaskId]);
    context.addTask(new RunSchematicTask('setup', options), [postInstallTaskId]);
  };
开发者ID:kevinheader,项目名称:nebular,代码行数:7,代码来源:index.ts

示例3: NodePackageInstallTask

    (_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);

        context.addTask(
          new RepositoryInitializerTask(
            options.directory,
            commit,
          ),
          packageTask ? [packageTask] : [],
        );
      }
    },
开发者ID:fmalcher,项目名称:angular-cli,代码行数:25,代码来源:index.ts

示例4: return

  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 ]);
    context.addTask(new RunSchematicTask('bootstrap', options));
  };
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:14,代码来源:index.ts

示例5: return

  return (host: Tree, context: SchematicContext) => {

    if (host.exists('package.json')) {
      const jsonStr = host.read('package.json') !.toString('utf-8');
      const json = JSON.parse(jsonStr);

      // If there are no dependencies, create an entry for dependencies.
      const type = 'dependencies';
      if (!json[type]) {
        json[type] = {};
      }

      // If not already present, add the dependency.
      const pkg = 'document-register-element';
      const version = '^1.7.2';
      if (!json[type][pkg]) {
        json[type][pkg] = version;
      }

      // Write the JSON back to package.json
      host.overwrite('package.json', JSON.stringify(json, null, 2));
      context.logger.log('info', 'Added `document-register-element` as a dependency.');

      // Install the dependency
      context.addTask(new NodePackageInstallTask());
    }

    return host;
  };
开发者ID:DeepanParikh,项目名称:angular,代码行数:29,代码来源:index.ts

示例6: return

 return (host: Tree, context: SchematicContext) => {
   addPackageToPackageJson(host, 'dependencies', '@angular/cdk', materialVersion);
   addPackageToPackageJson(host, 'dependencies', '@angular/material', materialVersion);
   addPackageToPackageJson(host, 'dependencies', '@angular/animations', angularVersion);
   context.addTask(new NodePackageInstallTask());
   return host;
 };
开发者ID:OkBayat,项目名称:material2,代码行数:7,代码来源:index.ts

示例7: return

  return (host: Tree, context: SchematicContext) => {
    [
      {
        type: NodeDependencyType.Dev,
        name: '@angular/compiler-cli',
        version: latestVersions.Angular,
      },
      {
        type: NodeDependencyType.Dev,
        name: '@angular-devkit/build-angular',
        version: latestVersions.DevkitBuildAngular,
      },
      {
        type: NodeDependencyType.Dev,
        name: 'typescript',
        version: latestVersions.TypeScript,
      },
    ].forEach(dependency => addPackageJsonDependency(host, dependency));

    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }

    return host;
  };
开发者ID:angular,项目名称:angular-cli,代码行数:25,代码来源:index.ts

示例8: _migrateOnly

function _migrateOnly(
  info: PackageInfo | undefined,
  context: SchematicContext,
  from: string,
  to?: string,
) {
  if (!info) {
    return of<void>();
  }

  const target = info.installed;
  if (!target || !target.updateMetadata.migrations) {
    return of<void>(undefined);
  }

  const collection = (
    target.updateMetadata.migrations.match(/^[./]/)
      ? info.name + '/'
      : ''
  ) + target.updateMetadata.migrations;

  context.addTask(new RunSchematicTask('@schematics/update', 'migrate', {
      package: info.name,
      collection,
      from: from,
      to: to || target.version,
    }),
  );

  return of<void>(undefined);
}
开发者ID:iwe7,项目名称:devkit,代码行数:31,代码来源:index.ts

示例9: return

  return (tree: Tree, context: SchematicContext) => {
    // Find the closest tslint.json or tslint.yaml
    let dir: DirEntry | null = tree.getDir(path.substr(0, path.lastIndexOf('/')));

    do {
      if ((dir.subfiles as string[]).some(f => f === 'tslint.json' || f === 'tslint.yaml')) {
        break;
      }

      dir = dir.parent;
    } while (dir !== null);

    if (dir === null) {
      throw new SchematicsException(
        'Asked to run lint fixes, but could not find a tslint.json or tslint.yaml config file.');
    }

    // Only include files that have been touched.
    const files = tree.actions.reduce((acc: Set<string>, action) => {
      const path = action.path.substr(1);  // Remove the starting '/'.
      if (path.endsWith('.ts') && dir && action.path.startsWith(dir.path)) {
        acc.add(path);
      }

      return acc;
    }, new Set<string>());

    context.addTask(new TslintFixTask({
      ignoreErrors: true,
      tsConfigPath: 'tsconfig.json',
      files: [...files],
    }));
  };
开发者ID:DevIntent,项目名称:angular-cli,代码行数:33,代码来源:lint-fix.ts

示例10: return

  return (tree: Tree, context: SchematicContext) => {
    const pkgPath = '/package.json';
    const buffer = tree.read(pkgPath);
    if (buffer == null) {
      throw new SchematicsException('Could not read package.json');
    }
    const content = buffer.toString();
    const pkg = JSON.parse(content);

    if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
      throw new SchematicsException('Error reading package.json');
    }

    const dependencyCategories = ['dependencies', 'devDependencies'];

    dependencyCategories.forEach(category => {
      const packageName = `@ngrx/${name}`;

      if (pkg[category] && pkg[category][packageName]) {
        const firstChar = pkg[category][packageName][0];
        const suffix = match(firstChar, '^') || match(firstChar, '~');

        // TODO: remove beta
        pkg[category][packageName] = `${suffix}6.0.0`;
      }
    });

    tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
    context.addTask(new NodePackageInstallTask());

    return tree;
  };
开发者ID:AlexChar,项目名称:platform,代码行数:32,代码来源:update.ts


注:本文中的@angular-devkit/schematics.SchematicContext.addTask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。