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


TypeScript schematics.url函数代码示例

本文整理汇总了TypeScript中@angular-devkit/schematics.url函数的典型用法代码示例。如果您正苦于以下问题:TypeScript url函数的具体用法?TypeScript url怎么用?TypeScript url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: async

  return async (host: Tree) => {
    const appProject = options.relatedAppName;
    const workspace = await getWorkspace(host);
    const project = workspace.projects.get(appProject);
    if (!project) {
      throw new SchematicsException(`Project name "${appProject}" doesn't not exist.`);
    }

    const root = join(normalize(project.root), 'e2e');

    project.targets.add({
      name: 'e2e',
      builder: Builders.Protractor,
      options: {
        protractorConfig: `${root}/protractor.conf.js`,
        devServerTarget: `${options.relatedAppName}:serve`,
      },
      configurations: {
        production: {
          devServerTarget: `${options.relatedAppName}:serve:production`,
        },
      },
    });

    const lintTarget = project.targets.get('lint');
    if (lintTarget && lintTarget.options && Array.isArray(lintTarget.options.tsConfig)) {
      lintTarget.options.tsConfig =
        lintTarget.options.tsConfig.concat(`${root}/tsconfig.json`);
    }

    return chain([
      updateWorkspace(workspace),
      mergeWith(
        apply(url('./files'), [
          applyTemplates({
            utils: strings,
            ...options,
            relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(root),
          }),
          move(root),
        ])),
    ]);
  };
开发者ID:angular,项目名称:angular-cli,代码行数:43,代码来源:index.ts

示例2: return

  return (host: Tree, context: SchematicContext) => {
    if (!options.name) {
      throw new SchematicsException(`Invalid options, "name" is required.`);
    }
    validateProjectName(options.name);
    let newProjectRoot = '';
    try {
      const workspace = getWorkspace(host);
      newProjectRoot = workspace.newProjectRoot || '';
    } catch {
    }
    const appDir = `${newProjectRoot}/${options.name}`;

    // If the project already has some deps installed, Bazel should use existing
    // versions.
    const existingVersions = {
      Angular: findVersion(options.name, '@angular/core', host),
      RxJs: findVersion(options.name, 'rxjs', host),
    };

    Object.keys(existingVersions).forEach((name: 'Angular' | 'RxJs') => {
      const version = existingVersions[name] as string;
      if (version) {
        context.logger.info(`Bazel will reuse existing version for ${name}: ${version}`);
      }
    });

    const workspaceVersions = {
      'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
      'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
      // TODO(kyliau): Consider moving this to latest-versions.ts
      'RULES_SASS_VERSION': '1.15.1',
    };

    return mergeWith(apply(url('./files'), [
      applyTemplates({
        utils: strings,
        ...options,
        'dot': '.', ...workspaceVersions,
      }),
      move(appDir),
    ]));
  };
开发者ID:cyrilletuzi,项目名称:angular,代码行数:43,代码来源:index.ts

示例3: function

export default function (options: Schema): Rule {
  const path = 'packages/'
    + options.name
             .replace(/^@/, '')
             .replace(/-/g, '_');

  // Verify if we need to create a full project, or just add a new schematic.
  const source = apply(url('./project-files'), [
    template({
      ...options as object,
      dot: '.',
      path,
    }),
  ]);

  return chain([
    mergeWith(source),
    addPackageToMonorepo(options, path),
  ]);
}
开发者ID:DevIntent,项目名称:angular-cli,代码行数:20,代码来源:factory.ts

示例4: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    if (!options.project) {
      throw new SchematicsException('Option (project) is required.');
    }
    const project = workspace.projects[options.project];

    if (options.path === undefined) {
      options.path = buildDefaultPath(project);
    }

    options.module = findModuleFromOptions(host, options);

    const parsedPath = parseName(options.path, options.name);
    options.name = parsedPath.name;
    options.path = parsedPath.path;
    options.selector = options.selector || buildSelector(options, project.prefix);

    validateName(options.name);
    validateHtmlSelector(options.selector);

    const templateSource = apply(url('./files'), [
      options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
      options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),
      options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
      template({
        ...strings,
        'if-flat': (s: string) => options.flat ? '' : s,
        ...options,
      }),
      move(parsedPath.path),
    ]);

    return chain([
      branchAndMerge(chain([
        addDeclarationToNgModule(options),
        mergeWith(templateSource),
      ])),
      options.lintFix ? applyLintFix(options.path) : noop(),
    ]);
  };
开发者ID:rexebin,项目名称:angular-cli,代码行数:41,代码来源:index.ts

示例5: return

  return (host: Tree, context: SchematicContext) => {
    const name = options.name || getWorkspace(host).defaultProject;
    if (!name) {
      throw new Error('Please provide a name for Bazel workspace');
    }
    validateProjectName(name);

    // If the project already has some deps installed, Bazel should use existing
    // versions.
    const existingVersions = {
      Angular: findVersion('@angular/core', host),
      RxJs: findVersion('rxjs', host),
    };

    Object.keys(existingVersions).forEach((name: 'Angular' | 'RxJs') => {
      const version = existingVersions[name] as string;
      if (version) {
        context.logger.info(`Bazel will reuse existing version for ${name}: ${version}`);
      }
    });

    const workspaceVersions = {
      'RULES_NODEJS_VERSION': '0.16.5',
      'RULES_TYPESCRIPT_VERSION': '0.22.1',
      'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
      'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
      // TODO(kyliau): Consider moving this to latest-versions.ts
      'RULES_SASS_VERSION': '1.15.1',
    };

    return mergeWith(apply(url('./files'), [
      applyTemplates({
        utils: strings,
        name,
        'dot': '.', ...workspaceVersions,
        routing: hasRoutingModule(host),
        sass: hasSassStylesheet(host),
      }),
    ]));
  };
开发者ID:matsko,项目名称:angular,代码行数:40,代码来源:index.ts

示例6: return

  return (host: Tree, context: SchematicContext) => {
    if (options.module) {
      options.module = findModuleFromOptions(host, options);
    }

    const templateSource = apply(url('./files'), [
      options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')),
      template({
        ...stringUtils,
        'if-flat': (s: string) =>
          stringUtils.group(
            options.flat ? '' : s,
            options.group ? 'reducers' : ''
          ),
        ...(options as object),
        dot: () => '.',
      }),
      move(sourceDir),
    ]);

    return chain([
      branchAndMerge(
        chain([
          filter(path => !path.includes('node_modules')),
          addReducerToState(options),
        ])
      ),
      branchAndMerge(
        chain([
          filter(
            path =>
              path.endsWith('.module.ts') &&
              !path.endsWith('-routing.module.ts')
          ),
          addReducerImportToNgModule(options),
          mergeWith(templateSource),
        ])
      ),
    ])(host, context);
  };
开发者ID:WinGood,项目名称:platform,代码行数:40,代码来源:index.ts

示例7: return

  return (host: Tree) => {
    validateProjectName(options.name);

    const workspace = getWorkspace(host);
    const appDir = options.projectRoot !== undefined
      ? options.projectRoot
      : `${workspace.newProjectRoot}/${options.name}`;

    return chain([
      addAppToWorkspaceFile(options, workspace),
      mergeWith(
        apply(url('./files'), [
          template({
            utils: strings,
            ...options,
            'dot': '.',
            appDir,
          }),
          move(appDir),
        ])),
    ]);
  };
开发者ID:DevIntent,项目名称:angular-cli,代码行数:22,代码来源:index.ts


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