UNPKG

@nstudio/schematics

Version:

Cross-platform (xplat) tools for Nx workspaces.

101 lines 3.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const utils_1 = require("../../utils"); function updateNativeScriptApps(tree, context) { const nxConfigPath = `nx.json`; const nxJson = utils_1.getJsonFromFile(tree, nxConfigPath); const npmScope = nxJson.npmScope; const appsDir = tree.getDir("apps"); const appFolders = appsDir.subdirs; // console.log("npmScope:", npmScope); // console.log("prefix:", prefix); // update {N} apps and configs for (const dir of appFolders) { // console.log(dir); if (dir.indexOf("nativescript-") === 0) { const appDir = `${appsDir.path}/${dir}`; // console.log('appDir:', appDir); utils_1.createOrUpdate(tree, `${appDir}/tsconfig.esm.json`, getTsConfigESM()); utils_1.createOrUpdate(tree, `${appDir}/tsconfig.json`, getTsConfig(npmScope)); } } return tree; } function updateRootPackage(tree, context) { return utils_1.updateJsonInTree("package.json", json => { json.scripts = json.scripts || {}; json.dependencies = json.dependencies || {}; json.devDependencies = json.devDependencies || {}; const appsDir = tree.getDir("apps"); const appFolders = appsDir.subdirs; for (const dir of appFolders) { if (dir.indexOf("nativescript-") === 0) { const parts = dir.split("-"); const appName = parts[1]; json.scripts[`start.nativescript.${appName}.ios`] = `cd apps/${dir} && tns run ios --emulator --bundle`; json.scripts[`start.nativescript.${appName}.android`] = `cd apps/${dir} && tns run android --emulator --bundle`; json.scripts[`clean.nativescript.${appName}`] = `cd apps/${dir} && npx rimraf -- hooks node_modules platforms package-lock.json && npm i && npx rimraf -- package-lock.json`; // the final removal of package-lock.json fixes issue with node 10+ } } return json; })(tree, context); } function default_1() { return schematics_1.chain([updateNativeScriptApps, updateRootPackage]); } exports.default = default_1; function getTsConfig(npmScope) { return `{ "compilerOptions": { "module": "commonjs", "target": "es2015", "experimentalDecorators": true, "emitDecoratorMetadata": true, "noEmitHelpers": true, "noEmitOnError": true, "removeComments": true, "skipLibCheck": true, "lib": [ "es2017", "dom", "es6" ], "baseUrl": ".", "paths": { "~/*": [ "app/*" ], "@${npmScope}/*": [ "../../libs/*" ], "@${npmScope}/nativescript": [ "../../xplat/nativescript/index.ts" ], "@${npmScope}/nativescript/*": [ "../../xplat/nativescript/*" ], "*": [ "./node_modules/tns-core-modules/*", "./node_modules/*" ] } }, "exclude": [ "node_modules", "platforms" ] } `; } function getTsConfigESM() { return `{ "extends": "./tsconfig", "compilerOptions": { "module": "es2015", "moduleResolution": "node" } } `; } //# sourceMappingURL=update-6-1-1.js.map