UNPKG

@routineless/nx-aws-cdk

Version:
61 lines 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTsConfigCompilerPaths = exports.getNpmScope = exports.deleteNodeLibRedundantDirs = exports.deleteNodeAppRedundantDirs = exports.addGitIgnoreEntries = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const fs_1 = require("fs"); const ignore_1 = tslib_1.__importDefault(require("ignore")); const path = tslib_1.__importStar(require("path")); const tsconfig_paths_1 = require("tsconfig-paths"); const addGitIgnoreEntries = (host, entries) => { if (!host.exists('.gitignore')) { return; } let content = host.read('.gitignore', 'utf-8')?.trimEnd() || ''; const ig = (0, ignore_1.default)(); ig.add(content); const newEntries = entries.filter((entry) => !ig.ignores(entry)); if (newEntries.length < 1) { return; } content = `${content}\n`; for (const entry of newEntries) { content = `${content}\n${entry}`; } host.write('.gitignore', content); }; exports.addGitIgnoreEntries = addGitIgnoreEntries; const deleteNodeAppRedundantDirs = (tree, projectRoot) => { tree.delete(`${projectRoot}/src/app`); }; exports.deleteNodeAppRedundantDirs = deleteNodeAppRedundantDirs; const deleteNodeLibRedundantDirs = (tree, projectRoot) => { tree.delete(`${projectRoot}/src/lib`); }; exports.deleteNodeLibRedundantDirs = deleteNodeLibRedundantDirs; const getNpmScope = (tree) => { const { name } = tree.exists('package.json') ? (0, devkit_1.readJson)(tree, 'package.json') : { name: null }; if (name?.startsWith('@')) { return name.split('/')[0]?.substring(1); } return undefined; }; exports.getNpmScope = getNpmScope; const getTsConfigCompilerPaths = (context) => { const tsConfigResult = (0, tsconfig_paths_1.loadConfig)(getRootTsConfigPath(context)); if (tsConfigResult.resultType !== 'success') { throw new Error('Cannot load tsconfig file'); } return tsConfigResult.paths; }; exports.getTsConfigCompilerPaths = getTsConfigCompilerPaths; function getRootTsConfigPath(context) { for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) { const tsConfigPath = path.join(context.root, tsConfigName); if ((0, fs_1.existsSync)(tsConfigPath)) { return tsConfigPath; } } throw new Error('Could not find a root tsconfig.json or tsconfig.base.json file.'); } //# sourceMappingURL=workspace.js.map