This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

25
node_modules/@angular/cdk/schematics/utils/ast.d.ts generated vendored Executable file
View File

@@ -0,0 +1,25 @@
/**
* @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.dev/license
*/
import { Tree } from '@angular-devkit/schematics';
import { Schema as ComponentOptions } from '@schematics/angular/component/schema';
import { ProjectDefinition } from '@schematics/angular/utility';
import * as ts from 'typescript';
/** Reads file given path and returns TypeScript source file. */
export declare function parseSourceFile(host: Tree, path: string): ts.SourceFile;
/** Import and add module to root app module. */
export declare function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: ProjectDefinition): void;
/**
* Import and add module to specific module path.
* @param host the tree we are updating
* @param modulePath src location of the module to import
* @param moduleName name of module to import
* @param src src location to import
*/
export declare function addModuleImportToModule(host: Tree, modulePath: string, moduleName: string, src: string): void;
/** Wraps the internal find module from options with undefined path handling */
export declare function findModuleFromOptions(host: Tree, options: ComponentOptions): Promise<string | undefined>;

79
node_modules/@angular/cdk/schematics/utils/ast.js generated vendored Executable file
View File

@@ -0,0 +1,79 @@
"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.dev/license
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSourceFile = parseSourceFile;
exports.addModuleImportToRootModule = addModuleImportToRootModule;
exports.addModuleImportToModule = addModuleImportToModule;
exports.findModuleFromOptions = findModuleFromOptions;
const schematics_1 = require("@angular-devkit/schematics");
const change_1 = require("@schematics/angular/utility/change");
const utility_1 = require("@schematics/angular/utility");
const find_module_1 = require("@schematics/angular/utility/find-module");
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
const ts = require("typescript");
const project_main_file_1 = require("./project-main-file");
/** Reads file given path and returns TypeScript source file. */
function parseSourceFile(host, path) {
const buffer = host.read(path);
if (!buffer) {
throw new schematics_1.SchematicsException(`Could not find file for path: ${path}`);
}
return ts.createSourceFile(path, buffer.toString(), ts.ScriptTarget.Latest, true);
}
/** Import and add module to root app module. */
function addModuleImportToRootModule(host, moduleName, src, project) {
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, (0, project_main_file_1.getProjectMainFile)(project));
addModuleImportToModule(host, modulePath, moduleName, src);
}
/**
* Import and add module to specific module path.
* @param host the tree we are updating
* @param modulePath src location of the module to import
* @param moduleName name of module to import
* @param src src location to import
*/
function addModuleImportToModule(host, modulePath, moduleName, src) {
const moduleSource = parseSourceFile(host, modulePath);
if (!moduleSource) {
throw new schematics_1.SchematicsException(`Module not found: ${modulePath}`);
}
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, moduleName, src);
const recorder = host.beginUpdate(modulePath);
changes.forEach(change => {
if (change instanceof change_1.InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
});
host.commitUpdate(recorder);
}
/** Wraps the internal find module from options with undefined path handling */
function findModuleFromOptions(host, options) {
return __awaiter(this, void 0, void 0, function* () {
const workspace = yield (0, utility_1.readWorkspace)(host);
if (!options.project) {
options.project = Array.from(workspace.projects.keys())[0];
}
const project = workspace.projects.get(options.project);
if (options.path === undefined) {
options.path = `/${project.root}/src/app`;
}
return (0, find_module_1.findModuleFromOptions)(host, options);
});
}
//# sourceMappingURL=ast.js.map

1
node_modules/@angular/cdk/schematics/utils/ast.js.map generated vendored Executable file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ast.js","sourceRoot":"","sources":["ast.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;AAaH,0CAMC;AAGD,kEAQC;AASD,0DAsBC;AAGD,sDAiBC;AA/ED,2DAAqE;AAErE,+DAAgE;AAChE,yDAA6E;AAC7E,yEAAoG;AACpG,qEAAwE;AACxE,2EAA0E;AAC1E,iCAAiC;AACjC,2DAAuD;AAEvD,gEAAgE;AAChE,SAAgB,eAAe,CAAC,IAAU,EAAE,IAAY;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,gCAAmB,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACpF,CAAC;AAED,gDAAgD;AAChD,SAAgB,2BAA2B,CACzC,IAAU,EACV,UAAkB,EAClB,GAAW,EACX,OAA0B;IAE1B,MAAM,UAAU,GAAG,IAAA,+BAAgB,EAAC,IAAI,EAAE,IAAA,sCAAkB,EAAC,OAAO,CAAC,CAAC,CAAC;IACvE,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,IAAU,EACV,UAAkB,EAClB,UAAkB,EAClB,GAAW;IAEX,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAEvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,gCAAmB,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,6BAAiB,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE9C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,IAAI,MAAM,YAAY,qBAAY,EAAE,CAAC;YACnC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,gFAAgF;AAChF,SAAsB,qBAAqB,CACzC,IAAU,EACV,OAAyB;;QAEzB,MAAM,SAAS,GAAG,MAAM,IAAA,uBAAa,EAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC;QAEzD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC;QAC5C,CAAC;QAED,OAAO,IAAA,mCAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CAAA"}

View File

@@ -0,0 +1,12 @@
/**
* @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.dev/license
*/
import { Tree } from '@angular-devkit/schematics';
/**
* Whether the Angular module in the given path imports the specified module class name.
*/
export declare function hasNgModuleImport(tree: Tree, modulePath: string, className: string): boolean;

View File

@@ -0,0 +1,82 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasNgModuleImport = hasNgModuleImport;
const schematics_1 = require("@angular-devkit/schematics");
const ts = require("typescript");
/**
* Whether the Angular module in the given path imports the specified module class name.
*/
function hasNgModuleImport(tree, modulePath, className) {
const moduleFileContent = tree.read(modulePath);
if (!moduleFileContent) {
throw new schematics_1.SchematicsException(`Could not read Angular module file: ${modulePath}`);
}
const parsedFile = ts.createSourceFile(modulePath, moduleFileContent.toString(), ts.ScriptTarget.Latest, true);
const ngModuleMetadata = findNgModuleMetadata(parsedFile);
if (!ngModuleMetadata) {
throw new schematics_1.SchematicsException(`Could not find NgModule declaration inside: "${modulePath}"`);
}
for (let property of ngModuleMetadata.properties) {
if (!ts.isPropertyAssignment(property) ||
property.name.getText() !== 'imports' ||
!ts.isArrayLiteralExpression(property.initializer)) {
continue;
}
if (property.initializer.elements.some(element => element.getText() === className)) {
return true;
}
}
return false;
}
/**
* Resolves the last identifier that is part of the given expression. This helps resolving
* identifiers of nested property access expressions (e.g. myNamespace.core.NgModule).
*/
function resolveIdentifierOfExpression(expression) {
if (ts.isIdentifier(expression)) {
return expression;
}
else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.name)) {
return expression.name;
}
return null;
}
/**
* Finds a NgModule declaration within the specified TypeScript node and returns the
* corresponding metadata for it. This function searches breadth first because
* NgModule's are usually not nested within other expressions or declarations.
*/
function findNgModuleMetadata(rootNode) {
// Add immediate child nodes of the root node to the queue.
const nodeQueue = [...rootNode.getChildren()];
while (nodeQueue.length) {
const node = nodeQueue.shift();
if (ts.isDecorator(node) &&
ts.isCallExpression(node.expression) &&
isNgModuleCallExpression(node.expression)) {
return node.expression.arguments[0];
}
else {
nodeQueue.push(...node.getChildren());
}
}
return null;
}
/** Whether the specified call expression is referring to a NgModule definition. */
function isNgModuleCallExpression(callExpression) {
if (!callExpression.arguments.length ||
!ts.isObjectLiteralExpression(callExpression.arguments[0])) {
return false;
}
// The `NgModule` call expression name is never referring to a `PrivateIdentifier`.
const decoratorIdentifier = resolveIdentifierOfExpression(callExpression.expression);
return decoratorIdentifier ? decoratorIdentifier.text === 'NgModule' : false;
}
//# sourceMappingURL=ng-module-imports.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ng-module-imports.js","sourceRoot":"","sources":["ng-module-imports.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAQH,8CAkCC;AAxCD,2DAAqE;AACrE,iCAAiC;AAEjC;;GAEG;AACH,SAAgB,iBAAiB,CAAC,IAAU,EAAE,UAAkB,EAAE,SAAiB;IACjF,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEhD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,gCAAmB,CAAC,uCAAuC,UAAU,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CACpC,UAAU,EACV,iBAAiB,CAAC,QAAQ,EAAE,EAC5B,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;IACF,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAE1D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,gCAAmB,CAAC,gDAAgD,UAAU,GAAG,CAAC,CAAC;IAC/F,CAAC;IAED,KAAK,IAAI,QAAQ,IAAI,gBAAiB,CAAC,UAAU,EAAE,CAAC;QAClD,IACE,CAAC,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,SAAS;YACrC,CA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ED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mFAAmF;AACnF,SAAS,wBAAwB,CAAC,cAAiC;IACjE,IACE,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM;QAChC,CAAC,EAAE,CAAC,yBAAyB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC1D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mFAAmF;IACnF,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACrF,OAAO,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/E,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* @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.dev/license
*/
import { Rule } from '@angular-devkit/schematics';
import { Schema as ComponentOptions } from '@schematics/angular/component/schema';
/**
* Rule that copies and interpolates the files that belong to this schematic context. Additionally
* a list of file paths can be passed to this rule in order to expose them inside the EJS
* template context.
*
* This allows inlining the external template or stylesheet files in EJS without having
* to manually duplicate the file content.
*/
export declare function buildComponent(options: ComponentOptions, additionalFiles?: {
[key: string]: string;
}): Rule;

189
node_modules/@angular/cdk/schematics/utils/build-component.js generated vendored Executable file
View File

@@ -0,0 +1,189 @@
"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.dev/license
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildComponent = buildComponent;
const core_1 = require("@angular-devkit/core");
const schematics_1 = require("@angular-devkit/schematics");
const schema_1 = require("@schematics/angular/component/schema");
const change_1 = require("@schematics/angular/utility/change");
const utility_1 = require("@schematics/angular/utility");
const find_module_1 = require("@schematics/angular/utility/find-module");
const parse_name_1 = require("@schematics/angular/utility/parse-name");
const validation_1 = require("@schematics/angular/utility/validation");
const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const fs_1 = require("fs");
const path_1 = require("path");
const ts = require("typescript");
const get_project_1 = require("./get-project");
const schematic_options_1 = require("./schematic-options");
/**
* Build a default project path for generating.
* @param project The project to build the path for.
*/
function buildDefaultPath(project) {
const root = project.sourceRoot ? `/${project.sourceRoot}/` : `/${project.root}/src/`;
const projectDirName = project.extensions['projectType'] === workspace_models_1.ProjectType.Application ? 'app' : 'lib';
return `${root}${projectDirName}`;
}
/**
* List of style extensions which are CSS compatible. All supported CLI style extensions can be
* found here: angular/angular-cli/main/packages/schematics/angular/ng-new/schema.json#L118-L122
*/
const supportedCssExtensions = ['css', 'scss', 'less'];
function readIntoSourceFile(host, modulePath) {
const text = host.read(modulePath);
if (text === null) {
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
}
return ts.createSourceFile(modulePath, text.toString('utf-8'), ts.ScriptTarget.Latest, true);
}
function addDeclarationToNgModule(options) {
return (host) => {
if (options.skipImport || options.standalone || !options.module) {
return host;
}
const modulePath = options.module;
let source = readIntoSourceFile(host, modulePath);
const componentPath = `/${options.path}/` +
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
schematics_1.strings.dasherize(options.name) +
'.component';
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
const classifiedName = schematics_1.strings.classify(`${options.name}Component`);
const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
const declarationRecorder = host.beginUpdate(modulePath);
for (const change of declarationChanges) {
if (change instanceof change_1.InsertChange) {
declarationRecorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(declarationRecorder);
if (options.export) {
// Need to refresh the AST because we overwrote the file in the host.
source = readIntoSourceFile(host, modulePath);
const exportRecorder = host.beginUpdate(modulePath);
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Component`), relativePath);
for (const change of exportChanges) {
if (change instanceof change_1.InsertChange) {
exportRecorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(exportRecorder);
}
return host;
};
}
function buildSelector(options, projectPrefix) {
let selector = schematics_1.strings.dasherize(options.name);
if (options.prefix) {
selector = `${options.prefix}-${selector}`;
}
else if (options.prefix === undefined && projectPrefix) {
selector = `${projectPrefix}-${selector}`;
}
return selector;
}
/**
* Indents the text content with the amount of specified spaces. The spaces will be added after
* every line-break. This utility function can be used inside of EJS templates to properly
* include the additional files.
*/
function indentTextContent(text, numSpaces) {
// In the Material project there should be only LF line-endings, but the schematic files
// are not being linted and therefore there can be also CRLF or just CR line-endings.
return text.replace(/(\r\n|\r|\n)/g, `$1${' '.repeat(numSpaces)}`);
}
/**
* Rule that copies and interpolates the files that belong to this schematic context. Additionally
* a list of file paths can be passed to this rule in order to expose them inside the EJS
* template context.
*
* This allows inlining the external template or stylesheet files in EJS without having
* to manually duplicate the file content.
*/
function buildComponent(options, additionalFiles = {}) {
return (host, ctx) => __awaiter(this, void 0, void 0, function* () {
const context = ctx;
const workspace = yield (0, utility_1.readWorkspace)(host);
const project = (0, get_project_1.getProjectFromWorkspace)(workspace, options.project);
const defaultComponentOptions = (0, schematic_options_1.getDefaultComponentOptions)(project);
// TODO(devversion): Remove if we drop support for older CLI versions.
// This handles an unreported breaking change from the @angular-devkit/schematics. Previously
// the description path resolved to the factory file, but starting from 6.2.0, it resolves
// to the factory directory.
const schematicPath = (0, fs_1.statSync)(context.schematic.description.path).isDirectory()
? context.schematic.description.path
: (0, path_1.dirname)(context.schematic.description.path);
const schematicFilesUrl = './files';
const schematicFilesPath = (0, path_1.resolve)(schematicPath, schematicFilesUrl);
// Add the default component option values to the options if an option is not explicitly
// specified but a default component option is available.
Object.keys(options)
.filter(key => options[key] == null &&
defaultComponentOptions[key])
.forEach(key => (options[key] = defaultComponentOptions[key]));
if (options.path === undefined) {
options.path = buildDefaultPath(project);
}
options.standalone = yield (0, schematic_options_1.isStandaloneSchematic)(host, options);
if (!options.standalone) {
// TODO: Remove ext option when the Angular CLI looks for both candidate locations.
options.module = (0, find_module_1.findModuleFromOptions)(host, Object.assign(Object.assign({}, options), { moduleExt: 'module.ts' }));
}
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
options.selector = options.selector || buildSelector(options, project.prefix);
(0, validation_1.validateHtmlSelector)(options.selector);
// In case the specified style extension is not part of the supported CSS supersets,
// we generate the stylesheets with the "css" extension. This ensures that we don't
// accidentally generate invalid stylesheets (e.g. drag-drop-comp.styl) which will
// break the Angular CLI project. See: https://github.com/angular/components/issues/15164
if (!supportedCssExtensions.includes(options.style)) {
options.style = schema_1.Style.Css;
}
// Object that will be used as context for the EJS templates.
const baseTemplateContext = Object.assign(Object.assign(Object.assign({}, schematics_1.strings), { 'if-flat': (s) => (options.flat ? '' : s) }), options);
// Key-value object that includes the specified additional files with their loaded content.
// The resolved contents can be used inside EJS templates.
const resolvedFiles = {};
for (let key in additionalFiles) {
if (additionalFiles[key]) {
const fileContent = (0, fs_1.readFileSync)((0, path_1.join)(schematicFilesPath, additionalFiles[key]), 'utf-8');
// Interpolate the additional files with the base EJS template context.
resolvedFiles[key] = (0, core_1.template)(fileContent)(baseTemplateContext);
}
}
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(schematicFilesUrl), [
options.skipTests ? (0, schematics_1.filter)(path => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
options.inlineStyle ? (0, schematics_1.filter)(path => !path.endsWith('.__style__.template')) : (0, schematics_1.noop)(),
options.inlineTemplate ? (0, schematics_1.filter)(path => !path.endsWith('.html.template')) : (0, schematics_1.noop)(),
// Treat the template options as any, because the type definition for the template options
// is made unnecessarily explicit. Every type of object can be used in the EJS template.
(0, schematics_1.applyTemplates)(Object.assign({ indentTextContent, resolvedFiles }, baseTemplateContext)),
// TODO(devversion): figure out why we cannot just remove the first parameter
// See for example: angular-cli#schematics/angular/component/index.ts#L160
(0, schematics_1.move)(null, parsedPath.path),
]);
return () => (0, schematics_1.chain)([
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([addDeclarationToNgModule(options), (0, schematics_1.mergeWith)(templateSource)])),
])(host, context);
});
}
//# sourceMappingURL=build-component.js.map

File diff suppressed because one or more lines are too long

13
node_modules/@angular/cdk/schematics/utils/get-project.d.ts generated vendored Executable file
View File

@@ -0,0 +1,13 @@
/**
* @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.dev/license
*/
import { ProjectDefinition, WorkspaceDefinition } from '@schematics/angular/utility';
/**
* Finds the specified project configuration in the workspace. Throws an error if the project
* couldn't be found.
*/
export declare function getProjectFromWorkspace(workspace: WorkspaceDefinition, projectName: string | undefined): ProjectDefinition;

28
node_modules/@angular/cdk/schematics/utils/get-project.js generated vendored Executable file
View File

@@ -0,0 +1,28 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectFromWorkspace = getProjectFromWorkspace;
const schematics_1 = require("@angular-devkit/schematics");
/**
* Finds the specified project configuration in the workspace. Throws an error if the project
* couldn't be found.
*/
function getProjectFromWorkspace(workspace, projectName) {
if (!projectName) {
// TODO(crisbeto): some schematics APIs have the project name as optional so for now it's
// simpler to allow undefined and checking it at runtime. Eventually we should clean this up.
throw new schematics_1.SchematicsException('Project name is required.');
}
const project = workspace.projects.get(projectName);
if (!project) {
throw new schematics_1.SchematicsException(`Could not find project in workspace: ${projectName}`);
}
return project;
}
//# sourceMappingURL=get-project.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-project.js","sourceRoot":"","sources":["get-project.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AASH,0DAiBC;AAxBD,2DAA+D;AAG/D;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,SAA8B,EAC9B,WAA+B;IAE/B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,yFAAyF;QACzF,6FAA6F;QAC7F,MAAM,IAAI,gCAAmB,CAAC,2BAA2B,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,gCAAmB,CAAC,wCAAwC,WAAW,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* @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.dev/license
*/
import { Tree } from '@angular-devkit/schematics';
import { Element } from './parse5-element';
/** Appends the given element HTML fragment to the `<head>` element of the specified HTML file. */
export declare function appendHtmlElementToHead(host: Tree, htmlFilePath: string, elementHtml: string): void;
/** Parses the given HTML file and returns the head element if available. */
export declare function getHtmlHeadTagElement(htmlContent: string): Element | null;
/** Adds a class to the body of the document. */
export declare function addBodyClass(host: Tree, htmlFilePath: string, className: string): void;

View File

@@ -0,0 +1,91 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendHtmlElementToHead = appendHtmlElementToHead;
exports.getHtmlHeadTagElement = getHtmlHeadTagElement;
exports.addBodyClass = addBodyClass;
const schematics_1 = require("@angular-devkit/schematics");
const parse5_element_1 = require("./parse5-element");
const parse5_1 = require("parse5");
/** Appends the given element HTML fragment to the `<head>` element of the specified HTML file. */
function appendHtmlElementToHead(host, htmlFilePath, elementHtml) {
const htmlFileBuffer = host.read(htmlFilePath);
if (!htmlFileBuffer) {
throw new schematics_1.SchematicsException(`Could not read file for path: ${htmlFilePath}`);
}
const htmlContent = htmlFileBuffer.toString();
if (htmlContent.includes(elementHtml)) {
return;
}
const headTag = getHtmlHeadTagElement(htmlContent);
if (!headTag) {
throw Error(`Could not find '<head>' element in HTML file: ${htmlFileBuffer}`);
}
// We always have access to the source code location here because the `getHeadTagElement`
// function explicitly has the `sourceCodeLocationInfo` option enabled.
const endTagOffset = headTag.sourceCodeLocation.endTag.startOffset;
const indentationOffset = (0, parse5_element_1.getChildElementIndentation)(headTag);
const insertion = `${' '.repeat(indentationOffset)}${elementHtml}`;
const recordedChange = host.beginUpdate(htmlFilePath).insertRight(endTagOffset, `${insertion}\n`);
host.commitUpdate(recordedChange);
}
/** Parses the given HTML file and returns the head element if available. */
function getHtmlHeadTagElement(htmlContent) {
return getElementByTagName('head', htmlContent);
}
/** Adds a class to the body of the document. */
function addBodyClass(host, htmlFilePath, className) {
const htmlFileBuffer = host.read(htmlFilePath);
if (!htmlFileBuffer) {
throw new schematics_1.SchematicsException(`Could not read file for path: ${htmlFilePath}`);
}
const htmlContent = htmlFileBuffer.toString();
const body = getElementByTagName('body', htmlContent);
if (!body) {
throw Error(`Could not find <body> element in HTML file: ${htmlFileBuffer}`);
}
const classAttribute = body.attrs.find(attribute => attribute.name === 'class');
if (classAttribute) {
const hasClass = classAttribute.value
.split(' ')
.map(part => part.trim())
.includes(className);
if (!hasClass) {
// We have source code location info enabled, and we pre-checked that the element
// has attributes, specifically the `class` attribute.
const classAttributeLocation = body.sourceCodeLocation.attrs['class'];
const recordedChange = host
.beginUpdate(htmlFilePath)
.insertRight(classAttributeLocation.endOffset - 1, ` ${className}`);
host.commitUpdate(recordedChange);
}
}
else {
const recordedChange = host
.beginUpdate(htmlFilePath)
.insertRight(body.sourceCodeLocation.startTag.endOffset - 1, ` class="${className}"`);
host.commitUpdate(recordedChange);
}
}
/** Finds an element by its tag name. */
function getElementByTagName(tagName, htmlContent) {
const document = (0, parse5_1.parse)(htmlContent, { sourceCodeLocationInfo: true });
const nodeQueue = [...document.childNodes];
while (nodeQueue.length) {
const node = nodeQueue.shift();
if (node.nodeName.toLowerCase() === tagName) {
return node;
}
else if (node.childNodes) {
nodeQueue.push(...node.childNodes);
}
}
return null;
}
//# sourceMappingURL=html-manipulation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"html-manipulation.js","sourceRoot":"","sources":["html-manipulation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAOH,0DA4BC;AAGD,sDAEC;AAGD,oCAqCC;AA9ED,2DAAqE;AACrE,qDAAqE;AACrE,mCAA0C;AAE1C,kGAAkG;AAClG,SAAgB,uBAAuB,CAAC,IAAU,EAAE,YAAoB,EAAE,WAAmB;IAC3F,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE/C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,gCAAmB,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAE9C,IAAI,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,iDAAiD,cAAc,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,yFAAyF;IACzF,u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C3B,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}

19
node_modules/@angular/cdk/schematics/utils/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1,19 @@
/**
* @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.dev/license
*/
export * from './ast';
export * from './ast/ng-module-imports';
export * from './build-component';
export * from './get-project';
export * from './html-manipulation';
export * from './parse5-element';
export * from './project-index-file';
export * from './project-main-file';
export * from './project-style-file';
export * from './project-targets';
export * from './project-tsconfig-paths';
export * from './schematic-options';

36
node_modules/@angular/cdk/schematics/utils/index.js generated vendored Executable file
View File

@@ -0,0 +1,36 @@
"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.dev/license
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ast"), exports);
__exportStar(require("./ast/ng-module-imports"), exports);
__exportStar(require("./build-component"), exports);
__exportStar(require("./get-project"), exports);
__exportStar(require("./html-manipulation"), exports);
__exportStar(require("./parse5-element"), exports);
__exportStar(require("./project-index-file"), exports);
__exportStar(require("./project-main-file"), exports);
__exportStar(require("./project-style-file"), exports);
__exportStar(require("./project-targets"), exports);
__exportStar(require("./project-tsconfig-paths"), exports);
__exportStar(require("./schematic-options"), exports);
//# sourceMappingURL=index.js.map

1
node_modules/@angular/cdk/schematics/utils/index.js.map generated vendored Executable file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,wCAAsB;AACtB,0DAAwC;AACxC,oDAAkC;AAClC,gDAA8B;AAC9B,sDAAoC;AACpC,mDAAiC;AACjC,uDAAqC;AACrC,sDAAoC;AACpC,uDAAqC;AACrC,oDAAkC;AAClC,2DAAyC;AACzC,sDAAoC"}

View File

@@ -0,0 +1,12 @@
/**
* @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.dev/license
*/
import { DefaultTreeAdapterMap } from 'parse5';
export type Element = DefaultTreeAdapterMap['element'];
export type ChildNode = DefaultTreeAdapterMap['childNode'];
/** Determines the indentation of child elements for the given Parse5 element. */
export declare function getChildElementIndentation(element: Element): number;

30
node_modules/@angular/cdk/schematics/utils/parse5-element.js generated vendored Executable file
View File

@@ -0,0 +1,30 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildElementIndentation = getChildElementIndentation;
const schematics_1 = require("@angular-devkit/schematics");
/** Determines the indentation of child elements for the given Parse5 element. */
function getChildElementIndentation(element) {
const childElement = element.childNodes.find(node => node.tagName);
if ((childElement && !childElement.sourceCodeLocation) || !element.sourceCodeLocation) {
throw new schematics_1.SchematicsException('Cannot determine child element indentation because the ' +
'specified Parse5 element does not have any source code location metadata.');
}
const startColumns = childElement
? // In case there are child elements inside of the element, we assume that their
// indentation is also applicable for other child elements.
childElement.sourceCodeLocation.startCol
: // In case there is no child element, we just assume that child elements should be indented
// by two spaces.
element.sourceCodeLocation.startCol + 2;
// Since Parse5 does not set the `startCol` properties as zero-based, we need to subtract
// one column in order to have a proper zero-based offset for the indentation.
return startColumns - 1;
}
//# sourceMappingURL=parse5-element.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parse5-element.js","sourceRoot":"","sources":["parse5-element.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAWH,gEAqBC;AA9BD,2DAA+D;AAQ/D,iFAAiF;AACjF,SAAgB,0BAA0B,CAAC,OAAgB;IACzD,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAE,IAAgB,CAAC,OAAO,CAAmB,CAAC;IAElG,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QACtF,MAAM,IAAI,gCAAmB,CAC3B,yDAAyD;YACvD,2EAA2E,CAC9E,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,+EAA+E;YAC/E,2DAA2D;YAC3D,YAAY,CAAC,kBAAmB,CAAC,QAAQ;QAC3C,CAAC,CAAC,2FAA2F;YAC3F,iBAAiB;YACjB,OAAO,CAAC,kBAAmB,CAAC,QAAQ,GAAG,CAAC,CAAC;IAE7C,yFAAyF;IACzF,8EAA8E;IAC9E,OAAO,YAAY,GAAG,CAAC,CAAC;AAC1B,CAAC"}

View File

@@ -0,0 +1,13 @@
/**
* @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.dev/license
*/
import { ProjectDefinition } from '@schematics/angular/utility';
/**
* Gets the path of the index file in the given project.
* This only searches the base options for each target and not any defined target configurations.
*/
export declare function getProjectIndexFiles(project: ProjectDefinition): string[];

View File

@@ -0,0 +1,43 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectIndexFiles = getProjectIndexFiles;
const posix_1 = require("node:path/posix");
const project_targets_1 = require("./project-targets");
/**
* Gets the path of the index file in the given project.
* This only searches the base options for each target and not any defined target configurations.
*/
function getProjectIndexFiles(project) {
var _a, _b;
// Use a Set to remove duplicate index files referenced in multiple build targets of a project.
const paths = new Set();
for (const target of (0, project_targets_1.getProjectBuildTargets)(project)) {
const indexValue = (_a = target.options) === null || _a === void 0 ? void 0 : _a['index'];
switch (typeof indexValue) {
case 'string':
// "index": "src/index.html"
paths.add(indexValue);
break;
case 'object':
// "index": { "input": "src/index.html", ... }
if (indexValue && 'input' in indexValue) {
paths.add(indexValue['input']);
}
break;
case 'undefined':
// v20+ supports an optional index field; default of `<project_source_root>/index.html`
// `project_source_root` is the project level `sourceRoot`; default of `<project_root>/src`
paths.add((0, posix_1.join)((_b = project.sourceRoot) !== null && _b !== void 0 ? _b : (0, posix_1.join)(project.root, 'src'), 'index.html'));
break;
}
}
return Array.from(paths);
}
//# sourceMappingURL=project-index-file.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"project-index-file.js","sourceRoot":"","sources":["project-index-file.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAUH,oDA2BC;AAnCD,2CAAqC;AACrC,uDAAyD;AAGzD;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,OAA0B;;IAC7D,+FAA+F;IAC/F,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,MAAM,IAAI,IAAA,wCAAsB,EAAC,OAAO,CAAC,EAAE,CAAC;QACrD,MAAM,UAAU,GAAG,MAAA,MAAM,CAAC,OAAO,0CAAG,OAAO,CAAC,CAAC;QAE7C,QAAQ,OAAO,UAAU,EAAE,CAAC;YAC1B,KAAK,QAAQ;gBACX,4BAA4B;gBAC5B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ;gBACX,8CAA8C;gBAC9C,IAAI,UAAU,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;oBACxC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAW,CAAC,CAAC;gBAC3C,CAAC;gBACD,MAAM;YACR,KAAK,WAAW;gBACd,uFAAuF;gBACvF,2FAA2F;gBAC3F,KAAK,CAAC,GAAG,CAAC,IAAA,YAAI,EAAC,MAAA,OAAO,CAAC,UAAU,mCAAI,IAAA,YAAI,EAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC/E,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC"}

View File

@@ -0,0 +1,11 @@
/**
* @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.dev/license
*/
import { Path } from '@angular-devkit/core';
import { ProjectDefinition } from '@schematics/angular/utility';
/** Looks for the main TypeScript file in the given project and returns its path. */
export declare function getProjectMainFile(project: ProjectDefinition): Path;

View File

@@ -0,0 +1,25 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectMainFile = getProjectMainFile;
const schematics_1 = require("@angular-devkit/schematics");
const project_targets_1 = require("./project-targets");
/** Looks for the main TypeScript file in the given project and returns its path. */
function getProjectMainFile(project) {
const buildOptions = (0, project_targets_1.getProjectTargetOptions)(project, 'build');
// `browser` is for the `@angular-devkit/build-angular:application` builder while
// `main` is for the `@angular-devkit/build-angular:browser` builder.
const mainPath = (buildOptions['browser'] || buildOptions['main']);
if (!mainPath) {
throw new schematics_1.SchematicsException(`Could not find the project main file inside of the ` +
`workspace config (${project.sourceRoot})`);
}
return mainPath;
}
//# sourceMappingURL=project-main-file.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"project-main-file.js","sourceRoot":"","sources":["project-main-file.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAQH,gDAeC;AApBD,2DAA+D;AAC/D,uDAA0D;AAG1D,oFAAoF;AACpF,SAAgB,kBAAkB,CAAC,OAA0B;IAC3D,MAAM,YAAY,GAAG,IAAA,yCAAuB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE/D,iFAAiF;IACjF,qEAAqE;IACrE,MAAM,QAAQ,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAqB,CAAC;IAEvF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,gCAAmB,CAC3B,qDAAqD;YACnD,qBAAqB,OAAO,CAAC,UAAU,GAAG,CAC7C,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}

View File

@@ -0,0 +1,13 @@
/**
* @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.dev/license
*/
import { ProjectDefinition } from '@schematics/angular/utility';
/**
* Gets a style file with the given extension in a project and returns its path. If no
* extension is specified, any style file with a valid extension will be returned.
*/
export declare function getProjectStyleFile(project: ProjectDefinition, extension?: string): string | null;

View File

@@ -0,0 +1,42 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectStyleFile = getProjectStyleFile;
const core_1 = require("@angular-devkit/core");
const project_targets_1 = require("./project-targets");
/** Regular expression that matches all possible Angular CLI default style files. */
const defaultStyleFileRegex = /styles\.(c|le|sc)ss/;
/** Regular expression that matches all files that have a proper stylesheet extension. */
const validStyleFileRegex = /\.(c|le|sc)ss/;
/**
* Gets a style file with the given extension in a project and returns its path. If no
* extension is specified, any style file with a valid extension will be returned.
*/
function getProjectStyleFile(project, extension) {
const buildOptions = (0, project_targets_1.getProjectTargetOptions)(project, 'build');
const buildStyles = buildOptions['styles'];
if (buildStyles && (0, core_1.isJsonArray)(buildStyles) && buildStyles.length) {
const styles = buildStyles.map(s => (typeof s === 'string' ? s : s.input));
// Look for the default style file that is generated for new projects by the Angular CLI. This
// default style file is usually called `styles.ext` unless it has been changed explicitly.
const defaultMainStylePath = styles.find(file => extension ? file === `styles.${extension}` : defaultStyleFileRegex.test(file));
if (defaultMainStylePath) {
return (0, core_1.normalize)(defaultMainStylePath);
}
// If no default style file could be found, use the first style file that matches the given
// extension. If no extension specified explicitly, we look for any file with a valid style
// file extension.
const fallbackStylePath = styles.find(file => extension ? file.endsWith(`.${extension}`) : validStyleFileRegex.test(file));
if (fallbackStylePath) {
return (0, core_1.normalize)(fallbackStylePath);
}
}
return null;
}
//# sourceMappingURL=project-style-file.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"project-style-file.js","sourceRoot":"","sources":["project-style-file.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAgBH,kDA8BC;AA5CD,+CAA4D;AAC5D,uDAA0D;AAG1D,oFAAoF;AACpF,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAEpD,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,OAA0B,EAAE,SAAkB;IAChF,MAAM,YAAY,GAAG,IAAA,yCAAuB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAE3C,IAAI,WAAW,IAAI,IAAA,kBAAW,EAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QAClE,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAEhG,8FAA8F;QAC9F,2FAA2F;QAC3F,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9C,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,SAAS,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAC9E,CAAC;QAEF,IAAI,oBAAoB,EAAE,CAAC;YACzB,OAAO,IAAA,gBAAS,EAAC,oBAAoB,CAAC,CAAC;QACzC,CAAC;QAED,2FAA2F;QAC3F,2FAA2F;QAC3F,kBAAkB;QAClB,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3C,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5E,CAAC;QAEF,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO,IAAA,gBAAS,EAAC,iBAAiB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* @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.dev/license
*/
import { JsonValue } from '@angular-devkit/core';
import { ProjectDefinition, TargetDefinition } from '@schematics/angular/utility';
/** Resolves the architect options for the build target of the given project. */
export declare function getProjectTargetOptions(project: ProjectDefinition, buildTarget: string): Record<string, JsonValue | undefined>;
/** Gets all of the default CLI-provided build targets in a project. */
export declare function getProjectBuildTargets(project: ProjectDefinition): TargetDefinition[];
/** Gets all of the default CLI-provided testing targets in a project. */
export declare function getProjectTestTargets(project: ProjectDefinition): TargetDefinition[];

View File

@@ -0,0 +1,46 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectTargetOptions = getProjectTargetOptions;
exports.getProjectBuildTargets = getProjectBuildTargets;
exports.getProjectTestTargets = getProjectTestTargets;
const schematics_1 = require("@angular-devkit/schematics");
/** Possible names of CLI builders used to configure the project. */
const PROJECT_BUILDERS = new Set([
'@angular-devkit/build-angular:browser-esbuild',
'@angular-devkit/build-angular:application',
'@angular-devkit/build-angular:browser',
'@angular/build:application',
]);
/** Possible name of CLI builders used to run tests in the project. */
const TEST_BUILDERS = new Set(['@angular-devkit/build-angular:karma', '@angular/build:karma']);
/** Resolves the architect options for the build target of the given project. */
function getProjectTargetOptions(project, buildTarget) {
var _a, _b;
const options = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.get(buildTarget)) === null || _b === void 0 ? void 0 : _b.options;
if (!options) {
throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`);
}
return options;
}
/** Gets all of the default CLI-provided build targets in a project. */
function getProjectBuildTargets(project) {
return getTargetsByBuilderName(project, builder => !!builder && PROJECT_BUILDERS.has(builder));
}
/** Gets all of the default CLI-provided testing targets in a project. */
function getProjectTestTargets(project) {
return getTargetsByBuilderName(project, builder => !!builder && TEST_BUILDERS.has(builder));
}
/** Gets all targets from the given project that pass a predicate check. */
function getTargetsByBuilderName(project, predicate) {
return Array.from(project.targets.keys())
.filter(name => { var _a; return predicate((_a = project.targets.get(name)) === null || _a === void 0 ? void 0 : _a.builder); })
.map(name => project.targets.get(name));
}
//# sourceMappingURL=project-targets.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"project-targets.js","sourceRoot":"","sources":["project-targets.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAkBH,0DAaC;AAGD,wDAEC;AAG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IAAI,CAAC,0CAAE,OAAO,CAAC,CAAA,EAAA,CAAC;SAC7D,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC;AAC7C,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* @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.dev/license
*/
import { Tree } from '@angular-devkit/schematics';
import { ProjectDefinition, WorkspaceDefinition } from '@schematics/angular/utility';
import { WorkspacePath } from '../update-tool/file-system';
/** Gets the tsconfig path from the given target within the specified project. */
export declare function getTargetTsconfigPath(project: ProjectDefinition, targetName: string): WorkspacePath | null;
/** Resolve the workspace configuration of the specified tree gracefully. */
export declare function getWorkspaceConfigGracefully(tree: Tree): Promise<WorkspaceDefinition | null>;

View File

@@ -0,0 +1,46 @@
"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.dev/license
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTargetTsconfigPath = getTargetTsconfigPath;
exports.getWorkspaceConfigGracefully = getWorkspaceConfigGracefully;
const core_1 = require("@angular-devkit/core");
const utility_1 = require("@schematics/angular/utility");
/** Name of the default Angular CLI workspace configuration files. */
const defaultWorkspaceConfigPaths = ['/angular.json', '/.angular.json'];
/** Gets the tsconfig path from the given target within the specified project. */
function getTargetTsconfigPath(project, targetName) {
var _a, _b, _c;
const tsconfig = (_c = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.get(targetName)) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c['tsConfig'];
return tsconfig ? (0, core_1.normalize)(tsconfig) : null;
}
/** Resolve the workspace configuration of the specified tree gracefully. */
function getWorkspaceConfigGracefully(tree) {
return __awaiter(this, void 0, void 0, function* () {
const path = defaultWorkspaceConfigPaths.find(filePath => tree.exists(filePath));
if (!path) {
return null;
}
try {
return (0, utility_1.readWorkspace)(tree, path);
}
catch (_a) {
return null;
}
});
}
//# sourceMappingURL=project-tsconfig-paths.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"project-tsconfig-paths.js","sourceRoot":"","sources":["project-tsconfig-paths.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;AAWH,sDAMC;AAGD,oEAcC;AAhCD,+CAA+C;AAE/C,yDAAkG;AAGlG,qEAAqE;AACrE,MAAM,2BAA2B,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAExE,iFAAiF;AACjF,SAAgB,qBAAqB,CACnC,OAA0B,EAC1B,UAAkB;;IAElB,MAAM,QAAQ,GAAG,MAAA,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,UAAU,CAAC,0CAAE,OAAO,0CAAG,UAAU,CAAC,CAAC;IACzE,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,gBAAS,EAAC,QAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED,4EAA4E;AAC5E,SAAsB,4BAA4B,CAChD,IAAU;;QAEV,MAAM,IAAI,GAAG,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEjF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,OAAO,IAAA,uBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}

View File

@@ -0,0 +1,20 @@
/**
* @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.dev/license
*/
import { Schema } from '@schematics/angular/component/schema';
import { ProjectDefinition } from '@schematics/angular/utility';
import { Tree } from '@angular-devkit/schematics';
/**
* 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.
*/
export declare function getDefaultComponentOptions(project: ProjectDefinition): Partial<Schema>;
/** Determines whether the schematic is configured to be standalone. */
export declare function isStandaloneSchematic(host: Tree, options: Schema): Promise<boolean>;

View File

@@ -0,0 +1,89 @@
"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.dev/license
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultComponentOptions = getDefaultComponentOptions;
exports.isStandaloneSchematic = isStandaloneSchematic;
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 utility_1 = require("@schematics/angular/utility");
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,
};
}
/** Determines whether the schematic is configured to be standalone. */
function isStandaloneSchematic(host, options) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
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 = yield (0, utility_1.readWorkspace)(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 (!((_a = project.targets) === null || _a === void 0 ? void 0 : _a.has('build'))) {
return false;
}
return (0, ng_ast_utils_1.isStandaloneApp)(host, (0, project_main_file_1.getProjectMainFile)(project));
});
}
/**
* 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=schematic-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schematic-options.js","sourceRoot":"","sources":["schematic-options.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;AAiBH,gEAmBC;AAGD,sDAgBC;AArDD,+CAA8D;AAC9D,iEAAmE;AACnE,2EAAyE;AACzE,2DAAuD;AACvD,yDAA6E;AAC7E,+CAAsD;AAGtD;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,OAA0B;IACnE,wFAAwF;IACxF,kFAAkF;IAClF,2FAA2F;IAC3F,IAAI,SAAS,GAAG,yBAAyB,CAAiB,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;IAExF,yFAAyF;IACzF,kFAAkF;IAClF,8FAA8F;IAC9F,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,SAAS,GAAG,CAAC,yBAAyB,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,KAAK,EAAE,yBAAyB,CAAQ,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,cAAK,CAAC,GAAG,CAAC;QAClF,WAAW,EAAE,yBAAyB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;QACvE,cAAc,EAAE,yBAAyB,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAC7E,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,SAAsB,qBAAqB,CAAC,IAAU,EAAE,OAAe;;;QACrE,IAAI,OAAO,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;Y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