@o3r/schematics 10.0.0-next.9 → 11.0.0-next.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/package.json +51 -41
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +3 -2
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.json +2 -2
- package/src/cli/environment.d.ts +2 -0
- package/src/cli/environment.d.ts.map +1 -0
- package/src/cli/environment.js +5 -0
- package/src/cli/environment.js.map +1 -0
- package/src/interfaces/angular-workspace.d.ts +11 -29
- package/src/interfaces/angular-workspace.d.ts.map +1 -1
- package/src/modules/index.d.ts +1 -0
- package/src/modules/index.d.ts.map +1 -1
- package/src/modules/index.js +1 -0
- package/src/modules/index.js.map +1 -1
- package/src/modules/modules.constants.d.ts +6 -2
- package/src/modules/modules.constants.d.ts.map +1 -1
- package/src/modules/modules.constants.js +5 -3
- package/src/modules/modules.constants.js.map +1 -1
- package/src/modules/modules.display.rule.d.ts +26 -0
- package/src/modules/modules.display.rule.d.ts.map +1 -0
- package/src/modules/modules.display.rule.js +45 -0
- package/src/modules/modules.display.rule.js.map +1 -0
- package/src/modules/modules.helpers.d.ts +2 -9
- package/src/modules/modules.helpers.d.ts.map +1 -1
- package/src/modules/modules.helpers.js +1 -6
- package/src/modules/modules.helpers.js.map +1 -1
- package/src/rule-factories/add-imports/index.d.ts +0 -1
- package/src/rule-factories/add-imports/index.d.ts.map +1 -1
- package/src/rule-factories/add-imports/index.js +0 -1
- package/src/rule-factories/add-imports/index.js.map +1 -1
- package/src/rule-factories/check-packages-peers/index.d.ts +0 -1
- package/src/rule-factories/check-packages-peers/index.d.ts.map +1 -1
- package/src/rule-factories/check-packages-peers/index.js +4 -7
- package/src/rule-factories/check-packages-peers/index.js.map +1 -1
- package/src/rule-factories/dev-tools/devtools-registration.d.ts +25 -0
- package/src/rule-factories/dev-tools/devtools-registration.d.ts.map +1 -0
- package/src/rule-factories/dev-tools/devtools-registration.js +89 -0
- package/src/rule-factories/dev-tools/devtools-registration.js.map +1 -0
- package/src/rule-factories/dev-tools/index.d.ts +2 -0
- package/src/rule-factories/dev-tools/index.d.ts.map +1 -0
- package/src/rule-factories/dev-tools/index.js +5 -0
- package/src/rule-factories/dev-tools/index.js.map +1 -0
- package/src/rule-factories/eslint-fix/index.d.ts +1 -18
- package/src/rule-factories/eslint-fix/index.d.ts.map +1 -1
- package/src/rule-factories/eslint-fix/index.js +17 -26
- package/src/rule-factories/eslint-fix/index.js.map +1 -1
- package/src/rule-factories/get-test-frameworks/index.d.ts +0 -1
- package/src/rule-factories/get-test-frameworks/index.d.ts.map +1 -1
- package/src/rule-factories/get-test-frameworks/index.js +0 -1
- package/src/rule-factories/get-test-frameworks/index.js.map +1 -1
- package/src/rule-factories/index.d.ts +1 -0
- package/src/rule-factories/index.d.ts.map +1 -1
- package/src/rule-factories/index.js +1 -0
- package/src/rule-factories/index.js.map +1 -1
- package/src/rule-factories/ng-add/index.d.ts +2 -5
- package/src/rule-factories/ng-add/index.d.ts.map +1 -1
- package/src/rule-factories/ng-add/index.js +107 -83
- package/src/rule-factories/ng-add/index.js.map +1 -1
- package/src/rule-factories/remove-packages/index.d.ts +0 -1
- package/src/rule-factories/remove-packages/index.d.ts.map +1 -1
- package/src/rule-factories/remove-packages/index.js +0 -1
- package/src/rule-factories/remove-packages/index.js.map +1 -1
- package/src/rule-factories/update-imports/list-of-vars.d.ts +1 -2
- 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 +0 -1
- package/src/rule-factories/update-imports/update-imports-with-scope.d.ts.map +1 -1
- package/src/rule-factories/update-imports/update-imports-with-scope.js +0 -1
- 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 +0 -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 +0 -1
- package/src/rule-factories/update-imports/update-ts-imports.js.map +1 -1
- package/src/rule-factories/update-imports/v7-to-v8-map-object.js +1 -1
- package/src/rule-factories/update-imports/v7-to-v8-map-object.js.map +1 -1
- package/src/rule-factories/vscode-extensions/index.d.ts +0 -1
- package/src/rule-factories/vscode-extensions/index.d.ts.map +1 -1
- package/src/rule-factories/vscode-extensions/index.js +0 -1
- package/src/rule-factories/vscode-extensions/index.js.map +1 -1
- package/src/rules/install.d.ts +0 -1
- package/src/rules/install.d.ts.map +1 -1
- package/src/rules/install.js +0 -1
- package/src/rules/install.js.map +1 -1
- package/src/tasks/eslint/index.d.ts +17 -1
- package/src/tasks/eslint/index.d.ts.map +1 -1
- package/src/tasks/eslint/index.js +15 -6
- package/src/tasks/eslint/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 +3 -1
- package/src/tasks/package-manager/add-dev-dependency.js.map +1 -1
- package/src/tasks/package-manager/interfaces.d.ts +9 -0
- package/src/tasks/package-manager/interfaces.d.ts.map +1 -1
- package/src/tasks/package-manager/npm-install.d.ts +2 -1
- package/src/tasks/package-manager/npm-install.d.ts.map +1 -1
- package/src/tasks/package-manager/npm-install.js +3 -1
- package/src/tasks/package-manager/npm-install.js.map +1 -1
- package/src/utility/ast.d.ts +4 -20
- package/src/utility/ast.d.ts.map +1 -1
- package/src/utility/ast.js +0 -18
- package/src/utility/ast.js.map +1 -1
- package/src/utility/builder.d.ts +11 -0
- package/src/utility/builder.d.ts.map +1 -0
- package/src/utility/builder.js +21 -0
- package/src/utility/builder.js.map +1 -0
- package/src/utility/collection.d.ts +2 -5
- package/src/utility/collection.d.ts.map +1 -1
- package/src/utility/collection.js +11 -9
- package/src/utility/collection.js.map +1 -1
- package/src/utility/component.d.ts +0 -6
- package/src/utility/component.d.ts.map +1 -1
- package/src/utility/component.js +4 -9
- package/src/utility/component.js.map +1 -1
- package/src/utility/dependencies.d.ts +0 -2
- package/src/utility/dependencies.d.ts.map +1 -1
- package/src/utility/dependencies.js +0 -2
- package/src/utility/dependencies.js.map +1 -1
- package/src/utility/environment.d.ts +27 -0
- package/src/utility/environment.d.ts.map +1 -0
- package/src/utility/environment.js +51 -0
- package/src/utility/environment.js.map +1 -0
- package/src/utility/error.d.ts +7 -0
- package/src/utility/error.d.ts.map +1 -0
- package/src/utility/error.js +17 -0
- package/src/utility/error.js.map +1 -0
- package/src/utility/file-info.d.ts +11 -1
- package/src/utility/file-info.d.ts.map +1 -1
- package/src/utility/file-info.js +46 -4
- package/src/utility/file-info.js.map +1 -1
- package/src/utility/generation.d.ts +0 -1
- package/src/utility/generation.d.ts.map +1 -1
- package/src/utility/generation.js +7 -11
- package/src/utility/generation.js.map +1 -1
- package/src/utility/gitignore.d.ts +0 -1
- package/src/utility/gitignore.d.ts.map +1 -1
- package/src/utility/gitignore.js +0 -1
- package/src/utility/gitignore.js.map +1 -1
- package/src/utility/index.d.ts +10 -7
- package/src/utility/index.d.ts.map +1 -1
- package/src/utility/index.js +10 -7
- package/src/utility/index.js.map +1 -1
- package/src/utility/loaders.d.ts +12 -50
- package/src/utility/loaders.d.ts.map +1 -1
- package/src/utility/loaders.js +34 -97
- package/src/utility/loaders.js.map +1 -1
- package/src/utility/logo.d.ts +0 -1
- package/src/utility/logo.d.ts.map +1 -1
- package/src/utility/logo.js +0 -1
- package/src/utility/logo.js.map +1 -1
- package/src/utility/matching-peers.d.ts +11 -3
- package/src/utility/matching-peers.d.ts.map +1 -1
- package/src/utility/matching-peers.js +26 -5
- package/src/utility/matching-peers.js.map +1 -1
- package/src/utility/modules.d.ts +4 -9
- package/src/utility/modules.d.ts.map +1 -1
- package/src/utility/modules.js +17 -22
- package/src/utility/modules.js.map +1 -1
- package/src/utility/monorepo.d.ts +0 -5
- package/src/utility/monorepo.d.ts.map +1 -1
- package/src/utility/monorepo.js +0 -5
- package/src/utility/monorepo.js.map +1 -1
- package/src/utility/package-manager-runner.d.ts +24 -7
- package/src/utility/package-manager-runner.d.ts.map +1 -1
- package/src/utility/package-manager-runner.js +70 -10
- package/src/utility/package-manager-runner.js.map +1 -1
- package/src/utility/package-version.d.ts +0 -2
- package/src/utility/package-version.d.ts.map +1 -1
- package/src/utility/package-version.js +0 -2
- package/src/utility/package-version.js.map +1 -1
- package/src/utility/question.d.ts +0 -1
- package/src/utility/question.d.ts.map +1 -1
- package/src/utility/question.js +0 -1
- package/src/utility/question.js.map +1 -1
- package/src/utility/routes.d.ts +0 -3
- package/src/utility/routes.d.ts.map +1 -1
- package/src/utility/routes.js +0 -5
- package/src/utility/routes.js.map +1 -1
- package/src/utility/sub-entry.d.ts +0 -2
- package/src/utility/sub-entry.d.ts.map +1 -1
- package/src/utility/sub-entry.js +0 -2
- package/src/utility/sub-entry.js.map +1 -1
- package/src/utility/template-property.helper.d.ts +0 -15
- package/src/utility/template-property.helper.d.ts.map +1 -1
- package/src/utility/template-property.helper.js +0 -16
- package/src/utility/template-property.helper.js.map +1 -1
- package/src/utility/update-imports.d.ts +0 -1
- package/src/utility/update-imports.d.ts.map +1 -1
- package/src/utility/update-imports.js +0 -1
- package/src/utility/update-imports.js.map +1 -1
@@ -1,10 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getO3rPeerDeps = exports.getPeerDepWithPattern = void 0;
|
3
|
+
exports.getO3rGeneratorDeps = exports.getO3rPeerDeps = exports.getPeerDepWithPattern = void 0;
|
4
4
|
const fs = require("node:fs");
|
5
5
|
/**
|
6
6
|
* Retrieve the peer dependencies with the given pattern from the given package json file
|
7
|
-
*
|
8
7
|
* @param packageJsonPath
|
9
8
|
* @param pattern
|
10
9
|
*/
|
@@ -20,11 +19,16 @@ function getPeerDepWithPattern(packageJsonPath, pattern = /^@(otter|o3r|ama-sdk)
|
|
20
19
|
return { packageName, packageVersion, matchingPackages };
|
21
20
|
}
|
22
21
|
exports.getPeerDepWithPattern = getPeerDepWithPattern;
|
22
|
+
const basicsPackageName = new Set([
|
23
|
+
'@o3r/core',
|
24
|
+
'@o3r/schematics',
|
25
|
+
'@o3r/dev-tools',
|
26
|
+
'@o3r/workspace'
|
27
|
+
]);
|
23
28
|
/**
|
24
29
|
* Get the list of o3r peer deps from a given package.json file
|
25
|
-
*
|
26
30
|
* @param packageJsonPath The package json on which we search for o3r peer deps
|
27
|
-
* @param filterBasics If activated it will remove the basic peer deps (o3r/core, o3r/dev-tools and o3r/schematics) from the list of results
|
31
|
+
* @param filterBasics If activated it will remove the basic peer deps (o3r/core, o3r/dev-tools, o3r/workspace and o3r/schematics) from the list of results
|
28
32
|
* @param packagePattern Pattern of the package name to look in the packages peer dependencies.
|
29
33
|
*/
|
30
34
|
function getO3rPeerDeps(packageJsonPath, filterBasics = true, packagePattern = /^@(?:o3r|ama-sdk)/) {
|
@@ -33,9 +37,26 @@ function getO3rPeerDeps(packageJsonPath, filterBasics = true, packagePattern = /
|
|
33
37
|
packageName: depsInfo.packageName,
|
34
38
|
packageVersion: depsInfo.packageVersion,
|
35
39
|
o3rPeerDeps: filterBasics ?
|
36
|
-
depsInfo.matchingPackages.filter(peerDep => peerDep
|
40
|
+
depsInfo.matchingPackages.filter((peerDep) => !basicsPackageName.has(peerDep))
|
37
41
|
: depsInfo.matchingPackages
|
38
42
|
};
|
39
43
|
}
|
40
44
|
exports.getO3rPeerDeps = getO3rPeerDeps;
|
45
|
+
/**
|
46
|
+
* Get the list of o3r generator deps from a given package.json file
|
47
|
+
* @param packageJsonPath The package json on which we search for o3r generator deps
|
48
|
+
* @param packagePattern Pattern of the package name to look in the packages generator dependencies.
|
49
|
+
*/
|
50
|
+
function getO3rGeneratorDeps(packageJsonPath, packagePattern = /^@(?:o3r|ama-sdk)/) {
|
51
|
+
const packageJsonContent = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
|
52
|
+
const packageName = packageJsonContent.name;
|
53
|
+
const packageVersion = packageJsonContent.version;
|
54
|
+
const optionalPackages = Object.entries(packageJsonContent.generatorDependencies || {})
|
55
|
+
.filter(([, dep]) => dep?.optional)
|
56
|
+
.map(([depName]) => depName);
|
57
|
+
const o3rGeneratorDeps = Object.keys(packageJsonContent.peerDependencies || [])
|
58
|
+
.filter(peerDep => packagePattern.test(peerDep) && !optionalPackages.includes(peerDep));
|
59
|
+
return { packageName, packageVersion, o3rGeneratorDeps };
|
60
|
+
}
|
61
|
+
exports.getO3rGeneratorDeps = getO3rGeneratorDeps;
|
41
62
|
//# sourceMappingURL=matching-peers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"matching-peers.js","sourceRoot":"","sources":["../../../src/utility/matching-peers.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAG9B
|
1
|
+
{"version":3,"file":"matching-peers.js","sourceRoot":"","sources":["../../../src/utility/matching-peers.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAG9B;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,eAAuB,EAAE,OAAO,GAAG,uBAAuB;IAC9F,MAAM,kBAAkB,GAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5G,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC5C,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAClD,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,IAAI,EAAE,CAAC;SACnF,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC;SAClC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,gBAAgB,GAAG,MAAM,CAAC,I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gB,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,qBAAqB,IAAI,EAAE,CAAC;SACpF,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC;SAClC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,IAAI,EAAE,CAAC;SAC5E,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAE3D,CAAC;AAbD,kDAaC"}
|
package/src/utility/modules.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { SchematicContext, Tree, UpdateRecorder } from '@angular-devkit/schematics';
|
2
2
|
import * as ts from 'typescript';
|
3
3
|
/**
|
4
|
-
* Get the path to the app.module.ts
|
5
|
-
*
|
4
|
+
* Get the path to the `app.module.ts`
|
5
|
+
* In case of standalone application, get the path to the `app.config.ts` instead
|
6
6
|
* @param tree File tree
|
7
7
|
* @param context Context of the rule
|
8
8
|
* @param projectName The name of the project where to search for an app module file
|
@@ -10,15 +10,14 @@ import * as ts from 'typescript';
|
|
10
10
|
export declare function getAppModuleFilePath(tree: Tree, context: SchematicContext, projectName?: string | null): string | undefined;
|
11
11
|
/**
|
12
12
|
* Get the path to the main.ts
|
13
|
-
*
|
14
13
|
* @param tree File tree
|
15
14
|
* @param context Context of the rule
|
15
|
+
* @param projectName
|
16
16
|
*/
|
17
|
-
export declare function getMainFilePath(tree: Tree, context: SchematicContext): string | undefined;
|
17
|
+
export declare function getMainFilePath(tree: Tree, context: SchematicContext, projectName?: string): string | undefined;
|
18
18
|
/**
|
19
19
|
* Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
|
20
20
|
* one of its modules.
|
21
|
-
*
|
22
21
|
* @param tree
|
23
22
|
* @param options @see RuleFactory.options
|
24
23
|
* @param options.projectName
|
@@ -28,7 +27,6 @@ export declare function isApplicationThatUsesRouterModule(tree: Tree, options: {
|
|
28
27
|
}): boolean | "" | undefined;
|
29
28
|
/**
|
30
29
|
* Add import to the main module
|
31
|
-
*
|
32
30
|
* @param name
|
33
31
|
* @param file
|
34
32
|
* @param sourceFile
|
@@ -43,7 +41,6 @@ export declare function isApplicationThatUsesRouterModule(tree: Tree, options: {
|
|
43
41
|
export declare function addImportToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, sourceFileContent: string, context: SchematicContext, recorder: UpdateRecorder, moduleFilePath: string, moduleIndex: number, moduleFunction?: string, override?: boolean): UpdateRecorder;
|
44
42
|
/**
|
45
43
|
* Insert import on top of the main module file
|
46
|
-
*
|
47
44
|
* @param name
|
48
45
|
* @param file
|
49
46
|
* @param sourceFile
|
@@ -54,7 +51,6 @@ export declare function addImportToModuleFile(name: string, file: string, source
|
|
54
51
|
export declare function insertImportToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, recorder: UpdateRecorder, moduleFilePath: string, isDefault?: boolean): UpdateRecorder;
|
55
52
|
/**
|
56
53
|
* Add providers to the main module
|
57
|
-
*
|
58
54
|
* @param name
|
59
55
|
* @param file
|
60
56
|
* @param sourceFile
|
@@ -68,7 +64,6 @@ export declare function insertImportToModuleFile(name: string, file: string, sou
|
|
68
64
|
export declare function addProviderToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, sourceFileContent: string, context: SchematicContext, recorder: UpdateRecorder, moduleFilePath: string, moduleIndex: number, customProvider?: string): UpdateRecorder;
|
69
65
|
/**
|
70
66
|
* Add custom code before the module definition
|
71
|
-
*
|
72
67
|
* @param line
|
73
68
|
* @param file
|
74
69
|
* @param recorder
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAuB,IAAI,EAAE,cAAc,EAAC,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAejC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,sBA0DtG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAuB,IAAI,EAAE,cAAc,EAAC,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAejC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,sBA0DtG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,MAAM,sBAU1F;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,4BAgB1G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EACrI,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,UAAQ,kBAoB3H;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,kBAMpK;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EACrI,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,kBAY3G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAK3G"}
|
package/src/utility/modules.js
CHANGED
@@ -11,38 +11,38 @@ const path = require("node:path");
|
|
11
11
|
const ast_1 = require("./ast");
|
12
12
|
const loaders_1 = require("./loaders");
|
13
13
|
/**
|
14
|
-
* Get the path to the app.module.ts
|
15
|
-
*
|
14
|
+
* Get the path to the `app.module.ts`
|
15
|
+
* In case of standalone application, get the path to the `app.config.ts` instead
|
16
16
|
* @param tree File tree
|
17
17
|
* @param context Context of the rule
|
18
18
|
* @param projectName The name of the project where to search for an app module file
|
19
19
|
*/
|
20
20
|
function getAppModuleFilePath(tree, context, projectName) {
|
21
|
-
const workspaceProject = (0, loaders_1.
|
21
|
+
const workspaceProject = projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
|
22
22
|
// exit if not an application
|
23
23
|
if (!workspaceProject) {
|
24
24
|
context.logger.debug('Aborted. App module file path will be searched only in application project.');
|
25
25
|
return undefined;
|
26
26
|
}
|
27
|
-
const mainFilePath = workspaceProject.architect.build.options.main;
|
27
|
+
const mainFilePath = workspaceProject.architect.build.options.main ?? workspaceProject.architect.build.options.browser;
|
28
28
|
const mainFile = tree.read(mainFilePath).toString();
|
29
|
-
const bootstrapModuleRegexpResult = mainFile.match(/bootstrapModule\(([
|
29
|
+
const bootstrapModuleRegexpResult = mainFile.match(/(?:bootstrapModule|bootstrapApplication)\((?:[^,)]*,)*\s*([^,) ]*)\s*\)/m);
|
30
30
|
if (!bootstrapModuleRegexpResult || !bootstrapModuleRegexpResult[1]) {
|
31
|
-
throw new schematics_1.SchematicsException('Could not find bootstrap module');
|
31
|
+
throw new schematics_1.SchematicsException('Could not find bootstrap module or appConfig');
|
32
32
|
}
|
33
33
|
const bootstrapModule = bootstrapModuleRegexpResult[1];
|
34
34
|
const findSource = new RegExp(`import +\\{[^}]*${bootstrapModule}[^}]*\\} +from +['"]([^'"]+)['"] *;`, 'm');
|
35
35
|
const bootstrapModuleFileRegExpResult = mainFile.match(findSource);
|
36
36
|
if (!bootstrapModuleFileRegExpResult || !bootstrapModuleFileRegExpResult[1]) {
|
37
|
-
throw new schematics_1.SchematicsException('Could not find bootstrap module');
|
37
|
+
throw new schematics_1.SchematicsException('Could not find bootstrap module or appConfig');
|
38
38
|
}
|
39
39
|
/** Path to the main module file */
|
40
|
-
const moduleFilePath = path.join(path.dirname(
|
41
|
-
const exportAppModuleClassRegExp = new RegExp(`class\\s+${bootstrapModule}`, 'gm');
|
40
|
+
const moduleFilePath = path.join(path.dirname(mainFilePath), bootstrapModuleFileRegExpResult[1] + '.ts');
|
41
|
+
const exportAppModuleClassRegExp = new RegExp(`(?:class|const)\\s+${bootstrapModule}`, 'gm');
|
42
42
|
if (tree.exists(moduleFilePath) && tree.read(moduleFilePath).toString().match(exportAppModuleClassRegExp)) {
|
43
43
|
return moduleFilePath;
|
44
44
|
}
|
45
|
-
const possibleAppModule = path.join(path.dirname(
|
45
|
+
const possibleAppModule = path.join(path.dirname(mainFilePath), path.dirname(bootstrapModuleFileRegExpResult[1]), 'app.module.ts');
|
46
46
|
if (tree.exists(possibleAppModule) && tree.read(possibleAppModule).toString().match(exportAppModuleClassRegExp)) {
|
47
47
|
return possibleAppModule;
|
48
48
|
}
|
@@ -55,8 +55,8 @@ function getAppModuleFilePath(tree, context, projectName) {
|
|
55
55
|
if (bootstrapModuleSymbol) {
|
56
56
|
const pathPlusModuleString = checker.getFullyQualifiedName(bootstrapModuleSymbol);
|
57
57
|
const filePath = pathPlusModuleString?.replace(new RegExp(`.${bootstrapModule}`), '').replace(/['"]/g, '');
|
58
|
-
const relativeFilePath = filePath ? path.relative(path.dirname(
|
59
|
-
const filePathInTree = relativeFilePath ? path.join(path.dirname(
|
58
|
+
const relativeFilePath = filePath ? path.relative(path.dirname(mainFilePath), `${filePath}.ts`) : undefined;
|
59
|
+
const filePathInTree = relativeFilePath ? path.join(path.dirname(mainFilePath), relativeFilePath) : undefined;
|
60
60
|
if (filePathInTree && tree.exists(filePathInTree) && tree.read(filePathInTree).toString().match(exportAppModuleClassRegExp)) {
|
61
61
|
return filePathInTree;
|
62
62
|
}
|
@@ -66,31 +66,30 @@ function getAppModuleFilePath(tree, context, projectName) {
|
|
66
66
|
exports.getAppModuleFilePath = getAppModuleFilePath;
|
67
67
|
/**
|
68
68
|
* Get the path to the main.ts
|
69
|
-
*
|
70
69
|
* @param tree File tree
|
71
70
|
* @param context Context of the rule
|
71
|
+
* @param projectName
|
72
72
|
*/
|
73
|
-
function getMainFilePath(tree, context) {
|
74
|
-
const workspaceProject = (0, loaders_1.
|
73
|
+
function getMainFilePath(tree, context, projectName) {
|
74
|
+
const workspaceProject = projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
|
75
75
|
// exit if not an application
|
76
76
|
if (!workspaceProject) {
|
77
77
|
context.logger.debug('Register localization on main module only in application project');
|
78
78
|
return undefined;
|
79
79
|
}
|
80
|
-
const mainFilePath = workspaceProject.architect.build.options.main;
|
80
|
+
const mainFilePath = workspaceProject.architect.build.options.main ?? workspaceProject.architect.build.options.browser;
|
81
81
|
return mainFilePath;
|
82
82
|
}
|
83
83
|
exports.getMainFilePath = getMainFilePath;
|
84
84
|
/**
|
85
85
|
* Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
|
86
86
|
* one of its modules.
|
87
|
-
*
|
88
87
|
* @param tree
|
89
88
|
* @param options @see RuleFactory.options
|
90
89
|
* @param options.projectName
|
91
90
|
*/
|
92
91
|
function isApplicationThatUsesRouterModule(tree, options) {
|
93
|
-
const workspaceProject = (0, loaders_1.
|
92
|
+
const workspaceProject = options.projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
94
93
|
const cwd = process.cwd().replace(/[\\/]+/g, '/');
|
95
94
|
const root = (workspaceProject?.root && cwd.endsWith(workspaceProject.root)) ? workspaceProject.root.replace(/[^\\/]+/g, '..') : '.';
|
96
95
|
return workspaceProject?.sourceRoot &&
|
@@ -110,7 +109,6 @@ function isApplicationThatUsesRouterModule(tree, options) {
|
|
110
109
|
exports.isApplicationThatUsesRouterModule = isApplicationThatUsesRouterModule;
|
111
110
|
/**
|
112
111
|
* Add import to the main module
|
113
|
-
*
|
114
112
|
* @param name
|
115
113
|
* @param file
|
116
114
|
* @param sourceFile
|
@@ -149,7 +147,6 @@ function addImportToModuleFile(name, file, sourceFile, sourceFileContent, contex
|
|
149
147
|
exports.addImportToModuleFile = addImportToModuleFile;
|
150
148
|
/**
|
151
149
|
* Insert import on top of the main module file
|
152
|
-
*
|
153
150
|
* @param name
|
154
151
|
* @param file
|
155
152
|
* @param sourceFile
|
@@ -167,7 +164,6 @@ function insertImportToModuleFile(name, file, sourceFile, recorder, moduleFilePa
|
|
167
164
|
exports.insertImportToModuleFile = insertImportToModuleFile;
|
168
165
|
/**
|
169
166
|
* Add providers to the main module
|
170
|
-
*
|
171
167
|
* @param name
|
172
168
|
* @param file
|
173
169
|
* @param sourceFile
|
@@ -194,7 +190,6 @@ function addProviderToModuleFile(name, file, sourceFile, sourceFileContent, cont
|
|
194
190
|
exports.addProviderToModuleFile = addProviderToModuleFile;
|
195
191
|
/**
|
196
192
|
* Add custom code before the module definition
|
197
|
-
*
|
198
193
|
* @param line
|
199
194
|
* @param file
|
200
195
|
* @param recorder
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":";;;AAAA,2DAAuG;AACvG,iCAAiC;AACjC,qEAK+C;AAC/C,+DAAgE;AAChE,8BAA8B;AAC9B,mCAA0C;AAC1C,kCAAkC;AAClC,+BAAiD;AACjD,
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":";;;AAAA,2DAAuG;AACvG,iCAAiC;AACjC,qEAK+C;AAC/C,+DAAgE;AAChE,8BAA8B;AAC9B,mCAA0C;AAC1C,kCAAkC;AAClC,+BAAiD;AACjD,uCAA+C;AAG/C;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,IAAU,EAAE,OAAyB,EAAE,WAA2B;IACrG,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,4BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnG,6BAA6B;IAC7B,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;QACpG,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,YAAY,GAAW,gBAAgB,CAAC,SAAU,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,gBAAgB,CAAC,SAAU,CAAC,KAAK,CAAC,OAAO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,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpJ;IACH,CAAC,CAAC,CAAC;IACL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAbD,0DAaC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,IAAY,EAAE,IAAY,EAAE,QAAwB,EAAE,WAAmB;IAC1G,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;QACtD,OAAO,QAAQ,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;KAC5D;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AALD,gDAKC"}
|
@@ -2,7 +2,6 @@ import type { SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
2
|
import { WorkspaceLayout, WorkspaceProject, WorkspaceSchema } from '../interfaces';
|
3
3
|
/**
|
4
4
|
* Find the relative path to a configuration file at the monorepo root
|
5
|
-
*
|
6
5
|
* @param tree
|
7
6
|
* @param files List of files to look for, the first of the list will used
|
8
7
|
* @param originPath Path from where to calculate the relative path
|
@@ -11,19 +10,16 @@ import { WorkspaceLayout, WorkspaceProject, WorkspaceSchema } from '../interface
|
|
11
10
|
export declare function findConfigFileRelativePath(tree: Tree, files: string[], originPath: string): string;
|
12
11
|
/**
|
13
12
|
* Determine if we are in an Nx Monorepo context
|
14
|
-
*
|
15
13
|
* @param tree
|
16
14
|
*/
|
17
15
|
export declare function isNxContext(tree: Tree): boolean;
|
18
16
|
/**
|
19
17
|
* Determine if a repository is standalone (not part of a monorepo)
|
20
|
-
*
|
21
18
|
* @param tree
|
22
19
|
*/
|
23
20
|
export declare function isStandaloneRepository(tree: Tree): boolean | null;
|
24
21
|
/**
|
25
22
|
* Determine if we are in a project with multi packages
|
26
|
-
*
|
27
23
|
* @param tree
|
28
24
|
*/
|
29
25
|
export declare function isMultipackagesContext(tree: Tree): boolean;
|
@@ -39,7 +35,6 @@ export declare const BASE_ROOT_FOLDERS_MAP: Record<WorkspaceProject['projectType
|
|
39
35
|
* Retrieve the project base root generation folder, based on the given projectType.
|
40
36
|
* - The default project root will be returned if there is no project root found in nx.json or angular.json (in schematics options)
|
41
37
|
* - The root path '/' will be returned if no project type given
|
42
|
-
*
|
43
38
|
* @param tree
|
44
39
|
* @param context
|
45
40
|
* @param config
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"monorepo.d.ts","sourceRoot":"","sources":["../../../src/utility/monorepo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKnF
|
1
|
+
{"version":3,"file":"monorepo.d.ts","sourceRoot":"","sources":["../../../src/utility/monorepo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKnF;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,UAOzF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,WAErC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,kBAGhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,WAEhD;AAED,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,SAAS,CAAC;AAE/C,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,EAAE,eAGlC,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,eAAe,CAGhG,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,OAQtJ"}
|
package/src/utility/monorepo.js
CHANGED
@@ -6,7 +6,6 @@ const collection_1 = require("./collection");
|
|
6
6
|
const loaders_1 = require("./loaders");
|
7
7
|
/**
|
8
8
|
* Find the relative path to a configuration file at the monorepo root
|
9
|
-
*
|
10
9
|
* @param tree
|
11
10
|
* @param files List of files to look for, the first of the list will used
|
12
11
|
* @param originPath Path from where to calculate the relative path
|
@@ -22,7 +21,6 @@ function findConfigFileRelativePath(tree, files, originPath) {
|
|
22
21
|
exports.findConfigFileRelativePath = findConfigFileRelativePath;
|
23
22
|
/**
|
24
23
|
* Determine if we are in an Nx Monorepo context
|
25
|
-
*
|
26
24
|
* @param tree
|
27
25
|
*/
|
28
26
|
function isNxContext(tree) {
|
@@ -31,7 +29,6 @@ function isNxContext(tree) {
|
|
31
29
|
exports.isNxContext = isNxContext;
|
32
30
|
/**
|
33
31
|
* Determine if a repository is standalone (not part of a monorepo)
|
34
|
-
*
|
35
32
|
* @param tree
|
36
33
|
*/
|
37
34
|
function isStandaloneRepository(tree) {
|
@@ -41,7 +38,6 @@ function isStandaloneRepository(tree) {
|
|
41
38
|
exports.isStandaloneRepository = isStandaloneRepository;
|
42
39
|
/**
|
43
40
|
* Determine if we are in a project with multi packages
|
44
|
-
*
|
45
41
|
* @param tree
|
46
42
|
*/
|
47
43
|
function isMultipackagesContext(tree) {
|
@@ -66,7 +62,6 @@ exports.BASE_ROOT_FOLDERS_MAP = {
|
|
66
62
|
* Retrieve the project base root generation folder, based on the given projectType.
|
67
63
|
* - The default project root will be returned if there is no project root found in nx.json or angular.json (in schematics options)
|
68
64
|
* - The root path '/' will be returned if no project type given
|
69
|
-
*
|
70
65
|
* @param tree
|
71
66
|
* @param context
|
72
67
|
* @param config
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"monorepo.js","sourceRoot":"","sources":["../../../src/utility/monorepo.ts"],"names":[],"mappings":";;;AACA,kCAAkC;AAElC,6CAAmD;AAEnD,uCAA+C;AAE/C
|
1
|
+
{"version":3,"file":"monorepo.js","sourceRoot":"","sources":["../../../src/utility/monorepo.ts"],"names":[],"mappings":";;;AACA,kCAAkC;AAElC,6CAAmD;AAEnD,uCAA+C;AAE/C;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,IAAU,EAAE,KAAe,EAAE,UAAkB;IACxF,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAChE,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;AAC1D,CAAC;AAPD,gEAOC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,IAAU;IAC/C,MAAM,eAAe,GAAG,IAAA,4BAAkB,EAAC,IAAI,CAAC,CAAC;IACjD,OAAO,eAAe,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAA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
|
|
1
|
-
import { WorkspaceSchema } from '../interfaces';
|
2
1
|
import { logging } from '@angular-devkit/core';
|
2
|
+
import type { WorkspaceSchema } from '../interfaces';
|
3
3
|
/** Support NPM package managers */
|
4
4
|
export type SupportedPackageManagers = 'npm' | 'yarn';
|
5
5
|
/** Support NPM package managers */
|
@@ -17,27 +17,44 @@ export interface PackageManagerOptions {
|
|
17
17
|
}
|
18
18
|
/**
|
19
19
|
* Determine if the given packager manager is supported
|
20
|
-
*
|
21
20
|
* @param name Name of the package manager
|
22
21
|
*/
|
23
22
|
export declare function isSupportedPackageManager(name?: any): name is SupportedPackageManagers;
|
24
23
|
/**
|
25
24
|
* Get package manager used in runs
|
26
25
|
* Defaults to the package manager setup in process.env if no package manager set in angular.json
|
27
|
-
*
|
28
26
|
* @param options Option to determine the final package manager
|
29
27
|
*/
|
30
28
|
export declare function getPackageManager(options?: PackageManagerOptions): SupportedPackageManagers;
|
31
29
|
/**
|
32
30
|
* Get command to run scripts with your package manager
|
33
|
-
*
|
34
31
|
* @param workspaceConfig Workspace configuration
|
32
|
+
* @param packageName Name of the package of the workspace to run the script (name from package.json)
|
35
33
|
*/
|
36
|
-
export declare function getPackageManagerRunner(workspaceConfig?: WorkspaceSchema | string | null):
|
34
|
+
export declare function getPackageManagerRunner(workspaceConfig?: WorkspaceSchema | string | null, packageName?: string | undefined): string;
|
37
35
|
/**
|
38
36
|
* Get command to execute bin command with your package manager
|
39
|
-
*
|
40
37
|
* @param workspaceConfig Workspace configuration
|
38
|
+
* @param packageName Name of the package of the workspace to execute the command
|
41
39
|
*/
|
42
|
-
export declare function getPackageManagerExecutor(workspaceConfig?: WorkspaceSchema | string | null):
|
40
|
+
export declare function getPackageManagerExecutor(workspaceConfig?: WorkspaceSchema | string | null, packageName?: string | undefined): string;
|
41
|
+
/**
|
42
|
+
* Determine if the given package is installed
|
43
|
+
* @param packageName name of the package to check
|
44
|
+
* @returns
|
45
|
+
*/
|
46
|
+
export declare function isPackageInstalled(packageName: string): boolean;
|
47
|
+
/**
|
48
|
+
* Get package manager version
|
49
|
+
* @param options Option to determine the final package manager
|
50
|
+
*/
|
51
|
+
export declare function getPackageManagerVersion(options?: PackageManagerOptions): string | undefined;
|
52
|
+
/**
|
53
|
+
* Get package manager information
|
54
|
+
* @param options Option to determine the final package manager
|
55
|
+
*/
|
56
|
+
export declare function getPackageManagerInfo(options?: PackageManagerOptions): {
|
57
|
+
name: SupportedPackageManagers;
|
58
|
+
version: string | undefined;
|
59
|
+
};
|
43
60
|
//# sourceMappingURL=package-manager-runner.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"package-manager-runner.d.ts","sourceRoot":"","sources":["../../../src/utility/package-manager-runner.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"package-manager-runner.d.ts","sourceRoot":"","sources":["../../../src/utility/package-manager-runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,mCAAmC;AACnC,MAAM,MAAM,wBAAwB,GAAG,KAAK,GAAG,MAAM,CAAC;AAEtD,mCAAmC;AACnC,MAAM,MAAM,8BAA8B,GAAG,GAAG,wBAAwB,MAAM,GAAG,MAAM,CAAC;AAExF,mCAAmC;AACnC,MAAM,MAAM,gCAAgC,GAAG,GAAG,wBAAwB,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAOnG,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,8BAA8B;IAC9B,eAAe,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;IAElD,4DAA4D;IAC5D,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,IAAI,wBAAwB,CAEtF;AAYD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,qBAAqB,4BAWhE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMnI;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMrI;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,WAMrD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAiB5F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,qBAAqB;;;EAKpE"}
|
@@ -1,9 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getPackageManagerExecutor = exports.getPackageManagerRunner = exports.getPackageManager = exports.isSupportedPackageManager = void 0;
|
3
|
+
exports.getPackageManagerInfo = exports.getPackageManagerVersion = exports.isPackageInstalled = exports.getPackageManagerExecutor = exports.getPackageManagerRunner = exports.getPackageManager = exports.isSupportedPackageManager = void 0;
|
4
|
+
const node_path_1 = require("node:path");
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
6
|
+
const PACKAGE_MANAGER_WORKSPACE_MAPPING = {
|
7
|
+
npm: '--workspace',
|
8
|
+
yarn: 'workspace'
|
9
|
+
};
|
4
10
|
/**
|
5
11
|
* Determine if the given packager manager is supported
|
6
|
-
*
|
7
12
|
* @param name Name of the package manager
|
8
13
|
*/
|
9
14
|
function isSupportedPackageManager(name) {
|
@@ -12,7 +17,6 @@ function isSupportedPackageManager(name) {
|
|
12
17
|
exports.isSupportedPackageManager = isSupportedPackageManager;
|
13
18
|
/**
|
14
19
|
* Get the Package Manager
|
15
|
-
*
|
16
20
|
* @param enforcedNpmManager package manager to enforce
|
17
21
|
*/
|
18
22
|
function getPackageManagerName(enforcedNpmManager) {
|
@@ -23,7 +27,6 @@ function getPackageManagerName(enforcedNpmManager) {
|
|
23
27
|
/**
|
24
28
|
* Get package manager used in runs
|
25
29
|
* Defaults to the package manager setup in process.env if no package manager set in angular.json
|
26
|
-
*
|
27
30
|
* @param options Option to determine the final package manager
|
28
31
|
*/
|
29
32
|
function getPackageManager(options) {
|
@@ -41,20 +44,77 @@ function getPackageManager(options) {
|
|
41
44
|
exports.getPackageManager = getPackageManager;
|
42
45
|
/**
|
43
46
|
* Get command to run scripts with your package manager
|
44
|
-
*
|
45
47
|
* @param workspaceConfig Workspace configuration
|
48
|
+
* @param packageName Name of the package of the workspace to run the script (name from package.json)
|
46
49
|
*/
|
47
|
-
function getPackageManagerRunner(workspaceConfig) {
|
48
|
-
|
50
|
+
function getPackageManagerRunner(workspaceConfig, packageName) {
|
51
|
+
const pckManager = getPackageManager({ workspaceConfig });
|
52
|
+
if (!packageName) {
|
53
|
+
return `${pckManager} run`;
|
54
|
+
}
|
55
|
+
return `${pckManager} ${PACKAGE_MANAGER_WORKSPACE_MAPPING[pckManager]} ${packageName} run`;
|
49
56
|
}
|
50
57
|
exports.getPackageManagerRunner = getPackageManagerRunner;
|
51
58
|
/**
|
52
59
|
* Get command to execute bin command with your package manager
|
53
|
-
*
|
54
60
|
* @param workspaceConfig Workspace configuration
|
61
|
+
* @param packageName Name of the package of the workspace to execute the command
|
55
62
|
*/
|
56
|
-
function getPackageManagerExecutor(workspaceConfig) {
|
57
|
-
|
63
|
+
function getPackageManagerExecutor(workspaceConfig, packageName) {
|
64
|
+
const pckManager = getPackageManager({ workspaceConfig });
|
65
|
+
if (!packageName) {
|
66
|
+
return `${pckManager} exec`;
|
67
|
+
}
|
68
|
+
return `${pckManager} ${PACKAGE_MANAGER_WORKSPACE_MAPPING[pckManager]} ${packageName} exec`;
|
58
69
|
}
|
59
70
|
exports.getPackageManagerExecutor = getPackageManagerExecutor;
|
71
|
+
/**
|
72
|
+
* Determine if the given package is installed
|
73
|
+
* @param packageName name of the package to check
|
74
|
+
* @returns
|
75
|
+
*/
|
76
|
+
function isPackageInstalled(packageName) {
|
77
|
+
try {
|
78
|
+
return !!require.resolve(node_path_1.posix.join(packageName, 'package.json'));
|
79
|
+
}
|
80
|
+
catch {
|
81
|
+
return false;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
exports.isPackageInstalled = isPackageInstalled;
|
85
|
+
/**
|
86
|
+
* Get package manager version
|
87
|
+
* @param options Option to determine the final package manager
|
88
|
+
*/
|
89
|
+
function getPackageManagerVersion(options) {
|
90
|
+
try {
|
91
|
+
return (0, node_child_process_1.execSync)(`${getPackageManager(options)} --version`, {
|
92
|
+
encoding: 'utf8',
|
93
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
94
|
+
env: {
|
95
|
+
...process.env,
|
96
|
+
// NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
|
97
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
98
|
+
NO_UPDATE_NOTIFIER: '1',
|
99
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
100
|
+
NPM_CONFIG_UPDATE_NOTIFIER: 'false'
|
101
|
+
}
|
102
|
+
}).trim();
|
103
|
+
}
|
104
|
+
catch {
|
105
|
+
return undefined;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
exports.getPackageManagerVersion = getPackageManagerVersion;
|
109
|
+
/**
|
110
|
+
* Get package manager information
|
111
|
+
* @param options Option to determine the final package manager
|
112
|
+
*/
|
113
|
+
function getPackageManagerInfo(options) {
|
114
|
+
return {
|
115
|
+
name: getPackageManager(options),
|
116
|
+
version: getPackageManagerVersion(options)
|
117
|
+
};
|
118
|
+
}
|
119
|
+
exports.getPackageManagerInfo = getPackageManagerInfo;
|
60
120
|
//# sourceMappingURL=package-manager-runner.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"package-manager-runner.js","sourceRoot":"","sources":["../../../src/utility/package-manager-runner.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"package-manager-runner.js","sourceRoot":"","sources":["../../../src/utility/package-manager-runner.ts"],"names":[],"mappings":";;;AAAA,yCAAkC;AAElC,2DAA8C;AAY9C,MAAM,iCAAiC,GAA6C;IAClF,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,WAAW;CAClB,CAAC;AAcF;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,IAAU;IAClD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,CAAC;AAC3C,CAAC;AAFD,8DAEC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAAC,kBAA6C;IAC1E,MAAM,uBAAuB,GAAG,yBAAyB,CAAC,OAAO,CAAC,GAAG,EAAE,wBAAwB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACzI,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;IACpF,OAAO,kBAAkB,IAAI,uBAAuB,IAAI,qBAAqB,IAAI,KAAK,CAAC;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,OAA+B;IAC/D,IAAI,2BAA+C,CAAC;IACpD,IAAI,OAAO,EAAE,eAAe,EAAE;QAC5B,MAAM,cAAc,GAAG,CAAC,OAAO,OAAO,EAAE,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,CAAqB,CAAC,CAAC,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC7J,IAAI,cAAc,EAAE,GAAG,EAAE,cAAc,E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AAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gDAMC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,OAA+B;IACtE,IAAI;QACF,OAAO,IAAA,6BAAQ,EAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,YAAY,EAAE;YACzD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;YACnC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,uGAAuG;gBACvG,gEAAgE;gBAChE,kBAAkB,EAAE,GAAG;gBACvB,gEAAgE;gBAChE,0BAA0B,EAAE,OAAO;aACpC;SACF,CAAC,CAAC,IAAI,EAAE,CAAC;KACX;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAjBD,4DAiBC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,OAA+B;IACnE,OAAO;QACL,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;QAChC,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC;KAC3C,CAAC;AACJ,CAAC;AALD,sDAKC"}
|
@@ -1,14 +1,12 @@
|
|
1
1
|
import { Tree } from '@angular-devkit/schematics';
|
2
2
|
/**
|
3
3
|
* Return the version of the given package json path
|
4
|
-
*
|
5
4
|
* @param packageJsonPath
|
6
5
|
*/
|
7
6
|
export declare function getPackageVersion(packageJsonPath: string): string | undefined;
|
8
7
|
/**
|
9
8
|
* Find the closest package.json file in parent folders
|
10
9
|
* Note: It is using file system if no tree provided
|
11
|
-
*
|
12
10
|
* @param currentPath current path to inspect
|
13
11
|
* @param tree current path to inspect
|
14
12
|
* @returns
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../../../src/utility/package-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAMlD
|
1
|
+
{"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../../../src/utility/package-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAMlD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,sBAGxD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,SAAS,IAAI,KAAG,MAAM,GAAG,SAQlF,CAAC"}
|
@@ -6,7 +6,6 @@ const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
7
7
|
/**
|
8
8
|
* Return the version of the given package json path
|
9
|
-
*
|
10
9
|
* @param packageJsonPath
|
11
10
|
*/
|
12
11
|
function getPackageVersion(packageJsonPath) {
|
@@ -17,7 +16,6 @@ exports.getPackageVersion = getPackageVersion;
|
|
17
16
|
/**
|
18
17
|
* Find the closest package.json file in parent folders
|
19
18
|
* Note: It is using file system if no tree provided
|
20
|
-
*
|
21
19
|
* @param currentPath current path to inspect
|
22
20
|
* @param tree current path to inspect
|
23
21
|
* @returns
|