UNPKG

@bd-innovations/abstract-section

Version:

A bunch of abstract logic for the section

36 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.init = void 0; const schematics_1 = require("@angular-devkit/schematics"); const core_1 = require("@angular-devkit/core"); const pluralizedStrings = require("./pluralized-strings"); function init(options) { return (tree) => { const workspaceConfig = tree.read('/angular.json'); if (!workspaceConfig) { throw new schematics_1.SchematicsException('Could not find Angular workspace configuration'); } // convert workspace to string const workspaceContent = workspaceConfig.toString(); // parse workspace string into JSON object const workspace = JSON.parse(workspaceContent); if (!options.project) { options.project = workspace.defaultProject; } const projectName = options.project; const project = workspace.projects[projectName]; const projectType = project.projectType === 'application' ? 'app' : 'lib'; if (options.path === undefined) { options.path = `${project.sourceRoot}/${projectType}`; } const templateSource = schematics_1.apply(schematics_1.url('./files'), [ schematics_1.applyTemplates(Object.assign(Object.assign(Object.assign({}, core_1.strings), pluralizedStrings), options)), schematics_1.move(core_1.normalize(options.path)) ]); return schematics_1.chain([ schematics_1.mergeWith(templateSource) ]); }; } exports.init = init; //# sourceMappingURL=index.js.map