Example #1
0
export function getPackageVersionFromPackageJson(tree: Tree, name: string): string | null {
  if (!tree.exists('package.json')) {
    return null;
  }

  const packageJson = JSON.parse(tree.read('package.json')!.toString('utf8'));

  if (packageJson.dependencies && packageJson.dependencies[name]) {
    return packageJson.dependencies[name];
  }

  return null;
}
Example #2
0
/**
 * Look for package.json file for package with `packageName` in node_modules and
 * extract its version.
 */
function findVersion(packageName: string, host: Tree): string|null {
  const candidate = `node_modules/${packageName}/package.json`;
  if (host.exists(candidate)) {
    try {
      const packageJson = JSON.parse(host.read(candidate).toString());
      if (packageJson.name === packageName && packageJson.version) {
        return packageJson.version;
      }
    } catch {
    }
  }
  return null;
}
Example #3
0
function envConfig(host: Tree, options: PluginOptions) {
  const defEnvPath = `${options.sourceRoot}/environments/environment.ts`;
  const defContent = host.get(defEnvPath).content;
  if (!host.exists(defEnvPath)) return ;
  // 1. update default env file
  addValueToVariable(host, defEnvPath, 'environment', 'hmr: false');
  // 2. update prod env file
  addValueToVariable(host, `${options.sourceRoot}/environments/environment.prod.ts`, 'environment', 'hmr: false');
  // 3. copy default env file to hmr file
  const hmrEnvPath = `${options.sourceRoot}/environments/environment.hmr.ts`;
  host.create(hmrEnvPath, defContent);
  addValueToVariable(host, hmrEnvPath, 'environment', 'hmr: true');
}
Example #4
0
File: index.ts Project: iwe7/devkit
  return (host: Tree) => {
    if (!host.exists('tsconfig.json')) { return host; }

    return updateJsonFile(host, 'tsconfig.json', (tsconfig: TsConfigPartialType) => {
      if (!tsconfig.compilerOptions.paths) {
        tsconfig.compilerOptions.paths = {};
      }
      if (!tsconfig.compilerOptions.paths[npmPackageName]) {
        tsconfig.compilerOptions.paths[npmPackageName] = [];
      }
      tsconfig.compilerOptions.paths[npmPackageName].push(`dist/${npmPackageName}`);
    });
  };
Example #5
0
export function getDependencyVersionFromPackageJson(tree: Tree, packageName: string): string {
  if (!tree.exists(packageJsonName)) {
    throwNoPackageJsonError();
  }

  const packageJson: PackageJson = readJSON(tree, packageJsonName);

  if (noInfoAboutDependency(packageJson, packageName)) {
    throwNoPackageInfoInPackageJson(packageName);
  }

  return packageJson.dependencies[packageName];
}
Example #6
0
function createHost(tree: Tree): workspaces.WorkspaceHost {
  return {
    async readFile(path: string): Promise<string> {
      const data = tree.read(path);
      if (!data) {
        throw new Error('File not found.');
      }

      return virtualFs.fileBufferToString(data);
    },
    async writeFile(path: string, data: string): Promise<void> {
      return tree.overwrite(path, data);
    },
    async isDirectory(path: string): Promise<boolean> {
      // approximate a directory check
      return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
    },
    async isFile(path: string): Promise<boolean> {
      return tree.exists(path);
    },
  };
}
Example #7
0
export function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {
  if (options.hasOwnProperty('skipImport') && options.skipImport) {
    return undefined;
  }

  const moduleExt = options.moduleExt || MODULE_EXT;
  const routingModuleExt = options.routingModuleExt || ROUTING_MODULE_EXT;

  if (!options.module) {
    const pathToCheck = (options.path || '')
      + (options.flat ? '' : '/' + strings.dasherize(options.name));

    return normalize(findModule(host, pathToCheck, moduleExt, routingModuleExt));
  } else {
    const modulePath = normalize(`/${options.path}/${options.module}`);
    const componentPath = normalize(`/${options.path}/${options.name}`);
    const moduleBaseName = normalize(modulePath).split('/').pop();

    const candidateSet = new Set<Path>([
      normalize(options.path || '/'),
    ]);

    for (let dir = modulePath; dir != NormalizedRoot; dir = dirname(dir)) {
      candidateSet.add(dir);
    }
    for (let dir = componentPath; dir != NormalizedRoot; dir = dirname(dir)) {
      candidateSet.add(dir);
    }

    const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
    for (const c of candidatesDirs) {
      const candidateFiles = [
        '',
        `${moduleBaseName}.ts`,
        `${moduleBaseName}${moduleExt}`,
      ].map(x => join(c, x));

      for (const sc of candidateFiles) {
        if (host.exists(sc)) {
          return normalize(sc);
        }
      }
    }

    throw new Error(
      `Specified module '${options.module}' does not exist.\n`
        + `Looked in the following directories:\n    ${candidatesDirs.join('\n    ')}`,
    );
  }
}
Example #8
0
  return (tree: Tree) => {
    const project = getProject(tree, options.project);
    const stylesPath: string = getProjectStyleFile(project, 'scss') as string;

    if (!tree.exists(stylesPath)) {
      throwSCSSRequiredForCustomizableThemes();
    }

    createThemeSCSS(tree, options.theme, project.sourceRoot as string);
    insertThemeImportInStyles(tree, stylesPath);


    return tree;
  }
Example #9
0
  return (host: Tree, context: SchematicContext) => {
    if (host.exists(npmrc)) {
      host.delete(npmrc);
    }

    if (options.type === 'remove') {
      return ;
    }

    host.create(npmrc, `sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org`);
  };
Example #10
0
  return (host: Tree) => {
    const tsLintPath = '/tslint.json';
    if (!host.exists(tsLintPath)) {
      return;
    }

    const rootTslintConfig = readTsLintConfig(parentHost, tsLintPath);
    const appTslintConfig = readTsLintConfig(host, tsLintPath);

    const recorder = host.beginUpdate(tsLintPath);
    rootTslintConfig.properties.forEach(prop => {
      if (findPropertyInAstObject(appTslintConfig, prop.key.value)) {
        // property already exists. Skip!
        return;
      }

      insertPropertyInAstObjectInOrder(
        recorder,
        appTslintConfig,
        prop.key.value,
        prop.value.value,
        2,
      );
    });

    const rootRules = findPropertyInAstObject(rootTslintConfig, 'rules');
    const appRules = findPropertyInAstObject(appTslintConfig, 'rules');

    if (!appRules || appRules.kind !== 'object' || !rootRules || rootRules.kind !== 'object') {
      // rules are not valid. Skip!
      return;
    }

    rootRules.properties.forEach(prop => {
      insertPropertyInAstObjectInOrder(
        recorder,
        appRules,
        prop.key.value,
        prop.value.value,
        4,
      );
    });

    host.commitUpdate(recorder);

    // this shouldn't be needed but at the moment without this formatting is not correct.
    const content = readTsLintConfig(host, tsLintPath);
    host.overwrite(tsLintPath, JSON.stringify(content.value, undefined, 2));
  };
Example #11
0
 return (host: Tree) => {
   const gitignore = '/.gitignore';
   if (!host.exists(gitignore)) {
     return host;
   }
   const gitIgnoreContent = host.read(gitignore).toString();
   if (gitIgnoreContent.includes('\n/bazel-out\n')) {
     return host;
   }
   const compiledOutput = '# compiled output\n';
   const index = gitIgnoreContent.indexOf(compiledOutput);
   const insertionIndex = index >= 0 ? index + compiledOutput.length : gitIgnoreContent.length;
   const recorder = host.beginUpdate(gitignore);
   recorder.insertRight(insertionIndex, '/bazel-out\n');
   host.commitUpdate(recorder);
   return host;
 };
Example #12
0
export function addPackageToPackageJson(host: Tree, type: string, pkg: string, version: string) {
  if (host.exists('package.json')) {
    const sourceText = host.read('package.json')!.toString('utf-8');
    const json = JSON.parse(sourceText);
    if (!json[type]) {
      json[type] = {};
    }

    if (!json[type][pkg]) {
      json[type][pkg] = version;
    }

    host.overwrite('package.json', JSON.stringify(json, null, 2));
  }

  return host;
}
Example #13
0
  return (host: Tree) => {
    const packageJson = 'package.json';
    if (!host.exists(packageJson)) {
      throw new Error(`Could not find ${packageJson}`);
    }
    const packageJsonContent = host.read(packageJson);
    if (!packageJsonContent) {
      throw new Error('Failed to read package.json content');
    }
    const jsonAst = parseJsonAst(packageJsonContent.toString()) as JsonAstObject;
    const deps = findPropertyInAstObject(jsonAst, 'dependencies') as JsonAstObject;
    const devDeps = findPropertyInAstObject(jsonAst, 'devDependencies') as JsonAstObject;

    const angularCoreNode = findPropertyInAstObject(deps, '@angular/core');
    if (!angularCoreNode) {
      throw new Error('@angular/core dependency not found in package.json');
    }
    const angularCoreVersion = angularCoreNode.value as string;

    const devDependencies: {[k: string]: string} = {
      '@angular/bazel': angularCoreVersion,
      '@bazel/bazel': '^0.24.0',
      '@bazel/ibazel': '^0.10.1',
      '@bazel/karma': '0.27.12',
      '@bazel/typescript': '0.27.12',
    };

    const recorder = host.beginUpdate(packageJson);
    for (const packageName of Object.keys(devDependencies)) {
      const existingDep = findPropertyInAstObject(deps, packageName);
      if (existingDep) {
        const content = packageJsonContent.toString();
        removeKeyValueInAstObject(recorder, content, deps, packageName);
      }
      const version = devDependencies[packageName];
      const indent = 4;
      if (findPropertyInAstObject(devDeps, packageName)) {
        replacePropertyInAstObject(recorder, devDeps, packageName, version, indent);
      } else {
        insertPropertyInAstObjectInOrder(recorder, devDeps, packageName, version, indent);
      }
    }
    host.commitUpdate(recorder);
    return host;
  };
Example #14
0
export function addDevDependencyToPackageJson(tree: Tree, packageName: string, packageVersion: string) {
  if (!tree.exists(packageJsonName)) {
    throwNoPackageJsonError();
  }

  const packageJson: PackageJson = readJSON(tree, packageJsonName);

  if (!packageJson.devDependencies) {
    packageJson.devDependencies = {};
  }

  if (!packageJson.devDependencies[packageName]) {
    packageJson.devDependencies[packageName] = packageVersion;
    packageJson.devDependencies = sortObjectByKeys(packageJson.devDependencies);
  }

  writeJSON(tree, packageJsonName, packageJson);
}
Example #15
0
  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}`);
      }
    });

    if (!host.exists('yarn.lock')) {
      host.create('yarn.lock', '');
    }

    const workspaceVersions = {
      'RULES_NODEJS_VERSION': '0.18.6',
      'RULES_NODEJS_SHA256': '1416d03823fed624b49a0abbd9979f7c63bbedfd37890ddecedd2fe25cccebc6',
      '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.17.0',
    };

    return mergeWith(apply(url('./files'), [
      applyTemplates({
        utils: strings,
        name,
        'dot': '.', ...workspaceVersions,
        routing: hasRoutingModule(host),
        sass: hasSassStylesheet(host),
      }),
    ]));
  };
Example #16
0
/**
 * Look for package.json file for @angular/core in node_modules and extract its
 * version.
 */
function findAngularVersion(options: BazelWorkspaceOptions, host: Tree): string|null {
  // Need to look in multiple locations because we could be working in a subtree.
  const candidates = [
    'node_modules/@angular/core/package.json',
    `${options.name}/node_modules/@angular/core/package.json`,
  ];
  for (const candidate of candidates) {
    if (host.exists(candidate)) {
      try {
        const packageJson = JSON.parse(host.read(candidate).toString());
        if (packageJson.name === '@angular/core' && packageJson.version) {
          return packageJson.version;
        }
      } catch {
      }
    }
  }
  return null;
}
Example #17
0
/**
 * Look for package.json file for package with `packageName` in node_modules and
 * extract its version.
 */
function findVersion(projectName: string, packageName: string, host: Tree): string|null {
  // Need to look in multiple locations because we could be working in a subtree.
  const candidates = [
    `node_modules/${packageName}/package.json`,
    `${projectName}/node_modules/${packageName}/package.json`,
  ];
  for (const candidate of candidates) {
    if (host.exists(candidate)) {
      try {
        const packageJson = JSON.parse(host.read(candidate).toString());
        if (packageJson.name === packageName && packageJson.version) {
          return packageJson.version;
        }
      } catch {
      }
    }
  }
  return null;
}
Example #18
0
function enablePolyfills(tree: Tree, context: SchematicContext): string {
  const targetFile = 'src/polyfills.ts';
  if (!tree.exists(targetFile)) {
    context.logger.warn(`${targetFile} not found. You may need to update polyfills.ts manually.`);
    return;
  }

  // Match all commented import statements that are core-js/es6/*
  const pattern = /\/{2}\s{0,}(import\s{0,}\'core\-js\/es6\/.+)/;
  let polyfillsData = tree.read(targetFile).toString();
  if (pattern.test(polyfillsData)) {
    let result: any;
    while (result = pattern.exec(polyfillsData)) {
      polyfillsData = polyfillsData.replace(result[0], result[1]);
    }
  }

  return polyfillsData;
}
Example #19
0
export function addPackageToPackageJson(host: Tree, pkg: string, version: string): Tree {

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

    if (!json.dependencies) {
      json.dependencies = {};
    }

    if (!json.dependencies[pkg]) {
      json.dependencies[pkg] = version;
      json.dependencies = sortObjectByKeys(json.dependencies);
    }

    host.overwrite('package.json', JSON.stringify(json, null, 2));
  }

  return host;
}
Example #20
0
  return (host: Tree) => {
    if (!host.exists('tsconfig.json')) { return host; }

    return updateJsonFile(host, 'tsconfig.json', (tsconfig: TsConfigPartialType) => {
      if (!tsconfig.compilerOptions.paths) {
        tsconfig.compilerOptions.paths = {};
      }
      if (!tsconfig.compilerOptions.paths[packageName]) {
        tsconfig.compilerOptions.paths[packageName] = [];
      }
      tsconfig.compilerOptions.paths[packageName].push(distRoot);

      // deep import & secondary entrypoint support
      const deepPackagePath = packageName + '/*';
      if (!tsconfig.compilerOptions.paths[deepPackagePath]) {
        tsconfig.compilerOptions.paths[deepPackagePath] = [];
      }
      tsconfig.compilerOptions.paths[deepPackagePath].push(distRoot + '/*');
    });
  };
Example #21
0
  return (host: Tree) => {
    const gitignore = `${options.name}/.gitignore`;
    if (!host.exists(gitignore)) {
      return host;
    }
    const gitIgnoreContent = host.read(gitignore);
    if (!gitIgnoreContent) {
      throw new Error('Failed to read .gitignore content');
    }

    if (gitIgnoreContent.includes('/bazel-out\n')) {
      return host;
    }
    const lines = gitIgnoreContent.toString().split(/\n/g);
    const recorder = host.beginUpdate(gitignore);
    const compileOutput = lines.findIndex((line: string) => line === '# compiled output');
    recorder.insertRight(compileOutput, '\n/bazel-out');
    host.commitUpdate(recorder);

    return host;
  };
Example #22
0
File: file.ts Project: wexz/delon
export function overwriteFile(
  host: Tree,
  filePath: string,
  sourcePath?: string,
  overwrite = false,
): Tree {
  const isExists = host.exists(filePath);
  if (overwrite || isExists) {
    try {
      const buffer = fs.readFileSync(sourcePath);
      const content = buffer ? buffer.toString('utf-8') : '';
      if (overwrite) {
        if (isExists) {
          host.delete(filePath);
        }
        host.create(filePath, content);
      } else {
        host.overwrite(filePath, content);
      }
    } catch {}
  }
  return host;
}
Example #23
0
 return (host: Tree, context: SchematicContext) => {
   const packageJson = 'package.json';
   if (!host.exists(packageJson)) {
     throw new Error(`Could not find ${packageJson}`);
   }
   const content = host.read(packageJson);
   if (!content) {
     throw new Error('Failed to read package.json content');
   }
   const jsonAst = parseJsonAst(content.toString());
   if (!isJsonAstObject(jsonAst)) {
     throw new Error(`Failed to parse JSON for ${packageJson}`);
   }
   const deps = findPropertyInAstObject(jsonAst, 'dependencies');
   if (!isJsonAstObject(deps)) {
     throw new Error(`Failed to find dependencies in ${packageJson}`);
   }
   const rxjs = findPropertyInAstObject(deps, 'rxjs');
   if (!rxjs) {
     throw new Error(`Failed to find rxjs in dependencies of ${packageJson}`);
   }
   const value = rxjs.value as string;  // value can be version or range
   const match = value.match(/(\d)+\.(\d)+.(\d)+$/);
   if (match) {
     const [_, major, minor] = match;
     if (major < '6' || (major === '6' && minor < '4')) {
       const recorder = host.beginUpdate(packageJson);
       replacePropertyInAstObject(recorder, deps, 'rxjs', '~6.4.0');
       host.commitUpdate(recorder);
     }
   } else {
     context.logger.info(
         'Could not determine version of rxjs. \n' +
         'Please make sure that version is at least 6.4.0.');
   }
   return host;
 };
Example #24
0
  return (host: Tree) => {
    const packageJson = 'package.json';
    if (!host.exists(packageJson)) {
      throw new Error(`Could not find ${packageJson}`);
    }
    const packageJsonContent = host.read(packageJson);
    if (!packageJsonContent) {
      throw new Error('Failed to read package.json content');
    }
    const jsonAst = parseJsonAst(packageJsonContent.toString()) as JsonAstObject;
    const deps = findPropertyInAstObject(jsonAst, 'dependencies') as JsonAstObject;
    const devDeps = findPropertyInAstObject(jsonAst, 'devDependencies') as JsonAstObject;

    const angularCoreNode = findPropertyInAstObject(deps, '@angular/core');
    if (!angularCoreNode) {
      throw new Error('@angular/core dependency not found in package.json');
    }
    const angularCoreVersion = angularCoreNode.value as string;

    const devDependencies: {[k: string]: string} = {
      '@angular/bazel': angularCoreVersion,
      // TODO(kyliau): Consider moving this to latest-versions.ts
      '@bazel/bazel': '^0.22.1',
      '@bazel/ibazel': '^0.9.0',
      '@bazel/karma': '^0.23.2',
      '@bazel/typescript': '^0.23.2',
    };

    const recorder = host.beginUpdate(packageJson);
    for (const packageName of Object.keys(devDependencies)) {
      const version = devDependencies[packageName];
      const indent = 4;
      insertPropertyInAstObjectInOrder(recorder, devDeps, packageName, version, indent);
    }
    host.commitUpdate(recorder);
    return host;
  };
Example #25
0
  return (host: Tree, context: SchematicContext) => {
    const {name} = options;
    const workspacePath = `${name}/angular.json`;
    if (!host.exists(workspacePath)) {
      throw new SchematicsException(`Workspace file ${workspacePath} not found.`);
    }
    const workspaceBuffer = host.read(workspacePath) !;
    const workspaceJsonAst = parseJsonAst(workspaceBuffer.toString()) as JsonAstObject;
    const projects = findPropertyInAstObject(workspaceJsonAst, 'projects');
    if (!projects) {
      throw new SchematicsException('Expect projects in angular.json to be an Object');
    }
    const project = findPropertyInAstObject(projects as JsonAstObject, name);
    if (!project) {
      throw new SchematicsException(`Expected projects to contain ${name}`);
    }
    const recorder = host.beginUpdate(workspacePath);
    const indent = 6;
    replacePropertyInAstObject(
        recorder, project as JsonAstObject, 'architect', {
          'build': {
            'builder': '@angular/bazel:build',
            'options': {'targetLabel': '//src:bundle.js', 'bazelCommand': 'build'},
            'configurations': {'production': {'targetLabel': '//src:bundle'}}
          },
          'serve': {
            'builder': '@angular/bazel:build',
            'options': {'targetLabel': '//src:devserver', 'bazelCommand': 'run'},
            'configurations': {'production': {'targetLabel': '//src:prodserver'}}
          },
          'extract-i18n': {
            'builder': '@angular-devkit/build-angular:extract-i18n',
            'options': {'browserTarget': `${name}:build`}
          },
          'test': {
            'builder': '@angular/bazel:build',
            'options': {'bazelCommand': 'test', 'targetLabel': '//src/...'}
          },
          'lint': {
            'builder': '@angular-devkit/build-angular:tslint',
            'options': {
              'tsConfig': ['src/tsconfig.app.json', 'src/tsconfig.spec.json'],
              'exclude': ['**/node_modules/**']
            }
          }
        },
        indent);

    const e2e = `${options.name}-e2e`;
    const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e);
    if (e2eNode) {
      replacePropertyInAstObject(
          recorder, e2eNode as JsonAstObject, 'architect', {
            'e2e': {
              'builder': '@angular/bazel:build',
              'options': {'bazelCommand': 'test', 'targetLabel': '//e2e:devserver_test'},
              'configurations': {'production': {'targetLabel': '//e2e:prodserver_test'}}
            },
            'lint': {
              'builder': '@angular-devkit/build-angular:tslint',
              'options': {'tsConfig': 'e2e/tsconfig.e2e.json', 'exclude': ['**/node_modules/**']}
            }
          },
          indent);
    }

    host.commitUpdate(recorder);
    return host;
  };
Example #26
0
 const path = possibleFiles.filter(path => host.exists(path))[0];
Example #27
0
File: index.ts Project: wexz/delon
 .filter(p => host.exists(p))
Example #28
0
File: index.ts Project: wexz/delon
 return (host: Tree, context: SchematicContext) => {
   const json = getPackage(host);
   if (json == null) return host;
   json.scripts['lint'] = `npm run lint:ts && npm run lint:style`;
   json.scripts[
     'lint:ts'
   ] = `tslint -p src/tsconfig.app.json -c tslint.json 'src/**/*.ts'`;
   json.scripts['lint:style'] = `stylelint \"{src}/**/*.less\" --syntax less`;
   json.scripts['lint-staged'] = `lint-staged`;
   json.scripts['tslint-check'] = `tslint-config-prettier-check ./tslint.json`;
   json['lint-staged'] = {
     '*.{cmd,html,json,md,sh,txt,xml,yml}': [
       'editorconfig-tools fix',
       'git add',
     ],
     '*.ts': ['npm run lint:ts', 'prettier --write', 'git add'],
     '*.less': ['npm run lint:style', 'prettier --write', 'git add'],
   };
   overwritePackage(host, json);
   // tslint
   const tsLint = getJSON(host, 'tslint.json', 'rules');
   tsLint.rules['curly'] = false;
   tsLint.rules['use-host-property-decorator'] = false;
   tsLint.rules['directive-selector'] = [
     true,
     'attribute',
     [projectPrefix, 'passport', 'exception', 'layout', 'header'],
     'camelCase',
   ];
   tsLint.rules['component-selector'] = [
     true,
     'element',
     [projectPrefix, 'passport', 'exception', 'layout', 'header'],
     'kebab-case',
   ];
   overwriteJSON(host, 'tslint.json', tsLint);
   // app tslint
   const sourceTslint = `${appSourceRoot}/tslint.json`;
   if (host.exists(sourceTslint)) {
     const appTsLint = getJSON(host, sourceTslint, 'rules');
     appTsLint.rules['directive-selector'] = [
       true,
       'attribute',
       [projectPrefix, 'passport', 'exception', 'layout', 'header'],
       'camelCase',
     ];
     appTsLint.rules['component-selector'] = [
       true,
       'element',
       [projectPrefix, 'passport', 'exception', 'layout', 'header'],
       'kebab-case',
     ];
     overwriteJSON(host, sourceTslint, appTsLint);
   }
   // dependencies
   addPackageToPackageJson(host, [
     `tslint-config-prettier@^1.12.0`,
     `tslint-language-service@^0.9.9`,
     `editorconfig-tools@^0.1.1`,
     `lint-staged@^7.1.2`,
     `husky@^0.14.3`,
     `prettier@^1.12.1`,
     `prettier-stylelint@^0.4.2`,
     `stylelint@^9.2.0`,
     `stylelint-config-standard@^18.2.0`,
   ]);
   return host;
 };
Example #29
0
 return configPaths.find(x => host.exists(x));
Example #30
0
File: alain.ts Project: wexz/delon
export function tryAddFile(host: Tree, path: string, content: string) {
  if (host.exists(path)) {
    host.delete(path);
  }
  host.create(path, content);
}