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


TypeScript schematics.getProjectMainFile函数代码示例

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


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

示例1: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));
    const moduleSource = getSourceFile(host, appModulePath);

    const locale = getCompatibleLocal(options);
    const localePrefix = locale.split('_')[ 0 ];

    const recorder = host.beginUpdate(appModulePath);

    const changes = [
      insertImport(moduleSource, appModulePath, 'NZ_I18N',
        'ng-zorro-antd'),
      insertImport(moduleSource, appModulePath, locale,
        'ng-zorro-antd'),
      insertImport(moduleSource, appModulePath, 'registerLocaleData',
        '@angular/common'),
      insertImport(moduleSource, appModulePath, localePrefix,
        `@angular/common/locales/${localePrefix}`, true),
      registerLocaleData(moduleSource, appModulePath, localePrefix),
      ...insertI18nTokenProvide(moduleSource, appModulePath, locale)
    ];

    changes.forEach((change) => {
      if (change instanceof InsertChange) {
        recorder.insertLeft(change.pos, change.toAdd);
      }
    });

    host.commitUpdate(recorder);

    return host;
  };
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:34,代码来源:register-locale.ts

示例2: isImportedInMainModule

export function isImportedInMainModule(tree: Tree, project: WorkspaceProject, moduleName: string,
                                       importPath: string): boolean {
  const appModulePath = getAppModulePath(tree, getProjectMainFile(project));
  const appModuleSource = getSourceFile(tree, appModulePath) as ts.SourceFile;

  return isImported(appModuleSource, moduleName, importPath);
}
开发者ID:kevinheader,项目名称:nebular,代码行数:7,代码来源:ast.ts

示例3: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        return console.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
            `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
            `set up browser animations.`));
      }

      addModuleImportToRootModule(host, browserAnimationsModuleName,
          '@angular/platform-browser/animations', project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        '@angular/platform-browser/animations', project);
    }

    return host;
  };
开发者ID:Nodarii,项目名称:material2,代码行数:27,代码来源:setup-project.ts

示例4: return

  return (tree: Tree, context: SchematicContext) => {
    const project = getProject(tree, options.project);
    const appModulePath = getAppModulePath(tree, getProjectMainFile(project));
    const browserAnimationsModuleName = 'BrowserAnimationsModule';
    const noopAnimationsModuleName = 'NoopAnimationsModule';
    const animationsPackage = '@angular/platform-browser/animations';

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(tree, appModulePath, noopAnimationsModuleName)) {
        return context.logger.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
          `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }

      addModuleImportToRootModule(tree, browserAnimationsModuleName, animationsPackage, project);
    } else if (!hasNgModuleImport(tree, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(tree, noopAnimationsModuleName, animationsPackage, project);
    }
  }
开发者ID:kevinheader,项目名称:nebular,代码行数:25,代码来源:index.ts

示例5: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    for (const module in modulesMap) {
      addModuleImportToApptModule(host, module, modulesMap[ module ],
        project, appModulePath, options);
    }

    return host;
  };
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:12,代码来源:add-required-modules.ts

示例6: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        console.log();
        return console.log(chalk.yellow(`Could not set up "${chalk.blue(browserAnimationsModuleName)}" ` +
          `because "${chalk.blue(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }
      addModuleImportToRootModule(host, browserAnimationsModuleName,
        animationsModulePath, project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        animationsModulePath, project);
    }

    return host;
  };
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:21,代码来源:add-animations-module.ts

示例7: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const mainFile = getProjectMainFile(project);

    const recorder = host.beginUpdate(mainFile);
    const buffer = host.read(mainFile);

    if (!buffer) {
      return console.error(`Could not read the project main file (${mainFile}). Please manually ` +
        `import HammerJS in your main TypeScript file.`);
    }

    const fileContent = buffer.toString('utf8');

    if (fileContent.includes(hammerjsImportStatement)) {
      return console.log(`HammerJS is already imported in the project main file (${mainFile}).`);
    }

    recorder.insertRight(0, `${hammerjsImportStatement}\n`);
    host.commitUpdate(recorder);
  };
开发者ID:Nodarii,项目名称:material2,代码行数:22,代码来源:hammerjs-import.ts


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