@mouryaamit/nx-polystack 1.2.6 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/migrations.json +5 -0
- package/dist/src/cli/commands/app-from.js +2 -2
- package/dist/src/cli/commands/app-from.js.map +1 -1
- package/dist/src/cli/commands/build.js +2 -2
- package/dist/src/cli/commands/build.js.map +1 -1
- package/dist/src/cli/commands/index.js +2 -0
- package/dist/src/cli/commands/index.js.map +1 -1
- package/dist/src/cli/commands/inspect.d.ts +3 -0
- package/dist/src/cli/commands/inspect.js +105 -0
- package/dist/src/cli/commands/inspect.js.map +1 -0
- package/dist/src/cli/commands/new.d.ts +3 -0
- package/dist/src/cli/commands/new.js +19 -1
- package/dist/src/cli/commands/new.js.map +1 -1
- package/dist/src/cli/commands/preset.js +3 -0
- package/dist/src/cli/commands/preset.js.map +1 -1
- package/dist/src/cli/commands/upgrade.d.ts +51 -0
- package/dist/src/cli/commands/upgrade.js +447 -0
- package/dist/src/cli/commands/upgrade.js.map +1 -0
- package/dist/src/cli/help.js +22 -0
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/launcher.js +3 -1
- package/dist/src/cli/launcher.js.map +1 -1
- package/dist/src/cli/run-tree.js +4 -4
- package/dist/src/cli/run-tree.js.map +1 -1
- package/dist/src/executors/build/executor.js +4 -0
- package/dist/src/executors/build/executor.js.map +1 -1
- package/dist/src/executors/build/schema.d.ts +2 -0
- package/dist/src/executors/build/schema.json +28 -7
- package/dist/src/executors/clean/executor.js +0 -1
- package/dist/src/executors/clean/executor.js.map +1 -1
- package/dist/src/executors/flutter-build/executor.js +19 -2
- package/dist/src/executors/flutter-build/executor.js.map +1 -1
- package/dist/src/executors/flutter-build/schema.d.ts +2 -0
- package/dist/src/executors/flutter-build/schema.json +13 -1
- package/dist/src/generators/app/files/angular/src/main.ts__template__ +1 -1
- package/dist/src/generators/app/files/ionic/package.json__template__ +4 -4
- package/dist/src/generators/app/from.js +3 -1
- package/dist/src/generators/app/from.js.map +1 -1
- package/dist/src/generators/app/generator.js +20 -4
- package/dist/src/generators/app/generator.js.map +1 -1
- package/dist/src/generators/infra/generator.js +2 -2
- package/dist/src/generators/infra/generator.js.map +1 -1
- package/dist/src/generators/lib/types/ionic.d.ts +2 -2
- package/dist/src/generators/lib/types/ionic.js +4 -3
- package/dist/src/generators/lib/types/ionic.js.map +1 -1
- package/dist/src/generators/migrate/adapters/angular-cli.d.ts +1 -1
- package/dist/src/generators/migrate/adapters/angular-cli.js +16 -10
- package/dist/src/generators/migrate/adapters/angular-cli.js.map +1 -1
- package/dist/src/generators/migrate/adapters/angular-workspace.js +3 -1
- package/dist/src/generators/migrate/adapters/angular-workspace.js.map +1 -1
- package/dist/src/generators/migrate/adapters/npm-workspaces.js +2 -1
- package/dist/src/generators/migrate/adapters/npm-workspaces.js.map +1 -1
- package/dist/src/generators/migrate/angular-config-files.js +8 -0
- package/dist/src/generators/migrate/angular-config-files.js.map +1 -1
- package/dist/src/generators/migrate/angular-project-json.d.ts +5 -0
- package/dist/src/generators/migrate/angular-project-json.js +18 -6
- package/dist/src/generators/migrate/angular-project-json.js.map +1 -1
- package/dist/src/generators/migrate/dependencies.d.ts +10 -1
- package/dist/src/generators/migrate/dependencies.js +26 -5
- package/dist/src/generators/migrate/dependencies.js.map +1 -1
- package/dist/src/generators/migrate/generator.js +12 -0
- package/dist/src/generators/migrate/generator.js.map +1 -1
- package/dist/src/generators/migrate/nx/env-encryption.d.ts +1 -1
- package/dist/src/generators/migrate/nx/env-encryption.js +2 -2
- package/dist/src/generators/migrate/nx/env-encryption.js.map +1 -1
- package/dist/src/generators/preset/generator.js +9 -0
- package/dist/src/generators/preset/generator.js.map +1 -1
- package/dist/src/generators/preset/schema.d.ts +2 -0
- package/dist/src/generators/preset/schema.json +5 -0
- package/dist/src/lib/env-encryption/switch-gcm.js +9 -2
- package/dist/src/lib/env-encryption/switch-gcm.js.map +1 -1
- package/dist/src/lib/helpers/build-gen.d.ts +26 -0
- package/dist/src/lib/helpers/build-gen.js +68 -0
- package/dist/src/lib/helpers/build-gen.js.map +1 -0
- package/dist/src/lib/helpers/inject-meta.d.ts +3 -0
- package/dist/src/lib/helpers/inject-meta.js +1 -0
- package/dist/src/lib/helpers/inject-meta.js.map +1 -1
- package/dist/src/lib/upgrade/pins.d.ts +34 -0
- package/dist/src/lib/upgrade/pins.js +89 -0
- package/dist/src/lib/upgrade/pins.js.map +1 -0
- package/dist/src/lib/utils/angular-deps.d.ts +31 -6
- package/dist/src/lib/utils/angular-deps.js +86 -37
- package/dist/src/lib/utils/angular-deps.js.map +1 -1
- package/dist/src/lib/utils/env-alias.d.ts +40 -0
- package/dist/src/lib/utils/env-alias.js +146 -0
- package/dist/src/lib/utils/env-alias.js.map +1 -0
- package/dist/src/lib/utils/nx-tree.d.ts +5 -0
- package/dist/src/lib/utils/nx-tree.js +39 -0
- package/dist/src/lib/utils/nx-tree.js.map +1 -0
- package/dist/src/migrations/env-import-alias/env-import-alias.d.ts +7 -0
- package/dist/src/migrations/env-import-alias/env-import-alias.js +32 -0
- package/dist/src/migrations/env-import-alias/env-import-alias.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,11 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ngPackagrDependencies = exports.ensureAngularDependencies = exports.ANGULAR_VERSION = void 0;
|
|
3
|
+
exports.ngPackagrDependencies = exports.ensureAngularDependencies = exports.workspaceGeneratorVersions = exports.angularGeneratorVersions = exports.GENERATOR_ANGULAR_MAJORS = exports.ANGULAR_MAJOR = exports.ANGULAR_VERSION = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const pins_1 = require("../upgrade/pins");
|
|
5
6
|
const dependencies_1 = require("./dependencies");
|
|
6
|
-
/** Angular line
|
|
7
|
+
/** Angular line a workspace without Angular gets by default (NgModule bootstrap, browser builder). */
|
|
7
8
|
exports.ANGULAR_VERSION = '~15.2.0';
|
|
8
|
-
|
|
9
|
+
exports.ANGULAR_MAJOR = 15;
|
|
10
|
+
/**
|
|
11
|
+
* Angular majors the generators write for: `pstack new --angular=<major>`, and `pstack app` / `:lib`
|
|
12
|
+
* fill in packages for a workspace on one of them. One major is added per public release.
|
|
13
|
+
*/
|
|
14
|
+
exports.GENERATOR_ANGULAR_MAJORS = [15, 16];
|
|
15
|
+
const ZONE_JS = { 15: '~0.12.0', 16: '~0.13.0' };
|
|
16
|
+
/** @types/node the major's TypeScript can parse (a latest one uses newer syntax: TS1139). */
|
|
17
|
+
const TYPES_NODE = { 15: '~18.16.9', 16: '~20.10.0' };
|
|
18
|
+
function angularGeneratorVersions(major) {
|
|
19
|
+
if (major === 15) {
|
|
20
|
+
// Kept as released: angular-eslint 15.x works with any Angular 15.x.
|
|
21
|
+
return {
|
|
22
|
+
angular: exports.ANGULAR_VERSION,
|
|
23
|
+
zoneJs: ZONE_JS[15],
|
|
24
|
+
typescript: '~4.9.5',
|
|
25
|
+
typesNode: TYPES_NODE[15],
|
|
26
|
+
angularEslint: exports.ANGULAR_VERSION,
|
|
27
|
+
ionicAngular: '~7.8.0',
|
|
28
|
+
capacitor: '~5.7.0',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const pins = pins_1.ANGULAR_PINS[major];
|
|
32
|
+
if (!pins || !exports.GENERATOR_ANGULAR_MAJORS.includes(major)) {
|
|
33
|
+
throw new Error(`Angular ${major} is not supported by the generators (${exports.GENERATOR_ANGULAR_MAJORS.join(', ')}).`);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
angular: `~${pins.angular}`,
|
|
37
|
+
zoneJs: ZONE_JS[major],
|
|
38
|
+
typescript: `~${pins.typescript}`,
|
|
39
|
+
typesNode: TYPES_NODE[major],
|
|
40
|
+
angularEslint: (0, pins_1.pinRange)(pins.angularEslint),
|
|
41
|
+
ionicAngular: (0, pins_1.pinRange)(pins.ionic),
|
|
42
|
+
capacitor: `^${pins.capacitor}.0.0`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.angularGeneratorVersions = angularGeneratorVersions;
|
|
46
|
+
/**
|
|
47
|
+
* The generator versions for the workspace's Angular (the declared @angular/core), or for Angular
|
|
48
|
+
* 15 when there is none or the major is not one the generators support.
|
|
49
|
+
*/
|
|
50
|
+
function workspaceGeneratorVersions(tree) {
|
|
51
|
+
const major = (0, dependencies_1.majorOf)((0, dependencies_1.declaredVersion)(tree, '@angular/core') ?? '');
|
|
52
|
+
return angularGeneratorVersions(major !== undefined && exports.GENERATOR_ANGULAR_MAJORS.includes(major) ? major : exports.ANGULAR_MAJOR);
|
|
53
|
+
}
|
|
54
|
+
exports.workspaceGeneratorVersions = workspaceGeneratorVersions;
|
|
9
55
|
/** Full runtime set for a workspace that has no Angular yet. */
|
|
10
56
|
const RUNTIME_ALL = [
|
|
11
57
|
'@angular/animations',
|
|
@@ -17,7 +63,7 @@ const RUNTIME_ALL = [
|
|
|
17
63
|
'@angular/platform-browser-dynamic',
|
|
18
64
|
'@angular/router',
|
|
19
65
|
];
|
|
20
|
-
/** Runtime packages the generated app code imports (filled in for an existing Angular
|
|
66
|
+
/** Runtime packages the generated app code imports (filled in for an existing Angular workspace). */
|
|
21
67
|
const RUNTIME_IMPORTED = [
|
|
22
68
|
'@angular/common',
|
|
23
69
|
'@angular/compiler',
|
|
@@ -25,67 +71,70 @@ const RUNTIME_IMPORTED = [
|
|
|
25
71
|
'@angular/platform-browser-dynamic',
|
|
26
72
|
'@angular/router',
|
|
27
73
|
];
|
|
28
|
-
|
|
29
|
-
rxjs: '~7.8.0',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
function buildAndLintPackages(angular, nx) {
|
|
74
|
+
function runtimeSupport(v) {
|
|
75
|
+
return { rxjs: '~7.8.0', tslib: '^2.3.0', 'zone.js': v.zoneJs };
|
|
76
|
+
}
|
|
77
|
+
function buildAndLintPackages(angular, nx, v) {
|
|
34
78
|
return {
|
|
35
79
|
'@angular-devkit/build-angular': angular,
|
|
36
80
|
'@angular/cli': angular,
|
|
37
81
|
'@angular/compiler-cli': angular,
|
|
38
82
|
'@nx/angular': nx,
|
|
39
83
|
'@nx/eslint': nx,
|
|
40
|
-
|
|
41
|
-
'@angular-eslint/eslint-plugin':
|
|
42
|
-
'@angular-eslint/
|
|
43
|
-
'@angular-eslint/template-parser': exports.ANGULAR_VERSION,
|
|
84
|
+
'@angular-eslint/eslint-plugin': v.angularEslint,
|
|
85
|
+
'@angular-eslint/eslint-plugin-template': v.angularEslint,
|
|
86
|
+
'@angular-eslint/template-parser': v.angularEslint,
|
|
44
87
|
};
|
|
45
88
|
}
|
|
46
89
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
90
|
+
* TypeScript and @types/node at the versions the major's compiler accepts. Without them npm can
|
|
91
|
+
* hoist a newer TypeScript (Angular 15 refuses 5.x, Angular 16 refuses 5.2+) or a latest
|
|
92
|
+
* @types/node whose syntax that TypeScript can't parse (TS1139).
|
|
50
93
|
* Only added when missing; a declared version is never replaced.
|
|
51
94
|
*/
|
|
52
|
-
|
|
53
|
-
typescript: '
|
|
54
|
-
|
|
55
|
-
};
|
|
95
|
+
function typeScriptPackages(v) {
|
|
96
|
+
return { typescript: v.typescript, '@types/node': v.typesNode };
|
|
97
|
+
}
|
|
56
98
|
/**
|
|
57
|
-
* Makes sure
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
99
|
+
* Makes sure a generated Angular app or library can build and lint. Packages are only added,
|
|
100
|
+
* never upgraded:
|
|
101
|
+
* - no @angular/core → the whole set for `major` (default 15): runtime, build, lint, TypeScript
|
|
102
|
+
* and @types/node;
|
|
103
|
+
* - a generator major installed (15, 16) → missing build/lint packages at the installed Angular
|
|
104
|
+
* version (plus the imported runtime packages when `includeRuntime`);
|
|
62
105
|
* - another Angular major → nothing; warns which build/lint packages are missing.
|
|
63
106
|
*/
|
|
64
107
|
function ensureAngularDependencies(tree, opts = {}) {
|
|
65
108
|
const nx = (0, dependencies_1.nxVersion)(tree);
|
|
66
109
|
const core = (0, dependencies_1.declaredVersion)(tree, '@angular/core');
|
|
67
110
|
if (core === undefined) {
|
|
111
|
+
const v = angularGeneratorVersions(opts.major ?? exports.ANGULAR_MAJOR);
|
|
68
112
|
const deps = {
|
|
69
|
-
...Object.fromEntries(RUNTIME_ALL.map((d) => [d,
|
|
70
|
-
...
|
|
113
|
+
...Object.fromEntries(RUNTIME_ALL.map((d) => [d, v.angular])),
|
|
114
|
+
...runtimeSupport(v),
|
|
71
115
|
};
|
|
72
|
-
const devDeps = { ...buildAndLintPackages(
|
|
116
|
+
const devDeps = { ...buildAndLintPackages(v.angular, nx, v), ...typeScriptPackages(v) };
|
|
73
117
|
return (0, dependencies_1.addMissingDependencies)(tree, deps, devDeps);
|
|
74
118
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
119
|
+
const major = (0, dependencies_1.majorOf)(core);
|
|
120
|
+
if (major === undefined || !exports.GENERATOR_ANGULAR_MAJORS.includes(major)) {
|
|
121
|
+
const devDeps = buildAndLintPackages(core, nx, angularGeneratorVersions(exports.ANGULAR_MAJOR));
|
|
77
122
|
const missing = Object.keys(devDeps).filter((name) => (0, dependencies_1.declaredVersion)(tree, name) === undefined);
|
|
78
123
|
if (missing.length > 0) {
|
|
79
|
-
devkit_1.logger.warn(`nx-polystack: workspace uses Angular ${
|
|
80
|
-
|
|
81
|
-
`your Angular for: ${missing.join(', ')}.`);
|
|
124
|
+
devkit_1.logger.warn(`nx-polystack: workspace uses Angular ${major ?? core}; the generators support Angular ` +
|
|
125
|
+
`${exports.GENERATOR_ANGULAR_MAJORS.join(', ')}. Not adding packages automatically — install ` +
|
|
126
|
+
`versions matching your Angular for: ${missing.join(', ')}.`);
|
|
82
127
|
}
|
|
83
128
|
return undefined;
|
|
84
129
|
}
|
|
130
|
+
const v = angularGeneratorVersions(major);
|
|
85
131
|
const deps = opts.includeRuntime
|
|
86
|
-
? { ...Object.fromEntries(RUNTIME_IMPORTED.map((d) => [d, core])), ...
|
|
132
|
+
? { ...Object.fromEntries(RUNTIME_IMPORTED.map((d) => [d, core])), ...runtimeSupport(v) }
|
|
87
133
|
: {};
|
|
88
|
-
return (0, dependencies_1.addMissingDependencies)(tree, deps, {
|
|
134
|
+
return (0, dependencies_1.addMissingDependencies)(tree, deps, {
|
|
135
|
+
...buildAndLintPackages(core, nx, v),
|
|
136
|
+
...typeScriptPackages(v),
|
|
137
|
+
});
|
|
89
138
|
}
|
|
90
139
|
exports.ensureAngularDependencies = ensureAngularDependencies;
|
|
91
140
|
/**
|
|
@@ -97,7 +146,7 @@ function ngPackagrDependencies(angularCore) {
|
|
|
97
146
|
const major = angularCore ? (0, dependencies_1.majorOf)(angularCore) : undefined;
|
|
98
147
|
return {
|
|
99
148
|
// ng-packagr releases don't follow Angular patch numbers, so pin the major only.
|
|
100
|
-
'ng-packagr': `^${major ?? ANGULAR_MAJOR}.0.0`,
|
|
149
|
+
'ng-packagr': `^${major ?? exports.ANGULAR_MAJOR}.0.0`,
|
|
101
150
|
postcss: '^8.4.5',
|
|
102
151
|
'postcss-preset-env': '~7.5.0',
|
|
103
152
|
'postcss-url': '~10.1.3',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-deps.js","sourceRoot":"","sources":["../../../../src/lib/utils/angular-deps.ts"],"names":[],"mappings":";;;AAAA,uCAA6D;AAE7D,iDAA6F;AAE7F,
|
|
1
|
+
{"version":3,"file":"angular-deps.js","sourceRoot":"","sources":["../../../../src/lib/utils/angular-deps.ts"],"names":[],"mappings":";;;AAAA,uCAA6D;AAE7D,0CAAyD;AAEzD,iDAA6F;AAE7F,sGAAsG;AACzF,QAAA,eAAe,GAAG,SAAS,CAAC;AAC5B,QAAA,aAAa,GAAG,EAAE,CAAC;AAEhC;;;GAGG;AACU,QAAA,w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|
|
3
|
+
* Env files live in the root `environments/` folder, which is not part of any Nx project. From
|
|
4
|
+
* Nx 18 on, `@nx/enforce-module-boundaries` refuses relative imports of files outside a project
|
|
5
|
+
* ("External resources cannot be imported using a relative or absolute path"), so apps import
|
|
6
|
+
* them through this tsconfig path alias instead: `@env/<app>/environment`.
|
|
7
|
+
* Angular resolves the alias to the same file, so `fileReplacements` and the release build's env
|
|
8
|
+
* encryption keep working unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ENV_ALIAS = "@env/*";
|
|
11
|
+
export declare const ENV_ALIAS_TARGET = "environments/*";
|
|
12
|
+
export declare const ENV_DIR = "environments";
|
|
13
|
+
export type EnvAliasState = 'added' | 'present' | 'conflict' | 'no-tsconfig';
|
|
14
|
+
/** Whether `@env/*` maps to `environments/*` (without changing anything). */
|
|
15
|
+
export declare function hasEnvAlias(tree: Tree): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Adds `"@env/*": ["environments/*"]` to tsconfig.base.json (or tsconfig.json). An `@env/*`
|
|
18
|
+
* mapped elsewhere is left alone and reported as a conflict.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ensureEnvAlias(tree: Tree): EnvAliasState;
|
|
21
|
+
/** The import specifier for a file under environments/ (path without extension). */
|
|
22
|
+
export declare function envAliasImport(underEnvironments: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites the imports in `file` that point into environments/ (relative, or baseUrl-style
|
|
25
|
+
* `environments/…`) to the `@env/…` alias. Files inside environments/ keep their own imports.
|
|
26
|
+
* Returns the number of specifiers changed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function rewriteEnvImports(tree: Tree, file: string): number;
|
|
29
|
+
/** Every .ts file outside environments/, node_modules and build output. */
|
|
30
|
+
export declare function workspaceTsFiles(tree: Tree, dir?: string): string[];
|
|
31
|
+
export interface EnvAliasReport {
|
|
32
|
+
state: EnvAliasState | 'no-environments';
|
|
33
|
+
/** file → number of rewritten imports */
|
|
34
|
+
files: Record<string, number>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds the alias (when environments/ exists) and moves every import of an env file to it. With a
|
|
38
|
+
* conflicting `@env/*`, nothing is rewritten.
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyEnvAlias(tree: Tree): EnvAliasReport;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyEnvAlias = exports.workspaceTsFiles = exports.rewriteEnvImports = exports.envAliasImport = exports.ensureEnvAlias = exports.hasEnvAlias = exports.ENV_DIR = exports.ENV_ALIAS_TARGET = exports.ENV_ALIAS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
/**
|
|
8
|
+
* Env files live in the root `environments/` folder, which is not part of any Nx project. From
|
|
9
|
+
* Nx 18 on, `@nx/enforce-module-boundaries` refuses relative imports of files outside a project
|
|
10
|
+
* ("External resources cannot be imported using a relative or absolute path"), so apps import
|
|
11
|
+
* them through this tsconfig path alias instead: `@env/<app>/environment`.
|
|
12
|
+
* Angular resolves the alias to the same file, so `fileReplacements` and the release build's env
|
|
13
|
+
* encryption keep working unchanged.
|
|
14
|
+
*/
|
|
15
|
+
exports.ENV_ALIAS = '@env/*';
|
|
16
|
+
exports.ENV_ALIAS_TARGET = 'environments/*';
|
|
17
|
+
exports.ENV_DIR = 'environments';
|
|
18
|
+
function tsconfigFile(tree) {
|
|
19
|
+
if (tree.exists('tsconfig.base.json'))
|
|
20
|
+
return 'tsconfig.base.json';
|
|
21
|
+
if (tree.exists('tsconfig.json'))
|
|
22
|
+
return 'tsconfig.json';
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function readPaths(tree, file) {
|
|
26
|
+
try {
|
|
27
|
+
return (0, devkit_1.readJson)(tree, file)?.compilerOptions?.paths;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Whether `@env/*` maps to `environments/*` (without changing anything). */
|
|
34
|
+
function hasEnvAlias(tree) {
|
|
35
|
+
const file = tsconfigFile(tree);
|
|
36
|
+
const target = file ? readPaths(tree, file)?.[exports.ENV_ALIAS] : undefined;
|
|
37
|
+
return Array.isArray(target) && target.length === 1 && target[0] === exports.ENV_ALIAS_TARGET;
|
|
38
|
+
}
|
|
39
|
+
exports.hasEnvAlias = hasEnvAlias;
|
|
40
|
+
/**
|
|
41
|
+
* Adds `"@env/*": ["environments/*"]` to tsconfig.base.json (or tsconfig.json). An `@env/*`
|
|
42
|
+
* mapped elsewhere is left alone and reported as a conflict.
|
|
43
|
+
*/
|
|
44
|
+
function ensureEnvAlias(tree) {
|
|
45
|
+
const file = tsconfigFile(tree);
|
|
46
|
+
if (!file)
|
|
47
|
+
return 'no-tsconfig';
|
|
48
|
+
try {
|
|
49
|
+
(0, devkit_1.readJson)(tree, file);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return 'no-tsconfig';
|
|
53
|
+
}
|
|
54
|
+
if (readPaths(tree, file)?.[exports.ENV_ALIAS])
|
|
55
|
+
return hasEnvAlias(tree) ? 'present' : 'conflict';
|
|
56
|
+
(0, devkit_1.updateJson)(tree, file, (json) => {
|
|
57
|
+
const opts = (json['compilerOptions'] ?? {});
|
|
58
|
+
opts['paths'] = { ...(opts['paths'] ?? {}), [exports.ENV_ALIAS]: [exports.ENV_ALIAS_TARGET] };
|
|
59
|
+
json['compilerOptions'] = opts;
|
|
60
|
+
return json;
|
|
61
|
+
});
|
|
62
|
+
return 'added';
|
|
63
|
+
}
|
|
64
|
+
exports.ensureEnvAlias = ensureEnvAlias;
|
|
65
|
+
/** The import specifier for a file under environments/ (path without extension). */
|
|
66
|
+
function envAliasImport(underEnvironments) {
|
|
67
|
+
return `@env/${underEnvironments.replace(/^environments\//, '').replace(/\.ts$/, '')}`;
|
|
68
|
+
}
|
|
69
|
+
exports.envAliasImport = envAliasImport;
|
|
70
|
+
/** Import specifiers in TS source: `from '…'`, `import '…'`, `import('…')`, `require('…')`. */
|
|
71
|
+
const SPECIFIER = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)(['"])([^'"\n]+)\2/g;
|
|
72
|
+
/**
|
|
73
|
+
* Rewrites the imports in `file` that point into environments/ (relative, or baseUrl-style
|
|
74
|
+
* `environments/…`) to the `@env/…` alias. Files inside environments/ keep their own imports.
|
|
75
|
+
* Returns the number of specifiers changed.
|
|
76
|
+
*/
|
|
77
|
+
function rewriteEnvImports(tree, file) {
|
|
78
|
+
if (file === exports.ENV_DIR || file.startsWith(`${exports.ENV_DIR}/`))
|
|
79
|
+
return 0;
|
|
80
|
+
const text = tree.read(file, 'utf8');
|
|
81
|
+
if (text === null || !text.includes(exports.ENV_DIR))
|
|
82
|
+
return 0;
|
|
83
|
+
const dir = path.posix.dirname(file);
|
|
84
|
+
let count = 0;
|
|
85
|
+
const out = text.replace(SPECIFIER, (whole, lead, q, spec) => {
|
|
86
|
+
let target;
|
|
87
|
+
if (spec.startsWith('.'))
|
|
88
|
+
target = path.posix.normalize(path.posix.join(dir, spec));
|
|
89
|
+
else if (spec.startsWith(`${exports.ENV_DIR}/`))
|
|
90
|
+
target = spec;
|
|
91
|
+
if (!target || !target.startsWith(`${exports.ENV_DIR}/`) || target === exports.ENV_DIR)
|
|
92
|
+
return whole;
|
|
93
|
+
count++;
|
|
94
|
+
return `${lead}${q}${envAliasImport(target)}${q}`;
|
|
95
|
+
});
|
|
96
|
+
if (count > 0)
|
|
97
|
+
tree.write(file, out);
|
|
98
|
+
return count;
|
|
99
|
+
}
|
|
100
|
+
exports.rewriteEnvImports = rewriteEnvImports;
|
|
101
|
+
const SKIP_DIRS = new Set([
|
|
102
|
+
'node_modules',
|
|
103
|
+
'dist',
|
|
104
|
+
'tmp',
|
|
105
|
+
'coverage',
|
|
106
|
+
'.git',
|
|
107
|
+
'.nx',
|
|
108
|
+
'.angular',
|
|
109
|
+
exports.ENV_DIR,
|
|
110
|
+
]);
|
|
111
|
+
/** Every .ts file outside environments/, node_modules and build output. */
|
|
112
|
+
function workspaceTsFiles(tree, dir = '') {
|
|
113
|
+
const out = [];
|
|
114
|
+
for (const name of tree.children(dir)) {
|
|
115
|
+
const p = dir ? `${dir}/${name}` : name;
|
|
116
|
+
if (tree.isFile(p)) {
|
|
117
|
+
if (/\.(m|c)?ts$/.test(name) && !name.endsWith('.d.ts'))
|
|
118
|
+
out.push(p);
|
|
119
|
+
}
|
|
120
|
+
else if (!SKIP_DIRS.has(name) && !(dir === '' && name.startsWith('.'))) {
|
|
121
|
+
out.push(...workspaceTsFiles(tree, p));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
exports.workspaceTsFiles = workspaceTsFiles;
|
|
127
|
+
/**
|
|
128
|
+
* Adds the alias (when environments/ exists) and moves every import of an env file to it. With a
|
|
129
|
+
* conflicting `@env/*`, nothing is rewritten.
|
|
130
|
+
*/
|
|
131
|
+
function applyEnvAlias(tree) {
|
|
132
|
+
if (!tree.exists(exports.ENV_DIR) || tree.isFile(exports.ENV_DIR))
|
|
133
|
+
return { state: 'no-environments', files: {} };
|
|
134
|
+
const state = ensureEnvAlias(tree);
|
|
135
|
+
const files = {};
|
|
136
|
+
if (state === 'conflict' || state === 'no-tsconfig')
|
|
137
|
+
return { state, files };
|
|
138
|
+
for (const f of workspaceTsFiles(tree)) {
|
|
139
|
+
const n = rewriteEnvImports(tree, f);
|
|
140
|
+
if (n > 0)
|
|
141
|
+
files[f] = n;
|
|
142
|
+
}
|
|
143
|
+
return { state, files };
|
|
144
|
+
}
|
|
145
|
+
exports.applyEnvAlias = applyEnvAlias;
|
|
146
|
+
//# sourceMappingURL=env-alias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AAE,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC;YAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KACzB;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC;AAVD,sCAUC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileChange, Tree } from '@nx/devkit';
|
|
2
|
+
/** A Tree over the files under `root` (changes stay in memory until flushChanges). */
|
|
3
|
+
export declare function fsTree(root: string, verbose?: boolean): Tree;
|
|
4
|
+
export declare function flushChanges(root: string, changes: FileChange[]): void;
|
|
5
|
+
export declare function printChanges(changes: FileChange[]): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printChanges = exports.flushChanges = exports.fsTree = void 0;
|
|
4
|
+
let cached;
|
|
5
|
+
function nxTree() {
|
|
6
|
+
if (cached)
|
|
7
|
+
return cached;
|
|
8
|
+
let mod;
|
|
9
|
+
try {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
+
mod = require('nx/src/generators/tree');
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
throw new Error(`nx-polystack: could not load nx/src/generators/tree from the workspace's nx ` +
|
|
15
|
+
`(${err.message}). nx-polystack supports Nx 17 to 22.`);
|
|
16
|
+
}
|
|
17
|
+
if (typeof mod.FsTree !== 'function' ||
|
|
18
|
+
typeof mod.flushChanges !== 'function' ||
|
|
19
|
+
typeof mod.printChanges !== 'function') {
|
|
20
|
+
throw new Error('nx-polystack: this nx version has no FsTree/flushChanges/printChanges in ' +
|
|
21
|
+
'nx/src/generators/tree. nx-polystack supports Nx 17 to 22.');
|
|
22
|
+
}
|
|
23
|
+
cached = mod;
|
|
24
|
+
return cached;
|
|
25
|
+
}
|
|
26
|
+
/** A Tree over the files under `root` (changes stay in memory until flushChanges). */
|
|
27
|
+
function fsTree(root, verbose = false) {
|
|
28
|
+
return new (nxTree().FsTree)(root, verbose);
|
|
29
|
+
}
|
|
30
|
+
exports.fsTree = fsTree;
|
|
31
|
+
function flushChanges(root, changes) {
|
|
32
|
+
nxTree().flushChanges(root, changes);
|
|
33
|
+
}
|
|
34
|
+
exports.flushChanges = flushChanges;
|
|
35
|
+
function printChanges(changes) {
|
|
36
|
+
nxTree().printChanges(changes);
|
|
37
|
+
}
|
|
38
|
+
exports.printChanges = printChanges;
|
|
39
|
+
//# sourceMappingURL=nx-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-tree.js","sourceRoot":"","sources":["../../../../src/lib/utils/nx-tree.ts"],"names":[],"mappings":";;;AAcA,IAAI,MAAgC,CAAC;AAErC,SAAS,MAAM;IACb,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,GAA0B,CAAC;IAC/B,IAAI;QACF,8DAA8D;QAC9D,GAAG,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;KACzC;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,8EAA8E;YAC5E,IAAK,GAAa,CAAC,OAAO,uCAAuC,CACpE,CAAC;KACH;IACD,IACE,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU;QACtC,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU,EACtC;QACA,MAAM,IAAI,KAAK,CACb,2EAA2E;YACzE,4DAA4D,CAC/D,CAAC;KACH;IACD,MAAM,GAAG,GAAmB,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,sFAAsF;AACtF,SAAgB,MAAM,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK;IAClD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,wBAEC;AAED,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAqB;IAC9D,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,OAAqB;IAChD,MAAM,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* v1.2.7: env files are imported through the `@env/*` alias instead of a relative path into the
|
|
4
|
+
* root environments/ folder, which `@nx/enforce-module-boundaries` refuses from Nx 18 on.
|
|
5
|
+
* Adds the alias to tsconfig.base.json and rewrites the imports; the files stay where they are.
|
|
6
|
+
*/
|
|
7
|
+
export default function envImportAlias(tree: Tree): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const env_alias_1 = require("../../lib/utils/env-alias");
|
|
5
|
+
/**
|
|
6
|
+
* v1.2.7: env files are imported through the `@env/*` alias instead of a relative path into the
|
|
7
|
+
* root environments/ folder, which `@nx/enforce-module-boundaries` refuses from Nx 18 on.
|
|
8
|
+
* Adds the alias to tsconfig.base.json and rewrites the imports; the files stay where they are.
|
|
9
|
+
*/
|
|
10
|
+
function envImportAlias(tree) {
|
|
11
|
+
const report = (0, env_alias_1.applyEnvAlias)(tree);
|
|
12
|
+
if (report.state === 'no-environments')
|
|
13
|
+
return;
|
|
14
|
+
if (report.state === 'conflict') {
|
|
15
|
+
devkit_1.logger.warn(`env-import-alias: tsconfig maps "${env_alias_1.ENV_ALIAS}" to something other than ` +
|
|
16
|
+
`"${env_alias_1.ENV_ALIAS_TARGET}"; env imports were left relative. They fail ` +
|
|
17
|
+
'@nx/enforce-module-boundaries from Nx 18 on.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (report.state === 'no-tsconfig') {
|
|
21
|
+
devkit_1.logger.warn('env-import-alias: no readable tsconfig.base.json; env imports were left relative.');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const files = Object.keys(report.files);
|
|
25
|
+
if (report.state === 'added')
|
|
26
|
+
devkit_1.logger.info(`env-import-alias: added "${env_alias_1.ENV_ALIAS}" to tsconfig.`);
|
|
27
|
+
if (files.length > 0) {
|
|
28
|
+
devkit_1.logger.info(`env-import-alias: env imports now use @env/ in ${files.join(', ')}.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = envImportAlias;
|
|
32
|
+
//# sourceMappingURL=env-import-alias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-import-alias.js","sourceRoot":"","sources":["../../../../src/migrations/env-import-alias/env-import-alias.ts"],"names":[],"mappings":";;AAAA,uCAA0C;AAE1C,yDAAuF;AAEvF;;;;GAIG;AACH,SAAwB,cAAc,CAAC,IAAU;IAC/C,MAAM,MAAM,GAAG,IAAA,yBAAa,EAAC,IAAI,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,KAAK,iBAAiB;QAAE,OAAO;IAC/C,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE;QAC/B,eAAM,CAAC,IAAI,CACT,oCAAoC,qBAAS,4BAA4B;YACvE,IAAI,4BAAgB,+CAA+C;YACnE,8CAA8C,CACjD,CAAC;QACF,OAAO;KACR;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,aAAa,EAAE;QAClC,eAAM,CAAC,IAAI,CACT,mFAAmF,CACpF,CAAC;QACF,OAAO;KACR;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO;QAAE,eAAM,CAAC,IAAI,CAAC,4BAA4B,qBAAS,gBAAgB,CAAC,CAAC;IACjG,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,eAAM,CAAC,IAAI,CAAC,kDAAkD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACpF;AACH,CAAC;AAtBD,iCAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mouryaamit/nx-polystack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Nx plugin and pstack CLI that scaffold and build multi-tech monorepos (Angular, Ionic, Flutter) with a hardened release pipeline.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"npm": ">=7.0.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@nx/devkit": "
|
|
67
|
+
"@nx/devkit": ">=17.0.0 <23.0.0",
|
|
68
68
|
"crypto-js": "^4.2.0",
|
|
69
|
-
"nx": "
|
|
69
|
+
"nx": ">=17.0.0 <23.0.0",
|
|
70
70
|
"sharp": "^0.33.0 || ^0.34.0 || ^0.35.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependenciesMeta": {
|