@mouryaamit/nx-polystack 1.7.0 → 1.7.2

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.
Files changed (32) hide show
  1. package/README.md +3 -1
  2. package/dist/bin/cli.js +5 -0
  3. package/dist/bin/cli.js.map +1 -1
  4. package/dist/generators.json +5 -0
  5. package/dist/src/cli/commands/adopt.d.ts +3 -0
  6. package/dist/src/cli/commands/adopt.js +55 -0
  7. package/dist/src/cli/commands/adopt.js.map +1 -0
  8. package/dist/src/cli/commands/index.js +1 -0
  9. package/dist/src/cli/commands/index.js.map +1 -1
  10. package/dist/src/cli/commands/update.js +11 -0
  11. package/dist/src/cli/commands/update.js.map +1 -1
  12. package/dist/src/cli/help.js +9 -0
  13. package/dist/src/cli/help.js.map +1 -1
  14. package/dist/src/cli/launcher.d.ts +12 -0
  15. package/dist/src/cli/launcher.js +54 -1
  16. package/dist/src/cli/launcher.js.map +1 -1
  17. package/dist/src/generators/adopt/generator.d.ts +33 -0
  18. package/dist/src/generators/adopt/generator.js +324 -0
  19. package/dist/src/generators/adopt/generator.js.map +1 -0
  20. package/dist/src/generators/adopt/pipeline.d.ts +31 -0
  21. package/dist/src/generators/adopt/pipeline.js +133 -0
  22. package/dist/src/generators/adopt/pipeline.js.map +1 -0
  23. package/dist/src/generators/adopt/schema.json +21 -0
  24. package/dist/src/generators/migrate/adapters/nx-workspace.js +1 -47
  25. package/dist/src/generators/migrate/adapters/nx-workspace.js.map +1 -1
  26. package/dist/src/generators/migrate/nx/build-scripts.d.ts +8 -0
  27. package/dist/src/generators/migrate/nx/build-scripts.js +50 -1
  28. package/dist/src/generators/migrate/nx/build-scripts.js.map +1 -1
  29. package/dist/src/lib/utils/json-layout.d.ts +37 -0
  30. package/dist/src/lib/utils/json-layout.js +247 -0
  31. package/dist/src/lib/utils/json-layout.js.map +1 -0
  32. package/package.json +1 -1
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setScriptsInPlace = exports.adoptCandidates = exports.ADOPT_REPORT = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const config_1 = require("../../lib/env-encryption/config");
6
+ const workspace_1 = require("../../lib/env-encryption/workspace");
7
+ const htaccess_adopt_1 = require("../../lib/release/htaccess-adopt");
8
+ const angular_project_1 = require("../../lib/utils/angular-project");
9
+ const project_json_files_1 = require("../../lib/utils/project-json-files");
10
+ const angular_project_json_1 = require("../migrate/angular-project-json");
11
+ const build_scripts_1 = require("../migrate/nx/build-scripts");
12
+ const env_encryption_1 = require("../migrate/nx/env-encryption");
13
+ const pipeline_1 = require("./pipeline");
14
+ const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
15
+ const code = (s) => `\`${s}\``;
16
+ /** Angular builders whose apps the release executor builds (it runs them through buildTarget). */
17
+ const ANGULAR_APP_BUILDERS = /^(@angular-devkit\/build-angular:(browser|browser-esbuild|application)|@angular\/build:application|@nx\/angular:(webpack-browser|browser-esbuild|application))$/;
18
+ exports.ADOPT_REPORT = 'docs/migrations/adopt.md';
19
+ /** Angular apps of the workspace that build without the plugin: build target, no release target. */
20
+ function adoptCandidates(tree) {
21
+ const out = [];
22
+ for (const { name, root, json } of (0, project_json_files_1.readProjects)(tree)) {
23
+ const targets = isObject(json['targets']) ? json['targets'] : {};
24
+ const build = targets['build'];
25
+ if (!isObject(build) || !ANGULAR_APP_BUILDERS.test(String(build['executor'] ?? '')))
26
+ continue;
27
+ if (json['projectType'] === 'library')
28
+ continue;
29
+ if (Object.values(targets).some((t) => isObject(t) && t['executor'] === angular_project_1.POLYSTACK_BUILD_EXECUTOR))
30
+ continue;
31
+ out.push({
32
+ name,
33
+ root,
34
+ reason: targets['release'] !== undefined ? 'has its own "release" target' : undefined,
35
+ });
36
+ }
37
+ return out.sort((a, b) => a.name.localeCompare(b.name));
38
+ }
39
+ exports.adoptCandidates = adoptCandidates;
40
+ /** The build stamp time zone the workspace's own script used (e.g. Asia/Kolkata). */
41
+ function setStampTimezone(tree, timezone, notes) {
42
+ const cfg = (0, config_1.normalizeEnvEncryption)((0, workspace_1.readEnvEncryptionBlock)(tree));
43
+ (0, workspace_1.writeEnvEncryptionBlock)(tree, {
44
+ ...cfg,
45
+ stamp: { ...config_1.DEFAULT_STAMP, ...(cfg.stamp ?? {}), timezone },
46
+ });
47
+ notes.push(`Env encryption: build stamp time zone ${code(timezone)}, as the build script wrote it.`);
48
+ }
49
+ /** Index of the brace that closes the one at `open` (strings skipped), or -1. */
50
+ function closingBrace(text, open) {
51
+ let depth = 0;
52
+ for (let i = open; i < text.length; i++) {
53
+ const c = text[i];
54
+ if (c === '"') {
55
+ for (i++; i < text.length && text[i] !== '"'; i++)
56
+ if (text[i] === '\\')
57
+ i++;
58
+ }
59
+ else if (c === '{' || c === '[')
60
+ depth++;
61
+ else if ((c === '}' || c === ']') && --depth === 0)
62
+ return i;
63
+ }
64
+ return -1;
65
+ }
66
+ /**
67
+ * Rewrites a project.json that adopt changed as a small edit of its original text (the .htaccess
68
+ * asset removed, the release target added at the end of targets) so the rest keeps its layout.
69
+ * Leaves the plain JSON write when the edit does not give the same JSON.
70
+ */
71
+ function keepFormatting(tree, file, original) {
72
+ const wanted = tree.read(file, 'utf8') ?? '';
73
+ let target;
74
+ try {
75
+ target = JSON.parse(wanted);
76
+ }
77
+ catch {
78
+ return;
79
+ }
80
+ let text = original
81
+ .replace(/,\s*\{[^{}]*"glob"\s*:\s*"\.htaccess"[^{}]*\}/g, '')
82
+ .replace(/\{[^{}]*"glob"\s*:\s*"\.htaccess"[^{}]*\}\s*,?\s*/g, '')
83
+ .replace(/,\s*"[^"]*\/\.htaccess"/g, '')
84
+ .replace(/"[^"]*\/\.htaccess"\s*,?\s*/g, '');
85
+ const release = target['targets']?.['release'];
86
+ const targetsKey = /"targets"\s*:\s*\{/.exec(text);
87
+ if (release !== undefined && targetsKey) {
88
+ const open = targetsKey.index + targetsKey[0].length - 1;
89
+ const close = closingBrace(text, open);
90
+ if (close < 0)
91
+ return;
92
+ const keyIndent = /\n([ \t]+)"[^"]+"\s*:/.exec(text.slice(open, close))?.[1] ?? ' ';
93
+ const unit = keyIndent.length >= 4 ? keyIndent.slice(0, keyIndent.length / 2) : ' ';
94
+ const body = JSON.stringify(release, null, unit).replace(/\n/g, `\n${keyIndent}`);
95
+ const before = text.slice(0, close).replace(/\s*$/, '');
96
+ const closeIndent = keyIndent.slice(unit.length);
97
+ text = `${before},\n${keyIndent}"release": ${body}\n${closeIndent}${text.slice(close)}`;
98
+ }
99
+ try {
100
+ if (JSON.stringify(JSON.parse(text)) === JSON.stringify(target))
101
+ tree.write(file, text);
102
+ }
103
+ catch {
104
+ // Keep the plain JSON write.
105
+ }
106
+ }
107
+ /** Release target options and configurations that do what the workspace's own build script did. */
108
+ function applyPipeline(release, pipeline, notes) {
109
+ const options = release['options'];
110
+ if (pipeline.nonce) {
111
+ options['secure'] = true;
112
+ const n = pipeline.nonce;
113
+ const nonce = {};
114
+ if (n.placeholder)
115
+ nonce['placeholder'] = n.placeholder;
116
+ if (n.tags)
117
+ nonce['tags'] = n.tags;
118
+ if (n.position)
119
+ nonce['position'] = n.position;
120
+ if (n.replaceTokens.length > 0)
121
+ nonce['replaceTokens'] = n.replaceTokens;
122
+ if (!n.addMeta)
123
+ nonce['addMeta'] = false;
124
+ if (Object.keys(nonce).length > 0)
125
+ options['nonce'] = nonce;
126
+ }
127
+ if (pipeline.stripHtmlComments)
128
+ options['stripHtmlComments'] = true;
129
+ const configurations = isObject(release['configurations'])
130
+ ? release['configurations']
131
+ : {};
132
+ for (const config of Object.values(configurations)) {
133
+ const env = String(config['env'] ?? '').toUpperCase();
134
+ if (env !== 'UAT' && env !== 'PROD')
135
+ continue;
136
+ if (pipeline.obfuscate)
137
+ config['obfuscate'] = pipeline.obfuscate;
138
+ if (pipeline.obfuscateOptions)
139
+ config['obfuscateOptions'] = pipeline.obfuscateOptions;
140
+ if (!pipeline.stripComments)
141
+ delete config['stripComments'];
142
+ if (!pipeline.dropConsole)
143
+ delete config['dropConsole'];
144
+ }
145
+ void notes;
146
+ }
147
+ /**
148
+ * The npm scripts of an adopted app: build:<app>:<env> → nx run <app>:release:<env> when the
149
+ * script built through the workspace's own build script (or is missing), plus the secure ones.
150
+ */
151
+ function appScripts(name, releases, current, custom) {
152
+ const wanted = (0, angular_project_json_1.angularAppNpmScripts)(name, false, releases);
153
+ const out = {};
154
+ for (const [key, cmd] of Object.entries(wanted)) {
155
+ if (current[key] === cmd)
156
+ continue;
157
+ if (current[key] === undefined || custom[key] !== undefined)
158
+ out[key] = cmd;
159
+ }
160
+ return out;
161
+ }
162
+ /**
163
+ * Sets npm scripts in package.json without reformatting the rest of the file: existing scripts
164
+ * are changed in place, new ones go after the app's last build script (or at the end of scripts).
165
+ */
166
+ function setScriptsInPlace(tree, scripts) {
167
+ if (Object.keys(scripts).length === 0)
168
+ return;
169
+ const before = tree.read('package.json', 'utf8') ?? '';
170
+ let text = before;
171
+ const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
172
+ const added = [];
173
+ for (const [key, cmd] of Object.entries(scripts)) {
174
+ const re = new RegExp(`("${esc(key)}"\\s*:\\s*)"(?:\\\\.|[^"\\\\])*"`);
175
+ if (re.test(text))
176
+ text = text.replace(re, (_m, lead) => `${lead}${JSON.stringify(cmd)}`);
177
+ else
178
+ added.push([key, cmd]);
179
+ }
180
+ for (const [key, cmd] of added) {
181
+ const app = /^build:([^:]+):/.exec(key)?.[1];
182
+ const lines = text.split('\n');
183
+ const scriptsStart = lines.findIndex((l) => /^\s*"scripts"\s*:\s*\{/.test(l));
184
+ if (scriptsStart < 0)
185
+ break;
186
+ let scriptsEnd = scriptsStart + 1;
187
+ while (scriptsEnd < lines.length && !/^\s*\}/.test(lines[scriptsEnd]))
188
+ scriptsEnd++;
189
+ let anchor = -1;
190
+ for (let i = scriptsStart + 1; i < scriptsEnd; i++) {
191
+ if (app && new RegExp(`^\\s*"build:${esc(app)}:`).test(lines[i]))
192
+ anchor = i;
193
+ }
194
+ if (anchor < 0)
195
+ anchor = scriptsEnd - 1;
196
+ const indent = /^(\s*)/.exec(lines[anchor])?.[1] ?? ' ';
197
+ const isLast = !/,\s*$/.test(lines[anchor]);
198
+ if (isLast)
199
+ lines[anchor] = `${lines[anchor].replace(/\s*$/, '')},`;
200
+ lines.splice(anchor + 1, 0, `${indent}${JSON.stringify(key)}: ${JSON.stringify(cmd)}${isLast ? '' : ','}`);
201
+ text = lines.join('\n');
202
+ }
203
+ // Fall back to a plain JSON write when the text edit did not give the scripts asked for.
204
+ let ok = false;
205
+ try {
206
+ const parsed = JSON.parse(text);
207
+ ok = Object.entries(scripts).every(([k, v]) => parsed.scripts?.[k] === v);
208
+ }
209
+ catch {
210
+ ok = false;
211
+ }
212
+ if (ok) {
213
+ tree.write('package.json', text);
214
+ return;
215
+ }
216
+ (0, devkit_1.updateJson)(tree, 'package.json', (pkg) => {
217
+ pkg.scripts = { ...(pkg.scripts ?? {}), ...scripts };
218
+ return pkg;
219
+ });
220
+ }
221
+ exports.setScriptsInPlace = setScriptsInPlace;
222
+ function report(result, pipeline, customScripts) {
223
+ const lines = ['# pstack adopt', ''];
224
+ lines.push(`Apps moved to the polystack \`release\` target: ${result.adopted.length > 0 ? result.adopted.map(code).join(', ') : 'none'}.`, '');
225
+ if (result.skipped.length > 0) {
226
+ lines.push('## Not changed', '', ...result.skipped.map((s) => `- ${s}`), '');
227
+ }
228
+ if (customScripts.length > 0) {
229
+ lines.push('## The workspace build script', '', `Read: ${pipeline.scripts.map(code).join(', ')}. The release target was set to do the same:`, '', `- CSP nonce: ${pipeline.nonce
230
+ ? `on (\`secure\`), placeholder ${code(pipeline.nonce.placeholder ?? 'default')}, tags ${pipeline.nonce.tags ?? 'all'}, position ${pipeline.nonce.position ?? 'end'}${pipeline.nonce.replaceTokens.length > 0
231
+ ? `, replaces ${pipeline.nonce.replaceTokens.map(code).join(', ')}`
232
+ : ''}, ${pipeline.nonce.addMeta ? 'adds' : 'no'} csp-nonce meta`
233
+ : 'none found'}`, `- HTML comments stripped in every env: ${pipeline.stripHtmlComments ? 'yes' : 'no'}`, `- UAT/PROD comment stripping: ${pipeline.stripComments ? 'yes' : 'no'}; obfuscation: ${pipeline.obfuscate
234
+ ? `yes (${pipeline.obfuscate}${pipeline.obfuscateOptions
235
+ ? ` with ${code(JSON.stringify(pipeline.obfuscateOptions))}`
236
+ : ''})`
237
+ : 'no'}; console removal: ${pipeline.dropConsole ? 'yes' : 'no'}`, '', 'Check before switching CI: build one app both ways for each env and compare ' +
238
+ '`dist/apps/<app>` (index.html, the .htaccess, the encrypted env values in main.js). ' +
239
+ `The old scripts (${customScripts.map(code).join(', ')}) are left in place.`, '');
240
+ }
241
+ if (result.notes.length > 0)
242
+ lines.push('## Notes', '', ...result.notes.map((n) => `- ${n}`), '');
243
+ const scripts = Object.entries(result.scripts);
244
+ if (scripts.length > 0) {
245
+ lines.push('## npm scripts', '', ...scripts.map(([k, v]) => `- ${code(k)}: ${code(v)}`), '');
246
+ }
247
+ return lines.join('\n');
248
+ }
249
+ /**
250
+ * pstack adopt: moves the Angular apps of this workspace that still build with their own scripts
251
+ * to the plugin's release target, in place. Each app gets a release target (base hrefs, env folder
252
+ * and the post-build steps read from the workspace's build script), its .htaccess becomes
253
+ * environments/<app>/htaccess.<env>, the workspace's env encryption is mirrored in nx.json, and its
254
+ * build:<app>:<env> npm scripts call nx run <app>:release:<env>. Old scripts are not deleted.
255
+ */
256
+ async function adoptGenerator(tree, options = {}) {
257
+ const result = { adopted: [], skipped: [], notes: [], scripts: {} };
258
+ let candidates = adoptCandidates(tree);
259
+ if (options.projects && options.projects.length > 0) {
260
+ const wanted = new Set(options.projects);
261
+ const known = new Set(candidates.map((c) => c.name));
262
+ const unknown = options.projects.filter((p) => !known.has(p));
263
+ if (unknown.length > 0) {
264
+ throw new Error(`adopt: ${unknown.map((p) => `"${p}"`).join(', ')} ${unknown.length === 1 ? 'is not an Angular app' : 'are not Angular apps'} that builds without the plugin (candidates: ${[...known].join(', ') || 'none'})`);
265
+ }
266
+ candidates = candidates.filter((c) => wanted.has(c.name));
267
+ }
268
+ for (const c of candidates.filter((c) => c.reason)) {
269
+ result.skipped.push(`${code(c.name)}: ${c.reason}`);
270
+ }
271
+ candidates = candidates.filter((c) => !c.reason);
272
+ if (candidates.length === 0) {
273
+ devkit_1.logger.info('adopt: no Angular app builds without the plugin; nothing to do.');
274
+ return result;
275
+ }
276
+ const pkg = tree.exists('package.json')
277
+ ? (0, devkit_1.readJson)(tree, 'package.json')
278
+ : {};
279
+ const names = candidates.map((c) => c.name);
280
+ const buildScripts = (0, build_scripts_1.readBuildScripts)(tree.root, pkg.scripts, names);
281
+ const pipeline = (0, pipeline_1.readSourcePipeline)(tree.root, buildScripts.customScripts);
282
+ // Before any release target exists: the encryption settings apply to every release build.
283
+ const encryption = (0, env_encryption_1.applySourceEnvEncryption)(tree, tree.root, result.notes);
284
+ if (encryption?.applied && pipeline.timezone)
285
+ setStampTimezone(tree, pipeline.timezone, result.notes);
286
+ const scripts = {};
287
+ for (const { name, root } of candidates) {
288
+ const pjPath = `${root}/project.json`;
289
+ const pj = (0, devkit_1.readJson)(tree, pjPath);
290
+ const targets = pj['targets'];
291
+ const notes = [];
292
+ const releases = (0, angular_project_json_1.addReleaseTarget)(targets, name, (w) => notes.push(w), root);
293
+ if (releases.length === 0) {
294
+ result.skipped.push(`${code(name)}: ${notes.join('; ')}`);
295
+ continue;
296
+ }
297
+ (0, build_scripts_1.shapeReleaseTarget)(targets, name, buildScripts, notes);
298
+ applyPipeline(targets['release'], pipeline, notes);
299
+ const original = tree.read(pjPath, 'utf8') ?? '';
300
+ (0, devkit_1.writeJson)(tree, pjPath, pj);
301
+ (0, htaccess_adopt_1.htaccessNote)((0, htaccess_adopt_1.adoptHtaccess)(tree, pjPath), name, notes);
302
+ keepFormatting(tree, pjPath, original);
303
+ result.adopted.push(name);
304
+ result.notes.push(...notes.map((n) => `${code(name)}: ${n}`));
305
+ if (options.scripts !== false) {
306
+ Object.assign(scripts, appScripts(name, releases, pkg.scripts ?? {}, buildScripts.customBuilds));
307
+ }
308
+ }
309
+ if (buildScripts.unread.length > 0) {
310
+ result.notes.push(`Base hrefs for ${buildScripts.unread.map(code).join(', ')} could not be read from the ` +
311
+ "build scripts; set `baseHref` on their release target's configurations.");
312
+ }
313
+ if (tree.exists('package.json'))
314
+ setScriptsInPlace(tree, scripts);
315
+ result.scripts = scripts;
316
+ tree.write(exports.ADOPT_REPORT, report(result, pipeline, buildScripts.customScripts));
317
+ devkit_1.logger.info(`adopt: ${result.adopted.length} app(s) now build with nx run <app>:release:<env> ` +
318
+ `(${result.adopted.join(', ')}). Report: ${exports.ADOPT_REPORT}`);
319
+ for (const s of result.skipped)
320
+ devkit_1.logger.warn(`adopt: not changed: ${s.replace(/`/g, '')}`);
321
+ return result;
322
+ }
323
+ exports.default = adoptGenerator;
324
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../src/generators/adopt/generator.ts"],"names":[],"mappings":";;;AAAA,uCAA2E;AAE3E,4DAAwF;AACxF,kEAG4C;AAC5C,qEAA+E;AAC/E,qEAA2E;AAC3E,2EAAkE;AAClE,0EAAyF;AACzF,+DAAmF;AACnF,iEAAwE;AAExE,yCAAgE;AAWhE,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAa,EAAE,CACzC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;AAEvC,kGAAkG;AAClG,MAAM,oBAAoB,GACxB,iKAAiK,CAAC;AAEvJ,QAAA,YAAY,GAAG,0BAA0B,CAAC;AASvD,oGAAoG;AACpG,SAAgB,eAAe,CAAC,IAAU;IACxC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,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1F,OAAO,MAAM,CAAC;AAChB,CAAC;AAlFD,iCAkFC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What a workspace's own build script (e.g. tools/scripts/build.js) does after `nx build`, read
3
+ * from it and the scripts it runs, so the release target can do the same.
4
+ */
5
+ export interface SourcePipeline {
6
+ /** The script files read (workspace-relative), sorted. */
7
+ scripts: string[];
8
+ /** CSP nonce written into index.html; undefined when no step writes one. */
9
+ nonce?: {
10
+ placeholder?: string;
11
+ tags?: 'all' | 'legacy';
12
+ position?: 'end' | 'after-tag-name';
13
+ replaceTokens: string[];
14
+ addMeta: boolean;
15
+ };
16
+ /** HTML comments removed from index.html in every env. */
17
+ stripHtmlComments: boolean;
18
+ /** Comments removed from the built JS/CSS (UAT/PROD). */
19
+ stripComments: boolean;
20
+ /** The app's JS obfuscated (UAT/PROD), as the release executor's `obfuscate` profile. */
21
+ obfuscate?: ObfuscateProfile;
22
+ /** javascript-obfuscator options the script sets that differ from that preset. */
23
+ obfuscateOptions?: Record<string, unknown>;
24
+ /** Console calls removed from the built JS. */
25
+ dropConsole: boolean;
26
+ /** IANA time zone the build stamp is written in (from a `timeZone: '…'` option). */
27
+ timezone?: string;
28
+ }
29
+ export type ObfuscateProfile = 'light' | 'medium' | 'strong';
30
+ /** Reads the custom build scripts and the step scripts they run. */
31
+ export declare function readSourcePipeline(root: string, buildScripts: string[]): SourcePipeline;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readSourcePipeline = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ /** What the release executor's presets set for the options read from a script (see hardening/obfuscate.ts). */
8
+ const PRESET_VALUES = {
9
+ light: {
10
+ stringArrayThreshold: 0.5,
11
+ identifierNamesGenerator: 'mangled',
12
+ stringArrayWrappersCount: 0,
13
+ },
14
+ medium: {
15
+ stringArrayThreshold: 0.75,
16
+ identifierNamesGenerator: 'hexadecimal',
17
+ stringArrayWrappersCount: 1,
18
+ },
19
+ };
20
+ /** `key: value` (number, quoted string or boolean) in a block of javascript-obfuscator options. */
21
+ function optionValue(block, key) {
22
+ const m = new RegExp(`\\b${key}\\s*:\\s*(?:(['"\`])([\\w-]+)\\1|([\\d.]+)|(true|false))`).exec(block);
23
+ if (!m)
24
+ return undefined;
25
+ if (m[2] !== undefined)
26
+ return m[2];
27
+ if (m[3] !== undefined)
28
+ return Number(m[3]);
29
+ return m[4] === 'true';
30
+ }
31
+ /**
32
+ * The preset and overrides matching an obfuscate script: its shared options plus the profile it
33
+ * runs by default (`process.env.X || 'light'` picking a `light: { … }` block). Hexadecimal names
34
+ * map to medium, anything else to light; the options that then differ become overrides.
35
+ */
36
+ function obfuscateSettings(text) {
37
+ const named = /\bprocess\.env\.\w*PROFILE\w*\s*(?:\|\||\?\?)\s*['"`](\w+)['"`]/.exec(text)?.[1];
38
+ if (named === 'medium' || named === 'strong')
39
+ return { obfuscate: named };
40
+ const profileBlock = named
41
+ ? new RegExp(`\\b${named}\\s*:\\s*\\{([^}]*)\\}`).exec(text)?.[1] ?? ''
42
+ : '';
43
+ const read = (key) => optionValue(profileBlock, key) ?? optionValue(text, key);
44
+ const names = read('identifierNamesGenerator');
45
+ const preset = names === 'hexadecimal' ? 'medium' : 'light';
46
+ const overrides = {};
47
+ for (const [key, presetValue] of Object.entries(PRESET_VALUES[preset])) {
48
+ const value = read(key);
49
+ if (value !== undefined && value !== presetValue)
50
+ overrides[key] = value;
51
+ }
52
+ return Object.keys(overrides).length > 0
53
+ ? { obfuscate: preset, obfuscateOptions: overrides }
54
+ : { obfuscate: preset };
55
+ }
56
+ const read = (root, rel) => {
57
+ try {
58
+ return fs.readFileSync(path.join(root, ...rel.split('/')), 'utf8');
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ };
64
+ /** `node <dir>/<x>.js` calls in a script's text, as workspace-relative paths. */
65
+ function calledScripts(text) {
66
+ const out = new Set();
67
+ for (const m of text.matchAll(/\bnode\s+(['"]?)([\w./-]+\.(?:c|m)?js)\1/g)) {
68
+ out.add(path.posix.normalize(m[2].replace(/^\.\//, '')));
69
+ }
70
+ // `run(\`node tools/scripts/x.js …\`)` is the common form; plain requires are helpers, not steps.
71
+ return [...out].sort();
72
+ }
73
+ /** The nonce settings of a script that puts a nonce placeholder on index.html tags. */
74
+ function nonceOf(text) {
75
+ if (!/\bnonce\b/i.test(text) || !/<script/i.test(text))
76
+ return undefined;
77
+ const placeholder = /\bconst\s+NONCE\s*=\s*(['"`])((?:(?!\1).)*)\1/.exec(text)?.[2];
78
+ // Inline scripts only: the <script pattern skips tags with src.
79
+ const tags = /<script\(\?!\[\^>\]\*\\bsrc=\)/.test(text) ? 'legacy' : undefined;
80
+ const position = /`<(?:script|link|style) nonce=/.test(text) ? 'after-tag-name' : undefined;
81
+ const replaceTokens = [
82
+ ...new Set([...text.matchAll(/\.replace\(\/([A-Za-z0-9_-]{4,})\/g,\s*NONCE\)/g)].map((m) => m[1])),
83
+ ].sort();
84
+ const addMeta = /property=\\?["']csp-nonce/.test(text);
85
+ return { placeholder, tags, position, replaceTokens, addMeta };
86
+ }
87
+ /** Reads the custom build scripts and the step scripts they run. */
88
+ function readSourcePipeline(root, buildScripts) {
89
+ const pipeline = {
90
+ scripts: [],
91
+ stripHtmlComments: false,
92
+ stripComments: false,
93
+ dropConsole: false,
94
+ };
95
+ const seen = new Set();
96
+ const visit = (rel) => {
97
+ if (seen.has(rel))
98
+ return;
99
+ seen.add(rel);
100
+ const text = read(root, rel);
101
+ if (text === undefined)
102
+ return;
103
+ pipeline.scripts.push(rel);
104
+ const name = path.posix.basename(rel);
105
+ const nonce = nonceOf(text);
106
+ if (nonce && !pipeline.nonce)
107
+ pipeline.nonce = nonce;
108
+ if (nonce && /<!--\(\?!#\)/.test(text))
109
+ pipeline.stripHtmlComments = true;
110
+ if (/obfuscat/i.test(name) && !pipeline.obfuscate)
111
+ Object.assign(pipeline, obfuscateSettings(text));
112
+ if (/strip-?comments/i.test(name))
113
+ pipeline.stripComments = true;
114
+ if (/drop_console|pure_funcs|dropConsole/.test(text))
115
+ pipeline.dropConsole = true;
116
+ const tz = /\btimeZone\s*:\s*['"`]([A-Za-z_]+\/[A-Za-z_+-]+)['"`]/.exec(text)?.[1];
117
+ if (tz && !pipeline.timezone)
118
+ pipeline.timezone = tz;
119
+ for (const called of calledScripts(text))
120
+ visit(called);
121
+ // Local helpers it requires (build-info, timestamp, …): read for the stamp time zone.
122
+ for (const m of text.matchAll(/\brequire\(\s*['"](\.{1,2}\/[\w./-]+)['"]\s*\)/g)) {
123
+ const dep = path.posix.normalize(path.posix.join(path.posix.dirname(rel), m[1]));
124
+ visit(/\.(c|m)?js$/.test(dep) ? dep : `${dep}.js`);
125
+ }
126
+ };
127
+ for (const s of buildScripts)
128
+ visit(s);
129
+ pipeline.scripts.sort();
130
+ return pipeline;
131
+ }
132
+ exports.readSourcePipeline = readSourcePipeline;
133
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../../src/generators/adopt/pipeline.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAiC7B,+GAA+G;AAC/G,MAAM,aAAa,GAAwD;IACzE,KAAK,EAAE;QACL,oBAAoB,EAAE,GAAG;QACzB,wBAAwB,EAAE,SAAS;QACnC,wBAAwB,EAAE,CAAC;KAC5B;IACD,MAAM,EAAE;QACN,oBAAoB,EAAE,IAAI;QAC1B,wBAAwB,EAAE,aAAa;QACvC,wBAAwB,EAAE,CAAC;KAC5B;CACF,CAAC;AAEF,mGAAmG;AACnG,SAAS,WAAW,CAAC,KAAa,EAAE,GAAW;IAC7C,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,0DAA0D,CAAC,CAAC,IAAI,CAC5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AK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjF,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SACpD;IACH,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,YAAY;QAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAlCD,gDAkCC"}
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "id": "adopt",
5
+ "title": "Adopt Apps",
6
+ "description": "Move the Angular apps of this workspace that build without the plugin to its release target, in place: release target (base hrefs and post-build steps read from the workspace's own build script), environments/<app>/htaccess.<env>, env encryption settings, build:<app>:<env> npm scripts. Old scripts are kept.",
7
+ "type": "object",
8
+ "properties": {
9
+ "projects": {
10
+ "type": "array",
11
+ "items": { "type": "string" },
12
+ "description": "Apps to adopt (default: every Angular app without a release target)."
13
+ },
14
+ "scripts": {
15
+ "type": "boolean",
16
+ "description": "Point the apps' build:<app>:<env> npm scripts at nx run <app>:release:<env>.",
17
+ "default": true
18
+ }
19
+ },
20
+ "required": []
21
+ }
@@ -256,7 +256,7 @@ function migrateNxWorkspace(tree, ctx) {
256
256
  releaseAdded = releases.length > 0;
257
257
  // Only the release target this run added; a source's own release target stays as it was.
258
258
  if (releases.length > 0)
259
- shapeReleaseTarget(targets, p, buildScripts, notes);
259
+ (0, build_scripts_1.shapeReleaseTarget)(targets, p.source.name, buildScripts, notes);
260
260
  const main = mainOf(targets);
261
261
  if (main)
262
262
  mains.push(main);
@@ -842,52 +842,6 @@ const mainOf = (targets) => {
842
842
  const main = (0, workspace_source_1.objectField)(targets, 'build')['options']?.['main'];
843
843
  return typeof main === 'string' ? main : undefined;
844
844
  };
845
- /**
846
- * The release target of a migrated app: the env folder its fileReplacements use
847
- * (environments/<x>/…), and base hrefs from the source's build scripts.
848
- */
849
- function shapeReleaseTarget(targets, p, scripts, notes) {
850
- const release = targets['release'];
851
- if (!(0, workspace_source_1.isObject)(release) || !(0, workspace_source_1.isObject)(release['options']))
852
- return;
853
- const options = release['options'];
854
- const envProject = envFolderOf((0, workspace_source_1.objectField)(targets, 'build'));
855
- if (envProject && envProject !== options['envProject'])
856
- options['envProject'] = envProject;
857
- const hrefs = scripts.baseHrefs.get(p.source.name);
858
- if (!hrefs)
859
- return;
860
- const configurations = (0, workspace_source_1.isObject)(release['configurations'])
861
- ? release['configurations']
862
- : {};
863
- const applied = [];
864
- for (const [name, config] of Object.entries(configurations)) {
865
- const href = hrefs[name] ?? hrefs['*'];
866
- if (!href || href === '/' || !(0, workspace_source_1.isObject)(config))
867
- continue;
868
- config['baseHref'] = href;
869
- applied.push(`${name}: ${href}`);
870
- }
871
- if (applied.length > 0) {
872
- notes.push(`release target base hrefs from the source build scripts: ${applied.join(', ')}`);
873
- }
874
- }
875
- /** "environments/<x>/environment.prod.ts" in the build's fileReplacements → "<x>". */
876
- function envFolderOf(build) {
877
- const sets = [build['options'], ...Object.values((0, workspace_source_1.objectField)(build, 'configurations'))];
878
- for (const set of sets) {
879
- const replacements = (0, workspace_source_1.isObject)(set) ? set['fileReplacements'] : undefined;
880
- if (!Array.isArray(replacements))
881
- continue;
882
- for (const r of replacements) {
883
- const w = (0, workspace_source_1.isObject)(r) ? r['with'] ?? r['replaceWith'] : undefined;
884
- const m = typeof w === 'string' ? /^(?:\.\/)?environments\/([^/]+)\/[^/]+$/.exec(w) : null;
885
- if (m)
886
- return m[1];
887
- }
888
- }
889
- return undefined;
890
- }
891
845
  const scriptContext = (plan) => ({
892
846
  renames: plan.renames,
893
847
  all: new Set(plan.all.map((p) => p.name)),