UNPKG

@nstudio/web-angular

Version:

Web Angular Plugin for xplat

62 lines (61 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const angular_1 = require("@nstudio/angular"); const schematics_1 = require("@angular-devkit/schematics"); const xplat_1 = require("@nstudio/xplat"); const xplat_utils_1 = require("@nstudio/xplat-utils"); function default_1(options) { const featureSettings = xplat_1.XplatFeatureHelpers.prepare(options); const chains = []; if (options.onlyProject) { for (const fullProjectPath of featureSettings.projectNames) { const projectName = (0, xplat_utils_1.parseProjectNameFromPath)(fullProjectPath); const projectParts = projectName.split('-'); const platPrefix = projectParts[0]; const platSuffix = projectParts.pop(); const platform = xplat_utils_1.supportedPlatforms.includes(platPrefix) ? platPrefix : platSuffix; if (platform === 'web') { // check for 2 different naming conventions on routing modules const routingModulePathOptions = []; const appDirectory = `apps/${fullProjectPath}/src/app/`; routingModulePathOptions.push(`${appDirectory}app.routing.ts`); routingModulePathOptions.push(`${appDirectory}app-routing.module.ts`); chains.push((tree, context) => { return xplat_1.XplatFeatureHelpers.addFiles(options, platform, fullProjectPath)(tree, context); }); if (options.routing) { chains.push((tree, context) => { return (0, angular_1.adjustRouting)(options, routingModulePathOptions, platform)(tree, context); }); if (options.adjustSandbox) { chains.push((tree, context) => { return (0, angular_1.adjustSandbox)(options, platform, appDirectory)(tree, context); }); } } if (!options.onlyModule) { chains.push((tree, context) => { return xplat_1.XplatFeatureHelpers.addFiles(options, platform, fullProjectPath, '_component')(tree, context); }); } } } } else { // projectChains.push(noop()); chains.push((tree, context) => xplat_1.XplatFeatureHelpers.addFiles(options, 'web', null, null, 'angular')(tree, context)); // update index chains.push((tree, context) => { const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername('web', 'angular'); return xplat_1.XplatFeatureHelpers.adjustBarrelIndex(options, `libs/xplat/${xplatFolderName}/features/src/lib/index.ts`)(tree, context); }); // add starting component unless onlyModule if (!options.onlyModule) { chains.push((tree, context) => xplat_1.XplatFeatureHelpers.addFiles(options, 'web', null, '_component', 'angular')(tree, context)); } } return (0, schematics_1.chain)([(0, xplat_utils_1.prerun)(), ...chains]); }