UNPKG

@objectivity/angular-schematic-ide

Version:

Configures IDE, adds common extensions and configurations

55 lines 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.vscode = void 0; const schematics_1 = require("@angular-devkit/schematics"); const schematics_utilities_1 = require("schematics-utilities"); function vscode(_options) { return (host, _context) => { const projects = schematics_utilities_1.getWorkspace(host).projects; const templateSource = schematics_1.apply(schematics_1.url('./files'), [ schematics_1.applyTemplates({ projects: Object.keys(projects).map(key => { return getTemplateServeOptions(projects[key], key); }) }), schematics_1.move('/.vscode') ]); return schematics_1.chain([ schematics_1.branchAndMerge(schematics_1.chain([ schematics_1.mergeWith(templateSource) ])), ]); }; } exports.vscode = vscode; function getTemplateServeOptions(project, projectName) { const projectRoot = project.root; const serveOptions = getProjectTargetOptions(project, 'serve'); return { servePort: serveOptions.port || 4200, serveProtocol: serveOptions.ssl === true ? 'https' : 'http', serveDomain: serveOptions.host || 'localhost', name: projectName, webRoot: projectRoot == '' ? '${workspaceFolder}' : '${workspaceFolder}/' + projectRoot, testProtocol: 'http', testDomain: 'localhost', testPort: 9876 }; } function getProjectTargetOptions(project, buildTarget) { if (project.targets && project.targets[buildTarget] && project.targets[buildTarget].options) { return project.targets[buildTarget].options; } // TODO(devversion): consider removing this architect check if the CLI completely switched // over to `targets`, and the `architect` support has been removed. // See: https://github.com/angular/angular-cli/commit/307160806cb48c95ecb8982854f452303801ac9f if (project.architect && project.architect[buildTarget] && project.architect[buildTarget].options) { return project.architect[buildTarget].options; } throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`); } //# sourceMappingURL=index.js.map