UNPKG

@nstudio/angular

Version:

Angular Plugin for xplat

45 lines (44 loc) 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; 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 externalChains = []; for (const platform of featureSettings.platforms) { if (xplat_utils_1.supportedPlatforms.includes(platform)) { externalChains.push((tree, context) => { // console.log(`@nstudio/${platform}-angular`); // console.log('angular feature chain getFrontendFramework:', getFrontendFramework()); return (0, schematics_1.externalSchematic)(`@nstudio/${platform}-angular`, 'feature', options, { interactive: false, })(tree, context); }); } else if (xplat_utils_1.supportedNxExtraPlatforms.includes(platform)) { throw new schematics_1.SchematicsException((0, xplat_1.unsupportedPlatformErrorWithNxNote)(platform, 'feature')); } else { throw new schematics_1.SchematicsException((0, xplat_1.unsupportedPlatformError)(platform)); } } return (0, schematics_1.chain)([ (0, xplat_utils_1.prerun)(), // libs (tree, context) => options.onlyProject ? (0, schematics_1.noop)()(tree, context) : xplat_1.XplatFeatureHelpers.addFiles(options)(tree, context), // libs (tree, context) => options.onlyProject || !options.createBase || options.onlyModule ? (0, schematics_1.noop)()(tree, context) : xplat_1.XplatFeatureHelpers.addFiles(options, null, null, '_component')(tree, context), // update libs index (tree, context) => options.onlyProject ? (0, schematics_1.noop)()(tree, context) : xplat_1.XplatFeatureHelpers.adjustBarrelIndex(options, 'libs/xplat/features/src/lib/index.ts'), // external schematic handling (tree, context) => (0, schematics_1.chain)(externalChains), ]); }