@sparkelf/dsh-plus 0.2.9-alpha.105 → 0.2.9-alpha.108

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/lib/apply.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as runApply, n as parseOfficialWorkspacePackages, r as resolvePatchPackageNames, t as materializeOfficialPackageScope } from "./apply-c_7SZFSh.js";
2
- export { materializeOfficialPackageScope, parseOfficialWorkspacePackages, resolvePatchPackageNames, runApply };
1
+ import { a as runApply, i as resolvePatchPackageNames, n as materializeOfficialPackageScope, o as sourcePatchsetDigest, r as parseOfficialWorkspacePackages, s as writeBuildMarker, t as assertPrebuiltSource } from "./apply-B1AtqWbU.js";
2
+ export { assertPrebuiltSource, materializeOfficialPackageScope, parseOfficialWorkspacePackages, resolvePatchPackageNames, runApply, sourcePatchsetDigest, writeBuildMarker };
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as assertRedirectsPublished, c as writeProfileCompatibility, i as runApply, l as writeProfileProjection, o as projectEdition, s as readDistributionFacts, u as readPatchSet } from "./apply-c_7SZFSh.js";
2
+ import { a as runApply, c as assertRedirectsPublished, d as writeProfileCompatibility, f as writeProfileProjection, l as projectEdition, p as readPatchSet, u as readDistributionFacts } from "./apply-B1AtqWbU.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -4,6 +4,38 @@ export interface OfficialWorkspacePackage {
4
4
  name: string;
5
5
  directory: string;
6
6
  }
7
+ /** One npm package patch selected for the installed graph. */
8
+ export interface SelectedNpmPatch {
9
+ id: string;
10
+ patchPackage: {
11
+ name: string;
12
+ version: string;
13
+ };
14
+ file: string;
15
+ absoluteFile: string;
16
+ target: {
17
+ kind: 'npm';
18
+ name: string;
19
+ version: string;
20
+ };
21
+ }
22
+ /** One official-source patch selected for the exact DSH checkout. */
23
+ export interface SelectedSourcePatch {
24
+ id: string;
25
+ patchPackage: {
26
+ name: string;
27
+ version: string;
28
+ };
29
+ file: string;
30
+ absoluteFile: string;
31
+ target: {
32
+ kind: 'dsh-source';
33
+ baseRevision: string;
34
+ };
35
+ alreadyApplied: boolean;
36
+ }
37
+ /** A patch the installed distribution selects for this DSH version and package graph. */
38
+ export type SelectedPatch = SelectedNpmPatch | SelectedSourcePatch;
7
39
  /**
8
40
  * Names of distribution dependencies that carry `dshPatch` variants.
9
41
  *
@@ -17,6 +49,42 @@ export interface OfficialWorkspacePackage {
17
49
  * @returns Patch-carrier package names; empty when the distribution ships only source patches.
18
50
  */
19
51
  export declare function resolvePatchPackageNames(plus: Record<string, unknown>): string[];
52
+ /**
53
+ * Digest of the source half of a patch selection.
54
+ *
55
+ * The row set matches `scripts/apply-plus-preflight.sh`: one row per selected `dsh-source`
56
+ * patch with its id, distribution-relative file, base revision, and payload bytes, sorted by
57
+ * id. Hashing the sorted JSON keeps the digest independent of selection order.
58
+ *
59
+ * @param patches - Selected patches, after or before materialization; payload bytes are equal.
60
+ * @returns Lowercase hex SHA-256 of the canonical row list.
61
+ */
62
+ export declare function sourcePatchsetDigest(patches: readonly SelectedPatch[]): string;
63
+ /**
64
+ * Write the build marker after `build:official` succeeds.
65
+ * @param dshRoot - Built official checkout.
66
+ * @param sourceRevision - Its `git rev-parse HEAD`, already checked against the distribution.
67
+ * @param patches - Selected patches whose source half the build now contains.
68
+ * @returns Absolute marker path.
69
+ */
70
+ export declare function writeBuildMarker(dshRoot: string, sourceRevision: string, patches: readonly SelectedPatch[]): string;
71
+ /**
72
+ * Refuse `--skip-build` unless the checkout still carries the exact prebuilt result.
73
+ *
74
+ * Four facts have to agree: every selected source patch is already applied, the marker
75
+ * belongs to the checkout revision, the marker's digest covers the same patch bytes the
76
+ * distribution selects now, and the build entry points exist. Skipping any one of them
77
+ * would ship stale `lib/` output under a patch set that no longer matches it.
78
+ *
79
+ * When the source phase pruned `.git`, the marker is the only revision record left; the caller
80
+ * passes the revision it already resolved from that marker and the distribution base.
81
+ *
82
+ * @param dshRoot - Official checkout the profile links into.
83
+ * @param patches - Selected patches, materialized into the profile.
84
+ * @param pendingFiles - Selected source patch payloads git still reports as unapplied.
85
+ * @param expectedRevision - Revision `prepareSelection` verified against the official base.
86
+ */
87
+ export declare function assertPrebuiltSource(dshRoot: string, patches: readonly SelectedPatch[], pendingFiles: readonly string[], expectedRevision?: string): void;
20
88
  /**
21
89
  * Parse pnpm's workspace roster into exact official package directories.
22
90
  * @param dshRoot - exact official DSH checkout root.
@@ -33,7 +101,12 @@ export declare function parseOfficialWorkspacePackages(dshRoot: string, stdout:
33
101
  export declare function materializeOfficialPackageScope(profileDirectory: string, cliScope: string, workspacePackages: readonly OfficialWorkspacePackage[]): void;
34
102
  /**
35
103
  * Apply the installed Plus distribution metadata from a DSH profile directory.
36
- * @param argv - Explicit `apply --dsh-root <path>` command arguments.
104
+ *
105
+ * A full run owns both phases: source patches, the official build and its marker, and the
106
+ * profile install/link. `--skip-build` runs the profile half only and verifies the marker a
107
+ * previous full run left in the checkout.
108
+ *
109
+ * @param argv - `apply --dsh-root <path>` plus optional `--skip-build`.
37
110
  */
38
111
  export declare function runApply(argv: readonly string[]): void;
39
112
  //# sourceMappingURL=apply.d.ts.map
@@ -1,6 +1,7 @@
1
1
  /** Materialize the Plus distribution's independent patch packages without Desktop. */
2
2
  import { spawnSync } from 'node:child_process';
3
- import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync, } from 'node:fs';
3
+ import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, symlinkSync, writeFileSync, } from 'node:fs';
4
+ import { createHash } from 'node:crypto';
4
5
  import { createRequire } from 'node:module';
5
6
  import { readPatchSet } from "./patch-set.js";
6
7
  import { writeProfileCompatibility } from "./manifest.js";
@@ -9,6 +10,8 @@ import { tmpdir } from 'node:os';
9
10
  import { satisfies, valid, validRange } from 'semver';
10
11
  import { parseDocument } from 'yaml';
11
12
  const FORMAT_VERSION = 1;
13
+ /** Marker proving the source tree was built from the currently selected source patch set. */
14
+ const BUILD_MARKER = '.dataops-official-build.json';
12
15
  function isSelectedNpmPatch(patch) {
13
16
  return patch.target.kind === 'npm';
14
17
  }
@@ -178,12 +181,64 @@ function preflightSourcePatches(root, files) {
178
181
  rmSync(directory, { recursive: true, force: true });
179
182
  }
180
183
  }
181
- function requireSourceBase(root, baseRevision) {
182
- const checkoutRevision = requireString(git(root, ['rev-parse', 'HEAD']), 'DSH checkout revision');
183
- if (checkoutRevision !== baseRevision) {
184
- throw new Error('DSH checkout must be exact official base ' + baseRevision + ', found ' + checkoutRevision);
184
+ /**
185
+ * Read the build marker a source phase left in the checkout.
186
+ * @param root - Official checkout that may carry the marker.
187
+ * @returns The validated marker, or `undefined` when the phase never wrote one.
188
+ */
189
+ function readBuildMarker(root) {
190
+ const markerPath = resolve(root, BUILD_MARKER);
191
+ if (!existsSync(markerPath))
192
+ return undefined;
193
+ const parsed = JSON.parse(readFileSync(markerPath, 'utf8'));
194
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
195
+ throw new Error(markerPath + ' must be a JSON object');
196
+ }
197
+ const marker = parsed;
198
+ const sourceRevision = requireString(marker.sourceRevision, markerPath + ' sourceRevision');
199
+ if (!/^[0-9a-f]{40}$/.test(sourceRevision)) {
200
+ throw new Error(markerPath + ' sourceRevision must be a 40-hex commit id, found ' + sourceRevision);
201
+ }
202
+ return {
203
+ sourceRevision,
204
+ patchsetDigest: requireString(marker.patchsetDigest, markerPath + ' patchsetDigest'),
205
+ builtAt: requireString(marker.builtAt, markerPath + ' builtAt'),
206
+ };
207
+ }
208
+ /**
209
+ * Resolve the checkout revision the current phase may operate on.
210
+ *
211
+ * A full apply needs `.git` because it applies patches and builds in that checkout. A
212
+ * `--skip-build` phase may run after the source phase pruned `.git`; there the build marker is the
213
+ * only remaining record of the built revision, so it must name the distribution's official base.
214
+ *
215
+ * @param root - Official checkout the profile links into.
216
+ * @param baseRevision - Exact official base the installed distribution declares.
217
+ * @param skipBuild - Whether the caller runs the profile half only.
218
+ * @returns The checkout revision both halves agree on.
219
+ */
220
+ function requireSourceBase(root, baseRevision, skipBuild) {
221
+ if (existsSync(resolve(root, '.git'))) {
222
+ const checkoutRevision = requireString(git(root, ['rev-parse', 'HEAD']), 'DSH checkout revision');
223
+ if (checkoutRevision !== baseRevision) {
224
+ throw new Error('DSH checkout must be exact official base ' + baseRevision + ', found ' + checkoutRevision);
225
+ }
226
+ return checkoutRevision;
227
+ }
228
+ if (!skipBuild) {
229
+ throw new Error('DSH checkout at ' + root + ' has no .git; run --phase source before a full apply');
185
230
  }
186
- return checkoutRevision;
231
+ const marker = readBuildMarker(root);
232
+ if (marker === undefined) {
233
+ throw new Error('DSH checkout at ' + root + ' has no .git and no ' + BUILD_MARKER
234
+ + '; run --phase source first');
235
+ }
236
+ if (marker.sourceRevision !== baseRevision) {
237
+ throw new Error('DSH checkout marker revision ' + marker.sourceRevision
238
+ + ' is not the official base ' + baseRevision);
239
+ }
240
+ console.log('[dsh-plus] checkout has no .git; the build marker authenticates ' + marker.sourceRevision);
241
+ return marker.sourceRevision;
187
242
  }
188
243
  /**
189
244
  * Names of distribution dependencies that carry `dshPatch` variants.
@@ -259,7 +314,7 @@ function patchSetVariants(distribution) {
259
314
  }));
260
315
  }
261
316
  // 先验证official source,再物化Plus声明的profile依赖,避免source不匹配时改动用户profile。
262
- function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
317
+ function prepareSelection(distributionDirectory, profileDirectory, dshRoot, skipBuild) {
263
318
  const distributionManifest = readJsonObject(resolve(distributionDirectory, 'package.json'), 'Plus distribution manifest');
264
319
  const distributionName = requireString(distributionManifest.name, 'Plus distribution name');
265
320
  const distributionVersion = requireVersion(distributionManifest.version, 'Plus distribution version');
@@ -306,7 +361,7 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
306
361
  if (!satisfies(dshVersion, dshRange, { includePrerelease: true })) {
307
362
  throw new Error(distributionName + '@' + distributionVersion + ' requires DSH ' + dshRange + ', found ' + dshVersion);
308
363
  }
309
- const checkoutRevision = requireSourceBase(dshRoot, baseRevision);
364
+ const checkoutRevision = requireSourceBase(dshRoot, baseRevision, skipBuild);
310
365
  // Legacy tarballs declare `dshPlus.patchPackages` (dshPatch carrier packages); the current
311
366
  // distribution declares `dshPlus.patchSet` with the patch files inside the Plus package.
312
367
  const variants = plus.patchPackages === undefined
@@ -325,18 +380,23 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
325
380
  }
326
381
  const sourceStates = new Map();
327
382
  const orderedGroups = [...groups].sort(([left], [right]) => left.localeCompare(right));
328
- for (const [, variants] of orderedGroups) {
329
- for (const variant of variants) {
330
- if (variant.target.kind !== 'dsh-source'
331
- || variant.target.baseRevision !== baseRevision
332
- || !satisfies(dshVersion, variant.dsh, { includePrerelease: true }))
333
- continue;
334
- const file = resolvePatchFile(variant.patchPackage.directory, variant.file);
335
- sourceStates.set(file.absoluteFile, sourcePatchState(dshRoot, file.absoluteFile));
383
+ // `--skip-build` authenticates the source result with the build marker, not with per-patch
384
+ // reverse application: the build's own cleanup removes tests/docs that some patches touch, so
385
+ // `git apply --check` can no longer classify those patches even though the built tree is exact.
386
+ if (!skipBuild) {
387
+ for (const [, variants] of orderedGroups) {
388
+ for (const variant of variants) {
389
+ if (variant.target.kind !== 'dsh-source'
390
+ || variant.target.baseRevision !== baseRevision
391
+ || !satisfies(dshVersion, variant.dsh, { includePrerelease: true }))
392
+ continue;
393
+ const file = resolvePatchFile(variant.patchPackage.directory, variant.file);
394
+ sourceStates.set(file.absoluteFile, sourcePatchState(dshRoot, file.absoluteFile));
395
+ }
336
396
  }
397
+ const pendingSourceFiles = [...sourceStates].flatMap(([file, state]) => state === 'pending' ? [file] : []);
398
+ preflightSourcePatches(dshRoot, pendingSourceFiles);
337
399
  }
338
- const pendingSourceFiles = [...sourceStates].flatMap(([file, state]) => state === 'pending' ? [file] : []);
339
- preflightSourcePatches(dshRoot, pendingSourceFiles);
340
400
  writeProfileRequirements(profileDirectory, profileDependencySpecs, allowBuilds);
341
401
  writeProfileCompatibility(profileDirectory, compatibilityExemptions, dshVersion);
342
402
  runPnpm(profileDirectory, ['install', '--no-frozen-lockfile'], 'pnpm install Plus profile dependencies');
@@ -367,7 +427,7 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
367
427
  file: file.relativeFile,
368
428
  absoluteFile: file.absoluteFile,
369
429
  target: { kind: 'dsh-source', baseRevision },
370
- alreadyApplied: sourceStates.get(file.absoluteFile) === 'applied',
430
+ alreadyApplied: skipBuild || sourceStates.get(file.absoluteFile) === 'applied',
371
431
  }];
372
432
  }
373
433
  const targetDirectory = variant.target.name in profileDependencySpecs ? profileDirectory : distributionDirectory;
@@ -403,6 +463,7 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
403
463
  runtimePackages,
404
464
  profileDependencies,
405
465
  allowBuilds,
466
+ sourceRevision: checkoutRevision,
406
467
  lock: {
407
468
  formatVersion: FORMAT_VERSION,
408
469
  distribution: { name: distributionName, version: distributionVersion },
@@ -638,7 +699,97 @@ function pendingSourcePatchFiles(patches) {
638
699
  ? [patch.absoluteFile]
639
700
  : []);
640
701
  }
641
- function applySelectedPatches(profileDirectory, dshRoot, patches, profileChanged) {
702
+ /**
703
+ * Digest of the source half of a patch selection.
704
+ *
705
+ * The row set matches `scripts/apply-plus-preflight.sh`: one row per selected `dsh-source`
706
+ * patch with its id, distribution-relative file, base revision, and payload bytes, sorted by
707
+ * id. Hashing the sorted JSON keeps the digest independent of selection order.
708
+ *
709
+ * @param patches - Selected patches, after or before materialization; payload bytes are equal.
710
+ * @returns Lowercase hex SHA-256 of the canonical row list.
711
+ */
712
+ export function sourcePatchsetDigest(patches) {
713
+ const rows = patches
714
+ .filter((patch) => patch.target.kind === 'dsh-source')
715
+ .map(patch => ({
716
+ id: patch.id,
717
+ file: patch.file,
718
+ baseRevision: patch.target.baseRevision,
719
+ sha256: createHash('sha256').update(readFileSync(patch.absoluteFile)).digest('hex'),
720
+ }))
721
+ .sort((left, right) => left.id.localeCompare(right.id));
722
+ return createHash('sha256').update(JSON.stringify(rows)).digest('hex');
723
+ }
724
+ /**
725
+ * Write the build marker after `build:official` succeeds.
726
+ * @param dshRoot - Built official checkout.
727
+ * @param sourceRevision - Its `git rev-parse HEAD`, already checked against the distribution.
728
+ * @param patches - Selected patches whose source half the build now contains.
729
+ * @returns Absolute marker path.
730
+ */
731
+ export function writeBuildMarker(dshRoot, sourceRevision, patches) {
732
+ const path = resolve(dshRoot, BUILD_MARKER);
733
+ const marker = {
734
+ sourceRevision,
735
+ patchsetDigest: sourcePatchsetDigest(patches),
736
+ builtAt: new Date().toISOString(),
737
+ };
738
+ const temporary = path + '.tmp';
739
+ writeFileSync(temporary, JSON.stringify(marker, undefined, 2) + '\n');
740
+ renameSync(temporary, path);
741
+ return path;
742
+ }
743
+ /**
744
+ * Refuse `--skip-build` unless the checkout still carries the exact prebuilt result.
745
+ *
746
+ * Four facts have to agree: every selected source patch is already applied, the marker
747
+ * belongs to the checkout revision, the marker's digest covers the same patch bytes the
748
+ * distribution selects now, and the build entry points exist. Skipping any one of them
749
+ * would ship stale `lib/` output under a patch set that no longer matches it.
750
+ *
751
+ * When the source phase pruned `.git`, the marker is the only revision record left; the caller
752
+ * passes the revision it already resolved from that marker and the distribution base.
753
+ *
754
+ * @param dshRoot - Official checkout the profile links into.
755
+ * @param patches - Selected patches, materialized into the profile.
756
+ * @param pendingFiles - Selected source patch payloads git still reports as unapplied.
757
+ * @param expectedRevision - Revision `prepareSelection` verified against the official base.
758
+ */
759
+ export function assertPrebuiltSource(dshRoot, patches, pendingFiles, expectedRevision) {
760
+ if (pendingFiles.length > 0) {
761
+ throw new Error('--skip-build requires every selected source patch to be applied already; '
762
+ + String(pendingFiles.length) + ' still pending');
763
+ }
764
+ const marker = readBuildMarker(dshRoot);
765
+ if (marker === undefined) {
766
+ throw new Error('--skip-build needs ' + resolve(dshRoot, BUILD_MARKER) + ' from an earlier full apply');
767
+ }
768
+ const gitRevision = existsSync(resolve(dshRoot, '.git'))
769
+ ? requireString(git(dshRoot, ['rev-parse', 'HEAD']), 'built source revision')
770
+ : expectedRevision;
771
+ if (gitRevision === undefined) {
772
+ throw new Error('--skip-build needs the checkout revision and ' + resolve(dshRoot, '.git') + ' is absent');
773
+ }
774
+ if (marker.sourceRevision !== gitRevision) {
775
+ throw new Error('--skip-build marker revision ' + marker.sourceRevision
776
+ + ' differs from checkout ' + gitRevision);
777
+ }
778
+ const digest = sourcePatchsetDigest(patches);
779
+ if (marker.patchsetDigest !== digest) {
780
+ throw new Error('--skip-build patch set differs from the prebuilt marker');
781
+ }
782
+ const entries = [
783
+ resolve(dshRoot, 'apps/cli/lib/bin.js'),
784
+ resolve(dshRoot, 'packages/client/ui-chat/lib/client.js'),
785
+ ];
786
+ const missing = entries.filter(entry => !existsSync(entry));
787
+ if (missing.length > 0) {
788
+ throw new Error('--skip-build prebuilt entry points are missing: ' + missing.join(', '));
789
+ }
790
+ console.log('[dsh-plus] skip-build verified ' + resolve(dshRoot, BUILD_MARKER) + ' (' + digest + ')');
791
+ }
792
+ function applySelectedPatches(profileDirectory, dshRoot, patches, profileChanged, skipBuild, sourceRevision) {
642
793
  const materialized = materializePatchFiles(profileDirectory, patches);
643
794
  const workspacePath = resolve(profileDirectory, 'pnpm-workspace.yaml');
644
795
  const workspace = profilePatchConfiguration(profileDirectory, materialized.npmPatchFiles);
@@ -648,6 +799,13 @@ function applySelectedPatches(profileDirectory, dshRoot, patches, profileChanged
648
799
  runPnpm(profileDirectory, ['install', '--no-frozen-lockfile'], 'pnpm install in Plus profile');
649
800
  }
650
801
  const sourceFiles = pendingSourcePatchFiles(materialized.patches);
802
+ if (skipBuild) {
803
+ // The source build belongs to the earlier phase. Applying a still-pending patch here or
804
+ // reinstalling the source tree would leave the marker describing different bytes than the
805
+ // `lib/` output the profile links, so both are refused instead of silently recomputed.
806
+ assertPrebuiltSource(dshRoot, materialized.patches, sourceFiles, sourceRevision);
807
+ return;
808
+ }
651
809
  // Docker/overlay copy会使内容未变的文件stat失效;先刷新clean index项,脏文件仍由git apply判冲突。
652
810
  if (sourceFiles.length > 0)
653
811
  git(dshRoot, ['update-index', '--refresh'], true);
@@ -658,6 +816,8 @@ function applySelectedPatches(profileDirectory, dshRoot, patches, profileChanged
658
816
  runPnpm(dshRoot, ['install', '--no-frozen-lockfile'], 'pnpm install after source patches');
659
817
  }
660
818
  runPnpm(dshRoot, ['run', 'build:official'], 'official DSH build after source patches');
819
+ const marker = writeBuildMarker(dshRoot, sourceRevision, materialized.patches);
820
+ console.log('[dsh-plus] wrote build marker ' + marker);
661
821
  }
662
822
  }
663
823
  // Official bundles由dsh CLI dependency tree拥有,private workspace root不承担package resolution。
@@ -754,27 +914,39 @@ function writeLock(profileDirectory, lock) {
754
914
  chmodSync(path, 0o600);
755
915
  return path;
756
916
  }
917
+ const APPLY_USAGE = 'usage: dsh-plus apply --dsh-root <official-dsh-root> [--skip-build]';
757
918
  function parseApplyArguments(argv) {
758
919
  if (argv[0] !== 'apply')
759
- throw new Error('usage: dsh-plus apply --dsh-root <official-dsh-root>');
920
+ throw new Error(APPLY_USAGE);
760
921
  let dshRoot;
761
- for (let index = 1; index < argv.length; index += 2) {
922
+ let skipBuild = false;
923
+ for (let index = 1; index < argv.length; index += 1) {
762
924
  const key = argv[index];
925
+ if (key === '--skip-build') {
926
+ skipBuild = true;
927
+ continue;
928
+ }
763
929
  const value = argv[index + 1];
764
930
  if (key !== '--dsh-root' || value === undefined)
765
- throw new Error('usage: dsh-plus apply --dsh-root <official-dsh-root>');
931
+ throw new Error(APPLY_USAGE);
766
932
  dshRoot = resolve(value);
933
+ index += 1;
767
934
  }
768
935
  if (dshRoot === undefined)
769
- throw new Error('usage: dsh-plus apply --dsh-root <official-dsh-root>');
770
- return { dshRoot, profileDirectory: process.cwd() };
936
+ throw new Error(APPLY_USAGE);
937
+ return { dshRoot, profileDirectory: process.cwd(), skipBuild };
771
938
  }
772
939
  /**
773
940
  * Apply the installed Plus distribution metadata from a DSH profile directory.
774
- * @param argv - Explicit `apply --dsh-root <path>` command arguments.
941
+ *
942
+ * A full run owns both phases: source patches, the official build and its marker, and the
943
+ * profile install/link. `--skip-build` runs the profile half only and verifies the marker a
944
+ * previous full run left in the checkout.
945
+ *
946
+ * @param argv - `apply --dsh-root <path>` plus optional `--skip-build`.
775
947
  */
776
948
  export function runApply(argv) {
777
- const { dshRoot, profileDirectory } = parseApplyArguments(argv);
949
+ const { dshRoot, profileDirectory, skipBuild } = parseApplyArguments(argv);
778
950
  const profileManifest = readJsonObject(resolve(profileDirectory, 'package.json'), 'DSH profile manifest');
779
951
  const dependencies = requireObject(profileManifest.dependencies, 'DSH profile dependencies');
780
952
  if (dependencies['@sparkelf/dsh-plus'] === undefined) {
@@ -782,9 +954,9 @@ export function runApply(argv) {
782
954
  }
783
955
  const distributionDirectory = dirname(createRequire(resolve(profileDirectory, 'package.json'))
784
956
  .resolve('@sparkelf/dsh-plus/package.json'));
785
- const selection = prepareSelection(distributionDirectory, profileDirectory, dshRoot);
957
+ const selection = prepareSelection(distributionDirectory, profileDirectory, dshRoot, skipBuild);
786
958
  const profileChanged = writeProfileComposition(profileDirectory, selection.bundles, selection.runtimePackages);
787
- applySelectedPatches(profileDirectory, dshRoot, selection.patches, profileChanged);
959
+ applySelectedPatches(profileDirectory, dshRoot, selection.patches, profileChanged, skipBuild, selection.sourceRevision);
788
960
  linkOfficialPackages(profileDirectory, dshRoot);
789
961
  const installedProfileDependencies = requireObject(readJsonObject(resolve(profileDirectory, 'package.json'), 'DSH profile manifest').dependencies, 'DSH profile dependencies');
790
962
  selection.lock.profile = {