"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 }); exports.isStandaloneSchematic = exports.getDefaultComponentOptions = void 0; const core_1 = require("@angular-devkit/core"); const schema_1 = require("@schematics/angular/component/schema"); const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils"); const project_main_file_1 = require("./project-main-file"); const workspace_1 = require("@schematics/angular/utility/workspace"); const get_project_1 = require("./get-project"); /** * Returns the default options for the `@schematics/angular:component` schematic which would * have been specified at project initialization (ng new or ng init). * * This is necessary because the Angular CLI only exposes the default values for the "--style", * "--inlineStyle", "--skipTests" and "--inlineTemplate" options to the "component" schematic. */ function getDefaultComponentOptions(project) { // Note: Not all options which are available when running "ng new" will be stored in the // workspace config. List of options which will be available in the configuration: // angular/angular-cli/blob/main/packages/schematics/angular/application/index.ts#L109-L131 let skipTests = getDefaultComponentOption(project, ['skipTests'], null); // In case "skipTests" is not set explicitly, also look for the "spec" option. The "spec" // option has been deprecated but can be still used in older Angular CLI projects. // See: https://github.com/angular/angular-cli/commit/a12a4e02a4689b5bdbc6e740c0d9865afb55671a if (skipTests === null) { skipTests = !getDefaultComponentOption(project, ['spec'], true); } return { style: getDefaultComponentOption(project, ['style', 'styleext'], schema_1.Style.Css), inlineStyle: getDefaultComponentOption(project, ['inlineStyle'], false), inlineTemplate: getDefaultComponentOption(project, ['inlineTemplate'], false), skipTests: skipTests, }; } exports.getDefaultComponentOptions = getDefaultComponentOptions; /** Determines whether the schematic is configured to be standalone. */ async function isStandaloneSchematic(host, options) { if (options.standalone != null) { return options.standalone; } // If the `--standalone` flag isn't passed and there isn't a default, infer based on the project. const workspace = await (0, workspace_1.getWorkspace)(host); const project = (0, get_project_1.getProjectFromWorkspace)(workspace, options.project); // Legacy projects might not have a `build` target, but they're likely // not on an Angular version that supports standalone either. if (!project.targets?.has('build')) { return false; } return (0, ng_ast_utils_1.isStandaloneApp)(host, (0, project_main_file_1.getProjectMainFile)(project)); } exports.isStandaloneSchematic = isStandaloneSchematic; /** * Gets the default value for the specified option. The default options will be determined * by looking at the stored schematic options for `@schematics/angular:component` in the * CLI workspace configuration. */ function getDefaultComponentOption(project, optionNames, fallbackValue) { const schematicOptions = (0, core_1.isJsonObject)(project.extensions.schematics || null) ? project.extensions.schematics : null; const defaultSchematic = schematicOptions ? schematicOptions['@schematics/angular:component'] : null; for (const optionName of optionNames) { if (defaultSchematic && defaultSchematic[optionName] != null) { return defaultSchematic[optionName]; } } return fallbackValue; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hdGljLW9wdGlvbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3NjaGVtYXRpY3MvdXRpbHMvc2NoZW1hdGljLW9wdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsK0NBQTBFO0FBQzFFLGlFQUFtRTtBQUNuRSwyRUFBeUU7QUFDekUsMkRBQXVEO0FBQ3ZELHFFQUFtRTtBQUNuRSwrQ0FBc0Q7QUFHdEQ7Ozs7OztHQU1HO0FBQ0gsU0FBZ0IsMEJBQTBCLENBQUMsT0FBcUM7SUFDOUUsd0ZBQXdGO0lBQ3hGLGtGQUFrRjtJQUNsRiwyRkFBMkY7SUFDM0YsSUFBSSxTQUFTLEdBQUcseUJBQXlCLENBQWlCLE9BQU8sRUFBRSxDQUFDLFdBQVcsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO0lBRXhGLHlGQUF5RjtJQUN6RixrRkFBa0Y7SUFDbEYsOEZBQThGO0lBQzlGLElBQUksU0FBUyxLQUFLLElBQUksRUFBRTtRQUN0QixTQUFTLEdBQUcsQ0FBQyx5QkFBeUIsQ0FBQyxPQUFPLEVBQUUsQ0FBQyx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