@b64hub/sfpm-cli 0.2.0 → 0.4.0
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/LICENSE +21 -0
- package/README.md +143 -74
- package/dist/commands/bootstrap.d.ts +21 -0
- package/dist/commands/bootstrap.js +123 -32
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/build/index.d.ts +11 -1
- package/dist/commands/build/index.js +73 -82
- package/dist/commands/build/index.js.map +1 -1
- package/dist/commands/deploy/artifact.d.ts +1 -3
- package/dist/commands/deploy/artifact.js +7 -7
- package/dist/commands/deploy/artifact.js.map +1 -1
- package/dist/commands/deploy/index.d.ts +3 -5
- package/dist/commands/deploy/index.js +10 -22
- package/dist/commands/deploy/index.js.map +1 -1
- package/dist/commands/dev/pool-list-replay.js +1 -1
- package/dist/commands/dev/pool-list-replay.js.map +1 -1
- package/dist/commands/dev/pool-replay.js +2 -1
- package/dist/commands/dev/pool-replay.js.map +1 -1
- package/dist/commands/dev/replay.js +2 -2
- package/dist/commands/dev/replay.js.map +1 -1
- package/dist/commands/install.js +4 -18
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/pool/delete.js +8 -8
- package/dist/commands/pool/delete.js.map +1 -1
- package/dist/commands/pool/fetch.js +57 -66
- package/dist/commands/pool/fetch.js.map +1 -1
- package/dist/commands/pool/fill.js +6 -7
- package/dist/commands/pool/fill.js.map +1 -1
- package/dist/commands/pool/list.js +2 -2
- package/dist/commands/pool/list.js.map +1 -1
- package/dist/commands/release/create.d.ts +25 -0
- package/dist/commands/release/create.js +291 -0
- package/dist/commands/release/create.js.map +1 -0
- package/dist/commands/release/run.d.ts +13 -0
- package/dist/commands/release/run.js +142 -0
- package/dist/commands/release/run.js.map +1 -0
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/sfpm-command.d.ts +17 -1
- package/dist/sfpm-command.js +55 -21
- package/dist/sfpm-command.js.map +1 -1
- package/dist/types/release.d.ts +110 -0
- package/dist/types/release.js +142 -0
- package/dist/types/release.js.map +1 -0
- package/dist/ui/{build-event-bridge.d.ts → adapters/build-event-bridge.d.ts} +7 -9
- package/dist/ui/{build-event-bridge.js → adapters/build-event-bridge.js} +7 -9
- package/dist/ui/adapters/build-event-bridge.js.map +1 -0
- package/dist/ui/adapters/install-event-bridge.js.map +1 -0
- package/dist/ui/adapters/pino-bridge.js.map +1 -0
- package/dist/ui/adapters/pool-delete-event-bridge.js.map +1 -0
- package/dist/ui/adapters/pool-fill-event-bridge.js.map +1 -0
- package/dist/ui/apps/BuildApp.js +1 -1
- package/dist/ui/apps/BuildApp.js.map +1 -1
- package/dist/ui/apps/PoolDeleteApp.js +1 -1
- package/dist/ui/apps/PoolDeleteApp.js.map +1 -1
- package/dist/ui/apps/PoolFillApp.js +1 -1
- package/dist/ui/apps/PoolFillApp.js.map +1 -1
- package/dist/ui/components/OrchestrationView.js +3 -3
- package/dist/ui/components/OrchestrationView.js.map +1 -1
- package/dist/ui/components/base/Footer.js +2 -2
- package/dist/ui/components/base/Footer.js.map +1 -1
- package/dist/ui/components/base/GradientBar.d.ts +1 -1
- package/dist/ui/components/base/GradientBar.js +1 -1
- package/dist/ui/components/base/GradientBar.js.map +1 -1
- package/dist/ui/components/base/StatusIcon.js +1 -1
- package/dist/ui/components/base/StatusIcon.js.map +1 -1
- package/dist/ui/components/pool/OrgRow.js +2 -2
- package/dist/ui/components/pool/OrgRow.js.map +1 -1
- package/dist/ui/components/pool/PoolOrgRow.js +1 -1
- package/dist/ui/components/pool/PoolOrgRow.js.map +1 -1
- package/dist/ui/renderers/run-orchestrator-plain.d.ts +11 -0
- package/dist/ui/renderers/run-orchestrator-plain.js +47 -0
- package/dist/ui/renderers/run-orchestrator-plain.js.map +1 -0
- package/dist/ui/renderers/run-orchestrator.d.ts +25 -0
- package/dist/ui/renderers/run-orchestrator.js +17 -0
- package/dist/ui/renderers/run-orchestrator.js.map +1 -0
- package/dist/ui/renderers/run-pool-delete-plain.d.ts +12 -0
- package/dist/ui/renderers/run-pool-delete-plain.js +31 -0
- package/dist/ui/renderers/run-pool-delete-plain.js.map +1 -0
- package/dist/ui/renderers/run-pool-delete.d.ts +12 -0
- package/dist/ui/renderers/run-pool-delete.js +20 -0
- package/dist/ui/renderers/run-pool-delete.js.map +1 -0
- package/dist/ui/renderers/run-pool-fill-plain.d.ts +10 -0
- package/dist/ui/renderers/run-pool-fill-plain.js +60 -0
- package/dist/ui/renderers/run-pool-fill-plain.js.map +1 -0
- package/dist/ui/renderers/run-pool-fill.d.ts +16 -0
- package/dist/ui/renderers/run-pool-fill.js +24 -0
- package/dist/ui/renderers/run-pool-fill.js.map +1 -0
- package/dist/ui/{run-pool-list.js → renderers/run-pool-list.js} +1 -1
- package/dist/ui/renderers/run-pool-list.js.map +1 -0
- package/dist/ui/state/adapters.js +1 -1
- package/dist/ui/state/adapters.js.map +1 -1
- package/dist/ui/state/{reducer.js → orchestration-reducer.js} +1 -1
- package/dist/ui/state/orchestration-reducer.js.map +1 -0
- package/dist/ui/table.js +1 -1
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/utils/pool-utils.js.map +1 -0
- package/dist/ui/{renderer-utils.d.ts → utils/renderer-utils.d.ts} +11 -0
- package/dist/ui/utils/renderer-utils.js.map +1 -0
- package/dist/ui/utils/theme.js.map +1 -0
- package/oclif.manifest.json +499 -305
- package/package.json +16 -10
- package/dist/ui/build-event-bridge.js.map +0 -1
- package/dist/ui/build-progress-renderer.d.ts +0 -84
- package/dist/ui/build-progress-renderer.js +0 -326
- package/dist/ui/build-progress-renderer.js.map +0 -1
- package/dist/ui/build-summary.d.ts +0 -15
- package/dist/ui/build-summary.js +0 -26
- package/dist/ui/build-summary.js.map +0 -1
- package/dist/ui/install-event-bridge.js.map +0 -1
- package/dist/ui/install-progress-renderer.d.ts +0 -72
- package/dist/ui/install-progress-renderer.js +0 -297
- package/dist/ui/install-progress-renderer.js.map +0 -1
- package/dist/ui/orchestration-listr.d.ts +0 -59
- package/dist/ui/orchestration-listr.js +0 -227
- package/dist/ui/orchestration-listr.js.map +0 -1
- package/dist/ui/pino-bridge.js.map +0 -1
- package/dist/ui/pool-delete-event-bridge.js.map +0 -1
- package/dist/ui/pool-fill-event-bridge.js.map +0 -1
- package/dist/ui/pool-utils.js.map +0 -1
- package/dist/ui/renderer-utils.js.map +0 -1
- package/dist/ui/run-pool-delete.d.ts +0 -11
- package/dist/ui/run-pool-delete.js +0 -15
- package/dist/ui/run-pool-delete.js.map +0 -1
- package/dist/ui/run-pool-fill.d.ts +0 -15
- package/dist/ui/run-pool-fill.js +0 -19
- package/dist/ui/run-pool-fill.js.map +0 -1
- package/dist/ui/run-pool-list.js.map +0 -1
- package/dist/ui/run.d.ts +0 -12
- package/dist/ui/run.js +0 -7
- package/dist/ui/run.js.map +0 -1
- package/dist/ui/state/reducer.js.map +0 -1
- package/dist/ui/strategies/display-strategy.d.ts +0 -51
- package/dist/ui/strategies/display-strategy.js +0 -5
- package/dist/ui/strategies/display-strategy.js.map +0 -1
- package/dist/ui/strategies/index.d.ts +0 -14
- package/dist/ui/strategies/index.js +0 -24
- package/dist/ui/strategies/index.js.map +0 -1
- package/dist/ui/strategies/interactive.d.ts +0 -36
- package/dist/ui/strategies/interactive.js +0 -149
- package/dist/ui/strategies/interactive.js.map +0 -1
- package/dist/ui/strategies/plain.d.ts +0 -24
- package/dist/ui/strategies/plain.js +0 -72
- package/dist/ui/strategies/plain.js.map +0 -1
- package/dist/ui/strategies/silent.d.ts +0 -22
- package/dist/ui/strategies/silent.js +0 -25
- package/dist/ui/strategies/silent.js.map +0 -1
- package/dist/ui/strategies/validation-display-strategy.d.ts +0 -64
- package/dist/ui/strategies/validation-display-strategy.js +0 -109
- package/dist/ui/strategies/validation-display-strategy.js.map +0 -1
- package/dist/ui/theme.js.map +0 -1
- package/dist/ui/validation-progress-renderer.d.ts +0 -48
- package/dist/ui/validation-progress-renderer.js +0 -114
- package/dist/ui/validation-progress-renderer.js.map +0 -1
- /package/dist/ui/{install-event-bridge.d.ts → adapters/install-event-bridge.d.ts} +0 -0
- /package/dist/ui/{install-event-bridge.js → adapters/install-event-bridge.js} +0 -0
- /package/dist/ui/{pino-bridge.d.ts → adapters/pino-bridge.d.ts} +0 -0
- /package/dist/ui/{pino-bridge.js → adapters/pino-bridge.js} +0 -0
- /package/dist/ui/{pool-delete-event-bridge.d.ts → adapters/pool-delete-event-bridge.d.ts} +0 -0
- /package/dist/ui/{pool-delete-event-bridge.js → adapters/pool-delete-event-bridge.js} +0 -0
- /package/dist/ui/{pool-fill-event-bridge.d.ts → adapters/pool-fill-event-bridge.d.ts} +0 -0
- /package/dist/ui/{pool-fill-event-bridge.js → adapters/pool-fill-event-bridge.js} +0 -0
- /package/dist/ui/{run-pool-list.d.ts → renderers/run-pool-list.d.ts} +0 -0
- /package/dist/ui/state/{reducer.d.ts → orchestration-reducer.d.ts} +0 -0
- /package/dist/ui/{pool-utils.d.ts → utils/pool-utils.d.ts} +0 -0
- /package/dist/ui/{pool-utils.js → utils/pool-utils.js} +0 -0
- /package/dist/ui/{renderer-utils.js → utils/renderer-utils.js} +0 -0
- /package/dist/ui/{theme.d.ts → utils/theme.d.ts} +0 -0
- /package/dist/ui/{theme.js → utils/theme.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import SfpmCommand from '../../sfpm-command.js';
|
|
2
|
+
export default class ReleaseRun extends SfpmCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
'skip-version-check': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
execute(): Promise<any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ArtifactProvider, InstallOrchestrator, LifecycleEngine, ProjectService, readReleaseDefinition, } from '@b64hub/sfpm-core';
|
|
2
|
+
import { createTracer } from '@b64hub/sfpm-telemetry';
|
|
3
|
+
import { Args, Flags } from '@oclif/core';
|
|
4
|
+
import { Org } from '@salesforce/core';
|
|
5
|
+
import EventEmitter from 'node:events';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import SfpmCommand from '../../sfpm-command.js';
|
|
8
|
+
import { reconcileManifest } from '../../types/release.js';
|
|
9
|
+
import { attachInstallBridge } from '../../ui/adapters/install-event-bridge.js';
|
|
10
|
+
import { renderApp } from '../../ui/renderers/run-orchestrator.js';
|
|
11
|
+
import { resolveCliProjectDir } from '../../utils/project-dir.js';
|
|
12
|
+
export default class ReleaseRun extends SfpmCommand {
|
|
13
|
+
static args = {
|
|
14
|
+
file: Args.string({
|
|
15
|
+
description: 'Path to the release YAML file',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
static description = 'Run a release by installing packages from a release definition';
|
|
20
|
+
static examples = [
|
|
21
|
+
'<%= config.bin %> <%= command.id %> release/summer-2025.yaml -o my-sandbox',
|
|
22
|
+
'<%= config.bin %> <%= command.id %> release/summer-2025.yaml -o my-sandbox --json',
|
|
23
|
+
];
|
|
24
|
+
static flags = {
|
|
25
|
+
'skip-version-check': Flags.boolean({
|
|
26
|
+
description: 'Skip version mismatch checks (still validates packages are present)',
|
|
27
|
+
}),
|
|
28
|
+
'target-org': Flags.string({
|
|
29
|
+
char: 'o',
|
|
30
|
+
description: 'Target org username',
|
|
31
|
+
env: 'SF_TARGET_ORG',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,complexity
|
|
36
|
+
async execute() {
|
|
37
|
+
const { args, flags } = await this.parse(ReleaseRun);
|
|
38
|
+
const projectDir = resolveCliProjectDir();
|
|
39
|
+
// Step 1 & 2: Read and parse release definition
|
|
40
|
+
let definition;
|
|
41
|
+
try {
|
|
42
|
+
definition = readReleaseDefinition(path.resolve(args.file));
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
46
|
+
}
|
|
47
|
+
// Step 3: Extract package names
|
|
48
|
+
const names = definition.packages.map(p => p.name);
|
|
49
|
+
// Step 4: Create ArtifactProvider
|
|
50
|
+
const artifactProvider = new ArtifactProvider({ logger: this.sfpmLogger, packages: names, projectDir });
|
|
51
|
+
// Step 5: Create ProjectService and resolve graph
|
|
52
|
+
let projectService;
|
|
53
|
+
try {
|
|
54
|
+
projectService = await ProjectService.create(projectDir, artifactProvider);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
58
|
+
}
|
|
59
|
+
const projectConfig = projectService.getDefinitionProvider();
|
|
60
|
+
const projectGraph = projectService.getProjectGraph();
|
|
61
|
+
// Step 6: TRUST BOUNDARY GATE — reconcile manifest vs node_modules
|
|
62
|
+
const resolvedVersions = new Map(projectConfig.getAllPackageDefinitions().map(p => [p.name, p.version]));
|
|
63
|
+
const { mismatched, missing } = reconcileManifest(definition.packages, resolvedVersions, { skipVersionCheck: flags['skip-version-check'] });
|
|
64
|
+
if (missing.length > 0) {
|
|
65
|
+
const msg = [
|
|
66
|
+
`Release "${definition.release}" declares packages not present in node_modules: ${missing.join(', ')}.`,
|
|
67
|
+
"Run 'npm ci' (or 'npm install --no-save <name>@<version>') before 'release run'.",
|
|
68
|
+
].join(' ');
|
|
69
|
+
this.error(msg);
|
|
70
|
+
}
|
|
71
|
+
if (mismatched.length > 0) {
|
|
72
|
+
const msg = [
|
|
73
|
+
`Version mismatch for: ${mismatched.map(m => `${m.name} (expected ${m.expected}, found ${m.actual})`).join('; ')}.`,
|
|
74
|
+
'Re-install the declared versions or pass --skip-version-check.',
|
|
75
|
+
].join(' ');
|
|
76
|
+
this.error(msg);
|
|
77
|
+
}
|
|
78
|
+
// Step 7: Resolve all packages (includes transitive sfpm deps)
|
|
79
|
+
const resolvedPackages = projectConfig.getAllPackageNames();
|
|
80
|
+
// Step 8: Load sfpm config and lifecycle hooks
|
|
81
|
+
const sfpmConfig = projectService.getSfpmConfig();
|
|
82
|
+
const lifecycle = LifecycleEngine.stage('install');
|
|
83
|
+
for (const hooks of sfpmConfig.hooks ?? []) {
|
|
84
|
+
lifecycle.use(hooks);
|
|
85
|
+
}
|
|
86
|
+
// Step 9: Create target org
|
|
87
|
+
let targetOrg;
|
|
88
|
+
try {
|
|
89
|
+
targetOrg = await Org.create({ aliasOrUsername: flags['target-org'] });
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
93
|
+
}
|
|
94
|
+
// Step 10: Setup logging and UI
|
|
95
|
+
const mode = this.outputMode;
|
|
96
|
+
const isInk = mode !== 'json';
|
|
97
|
+
const uiBus = isInk ? new EventEmitter() : undefined;
|
|
98
|
+
const { logger: pinoLogger, logPath } = this.createRunLogger(uiBus);
|
|
99
|
+
// Step 11: Create orchestrator with manifest options
|
|
100
|
+
const orchestrator = InstallOrchestrator.forArtifact(targetOrg, projectConfig, projectGraph, {
|
|
101
|
+
force: definition.options?.force,
|
|
102
|
+
includeDependencies: definition.options?.includeDependencies ?? true,
|
|
103
|
+
regressionTest: definition.options?.regressionTest,
|
|
104
|
+
testLevel: definition.options?.testLevel,
|
|
105
|
+
unlocked: definition.options?.unlocked,
|
|
106
|
+
}, pinoLogger);
|
|
107
|
+
// Step 12: Setup ink UI bridge if needed
|
|
108
|
+
let inkInstance;
|
|
109
|
+
if (isInk) {
|
|
110
|
+
attachInstallBridge(orchestrator.installBus, orchestrator.orchestrationBus, uiBus);
|
|
111
|
+
inkInstance = renderApp(uiBus, { logPath, mode: mode === 'interactive' ? 'interactive' : 'plain' });
|
|
112
|
+
}
|
|
113
|
+
// Setup telemetry tracer
|
|
114
|
+
const tracer = createTracer({ serviceName: 'sfpm-cli' });
|
|
115
|
+
tracer.subscribe({ install: orchestrator.installBus, orchestration: orchestrator.orchestrationBus });
|
|
116
|
+
try {
|
|
117
|
+
// Run installation
|
|
118
|
+
const result = await orchestrator.installAll(resolvedPackages);
|
|
119
|
+
await tracer.shutdown();
|
|
120
|
+
// Let the app self-exit after rendering its terminal state
|
|
121
|
+
if (inkInstance) {
|
|
122
|
+
await inkInstance.waitUntilExit();
|
|
123
|
+
inkInstance = undefined;
|
|
124
|
+
}
|
|
125
|
+
if (!result.success) {
|
|
126
|
+
const failedNames = result.failedPackages.join(', ');
|
|
127
|
+
this.error(`Install failed for: ${failedNames}`, { exit: 2 });
|
|
128
|
+
}
|
|
129
|
+
return { release: definition.release, ...result };
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof Error) {
|
|
133
|
+
this.error(error.message, { exit: 2 });
|
|
134
|
+
}
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
inkInstance?.unmount();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/release/run.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,GAC9F,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAC;AACrC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,WAAW,MAAM,uBAA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OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAAC,CAAC,CAAC;QAEnG,IAAI,CAAC;YACH,mBAAmB;YACnB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;YAE/D,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;YAExB,2DAA2D;YAC3D,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,WAAW,CAAC,aAAa,EAAE,CAAC;gBAClC,WAAW,GAAG,SAAS,CAAC;YAC1B,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrD,IAAI,CAAC,KAAK,CAAC,uBAAuB,WAAW,EAAE,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC;YAC9D,CAAC;YAED,OAAO,EAAC,OAAO,EAAE,UAAW,CAAC,OAAO,EAAE,GAAG,MAAM,EAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC;YACvC,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,OAAO,EAAE,CAAC;QACzB,CAAC;IACH,CAAC"}
|
package/dist/logger.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { mkdirSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import pino from 'pino';
|
|
5
|
-
import { createPinoBridge } from './ui/pino-bridge.js';
|
|
5
|
+
import { createPinoBridge } from './ui/adapters/pino-bridge.js';
|
|
6
6
|
import { resolveCliProjectDir } from './utils/project-dir.js';
|
|
7
7
|
export class CliLoggerFactory {
|
|
8
8
|
static instance;
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,gBAAgB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAmC5D,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,QAAQ,CAAyB;IAEhD;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,MAAiB,EAAE,OAA+B;QAC7D,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAA0B;QACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC;QAEvC,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC9B,gBA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CAAC,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/sfpm-command.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from 'node:events';
|
|
2
2
|
import { Command } from '@oclif/core';
|
|
3
|
-
import type { OutputMode } from './ui/renderer-utils.js';
|
|
3
|
+
import type { OutputMode } from './ui/utils/renderer-utils.js';
|
|
4
4
|
import { CliLogger } from './logger.js';
|
|
5
5
|
/**
|
|
6
6
|
* Standard JSON envelope emitted by every command in `--json` mode.
|
|
@@ -28,6 +28,14 @@ export default abstract class SfpmCommand extends Command {
|
|
|
28
28
|
protected outputMode: OutputMode;
|
|
29
29
|
/** Pino-backed logger for diagnostic output (writes to stderr). */
|
|
30
30
|
protected sfpmLogger: CliLogger;
|
|
31
|
+
/**
|
|
32
|
+
* Directory `writeTurboResult` writes `dist/<command>-result.json` into.
|
|
33
|
+
* `process.cwd()` is only the package directory when turbo itself invokes
|
|
34
|
+
* the per-package npm script — a direct `sfpm build <pkg> --turbo` from
|
|
35
|
+
* the repo root has cwd at the project root instead. Commands that support
|
|
36
|
+
* `--turbo` must set this to the resolved package directory in `execute()`.
|
|
37
|
+
*/
|
|
38
|
+
protected turboResultDir?: string;
|
|
31
39
|
/**
|
|
32
40
|
* Create a run-scoped multistream logger for the orchestrator.
|
|
33
41
|
* Always writes full-fidelity JSON to `.sfpm/logs/<runId>.log`.
|
|
@@ -49,4 +57,12 @@ export default abstract class SfpmCommand extends Command {
|
|
|
49
57
|
*/
|
|
50
58
|
run(): Promise<any>;
|
|
51
59
|
private logHeader;
|
|
60
|
+
/**
|
|
61
|
+
* `--turbo` mode: persist the JSON envelope to `dist/<command>-result.json`.
|
|
62
|
+
* Written here — after `execute()` has fully returned — so it lands after
|
|
63
|
+
* any dist cleanup the command does mid-run, instead of relying on a shell
|
|
64
|
+
* redirect that opens the file before the build even starts (and loses it
|
|
65
|
+
* when the build empties `dist/`).
|
|
66
|
+
*/
|
|
67
|
+
private writeTurboResult;
|
|
52
68
|
}
|
package/dist/sfpm-command.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { DIST_DIR } from '@b64hub/sfpm-core';
|
|
1
2
|
import { Command, Flags } from '@oclif/core';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import gradient from 'gradient-string';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
4
7
|
import { CliLoggerFactory } from './logger.js';
|
|
5
8
|
import { suppressStderr } from './utils/suppress.js';
|
|
6
9
|
const LOG_LEVELS = ['trace', 'debug', 'info', 'warn', 'error'];
|
|
@@ -54,6 +57,14 @@ export default class SfpmCommand extends Command {
|
|
|
54
57
|
outputMode;
|
|
55
58
|
/** Pino-backed logger for diagnostic output (writes to stderr). */
|
|
56
59
|
sfpmLogger;
|
|
60
|
+
/**
|
|
61
|
+
* Directory `writeTurboResult` writes `dist/<command>-result.json` into.
|
|
62
|
+
* `process.cwd()` is only the package directory when turbo itself invokes
|
|
63
|
+
* the per-package npm script — a direct `sfpm build <pkg> --turbo` from
|
|
64
|
+
* the repo root has cwd at the project root instead. Commands that support
|
|
65
|
+
* `--turbo` must set this to the resolved package directory in `execute()`.
|
|
66
|
+
*/
|
|
67
|
+
turboResultDir;
|
|
57
68
|
/**
|
|
58
69
|
* Create a run-scoped multistream logger for the orchestrator.
|
|
59
70
|
* Always writes full-fidelity JSON to `.sfpm/logs/<runId>.log`.
|
|
@@ -80,40 +91,46 @@ export default class SfpmCommand extends Command {
|
|
|
80
91
|
level: logLevel,
|
|
81
92
|
pretty: this.outputMode !== 'json',
|
|
82
93
|
});
|
|
83
|
-
if (this.outputMode
|
|
94
|
+
if (this.outputMode === 'interactive') {
|
|
84
95
|
this.logHeader();
|
|
85
96
|
}
|
|
86
97
|
try {
|
|
87
|
-
const cap = this.outputMode === '
|
|
98
|
+
const cap = this.outputMode === 'json' ? null : suppressStderr();
|
|
88
99
|
const result = await this.execute().finally(() => {
|
|
89
100
|
const captured = cap?.release() ?? '';
|
|
90
101
|
if (captured)
|
|
91
102
|
process.stderr.write(captured);
|
|
92
103
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
envelope.result = result;
|
|
101
|
-
}
|
|
102
|
-
this.log(JSON.stringify(envelope));
|
|
104
|
+
const envelope = {
|
|
105
|
+
command: this.id ?? 'unknown',
|
|
106
|
+
duration: Date.now() - startTime,
|
|
107
|
+
status: 'success',
|
|
108
|
+
};
|
|
109
|
+
if (result !== undefined) {
|
|
110
|
+
envelope.result = result;
|
|
103
111
|
}
|
|
112
|
+
// stdout format follows outputMode (json vs the ink UI); the turbo
|
|
113
|
+
// result file is orthogonal — `--turbo` needs it regardless of whether
|
|
114
|
+
// `--json` was also passed, so CI can render plain/interactive progress
|
|
115
|
+
// while still handing the aggregator a file to read.
|
|
116
|
+
if (this.outputMode === 'json')
|
|
117
|
+
this.log(JSON.stringify(envelope));
|
|
118
|
+
if (flags.turbo)
|
|
119
|
+
this.writeTurboResult(envelope);
|
|
104
120
|
return result;
|
|
105
121
|
}
|
|
106
122
|
catch (error) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
124
|
+
const envelope = {
|
|
125
|
+
command: this.id ?? 'unknown',
|
|
126
|
+
duration: Date.now() - startTime,
|
|
127
|
+
error: { message: err.message },
|
|
128
|
+
status: 'error',
|
|
129
|
+
};
|
|
130
|
+
if (this.outputMode === 'json')
|
|
115
131
|
this.log(JSON.stringify(envelope));
|
|
116
|
-
|
|
132
|
+
if (flags.turbo)
|
|
133
|
+
this.writeTurboResult(envelope);
|
|
117
134
|
throw error;
|
|
118
135
|
}
|
|
119
136
|
}
|
|
@@ -124,5 +141,22 @@ export default class SfpmCommand extends Command {
|
|
|
124
141
|
+ chalk.gray(`${this.config.version}`);
|
|
125
142
|
this.log(header);
|
|
126
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* `--turbo` mode: persist the JSON envelope to `dist/<command>-result.json`.
|
|
146
|
+
* Written here — after `execute()` has fully returned — so it lands after
|
|
147
|
+
* any dist cleanup the command does mid-run, instead of relying on a shell
|
|
148
|
+
* redirect that opens the file before the build even starts (and loses it
|
|
149
|
+
* when the build empties `dist/`).
|
|
150
|
+
*/
|
|
151
|
+
writeTurboResult(envelope) {
|
|
152
|
+
try {
|
|
153
|
+
const dir = path.join(this.turboResultDir ?? process.cwd(), DIST_DIR);
|
|
154
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
155
|
+
fs.writeFileSync(path.join(dir, `${this.id ?? 'unknown'}-result.json`), JSON.stringify(envelope));
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.sfpmLogger?.warn(`Failed to write turbo result file: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
127
161
|
}
|
|
128
162
|
//# sourceMappingURL=sfpm-command.js.map
|
package/dist/sfpm-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sfpm-command.js","sourceRoot":"","sources":["../src/sfpm-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sfpm-command.js","sourceRoot":"","sources":["../src/sfpm-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAgB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAY,gBAAg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combines a package's identity with its keywords, which double as sfpm's
|
|
4
|
+
* package tags (an arbitrary, user-assigned label — no reserved prefix,
|
|
5
|
+
* no enforced vocabulary), for tag-based filtering.
|
|
6
|
+
*/
|
|
7
|
+
export interface WorkspaceCandidate {
|
|
8
|
+
/** Absolute path to the package directory */
|
|
9
|
+
dir: string;
|
|
10
|
+
/** Keywords from package.json — the storage field backing sfpm's package tags */
|
|
11
|
+
keywords: string[];
|
|
12
|
+
/** Package name (scoped or unscoped) */
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A selection mode: which strategy to use for picking packages.
|
|
17
|
+
*/
|
|
18
|
+
export type SelectionMode = {
|
|
19
|
+
dir: string;
|
|
20
|
+
kind: 'path';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'all';
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'explicit';
|
|
25
|
+
names: string[];
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'tag';
|
|
28
|
+
tags: string[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Determine the package selection mode from supplied flags.
|
|
32
|
+
*
|
|
33
|
+
* Ensures exactly one selection strategy is active; throws if multiple are specified.
|
|
34
|
+
*
|
|
35
|
+
* @param names - Explicitly named packages from argv
|
|
36
|
+
* @param tags - Package tags specified via --tag (matched against package.json keywords)
|
|
37
|
+
* @param dir - Directory path specified via --path
|
|
38
|
+
* @returns SelectionMode configured for the active strategy
|
|
39
|
+
* @throws Error if more than one selection mode is active
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveSelectionMode(names: string[], tags?: string[], dir?: string): SelectionMode;
|
|
42
|
+
/**
|
|
43
|
+
* Decide whether `release create` was invoked with no selection or naming
|
|
44
|
+
* signal at all — i.e. bare `sfpm release create`, which should launch the
|
|
45
|
+
* interactive guided walkthrough instead of failing on a missing --name.
|
|
46
|
+
*
|
|
47
|
+
* @param argv - Positional package name arguments
|
|
48
|
+
* @param flags - The subset of flags that count as a selection/naming signal
|
|
49
|
+
* @param flags.name - The --name flag value, if supplied
|
|
50
|
+
* @param flags.path - The --path flag value, if supplied
|
|
51
|
+
* @param flags.tag - The --tag flag value(s), if supplied
|
|
52
|
+
* @returns true when nothing was supplied and the wizard should run
|
|
53
|
+
*/
|
|
54
|
+
export declare function isBareInvocation(argv: string[], flags: {
|
|
55
|
+
name?: string;
|
|
56
|
+
path?: string;
|
|
57
|
+
tag?: string[];
|
|
58
|
+
}): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Collect the distinct package tags (package.json keywords) present across
|
|
61
|
+
* a set of workspace candidates, sorted for stable prompt/display order.
|
|
62
|
+
*
|
|
63
|
+
* @param candidates - Available workspace packages with metadata
|
|
64
|
+
* @returns Sorted array of distinct tag values
|
|
65
|
+
*/
|
|
66
|
+
export declare function getDistinctTags(candidates: WorkspaceCandidate[]): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Select package names from candidates using the specified selection mode.
|
|
69
|
+
*
|
|
70
|
+
* @param candidates - Available workspace packages with metadata
|
|
71
|
+
* @param mode - The selection strategy to apply
|
|
72
|
+
* @returns Array of selected package names
|
|
73
|
+
*/
|
|
74
|
+
export declare function selectPackageNames(candidates: WorkspaceCandidate[], mode: SelectionMode): string[];
|
|
75
|
+
/**
|
|
76
|
+
* Version mismatch detail in reconciliation.
|
|
77
|
+
*/
|
|
78
|
+
export interface ReconcileMismatch {
|
|
79
|
+
actual: string;
|
|
80
|
+
expected: string;
|
|
81
|
+
name: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Result of manifest reconciliation.
|
|
85
|
+
*/
|
|
86
|
+
export interface ReconcileResult {
|
|
87
|
+
mismatched: ReconcileMismatch[];
|
|
88
|
+
missing: string[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Reconcile a release manifest against what's currently in node_modules.
|
|
92
|
+
*
|
|
93
|
+
* Checks for:
|
|
94
|
+
* - Missing packages (declared but not installed)
|
|
95
|
+
* - Version mismatches (unless --skip-version-check is set)
|
|
96
|
+
*
|
|
97
|
+
* Uses exact string comparison, not semver.eq — a release pins an exact artifact.
|
|
98
|
+
*
|
|
99
|
+
* @param declared - Packages and versions from the release manifest
|
|
100
|
+
* @param resolved - Packages and versions currently in node_modules (from ArtifactProvider)
|
|
101
|
+
* @param options - Control behavior
|
|
102
|
+
* @param options.skipVersionCheck - Skip version mismatch checks (still validates packages are present)
|
|
103
|
+
* @returns Reconciliation result with missing and mismatched arrays
|
|
104
|
+
*/
|
|
105
|
+
export declare function reconcileManifest(declared: {
|
|
106
|
+
name: string;
|
|
107
|
+
version: string;
|
|
108
|
+
}[], resolved: Map<string, string>, options?: {
|
|
109
|
+
skipVersionCheck?: boolean;
|
|
110
|
+
}): ReconcileResult;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Determine the package selection mode from supplied flags.
|
|
4
|
+
*
|
|
5
|
+
* Ensures exactly one selection strategy is active; throws if multiple are specified.
|
|
6
|
+
*
|
|
7
|
+
* @param names - Explicitly named packages from argv
|
|
8
|
+
* @param tags - Package tags specified via --tag (matched against package.json keywords)
|
|
9
|
+
* @param dir - Directory path specified via --path
|
|
10
|
+
* @returns SelectionMode configured for the active strategy
|
|
11
|
+
* @throws Error if more than one selection mode is active
|
|
12
|
+
*/
|
|
13
|
+
export function resolveSelectionMode(names, tags, dir) {
|
|
14
|
+
// Identify which modes are active
|
|
15
|
+
const active = [];
|
|
16
|
+
if (names.length > 0)
|
|
17
|
+
active.push('packages');
|
|
18
|
+
if (tags?.length)
|
|
19
|
+
active.push('--tag');
|
|
20
|
+
if (dir)
|
|
21
|
+
active.push('--path');
|
|
22
|
+
if (active.length > 1) {
|
|
23
|
+
throw new Error(`Select packages by exactly one of: package names, --tag, or --path (got ${active.join(', ')}).`);
|
|
24
|
+
}
|
|
25
|
+
if (names.length > 0)
|
|
26
|
+
return { kind: 'explicit', names };
|
|
27
|
+
if (tags?.length)
|
|
28
|
+
return { kind: 'tag', tags };
|
|
29
|
+
if (dir)
|
|
30
|
+
return { dir, kind: 'path' };
|
|
31
|
+
return { kind: 'all' };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if a child directory is within a parent directory.
|
|
35
|
+
*
|
|
36
|
+
* Both paths are resolved to absolute form.
|
|
37
|
+
* Returns true if child is exactly parent or a descendant of parent (not a sibling).
|
|
38
|
+
*
|
|
39
|
+
* @param parent - Parent directory path
|
|
40
|
+
* @param child - Child directory path
|
|
41
|
+
* @returns true if child is parent or within parent
|
|
42
|
+
*/
|
|
43
|
+
function isWithin(parent, child) {
|
|
44
|
+
const absParent = path.resolve(parent);
|
|
45
|
+
const absChild = path.resolve(child);
|
|
46
|
+
// Exact match
|
|
47
|
+
if (absParent === absChild)
|
|
48
|
+
return true;
|
|
49
|
+
const rel = path.relative(absParent, absChild);
|
|
50
|
+
// rel starts with '..' => child is outside parent
|
|
51
|
+
// isAbsolute(rel) => child is on a different drive (windows)
|
|
52
|
+
// otherwise, rel is a relative path from parent to child
|
|
53
|
+
return !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Decide whether `release create` was invoked with no selection or naming
|
|
57
|
+
* signal at all — i.e. bare `sfpm release create`, which should launch the
|
|
58
|
+
* interactive guided walkthrough instead of failing on a missing --name.
|
|
59
|
+
*
|
|
60
|
+
* @param argv - Positional package name arguments
|
|
61
|
+
* @param flags - The subset of flags that count as a selection/naming signal
|
|
62
|
+
* @param flags.name - The --name flag value, if supplied
|
|
63
|
+
* @param flags.path - The --path flag value, if supplied
|
|
64
|
+
* @param flags.tag - The --tag flag value(s), if supplied
|
|
65
|
+
* @returns true when nothing was supplied and the wizard should run
|
|
66
|
+
*/
|
|
67
|
+
export function isBareInvocation(argv, flags) {
|
|
68
|
+
return argv.length === 0 && !flags.tag?.length && !flags.path && !flags.name;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Collect the distinct package tags (package.json keywords) present across
|
|
72
|
+
* a set of workspace candidates, sorted for stable prompt/display order.
|
|
73
|
+
*
|
|
74
|
+
* @param candidates - Available workspace packages with metadata
|
|
75
|
+
* @returns Sorted array of distinct tag values
|
|
76
|
+
*/
|
|
77
|
+
export function getDistinctTags(candidates) {
|
|
78
|
+
const tags = new Set();
|
|
79
|
+
for (const candidate of candidates) {
|
|
80
|
+
for (const keyword of candidate.keywords) {
|
|
81
|
+
tags.add(keyword);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [...tags].sort();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Select package names from candidates using the specified selection mode.
|
|
88
|
+
*
|
|
89
|
+
* @param candidates - Available workspace packages with metadata
|
|
90
|
+
* @param mode - The selection strategy to apply
|
|
91
|
+
* @returns Array of selected package names
|
|
92
|
+
*/
|
|
93
|
+
export function selectPackageNames(candidates, mode) {
|
|
94
|
+
switch (mode.kind) {
|
|
95
|
+
case 'all': {
|
|
96
|
+
return candidates.map(c => c.name);
|
|
97
|
+
}
|
|
98
|
+
case 'explicit': {
|
|
99
|
+
return mode.names;
|
|
100
|
+
}
|
|
101
|
+
case 'path': {
|
|
102
|
+
return candidates.filter(c => isWithin(mode.dir, c.dir)).map(c => c.name);
|
|
103
|
+
}
|
|
104
|
+
case 'tag': {
|
|
105
|
+
return candidates
|
|
106
|
+
.filter(c => mode.tags.some(t => c.keywords.includes(t)))
|
|
107
|
+
.map(c => c.name);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Reconcile a release manifest against what's currently in node_modules.
|
|
113
|
+
*
|
|
114
|
+
* Checks for:
|
|
115
|
+
* - Missing packages (declared but not installed)
|
|
116
|
+
* - Version mismatches (unless --skip-version-check is set)
|
|
117
|
+
*
|
|
118
|
+
* Uses exact string comparison, not semver.eq — a release pins an exact artifact.
|
|
119
|
+
*
|
|
120
|
+
* @param declared - Packages and versions from the release manifest
|
|
121
|
+
* @param resolved - Packages and versions currently in node_modules (from ArtifactProvider)
|
|
122
|
+
* @param options - Control behavior
|
|
123
|
+
* @param options.skipVersionCheck - Skip version mismatch checks (still validates packages are present)
|
|
124
|
+
* @returns Reconciliation result with missing and mismatched arrays
|
|
125
|
+
*/
|
|
126
|
+
export function reconcileManifest(declared, resolved, options) {
|
|
127
|
+
const mismatched = [];
|
|
128
|
+
const missing = [];
|
|
129
|
+
for (const { name, version } of declared) {
|
|
130
|
+
const actual = resolved.get(name);
|
|
131
|
+
if (actual === undefined) {
|
|
132
|
+
missing.push(name);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Only check version mismatch if not explicitly skipped
|
|
136
|
+
if (!options?.skipVersionCheck && actual !== version) {
|
|
137
|
+
mismatched.push({ actual, expected: version, name });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { mismatched, missing };
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.js","sourceRoot":"","sources":["../../src/types/release.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAsB5B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAe,EAAE,IAAe,EAAE,GAAY;IACjF,kCAAkC;IAClC,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7C,IAAI,IAAI,EAAE,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI,GAAG;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE9B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,2E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