Primeiro commit do projeto Angular
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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';
|
||||
/** Data resolved for a bootstrapped component. */
|
||||
interface BootstrappedComponentData {
|
||||
/** Original name of the component class. */
|
||||
componentName: string;
|
||||
/** Path under which the component was imported in the main entrypoint. */
|
||||
componentImportPathInSameFile: string;
|
||||
/** Original name of the NgModule being bootstrapped, null if the app isn't module-based. */
|
||||
moduleName: string | null;
|
||||
/**
|
||||
* Path under which the module was imported in the main entrypoint,
|
||||
* null if the app isn't module-based.
|
||||
*/
|
||||
moduleImportPathInSameFile: string | null;
|
||||
}
|
||||
/**
|
||||
* Finds the original name and path relative to the `main.ts` of the bootrstrapped app component.
|
||||
* @param tree File tree in which to look for the component.
|
||||
* @param mainFilePath Path of the `main` file.
|
||||
*/
|
||||
export declare function resolveBootstrappedComponentData(tree: Tree, mainFilePath: string): BootstrappedComponentData | null;
|
||||
export {};
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveBootstrappedComponentData = resolveBootstrappedComponentData;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
||||
const ast_utils_1 = require("../ast-utils");
|
||||
const ng_ast_utils_1 = require("../ng-ast-utils");
|
||||
const util_1 = require("./util");
|
||||
/**
|
||||
* Finds the original name and path relative to the `main.ts` of the bootrstrapped app component.
|
||||
* @param tree File tree in which to look for the component.
|
||||
* @param mainFilePath Path of the `main` file.
|
||||
*/
|
||||
function resolveBootstrappedComponentData(tree, mainFilePath) {
|
||||
// First try to resolve for a standalone app.
|
||||
try {
|
||||
const call = (0, util_1.findBootstrapApplicationCall)(tree, mainFilePath);
|
||||
if (call.arguments.length > 0 && typescript_1.default.isIdentifier(call.arguments[0])) {
|
||||
const resolved = resolveIdentifier(call.arguments[0]);
|
||||
if (resolved) {
|
||||
return {
|
||||
componentName: resolved.name,
|
||||
componentImportPathInSameFile: resolved.path,
|
||||
moduleName: null,
|
||||
moduleImportPathInSameFile: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// `findBootstrapApplicationCall` will throw if it can't find the `bootrstrapApplication` call.
|
||||
// Catch so we can continue to the fallback logic.
|
||||
if (!(e instanceof schematics_1.SchematicsException)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// Otherwise fall back to resolving an NgModule-based app.
|
||||
return resolveNgModuleBasedData(tree, mainFilePath);
|
||||
}
|
||||
/** Resolves the bootstrap data for a NgModule-based app. */
|
||||
function resolveNgModuleBasedData(tree, mainFilePath) {
|
||||
const appModulePath = (0, ng_ast_utils_1.getAppModulePath)(tree, mainFilePath);
|
||||
const appModuleFile = (0, util_1.getSourceFile)(tree, appModulePath);
|
||||
const metadataNodes = (0, ast_utils_1.getDecoratorMetadata)(appModuleFile, 'NgModule', '@angular/core');
|
||||
for (const node of metadataNodes) {
|
||||
if (!typescript_1.default.isObjectLiteralExpression(node)) {
|
||||
continue;
|
||||
}
|
||||
const bootstrapProp = (0, ast_utils_1.getMetadataField)(node, 'bootstrap').find((prop) => {
|
||||
return (typescript_1.default.isArrayLiteralExpression(prop.initializer) &&
|
||||
prop.initializer.elements.length > 0 &&
|
||||
typescript_1.default.isIdentifier(prop.initializer.elements[0]));
|
||||
});
|
||||
const componentIdentifier = (bootstrapProp?.initializer)
|
||||
.elements[0];
|
||||
const componentResult = componentIdentifier ? resolveIdentifier(componentIdentifier) : null;
|
||||
const bootstrapCall = (0, ng_ast_utils_1.findBootstrapModuleCall)(tree, mainFilePath);
|
||||
if (componentResult &&
|
||||
bootstrapCall &&
|
||||
bootstrapCall.arguments.length > 0 &&
|
||||
typescript_1.default.isIdentifier(bootstrapCall.arguments[0])) {
|
||||
const moduleResult = resolveIdentifier(bootstrapCall.arguments[0]);
|
||||
if (moduleResult) {
|
||||
return {
|
||||
componentName: componentResult.name,
|
||||
componentImportPathInSameFile: componentResult.path,
|
||||
moduleName: moduleResult.name,
|
||||
moduleImportPathInSameFile: moduleResult.path,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/** Resolves an identifier to its original name and path that it was imported from. */
|
||||
function resolveIdentifier(identifier) {
|
||||
const sourceFile = identifier.getSourceFile();
|
||||
// Try to resolve the import path by looking at the top-level named imports of the file.
|
||||
for (const node of sourceFile.statements) {
|
||||
if (!typescript_1.default.isImportDeclaration(node) ||
|
||||
!typescript_1.default.isStringLiteral(node.moduleSpecifier) ||
|
||||
!node.importClause ||
|
||||
!node.importClause.namedBindings ||
|
||||
!typescript_1.default.isNamedImports(node.importClause.namedBindings)) {
|
||||
continue;
|
||||
}
|
||||
for (const element of node.importClause.namedBindings.elements) {
|
||||
if (element.name.text === identifier.text) {
|
||||
return {
|
||||
// Note that we use `propertyName` if available, because it contains
|
||||
// the real name in the case where the import is aliased.
|
||||
name: (element.propertyName || element.name).text,
|
||||
path: node.moduleSpecifier.text,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=app_component.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app_component.js","sourceRoot":"","sources":["app_component.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AA+BH,4EA8BC;AA3DD,2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CAAC,IAAI;iBAC9C,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sFAAsF;AACtF,SAAS,iBAAiB,CAAC,UAAyB;IAClD,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;IAE9C,wFAAwF;IACxF,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,IACE,CAAC,oBAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC7B,CAAC,oBAAE,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC;YACzC,CAAC,IAAI,CAAC,YAAY;YAClB,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa;YAChC,CAAC,oBAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EACnD,CAAC;YACD,SAAS;QACX,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC/D,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC;gBAC1C,OAAO;oBACL,oEAAoE;oBACpE,yDAAyD;oBACzD,IAAI,EAAE,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI;oBACjD,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;iBAChC,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @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 ts from '../../third_party/github.com/Microsoft/TypeScript/lib/typescript';
|
||||
/** App config that was resolved to its source node. */
|
||||
export interface ResolvedAppConfig {
|
||||
/** Tree-relative path of the file containing the app config. */
|
||||
filePath: string;
|
||||
/** Node defining the app config. */
|
||||
node: ts.ObjectLiteralExpression;
|
||||
}
|
||||
/**
|
||||
* Resolves the node that defines the app config from a bootstrap call.
|
||||
* @param bootstrapCall Call for which to resolve the config.
|
||||
* @param tree File tree of the project.
|
||||
* @param filePath File path of the bootstrap call.
|
||||
*/
|
||||
export declare function findAppConfig(bootstrapCall: ts.CallExpression, tree: Tree, filePath: string): ResolvedAppConfig | null;
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findAppConfig = findAppConfig;
|
||||
const node_path_1 = require("node:path");
|
||||
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
||||
const util_1 = require("./util");
|
||||
/**
|
||||
* Resolves the node that defines the app config from a bootstrap call.
|
||||
* @param bootstrapCall Call for which to resolve the config.
|
||||
* @param tree File tree of the project.
|
||||
* @param filePath File path of the bootstrap call.
|
||||
*/
|
||||
function findAppConfig(bootstrapCall, tree, filePath) {
|
||||
if (bootstrapCall.arguments.length > 1) {
|
||||
const config = bootstrapCall.arguments[1];
|
||||
if (typescript_1.default.isObjectLiteralExpression(config)) {
|
||||
return { filePath, node: config };
|
||||
}
|
||||
if (typescript_1.default.isIdentifier(config)) {
|
||||
return resolveAppConfigFromIdentifier(config, tree, filePath);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Resolves the app config from an identifier referring to it.
|
||||
* @param identifier Identifier referring to the app config.
|
||||
* @param tree File tree of the project.
|
||||
* @param bootstapFilePath Path of the bootstrap call.
|
||||
*/
|
||||
function resolveAppConfigFromIdentifier(identifier, tree, bootstapFilePath) {
|
||||
const sourceFile = identifier.getSourceFile();
|
||||
for (const node of sourceFile.statements) {
|
||||
// Only look at relative imports. This will break if the app uses a path
|
||||
// mapping to refer to the import, but in order to resolve those, we would
|
||||
// need knowledge about the entire program.
|
||||
if (!typescript_1.default.isImportDeclaration(node) ||
|
||||
!node.importClause?.namedBindings ||
|
||||
!typescript_1.default.isNamedImports(node.importClause.namedBindings) ||
|
||||
!typescript_1.default.isStringLiteralLike(node.moduleSpecifier) ||
|
||||
!node.moduleSpecifier.text.startsWith('.')) {
|
||||
continue;
|
||||
}
|
||||
for (const specifier of node.importClause.namedBindings.elements) {
|
||||
if (specifier.name.text !== identifier.text) {
|
||||
continue;
|
||||
}
|
||||
// Look for a variable with the imported name in the file. Note that ideally we would use
|
||||
// the type checker to resolve this, but we can't because these utilities are set up to
|
||||
// operate on individual files, not the entire program.
|
||||
const filePath = (0, node_path_1.join)((0, node_path_1.dirname)(bootstapFilePath), node.moduleSpecifier.text + '.ts');
|
||||
const importedSourceFile = (0, util_1.getSourceFile)(tree, filePath);
|
||||
const resolvedVariable = findAppConfigFromVariableName(importedSourceFile, (specifier.propertyName || specifier.name).text);
|
||||
if (resolvedVariable) {
|
||||
return { filePath, node: resolvedVariable };
|
||||
}
|
||||
}
|
||||
}
|
||||
const variableInSameFile = findAppConfigFromVariableName(sourceFile, identifier.text);
|
||||
return variableInSameFile ? { filePath: bootstapFilePath, node: variableInSameFile } : null;
|
||||
}
|
||||
/**
|
||||
* Finds an app config within the top-level variables of a file.
|
||||
* @param sourceFile File in which to search for the config.
|
||||
* @param variableName Name of the variable containing the config.
|
||||
*/
|
||||
function findAppConfigFromVariableName(sourceFile, variableName) {
|
||||
for (const node of sourceFile.statements) {
|
||||
if (typescript_1.default.isVariableStatement(node)) {
|
||||
for (const decl of node.declarationList.declarations) {
|
||||
if (typescript_1.default.isIdentifier(decl.name) &&
|
||||
decl.name.text === variableName &&
|
||||
decl.initializer &&
|
||||
typescript_1.default.isObjectLiteralExpression(decl.initializer)) {
|
||||
return decl.initializer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=app_config.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app_config.js","sourceRoot":"","sources":["app_config.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAsBH,sCAkBC;AArCD,yCAA0C;AAC1C,kHAAkF;AAClF,iCAAuC;AAWvC;;;;;GAKG;AACH,SAAgB,aAAa,CAC3B,aAAgC,EAChC,IAAU,EACV,QAAgB;IAEhB,IAAI,aAAa,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,oBAAE,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC;YACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACpC,CAAC;QAED,IAAI,oBAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,8BAA8B,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,8BAA8B,CACrC,UAAyB,EACzB,IAAU,EACV,gBAAwB;IAExB,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;IAE9C,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,wEAAwE;QACxE,0EAA0E;QAC1E,2CAA2C;QAC3C,IACE,CAAC,oBAAE,CAAC,mBAAmB,CAAC,IAA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;AAED;;;;GAIG;AACH,SAAS,6BAA6B,CACpC,UAAyB,EACzB,YAAoB;IAEpB,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,oBAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC;gBACrD,IACE,oBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;oBAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY;oBAC/B,IAAI,CAAC,WAAW;oBAChB,oBAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAC9C,CAAC;oBACD,OAAO,IAAI,CAAC,WAAW,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @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';
|
||||
/** Generated code that hasn't been interpolated yet. */
|
||||
export interface PendingCode {
|
||||
/** Code that will be inserted. */
|
||||
expression: string;
|
||||
/** Imports that need to be added to the file in which the code is inserted. */
|
||||
imports: PendingImports;
|
||||
}
|
||||
/** Map keeping track of imports and aliases under which they're referred to in an expression. */
|
||||
type PendingImports = Map<string, Map<string, string>>;
|
||||
/**
|
||||
* Callback invoked by a Rule that produces the code
|
||||
* that needs to be inserted somewhere in the app.
|
||||
*/
|
||||
export type CodeBlockCallback = (block: CodeBlock) => PendingCode;
|
||||
/**
|
||||
* Utility class used to generate blocks of code that
|
||||
* can be inserted by the devkit into a user's app.
|
||||
*/
|
||||
export declare class CodeBlock {
|
||||
private _imports;
|
||||
/** Function used to tag a code block in order to produce a `PendingCode` object. */
|
||||
code: (strings: TemplateStringsArray, ...params: unknown[]) => PendingCode;
|
||||
/**
|
||||
* Used inside of a code block to mark external symbols and which module they should be imported
|
||||
* from. When the code is inserted, the required import statements will be produced automatically.
|
||||
* @param symbolName Name of the external symbol.
|
||||
* @param moduleName Module from which the symbol should be imported.
|
||||
*/
|
||||
external: (symbolName: string, moduleName: string) => string;
|
||||
/**
|
||||
* Produces the necessary rules to transform a `PendingCode` object into valid code.
|
||||
* @param initialCode Code pending transformed.
|
||||
* @param filePath Path of the file in which the code will be inserted.
|
||||
*/
|
||||
static transformPendingCode(initialCode: PendingCode, filePath: string): {
|
||||
code: PendingCode;
|
||||
rules: Rule[];
|
||||
};
|
||||
}
|
||||
export {};
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CodeBlock = void 0;
|
||||
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
||||
const ast_utils_1 = require("../ast-utils");
|
||||
const change_1 = require("../change");
|
||||
/** Counter used to generate unique IDs. */
|
||||
let uniqueIdCounter = 0;
|
||||
/**
|
||||
* Utility class used to generate blocks of code that
|
||||
* can be inserted by the devkit into a user's app.
|
||||
*/
|
||||
class CodeBlock {
|
||||
_imports = new Map();
|
||||
// Note: the methods here are defined as arrow function so that they can be destructured by
|
||||
// consumers without losing their context. This makes the API more concise.
|
||||
/** Function used to tag a code block in order to produce a `PendingCode` object. */
|
||||
code = (strings, ...params) => {
|
||||
return {
|
||||
expression: strings.map((part, index) => part + (params[index] || '')).join(''),
|
||||
imports: this._imports,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Used inside of a code block to mark external symbols and which module they should be imported
|
||||
* from. When the code is inserted, the required import statements will be produced automatically.
|
||||
* @param symbolName Name of the external symbol.
|
||||
* @param moduleName Module from which the symbol should be imported.
|
||||
*/
|
||||
external = (symbolName, moduleName) => {
|
||||
if (!this._imports.has(moduleName)) {
|
||||
this._imports.set(moduleName, new Map());
|
||||
}
|
||||
const symbolsPerModule = this._imports.get(moduleName);
|
||||
if (!symbolsPerModule.has(symbolName)) {
|
||||
symbolsPerModule.set(symbolName, `@@__SCHEMATIC_PLACEHOLDER_${uniqueIdCounter++}__@@`);
|
||||
}
|
||||
return symbolsPerModule.get(symbolName);
|
||||
};
|
||||
/**
|
||||
* Produces the necessary rules to transform a `PendingCode` object into valid code.
|
||||
* @param initialCode Code pending transformed.
|
||||
* @param filePath Path of the file in which the code will be inserted.
|
||||
*/
|
||||
static transformPendingCode(initialCode, filePath) {
|
||||
const code = { ...initialCode };
|
||||
const rules = [];
|
||||
code.imports.forEach((symbols, moduleName) => {
|
||||
symbols.forEach((placeholder, symbolName) => {
|
||||
rules.push((tree) => {
|
||||
const recorder = tree.beginUpdate(filePath);
|
||||
const sourceFile = typescript_1.default.createSourceFile(filePath, tree.readText(filePath), typescript_1.default.ScriptTarget.Latest, true);
|
||||
// Note that this could still technically clash if there's a top-level symbol called
|
||||
// `${symbolName}_alias`, however this is unlikely. We can revisit this if it becomes
|
||||
// a problem.
|
||||
const alias = (0, ast_utils_1.hasTopLevelIdentifier)(sourceFile, symbolName, moduleName)
|
||||
? symbolName + '_alias'
|
||||
: undefined;
|
||||
code.expression = code.expression.replace(new RegExp(placeholder, 'g'), alias || symbolName);
|
||||
(0, change_1.applyToUpdateRecorder)(recorder, [
|
||||
(0, ast_utils_1.insertImport)(sourceFile, filePath, symbolName, moduleName, false, alias),
|
||||
]);
|
||||
tree.commitUpdate(recorder);
|
||||
});
|
||||
});
|
||||
});
|
||||
return { code, rules };
|
||||
}
|
||||
}
|
||||
exports.CodeBlock = CodeBlock;
|
||||
//# sourceMappingURL=code_block.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"code_block.js","sourceRoot":"","sources":["code_block.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAGH,kHAAkF;AAClF,4CAAmE;AACnE,sCAAkD;AAclD,2CAA2C;AAC3C,IAAI,eAAe,GAAG,CAAC,CAAC;AAQxB;;;GAGG;AACH,MAAa,SAAS;IACZ,QAAQ,GAAmB,IAAI,GAAG,EAA+B,CAAC;IAE1E,2FAA2F;IAC3F,2EAA2E;IAE3E,oFAAoF;IACpF,IAAI,GAAG,CAAC,OAA6B,EAAE,GAAG,MAAiB,EAAe,EAAE;QAC1E,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/E,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;OAKG;IACH,QAAQ,GAAG,CAAC,UAAkB,EAAE,UAAkB,EAAU,EAAE;QAC5D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAwB,CAAC;QAE9E,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtC,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,6BAA6B,eAAe,EAAE,MAAM,CAAC,CAAC;Q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;gBAC9B,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AA/ED,8BA+EC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @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 { addRootImport, addRootProvider } from './rules';
|
||||
export type { PendingCode, CodeBlockCallback, CodeBlock } from './code_block';
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"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.addRootProvider = exports.addRootImport = void 0;
|
||||
var rules_1 = require("./rules");
|
||||
Object.defineProperty(exports, "addRootImport", { enumerable: true, get: function () { return rules_1.addRootImport; } });
|
||||
Object.defineProperty(exports, "addRootProvider", { enumerable: true, get: function () { return rules_1.addRootProvider; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAAyD;AAAhD,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA"}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @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 { CodeBlockCallback } from './code_block';
|
||||
/**
|
||||
* Adds an import to the root of the project.
|
||||
* @param project Name of the project to which to add the import.
|
||||
* @param callback Function that generates the code block which should be inserted.
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { Rule } from '@angular-devkit/schematics';
|
||||
* import { addRootImport } from '@schematics/angular/utility';
|
||||
*
|
||||
* export default function(): Rule {
|
||||
* return addRootImport('default', ({code, external}) => {
|
||||
* return code`${external('MyModule', '@my/module')}.forRoot({})`;
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function addRootImport(project: string, callback: CodeBlockCallback): Rule;
|
||||
/**
|
||||
* Adds a provider to the root of the project.
|
||||
* @param project Name of the project to which to add the import.
|
||||
* @param callback Function that generates the code block which should be inserted.
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { Rule } from '@angular-devkit/schematics';
|
||||
* import { addRootProvider } from '@schematics/angular/utility';
|
||||
*
|
||||
* export default function(): Rule {
|
||||
* return addRootProvider('default', ({code, external}) => {
|
||||
* return code`${external('provideLibrary', '@my/library')}({})`;
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function addRootProvider(project: string, callback: CodeBlockCallback): Rule;
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
"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.addRootImport = addRootImport;
|
||||
exports.addRootProvider = addRootProvider;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const ast_utils_1 = require("../ast-utils");
|
||||
const change_1 = require("../change");
|
||||
const ng_ast_utils_1 = require("../ng-ast-utils");
|
||||
const app_config_1 = require("./app_config");
|
||||
const code_block_1 = require("./code_block");
|
||||
const util_1 = require("./util");
|
||||
/**
|
||||
* Adds an import to the root of the project.
|
||||
* @param project Name of the project to which to add the import.
|
||||
* @param callback Function that generates the code block which should be inserted.
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { Rule } from '@angular-devkit/schematics';
|
||||
* import { addRootImport } from '@schematics/angular/utility';
|
||||
*
|
||||
* export default function(): Rule {
|
||||
* return addRootImport('default', ({code, external}) => {
|
||||
* return code`${external('MyModule', '@my/module')}.forRoot({})`;
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function addRootImport(project, callback) {
|
||||
return getRootInsertionRule(project, callback, 'imports', {
|
||||
name: 'importProvidersFrom',
|
||||
module: '@angular/core',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Adds a provider to the root of the project.
|
||||
* @param project Name of the project to which to add the import.
|
||||
* @param callback Function that generates the code block which should be inserted.
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import { Rule } from '@angular-devkit/schematics';
|
||||
* import { addRootProvider } from '@schematics/angular/utility';
|
||||
*
|
||||
* export default function(): Rule {
|
||||
* return addRootProvider('default', ({code, external}) => {
|
||||
* return code`${external('provideLibrary', '@my/library')}({})`;
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function addRootProvider(project, callback) {
|
||||
return getRootInsertionRule(project, callback, 'providers');
|
||||
}
|
||||
/**
|
||||
* Creates a rule that inserts code at the root of either a standalone or NgModule-based project.
|
||||
* @param project Name of the project into which to inser tthe code.
|
||||
* @param callback Function that generates the code block which should be inserted.
|
||||
* @param ngModuleField Field of the root NgModule into which the code should be inserted, if the
|
||||
* app is based on NgModule
|
||||
* @param standaloneWrapperFunction Function with which to wrap the code if the app is standalone.
|
||||
*/
|
||||
function getRootInsertionRule(project, callback, ngModuleField, standaloneWrapperFunction) {
|
||||
return async (host) => {
|
||||
const mainFilePath = await (0, util_1.getMainFilePath)(host, project);
|
||||
const codeBlock = new code_block_1.CodeBlock();
|
||||
if ((0, ng_ast_utils_1.isStandaloneApp)(host, mainFilePath)) {
|
||||
return (tree) => addProviderToStandaloneBootstrap(tree, callback(codeBlock), mainFilePath, standaloneWrapperFunction);
|
||||
}
|
||||
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainFilePath);
|
||||
const pendingCode = code_block_1.CodeBlock.transformPendingCode(callback(codeBlock), modulePath);
|
||||
return (0, schematics_1.chain)([
|
||||
...pendingCode.rules,
|
||||
(tree) => {
|
||||
const changes = (0, ast_utils_1.addSymbolToNgModuleMetadata)((0, util_1.getSourceFile)(tree, modulePath), modulePath, ngModuleField, pendingCode.code.expression,
|
||||
// Explicitly set the import path to null since we deal with imports here separately.
|
||||
null);
|
||||
(0, util_1.applyChangesToFile)(tree, modulePath, changes);
|
||||
},
|
||||
]);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds a provider to the root of a standalone project.
|
||||
* @param host Tree of the root rule.
|
||||
* @param pendingCode Code that should be inserted.
|
||||
* @param mainFilePath Path to the project's main file.
|
||||
* @param wrapperFunction Optional function with which to wrap the provider.
|
||||
*/
|
||||
function addProviderToStandaloneBootstrap(host, pendingCode, mainFilePath, wrapperFunction) {
|
||||
const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
|
||||
const fileToEdit = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath)?.filePath || mainFilePath;
|
||||
const { code, rules } = code_block_1.CodeBlock.transformPendingCode(pendingCode, fileToEdit);
|
||||
return (0, schematics_1.chain)([
|
||||
...rules,
|
||||
() => {
|
||||
let wrapped;
|
||||
let additionalRules;
|
||||
if (wrapperFunction) {
|
||||
const block = new code_block_1.CodeBlock();
|
||||
const result = code_block_1.CodeBlock.transformPendingCode(block.code `${block.external(wrapperFunction.name, wrapperFunction.module)}(${code.expression})`, fileToEdit);
|
||||
wrapped = result.code;
|
||||
additionalRules = result.rules;
|
||||
}
|
||||
else {
|
||||
wrapped = code;
|
||||
additionalRules = [];
|
||||
}
|
||||
return (0, schematics_1.chain)([
|
||||
...additionalRules,
|
||||
(tree) => insertStandaloneRootProvider(tree, mainFilePath, wrapped.expression),
|
||||
]);
|
||||
},
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Inserts a string expression into the root of a standalone project.
|
||||
* @param tree File tree used to modify the project.
|
||||
* @param mainFilePath Path to the main file of the project.
|
||||
* @param expression Code expression to be inserted.
|
||||
*/
|
||||
function insertStandaloneRootProvider(tree, mainFilePath, expression) {
|
||||
const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(tree, mainFilePath);
|
||||
const appConfig = (0, app_config_1.findAppConfig)(bootstrapCall, tree, mainFilePath);
|
||||
if (bootstrapCall.arguments.length === 0) {
|
||||
throw new schematics_1.SchematicsException(`Cannot add provider to invalid bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
|
||||
}
|
||||
if (appConfig) {
|
||||
addProvidersExpressionToAppConfig(tree, appConfig, expression);
|
||||
return;
|
||||
}
|
||||
const newAppConfig = `, {\n${' '.repeat(2)}providers: [${expression}]\n}`;
|
||||
let targetCall;
|
||||
if (bootstrapCall.arguments.length === 1) {
|
||||
targetCall = bootstrapCall;
|
||||
}
|
||||
else if ((0, util_1.isMergeAppConfigCall)(bootstrapCall.arguments[1])) {
|
||||
targetCall = bootstrapCall.arguments[1];
|
||||
}
|
||||
else {
|
||||
throw new schematics_1.SchematicsException(`Cannot statically analyze bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
|
||||
}
|
||||
(0, util_1.applyChangesToFile)(tree, mainFilePath, [
|
||||
(0, ast_utils_1.insertAfterLastOccurrence)(targetCall.arguments, newAppConfig, mainFilePath, targetCall.getEnd() - 1),
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Adds a string expression to an app config object.
|
||||
* @param tree File tree used to modify the project.
|
||||
* @param appConfig Resolved configuration object of the project.
|
||||
* @param expression Code expression to be inserted.
|
||||
*/
|
||||
function addProvidersExpressionToAppConfig(tree, appConfig, expression) {
|
||||
const { node, filePath } = appConfig;
|
||||
const configProps = node.properties;
|
||||
const providersLiteral = (0, util_1.findProvidersLiteral)(node);
|
||||
// If there's a `providers` property, we can add the provider
|
||||
// to it, otherwise we need to declare it ourselves.
|
||||
if (providersLiteral) {
|
||||
(0, util_1.applyChangesToFile)(tree, filePath, [
|
||||
(0, ast_utils_1.insertAfterLastOccurrence)(providersLiteral.elements, (providersLiteral.elements.length === 0 ? '' : ', ') + expression, filePath, providersLiteral.getStart() + 1),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
const prop = `${' '.repeat(2)}providers: [${expression}]`;
|
||||
let toInsert;
|
||||
let insertPosition;
|
||||
if (configProps.length === 0) {
|
||||
toInsert = '\n' + prop + '\n';
|
||||
insertPosition = node.getEnd() - 1;
|
||||
}
|
||||
else {
|
||||
const hasTrailingComma = configProps.hasTrailingComma;
|
||||
toInsert = (hasTrailingComma ? '' : ',') + '\n' + prop;
|
||||
insertPosition = configProps[configProps.length - 1].getEnd() + (hasTrailingComma ? 1 : 0);
|
||||
}
|
||||
(0, util_1.applyChangesToFile)(tree, filePath, [new change_1.InsertChange(filePath, insertPosition, toInsert)]);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=rules.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rules.js","sourceRoot":"","sources":["rules.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAmCH,sCAKC;AAmBD,0CAEC;AA3DD,2DAAoF;AAEpF,4CAAsF;AACtF,sCAAyC;AACzC,kDAAoE;AACpE,6CAAgE;AAChE,6CAAyE;AACzE,iCAOgB;AAEhB;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,QAA2B;IACxE,OAAO,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;QACxD,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EAAE,eAAe;KACxB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,QAA2B;IAC1E,OAAO,o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AAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @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 ts from '../../third_party/github.com/Microsoft/TypeScript/lib/typescript';
|
||||
import { Change } from '../change';
|
||||
/**
|
||||
* Finds the main file of a project.
|
||||
* @param tree File tree for the project.
|
||||
* @param projectName Name of the project in which to search.
|
||||
*/
|
||||
export declare function getMainFilePath(tree: Tree, projectName: string): Promise<string>;
|
||||
/**
|
||||
* Gets a TypeScript source file at a specific path.
|
||||
* @param tree File tree of a project.
|
||||
* @param path Path to the file.
|
||||
*/
|
||||
export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile;
|
||||
/** Finds the call to `bootstrapApplication` within a file. */
|
||||
export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression;
|
||||
/**
|
||||
* Applies a set of changes to a file.
|
||||
* @param tree File tree of the project.
|
||||
* @param path Path to the file that is being changed.
|
||||
* @param changes Changes that should be applied to the file.
|
||||
*/
|
||||
export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void;
|
||||
/** Checks whether a node is a call to `mergeApplicationConfig`. */
|
||||
export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression;
|
||||
/** Finds the `providers` array literal within an application config. */
|
||||
export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null;
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMainFilePath = getMainFilePath;
|
||||
exports.getSourceFile = getSourceFile;
|
||||
exports.findBootstrapApplicationCall = findBootstrapApplicationCall;
|
||||
exports.applyChangesToFile = applyChangesToFile;
|
||||
exports.isMergeAppConfigCall = isMergeAppConfigCall;
|
||||
exports.findProvidersLiteral = findProvidersLiteral;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const posix_1 = require("node:path/posix");
|
||||
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
||||
const change_1 = require("../change");
|
||||
const project_targets_1 = require("../project-targets");
|
||||
const workspace_1 = require("../workspace");
|
||||
const workspace_models_1 = require("../workspace-models");
|
||||
/**
|
||||
* Finds the main file of a project.
|
||||
* @param tree File tree for the project.
|
||||
* @param projectName Name of the project in which to search.
|
||||
*/
|
||||
async function getMainFilePath(tree, projectName) {
|
||||
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
||||
const project = workspace.projects.get(projectName);
|
||||
const buildTarget = project?.targets.get('build');
|
||||
if (!project || !buildTarget) {
|
||||
throw (0, project_targets_1.targetBuildNotFoundError)();
|
||||
}
|
||||
const options = buildTarget.options;
|
||||
if (buildTarget.builder === workspace_models_1.Builders.Application ||
|
||||
buildTarget.builder === workspace_models_1.Builders.BuildApplication) {
|
||||
// These builders support a default of `<project_source_root>/main.ts`
|
||||
const projectSourceRoot = project.sourceRoot ?? (0, posix_1.join)(project.root, 'src');
|
||||
return options.browser ?? (0, posix_1.join)(projectSourceRoot, 'main.ts');
|
||||
}
|
||||
return options.main;
|
||||
}
|
||||
/**
|
||||
* Gets a TypeScript source file at a specific path.
|
||||
* @param tree File tree of a project.
|
||||
* @param path Path to the file.
|
||||
*/
|
||||
function getSourceFile(tree, path) {
|
||||
const content = tree.readText(path);
|
||||
const source = typescript_1.default.createSourceFile(path, content, typescript_1.default.ScriptTarget.Latest, true);
|
||||
return source;
|
||||
}
|
||||
/** Finds the call to `bootstrapApplication` within a file. */
|
||||
function findBootstrapApplicationCall(tree, mainFilePath) {
|
||||
const sourceFile = getSourceFile(tree, mainFilePath);
|
||||
const localName = findImportLocalName(sourceFile, 'bootstrapApplication', '@angular/platform-browser');
|
||||
if (localName) {
|
||||
let result = null;
|
||||
sourceFile.forEachChild(function walk(node) {
|
||||
if (typescript_1.default.isCallExpression(node) &&
|
||||
typescript_1.default.isIdentifier(node.expression) &&
|
||||
node.expression.text === localName) {
|
||||
result = node;
|
||||
}
|
||||
if (!result) {
|
||||
node.forEachChild(walk);
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw new schematics_1.SchematicsException(`Could not find bootstrapApplication call in ${mainFilePath}`);
|
||||
}
|
||||
/**
|
||||
* Finds the local name of an imported symbol. Could be the symbol name itself or its alias.
|
||||
* @param sourceFile File within which to search for the import.
|
||||
* @param name Actual name of the import, not its local alias.
|
||||
* @param moduleName Name of the module from which the symbol is imported.
|
||||
*/
|
||||
function findImportLocalName(sourceFile, name, moduleName) {
|
||||
for (const node of sourceFile.statements) {
|
||||
// Only look for top-level imports.
|
||||
if (!typescript_1.default.isImportDeclaration(node) ||
|
||||
!typescript_1.default.isStringLiteral(node.moduleSpecifier) ||
|
||||
node.moduleSpecifier.text !== moduleName) {
|
||||
continue;
|
||||
}
|
||||
// Filter out imports that don't have the right shape.
|
||||
if (!node.importClause ||
|
||||
!node.importClause.namedBindings ||
|
||||
!typescript_1.default.isNamedImports(node.importClause.namedBindings)) {
|
||||
continue;
|
||||
}
|
||||
// Look through the elements of the declaration for the specific import.
|
||||
for (const element of node.importClause.namedBindings.elements) {
|
||||
if ((element.propertyName || element.name).text === name) {
|
||||
// The local name is always in `name`.
|
||||
return element.name.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Applies a set of changes to a file.
|
||||
* @param tree File tree of the project.
|
||||
* @param path Path to the file that is being changed.
|
||||
* @param changes Changes that should be applied to the file.
|
||||
*/
|
||||
function applyChangesToFile(tree, path, changes) {
|
||||
if (changes.length > 0) {
|
||||
const recorder = tree.beginUpdate(path);
|
||||
(0, change_1.applyToUpdateRecorder)(recorder, changes);
|
||||
tree.commitUpdate(recorder);
|
||||
}
|
||||
}
|
||||
/** Checks whether a node is a call to `mergeApplicationConfig`. */
|
||||
function isMergeAppConfigCall(node) {
|
||||
if (!typescript_1.default.isCallExpression(node)) {
|
||||
return false;
|
||||
}
|
||||
const localName = findImportLocalName(node.getSourceFile(), 'mergeApplicationConfig', '@angular/core');
|
||||
return !!localName && typescript_1.default.isIdentifier(node.expression) && node.expression.text === localName;
|
||||
}
|
||||
/** Finds the `providers` array literal within an application config. */
|
||||
function findProvidersLiteral(config) {
|
||||
for (const prop of config.properties) {
|
||||
if (typescript_1.default.isPropertyAssignment(prop) &&
|
||||
typescript_1.default.isIdentifier(prop.name) &&
|
||||
prop.name.text === 'providers' &&
|
||||
typescript_1.default.isArrayLiteralExpression(prop.initializer)) {
|
||||
return prop.initializer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=util.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAeH,0CAsBC;AAOD,sCAKC;AAGD,oEA+BC;AAkDD,gDAMC;AAGD,oDAYC;AAGD,oDAeC;AA1KD,2DAAuE;AACvE,2CAAuC;AACvC,kHAAkF;AAClF,sCAA0D;AAC1D,wDAA8D;AAC9D,4CAA4C;AAC5C,0DAA+C;AAE/C;;;;GAIG;AACI,KAAK,UAAU,eAAe,CAAC,IAAU,EAAE,WAAmB;IACnE,MAAM,SAAS,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;IAC3C,M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