@smoothbricks/cli 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -23
- package/dist/bun/preload.d.ts +13 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +12 -0
- package/dist/cli.js +36 -4
- package/dist/generate/index.d.ts.map +1 -1
- package/dist/generate/index.js +0 -6
- package/dist/github-ci/index.d.ts +17 -2
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +192 -26
- package/dist/github-ci/outputs.d.ts +22 -0
- package/dist/github-ci/outputs.d.ts.map +1 -0
- package/dist/github-ci/outputs.js +648 -0
- package/dist/lib/cli-package.js +2 -2
- package/dist/lib/json.d.ts +118 -11
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/json.js +317 -29
- package/dist/lib/workspace.d.ts +7 -14
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/lib/workspace.js +76 -82
- package/dist/monorepo/ci-workflow.d.ts +2 -0
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +28 -2
- package/dist/monorepo/git-config.js +2 -2
- package/dist/monorepo/index.d.ts +3 -1
- package/dist/monorepo/index.d.ts.map +1 -1
- package/dist/monorepo/index.js +6 -2
- package/dist/monorepo/lockfile.d.ts +13 -1
- package/dist/monorepo/lockfile.d.ts.map +1 -1
- package/dist/monorepo/lockfile.js +33 -21
- package/dist/monorepo/managed-files.d.ts +12 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +86 -28
- package/dist/monorepo/package-policy.d.ts.map +1 -1
- package/dist/monorepo/package-policy.js +78 -45
- package/dist/monorepo/packed-manifest.d.ts +5 -2
- package/dist/monorepo/packed-manifest.d.ts.map +1 -1
- package/dist/monorepo/packed-manifest.js +16 -47
- package/dist/monorepo/packed-package.d.ts.map +1 -1
- package/dist/monorepo/packed-package.js +28 -16
- package/dist/monorepo/packs/index.d.ts +3 -0
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +18 -6
- package/dist/monorepo/publish-workflow.d.ts +1 -0
- package/dist/monorepo/publish-workflow.d.ts.map +1 -1
- package/dist/monorepo/publish-workflow.js +242 -3
- package/dist/monorepo/runtime.d.ts +15 -0
- package/dist/monorepo/runtime.d.ts.map +1 -1
- package/dist/monorepo/runtime.js +66 -12
- package/dist/monorepo/tool-validation.d.ts.map +1 -1
- package/dist/monorepo/tool-validation.js +32 -23
- package/dist/monorepo/wrangler.d.ts.map +1 -1
- package/dist/monorepo/wrangler.js +13 -13
- package/dist/nx/index.d.ts +12 -4
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +86 -19
- package/dist/pr/index.d.ts.map +1 -1
- package/dist/pr/index.js +28 -32
- package/dist/release/candidates.d.ts +3 -2
- package/dist/release/candidates.d.ts.map +1 -1
- package/dist/release/candidates.js +4 -5
- package/dist/release/github-release.d.ts +3 -0
- package/dist/release/github-release.d.ts.map +1 -1
- package/dist/release/github-release.js +11 -0
- package/dist/release/index.d.ts +20 -1
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +221 -89
- package/dist/release/orchestration.d.ts +8 -1
- package/dist/release/orchestration.d.ts.map +1 -1
- package/dist/release/orchestration.js +38 -1
- package/dist/wrangler/prepare-env.d.ts +0 -1
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +100 -51
- package/dist/wrangler/scaffold.d.ts.map +1 -1
- package/dist/wrangler/scaffold.js +12 -12
- package/managed/raw/git-format-staged.yml +19 -1
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +6 -0
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +3 -3
- package/managed/raw/tooling/direnv/setup-environment.ts +187 -19
- package/managed/raw/tooling/git-hooks/pre-commit.sh +0 -6
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +12 -10
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -2
- package/managed/templates/github/actions/cache-nx/action.yml +2 -2
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/save-nix-devenv/action.yml +11 -3
- package/managed/templates/github/actions/setup-devenv/action.yml +5 -0
- package/managed/templates/github/workflows/managed-files.yml +80 -0
- package/package.json +18 -4
- package/src/bun/preload.ts +12 -0
- package/src/cli.ts +49 -11
- package/src/generate/index.ts +0 -6
- package/src/github-ci/index.test.ts +486 -0
- package/src/github-ci/index.ts +220 -30
- package/src/github-ci/outputs.ts +505 -0
- package/src/lib/cli-package.ts +2 -2
- package/src/lib/json.ts +291 -32
- package/src/lib/workspace.ts +88 -100
- package/src/monorepo/__tests__/ci-workflow.test.ts +14 -3
- package/src/monorepo/__tests__/publish-workflow.test.ts +222 -1
- package/src/monorepo/ci-workflow.ts +28 -2
- package/src/monorepo/git-config.ts +2 -2
- package/src/monorepo/index.ts +6 -2
- package/src/monorepo/lockfile.test.ts +35 -36
- package/src/monorepo/lockfile.ts +48 -24
- package/src/monorepo/managed-files.test.ts +63 -0
- package/src/monorepo/managed-files.ts +94 -34
- package/src/monorepo/package-policy.test.ts +70 -51
- package/src/monorepo/package-policy.ts +104 -59
- package/src/monorepo/packed-manifest.ts +18 -52
- package/src/monorepo/packed-package.ts +43 -22
- package/src/monorepo/packs/index.test.ts +18 -1
- package/src/monorepo/packs/index.ts +20 -7
- package/src/monorepo/publish-workflow.ts +482 -3
- package/src/monorepo/runtime.test.ts +42 -3
- package/src/monorepo/runtime.ts +90 -12
- package/src/monorepo/tool-validation.ts +35 -25
- package/src/monorepo/wrangler.test.ts +11 -15
- package/src/monorepo/wrangler.ts +15 -15
- package/src/nx/index.test.ts +43 -0
- package/src/nx/index.ts +110 -23
- package/src/pr/index.ts +42 -36
- package/src/release/__tests__/candidates.test.ts +5 -4
- package/src/release/__tests__/fixture-repo.test.ts +18 -16
- package/src/release/__tests__/github-release.test.ts +11 -0
- package/src/release/__tests__/orchestration.test.ts +57 -2
- package/src/release/__tests__/trust-publisher.test.ts +98 -2
- package/src/release/candidates.ts +10 -17
- package/src/release/github-release.ts +12 -0
- package/src/release/index.ts +321 -112
- package/src/release/orchestration.ts +55 -3
- package/src/wrangler/prepare-env.ts +75 -54
- package/src/wrangler/scaffold.test.ts +9 -12
- package/src/wrangler/scaffold.ts +13 -13
package/dist/release/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
1
2
|
import { appendFile, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { tmpdir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
4
5
|
import { createInterface } from 'node:readline/promises';
|
|
5
6
|
import { Writable } from 'node:stream';
|
|
6
7
|
import { $ } from 'bun';
|
|
8
|
+
import typia from 'typia';
|
|
9
|
+
import { githubCiApplyOutputs, githubCiNxRunMany } from '../github-ci/index.js';
|
|
7
10
|
import { assertNoConflictMarkers } from '../lib/conflict-markers.js';
|
|
8
11
|
import { withDevenvEnv } from '../lib/devenv.js';
|
|
9
|
-
import {
|
|
10
|
-
import { decode, run, runInteractiveStatus, runResult
|
|
12
|
+
import { parseNxJsonText, parseNxProjectJsonText, parsePackageJsonText, } from '../lib/json.js';
|
|
13
|
+
import { decode, run, runInteractiveStatus, runResult } from '../lib/run.js';
|
|
11
14
|
import { listReleasePackages, readPackageJson, repositoryInfo } from '../lib/workspace.js';
|
|
12
15
|
import { readPackedPackageJson, validatePackedWorkspaceDependencies } from '../monorepo/packed-manifest.js';
|
|
13
16
|
import { bootstrapNpmPackages, NPM_BOOTSTRAP_DIST_TAG, NPM_BOOTSTRAP_VERSION, } from './bootstrap-npm-packages.js';
|
|
14
17
|
import { autoReleaseCandidatePackages } from './candidates.js';
|
|
15
18
|
import { collectOwnedReleaseTagRecords, pendingReleaseTargets, releaseTag, releaseTagAliases, } from './core.js';
|
|
16
|
-
import { createOrUpdateGithubRelease, renderNxProjectChangelogContents, withNxWorkspaceRoot, } from './github-release.js';
|
|
19
|
+
import { createOrUpdateGithubRelease, githubReleaseLookupExists, renderNxProjectChangelogContents, withNxWorkspaceRoot, } from './github-release.js';
|
|
17
20
|
import { publishWithAuthDiagnostics } from './npm-auth.js';
|
|
18
|
-
import { bumpStableReleaseToNext, completeReleaseAtHead as completeReleaseAtHeadWithShell, repairPendingTargets, runReleaseVersion, } from './orchestration.js';
|
|
21
|
+
import { bumpStableReleaseToNext, collectRepairPlatformOutputs, completeReleaseAtHead as completeReleaseAtHeadWithShell, repairPendingTargets, runReleaseVersion, } from './orchestration.js';
|
|
19
22
|
import { retagUnpublished } from './retag-unpublished.js';
|
|
20
23
|
export async function releaseVersion(root, options) {
|
|
21
24
|
const bump = releaseBumpArg(options.bump);
|
|
@@ -78,23 +81,38 @@ export async function releasePublish(root, options) {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
export async function releaseRepairPending(root, options) {
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
console.log(`Repair pending releases:
|
|
84
|
-
await
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const targets = await listPendingReleaseTargets(root, restoreRef);
|
|
89
|
-
console.log(targets.length === 0
|
|
90
|
-
? 'Repair pending releases: no pending durable state repairs found.'
|
|
91
|
-
: `Repair pending releases: ${targets.length} release target${targets.length === 1 ? '' : 's'} need repair.`);
|
|
92
|
-
for (const target of targets) {
|
|
93
|
-
console.log(`Repair pending releases: target ${target.sha.slice(0, 12)} needs ${repairTargetSummary(target)}.`);
|
|
94
|
-
}
|
|
95
|
-
const summaries = await repairPendingTargets(releaseRepairShell(root), targets, restoreRef, options.dryRun === true);
|
|
84
|
+
const repairRef = await fetchReleaseRepairRef(root, options.ref);
|
|
85
|
+
const restoreRef = options.ref ? await gitHead(root) : repairRef;
|
|
86
|
+
console.log(`Repair pending releases: planning from ${repairRef}.`);
|
|
87
|
+
const targets = await listPendingReleaseTargets(root, repairRef);
|
|
88
|
+
logPendingReleaseTargets(targets);
|
|
89
|
+
const platformOutputs = options.platformOutputs ? resolve(root, options.platformOutputs) : undefined;
|
|
90
|
+
const summaries = await repairPendingTargets(releaseRepairShell(root, platformOutputs), targets, restoreRef, options.dryRun === true);
|
|
96
91
|
await writeRepairSummary(summaries, options.dryRun === true);
|
|
97
92
|
}
|
|
93
|
+
export async function releaseCollectPlatformOutputs(root, options) {
|
|
94
|
+
const restoreRef = await gitHead(root);
|
|
95
|
+
const releaseRef = await fetchReleaseRepairRef(root, options.ref);
|
|
96
|
+
const packages = releasePackages(root);
|
|
97
|
+
const packagesAtHead = await releasePackagesAtHead(root, packages);
|
|
98
|
+
const currentPackages = packagesAtHead.length > 0
|
|
99
|
+
? packagesAtHead
|
|
100
|
+
: await releasePlatformPackages(root, packages, releaseBumpArg(options.bump));
|
|
101
|
+
console.log(currentPackages.length === 0
|
|
102
|
+
? 'Release platform outputs: no current release packages selected.'
|
|
103
|
+
: `Release platform outputs: building current outputs for ${packageSummary(currentPackages)}.`);
|
|
104
|
+
const outputRoot = resolve(root, options.output);
|
|
105
|
+
await githubCiNxRunMany(root, {
|
|
106
|
+
targets: options.targets,
|
|
107
|
+
projects: releasePackageProjects(currentPackages),
|
|
108
|
+
collectOutputs: join(outputRoot, 'current'),
|
|
109
|
+
allowEmptyProjects: true,
|
|
110
|
+
});
|
|
111
|
+
console.log(`Repair platform outputs: planning from ${releaseRef}.`);
|
|
112
|
+
const targets = await listPendingReleaseTargets(root, releaseRef);
|
|
113
|
+
logPendingReleaseTargets(targets);
|
|
114
|
+
await collectRepairPlatformOutputs(releaseRepairOutputsShell(root, options.targets, join(outputRoot, 'repairs')), targets, restoreRef);
|
|
115
|
+
}
|
|
98
116
|
export async function releaseTrustPublisher(root, options) {
|
|
99
117
|
const repository = githubRepositoryFromRootPackage(root);
|
|
100
118
|
const workflow = 'publish.yml';
|
|
@@ -111,18 +129,20 @@ export async function releaseTrustPublisher(root, options) {
|
|
|
111
129
|
promptOtp: (packageName) => promptForNpmOtp(packageName),
|
|
112
130
|
log: (message) => console.log(message),
|
|
113
131
|
}, bootstrapOptions),
|
|
114
|
-
trustPublisher: (pkg, dryRun, env) =>
|
|
115
|
-
const args = ['trust', 'github', pkg.name, '--file', workflow, '--repo', repository, '--yes'];
|
|
116
|
-
if (dryRun) {
|
|
117
|
-
args.push('--dry-run');
|
|
118
|
-
}
|
|
119
|
-
return runLatestNpmTrust(root, args, env);
|
|
120
|
-
},
|
|
132
|
+
trustPublisher: (pkg, dryRun, env) => runLatestNpmTrust(root, npmTrustGithubArgs(pkg.name, repository, workflow, dryRun), env),
|
|
121
133
|
trustedPublishers: (pkg) => listTrustedPublishers(root, pkg),
|
|
134
|
+
login: () => runLatestNpm(root, ['login', '--auth-type=web']),
|
|
122
135
|
log: (message) => console.log(message),
|
|
123
136
|
error: (message) => console.error(message),
|
|
124
137
|
}, options);
|
|
125
138
|
}
|
|
139
|
+
export function npmTrustGithubArgs(packageName, repository, workflow, dryRun) {
|
|
140
|
+
const args = ['trust', 'github', packageName, '--file', workflow, '--repo', repository, '--allow-publish', '--yes'];
|
|
141
|
+
if (dryRun) {
|
|
142
|
+
args.push('--dry-run');
|
|
143
|
+
}
|
|
144
|
+
return args;
|
|
145
|
+
}
|
|
126
146
|
export async function configureTrustedPublishers(shell, options) {
|
|
127
147
|
const packages = shell.listReleasePackages();
|
|
128
148
|
const selectedPackages = selectedTrustPublisherPackages(packages, options.packages ?? []);
|
|
@@ -149,7 +169,7 @@ export async function configureTrustedPublishers(shell, options) {
|
|
|
149
169
|
const failedPackages = [];
|
|
150
170
|
for (const pkg of selectedPackages) {
|
|
151
171
|
if (!options.dryRun) {
|
|
152
|
-
const trustedPublishers = await shell
|
|
172
|
+
const trustedPublishers = await trustedPublishersWithOwnerLogin(shell, pkg);
|
|
153
173
|
if (hasMatchingGithubTrustedPublisher(trustedPublishers, shell.repository, shell.workflow)) {
|
|
154
174
|
shell.log(`${pkg.name}: npm trusted publisher is already configured; skipping.`);
|
|
155
175
|
continue;
|
|
@@ -186,6 +206,23 @@ export async function configureTrustedPublishers(shell, options) {
|
|
|
186
206
|
shell.error(`Trusted publishing was not configured for: ${failedPackages.join(', ')}`);
|
|
187
207
|
}
|
|
188
208
|
}
|
|
209
|
+
async function trustedPublishersWithOwnerLogin(shell, pkg) {
|
|
210
|
+
let result = await shell.trustedPublishers(pkg);
|
|
211
|
+
if (Array.isArray(result)) {
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
shell.error(`${pkg.name}: npm trust access denied for npm account "${result.identity}". ` +
|
|
215
|
+
`npm trust requires package write access. Package owners:\n${result.owners}`);
|
|
216
|
+
shell.log(`${pkg.name}: opening npm browser login. Sign in as a listed package owner, then return here.`);
|
|
217
|
+
await shell.login();
|
|
218
|
+
result = await shell.trustedPublishers(pkg);
|
|
219
|
+
if (Array.isArray(result)) {
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`${pkg.name}: npm trust access denied for npm account "${result.identity}". ` +
|
|
223
|
+
`npm trust requires package write access. Package owners:\n${result.owners}\n` +
|
|
224
|
+
'npm browser login completed, but the selected account still cannot manage this package.');
|
|
225
|
+
}
|
|
189
226
|
function selectedTrustPublisherPackages(packages, selections) {
|
|
190
227
|
if (selections.length === 0) {
|
|
191
228
|
return packages;
|
|
@@ -305,7 +342,7 @@ async function publishPlaceholderPackage(root, pkg, env) {
|
|
|
305
342
|
name: pkg.name,
|
|
306
343
|
version: NPM_BOOTSTRAP_VERSION,
|
|
307
344
|
description: `Bootstrap placeholder for ${pkg.name}. Real releases are published by SmoothBricks CI.`,
|
|
308
|
-
license:
|
|
345
|
+
license: pkg.json.license ?? 'UNLICENSED',
|
|
309
346
|
repository: pkg.json.repository,
|
|
310
347
|
publishConfig: { access: 'public' },
|
|
311
348
|
}, null, 2)}\n`);
|
|
@@ -321,7 +358,7 @@ function safeTarballPrefix(name) {
|
|
|
321
358
|
}
|
|
322
359
|
async function assertPackedWorkspaceDependencies(root, tarball, pkg) {
|
|
323
360
|
const manifest = await readPackedPackageJson(root, tarball, pkg.name);
|
|
324
|
-
const failures = validatePackedWorkspaceDependencies(root, pkg, manifest);
|
|
361
|
+
const failures = validatePackedWorkspaceDependencies(root, pkg, manifest, { mode: 'publish' });
|
|
325
362
|
if (failures.length > 0) {
|
|
326
363
|
throw new Error(failures.join('\n'));
|
|
327
364
|
}
|
|
@@ -350,6 +387,14 @@ async function releaseVersionPackages(root, packages, bump) {
|
|
|
350
387
|
packageHasHistory: (packagePath) => packageHasHistory(root, packagePath),
|
|
351
388
|
}, packages);
|
|
352
389
|
}
|
|
390
|
+
async function releasePlatformPackages(root, packages, bump) {
|
|
391
|
+
const candidates = await releaseVersionPackages(root, packages, bump);
|
|
392
|
+
if (candidates.length === 0) {
|
|
393
|
+
return [];
|
|
394
|
+
}
|
|
395
|
+
// Nx may version additional reverse dependents, so use its dry-run result rather than only the direct candidates.
|
|
396
|
+
return runNxReleaseVersionPreview(root, releasePackageProjects(candidates), bump);
|
|
397
|
+
}
|
|
353
398
|
async function runNxReleaseVersion(root, projects, bump, dryRun) {
|
|
354
399
|
if (dryRun) {
|
|
355
400
|
return runNxReleaseVersionPreview(root, projects, bump);
|
|
@@ -392,6 +437,7 @@ async function runNxReleaseVersionPreview(root, projects, bump) {
|
|
|
392
437
|
gitPush: false,
|
|
393
438
|
stageChanges: false,
|
|
394
439
|
createRelease: false,
|
|
440
|
+
forceChangelogGeneration: true,
|
|
395
441
|
dryRun: true,
|
|
396
442
|
});
|
|
397
443
|
releasePreviewChangelogs.clear();
|
|
@@ -455,8 +501,7 @@ async function packageVersionAtRef(root, packagePath, ref) {
|
|
|
455
501
|
return null;
|
|
456
502
|
}
|
|
457
503
|
try {
|
|
458
|
-
|
|
459
|
-
return isRecord(parsed) ? stringProperty(parsed, 'version') : null;
|
|
504
|
+
return parsePackageJsonText(decode(result.stdout))?.version ?? null;
|
|
460
505
|
}
|
|
461
506
|
catch {
|
|
462
507
|
return null;
|
|
@@ -568,9 +613,8 @@ function releaseNextShell(root) {
|
|
|
568
613
|
},
|
|
569
614
|
};
|
|
570
615
|
}
|
|
571
|
-
function
|
|
616
|
+
function releaseTargetCheckoutShell(root) {
|
|
572
617
|
return {
|
|
573
|
-
...releaseCompletionShell(root),
|
|
574
618
|
checkout: (ref) => run('git', ['switch', '--detach', ref], root),
|
|
575
619
|
withDevenvEnv: (runWithEnv) => withDevenvEnv(root, runWithEnv),
|
|
576
620
|
beforeRepairTarget: (target) => {
|
|
@@ -581,6 +625,30 @@ function releaseRepairShell(root) {
|
|
|
581
625
|
},
|
|
582
626
|
};
|
|
583
627
|
}
|
|
628
|
+
function releaseRepairShell(root, platformOutputs) {
|
|
629
|
+
return {
|
|
630
|
+
...releaseCompletionShell(root),
|
|
631
|
+
...releaseTargetCheckoutShell(root),
|
|
632
|
+
prepareRepairTarget: async (target) => {
|
|
633
|
+
if (!platformOutputs || target.npmPackages.length === 0) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const output = join(platformOutputs, target.sha);
|
|
637
|
+
console.log(`Repair pending releases: applying cross-platform outputs from ${output}.`);
|
|
638
|
+
await githubCiApplyOutputs(root, [output], target.sha);
|
|
639
|
+
},
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function releaseRepairOutputsShell(root, targetGlobs, outputRoot) {
|
|
643
|
+
return {
|
|
644
|
+
...releaseTargetCheckoutShell(root),
|
|
645
|
+
collectRepairTargetOutputs: (target) => githubCiNxRunMany(root, {
|
|
646
|
+
targets: targetGlobs,
|
|
647
|
+
projects: releasePackageProjects(target.npmPackages),
|
|
648
|
+
collectOutputs: join(outputRoot, target.sha),
|
|
649
|
+
}),
|
|
650
|
+
};
|
|
651
|
+
}
|
|
584
652
|
function releaseRetagShell(root, remote) {
|
|
585
653
|
return {
|
|
586
654
|
listReleasePackages: () => releasePackages(root),
|
|
@@ -596,6 +664,25 @@ function releaseRetagShell(root, remote) {
|
|
|
596
664
|
log: (message) => console.log(message),
|
|
597
665
|
};
|
|
598
666
|
}
|
|
667
|
+
async function fetchReleaseRepairRef(root, requestedRef) {
|
|
668
|
+
const branch = await releaseBranch(root);
|
|
669
|
+
const remote = await releaseRemote(root, branch);
|
|
670
|
+
console.log(`Repair pending releases: fetching ${remote}/${branch} and tags.`);
|
|
671
|
+
await fetchReleaseRefs(root, remote, branch);
|
|
672
|
+
if (requestedRef) {
|
|
673
|
+
return requestedRef;
|
|
674
|
+
}
|
|
675
|
+
const remoteRef = `${remote}/${branch}`;
|
|
676
|
+
return (await gitRefExists(root, remoteRef)) ? remoteRef : gitHead(root);
|
|
677
|
+
}
|
|
678
|
+
function logPendingReleaseTargets(targets) {
|
|
679
|
+
console.log(targets.length === 0
|
|
680
|
+
? 'Repair pending releases: no pending durable state repairs found.'
|
|
681
|
+
: `Repair pending releases: ${targets.length} release target${targets.length === 1 ? '' : 's'} need repair.`);
|
|
682
|
+
for (const target of targets) {
|
|
683
|
+
console.log(`Repair pending releases: target ${target.sha.slice(0, 12)} needs ${repairTargetSummary(target)}.`);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
599
686
|
async function listPendingReleaseTargets(root, ref) {
|
|
600
687
|
const head = await gitHead(root);
|
|
601
688
|
return pendingReleaseTargets(await listOwnedReleaseTagRecords(root, ref), head);
|
|
@@ -795,7 +882,8 @@ function repairReasons(target, pkg) {
|
|
|
795
882
|
return reasons;
|
|
796
883
|
}
|
|
797
884
|
async function fetchReleaseRefs(root, remote, branch) {
|
|
798
|
-
|
|
885
|
+
// `retag-unpublished` intentionally moves repairable tags, so the remote tag is authoritative.
|
|
886
|
+
await run('git', ['fetch', '--force', '--tags', remote, branch], root);
|
|
799
887
|
}
|
|
800
888
|
async function gitRefExists(root, ref) {
|
|
801
889
|
const result = await $ `git rev-parse --verify ${ref}`.cwd(root).quiet().nothrow();
|
|
@@ -840,8 +928,7 @@ async function packageJsonAtRef(root, ref, packagePath) {
|
|
|
840
928
|
return null;
|
|
841
929
|
}
|
|
842
930
|
try {
|
|
843
|
-
|
|
844
|
-
return isRecord(parsed) ? parsed : null;
|
|
931
|
+
return parsePackageJsonText(decode(result.stdout));
|
|
845
932
|
}
|
|
846
933
|
catch {
|
|
847
934
|
return null;
|
|
@@ -852,46 +939,59 @@ async function currentPackageJson(root, packagePath) {
|
|
|
852
939
|
}
|
|
853
940
|
async function packageBuildInputPatterns(root, projectName, _packagePath) {
|
|
854
941
|
const project = await nxProjectJson(root, projectName);
|
|
855
|
-
|
|
856
|
-
return resolveBuildInputPatterns(project, nxJson);
|
|
942
|
+
return resolveBuildInputPatterns(project, readNxJson(join(root, 'nx.json')));
|
|
857
943
|
}
|
|
858
944
|
async function nxProjectJson(root, projectName) {
|
|
859
945
|
const result = await $ `nx show project ${projectName} --json`.cwd(root).quiet();
|
|
860
|
-
const parsed =
|
|
861
|
-
if (!
|
|
946
|
+
const parsed = parseNxProjectJsonText(decode(result.stdout));
|
|
947
|
+
if (!parsed) {
|
|
862
948
|
throw new Error(`Unable to inspect Nx project ${projectName}.`);
|
|
863
949
|
}
|
|
864
950
|
return parsed;
|
|
865
951
|
}
|
|
952
|
+
function readNxJson(path) {
|
|
953
|
+
if (!existsSync(path)) {
|
|
954
|
+
return {};
|
|
955
|
+
}
|
|
956
|
+
try {
|
|
957
|
+
return parseNxJsonText(readFileSync(path, 'utf8')) ?? {};
|
|
958
|
+
}
|
|
959
|
+
catch {
|
|
960
|
+
return {};
|
|
961
|
+
}
|
|
962
|
+
}
|
|
866
963
|
function resolveBuildInputPatterns(project, nxJson) {
|
|
867
|
-
const targets =
|
|
964
|
+
const targets = project.targets;
|
|
868
965
|
if (!targets) {
|
|
869
966
|
return [];
|
|
870
967
|
}
|
|
871
968
|
return normalizeInputPatterns(collectBuildInputs(targets), nxJson);
|
|
872
969
|
}
|
|
873
970
|
function collectBuildInputs(targets) {
|
|
874
|
-
const build =
|
|
971
|
+
const build = targets.build;
|
|
875
972
|
if (!build) {
|
|
876
973
|
return ['production'];
|
|
877
974
|
}
|
|
878
|
-
const directInputs =
|
|
975
|
+
const directInputs = stringInputs(build.inputs);
|
|
879
976
|
if (directInputs.length > 0) {
|
|
880
977
|
return directInputs;
|
|
881
978
|
}
|
|
882
979
|
const inputs = [];
|
|
883
|
-
for (const dependency of
|
|
884
|
-
if (dependency.startsWith('^')) {
|
|
980
|
+
for (const dependency of build.dependsOn ?? []) {
|
|
981
|
+
if (typeof dependency !== 'string' || dependency.startsWith('^')) {
|
|
885
982
|
continue;
|
|
886
983
|
}
|
|
887
984
|
const targetName = dependency.includes(':') ? dependency.split(':')[1] : dependency;
|
|
888
985
|
if (!targetName) {
|
|
889
986
|
continue;
|
|
890
987
|
}
|
|
891
|
-
inputs.push(...
|
|
988
|
+
inputs.push(...stringInputs(targets[targetName]?.inputs));
|
|
892
989
|
}
|
|
893
990
|
return inputs.length > 0 ? inputs : ['production'];
|
|
894
991
|
}
|
|
992
|
+
function stringInputs(inputs) {
|
|
993
|
+
return Array.isArray(inputs) ? inputs.filter((entry) => typeof entry === 'string') : [];
|
|
994
|
+
}
|
|
895
995
|
function normalizeInputPatterns(inputs, nxJson) {
|
|
896
996
|
const patterns = [];
|
|
897
997
|
const seen = new Set();
|
|
@@ -908,8 +1008,7 @@ function expandInputPattern(input, nxJson, seen) {
|
|
|
908
1008
|
}
|
|
909
1009
|
seen.add(input);
|
|
910
1010
|
if (!input.includes('{')) {
|
|
911
|
-
const
|
|
912
|
-
const namedInput = namedInputs?.[input];
|
|
1011
|
+
const namedInput = nxJson.namedInputs?.[input];
|
|
913
1012
|
if (Array.isArray(namedInput)) {
|
|
914
1013
|
return namedInput.flatMap((entry) => (typeof entry === 'string' ? expandInputPattern(entry, nxJson, seen) : []));
|
|
915
1014
|
}
|
|
@@ -923,17 +1022,6 @@ function expandInputPattern(input, nxJson, seen) {
|
|
|
923
1022
|
const packageRelative = rawInput.slice('{projectRoot}/'.length);
|
|
924
1023
|
return [`${excluded ? '!' : ''}${packageRelative}`];
|
|
925
1024
|
}
|
|
926
|
-
function recordProperty(record, key) {
|
|
927
|
-
if (!record) {
|
|
928
|
-
return null;
|
|
929
|
-
}
|
|
930
|
-
const value = record[key];
|
|
931
|
-
return isRecord(value) ? value : null;
|
|
932
|
-
}
|
|
933
|
-
function stringArrayProperty(record, key) {
|
|
934
|
-
const value = record?.[key];
|
|
935
|
-
return Array.isArray(value) ? value.filter((entry) => typeof entry === 'string') : [];
|
|
936
|
-
}
|
|
937
1025
|
async function packageHasHistory(root, packagePath) {
|
|
938
1026
|
const result = await $ `git log --format=%H -- ${packagePath}`.cwd(root).quiet().nothrow();
|
|
939
1027
|
if (result.exitCode !== 0) {
|
|
@@ -1003,7 +1091,8 @@ async function pushRetaggedReleaseTags(root, remote, updates) {
|
|
|
1003
1091
|
await run('git', ['push', '--atomic', ...leases, remote, ...refspecs], root);
|
|
1004
1092
|
}
|
|
1005
1093
|
async function githubReleaseExists(root, tag) {
|
|
1006
|
-
|
|
1094
|
+
const result = await $ `gh release view ${tag} --json tagName`.cwd(root).quiet().nothrow();
|
|
1095
|
+
return githubReleaseLookupExists(tag, result.exitCode, decode(result.stdout), decode(result.stderr));
|
|
1007
1096
|
}
|
|
1008
1097
|
function githubReleaseUrl(root, tag) {
|
|
1009
1098
|
return `https://github.com/${githubRepositoryFromRootPackage(root)}/releases/tag/${encodeURIComponent(tag)}`;
|
|
@@ -1131,7 +1220,7 @@ async function runLatestNpmTrust(root, npmArgs, env) {
|
|
|
1131
1220
|
if (status === 0) {
|
|
1132
1221
|
return 'configured';
|
|
1133
1222
|
}
|
|
1134
|
-
throw new Error(
|
|
1223
|
+
throw new Error(npmCommandFailedMessage(npmArgs, status));
|
|
1135
1224
|
}
|
|
1136
1225
|
async function listTrustedPublishers(root, pkg) {
|
|
1137
1226
|
const args = ['trust', 'list', pkg.name, '--json'];
|
|
@@ -1139,47 +1228,90 @@ async function listTrustedPublishers(root, pkg) {
|
|
|
1139
1228
|
if (result.exitCode !== 0 && /\bEOTP\b/.test(`${result.stdout}\n${result.stderr}`)) {
|
|
1140
1229
|
const status = await runInteractiveStatus('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', ...args], root);
|
|
1141
1230
|
if (status !== 0) {
|
|
1142
|
-
throw new Error(
|
|
1231
|
+
throw new Error(npmCommandFailedMessage(args, status));
|
|
1143
1232
|
}
|
|
1144
1233
|
result = await runResult('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', ...args], root);
|
|
1145
1234
|
}
|
|
1235
|
+
if (result.exitCode !== 0 && npmTrustListAccessDenied(result.stdout, result.stderr)) {
|
|
1236
|
+
return npmTrustAccessDetails(root, pkg.name);
|
|
1237
|
+
}
|
|
1146
1238
|
if (result.exitCode !== 0) {
|
|
1147
|
-
throw new Error(
|
|
1239
|
+
throw new Error(npmCommandFailedMessage(args, result.exitCode, result.stdout, result.stderr));
|
|
1148
1240
|
}
|
|
1149
1241
|
return parseTrustedPublishers(result.stdout, pkg.name);
|
|
1150
1242
|
}
|
|
1243
|
+
/** npm trust list/setup requires an authenticated package owner. */
|
|
1244
|
+
export function npmTrustListAccessDenied(stdout, stderr) {
|
|
1245
|
+
const output = `${stdout}\n${stderr}`;
|
|
1246
|
+
// E403: authenticated but not an owner. E401 / login-required: no usable session.
|
|
1247
|
+
return (/\bE403\b/.test(output) ||
|
|
1248
|
+
/\bE401\b/.test(output) ||
|
|
1249
|
+
/You must be logged in to publish packages/i.test(output) ||
|
|
1250
|
+
/npm error 401 Unauthorized/i.test(output));
|
|
1251
|
+
}
|
|
1252
|
+
function npmCommandFailedMessage(npmArgs, exitCode, stdout = '', stderr = '') {
|
|
1253
|
+
const command = `nix shell nixpkgs#nodejs_latest -c npm ${npmArgs.join(' ')}`;
|
|
1254
|
+
const detail = npmFailureDetail(stdout, stderr);
|
|
1255
|
+
return detail.length > 0
|
|
1256
|
+
? `${command} failed with exit code ${exitCode}\n${detail}`
|
|
1257
|
+
: `${command} failed with exit code ${exitCode}`;
|
|
1258
|
+
}
|
|
1259
|
+
function npmFailureDetail(stdout, stderr) {
|
|
1260
|
+
const chunks = [stderr.trim(), stdout.trim()].filter((chunk) => chunk.length > 0);
|
|
1261
|
+
if (chunks.length === 0) {
|
|
1262
|
+
return '';
|
|
1263
|
+
}
|
|
1264
|
+
// Prefer the actionable npm error line over notice spam when present.
|
|
1265
|
+
const joined = chunks.join('\n');
|
|
1266
|
+
const errorLines = joined
|
|
1267
|
+
.split('\n')
|
|
1268
|
+
.map((line) => line.trimEnd())
|
|
1269
|
+
.filter((line) => /npm error|error code|401 Unauthorized|403 Forbidden|E401|E403|logged in/i.test(line));
|
|
1270
|
+
if (errorLines.length > 0) {
|
|
1271
|
+
return errorLines.slice(0, 8).join('\n');
|
|
1272
|
+
}
|
|
1273
|
+
// Fall back to a short tail of combined output.
|
|
1274
|
+
return joined.split('\n').slice(-12).join('\n');
|
|
1275
|
+
}
|
|
1276
|
+
async function npmTrustAccessDetails(root, packageName) {
|
|
1277
|
+
const [identityResult, ownersResult] = await Promise.all([
|
|
1278
|
+
runResult('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', 'whoami'], root),
|
|
1279
|
+
runResult('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', 'owner', 'ls', packageName], root),
|
|
1280
|
+
]);
|
|
1281
|
+
return {
|
|
1282
|
+
status: 'access-denied',
|
|
1283
|
+
identity: identityResult.exitCode === 0 && identityResult.stdout.trim().length > 0
|
|
1284
|
+
? identityResult.stdout.trim()
|
|
1285
|
+
: '(not authenticated)',
|
|
1286
|
+
owners: ownersResult.exitCode === 0 && ownersResult.stdout.trim().length > 0
|
|
1287
|
+
? ownersResult.stdout.trim()
|
|
1288
|
+
: '(owner lookup unavailable)',
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1151
1291
|
export function parseTrustedPublishers(stdout, packageName) {
|
|
1152
1292
|
if (stdout.trim().length === 0) {
|
|
1153
1293
|
return [];
|
|
1154
1294
|
}
|
|
1155
|
-
|
|
1295
|
+
// createIsParse returns null for non-matching shapes and bare `null`.
|
|
1296
|
+
const parsed = parseTrustedPublisherJson(stdout);
|
|
1156
1297
|
if (parsed === null) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
}
|
|
1162
|
-
if (isRecord(parsed)) {
|
|
1163
|
-
return [parseTrustedPublisher(parsed, packageName)];
|
|
1164
|
-
}
|
|
1165
|
-
throw new Error(`${packageName}: npm trust list returned invalid JSON.`);
|
|
1166
|
-
}
|
|
1167
|
-
function parseTrustedPublisher(value, packageName) {
|
|
1168
|
-
if (!isRecord(value)) {
|
|
1169
|
-
throw new Error(`${packageName}: npm trust list returned invalid trusted publisher entry.`);
|
|
1170
|
-
}
|
|
1171
|
-
const id = stringProperty(value, 'id');
|
|
1172
|
-
const type = stringProperty(value, 'type');
|
|
1173
|
-
if (!id || !type) {
|
|
1174
|
-
throw new Error(`${packageName}: npm trust list returned a trusted publisher without id or type.`);
|
|
1298
|
+
if (stdout.trim() === 'null') {
|
|
1299
|
+
return [];
|
|
1300
|
+
}
|
|
1301
|
+
throw new Error(`${packageName}: npm trust list returned invalid trusted publisher JSON.`);
|
|
1175
1302
|
}
|
|
1176
|
-
return {
|
|
1177
|
-
id,
|
|
1178
|
-
type,
|
|
1179
|
-
file:
|
|
1180
|
-
repository:
|
|
1181
|
-
};
|
|
1303
|
+
return (Array.isArray(parsed) ? parsed : [parsed]).map((value) => ({
|
|
1304
|
+
id: value.id,
|
|
1305
|
+
type: value.type,
|
|
1306
|
+
file: value.file,
|
|
1307
|
+
repository: value.repository,
|
|
1308
|
+
}));
|
|
1182
1309
|
}
|
|
1310
|
+
const parseTrustedPublisherJson = (() => {
|
|
1311
|
+
const _io0 = input => "string" === typeof input.id && "string" === typeof input.type && (undefined === input.file || "string" === typeof input.file) && (undefined === input.repository || "string" === typeof input.repository);
|
|
1312
|
+
const __is = input => null !== input && undefined !== input && (Array.isArray(input) && input.every(elem => "object" === typeof elem && null !== elem && _io0(elem)) || "object" === typeof input && null !== input && _io0(input));
|
|
1313
|
+
return input => { input = JSON.parse(input); return __is(input) ? input : null; };
|
|
1314
|
+
})();
|
|
1183
1315
|
async function runLatestNpmPublish(root, npmArgs) {
|
|
1184
1316
|
await runLatestNpm(root, npmArgs, { NODE_AUTH_TOKEN: '', NPM_TOKEN: '' });
|
|
1185
1317
|
}
|
|
@@ -27,12 +27,18 @@ export interface ReleaseCompletionShell<Package extends ReleasePackageInfo = Rel
|
|
|
27
27
|
export interface ReleaseNextShell<Package extends ReleasePackageInfo = ReleasePackageInfo> {
|
|
28
28
|
bumpStablePackagesToNext(packages: Package[]): Promise<void>;
|
|
29
29
|
}
|
|
30
|
-
export interface
|
|
30
|
+
export interface ReleaseTargetCheckoutShell<Package extends ReleasePackageInfo = ReleasePackageInfo> {
|
|
31
31
|
checkout(ref: string): Promise<void>;
|
|
32
32
|
withDevenvEnv<T>(runWithEnv: () => Promise<T>): Promise<T>;
|
|
33
33
|
beforeRepairTarget?(target: ReleaseTarget<Package>): void;
|
|
34
34
|
afterRepairTarget?(target: ReleaseTarget<Package>): void;
|
|
35
35
|
}
|
|
36
|
+
export interface ReleaseRepairShell<Package extends ReleasePackageInfo = ReleasePackageInfo> extends ReleaseCompletionShell<Package>, ReleaseTargetCheckoutShell<Package> {
|
|
37
|
+
prepareRepairTarget?(target: ReleaseTarget<Package>): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface ReleaseRepairOutputsShell<Package extends ReleasePackageInfo = ReleasePackageInfo> extends ReleaseTargetCheckoutShell<Package> {
|
|
40
|
+
collectRepairTargetOutputs(target: ReleaseTarget<Package>): Promise<void>;
|
|
41
|
+
}
|
|
36
42
|
export interface ReleaseVersionShell<Package extends ReleasePackageInfo = ReleasePackageInfo> {
|
|
37
43
|
releasePackagesAtHead(): Promise<Package[]>;
|
|
38
44
|
releaseVersionPackages(bump: string): Promise<Package[]>;
|
|
@@ -53,5 +59,6 @@ export declare function runReleaseVersion<Package extends ReleasePackageInfo>(sh
|
|
|
53
59
|
export declare function completeReleaseAtHead<Package extends ReleasePackageInfo>(shell: ReleaseCompletionShell<Package>, packages: Package[], dryRun: boolean, rerunRequired: boolean): Promise<ReleaseSummary<Package>>;
|
|
54
60
|
export declare function bumpStableReleaseToNext<Package extends ReleasePackageInfo>(shell: ReleaseNextShell<Package>, packages: Package[], dryRun: boolean, rerunRequired: boolean): Promise<Package[]>;
|
|
55
61
|
export declare function repairPendingTargets<Package extends ReleasePackageInfo>(shell: ReleaseRepairShell<Package>, targets: Array<ReleaseTarget<Package>>, restoreRef: string, dryRun: boolean): Promise<Array<ReleaseSummary<Package>>>;
|
|
62
|
+
export declare function collectRepairPlatformOutputs<Package extends ReleasePackageInfo>(shell: ReleaseRepairOutputsShell<Package>, targets: Array<ReleaseTarget<Package>>, restoreRef: string): Promise<void>;
|
|
56
63
|
export declare function completeRepairTargetAtHead<Package extends ReleasePackageInfo>(shell: ReleaseCompletionShell<Package>, target: ReleaseTarget<Package>, dryRun: boolean): Promise<ReleaseSummary<Package>>;
|
|
57
64
|
//# sourceMappingURL=orchestration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration.d.ts","sourceRoot":"","sources":["../../src/release/orchestration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGnE,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhD,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,gBA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EAAE,CAAC,CAOpB;AAED,wBAAsB,oBAAoB,CAAC,OAAO,SAAS,kBAAkB,EAC3E,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAClC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAkCzC;AAED,wBAAsB,4BAA4B,CAAC,OAAO,SAAS,kBAAkB,EACnF,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,EACzC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EACtC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAmBD,wBAAsB,0BAA0B,CAAC,OAAO,SAAS,kBAAkB,EACjF,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAUlC"}
|
|
@@ -72,7 +72,10 @@ export async function repairPendingTargets(shell, targets, restoreRef, dryRun) {
|
|
|
72
72
|
}
|
|
73
73
|
shell.beforeRepairTarget?.(target);
|
|
74
74
|
try {
|
|
75
|
-
summaries.push(await shell.withDevenvEnv(() =>
|
|
75
|
+
summaries.push(await shell.withDevenvEnv(async () => {
|
|
76
|
+
await shell.prepareRepairTarget?.(target);
|
|
77
|
+
return completeRepairTargetAtHead(shell, target, dryRun);
|
|
78
|
+
}));
|
|
76
79
|
}
|
|
77
80
|
finally {
|
|
78
81
|
shell.afterRepairTarget?.(target);
|
|
@@ -81,9 +84,43 @@ export async function repairPendingTargets(shell, targets, restoreRef, dryRun) {
|
|
|
81
84
|
}
|
|
82
85
|
finally {
|
|
83
86
|
await shell.checkout(restoreRef);
|
|
87
|
+
if (targets.length > 0) {
|
|
88
|
+
// Loading devenv at a historical release can rebuild ignored tool outputs
|
|
89
|
+
// from that checkout. Refresh after restoring HEAD so later release phases
|
|
90
|
+
// cannot combine the current CLI with an older Nx plugin build.
|
|
91
|
+
await shell.withDevenvEnv(async () => undefined);
|
|
92
|
+
}
|
|
84
93
|
}
|
|
85
94
|
return summaries;
|
|
86
95
|
}
|
|
96
|
+
export async function collectRepairPlatformOutputs(shell, targets, restoreRef) {
|
|
97
|
+
const outputTargets = targets.filter((target) => target.npmPackages.length > 0);
|
|
98
|
+
if (outputTargets.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
for (const target of outputTargets) {
|
|
103
|
+
await shell.checkout(target.sha);
|
|
104
|
+
if (target.packages.length === 0) {
|
|
105
|
+
// invariant throw: release target discovery must never yield a package-free target.
|
|
106
|
+
throw new Error(`Release commit ${target.sha} has no release packages after checkout.`);
|
|
107
|
+
}
|
|
108
|
+
shell.beforeRepairTarget?.(target);
|
|
109
|
+
try {
|
|
110
|
+
await shell.withDevenvEnv(() => shell.collectRepairTargetOutputs(target));
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
shell.afterRepairTarget?.(target);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
await shell.checkout(restoreRef);
|
|
119
|
+
// Historical devenv activation may rebuild ignored tool outputs. Restore the
|
|
120
|
+
// dispatch environment before the macOS job performs any further work.
|
|
121
|
+
await shell.withDevenvEnv(async () => undefined);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
87
124
|
function repairDryRunSummary(target) {
|
|
88
125
|
return {
|
|
89
126
|
sha: target.sha,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function isRecord(v: unknown): v is Record<string, unknown>;
|
|
2
1
|
/** First `[env.<name>]` (source order; also derived from a nested `[env.<name>.*]`), or null when no env declared. */
|
|
3
2
|
export declare function firstWranglerEnv(toml: string): string | null;
|
|
4
3
|
/** True if the toml declares `[env.<env>]` (or any `[env.<env>.*]` sub-table). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"AAgIA,sHAAsH;AACtH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7E;AAED,oIAAoI;AACpI,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKjF;AAED,iIAAiI;AACjI,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,qGAAqG;AACrG,wBAAgB,YAAY,CAA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