@o3r/schematics 11.0.0-next.0 → 11.0.0-next.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -1
- package/{src/cli → cli}/environment.d.ts.map +1 -1
- package/{src/cli → cli}/environment.js +1 -1
- package/cli/environment.js.map +1 -0
- package/cli/package.json +3 -0
- package/package.json +61 -43
- package/schematics/ng-add/index.d.ts +3 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +36 -25
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +1 -1
- package/schematics/ng-add/schema.d.ts.map +1 -1
- package/src/interfaces/angular-workspace.d.ts.map +1 -1
- package/src/interfaces/index.d.ts +1 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +1 -0
- package/src/interfaces/index.js.map +1 -1
- package/src/{rule-factories/interfaces.d.ts → interfaces/rule-factories.d.ts} +2 -2
- package/src/interfaces/rule-factories.d.ts.map +1 -0
- package/src/{rule-factories/interfaces.js → interfaces/rule-factories.js} +1 -1
- package/src/interfaces/rule-factories.js.map +1 -0
- package/src/modules/modules.display.rule.d.ts.map +1 -1
- package/src/modules/modules.display.rule.js +3 -4
- package/src/modules/modules.display.rule.js.map +1 -1
- package/src/modules/modules.helpers.d.ts +2 -2
- package/src/modules/modules.helpers.d.ts.map +1 -1
- package/src/modules/modules.helpers.js +2 -2
- package/src/modules/modules.helpers.js.map +1 -1
- package/src/public_api.d.ts +6 -1
- package/src/public_api.d.ts.map +1 -1
- package/src/public_api.js +6 -1
- package/src/public_api.js.map +1 -1
- package/src/rule-factories/add-imports/index.js.map +1 -1
- package/src/rule-factories/check-packages-peers/index.js.map +1 -1
- package/src/rule-factories/dev-tools/devtools-registration.js +7 -7
- package/src/rule-factories/dev-tools/devtools-registration.js.map +1 -1
- package/src/rule-factories/eslint-fix/index.d.ts +8 -3
- package/src/rule-factories/eslint-fix/index.d.ts.map +1 -1
- package/src/rule-factories/eslint-fix/index.js +5 -3
- package/src/rule-factories/eslint-fix/index.js.map +1 -1
- package/src/rule-factories/get-test-frameworks/index.js +2 -2
- package/src/rule-factories/get-test-frameworks/index.js.map +1 -1
- package/src/rule-factories/index.d.ts +1 -1
- package/src/rule-factories/index.d.ts.map +1 -1
- package/src/rule-factories/index.js +1 -1
- package/src/rule-factories/index.js.map +1 -1
- package/src/rule-factories/ng-add/dependencies.d.ts +93 -0
- package/src/rule-factories/ng-add/dependencies.d.ts.map +1 -0
- package/src/rule-factories/ng-add/dependencies.js +174 -0
- package/src/rule-factories/ng-add/dependencies.js.map +1 -0
- package/src/rule-factories/ng-add/index.d.ts +3 -36
- package/src/rule-factories/ng-add/index.d.ts.map +1 -1
- package/src/rule-factories/ng-add/index.js +4 -218
- package/src/rule-factories/ng-add/index.js.map +1 -1
- package/src/rule-factories/ng-add/ng-add.helpers.d.ts +22 -0
- package/src/rule-factories/ng-add/ng-add.helpers.d.ts.map +1 -0
- package/src/rule-factories/ng-add/ng-add.helpers.js +162 -0
- package/src/rule-factories/ng-add/ng-add.helpers.js.map +1 -0
- package/src/rule-factories/ng-add/schematics-register.d.ts +17 -0
- package/src/rule-factories/ng-add/schematics-register.d.ts.map +1 -0
- package/src/rule-factories/ng-add/schematics-register.js +64 -0
- package/src/rule-factories/ng-add/schematics-register.js.map +1 -0
- package/src/rule-factories/remove-packages/index.js.map +1 -1
- package/src/rule-factories/update-imports/index.d.ts +0 -1
- package/src/rule-factories/update-imports/index.d.ts.map +1 -1
- package/src/rule-factories/update-imports/index.js +0 -1
- package/src/rule-factories/update-imports/index.js.map +1 -1
- package/src/rule-factories/update-imports/list-of-vars.d.ts +4 -5
- package/src/rule-factories/update-imports/list-of-vars.d.ts.map +1 -1
- package/src/rule-factories/update-imports/list-of-vars.js.map +1 -1
- package/src/rule-factories/update-imports/update-imports-with-scope.d.ts +1 -1
- package/src/rule-factories/update-imports/update-imports-with-scope.js +3 -3
- package/src/rule-factories/update-imports/update-imports-with-scope.js.map +1 -1
- package/src/rule-factories/update-imports/update-ts-imports.d.ts +1 -1
- package/src/rule-factories/update-imports/update-ts-imports.d.ts.map +1 -1
- package/src/rule-factories/update-imports/update-ts-imports.js +7 -6
- package/src/rule-factories/update-imports/update-ts-imports.js.map +1 -1
- package/src/rule-factories/vscode-extensions/index.js.map +1 -1
- package/src/rules/install.d.ts +8 -4
- package/src/rules/install.d.ts.map +1 -1
- package/src/rules/install.js +10 -8
- package/src/rules/install.js.map +1 -1
- package/src/tasks/eslint/index.d.ts +8 -1
- package/src/tasks/eslint/index.d.ts.map +1 -1
- package/src/tasks/eslint/index.js +8 -1
- package/src/tasks/eslint/index.js.map +1 -1
- package/src/tasks/ng-add/index.d.ts +1 -0
- package/src/tasks/ng-add/index.d.ts.map +1 -1
- package/src/tasks/ng-add/index.js +1 -0
- package/src/tasks/ng-add/index.js.map +1 -1
- package/src/tasks/package-manager/add-dev-dependency.d.ts +1 -0
- package/src/tasks/package-manager/add-dev-dependency.d.ts.map +1 -1
- package/src/tasks/package-manager/add-dev-dependency.js +4 -3
- package/src/tasks/package-manager/add-dev-dependency.js.map +1 -1
- package/src/tasks/package-manager/interfaces.d.ts +1 -1
- package/src/tasks/package-manager/interfaces.d.ts.map +1 -1
- package/src/tasks/package-manager/npm-install.js +3 -3
- package/src/tasks/package-manager/npm-install.js.map +1 -1
- package/src/utility/ast.d.ts +2 -1
- package/src/utility/ast.d.ts.map +1 -1
- package/src/utility/ast.js +8 -2
- package/src/utility/ast.js.map +1 -1
- package/src/utility/builder.js.map +1 -1
- package/src/utility/collection.d.ts.map +1 -1
- package/src/utility/collection.js +1 -1
- package/src/utility/collection.js.map +1 -1
- package/src/utility/component.d.ts +1 -1
- package/src/utility/component.d.ts.map +1 -1
- package/src/utility/component.js.map +1 -1
- package/src/utility/dependencies.d.ts.map +1 -1
- package/src/utility/dependencies.js +1 -1
- package/src/utility/dependencies.js.map +1 -1
- package/src/utility/environment.d.ts +1 -0
- package/src/utility/environment.d.ts.map +1 -1
- package/src/utility/environment.js.map +1 -1
- package/src/utility/file-info.d.ts +1 -2
- package/src/utility/file-info.d.ts.map +1 -1
- package/src/utility/file-info.js.map +1 -1
- package/src/utility/generation.d.ts +1 -1
- package/src/utility/generation.d.ts.map +1 -1
- package/src/utility/generation.js.map +1 -1
- package/src/utility/gitignore.d.ts +1 -1
- package/src/utility/gitignore.d.ts.map +1 -1
- package/src/utility/gitignore.js.map +1 -1
- package/src/utility/index.d.ts +2 -0
- package/src/utility/index.d.ts.map +1 -1
- package/src/utility/index.js +2 -0
- package/src/utility/index.js.map +1 -1
- package/src/utility/loaders.d.ts +6 -1
- package/src/utility/loaders.d.ts.map +1 -1
- package/src/utility/loaders.js +10 -2
- package/src/utility/loaders.js.map +1 -1
- package/src/utility/matching-peers.d.ts +7 -3
- package/src/utility/matching-peers.d.ts.map +1 -1
- package/src/utility/matching-peers.js +7 -5
- package/src/utility/matching-peers.js.map +1 -1
- package/src/utility/modules.js.map +1 -1
- package/src/utility/monorepo.d.ts +3 -2
- package/src/utility/monorepo.d.ts.map +1 -1
- package/src/utility/monorepo.js +2 -1
- package/src/utility/monorepo.js.map +1 -1
- package/src/utility/package-manager-runner.d.ts +1 -1
- package/src/utility/package-manager-runner.d.ts.map +1 -1
- package/src/utility/package-manager-runner.js.map +1 -1
- package/src/utility/package-version.js.map +1 -1
- package/src/utility/routes.d.ts +1 -1
- package/src/utility/routes.d.ts.map +1 -1
- package/src/utility/routes.js.map +1 -1
- package/src/utility/sub-entry.d.ts +1 -1
- package/src/utility/sub-entry.d.ts.map +1 -1
- package/src/utility/sub-entry.js.map +1 -1
- package/src/utility/template-property.helper.js.map +1 -1
- package/src/utility/update-imports.d.ts.map +1 -1
- package/src/utility/update-imports.js +21 -10
- package/src/utility/update-imports.js.map +1 -1
- package/src/utility/update-pipes.d.ts +15 -0
- package/src/utility/update-pipes.d.ts.map +1 -0
- package/src/utility/update-pipes.js +82 -0
- package/src/utility/update-pipes.js.map +1 -0
- package/src/utility/wrapper.d.ts +8 -0
- package/src/utility/wrapper.d.ts.map +1 -0
- package/src/utility/wrapper.js +87 -0
- package/src/utility/wrapper.js.map +1 -0
- package/src/cli/environment.js.map +0 -1
- package/src/index.d.ts +0 -7
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -10
- package/src/index.js.map +0 -1
- package/src/rule-factories/interfaces.d.ts.map +0 -1
- package/src/rule-factories/interfaces.js.map +0 -1
- package/src/rule-factories/update-imports/v7-to-v8-map-object.d.ts +0 -8
- package/src/rule-factories/update-imports/v7-to-v8-map-object.d.ts.map +0 -1
- package/src/rule-factories/update-imports/v7-to-v8-map-object.js +0 -2049
- package/src/rule-factories/update-imports/v7-to-v8-map-object.js.map +0 -1
- /package/{src/cli → cli}/environment.d.ts +0 -0
@@ -22,7 +22,7 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
22
22
|
const imp = nodeImp;
|
23
23
|
const importFrom = imp.moduleSpecifier.getText().replace(/['"]/g, '');
|
24
24
|
const renamePackageMatch = importFrom.match(renamePackagesRegexp);
|
25
|
-
const otterPackage = renamePackageMatch
|
25
|
+
const otterPackage = renamePackageMatch?.[0] || importFrom.match(importsRegexp)?.[0];
|
26
26
|
// If the import matched an Otter package
|
27
27
|
if (otterPackage) {
|
28
28
|
if (!oldImportedSymbolsPerPackage[otterPackage]) {
|
@@ -31,9 +31,10 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
31
31
|
// We store the import line to be able to remove it afterwards
|
32
32
|
importNodes.push(imp);
|
33
33
|
// We retrieve all the symbols listed in the import statement
|
34
|
-
const namedImport = imp.importClause
|
34
|
+
const namedImport = imp.importClause?.namedBindings;
|
35
|
+
const isTypeOnlyImport = !!imp.importClause && ts.isTypeOnlyImportDeclaration(imp.importClause);
|
35
36
|
const imports = namedImport && ts.isNamedImports(namedImport) ?
|
36
|
-
namedImport.elements.map((element) => ({ symbol: element.getText(), location: importFrom })) :
|
37
|
+
namedImport.elements.map((element) => ({ symbol: element.getText(), isTypeOnlyImport, location: importFrom })) :
|
37
38
|
[];
|
38
39
|
// And associate them to the Otter package
|
39
40
|
oldImportedSymbolsPerPackage[otterPackage].push(...imports);
|
@@ -48,7 +49,7 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
48
49
|
const resolvedImports = Object.entries(oldImportedSymbolsPerPackage).reduce((acc, [oldPackageName, importsFromOldPackage]) => {
|
49
50
|
importsFromOldPackage.forEach((importSymbol) => {
|
50
51
|
let newPackageNameImport;
|
51
|
-
if (
|
52
|
+
if (renamedPackages[oldPackageName]) {
|
52
53
|
newPackageNameImport = importSymbol.location.replace(oldPackageName, renamedPackages[oldPackageName]);
|
53
54
|
}
|
54
55
|
else {
|
@@ -62,18 +63,28 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
62
63
|
acc[importFrom] = [];
|
63
64
|
}
|
64
65
|
const newNameForExportedValue = mapImports[oldPackageName]?.[importSymbol.symbol]?.newValue;
|
65
|
-
acc[importFrom].push(newNameForExportedValue || importSymbol.symbol);
|
66
|
+
acc[importFrom].push(`${importSymbol.isTypeOnlyImport ? 'type ' : ''}${newNameForExportedValue || importSymbol.symbol}`);
|
66
67
|
});
|
67
68
|
return acc;
|
68
69
|
}, {});
|
70
|
+
let fileContent = tree.readText(sourceFile.fileName);
|
71
|
+
const escapeRegExp = (str) => str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
69
72
|
// Remove captured imports
|
70
|
-
|
71
|
-
|
73
|
+
fileContent = fileContent.replace(new RegExp(`(${importNodes.map((node) => escapeRegExp(node.getText())).join('|')})[\\n\\r]*`, 'g'), '');
|
74
|
+
// Replace imported values
|
75
|
+
const valuesToReplace = Object.fromEntries(Object.values(mapImports).flatMap((mapImport) => Object.entries(mapImport)
|
76
|
+
.filter(([_, value]) => value.newValue)
|
77
|
+
.map(([key, value]) => [key, value.newValue])));
|
78
|
+
if (Object.keys(valuesToReplace).length) {
|
79
|
+
const matcher = new RegExp(Object.keys(valuesToReplace).map((oldValue) => `\\b${escapeRegExp(oldValue)}\\b`).join('|'), 'g');
|
80
|
+
const replacer = (match) => valuesToReplace[match];
|
81
|
+
fileContent = fileContent.replace(matcher, replacer);
|
82
|
+
}
|
72
83
|
// Add the computed imports at the top of the file
|
73
|
-
|
84
|
+
fileContent = Object.entries(resolvedImports)
|
74
85
|
.map(([importFrom, imports]) => `import {${imports.join(', ')}} from '${importFrom}';`)
|
75
|
-
.join('\n') + '\n' +
|
76
|
-
tree.overwrite(sourceFile.fileName,
|
86
|
+
.join('\n') + '\n' + fileContent;
|
87
|
+
tree.overwrite(sourceFile.fileName, fileContent);
|
77
88
|
// Log details about imports for which we could not find an associated sub-entry
|
78
89
|
if (unResolvedImports.length > 0) {
|
79
90
|
logger.warn(`Some imports in file ${sourceFile.fileName} could not be resolved:`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"update-imports.js","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAAkE;
|
1
|
+
{"version":3,"file":"update-imports.js","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAAkE;AAuBlE;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,MAAyB,EACzB,IAAU,EACV,UAAyB,EACzB,aAAqB,EACrB,oBAA4B,EAC5B,aAA6B,EAAE,EAC/B,kBAA0C,EAAE;IAE5C,MAAM,4BAA4B,GAAsC,EAAE,CAAC;IAC3E,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAChD,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,6FAA6F;IAC7F,IAAA,qBAAS,EAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrE,MAAM,GAAG,GAAG,OAA+B,CAAC;QAC5C,MAAM,UAAU,GAAG,GAA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QAC3D,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED,kDAAkD;IAClD,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,WAAW,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,UAAU,IAAI,CAAC;SACtF,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC;IAEnC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAEjD,gFAAgF;IAChF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,wBAAwB,UAAU,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAClF,iBAAiB,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,gBAAgB,CAAC,MAAM,kBAAkB,gBAAgB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACvJ,CAAC;IAED,OAAO,iBAAiB,CAAC,MAAM,CAAC;AAClC,CAAC;AA3GD,kDA2GC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
2
|
+
/** Dictionary of pipes to be updated */
|
3
|
+
export type PipeReplacementInfo = Record<string, {
|
4
|
+
new: {
|
5
|
+
name: string;
|
6
|
+
import?: string;
|
7
|
+
};
|
8
|
+
import: string;
|
9
|
+
}>;
|
10
|
+
/**
|
11
|
+
* Returns a rule tu update pipes
|
12
|
+
* @param pipeReplacementInfo
|
13
|
+
*/
|
14
|
+
export declare const updatePipes: (pipeReplacementInfo: PipeReplacementInfo) => Rule;
|
15
|
+
//# sourceMappingURL=update-pipes.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-pipes.d.ts","sourceRoot":"","sources":["../../../src/utility/update-pipes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAO1E,wCAAwC;AACxC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAmD7G;;;GAGG;AACH,eAAO,MAAM,WAAW,wBAAyB,mBAAmB,KAAG,IAoDtE,CAAC"}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.updatePipes = void 0;
|
4
|
+
const node_path_1 = require("node:path");
|
5
|
+
const ts = require("typescript");
|
6
|
+
const ast_1 = require("./ast");
|
7
|
+
const component_1 = require("./component");
|
8
|
+
const loaders_1 = require("./loaders");
|
9
|
+
const applyChanges = (pipeReplacementInfo, ngDecorator, matchers, fileWithImports, templateFile, tree, context) => {
|
10
|
+
if (ts.isObjectLiteralExpression(ngDecorator.expression.arguments[0])) {
|
11
|
+
const importsProp = ngDecorator.expression.arguments[0].properties.find((prop) => ts.isPropertyAssignment(prop)
|
12
|
+
&& ts.isIdentifier(prop.name)
|
13
|
+
&& prop.name.text === 'imports'
|
14
|
+
&& ts.isArrayLiteralExpression(prop.initializer));
|
15
|
+
if (importsProp) {
|
16
|
+
matchers.forEach((matcher) => {
|
17
|
+
const pipeName = matcher[1];
|
18
|
+
const importModuleRegexp = new RegExp(`\\b${pipeReplacementInfo[pipeName].import}\\b`, 'g');
|
19
|
+
if (importsProp.initializer.elements.some((element) => importModuleRegexp.test(element.getText()))) {
|
20
|
+
if (pipeReplacementInfo[pipeName].new.import) {
|
21
|
+
tree.overwrite(fileWithImports, tree.readText(fileWithImports).replaceAll(importModuleRegexp, pipeReplacementInfo[pipeName].new.import));
|
22
|
+
}
|
23
|
+
tree.overwrite(templateFile, tree.readText(templateFile).replaceAll(new RegExp(`\\|\\s*${pipeName}`, 'g'), `| ${pipeReplacementInfo[pipeName].new.name}`));
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
context.logger.warn(`Deprecated pipe ${pipeName} was found in ${templateFile} `
|
27
|
+
+ `but no associated import in ${fileWithImports}`
|
28
|
+
+ `to be able to migrate to the new pipe ${pipeReplacementInfo[pipeName].new.name}.`);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}
|
33
|
+
};
|
34
|
+
const isNgModuleDecorator = (decorator) => ts.isCallExpression(decorator.expression)
|
35
|
+
&& decorator.expression.expression
|
36
|
+
&& ts.isIdentifier(decorator.expression.expression)
|
37
|
+
&& decorator.expression.expression.text === 'NgModule';
|
38
|
+
/**
|
39
|
+
* Returns a rule tu update pipes
|
40
|
+
* @param pipeReplacementInfo
|
41
|
+
*/
|
42
|
+
const updatePipes = (pipeReplacementInfo) => (tree, context) => {
|
43
|
+
const pipeRegex = new RegExp(`\\|\\s*(${Object.keys(pipeReplacementInfo).join('|')})`, 'g');
|
44
|
+
const files = (0, loaders_1.findFilesInTree)(tree.root, (file) => file.endsWith('.html'));
|
45
|
+
files.forEach((file) => {
|
46
|
+
const matchers = Array.from(file.content.toString().matchAll(pipeRegex)).filter((matcher) => !!pipeReplacementInfo[matcher[1]]);
|
47
|
+
if (matchers.length) {
|
48
|
+
const directory = (0, node_path_1.dirname)(file.path);
|
49
|
+
const baseFileName = (0, node_path_1.basename)((0, node_path_1.basename)(file.path, '.html'), '.template');
|
50
|
+
const componentFile = (0, node_path_1.join)(directory, `${baseFileName}.component.ts`);
|
51
|
+
const moduleFile = (0, node_path_1.join)(directory, `${baseFileName}.module.ts`);
|
52
|
+
let standalone = false;
|
53
|
+
if (tree.exists(componentFile)) {
|
54
|
+
try {
|
55
|
+
const info = (0, component_1.getO3rComponentInfoOrThrowIfNotFound)(tree, componentFile);
|
56
|
+
standalone = info.standalone;
|
57
|
+
}
|
58
|
+
catch { }
|
59
|
+
}
|
60
|
+
if (standalone) {
|
61
|
+
const componentSourceFile = ts.createSourceFile(componentFile, tree.readText(componentFile), ts.ScriptTarget.ES2020, true);
|
62
|
+
const [ngClass] = componentSourceFile.statements.filter((statement) => ts.isClassDeclaration(statement)
|
63
|
+
&& (0, component_1.isNgClassComponent)(statement));
|
64
|
+
const [ngDecorator] = ((ngClass && ts.getDecorators(ngClass)) || []).filter(component_1.isNgClassDecorator);
|
65
|
+
if (ngDecorator) {
|
66
|
+
applyChanges(pipeReplacementInfo, ngDecorator, matchers, componentFile, file.path, tree, context);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
else if (tree.exists(moduleFile)) {
|
70
|
+
const moduleSourceFile = ts.createSourceFile(moduleFile, tree.readText(moduleFile), ts.ScriptTarget.ES2020, true);
|
71
|
+
const ngModuleClass = moduleSourceFile.statements.find((statement) => ts.isClassDeclaration(statement)
|
72
|
+
&& !!(ts.getDecorators(statement) || []).find(isNgModuleDecorator));
|
73
|
+
const ngDecorator = ((ngModuleClass && ts.getDecorators(ngModuleClass)) || []).find(isNgModuleDecorator);
|
74
|
+
if (ngDecorator && (0, ast_1.isDecoratorWithArg)(ngDecorator)) {
|
75
|
+
applyChanges(pipeReplacementInfo, ngDecorator, matchers, moduleFile, file.path, tree, context);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
};
|
81
|
+
exports.updatePipes = updatePipes;
|
82
|
+
//# sourceMappingURL=update-pipes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-pipes.js","sourceRoot":"","sources":["../../../src/utility/update-pipes.ts"],"names":[],"mappings":";;;AACA,yCAAoD;AACpD,iCAAiC;AACjC,+BAA6D;AAC7D,2CAA2G;AAC3G,uCAA4C;AAK5C,MAAM,YAAY,GAAG,CACnB,m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AAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBACjG,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApDW,QAAA,WAAW,eAoDtB"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { SchematicWrapper } from '@o3r/telemetry';
|
2
|
+
/**
|
3
|
+
* Wrapper method of a schematic to retrieve some metrics around the schematic run
|
4
|
+
* if @o3r/telemetry is installed
|
5
|
+
* @param schematicFn
|
6
|
+
*/
|
7
|
+
export declare const createSchematicWithMetricsIfInstalled: SchematicWrapper;
|
8
|
+
//# sourceMappingURL=wrapper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA0CvD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,EAAE,gBA4CnD,CAAC"}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createSchematicWithMetricsIfInstalled = void 0;
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
5
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
6
|
+
const inquirer_1 = require("inquirer");
|
7
|
+
const node_fs_1 = require("node:fs");
|
8
|
+
const path = require("node:path");
|
9
|
+
const rule_factories_1 = require("../rule-factories");
|
10
|
+
const noopSchematicWrapper = (fn) => fn;
|
11
|
+
const PACKAGE_JSON_PATH = 'package.json';
|
12
|
+
const setupO3rMetricsInPackageJson = (activated) => (tree) => {
|
13
|
+
if (tree.exists(PACKAGE_JSON_PATH)) {
|
14
|
+
const packageJson = tree.readJson(PACKAGE_JSON_PATH);
|
15
|
+
packageJson.config ||= {};
|
16
|
+
packageJson.config.o3rMetrics = activated;
|
17
|
+
tree.overwrite(PACKAGE_JSON_PATH, JSON.stringify(packageJson, null, 2));
|
18
|
+
}
|
19
|
+
};
|
20
|
+
const setupTelemetry = ({ workingDirectory, runNgAdd, exactO3rVersion }) => (_, context) => {
|
21
|
+
const taskIdsFromContext = (0, rule_factories_1.hasSetupInformation)(context) ? context.setupDependencies.taskIds : undefined;
|
22
|
+
const version = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
|
23
|
+
return (0, rule_factories_1.setupDependencies)({
|
24
|
+
dependencies: {
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
26
|
+
'@o3r/telemetry': {
|
27
|
+
inManifest: [{
|
28
|
+
range: `${exactO3rVersion ? '' : '~'}${version}`,
|
29
|
+
types: [dependencies_1.NodeDependencyType.Dev]
|
30
|
+
}],
|
31
|
+
ngAddOptions: { exactO3rVersion }
|
32
|
+
}
|
33
|
+
},
|
34
|
+
ngAddToRun: runNgAdd ? ['@o3r/telemetry'] : [],
|
35
|
+
runAfterTasks: taskIdsFromContext,
|
36
|
+
workingDirectory
|
37
|
+
});
|
38
|
+
};
|
39
|
+
/**
|
40
|
+
* Wrapper method of a schematic to retrieve some metrics around the schematic run
|
41
|
+
* if @o3r/telemetry is installed
|
42
|
+
* @param schematicFn
|
43
|
+
*/
|
44
|
+
const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (tree, context) => {
|
45
|
+
let wrapper = noopSchematicWrapper;
|
46
|
+
let shouldInstallTelemetry;
|
47
|
+
const packageJson = tree.exists(PACKAGE_JSON_PATH) ? tree.readJson(PACKAGE_JSON_PATH) : {};
|
48
|
+
try {
|
49
|
+
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
50
|
+
wrapper = createSchematicWithMetrics;
|
51
|
+
}
|
52
|
+
catch (e) {
|
53
|
+
// Do not throw if `@o3r/telemetry is not installed
|
54
|
+
if ((process.env.NX_CLI_SET !== 'true' || process.env.NX_INTERACTIVE === 'true')
|
55
|
+
&& context.interactive
|
56
|
+
&& typeof packageJson.config?.o3rMetrics === 'undefined'
|
57
|
+
&& process.env.O3R_METRICS !== 'false'
|
58
|
+
&& opts.o3rMetrics !== false
|
59
|
+
&& (!process.env.CI || process.env.CI === 'false')) {
|
60
|
+
context.logger.debug('`@o3r/telemetry` is not available.\nAsking to add the dependency\n' + e.toString());
|
61
|
+
const question = {
|
62
|
+
type: 'confirm',
|
63
|
+
name: 'isReplyPositive',
|
64
|
+
message: `
|
65
|
+
Would you like to share anonymous data about the usage of Otter builders and schematics with the Otter Team at Amadeus ?
|
66
|
+
It will help us to improve our tools.
|
67
|
+
For more details and instructions on how to change these settings, see https://github.com/AmadeusITGroup/otter/blob/main/docs/telemetry/PRIVACY_NOTICE.md.
|
68
|
+
`,
|
69
|
+
default: false
|
70
|
+
};
|
71
|
+
const { isReplyPositive } = await (0, inquirer_1.prompt)([question]);
|
72
|
+
shouldInstallTelemetry = isReplyPositive;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
const subtreeDirectory = context.schematic.description.name === 'typescript-shell' ? opts.directory.split(path.posix.sep).join(path.sep) ?? '' : '';
|
76
|
+
const rule = (0, schematics_1.chain)([
|
77
|
+
typeof shouldInstallTelemetry !== 'undefined' ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [setupO3rMetricsInPackageJson(!!shouldInstallTelemetry)]) : (0, schematics_1.noop)(),
|
78
|
+
schematicFn(opts),
|
79
|
+
shouldInstallTelemetry ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [
|
80
|
+
setupTelemetry({ workingDirectory: subtreeDirectory || undefined, runNgAdd: !subtreeDirectory, exactO3rVersion: opts.exactO3rVersion })
|
81
|
+
]) : (0, schematics_1.noop)(),
|
82
|
+
typeof shouldInstallTelemetry !== 'undefined' && subtreeDirectory ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [setupO3rMetricsInPackageJson(shouldInstallTelemetry)]) : (0, schematics_1.noop)()
|
83
|
+
]);
|
84
|
+
return wrapper(() => rule)(opts);
|
85
|
+
};
|
86
|
+
exports.createSchematicWithMetricsIfInstalled = createSchematicWithMetricsIfInstalled;
|
87
|
+
//# sourceMappingURL=wrapper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":";;;AACA,2DAAoF;AAEpF,2EAA8E;AAC9E,uCAA4C;AAC5C,qCAAuC;AACvC,kCAAkC;AAClC,sDAA2E;AAE3E,MAAM,oBAAoB,GAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAE1D,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,MAAM,4BAA4B,GAAiC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;IACzF,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAe,CAAC;QAEnE,WAAW,CAAC,MAAM,KAAK,EAAE,CAAC;QACzB,WAAW,CAAC,MAAqB,CAAC,UAAU,GAAG,SAAS,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,cAAc,GAA+F,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;IACrL,MAAM,kBAAkB,GAAG,IAAA,oCAAmB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACx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CAAC,IAAI,CAAC;QACjB,sBAAsB,CAAC,CAAC,CAAC,IAAA,2BAAc,EAAC,gBAAgB,EAAE;YACxD,cAAc,CAAC,EAAE,gBAAgB,EAAE,gBAAgB,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAG,IAAY,CAAC,eAAe,EAAE,CAAC;SACjJ,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;QACX,OAAO,sBAAsB,KAAK,WAAW,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAA,2BAAc,EAAC,gBAAgB,EAAE,CAAC,4BAA4B,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;KACtK,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC;AA5CW,QAAA,qCAAqC,yCA4ChD"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/cli/environment.ts"],"names":[],"mappings":";;AAAA,4CAA+D;AAE/D,OAAO,CAAC,IAAI,CAAC,4BAA4B,IAAA,mCAA2B,GAAE,EAAE,CAAC,CAAC"}
|
package/src/index.d.ts
DELETED
package/src/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/src/index.js
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
tslib_1.__exportStar(require("./interfaces/index"), exports);
|
5
|
-
tslib_1.__exportStar(require("./rule-factories/index"), exports);
|
6
|
-
tslib_1.__exportStar(require("./rules/index"), exports);
|
7
|
-
tslib_1.__exportStar(require("./tasks/index"), exports);
|
8
|
-
tslib_1.__exportStar(require("./utility/index"), exports);
|
9
|
-
tslib_1.__exportStar(require("./modules/index"), exports);
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,iEAAuC;AACvC,wDAA8B;AAC9B,wDAA8B;AAC9B,0DAAgC;AAChC,0DAAgC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/rule-factories/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/rule-factories/interfaces.ts"],"names":[],"mappings":""}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { ImportsMapping } from '../../utility';
|
2
|
-
/** Packages that were renamed */
|
3
|
-
export declare const renamedPackagesV7toV8: {
|
4
|
-
[key: string]: string;
|
5
|
-
};
|
6
|
-
/** Map containing the import changes in otter packages for the exported elements */
|
7
|
-
export declare const mapImportV7toV8: ImportsMapping;
|
8
|
-
//# sourceMappingURL=v7-to-v8-map-object.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"v7-to-v8-map-object.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/update-imports/v7-to-v8-map-object.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,iCAAiC;AACjC,eAAO,MAAM,qBAAqB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAa1D,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,eAAe,EAAE,cA6+D7B,CAAC"}
|