@memberjunction/installer 6.1.0-edge.5 → 6.1.0-edge.6
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/dist/InstallerEngine.d.ts +4 -2
- package/dist/InstallerEngine.d.ts.map +1 -1
- package/dist/InstallerEngine.js +21 -8
- package/dist/InstallerEngine.js.map +1 -1
- package/dist/adapters/FileSystemAdapter.d.ts +24 -0
- package/dist/adapters/FileSystemAdapter.d.ts.map +1 -1
- package/dist/adapters/FileSystemAdapter.js +55 -8
- package/dist/adapters/FileSystemAdapter.js.map +1 -1
- package/dist/distribution/DistributionAssembler.d.ts.map +1 -1
- package/dist/distribution/DistributionAssembler.js +1 -0
- package/dist/distribution/DistributionAssembler.js.map +1 -1
- package/dist/errors/ArchiveEntryRefusedError.d.ts +16 -0
- package/dist/errors/ArchiveEntryRefusedError.d.ts.map +1 -0
- package/dist/errors/ArchiveEntryRefusedError.js +21 -0
- package/dist/errors/ArchiveEntryRefusedError.js.map +1 -0
- package/dist/logging/ReportGenerator.d.ts.map +1 -1
- package/dist/logging/ReportGenerator.js +5 -0
- package/dist/logging/ReportGenerator.js.map +1 -1
- package/dist/models/Diagnostics.d.ts +4 -0
- package/dist/models/Diagnostics.d.ts.map +1 -1
- package/dist/models/Diagnostics.js.map +1 -1
- package/dist/models/InstallConfig.d.ts +10 -0
- package/dist/models/InstallConfig.d.ts.map +1 -1
- package/dist/models/InstallConfig.js +3 -0
- package/dist/models/InstallConfig.js.map +1 -1
- package/dist/models/PackageManager.d.ts +60 -0
- package/dist/models/PackageManager.d.ts.map +1 -0
- package/dist/models/PackageManager.js +90 -0
- package/dist/models/PackageManager.js.map +1 -0
- package/dist/phases/CodeGenPhase.d.ts +12 -9
- package/dist/phases/CodeGenPhase.d.ts.map +1 -1
- package/dist/phases/CodeGenPhase.js +57 -47
- package/dist/phases/CodeGenPhase.js.map +1 -1
- package/dist/phases/DependencyPhase.d.ts +61 -19
- package/dist/phases/DependencyPhase.d.ts.map +1 -1
- package/dist/phases/DependencyPhase.js +259 -65
- package/dist/phases/DependencyPhase.js.map +1 -1
- package/dist/phases/MigratePhase.d.ts +4 -1
- package/dist/phases/MigratePhase.d.ts.map +1 -1
- package/dist/phases/MigratePhase.js +8 -4
- package/dist/phases/MigratePhase.js.map +1 -1
- package/dist/phases/PreflightPhase.d.ts +8 -1
- package/dist/phases/PreflightPhase.d.ts.map +1 -1
- package/dist/phases/PreflightPhase.js +62 -25
- package/dist/phases/PreflightPhase.js.map +1 -1
- package/dist/phases/ScaffoldPhase.d.ts +4 -0
- package/dist/phases/ScaffoldPhase.d.ts.map +1 -1
- package/dist/phases/ScaffoldPhase.js +14 -2
- package/dist/phases/ScaffoldPhase.js.map +1 -1
- package/dist/phases/SmokeTestPhase.d.ts +3 -0
- package/dist/phases/SmokeTestPhase.d.ts.map +1 -1
- package/dist/phases/SmokeTestPhase.js +36 -11
- package/dist/phases/SmokeTestPhase.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Phase G — Dependencies (Install + Build)
|
|
3
3
|
*
|
|
4
|
-
* Runs `
|
|
5
|
-
* then `
|
|
4
|
+
* Runs the configured package manager's `install` at the repo root to install
|
|
5
|
+
* all workspace dependencies, then `run build` to compile all ~170 packages
|
|
6
|
+
* in the monorepo. The package manager defaults to pnpm (the era-6 platform
|
|
7
|
+
* manifest declares pnpm); npm remains available as an explicit override.
|
|
6
8
|
*
|
|
7
9
|
* Key behaviors:
|
|
8
|
-
* - **
|
|
9
|
-
*
|
|
10
|
+
* - **Workspace scaffold**: pins the root `packageManager` field, rewrites
|
|
11
|
+
* npm-layout-specific scripts, and (for pnpm) writes `pnpm-workspace.yaml`
|
|
12
|
+
* when the extracted bundle doesn't ship one.
|
|
13
|
+
* - **ERESOLVE retry (npm only)**: If `npm install` fails with peer dependency
|
|
14
|
+
* conflicts, automatically retries with `--legacy-peer-deps`. pnpm has no
|
|
15
|
+
* equivalent flag and treats peer conflicts as warnings, so no retry exists.
|
|
10
16
|
* - **Partial build tolerance**: Build failures in codegen-managed packages
|
|
11
17
|
* (entity forms, bootstrap) are treated as partial success since CodeGen
|
|
12
18
|
* will regenerate their source and rebuild in a later phase.
|
|
@@ -18,6 +24,7 @@
|
|
|
18
24
|
* @see PlatformCompatPhase — patches scripts before this phase runs.
|
|
19
25
|
*/
|
|
20
26
|
import type { InstallerEventEmitter } from '../events/InstallerEvents.js';
|
|
27
|
+
import { type PackageManagerType } from '../models/PackageManager.js';
|
|
21
28
|
/**
|
|
22
29
|
* Convert an install tag into a valid npm version spec.
|
|
23
30
|
*
|
|
@@ -44,10 +51,12 @@ export declare function tagToNpmVersion(tag: string): string;
|
|
|
44
51
|
* @see DependencyPhase.Run
|
|
45
52
|
*/
|
|
46
53
|
export interface DependencyContext {
|
|
47
|
-
/** Absolute path to the repo root (where
|
|
54
|
+
/** Absolute path to the repo root (where install and build are executed). */
|
|
48
55
|
Dir: string;
|
|
49
56
|
/** MemberJunction version tag (e.g., `"v5.9.0"`) — used to pin the CLI dependency version. */
|
|
50
57
|
Tag: string;
|
|
58
|
+
/** Package manager to install and build with (`'pnpm'` default, `'npm'` override). */
|
|
59
|
+
PackageManager: PackageManagerType;
|
|
51
60
|
/** Event emitter for progress, warn, and log events. */
|
|
52
61
|
Emitter: InstallerEventEmitter;
|
|
53
62
|
}
|
|
@@ -57,9 +66,9 @@ export interface DependencyContext {
|
|
|
57
66
|
* @see DependencyPhase.Run
|
|
58
67
|
*/
|
|
59
68
|
export interface DependencyResult {
|
|
60
|
-
/** Whether
|
|
69
|
+
/** Whether the install completed successfully. */
|
|
61
70
|
InstallSuccess: boolean;
|
|
62
|
-
/** Whether
|
|
71
|
+
/** Whether the build completed fully (`false` if partial). */
|
|
63
72
|
BuildSuccess: boolean;
|
|
64
73
|
/**
|
|
65
74
|
* Whether the build was partial — codegen-managed packages failed
|
|
@@ -70,12 +79,13 @@ export interface DependencyResult {
|
|
|
70
79
|
Warnings: string[];
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
|
-
* Phase G — Installs
|
|
82
|
+
* Phase G — Installs workspace dependencies and builds all workspace packages
|
|
83
|
+
* with the configured package manager.
|
|
74
84
|
*
|
|
75
85
|
* @example
|
|
76
86
|
* ```typescript
|
|
77
87
|
* const deps = new DependencyPhase();
|
|
78
|
-
* const result = await deps.Run({ Dir: '/path/to/install', Emitter: emitter });
|
|
88
|
+
* const result = await deps.Run({ Dir: '/path/to/install', Tag: 'v6.1.0', PackageManager: 'pnpm', Emitter: emitter });
|
|
79
89
|
* if (result.BuildPartial) {
|
|
80
90
|
* console.log('Partial build — CodeGen will fix remaining packages');
|
|
81
91
|
* }
|
|
@@ -85,24 +95,43 @@ export declare class DependencyPhase {
|
|
|
85
95
|
private processRunner;
|
|
86
96
|
private fileSystem;
|
|
87
97
|
/**
|
|
88
|
-
* Execute the dependency phase:
|
|
98
|
+
* Execute the dependency phase: workspace scaffold, install, then build.
|
|
89
99
|
*
|
|
90
|
-
* @param context - Dependency input with directory and emitter.
|
|
100
|
+
* @param context - Dependency input with directory, package manager, and emitter.
|
|
91
101
|
* @returns Install/build status and collected warnings.
|
|
92
|
-
* @throws {InstallerError} With code `
|
|
102
|
+
* @throws {InstallerError} With code `INSTALL_FAILED` or `INSTALL_TIMEOUT` on install failure.
|
|
93
103
|
* @throws {InstallerError} With code `BUILD_FAILED` or `BUILD_TIMEOUT` on non-codegen build failure.
|
|
94
104
|
*/
|
|
95
105
|
Run(context: DependencyContext): Promise<DependencyResult>;
|
|
96
106
|
/**
|
|
97
|
-
* Run
|
|
107
|
+
* Run the package manager's install. For npm, retries with
|
|
108
|
+
* `--legacy-peer-deps` on ERESOLVE errors — pnpm reports peer conflicts as
|
|
109
|
+
* warnings and has no equivalent flag, so it gets a single attempt.
|
|
98
110
|
* Collects vulnerability warnings into the supplied array.
|
|
99
111
|
*/
|
|
100
|
-
private
|
|
112
|
+
private runInstall;
|
|
101
113
|
/**
|
|
102
|
-
*
|
|
114
|
+
* npm-only ERESOLVE recovery: retry the install with `--legacy-peer-deps`.
|
|
115
|
+
* pnpm has no equivalent flag (it reports peer conflicts as warnings), so
|
|
116
|
+
* this is never reached for pnpm.
|
|
117
|
+
*/
|
|
118
|
+
private retryNpmPeerConflicts;
|
|
119
|
+
/** Surface dependency-audit advisories as informational warnings. */
|
|
120
|
+
private collectAuditWarnings;
|
|
121
|
+
/**
|
|
122
|
+
* Log the package-manager version resolved from the install directory —
|
|
123
|
+
* the version that actually runs the install (gate-4 evidence). A probe
|
|
124
|
+
* failure is logged and never fails the install; the preflight PATH check
|
|
125
|
+
* already guaranteed the binary exists.
|
|
126
|
+
*/
|
|
127
|
+
private logEffectiveVersion;
|
|
128
|
+
/** Build the INSTALL_TIMEOUT error for a (possibly retried) install. */
|
|
129
|
+
private installTimeoutError;
|
|
130
|
+
/**
|
|
131
|
+
* Runs the build script. Returns true if the build was "partial" (only codegen-managed
|
|
103
132
|
* packages failed), false if it fully succeeded. Throws on hard failures.
|
|
104
133
|
*/
|
|
105
|
-
private
|
|
134
|
+
private runBuild;
|
|
106
135
|
/**
|
|
107
136
|
* Extract failed package names from turbo's output.
|
|
108
137
|
*
|
|
@@ -115,10 +144,10 @@ export declare class DependencyPhase {
|
|
|
115
144
|
*/
|
|
116
145
|
private extractFailedTurboPackages;
|
|
117
146
|
/**
|
|
118
|
-
* Execute a single
|
|
147
|
+
* Execute a single install invocation with optional extra arguments.
|
|
119
148
|
* Streams stdout/stderr to the emitter for real-time progress.
|
|
120
149
|
*/
|
|
121
|
-
private
|
|
150
|
+
private runInstallOnce;
|
|
122
151
|
/** Check whether npm stderr output indicates an ERESOLVE peer-dependency conflict. */
|
|
123
152
|
private isEresolveError;
|
|
124
153
|
/** Return the last `n` lines of a multi-line string. */
|
|
@@ -133,7 +162,8 @@ export declare class DependencyPhase {
|
|
|
133
162
|
/**
|
|
134
163
|
* Packages that must be hoisted to the root `node_modules` to avoid duplicate-
|
|
135
164
|
* instance problems with Angular's DI system and MJ's ClassFactory.
|
|
136
|
-
* Only applicable for distribution installs
|
|
165
|
+
* Only applicable for npm distribution installs — pnpm's isolated linker
|
|
166
|
+
* never nests a package under a workspace member the way npm hoisting can.
|
|
137
167
|
*/
|
|
138
168
|
private static readonly HOISTED_PACKAGES;
|
|
139
169
|
/**
|
|
@@ -141,5 +171,17 @@ export declare class DependencyPhase {
|
|
|
141
171
|
* In monorepo mode, workspace resolution handles this automatically.
|
|
142
172
|
*/
|
|
143
173
|
private ensureHoistedDependencies;
|
|
174
|
+
/**
|
|
175
|
+
* Align the extracted workspace with the configured package manager:
|
|
176
|
+
* pin the root `packageManager` field, rewrite npm-layout scripts to
|
|
177
|
+
* PM-neutral forms, and (pnpm only) write `pnpm-workspace.yaml` when the
|
|
178
|
+
* bundle doesn't ship one. Runs on every install so bundles built before
|
|
179
|
+
* the pnpm flip install correctly too.
|
|
180
|
+
*/
|
|
181
|
+
private ensurePackageManagerScaffold;
|
|
182
|
+
/** Pin `packageManager` and neutralize npm-layout scripts in the root manifest. */
|
|
183
|
+
private patchRootManifest;
|
|
184
|
+
/** Write `pnpm-workspace.yaml` when the extracted bundle doesn't ship one. */
|
|
185
|
+
private ensurePnpmWorkspaceFile;
|
|
144
186
|
}
|
|
145
187
|
//# sourceMappingURL=DependencyPhase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyPhase.d.ts","sourceRoot":"","sources":["../../src/phases/DependencyPhase.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DependencyPhase.d.ts","sourceRoot":"","sources":["../../src/phases/DependencyPhase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAG9F;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AA6DD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,8FAA8F;IAC9F,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,cAAc,EAAE,kBAAkB,CAAC;IACnC,wDAAwD;IACxD,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,8DAA8D;IAC9D,YAAY,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,UAAU,CAA2B;IAE7C;;;;;;;OAOG;IACG,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA6ChE;;;;;OAKG;YACW,UAAU;IA0CxB;;;;OAIG;YACW,qBAAqB;IA4BnC,qEAAqE;IACrE,OAAO,CAAC,oBAAoB;IAoB5B;;;;;OAKG;YACW,mBAAmB;IAqBjC,wEAAwE;IACxE,OAAO,CAAC,mBAAmB;IAc3B;;;OAGG;YACW,QAAQ;IAsFtB;;;;;;;;;OASG;IACH,OAAO,CAAC,0BAA0B;IAclC;;;OAGG;YACW,cAAc;IA6B5B,sFAAsF;IACtF,OAAO,CAAC,eAAe;IAIvB,wDAAwD;IACxD,OAAO,CAAC,UAAU;IASlB;;;;;OAKG;YACW,mBAAmB;IAsCjC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAKtC;IAEF;;;OAGG;YACW,yBAAyB;IA8CvC;;;;;;OAMG;YACW,4BAA4B;IAY1C,mFAAmF;YACrE,iBAAiB;IAsE/B,8EAA8E;YAChE,uBAAuB;CAatC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Phase G — Dependencies (Install + Build)
|
|
3
3
|
*
|
|
4
|
-
* Runs `
|
|
5
|
-
* then `
|
|
4
|
+
* Runs the configured package manager's `install` at the repo root to install
|
|
5
|
+
* all workspace dependencies, then `run build` to compile all ~170 packages
|
|
6
|
+
* in the monorepo. The package manager defaults to pnpm (the era-6 platform
|
|
7
|
+
* manifest declares pnpm); npm remains available as an explicit override.
|
|
6
8
|
*
|
|
7
9
|
* Key behaviors:
|
|
8
|
-
* - **
|
|
9
|
-
*
|
|
10
|
+
* - **Workspace scaffold**: pins the root `packageManager` field, rewrites
|
|
11
|
+
* npm-layout-specific scripts, and (for pnpm) writes `pnpm-workspace.yaml`
|
|
12
|
+
* when the extracted bundle doesn't ship one.
|
|
13
|
+
* - **ERESOLVE retry (npm only)**: If `npm install` fails with peer dependency
|
|
14
|
+
* conflicts, automatically retries with `--legacy-peer-deps`. pnpm has no
|
|
15
|
+
* equivalent flag and treats peer conflicts as warnings, so no retry exists.
|
|
10
16
|
* - **Partial build tolerance**: Build failures in codegen-managed packages
|
|
11
17
|
* (entity forms, bootstrap) are treated as partial success since CodeGen
|
|
12
18
|
* will regenerate their source and rebuild in a later phase.
|
|
@@ -20,6 +26,7 @@
|
|
|
20
26
|
import { InstallerError } from '../errors/InstallerError.js';
|
|
21
27
|
import { ProcessRunner } from '../adapters/ProcessRunner.js';
|
|
22
28
|
import { FileSystemAdapter } from '../adapters/FileSystemAdapter.js';
|
|
29
|
+
import { PackageManagerCommands } from '../models/PackageManager.js';
|
|
23
30
|
import path from 'node:path';
|
|
24
31
|
/**
|
|
25
32
|
* Convert an install tag into a valid npm version spec.
|
|
@@ -61,12 +68,54 @@ const CODEGEN_MANAGED_PACKAGES = [
|
|
|
61
68
|
'ng-bootstrap',
|
|
62
69
|
];
|
|
63
70
|
/**
|
|
64
|
-
*
|
|
71
|
+
* The `pnpm-workspace.yaml` written into a distribution install when the
|
|
72
|
+
* extracted bundle doesn't ship one (bundles built before the pnpm flip).
|
|
73
|
+
*
|
|
74
|
+
* Both settings are load-bearing under pnpm 10:
|
|
75
|
+
* - `linkWorkspacePackages: true` — without it, exact-version internal deps
|
|
76
|
+
* resolve from the REGISTRY instead of linking the local workspace package.
|
|
77
|
+
* For unpublished packages (mj_generatedentities) that fails loudly; for
|
|
78
|
+
* published ones it silently installs a stale copy.
|
|
79
|
+
* - `onlyBuiltDependencies` — pnpm 10 does not run dependency build scripts
|
|
80
|
+
* unless allowlisted; anything omitted installs without its postinstall
|
|
81
|
+
* step and fails later at runtime. The list mirrors the MJ monorepo's own
|
|
82
|
+
* allowlist for the dependency graph the published packages pull in.
|
|
83
|
+
*/
|
|
84
|
+
const PNPM_WORKSPACE_YAML = `# Generated by mj install — pnpm workspace definition for the MJ distribution.
|
|
85
|
+
packages:
|
|
86
|
+
- 'apps/*'
|
|
87
|
+
- 'packages/*'
|
|
88
|
+
|
|
89
|
+
# pnpm 10 defaults this to false, which makes exact-version internal deps
|
|
90
|
+
# resolve from the registry instead of linking the local workspace package.
|
|
91
|
+
linkWorkspacePackages: true
|
|
92
|
+
|
|
93
|
+
# pnpm 10 only runs dependency build scripts that are allowlisted here.
|
|
94
|
+
onlyBuiltDependencies:
|
|
95
|
+
- '@apollo/protobufjs'
|
|
96
|
+
- '@google/genai'
|
|
97
|
+
- '@parcel/watcher'
|
|
98
|
+
- browser-tabs-lock
|
|
99
|
+
- core-js
|
|
100
|
+
- core-js-pure
|
|
101
|
+
- esbuild
|
|
102
|
+
- isolated-vm
|
|
103
|
+
- lmdb
|
|
104
|
+
- msgpackr-extract
|
|
105
|
+
- oracledb
|
|
106
|
+
- protobufjs
|
|
107
|
+
- rete
|
|
108
|
+
- sharp
|
|
109
|
+
- tesseract.js
|
|
110
|
+
`;
|
|
111
|
+
/**
|
|
112
|
+
* Phase G — Installs workspace dependencies and builds all workspace packages
|
|
113
|
+
* with the configured package manager.
|
|
65
114
|
*
|
|
66
115
|
* @example
|
|
67
116
|
* ```typescript
|
|
68
117
|
* const deps = new DependencyPhase();
|
|
69
|
-
* const result = await deps.Run({ Dir: '/path/to/install', Emitter: emitter });
|
|
118
|
+
* const result = await deps.Run({ Dir: '/path/to/install', Tag: 'v6.1.0', PackageManager: 'pnpm', Emitter: emitter });
|
|
70
119
|
* if (result.BuildPartial) {
|
|
71
120
|
* console.log('Partial build — CodeGen will fix remaining packages');
|
|
72
121
|
* }
|
|
@@ -78,27 +127,39 @@ export class DependencyPhase {
|
|
|
78
127
|
this.fileSystem = new FileSystemAdapter();
|
|
79
128
|
}
|
|
80
129
|
/**
|
|
81
|
-
* Execute the dependency phase:
|
|
130
|
+
* Execute the dependency phase: workspace scaffold, install, then build.
|
|
82
131
|
*
|
|
83
|
-
* @param context - Dependency input with directory and emitter.
|
|
132
|
+
* @param context - Dependency input with directory, package manager, and emitter.
|
|
84
133
|
* @returns Install/build status and collected warnings.
|
|
85
|
-
* @throws {InstallerError} With code `
|
|
134
|
+
* @throws {InstallerError} With code `INSTALL_FAILED` or `INSTALL_TIMEOUT` on install failure.
|
|
86
135
|
* @throws {InstallerError} With code `BUILD_FAILED` or `BUILD_TIMEOUT` on non-codegen build failure.
|
|
87
136
|
*/
|
|
88
137
|
async Run(context) {
|
|
89
138
|
const { Emitter: emitter } = context;
|
|
139
|
+
const pm = new PackageManagerCommands(context.PackageManager);
|
|
90
140
|
const warnings = [];
|
|
91
|
-
// Step 0a: Ensure @memberjunction/cli is a dependency so `mj` in
|
|
141
|
+
// Step 0a: Ensure @memberjunction/cli is a dependency so `mj` in scripts
|
|
92
142
|
// resolves to the correct version (not a stale global install)
|
|
93
143
|
await this.ensureCliDependency(context.Dir, context.Tag, emitter);
|
|
94
|
-
// Step 0b: Ensure packages that must be hoisted to root node_modules
|
|
95
|
-
// as root dependencies.
|
|
96
|
-
// due to peer-dep conflicts, causing duplicate class instances and Angular DI
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
144
|
+
// Step 0b (npm only): Ensure packages that must be hoisted to root node_modules
|
|
145
|
+
// are listed as root dependencies. npm may nest them under workspace packages
|
|
146
|
+
// due to peer-dep conflicts, causing duplicate class instances and Angular DI
|
|
147
|
+
// failures. pnpm's isolated linker doesn't have that nesting problem.
|
|
148
|
+
if (pm.Name === 'npm') {
|
|
149
|
+
await this.ensureHoistedDependencies(context.Dir, context.Tag, emitter);
|
|
150
|
+
}
|
|
151
|
+
// Step 0c: Align the workspace scaffold with the configured package manager
|
|
152
|
+
// (root packageManager pin, PM-neutral scripts, pnpm-workspace.yaml).
|
|
153
|
+
await this.ensurePackageManagerScaffold(context.Dir, pm, emitter);
|
|
154
|
+
// Record the version that will ACTUALLY run the install. Probed in the
|
|
155
|
+
// install dir AFTER the pin is written, because corepack shims and pnpm
|
|
156
|
+
// 10's manage-package-manager-versions resolve the packageManager field
|
|
157
|
+
// by cwd — a preflight PATH probe can report a different version.
|
|
158
|
+
await this.logEffectiveVersion(context.Dir, pm, emitter);
|
|
159
|
+
// Step 1: install
|
|
160
|
+
await this.runInstall(context.Dir, pm, emitter, warnings);
|
|
161
|
+
// Step 2: build
|
|
162
|
+
const buildPartial = await this.runBuild(context.Dir, pm, emitter, warnings);
|
|
102
163
|
return {
|
|
103
164
|
InstallSuccess: true,
|
|
104
165
|
BuildSuccess: !buildPartial,
|
|
@@ -107,72 +168,116 @@ export class DependencyPhase {
|
|
|
107
168
|
};
|
|
108
169
|
}
|
|
109
170
|
// ---------------------------------------------------------------------------
|
|
110
|
-
//
|
|
171
|
+
// Install
|
|
111
172
|
// ---------------------------------------------------------------------------
|
|
112
173
|
/**
|
|
113
|
-
* Run
|
|
174
|
+
* Run the package manager's install. For npm, retries with
|
|
175
|
+
* `--legacy-peer-deps` on ERESOLVE errors — pnpm reports peer conflicts as
|
|
176
|
+
* warnings and has no equivalent flag, so it gets a single attempt.
|
|
114
177
|
* Collects vulnerability warnings into the supplied array.
|
|
115
178
|
*/
|
|
116
|
-
async
|
|
179
|
+
async runInstall(dir, pm, emitter, warnings) {
|
|
117
180
|
emitter.Emit('step:progress', {
|
|
118
181
|
Type: 'step:progress',
|
|
119
182
|
Phase: 'dependencies',
|
|
120
|
-
Message:
|
|
183
|
+
Message: `Running ${pm.Name} install (this may take several minutes)...`,
|
|
121
184
|
});
|
|
122
|
-
let result = await this.
|
|
185
|
+
let result = await this.runInstallOnce(dir, pm, emitter, []);
|
|
123
186
|
if (result.TimedOut) {
|
|
124
|
-
throw
|
|
187
|
+
throw this.installTimeoutError(pm, []);
|
|
125
188
|
}
|
|
126
|
-
//
|
|
127
|
-
if (result.ExitCode !== 0 && this.isEresolveError(result.Stderr)) {
|
|
128
|
-
|
|
129
|
-
Type: 'warn',
|
|
130
|
-
Phase: 'dependencies',
|
|
131
|
-
Message: 'Peer dependency conflict detected. Retrying with --legacy-peer-deps...',
|
|
132
|
-
});
|
|
133
|
-
result = await this.runNpmInstallOnce(dir, emitter, ['--legacy-peer-deps']);
|
|
134
|
-
if (result.TimedOut) {
|
|
135
|
-
throw new InstallerError('dependencies', 'NPM_INSTALL_TIMEOUT', 'npm install --legacy-peer-deps timed out after 15 minutes.', 'Run "npm install --legacy-peer-deps" manually at the repo root.');
|
|
136
|
-
}
|
|
137
|
-
if (result.ExitCode === 0) {
|
|
138
|
-
warnings.push('npm install required --legacy-peer-deps due to peer dependency conflicts in the release. ' +
|
|
139
|
-
'This is safe but indicates a minor version skew in the release packages.');
|
|
140
|
-
}
|
|
189
|
+
// npm only: retry peer dependency conflicts with --legacy-peer-deps
|
|
190
|
+
if (pm.Name === 'npm' && result.ExitCode !== 0 && this.isEresolveError(result.Stderr)) {
|
|
191
|
+
result = await this.retryNpmPeerConflicts(dir, pm, emitter, warnings);
|
|
141
192
|
}
|
|
142
193
|
if (result.ExitCode !== 0) {
|
|
143
194
|
const lastLines = this.lastNLines(result.Stderr || result.Stdout, 50);
|
|
144
|
-
throw new InstallerError('dependencies', '
|
|
145
|
-
}
|
|
146
|
-
// Check for audit vulnerabilities (informational only)
|
|
147
|
-
if (result.Stderr.includes('vulnerabilit')) {
|
|
148
|
-
warnings.push('npm reports vulnerabilities in dependencies. This is common in large workspaces. ' +
|
|
149
|
-
'Do NOT run "npm audit fix --force" — it can break the workspace.');
|
|
150
|
-
emitter.Emit('warn', {
|
|
151
|
-
Type: 'warn',
|
|
152
|
-
Phase: 'dependencies',
|
|
153
|
-
Message: 'npm reports dependency vulnerabilities (informational). Do not run "npm audit fix --force".',
|
|
154
|
-
});
|
|
195
|
+
throw new InstallerError('dependencies', 'INSTALL_FAILED', `${pm.Name} install failed (exit code ${result.ExitCode}):\n${lastLines}`, `Run "${pm.Name} install" manually at the repo root to see full error output.`);
|
|
155
196
|
}
|
|
197
|
+
this.collectAuditWarnings(result.Stderr, pm, emitter, warnings);
|
|
156
198
|
emitter.Emit('log', {
|
|
157
199
|
Type: 'log',
|
|
158
200
|
Level: 'info',
|
|
159
|
-
Message:
|
|
201
|
+
Message: `${pm.Name} install completed successfully.`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* npm-only ERESOLVE recovery: retry the install with `--legacy-peer-deps`.
|
|
206
|
+
* pnpm has no equivalent flag (it reports peer conflicts as warnings), so
|
|
207
|
+
* this is never reached for pnpm.
|
|
208
|
+
*/
|
|
209
|
+
async retryNpmPeerConflicts(dir, pm, emitter, warnings) {
|
|
210
|
+
emitter.Emit('warn', {
|
|
211
|
+
Type: 'warn',
|
|
212
|
+
Phase: 'dependencies',
|
|
213
|
+
Message: 'Peer dependency conflict detected. Retrying with --legacy-peer-deps...',
|
|
214
|
+
});
|
|
215
|
+
const result = await this.runInstallOnce(dir, pm, emitter, ['--legacy-peer-deps']);
|
|
216
|
+
if (result.TimedOut) {
|
|
217
|
+
throw this.installTimeoutError(pm, ['--legacy-peer-deps']);
|
|
218
|
+
}
|
|
219
|
+
if (result.ExitCode === 0) {
|
|
220
|
+
warnings.push('npm install required --legacy-peer-deps due to peer dependency conflicts in the release. ' +
|
|
221
|
+
'This is safe but indicates a minor version skew in the release packages.');
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
/** Surface dependency-audit advisories as informational warnings. */
|
|
226
|
+
collectAuditWarnings(stderr, pm, emitter, warnings) {
|
|
227
|
+
if (!stderr.includes('vulnerabilit')) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
warnings.push(`${pm.Name} reports vulnerabilities in dependencies. This is common in large workspaces. ` +
|
|
231
|
+
'Do NOT run "npm audit fix --force" — it can break the workspace.');
|
|
232
|
+
emitter.Emit('warn', {
|
|
233
|
+
Type: 'warn',
|
|
234
|
+
Phase: 'dependencies',
|
|
235
|
+
Message: `${pm.Name} reports dependency vulnerabilities (informational). Do not run "npm audit fix --force".`,
|
|
160
236
|
});
|
|
161
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Log the package-manager version resolved from the install directory —
|
|
240
|
+
* the version that actually runs the install (gate-4 evidence). A probe
|
|
241
|
+
* failure is logged and never fails the install; the preflight PATH check
|
|
242
|
+
* already guaranteed the binary exists.
|
|
243
|
+
*/
|
|
244
|
+
async logEffectiveVersion(dir, pm, emitter) {
|
|
245
|
+
try {
|
|
246
|
+
const version = await this.processRunner.RunSimple(pm.Name, ['--version'], dir);
|
|
247
|
+
emitter.Emit('log', {
|
|
248
|
+
Type: 'log',
|
|
249
|
+
Level: 'info',
|
|
250
|
+
Message: `Using ${pm.Name} ${version.trim()} for this install (root packageManager pin: ${pm.PackageManagerPin}).`,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
emitter.Emit('log', {
|
|
255
|
+
Type: 'log',
|
|
256
|
+
Level: 'verbose',
|
|
257
|
+
Message: `Could not probe the effective ${pm.Name} version: ${err instanceof Error ? err.message : String(err)}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/** Build the INSTALL_TIMEOUT error for a (possibly retried) install. */
|
|
262
|
+
installTimeoutError(pm, extraArgs) {
|
|
263
|
+
const commandLine = [pm.Name, 'install', ...extraArgs].join(' ');
|
|
264
|
+
return new InstallerError('dependencies', 'INSTALL_TIMEOUT', `${commandLine} timed out after 15 minutes.`, `Run "${commandLine}" manually at the repo root. Check network connectivity.`);
|
|
265
|
+
}
|
|
162
266
|
// ---------------------------------------------------------------------------
|
|
163
|
-
//
|
|
267
|
+
// Build
|
|
164
268
|
// ---------------------------------------------------------------------------
|
|
165
269
|
/**
|
|
166
|
-
* Runs
|
|
270
|
+
* Runs the build script. Returns true if the build was "partial" (only codegen-managed
|
|
167
271
|
* packages failed), false if it fully succeeded. Throws on hard failures.
|
|
168
272
|
*/
|
|
169
|
-
async
|
|
273
|
+
async runBuild(dir, pm, emitter, warnings) {
|
|
170
274
|
emitter.Emit('step:progress', {
|
|
171
275
|
Type: 'step:progress',
|
|
172
276
|
Phase: 'dependencies',
|
|
173
|
-
Message:
|
|
277
|
+
Message: `Running ${pm.Name} run build (first-time builds can take 15-20 minutes for 170 packages)...`,
|
|
174
278
|
});
|
|
175
|
-
const
|
|
279
|
+
const build = pm.RunScript('build');
|
|
280
|
+
const result = await this.processRunner.Run(build.Cmd, build.Args, {
|
|
176
281
|
Cwd: dir,
|
|
177
282
|
TimeoutMs: 1_800_000, // 30 minutes — first-time full workspace build of 170 packages can take 17+ min
|
|
178
283
|
OnStdout: (line) => {
|
|
@@ -191,7 +296,7 @@ export class DependencyPhase {
|
|
|
191
296
|
},
|
|
192
297
|
});
|
|
193
298
|
if (result.TimedOut) {
|
|
194
|
-
throw new InstallerError('dependencies', 'BUILD_TIMEOUT',
|
|
299
|
+
throw new InstallerError('dependencies', 'BUILD_TIMEOUT', `${pm.Name} run build timed out after 30 minutes.`, `Run "${pm.Name} run build" manually at the repo root to see full output. First-time builds of 170 packages can take 15-20 minutes.`);
|
|
195
300
|
}
|
|
196
301
|
if (result.ExitCode === 0) {
|
|
197
302
|
emitter.Emit('log', {
|
|
@@ -221,7 +326,7 @@ export class DependencyPhase {
|
|
|
221
326
|
}
|
|
222
327
|
// Non-codegen failures — hard error
|
|
223
328
|
const lastLines = this.lastNLines(result.Stderr || result.Stdout, 50);
|
|
224
|
-
throw new InstallerError('dependencies', 'BUILD_FAILED', `Build failed (exit code ${result.ExitCode}):\n${lastLines}`,
|
|
329
|
+
throw new InstallerError('dependencies', 'BUILD_FAILED', `Build failed (exit code ${result.ExitCode}):\n${lastLines}`, `Run "${pm.Name} run build" manually at the repo root to see full error output.`);
|
|
225
330
|
}
|
|
226
331
|
// ---------------------------------------------------------------------------
|
|
227
332
|
// Turbo output parsing
|
|
@@ -249,12 +354,12 @@ export class DependencyPhase {
|
|
|
249
354
|
// Helpers
|
|
250
355
|
// ---------------------------------------------------------------------------
|
|
251
356
|
/**
|
|
252
|
-
* Execute a single
|
|
357
|
+
* Execute a single install invocation with optional extra arguments.
|
|
253
358
|
* Streams stdout/stderr to the emitter for real-time progress.
|
|
254
359
|
*/
|
|
255
|
-
async
|
|
256
|
-
const
|
|
257
|
-
return this.processRunner.Run(
|
|
360
|
+
async runInstallOnce(dir, pm, emitter, extraArgs) {
|
|
361
|
+
const install = pm.Install(extraArgs);
|
|
362
|
+
return this.processRunner.Run(install.Cmd, install.Args, {
|
|
258
363
|
Cwd: dir,
|
|
259
364
|
TimeoutMs: 900_000, // 15 minutes
|
|
260
365
|
OnStdout: (line) => {
|
|
@@ -269,7 +374,7 @@ export class DependencyPhase {
|
|
|
269
374
|
emitter.Emit('log', {
|
|
270
375
|
Type: 'log',
|
|
271
376
|
Level: 'verbose',
|
|
272
|
-
Message: `[
|
|
377
|
+
Message: `[${pm.Name}] ${line.trim()}`,
|
|
273
378
|
});
|
|
274
379
|
}
|
|
275
380
|
},
|
|
@@ -317,12 +422,13 @@ export class DependencyPhase {
|
|
|
317
422
|
});
|
|
318
423
|
}
|
|
319
424
|
// ---------------------------------------------------------------------------
|
|
320
|
-
// Dependency hoisting
|
|
425
|
+
// Dependency hoisting (npm only)
|
|
321
426
|
// ---------------------------------------------------------------------------
|
|
322
427
|
/**
|
|
323
428
|
* Packages that must be hoisted to the root `node_modules` to avoid duplicate-
|
|
324
429
|
* instance problems with Angular's DI system and MJ's ClassFactory.
|
|
325
|
-
* Only applicable for distribution installs
|
|
430
|
+
* Only applicable for npm distribution installs — pnpm's isolated linker
|
|
431
|
+
* never nests a package under a workspace member the way npm hoisting can.
|
|
326
432
|
*/
|
|
327
433
|
static { this.HOISTED_PACKAGES = [
|
|
328
434
|
{ Name: '@memberjunction/ng-auth-services', Section: 'dependencies' },
|
|
@@ -361,5 +467,93 @@ export class DependencyPhase {
|
|
|
361
467
|
await this.fileSystem.WriteJSON(pkgPath, pkg);
|
|
362
468
|
}
|
|
363
469
|
}
|
|
470
|
+
// ---------------------------------------------------------------------------
|
|
471
|
+
// Package-manager scaffold
|
|
472
|
+
// ---------------------------------------------------------------------------
|
|
473
|
+
/**
|
|
474
|
+
* Align the extracted workspace with the configured package manager:
|
|
475
|
+
* pin the root `packageManager` field, rewrite npm-layout scripts to
|
|
476
|
+
* PM-neutral forms, and (pnpm only) write `pnpm-workspace.yaml` when the
|
|
477
|
+
* bundle doesn't ship one. Runs on every install so bundles built before
|
|
478
|
+
* the pnpm flip install correctly too.
|
|
479
|
+
*/
|
|
480
|
+
async ensurePackageManagerScaffold(dir, pm, emitter) {
|
|
481
|
+
await this.patchRootManifest(dir, pm, emitter);
|
|
482
|
+
if (pm.Name === 'pnpm') {
|
|
483
|
+
await this.ensurePnpmWorkspaceFile(dir, emitter);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/** Pin `packageManager` and neutralize npm-layout scripts in the root manifest. */
|
|
487
|
+
async patchRootManifest(dir, pm, emitter) {
|
|
488
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
489
|
+
const pkg = await this.fileSystem.ReadJSON(pkgPath);
|
|
490
|
+
let modified = false;
|
|
491
|
+
if (pkg['packageManager'] !== pm.PackageManagerPin) {
|
|
492
|
+
pkg['packageManager'] = pm.PackageManagerPin;
|
|
493
|
+
modified = true;
|
|
494
|
+
}
|
|
495
|
+
const scripts = (pkg['scripts'] ?? {});
|
|
496
|
+
// The `mj*` scripts historically pointed at apps/MJAPI/node_modules — an
|
|
497
|
+
// npm-hoisting artifact that doesn't exist under pnpm. The CLI is a root
|
|
498
|
+
// devDependency (ensureCliDependency), so its bin is on every script's
|
|
499
|
+
// PATH under both package managers.
|
|
500
|
+
const npmHoistPath = 'node_modules/@memberjunction/cli';
|
|
501
|
+
const mjScriptRewrites = {
|
|
502
|
+
'mj': 'mj',
|
|
503
|
+
'mj:migrate': 'mj migrate',
|
|
504
|
+
'mj:codegen': 'mj codegen',
|
|
505
|
+
};
|
|
506
|
+
for (const [name, replacement] of Object.entries(mjScriptRewrites)) {
|
|
507
|
+
if (scripts[name]?.includes(npmHoistPath)) {
|
|
508
|
+
scripts[name] = replacement;
|
|
509
|
+
modified = true;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const installDeps = `${pm.Name} install`;
|
|
513
|
+
if (scripts['install:deps'] && scripts['install:deps'] !== installDeps) {
|
|
514
|
+
scripts['install:deps'] = installDeps;
|
|
515
|
+
modified = true;
|
|
516
|
+
}
|
|
517
|
+
// Pre-flip bundles route `build` through npm (`npm run build:stream`) and
|
|
518
|
+
// carry npm-only guidance in prebuild/setup. Rewrite those exact shim
|
|
519
|
+
// forms to PM-neutral equivalents so a pnpm install never shells back
|
|
520
|
+
// into npm; anything user-customized is left alone.
|
|
521
|
+
if (scripts['build'] === 'npm run build:stream') {
|
|
522
|
+
scripts['build'] = 'turbo --log-order=stream build';
|
|
523
|
+
modified = true;
|
|
524
|
+
}
|
|
525
|
+
if (scripts['prebuild']?.includes('Run: npm install')) {
|
|
526
|
+
scripts['prebuild'] =
|
|
527
|
+
'node -e "try { require.resolve(\'turbo\') } catch (e) { console.error(\'\\n❌ Dependencies not installed. Run: pnpm install (or npm install)\\n\'); process.exit(1); }"';
|
|
528
|
+
modified = true;
|
|
529
|
+
}
|
|
530
|
+
if (scripts['setup']?.includes('npm run mj:migrate')) {
|
|
531
|
+
scripts['setup'] = "echo 'Please run the mj:migrate, mj:codegen, and build scripts with your package manager.'";
|
|
532
|
+
modified = true;
|
|
533
|
+
}
|
|
534
|
+
if (!modified) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
pkg['scripts'] = scripts;
|
|
538
|
+
await this.fileSystem.WriteJSON(pkgPath, pkg);
|
|
539
|
+
emitter.Emit('step:progress', {
|
|
540
|
+
Type: 'step:progress',
|
|
541
|
+
Phase: 'dependencies',
|
|
542
|
+
Message: `Pinned root packageManager to ${pm.PackageManagerPin}`,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
/** Write `pnpm-workspace.yaml` when the extracted bundle doesn't ship one. */
|
|
546
|
+
async ensurePnpmWorkspaceFile(dir, emitter) {
|
|
547
|
+
const wsPath = path.join(dir, 'pnpm-workspace.yaml');
|
|
548
|
+
if (await this.fileSystem.FileExists(wsPath)) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
await this.fileSystem.WriteText(wsPath, PNPM_WORKSPACE_YAML);
|
|
552
|
+
emitter.Emit('step:progress', {
|
|
553
|
+
Type: 'step:progress',
|
|
554
|
+
Phase: 'dependencies',
|
|
555
|
+
Message: 'Wrote pnpm-workspace.yaml (bundle predates the pnpm flip)',
|
|
556
|
+
});
|
|
557
|
+
}
|
|
364
558
|
}
|
|
365
559
|
//# sourceMappingURL=DependencyPhase.js.map
|