UNPKG

@nstudio/schematics

Version:

Cross-platform (xplat) tools for Nx workspaces.

69 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const utils_1 = require("../utils"); function default_1(options) { return schematics_1.chain([ updatePaths(options), ]); } exports.default = default_1; ; function updatePaths(options) { return (tree) => { const nxJson = utils_1.getNxWorkspaceConfig(tree); const npmScope = nxJson.npmScope; const platformArg = options.platforms; // sort for consistency const platforms = utils_1.sanitizeCommaDelimitedArg(platformArg).sort(function (a, b) { if (a < b) return -1; if (a > b) return 1; return 0; }); if ((platforms.includes('ionic') || platforms.includes('electron')) && !platforms.includes('web')) { // ensure web is added since these platforms depend on it platforms.push('web'); } const updates = {}; // ensure default Nx libs path is in place updates[`@${npmScope}/*`] = [ `libs/*` ]; for (const t of platforms) { if (utils_1.supportedPlatforms.includes(t)) { updates[`@${npmScope}/${t}`] = [ `xplat/${t}/index.ts` ]; updates[`@${npmScope}/${t}/*`] = [ `xplat/${t}/*` ]; } else { throw new Error(`${t} is not a supported platform. Currently supported: ${utils_1.supportedPlatforms}`); } } return utils_1.updateTsConfig(tree, (tsConfig) => { if (tsConfig) { if (!tsConfig.compilerOptions) { tsConfig.compilerOptions = {}; } tsConfig.compilerOptions.paths = Object.assign({}, (tsConfig.compilerOptions.paths || {}), updates); } }); }; } // function updateSpecExcludes() { // return ( tree: Tree ) => { // return updateTsConfig(tree, (tsConfig: any) => { // if (tsConfig) { // if (!tsConfig.exclude) { // tsConfig.exclude = []; // } // tsConfig.exclude.push('apps/nativescript-*'); // } // }, 'spec'); // } // } //# sourceMappingURL=index.js.map