"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@angular-devkit/core"); const schematics_1 = require("@angular-devkit/schematics"); const tasks_1 = require("@angular-devkit/schematics/tasks"); const dependencies_1 = require("../utility/dependencies"); const latest_versions_1 = require("../utility/latest-versions"); const paths_1 = require("../utility/paths"); const workspace_1 = require("../utility/workspace"); const workspace_models_1 = require("../utility/workspace-models"); const schema_1 = require("./schema"); function default_1(options) { return async (host, context) => { const { appDir, appRootSelector, componentOptions, folderName, sourceDir } = await getAppOptions(host, options); if (options.standalone) { context.logger.warn('Standalone application structure is new and not yet supported by many existing' + ` 'ng add' and 'ng update' integrations with community libraries.`); } return (0, schematics_1.chain)([ addAppToWorkspaceFile(options, appDir, folderName), options.standalone ? (0, schematics_1.noop)() : (0, schematics_1.schematic)('module', { name: 'app', commonModule: false, flat: true, routing: options.routing, routingScope: 'Root', path: sourceDir, project: options.name, }), (0, schematics_1.schematic)('component', { name: 'app', selector: appRootSelector, flat: true, path: sourceDir, skipImport: true, project: options.name, ...componentOptions, }), (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(options.standalone ? './files/standalone-files' : './files/module-files'), [ options.routing ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('app.routes.ts.template')), componentOptions.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(), (0, schematics_1.applyTemplates)({ utils: schematics_1.strings, ...options, ...componentOptions, selector: appRootSelector, relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(appDir), appName: options.name, folderName, }), (0, schematics_1.move)(appDir), ]), schematics_1.MergeStrategy.Overwrite), (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/common-files'), [ options.minimal ? (0, schematics_1.filter)((path) => !path.endsWith('tsconfig.spec.json.template')) : (0, schematics_1.noop)(), componentOptions.inlineTemplate ? (0, schematics_1.filter)((path) => !path.endsWith('component.html.template')) : (0, schematics_1.noop)(), (0, schematics_1.applyTemplates)({ utils: schematics_1.strings, ...options, selector: appRootSelector, relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(appDir), appName: options.name, folderName, }), (0, schematics_1.move)(appDir), ]), schematics_1.MergeStrategy.Overwrite), options.skipPackageJson ? (0, schematics_1.noop)() : addDependenciesToPackageJson(options), ]); }; } exports.default = default_1; function addDependenciesToPackageJson(options) { return (host, context) => { [ { type: dependencies_1.NodeDependencyType.Dev, name: '@angular/compiler-cli', version: latest_versions_1.latestVersions.Angular, }, { type: dependencies_1.NodeDependencyType.Dev, name: '@angular-devkit/build-angular', version: latest_versions_1.latestVersions.DevkitBuildAngular, }, { type: dependencies_1.NodeDependencyType.Dev, name: 'typescript', version: latest_versions_1.latestVersions['typescript'], }, ].forEach((dependency) => (0, dependencies_1.addPackageJsonDependency)(host, dependency)); if (!options.skipInstall) { context.addTask(new tasks_1.NodePackageInstallTask()); } return host; }; } function addAppToWorkspaceFile(options, appDir, folderName) { let projectRoot = appDir; if (projectRoot) { projectRoot += '/'; } const schematics = {}; if (options.inlineTemplate || options.inlineStyle || options.minimal || options.style !== schema_1.Style.Css) { const componentSchematicsOptions = {}; if (options.inlineTemplate ?? options.minimal) { componentSchematicsOptions.inlineTemplate = true; } if (options.inlineStyle ?? options.minimal) { componentSchematicsOptions.inlineStyle = true; } if (options.style && options.style !== schema_1.Style.Css) { componentSchematicsOptions.style = options.style; } schematics['@schematics/angular:component'] = componentSchematicsOptions; } if (options.skipTests || options.minimal) { const schematicsWithTests = [ 'class', 'component', 'directive', 'guard', 'interceptor', 'pipe', 'resolver', 'service', ]; schematicsWithTests.forEach((type) => { if (!(`@schematics/angular:${type}` in schematics)) { schematics[`@schematics/angular:${type}`] = {}; } schematics[`@schematics/angular:${type}`].skipTests = true; }); } if (options.standalone) { const schematicsWithStandalone = ['component', 'directive', 'pipe']; schematicsWithStandalone.forEach((type) => { if (!(`@schematics/angular:${type}` in schematics)) { schematics[`@schematics/angular:${type}`] = {}; } schematics[`@schematics/angular:${type}`].standalone = true; }); } const sourceRoot = (0, core_1.join)((0, core_1.normalize)(projectRoot), 'src'); let budgets = []; if (options.strict) { budgets = [ { type: 'initial', maximumWarning: '500kb', maximumError: '1mb', }, { type: 'anyComponentStyle', maximumWarning: '2kb', maximumError: '4kb', }, ]; } else { budgets = [ { type: 'initial', maximumWarning: '2mb', maximumError: '5mb', }, { type: 'anyComponentStyle', maximumWarning: '6kb', maximumError: '10kb', }, ]; } const inlineStyleLanguage = options?.style !== schema_1.Style.Css ? options.style : undefined; const project = { root: (0, core_1.normalize)(projectRoot), sourceRoot, projectType: workspace_models_1.ProjectType.Application, prefix: options.prefix || 'app', schematics, targets: { build: { builder: workspace_models_1.Builders.Browser, defaultConfiguration: 'production', options: { outputPath: `dist/${folderName}`, index: `${sourceRoot}/index.html`, main: `${sourceRoot}/main.ts`, polyfills: ['zone.js'], tsConfig: `${projectRoot}tsconfig.app.json`, inlineStyleLanguage, assets: [`${sourceRoot}/favicon.ico`, `${sourceRoot}/assets`], styles: [`${sourceRoot}/styles.${options.style}`], scripts: [], }, configurations: { production: { budgets, outputHashing: 'all', }, development: { buildOptimizer: false, optimization: false, vendorChunk: true, extractLicenses: false, sourceMap: true, namedChunks: true, }, }, }, serve: { builder: workspace_models_1.Builders.DevServer, defaultConfiguration: 'development', options: {}, configurations: { production: { browserTarget: `${options.name}:build:production`, }, development: { browserTarget: `${options.name}:build:development`, }, }, }, 'extract-i18n': { builder: workspace_models_1.Builders.ExtractI18n, options: { browserTarget: `${options.name}:build`, }, }, test: options.minimal ? undefined : { builder: workspace_models_1.Builders.Karma, options: { polyfills: ['zone.js', 'zone.js/testing'], tsConfig: `${projectRoot}tsconfig.spec.json`, inlineStyleLanguage, assets: [`${sourceRoot}/favicon.ico`, `${sourceRoot}/assets`], styles: [`${sourceRoot}/styles.${options.style}`], scripts: [], }, }, }, }; return (0, workspace_1.updateWorkspace)((workspace) => { workspace.projects.add({ name: options.name, ...project, }); }); } async function getAppOptions(host, options) { const appRootSelector = `${options.prefix}-root`; const componentOptions = getComponentOptions(options); const workspace = await (0, workspace_1.getWorkspace)(host); const newProjectRoot = workspace.extensions.newProjectRoot || ''; // If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar". let folderName = options.name.startsWith('@') ? options.name.slice(1) : options.name; if (/[A-Z]/.test(folderName)) { folderName = schematics_1.strings.dasherize(folderName); } const appDir = options.projectRoot === undefined ? (0, core_1.join)((0, core_1.normalize)(newProjectRoot), folderName) : (0, core_1.normalize)(options.projectRoot); const sourceDir = `${appDir}/src/app`; return { appDir, appRootSelector, componentOptions, folderName, sourceDir, }; } function getComponentOptions(options) { const componentOptions = !options.minimal ? { inlineStyle: options.inlineStyle, inlineTemplate: options.inlineTemplate, skipTests: options.skipTests, style: options.style, viewEncapsulation: options.viewEncapsulation, } : { inlineStyle: options.inlineStyle ?? true, inlineTemplate: options.inlineTemplate ?? true, skipTests: true, style: options.style, viewEncapsulation: options.viewEncapsulation, }; return componentOptions; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9zY2hlbWF0aWNzL2FuZ3VsYXIvYXBwbGljYXRpb24vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7QUFFSCwrQ0FBbUU7QUFDbkUsMkRBZW9DO0FBQ3BDLDREQUEwRTtBQUUxRSwwREFBdUY7QUFDdkYsZ0VBQTREO0FBQzVELDRDQUErRDtBQUMvRCxvREFBcUU7QUFDckUsa0VBQW9FO0FBQ3BFLHFDQUErRDtBQUUvRCxtQkFBeUIsT0FBMkI7SUFDbEQsT0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oge1xuICAgICAgICBidWlsZGVyOiBCdWlsZGVycy5Ccm93c2VyLFxuICAgICAgICBkZWZhdWx0Q29uZmlndXJhdGlvbjogJ3Byb2R1Y3Rpb24nLFxuICAgICAgICBvcHRpb25zOiB7XG4gICAgICAgICAgb3V0cHV0UGF0aDogYGRpc3QvJHtmb2xkZXJOYW1lfWAsXG4gICAgICAgICAgaW5kZXg6IGAke3NvdXJjZVJvb3R9L2luZGV4Lmh0bWxgLFxuICAgICAgICAgIG1haW46IGAke3NvdXJjZVJvb3R9L21haW4udHNgLFxuICAgICAgICAgIHBvbHlmaWxsczogWyd6b25lLmpzJ10sXG4gICAgICAgICAgdHNDb25maWc6IGAke3Byb2plY3RSb290fXRzY29uZmlnLmFwcC5qc29uYCxcbiAgICAgICAgICBpbmxpbmVTdHlsZUxhbmd1YWdlLFxuICAgICAgICAgIGFzc2V0czogW2Ake3NvdXJjZVJvb3R9L2Zhdmljb24uaWNvYCwgYCR7c291cmNlUm9vdH0vYXNzZXRzYF0sXG4gICAgICAgICAgc3R5bGVzOiBbYCR7c291cmNlUm9vdH0vc3R5bGVzLiR7b3B0aW9ucy5zdHlsZX1gXSxcbiAgICAgICAgICBzY3JpcHRzOiBbXSxcbiAgICAgICAgfSxcbiAgICAgICAgY29uZmlndXJhdGlvbnM6IHtcbiAgICAgICAgICBwcm9kdWN0aW9uOiB7XG4gICAgICAgICAgICBidWRnZXRzLFxuICAgICAgICAgICAgb3V0cHV0SGFzaGluZzogJ2FsbCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgICBkZXZlbG9wbWVudDoge1xuICAgICAgICAgICAgYnVpbGRPcHRpbWl6ZXI6IGZhbHNlLFxuICAgICAgICAgICAgb3B0aW1pemF0aW9uOiBmYWxzZSxcbiAgICAgICAgICAgIHZlbmRvckNodW5rOiB0cnVlLFxuICAgICAgICAgICAgZXh0cmFjdExpY2Vuc2VzOiBmYWxzZSxcbiAgICAgICAgICAgIHNvdXJjZU1hcDogdHJ1ZSxcbiAgICAgICAgICAgIG5hbWVkQ2h1bmtzOiB0cnVlLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgc2VydmU6IHtcbiAgICAgICAgYnVpbGRlcjogQnVpbGRlcnMuRGV2U2VydmVyLFxuICAgICAgICBkZWZhdWx0Q29uZmlndXJhdGlvbjogJ2RldmVsb3BtZW50JyxcbiAgICAgICAgb3B0aW9uczoge30sXG4gICAgICAgIGNvbmZpZ3VyYXRpb25zOiB7XG4gICAgICAgICAgcHJvZHVjdGlvbjoge1xuICAgICAgICAgICAgYnJvd3NlclRhcmdldDogYCR7b3B0aW9ucy5uYW1lfTpidWlsZDpwcm9kdWN0aW9uYCxcbiAgICAgICAgICB9LFxuICAgICAgICAgIGRldmVsb3BtZW50OiB7XG4gICAgICAgICAgICBicm93c2VyVGFyZ2V0OiBgJHtvcHRpb25zLm5hbWV9OmJ1aWxkOmRldmVsb3BtZW50YCxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgICdleHRyYWN0LWkxOG4nOiB7XG4gICAgICAgIGJ1aWxkZXI6IEJ1aWxkZXJzLkV4dHJhY3RJMThuLFxuICAgICAgICBvcHRpb25zOiB7XG4gICAgICAgICAgYnJvd3NlclRhcmdldDogYCR7b3B0aW9ucy5uYW1lfTpidWlsZGAsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgdGVzdDogb3B0aW9ucy5taW5pbWFsXG4gICAgICAgID8gdW5kZWZpbmVkXG4gICAgICAgIDoge1xuICAgICAgICAgICAgYnVpbGRlcjogQnVpbGRlcnMuS2FybWEsXG4gICAgICAgICAgICBvcHRpb25zOiB7XG4gICAgICAgICAgICAgIHBvbHlmaWxsczogWyd6b25lLmpzJywgJ3pvbmUuanMvdGVzdGluZyddLFxuICAgICAgICAgICAgICB0c0NvbmZpZzogYCR7cHJvamVjdFJvb3R9dHNjb25maWcuc3BlYy5qc29uYCxcbiAgICAgICAgICAgICAgaW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