@adea-ai/app-framework-release-tools 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/dist/cli.js +1585 -292
- package/dist/index.js +689 -212
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,12 +17,15 @@ var __export = (target, all) => {
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var exports_src = {};
|
|
19
19
|
__export(exports_src, {
|
|
20
|
+
createDailyNativeReceipt: () => createDailyNativeReceipt,
|
|
20
21
|
createGitHubPromotionProvider: () => createGitHubPromotionProvider,
|
|
21
22
|
createGitHubReleasePublisher: () => createGitHubReleasePublisher,
|
|
22
23
|
createMacosDmg: () => createMacosDmg,
|
|
24
|
+
desktopDailyProfile: () => desktopDailyProfile,
|
|
23
25
|
fileIdentity: () => fileIdentity2,
|
|
24
26
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
25
27
|
inspectStagedStep: () => inspectStagedStep,
|
|
28
|
+
planDailyReleaseMatrix: () => planDailyReleaseMatrix,
|
|
26
29
|
planQualificationRun: () => planQualificationRun2,
|
|
27
30
|
planReleaseAssets: () => planReleaseAssets2,
|
|
28
31
|
publishFrameworkPackage: () => publishFrameworkPackage,
|
|
@@ -37,8 +40,10 @@ __export(exports_src, {
|
|
|
37
40
|
selectRetainedStep: () => selectRetainedStep,
|
|
38
41
|
signReleaseArtifact: () => signReleaseArtifact,
|
|
39
42
|
stageBuildStep: () => stageBuildStep,
|
|
43
|
+
stageLinuxPackagePair: () => stageLinuxPackagePair,
|
|
40
44
|
stagePlatformArtifacts: () => stagePlatformArtifacts,
|
|
41
45
|
stageReleaseDescriptors: () => stageReleaseDescriptors,
|
|
46
|
+
verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
|
|
42
47
|
verifyImage: () => verifyImage,
|
|
43
48
|
writeDescriptors: () => writeDescriptors
|
|
44
49
|
});
|
|
@@ -1635,6 +1640,9 @@ var RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-dev\.\d+)?$/;
|
|
|
1635
1640
|
function isReleaseVersion(value) {
|
|
1636
1641
|
return typeof value === "string" && value.length <= MAX_RELEASE_VERSION_LENGTH && RELEASE_VERSION.test(value);
|
|
1637
1642
|
}
|
|
1643
|
+
function isReleaseTag(value) {
|
|
1644
|
+
return typeof value === "string" && value.startsWith("v") && isReleaseVersion(value.slice(1));
|
|
1645
|
+
}
|
|
1638
1646
|
|
|
1639
1647
|
// ../../src/release/release-promotion.ts
|
|
1640
1648
|
function order(a, b) {
|
|
@@ -3136,6 +3144,264 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
|
|
|
3136
3144
|
});
|
|
3137
3145
|
var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
|
|
3138
3146
|
var stageReleaseDescriptors = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(stageReleaseDescriptorsEffect(options)));
|
|
3147
|
+
// src/library/daily-matrix.ts
|
|
3148
|
+
import { join as join7 } from "path";
|
|
3149
|
+
import { Effect as Effect16 } from "effect";
|
|
3150
|
+
|
|
3151
|
+
// src/library/daily-native-evidence.ts
|
|
3152
|
+
var digest = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
|
|
3153
|
+
var record = (value, keys) => isRecord(value) && hasExactOwnKeys(value, keys);
|
|
3154
|
+
function assertDailyIdentity(identity) {
|
|
3155
|
+
if (!isReleaseTag(identity.tag) || !isGitSha(identity.sourceSha) || identity.workflowSha !== identity.sourceSha || typeof identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(identity.runId) || !Number.isSafeInteger(identity.runAttempt) || identity.runAttempt <= 0)
|
|
3156
|
+
throw new Error("Invalid exact Daily identity");
|
|
3157
|
+
}
|
|
3158
|
+
function validArtifact(value) {
|
|
3159
|
+
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 && digest(value.digest);
|
|
3160
|
+
}
|
|
3161
|
+
function originMatches(value, payloadName) {
|
|
3162
|
+
if (record(value, ["kind", "sourceSha"]))
|
|
3163
|
+
return value.kind === "published-installer" && isGitSha(value.sourceSha);
|
|
3164
|
+
return record(value, ["kind", "sourceSha", "payload"]) && value.kind === "private-from-verified-payload" && isGitSha(value.sourceSha) && validArtifact(value.payload) && value.payload.name === payloadName;
|
|
3165
|
+
}
|
|
3166
|
+
function observationsMatch(value, { identity, check, baselineNames }) {
|
|
3167
|
+
const version = identity.tag.slice(1);
|
|
3168
|
+
if (!record(value, check.format === "command" ? ["install", "command"] : ["install", "launch", "upgrade"]) || !record(value.install, ["version"]) || value.install.version !== version)
|
|
3169
|
+
return false;
|
|
3170
|
+
if (check.format === "command") {
|
|
3171
|
+
const cmd = value.command;
|
|
3172
|
+
return record(cmd, ["version", "probesPassed", "serviceStarted", "serviceStopped"]) && cmd.version === version && cmd.probesPassed === true && cmd.serviceStarted === true && cmd.serviceStopped === (check.platform === "windows-x64" ? "process-tree" : "sigterm");
|
|
3173
|
+
}
|
|
3174
|
+
const { launch, upgrade } = value;
|
|
3175
|
+
return record(launch, ["version", "ready"]) && launch.version === version && launch.ready === true && record(upgrade, [
|
|
3176
|
+
"baselineTag",
|
|
3177
|
+
"baselineAsset",
|
|
3178
|
+
"baselineOrigin",
|
|
3179
|
+
"baselineVersion",
|
|
3180
|
+
"upgradedVersion",
|
|
3181
|
+
"ready",
|
|
3182
|
+
"fixtureBefore",
|
|
3183
|
+
"fixtureAfter"
|
|
3184
|
+
]) && isReleaseTag(upgrade.baselineTag) && versionLessThan(upgrade.baselineTag, identity.tag) && validArtifact(upgrade.baselineAsset) && upgrade.baselineAsset.name === baselineNames(upgrade.baselineTag).installer && originMatches(upgrade.baselineOrigin, baselineNames(upgrade.baselineTag).payload) && upgrade.baselineVersion === upgrade.baselineTag.slice(1) && upgrade.upgradedVersion === version && upgrade.ready === true && digest(upgrade.fixtureBefore) && upgrade.fixtureAfter === upgrade.fixtureBefore;
|
|
3185
|
+
}
|
|
3186
|
+
function validateDailyNativeEvidence(input, schema, context) {
|
|
3187
|
+
const { appId, identity, check, assets } = context;
|
|
3188
|
+
const [os, arch] = platformTargets[check.platform];
|
|
3189
|
+
if (!record(input, [
|
|
3190
|
+
"schema",
|
|
3191
|
+
"appId",
|
|
3192
|
+
"profile",
|
|
3193
|
+
"tag",
|
|
3194
|
+
"sourceSha",
|
|
3195
|
+
"workflowSha",
|
|
3196
|
+
"runId",
|
|
3197
|
+
"runAttempt",
|
|
3198
|
+
"check",
|
|
3199
|
+
"platform",
|
|
3200
|
+
"format",
|
|
3201
|
+
"host",
|
|
3202
|
+
"assets",
|
|
3203
|
+
"observations"
|
|
3204
|
+
]) || input.schema !== schema || input.appId !== appId || input.profile !== "desktop-v1" || input.tag !== identity.tag || input.sourceSha !== identity.sourceSha || input.workflowSha !== identity.workflowSha || input.runId !== identity.runId || input.runAttempt !== identity.runAttempt || input.check !== check.name || input.platform !== check.platform || input.format !== check.format || !record(input.host, ["os", "arch"]) || input.host.os !== os || input.host.arch !== arch || !Array.isArray(input.assets) || input.assets.length !== assets.length)
|
|
3205
|
+
throw new Error(`Native receipt identity or result mismatch: ${check.name}`);
|
|
3206
|
+
for (const expected of assets) {
|
|
3207
|
+
const matches = input.assets.filter((item) => validArtifact(item) && item.name === expected.name);
|
|
3208
|
+
if (matches.length !== 1 || matches[0].size !== expected.size || matches[0].digest !== expected.digest)
|
|
3209
|
+
throw new Error(`Native receipt does not qualify staged bytes: ${check.name} / ${expected.name}`);
|
|
3210
|
+
}
|
|
3211
|
+
if (!observationsMatch(input.observations, context))
|
|
3212
|
+
throw new Error(`Missing or invalid native observations: ${check.name}`);
|
|
3213
|
+
return { host: { os, arch }, observations: input.observations };
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
// src/library/daily-matrix.ts
|
|
3217
|
+
var desktopDailyProfile = "desktop-v1";
|
|
3218
|
+
var platforms = [
|
|
3219
|
+
"macos-arm64",
|
|
3220
|
+
"windows-x64",
|
|
3221
|
+
"linux-x64"
|
|
3222
|
+
];
|
|
3223
|
+
var receiptLimit = 64 * 1024;
|
|
3224
|
+
function requireThat(ok, message) {
|
|
3225
|
+
if (!ok)
|
|
3226
|
+
throw new Error(message);
|
|
3227
|
+
}
|
|
3228
|
+
function planDailyReleaseMatrix(config, tag) {
|
|
3229
|
+
requireThat(isRecord(config) && config.dailyReleaseProfile === desktopDailyProfile && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
3230
|
+
const parsed = parseReleaseConfig(config);
|
|
3231
|
+
const requirements = parsed.requirements(tag);
|
|
3232
|
+
const checks = [];
|
|
3233
|
+
for (const platform of platforms) {
|
|
3234
|
+
const pair = requirements.platforms[platform];
|
|
3235
|
+
requireThat(pair?.length === 2, `Expected installer and updater archive for ${platform}`);
|
|
3236
|
+
const [installer, archive] = pair;
|
|
3237
|
+
const suffix = platform === "macos-arm64" ? ".dmg" : platform === "windows-x64" ? "-Setup.zip" : "-Setup.tar.gz";
|
|
3238
|
+
requireThat(installer.endsWith(suffix) && archive.endsWith(".tar.zst"), `Unexpected desktop installer or updater format for ${platform}`);
|
|
3239
|
+
const format = platform === "macos-arm64" ? "dmg" : platform === "windows-x64" ? "windows-setup" : "portable-linux";
|
|
3240
|
+
checks.push({ name: `installer-${platform}`, platform, format, assets: pair });
|
|
3241
|
+
for (const command of parsed.commandArtifacts) {
|
|
3242
|
+
const name = requirements.commandArtifacts?.[command.kind]?.[platform];
|
|
3243
|
+
requireThat(name, `Missing command archive for ${platform}`);
|
|
3244
|
+
checks.push({
|
|
3245
|
+
name: `command-${command.kind}-${platform}`,
|
|
3246
|
+
platform,
|
|
3247
|
+
format: "command",
|
|
3248
|
+
assets: [name]
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
const linux = "linux-x64";
|
|
3253
|
+
const base = requirements.platforms[linux][1].slice(0, -".tar.zst".length);
|
|
3254
|
+
checks.push({ name: "deb-linux-x64", platform: linux, format: "deb", assets: [base + ".deb"] }, {
|
|
3255
|
+
name: "appimage-linux-x64",
|
|
3256
|
+
platform: linux,
|
|
3257
|
+
format: "appimage",
|
|
3258
|
+
assets: [base + ".AppImage"]
|
|
3259
|
+
});
|
|
3260
|
+
const names = checks.flatMap((check) => check.assets);
|
|
3261
|
+
discoveryPolicies(config, tag);
|
|
3262
|
+
const all = [...names, ...requirements.releaseAssets];
|
|
3263
|
+
requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
|
|
3264
|
+
return { appId: config.appId, profile: desktopDailyProfile, assets: all, checks };
|
|
3265
|
+
}
|
|
3266
|
+
function priorDailyInstallerNames(config, tag, check) {
|
|
3267
|
+
const plan = planDailyReleaseMatrix(config, tag);
|
|
3268
|
+
return {
|
|
3269
|
+
installer: plan.checks.find((entry) => entry.name === check.name)?.assets[0],
|
|
3270
|
+
payload: plan.checks.find((entry) => entry.name === `installer-${check.platform}`)?.assets[1]
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
function exactDirectory(root, names) {
|
|
3274
|
+
return Effect16.gen(function* () {
|
|
3275
|
+
const fs = yield* ReleaseFs;
|
|
3276
|
+
const stat = yield* step(() => fs.lstat(root));
|
|
3277
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
3278
|
+
return yield* fail("Expected real matrix input directory");
|
|
3279
|
+
const entries = yield* step(() => fs.readdir(root, { withFileTypes: true }));
|
|
3280
|
+
const expected = new Set(names);
|
|
3281
|
+
if (entries.length !== expected.size || entries.some((e) => !e.isFile() || !expected.has(e.name)))
|
|
3282
|
+
return yield* fail("Matrix directory must contain exactly the required regular files");
|
|
3283
|
+
});
|
|
3284
|
+
}
|
|
3285
|
+
function readNativeReceipt(path, label) {
|
|
3286
|
+
return Effect16.gen(function* () {
|
|
3287
|
+
const fs = yield* ReleaseFs;
|
|
3288
|
+
const stat = yield* step(() => fs.lstat(path));
|
|
3289
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size < 1 || stat.size > receiptLimit)
|
|
3290
|
+
return yield* fail(`Invalid native receipt size or type: ${label}`);
|
|
3291
|
+
const { file, before } = yield* Effect16.acquireRelease(step(() => openUnchangedFile(path, stat, "Native receipt changed before opening")), ({ file: opened }) => Effect16.promise(() => opened.close().catch(() => {
|
|
3292
|
+
return;
|
|
3293
|
+
})));
|
|
3294
|
+
const data = yield* step(async () => {
|
|
3295
|
+
const bytes = Buffer.alloc(before.size);
|
|
3296
|
+
let offset = 0;
|
|
3297
|
+
while (offset < bytes.length) {
|
|
3298
|
+
const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
|
|
3299
|
+
if (!bytesRead)
|
|
3300
|
+
throw new Error("Native receipt changed during read");
|
|
3301
|
+
offset += bytesRead;
|
|
3302
|
+
}
|
|
3303
|
+
const after = await file.stat();
|
|
3304
|
+
if (!sameFile(before, after) || before.ctimeMs !== after.ctimeMs)
|
|
3305
|
+
throw new Error("Native receipt changed during read");
|
|
3306
|
+
return bytes.toString("utf8");
|
|
3307
|
+
});
|
|
3308
|
+
return yield* attempt(() => {
|
|
3309
|
+
try {
|
|
3310
|
+
return JSON.parse(data);
|
|
3311
|
+
} catch {
|
|
3312
|
+
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
}).pipe(Effect16.scoped);
|
|
3316
|
+
}
|
|
3317
|
+
var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
|
|
3318
|
+
const { config, identity, artifacts, receipts } = options;
|
|
3319
|
+
const { tag } = identity;
|
|
3320
|
+
yield* attempt(() => assertDailyIdentity(identity));
|
|
3321
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, tag));
|
|
3322
|
+
yield* exactDirectory(artifacts, matrix.assets);
|
|
3323
|
+
yield* exactDirectory(receipts, matrix.checks.map((c) => c.name + ".json"));
|
|
3324
|
+
const inventory = new Map;
|
|
3325
|
+
for (const name of matrix.assets)
|
|
3326
|
+
inventory.set(name, yield* fileIdentityEffect(join7(artifacts, name), name));
|
|
3327
|
+
for (const check of matrix.checks) {
|
|
3328
|
+
const r = yield* readNativeReceipt(join7(receipts, check.name + ".json"), check.name);
|
|
3329
|
+
yield* attempt(() => validateDailyNativeEvidence(r, "framework/daily-native-receipt/v2", {
|
|
3330
|
+
appId: matrix.appId,
|
|
3331
|
+
identity,
|
|
3332
|
+
check,
|
|
3333
|
+
assets: check.assets.map((name) => inventory.get(name)),
|
|
3334
|
+
baselineNames: (priorTag) => priorDailyInstallerNames(config, priorTag, check)
|
|
3335
|
+
}));
|
|
3336
|
+
}
|
|
3337
|
+
return {
|
|
3338
|
+
profile: matrix.profile,
|
|
3339
|
+
appId: matrix.appId,
|
|
3340
|
+
identity,
|
|
3341
|
+
assets: [...inventory.values()]
|
|
3342
|
+
};
|
|
3343
|
+
});
|
|
3344
|
+
function verifyDailyReleaseMatrix(options) {
|
|
3345
|
+
return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
|
|
3346
|
+
}
|
|
3347
|
+
// src/library/daily-native-receipt.ts
|
|
3348
|
+
import { join as join8 } from "path";
|
|
3349
|
+
import { Effect as Effect17 } from "effect";
|
|
3350
|
+
var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function* () {
|
|
3351
|
+
const { config, identity, artifacts, checkName, report } = options;
|
|
3352
|
+
yield* attempt(() => assertDailyIdentity(identity));
|
|
3353
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
3354
|
+
const check = matrix.checks.find(({ name }) => name === checkName);
|
|
3355
|
+
if (!check)
|
|
3356
|
+
return yield* fail("Unknown Daily native check");
|
|
3357
|
+
const [os, arch] = platformTargets[check.platform];
|
|
3358
|
+
if (worker.os !== os || worker.arch !== arch)
|
|
3359
|
+
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
3360
|
+
const fs = yield* ReleaseFs;
|
|
3361
|
+
const dir = yield* step(() => fs.lstat(artifacts));
|
|
3362
|
+
if (!dir.isDirectory() || dir.isSymbolicLink())
|
|
3363
|
+
return yield* fail("Expected real native artifact directory");
|
|
3364
|
+
const assets = yield* Effect17.forEach(check.assets, (name) => fileIdentityEffect(join8(artifacts, name), name));
|
|
3365
|
+
const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
|
|
3366
|
+
appId: matrix.appId,
|
|
3367
|
+
identity,
|
|
3368
|
+
check,
|
|
3369
|
+
assets,
|
|
3370
|
+
baselineNames: (tag) => priorDailyInstallerNames(config, tag, check)
|
|
3371
|
+
}));
|
|
3372
|
+
if ("upgrade" in evidence.observations) {
|
|
3373
|
+
if (!options.baselineArtifacts)
|
|
3374
|
+
return yield* fail("Daily desktop check requires the exact baseline installer");
|
|
3375
|
+
const baselineDirectory = options.baselineArtifacts;
|
|
3376
|
+
const info = yield* step(() => fs.lstat(baselineDirectory));
|
|
3377
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
3378
|
+
return yield* fail("Expected real native baseline directory");
|
|
3379
|
+
const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
|
|
3380
|
+
const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
|
|
3381
|
+
for (const expected of proofFiles) {
|
|
3382
|
+
const observed = yield* fileIdentityEffect(join8(baselineDirectory, expected.name), expected.name);
|
|
3383
|
+
if (observed.size !== expected.size || observed.digest !== expected.digest)
|
|
3384
|
+
return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
return {
|
|
3388
|
+
...identity,
|
|
3389
|
+
...evidence,
|
|
3390
|
+
schema: "framework/daily-native-receipt/v2",
|
|
3391
|
+
appId: matrix.appId,
|
|
3392
|
+
profile: matrix.profile,
|
|
3393
|
+
check: check.name,
|
|
3394
|
+
platform: check.platform,
|
|
3395
|
+
format: check.format,
|
|
3396
|
+
assets
|
|
3397
|
+
};
|
|
3398
|
+
});
|
|
3399
|
+
function createDailyNativeReceipt(options) {
|
|
3400
|
+
return runReleaseLibrary(provideLibraryPorts()(createDailyNativeReceiptEffect(options, {
|
|
3401
|
+
os: process.platform,
|
|
3402
|
+
arch: process.arch
|
|
3403
|
+
})));
|
|
3404
|
+
}
|
|
3139
3405
|
// src/library/macos-dmg.ts
|
|
3140
3406
|
import { execFileSync } from "child_process";
|
|
3141
3407
|
import {
|
|
@@ -3147,8 +3413,8 @@ import {
|
|
|
3147
3413
|
rmSync,
|
|
3148
3414
|
symlinkSync
|
|
3149
3415
|
} from "fs";
|
|
3150
|
-
import { basename as basename4, dirname, join as
|
|
3151
|
-
import { Context as Context2, Effect as
|
|
3416
|
+
import { basename as basename4, dirname, join as join9, resolve as resolve6 } from "path";
|
|
3417
|
+
import { Context as Context2, Effect as Effect18 } from "effect";
|
|
3152
3418
|
|
|
3153
3419
|
// ../../src/release/macos-dmg.ts
|
|
3154
3420
|
var MIB = 1024 * 1024;
|
|
@@ -3179,7 +3445,7 @@ function treeSize(root) {
|
|
|
3179
3445
|
logicalBytes += info.size;
|
|
3180
3446
|
else if (info.isDirectory())
|
|
3181
3447
|
for (const name of readdirSync(path))
|
|
3182
|
-
pending.push(
|
|
3448
|
+
pending.push(join9(path, name));
|
|
3183
3449
|
else if (!info.isSymbolicLink())
|
|
3184
3450
|
throw new Error("Unsupported disk image entry");
|
|
3185
3451
|
if (!Number.isSafeInteger(logicalBytes))
|
|
@@ -3187,16 +3453,16 @@ function treeSize(root) {
|
|
|
3187
3453
|
}
|
|
3188
3454
|
return { logicalBytes, entries };
|
|
3189
3455
|
}
|
|
3190
|
-
var verifyImageEffect = (image) =>
|
|
3456
|
+
var verifyImageEffect = (image) => Effect18.gen(function* () {
|
|
3191
3457
|
const host = yield* MacosHost;
|
|
3192
3458
|
for (let tries = 1;; tries++) {
|
|
3193
|
-
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(
|
|
3459
|
+
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect18.as(true), Effect18.catchIf(() => tries < 6, () => Effect18.succeed(false)));
|
|
3194
3460
|
if (verified)
|
|
3195
3461
|
return;
|
|
3196
3462
|
host.wait(5000 * 2 ** (tries - 1));
|
|
3197
3463
|
}
|
|
3198
3464
|
});
|
|
3199
|
-
var createMacosDmgEffect = (options) =>
|
|
3465
|
+
var createMacosDmgEffect = (options) => Effect18.gen(function* () {
|
|
3200
3466
|
const host = yield* MacosHost;
|
|
3201
3467
|
if (host.platform !== "darwin")
|
|
3202
3468
|
return yield* fail("Disk image creation requires macOS");
|
|
@@ -3205,11 +3471,11 @@ var createMacosDmgEffect = (options) => Effect16.gen(function* () {
|
|
|
3205
3471
|
const info = yield* attempt(() => lstatSync(app));
|
|
3206
3472
|
if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
|
|
3207
3473
|
return yield* fail("Invalid disk image paths");
|
|
3208
|
-
const staging = yield*
|
|
3209
|
-
const payload =
|
|
3474
|
+
const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join9(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
|
|
3475
|
+
const payload = join9(staging, "payload"), image = join9(staging, "result.dmg");
|
|
3210
3476
|
yield* attempt(() => mkdirSync(payload));
|
|
3211
|
-
yield* attempt(() => host.run("/usr/bin/ditto", [app,
|
|
3212
|
-
yield* attempt(() => symlinkSync("/Applications",
|
|
3477
|
+
yield* attempt(() => host.run("/usr/bin/ditto", [app, join9(payload, basename4(app))]));
|
|
3478
|
+
yield* attempt(() => symlinkSync("/Applications", join9(payload, "Applications")));
|
|
3213
3479
|
const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
|
|
3214
3480
|
yield* attempt(() => host.run("/usr/bin/hdiutil", [
|
|
3215
3481
|
"create",
|
|
@@ -3226,31 +3492,31 @@ var createMacosDmgEffect = (options) => Effect16.gen(function* () {
|
|
|
3226
3492
|
yield* verifyImageEffect(image);
|
|
3227
3493
|
yield* attempt(() => linkSync(image, output));
|
|
3228
3494
|
return { capacityMiB };
|
|
3229
|
-
}).pipe(
|
|
3495
|
+
}).pipe(Effect18.scoped);
|
|
3230
3496
|
function verifyImage(image, io = liveHost) {
|
|
3231
|
-
runReleaseLibrarySync(verifyImageEffect(image).pipe(
|
|
3497
|
+
runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
|
|
3232
3498
|
run: (command, args) => io.run(command, args),
|
|
3233
3499
|
wait: (milliseconds) => io.wait(milliseconds),
|
|
3234
3500
|
platform: process.platform
|
|
3235
3501
|
})));
|
|
3236
3502
|
}
|
|
3237
3503
|
function createMacosDmg(options) {
|
|
3238
|
-
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(
|
|
3504
|
+
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
|
|
3239
3505
|
}
|
|
3240
3506
|
// src/library/qualification-run.ts
|
|
3241
|
-
import { Effect as
|
|
3507
|
+
import { Effect as Effect21 } from "effect";
|
|
3242
3508
|
|
|
3243
3509
|
// src/library/local-release.ts
|
|
3244
3510
|
import { createHash as createHash8 } from "crypto";
|
|
3245
3511
|
import { constants as constants3 } from "fs";
|
|
3246
|
-
import { dirname as dirname2, join as
|
|
3247
|
-
import { Cause as Cause2, Effect as
|
|
3512
|
+
import { dirname as dirname2, join as join11, resolve as resolve8 } from "path";
|
|
3513
|
+
import { Cause as Cause2, Effect as Effect20, Exit as Exit3 } from "effect";
|
|
3248
3514
|
|
|
3249
3515
|
// ../../src/native/native-rename.ts
|
|
3250
3516
|
import { randomUUID } from "crypto";
|
|
3251
3517
|
import { mkdir as mkdir3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
3252
3518
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
3253
|
-
import { join as
|
|
3519
|
+
import { join as join10 } from "path";
|
|
3254
3520
|
|
|
3255
3521
|
// ../../src/native/canonical-path.ts
|
|
3256
3522
|
import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
|
|
@@ -3329,8 +3595,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3329
3595
|
if (!isCanonicalPath(parent))
|
|
3330
3596
|
throw new Error("Invalid directory exchange probe parent");
|
|
3331
3597
|
const id = randomUUID();
|
|
3332
|
-
const first =
|
|
3333
|
-
const second =
|
|
3598
|
+
const first = join10(parent, `.framework-exchange-probe-${id}-a`);
|
|
3599
|
+
const second = join10(parent, `.framework-exchange-probe-${id}-b`);
|
|
3334
3600
|
const marker = "exchange-probe";
|
|
3335
3601
|
const firstValue = `${id}:first`;
|
|
3336
3602
|
const secondValue = `${id}:second`;
|
|
@@ -3341,12 +3607,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3341
3607
|
firstCreated = true;
|
|
3342
3608
|
await mkdir3(second, { mode: 448 });
|
|
3343
3609
|
secondCreated = true;
|
|
3344
|
-
await writeFile3(
|
|
3345
|
-
await writeFile3(
|
|
3610
|
+
await writeFile3(join10(first, marker), firstValue, { flag: "wx", mode: 384 });
|
|
3611
|
+
await writeFile3(join10(second, marker), secondValue, { flag: "wx", mode: 384 });
|
|
3346
3612
|
exchange(first, second);
|
|
3347
3613
|
const [firstAfter, secondAfter] = await Promise.all([
|
|
3348
|
-
readFile5(
|
|
3349
|
-
readFile5(
|
|
3614
|
+
readFile5(join10(first, marker), "utf8"),
|
|
3615
|
+
readFile5(join10(second, marker), "utf8")
|
|
3350
3616
|
]);
|
|
3351
3617
|
if (firstAfter !== secondValue || secondAfter !== firstValue)
|
|
3352
3618
|
throw new Error("Directory exchange did not exchange both probe trees");
|
|
@@ -3412,7 +3678,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
3412
3678
|
|
|
3413
3679
|
// src/library/feed-state.ts
|
|
3414
3680
|
import { createHash as createHash7 } from "crypto";
|
|
3415
|
-
import { Effect as
|
|
3681
|
+
import { Effect as Effect19 } from "effect";
|
|
3416
3682
|
|
|
3417
3683
|
// ../../src/shared/discard-stream.ts
|
|
3418
3684
|
function discardStream(stream) {
|
|
@@ -3572,11 +3838,11 @@ var json = (bytes) => {
|
|
|
3572
3838
|
throw new Error("Invalid release feed response");
|
|
3573
3839
|
}
|
|
3574
3840
|
};
|
|
3575
|
-
var feedObject = (feed, path, maximum) =>
|
|
3841
|
+
var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
|
|
3576
3842
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3577
3843
|
return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
|
|
3578
3844
|
});
|
|
3579
|
-
var readFeedLedgerEffect = (feed) =>
|
|
3845
|
+
var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
|
|
3580
3846
|
const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
|
|
3581
3847
|
const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
|
|
3582
3848
|
if (ledger && ledger.releases.length > 0)
|
|
@@ -3588,7 +3854,7 @@ var readFeedLedgerEffect = (feed) => Effect17.gen(function* () {
|
|
|
3588
3854
|
}
|
|
3589
3855
|
return ledger ?? { schema: 1, app: feed.app, releases: [] };
|
|
3590
3856
|
});
|
|
3591
|
-
var readFeedReleaseEffect = (feed, tag) =>
|
|
3857
|
+
var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
|
|
3592
3858
|
const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
|
|
3593
3859
|
if (!bytes)
|
|
3594
3860
|
return null;
|
|
@@ -3638,10 +3904,10 @@ class ReleaseFeedSnapshotChanged extends Error {
|
|
|
3638
3904
|
var snapshotChanged = step(async () => {
|
|
3639
3905
|
throw new ReleaseFeedSnapshotChanged;
|
|
3640
3906
|
});
|
|
3641
|
-
var verifyFeedReleaseEffect = (options) =>
|
|
3907
|
+
var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
|
|
3642
3908
|
const { config, feed, tag } = options;
|
|
3643
3909
|
const { fetch: fetcher } = yield* ReleaseFetch;
|
|
3644
|
-
const ledger = yield* readFeedLedgerEffect(feed).pipe(
|
|
3910
|
+
const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect19.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
|
|
3645
3911
|
if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
|
|
3646
3912
|
return yield* snapshotChanged;
|
|
3647
3913
|
const release = yield* readFeedReleaseEffect(feed, tag);
|
|
@@ -3704,13 +3970,13 @@ var timestamp2 = (value) => {
|
|
|
3704
3970
|
throw new Error("Invalid release clock");
|
|
3705
3971
|
return new Date(value).toISOString();
|
|
3706
3972
|
};
|
|
3707
|
-
var exactFiles = (directory, names) =>
|
|
3973
|
+
var exactFiles = (directory, names) => Effect20.gen(function* () {
|
|
3708
3974
|
const fs = yield* ReleaseFs;
|
|
3709
3975
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
3710
3976
|
if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
|
|
3711
3977
|
return yield* fail("Staged directory does not hold exactly the platform release files");
|
|
3712
3978
|
});
|
|
3713
|
-
var promised2 =
|
|
3979
|
+
var promised2 = Effect20.gen(function* () {
|
|
3714
3980
|
const fs = yield* ReleaseFs;
|
|
3715
3981
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3716
3982
|
const { run: git } = yield* ReleaseGit;
|
|
@@ -3720,7 +3986,7 @@ var promised2 = Effect18.gen(function* () {
|
|
|
3720
3986
|
run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
|
|
3721
3987
|
};
|
|
3722
3988
|
});
|
|
3723
|
-
var runLocalReleaseCutEffect = (options) =>
|
|
3989
|
+
var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
|
|
3724
3990
|
const { kind, platform } = options;
|
|
3725
3991
|
const parsed = parseReleaseConfig(options.config);
|
|
3726
3992
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -3745,7 +4011,7 @@ var runLocalReleaseCutEffect = (options) => Effect18.gen(function* () {
|
|
|
3745
4011
|
}));
|
|
3746
4012
|
return { ...result, version: result.tag.slice(1), platform };
|
|
3747
4013
|
});
|
|
3748
|
-
var localTagProvenanceEffect = (options) =>
|
|
4014
|
+
var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
|
|
3749
4015
|
const parsed = parseReleaseConfig(options.config);
|
|
3750
4016
|
parsed.requirements(options.tag);
|
|
3751
4017
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -3756,7 +4022,7 @@ var localTagProvenanceEffect = (options) => Effect18.gen(function* () {
|
|
|
3756
4022
|
return yield* fail("Release tag does not belong to the source version");
|
|
3757
4023
|
return { repository: provenance.repository };
|
|
3758
4024
|
});
|
|
3759
|
-
var stageLocalDescriptorsEffect = (options) =>
|
|
4025
|
+
var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
|
|
3760
4026
|
const { tag, platform } = options;
|
|
3761
4027
|
const local = localConfig(options.config);
|
|
3762
4028
|
if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
|
|
@@ -3765,7 +4031,7 @@ var stageLocalDescriptorsEffect = (options) => Effect18.gen(function* () {
|
|
|
3765
4031
|
const payloads = platformPayloads(local.requirements(tag), platform);
|
|
3766
4032
|
const directory = resolve8(options.directory);
|
|
3767
4033
|
yield* exactFiles(directory, payloads);
|
|
3768
|
-
const assets = yield*
|
|
4034
|
+
const assets = yield* Effect20.forEach(payloads, (name) => fileIdentityEffect(join11(directory, name), name), { concurrency: "unbounded" });
|
|
3769
4035
|
const signed = signDiscoveryDescriptors({
|
|
3770
4036
|
policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
|
|
3771
4037
|
assets,
|
|
@@ -3783,7 +4049,7 @@ var stageLocalDescriptorsEffect = (options) => Effect18.gen(function* () {
|
|
|
3783
4049
|
privateKey: options.privateKey
|
|
3784
4050
|
});
|
|
3785
4051
|
for (const asset of assets)
|
|
3786
|
-
if (JSON.stringify(yield* fileIdentityEffect(
|
|
4052
|
+
if (JSON.stringify(yield* fileIdentityEffect(join11(directory, asset.name), asset.name)) !== JSON.stringify(asset))
|
|
3787
4053
|
return yield* fail("Staged payload changed before signing");
|
|
3788
4054
|
yield* writeDescriptorsEffect(directory, signed);
|
|
3789
4055
|
return signed.map((value) => value.name);
|
|
@@ -3807,18 +4073,18 @@ var describe = (key, bytes, cacheControl) => ({
|
|
|
3807
4073
|
contentType: "application/json",
|
|
3808
4074
|
cacheControl
|
|
3809
4075
|
});
|
|
3810
|
-
var writeStagedTree = (out, feed, assets, documents) =>
|
|
4076
|
+
var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
|
|
3811
4077
|
const fs = yield* ReleaseFs;
|
|
3812
4078
|
const root = resolve8(out);
|
|
3813
|
-
const exists = yield* step(() => fs.lstat(root)).pipe(
|
|
4079
|
+
const exists = yield* step(() => fs.lstat(root)).pipe(Effect20.as(true), Effect20.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect20.succeed(false)));
|
|
3814
4080
|
if (exists)
|
|
3815
4081
|
return yield* fail("Release output directory already exists");
|
|
3816
4082
|
yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
|
|
3817
|
-
const staging = yield* step(() => fs.mkdtemp(
|
|
3818
|
-
const exit = yield*
|
|
4083
|
+
const staging = yield* step(() => fs.mkdtemp(join11(dirname2(root), ".release-staging-")));
|
|
4084
|
+
const exit = yield* Effect20.exit(Effect20.gen(function* () {
|
|
3819
4085
|
const objects = [];
|
|
3820
4086
|
for (const { key, path, artifact } of assets) {
|
|
3821
|
-
const target =
|
|
4087
|
+
const target = join11(staging, key);
|
|
3822
4088
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
3823
4089
|
yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
|
|
3824
4090
|
if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
|
|
@@ -3832,13 +4098,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
3832
4098
|
});
|
|
3833
4099
|
}
|
|
3834
4100
|
for (const { key, bytes } of documents) {
|
|
3835
|
-
const target =
|
|
4101
|
+
const target = join11(staging, key);
|
|
3836
4102
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
3837
4103
|
yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
|
|
3838
4104
|
objects.push(describe(key, bytes, MUTABLE));
|
|
3839
4105
|
}
|
|
3840
4106
|
const plan = { schema: 1, base: feed.base, objects };
|
|
3841
|
-
yield* step(() => fs.writeFile(
|
|
4107
|
+
yield* step(() => fs.writeFile(join11(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
|
|
3842
4108
|
yield* attempt(() => renameExclusive(staging, root));
|
|
3843
4109
|
return plan;
|
|
3844
4110
|
}));
|
|
@@ -3846,10 +4112,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
3846
4112
|
return exit.value;
|
|
3847
4113
|
const error = Cause2.squash(exit.cause);
|
|
3848
4114
|
const original = error instanceof ReleaseFailure ? error.original ?? error : error;
|
|
3849
|
-
const cleanup = yield*
|
|
4115
|
+
const cleanup = yield* Effect20.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
|
|
3850
4116
|
if (Exit3.isFailure(cleanup)) {
|
|
3851
4117
|
const cleanupError = Cause2.squash(cleanup.cause);
|
|
3852
|
-
return yield*
|
|
4118
|
+
return yield* Effect20.fail(new ReleaseFailure({
|
|
3853
4119
|
reason: "cleanup",
|
|
3854
4120
|
message: "Release staging failed and its private temporary tree could not be removed",
|
|
3855
4121
|
original: new AggregateError([
|
|
@@ -3858,8 +4124,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
3858
4124
|
], "Release staging failed and its private temporary tree could not be removed", { cause: original })
|
|
3859
4125
|
}));
|
|
3860
4126
|
}
|
|
3861
|
-
return yield*
|
|
3862
|
-
}).pipe(
|
|
4127
|
+
return yield* Effect20.failCause(exit.cause);
|
|
4128
|
+
}).pipe(Effect20.uninterruptible);
|
|
3863
4129
|
function releaseDocuments(feed, ledger, release) {
|
|
3864
4130
|
return [
|
|
3865
4131
|
{ key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
|
|
@@ -3876,7 +4142,7 @@ function releaseDocuments(feed, ledger, release) {
|
|
|
3876
4142
|
}))
|
|
3877
4143
|
];
|
|
3878
4144
|
}
|
|
3879
|
-
var stageLocalReleaseEffect = (options) =>
|
|
4145
|
+
var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
3880
4146
|
const fs = yield* ReleaseFs;
|
|
3881
4147
|
const { tag, sourceSha, platform } = options;
|
|
3882
4148
|
const local = localConfig(options.config);
|
|
@@ -3886,12 +4152,12 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
3886
4152
|
const directory = resolve8(options.directory);
|
|
3887
4153
|
const names = [...payloads, ...policies.map((policy) => policy.name)];
|
|
3888
4154
|
yield* exactFiles(directory, names);
|
|
3889
|
-
const staged = yield*
|
|
4155
|
+
const staged = yield* Effect20.forEach(names, (name) => fileIdentityEffect(join11(directory, name), name), { concurrency: "unbounded" });
|
|
3890
4156
|
for (const policy of policies) {
|
|
3891
4157
|
const artifact = staged.find((asset) => asset.name === policy.name);
|
|
3892
4158
|
if (artifact.size > 65536)
|
|
3893
4159
|
return yield* fail("Signed descriptor is too large");
|
|
3894
|
-
const bytes = yield* step(() => fs.readFile(
|
|
4160
|
+
const bytes = yield* step(() => fs.readFile(join11(directory, policy.name)));
|
|
3895
4161
|
if ("sha256:" + createHash8("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
3896
4162
|
return yield* fail("Signed descriptor changed");
|
|
3897
4163
|
let parsed;
|
|
@@ -3913,7 +4179,7 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
3913
4179
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest)
|
|
3914
4180
|
return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
|
|
3915
4181
|
}
|
|
3916
|
-
const [ledger, remote] = yield*
|
|
4182
|
+
const [ledger, remote] = yield* Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
|
|
3917
4183
|
const entry = ledger.releases.find((item) => item.tag === tag);
|
|
3918
4184
|
if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
|
|
3919
4185
|
return yield* fail("Inconsistent feed release; reconcile publication before retrying");
|
|
@@ -3931,7 +4197,7 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
3931
4197
|
merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
|
|
3932
4198
|
uploads.push({
|
|
3933
4199
|
key: feedAssetKey(feed, tag, artifact.name),
|
|
3934
|
-
path:
|
|
4200
|
+
path: join11(directory, artifact.name),
|
|
3935
4201
|
artifact
|
|
3936
4202
|
});
|
|
3937
4203
|
}
|
|
@@ -3964,7 +4230,7 @@ function stablePlatforms(config) {
|
|
|
3964
4230
|
throw new Error("Invalid stablePlatforms in the release configuration");
|
|
3965
4231
|
return value;
|
|
3966
4232
|
}
|
|
3967
|
-
var verifyLocalReleaseEffect = (options) =>
|
|
4233
|
+
var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
3968
4234
|
const local = localConfig(options.config);
|
|
3969
4235
|
const { release, platforms } = yield* verifyFeedReleaseEffect({
|
|
3970
4236
|
config: local.config,
|
|
@@ -3980,7 +4246,7 @@ var verifyLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
3980
4246
|
missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
|
|
3981
4247
|
};
|
|
3982
4248
|
});
|
|
3983
|
-
var runLocalPromotionEffect = (options) =>
|
|
4249
|
+
var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
|
|
3984
4250
|
const local = localConfig(options.config);
|
|
3985
4251
|
const feed = local.feed;
|
|
3986
4252
|
const required = stablePlatforms(local.config);
|
|
@@ -4038,7 +4304,7 @@ var runLocalPromotionEffect = (options) => Effect18.gen(function* () {
|
|
|
4038
4304
|
const verification = qualified.get(selected.tag);
|
|
4039
4305
|
const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
|
|
4040
4306
|
const entry = ledger.releases.find((item) => item.tag === selected.tag);
|
|
4041
|
-
const [currentLedger, remote] = await run(
|
|
4307
|
+
const [currentLedger, remote] = await run(Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
|
|
4042
4308
|
concurrency: "unbounded"
|
|
4043
4309
|
}));
|
|
4044
4310
|
if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
|
|
@@ -4077,7 +4343,7 @@ var runLocalPromotionEffect = (options) => Effect18.gen(function* () {
|
|
|
4077
4343
|
|
|
4078
4344
|
// src/library/qualification-run.ts
|
|
4079
4345
|
var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
|
|
4080
|
-
var tagRun = (options) =>
|
|
4346
|
+
var tagRun = (options) => Effect21.gen(function* () {
|
|
4081
4347
|
const { tag, sha, runId } = options;
|
|
4082
4348
|
if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
|
|
4083
4349
|
return yield* fail(REFUSAL);
|
|
@@ -4091,7 +4357,7 @@ var tagRun = (options) => Effect19.gen(function* () {
|
|
|
4091
4357
|
runAttempt: 1
|
|
4092
4358
|
};
|
|
4093
4359
|
});
|
|
4094
|
-
var planQualificationRunEffect = (options) =>
|
|
4360
|
+
var planQualificationRunEffect = (options) => Effect21.gen(function* () {
|
|
4095
4361
|
const { env, config, tag } = options;
|
|
4096
4362
|
if (env.GITHUB_ACTIONS === "true") {
|
|
4097
4363
|
const plan = yield* planReleaseAssetsEffect({ env, config, tag });
|
|
@@ -4124,8 +4390,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
|
|
|
4124
4390
|
...options.git ? { git: options.git } : {}
|
|
4125
4391
|
})(planQualificationRunEffect(options)));
|
|
4126
4392
|
// src/library/retained-build.ts
|
|
4127
|
-
import { Effect as
|
|
4128
|
-
var id = (value) =>
|
|
4393
|
+
import { Effect as Effect22 } from "effect";
|
|
4394
|
+
var id = (value) => Effect22.gen(function* () {
|
|
4129
4395
|
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
4130
4396
|
return yield* fail("Invalid GitHub identity");
|
|
4131
4397
|
const text = String(value);
|
|
@@ -4133,7 +4399,7 @@ var id = (value) => Effect20.gen(function* () {
|
|
|
4133
4399
|
return yield* fail("Invalid GitHub identity");
|
|
4134
4400
|
return text;
|
|
4135
4401
|
});
|
|
4136
|
-
var selectRetainedReleaseBuildEffect = (options) =>
|
|
4402
|
+
var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
|
|
4137
4403
|
const { env, config, tag, platform } = options;
|
|
4138
4404
|
if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
|
|
4139
4405
|
return yield* fail("Invalid retained build context");
|
|
@@ -4252,9 +4518,9 @@ var selectRetainedReleaseBuildEffect = (options) => Effect20.gen(function* () {
|
|
|
4252
4518
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
4253
4519
|
// src/library/staging.ts
|
|
4254
4520
|
import { createHash as createHash9 } from "crypto";
|
|
4255
|
-
import { join as
|
|
4256
|
-
import { Effect as
|
|
4257
|
-
var copyHashed = (input, output, size) =>
|
|
4521
|
+
import { join as join12, resolve as resolve9 } from "path";
|
|
4522
|
+
import { Effect as Effect23 } from "effect";
|
|
4523
|
+
var copyHashed = (input, output, size) => Effect23.tryPromise({
|
|
4258
4524
|
try: async (signal) => {
|
|
4259
4525
|
const hash = createHash9("sha256");
|
|
4260
4526
|
let copied = 0;
|
|
@@ -4283,15 +4549,14 @@ var copyHashed = (input, output, size) => Effect21.tryPromise({
|
|
|
4283
4549
|
original: error
|
|
4284
4550
|
})
|
|
4285
4551
|
});
|
|
4286
|
-
var
|
|
4552
|
+
var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
|
|
4287
4553
|
const fs = yield* ReleaseFs;
|
|
4288
|
-
const
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
return yield* fail("Platform staging sources do not match release configuration");
|
|
4554
|
+
const { expected } = options;
|
|
4555
|
+
if (!expected.length || new Set(expected).size !== expected.length || expected.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(name)) || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
4556
|
+
return yield* fail("Staging sources do not match expected filenames");
|
|
4292
4557
|
const directory = resolve9(options.directory);
|
|
4293
4558
|
const created = [];
|
|
4294
|
-
const stage =
|
|
4559
|
+
const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
|
|
4295
4560
|
const sourcePath = options.sources[name];
|
|
4296
4561
|
if (typeof sourcePath !== "string" || !sourcePath)
|
|
4297
4562
|
return yield* fail("Invalid staging source");
|
|
@@ -4302,7 +4567,7 @@ var stagePlatformArtifactsEffect = (options) => Effect21.gen(function* () {
|
|
|
4302
4567
|
const before = yield* step(() => input.stat());
|
|
4303
4568
|
if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
|
|
4304
4569
|
return yield* fail("Staging source changed");
|
|
4305
|
-
const target =
|
|
4570
|
+
const target = join12(directory, name);
|
|
4306
4571
|
const output = yield* scopedHandle(() => fs.open(target, "wx"));
|
|
4307
4572
|
created.push(target);
|
|
4308
4573
|
const copied = yield* copyHashed(input, output, before.size);
|
|
@@ -4311,13 +4576,20 @@ var stagePlatformArtifactsEffect = (options) => Effect21.gen(function* () {
|
|
|
4311
4576
|
if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
|
|
4312
4577
|
return yield* fail("Staging source changed");
|
|
4313
4578
|
return { name, size: copied.size, digest: copied.digest };
|
|
4314
|
-
}).pipe(
|
|
4315
|
-
return yield* stage.pipe(
|
|
4579
|
+
}).pipe(Effect23.scoped), { concurrency: 1 });
|
|
4580
|
+
return yield* stage.pipe(Effect23.onError(() => Effect23.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
|
|
4581
|
+
});
|
|
4582
|
+
var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
|
|
4583
|
+
const requirements = parseReleaseConfig(options.config).requirements(options.tag);
|
|
4584
|
+
const expected = platformPayloads(requirements, options.platform);
|
|
4585
|
+
if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
4586
|
+
return yield* fail("Platform staging sources do not match release configuration");
|
|
4587
|
+
return yield* stageExpectedFilesEffect({ ...options, expected });
|
|
4316
4588
|
});
|
|
4317
4589
|
var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
|
|
4318
4590
|
// src/library/steps.ts
|
|
4319
|
-
import { join as
|
|
4320
|
-
import { Effect as
|
|
4591
|
+
import { join as join32 } from "path";
|
|
4592
|
+
import { Effect as Effect24 } from "effect";
|
|
4321
4593
|
|
|
4322
4594
|
// ../../src/installer/installer-archive-members.ts
|
|
4323
4595
|
import { createHash as createHash10 } from "crypto";
|
|
@@ -4446,11 +4718,11 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
4446
4718
|
// ../../src/installer/installer-identity.ts
|
|
4447
4719
|
import { lstat as lstat8, mkdtemp as mkdtemp4, readdir as readdir5, realpath } from "fs/promises";
|
|
4448
4720
|
import { tmpdir as tmpdir4 } from "os";
|
|
4449
|
-
import { basename as basename5, join as
|
|
4721
|
+
import { basename as basename5, join as join14, resolve as resolve10, win32 } from "path";
|
|
4450
4722
|
|
|
4451
4723
|
// ../../src/installer/installer-image-mount.ts
|
|
4452
4724
|
import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, rm as rm4, stat } from "fs/promises";
|
|
4453
|
-
import { dirname as dirname3, join as
|
|
4725
|
+
import { dirname as dirname3, join as join13 } from "path";
|
|
4454
4726
|
var FAILED_ATTACH_PROBES = 5;
|
|
4455
4727
|
var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
|
|
4456
4728
|
async function containsMountAt(path, expectedDevice) {
|
|
@@ -4460,7 +4732,7 @@ async function containsMountAt(path, expectedDevice) {
|
|
|
4460
4732
|
if (info.dev !== expectedDevice)
|
|
4461
4733
|
return true;
|
|
4462
4734
|
for (const name of await readdir4(path)) {
|
|
4463
|
-
const child =
|
|
4735
|
+
const child = join13(path, name), childInfo = await lstat7(child);
|
|
4464
4736
|
if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
|
|
4465
4737
|
continue;
|
|
4466
4738
|
if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
|
|
@@ -4654,8 +4926,8 @@ async function withInstallerImageRetries(options) {
|
|
|
4654
4926
|
};
|
|
4655
4927
|
const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
|
|
4656
4928
|
for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
|
|
4657
|
-
const directory = await mkdtemp3(
|
|
4658
|
-
const mount =
|
|
4929
|
+
const directory = await mkdtemp3(join13(options.parent, options.prefix));
|
|
4930
|
+
const mount = join13(directory, "mount");
|
|
4659
4931
|
const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
|
|
4660
4932
|
let lifecycleStarted = false;
|
|
4661
4933
|
try {
|
|
@@ -4855,7 +5127,7 @@ async function verifyInstallerPayload(options) {
|
|
|
4855
5127
|
if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
|
|
4856
5128
|
throw new Error("Installer archive exceeds bound");
|
|
4857
5129
|
const env = environment(parent);
|
|
4858
|
-
const temporary = await mkdtemp4(
|
|
5130
|
+
const temporary = await mkdtemp4(join14(tmpdir4(), "framework-installer-inspect-"));
|
|
4859
5131
|
const cleanupIo = defaultInstallerImageMountIo(command);
|
|
4860
5132
|
try {
|
|
4861
5133
|
if (options.platform === "macos-arm64") {
|
|
@@ -4869,21 +5141,21 @@ async function verifyInstallerPayload(options) {
|
|
|
4869
5141
|
const apps = (await readdir5(mount)).filter((name) => name.endsWith(".app"));
|
|
4870
5142
|
if (apps.length !== 1)
|
|
4871
5143
|
throw new Error("Installer application is missing or ambiguous");
|
|
4872
|
-
const resources =
|
|
4873
|
-
const actualRoot = await realpath(mount), actualApp = await realpath(
|
|
5144
|
+
const resources = join14(mount, apps[0], "Contents", "Resources");
|
|
5145
|
+
const actualRoot = await realpath(mount), actualApp = await realpath(join14(mount, apps[0])), actualResources = await realpath(resources);
|
|
4874
5146
|
if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
|
|
4875
5147
|
throw new Error("Installer resources escape mounted image");
|
|
4876
|
-
const plist =
|
|
5148
|
+
const plist = join14(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
|
|
4877
5149
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
4878
5150
|
throw new Error("Invalid installer property list");
|
|
4879
5151
|
const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
|
|
4880
5152
|
if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
|
|
4881
5153
|
throw new Error("Invalid installer executable name");
|
|
4882
|
-
await assertInstallerExecutable(
|
|
5154
|
+
await assertInstallerExecutable(join14(actualApp, "Contents", "MacOS", executable), options.platform);
|
|
4883
5155
|
const archives = (await readdir5(actualResources)).filter((name) => name.endsWith(".tar.zst"));
|
|
4884
5156
|
if (archives.length !== 1)
|
|
4885
5157
|
throw new Error("Installer archive is missing or ambiguous");
|
|
4886
|
-
const embedded = await identity(
|
|
5158
|
+
const embedded = await identity(join14(actualResources, archives[0]));
|
|
4887
5159
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
4888
5160
|
throw new Error("Installer archive differs from release archive");
|
|
4889
5161
|
}
|
|
@@ -4901,7 +5173,7 @@ async function verifyInstallerPayload(options) {
|
|
|
4901
5173
|
const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
|
|
4902
5174
|
if (matches.length !== 1)
|
|
4903
5175
|
throw new Error("Installer archive is missing or ambiguous");
|
|
4904
|
-
const extracted =
|
|
5176
|
+
const extracted = join14(temporary, "member");
|
|
4905
5177
|
const count = await extractArchiveMember({
|
|
4906
5178
|
tar,
|
|
4907
5179
|
archive: installerPath,
|
|
@@ -4912,7 +5184,7 @@ async function verifyInstallerPayload(options) {
|
|
|
4912
5184
|
});
|
|
4913
5185
|
if (options.platform === "windows-x64") {
|
|
4914
5186
|
const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
|
|
4915
|
-
const executable =
|
|
5187
|
+
const executable = join14(temporary, "setup.exe");
|
|
4916
5188
|
await extractArchiveMember({
|
|
4917
5189
|
tar,
|
|
4918
5190
|
archive: installerPath,
|
|
@@ -4949,18 +5221,18 @@ async function verifyInstallerPayload(options) {
|
|
|
4949
5221
|
|
|
4950
5222
|
// ../../src/installer/installer-qualification-command.ts
|
|
4951
5223
|
import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
|
|
4952
|
-
import { join as
|
|
5224
|
+
import { join as join29, resolve as resolve13 } from "path";
|
|
4953
5225
|
|
|
4954
5226
|
// ../../src/installer/installer-observation.ts
|
|
4955
5227
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
4956
5228
|
import { chmod as chmod2, mkdir as mkdir9, readFile as readFile9, realpath as realpath8, writeFile as writeFile8 } from "fs/promises";
|
|
4957
5229
|
import { createServer } from "net";
|
|
4958
|
-
import { delimiter, dirname as dirname12, join as
|
|
5230
|
+
import { delimiter, dirname as dirname12, join as join28 } from "path";
|
|
4959
5231
|
|
|
4960
5232
|
// ../../src/installer/installer-ci-bootstrap.ts
|
|
4961
5233
|
import { randomBytes } from "crypto";
|
|
4962
5234
|
import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
|
|
4963
|
-
import { dirname as dirname4, isAbsolute as isAbsolute4, join as
|
|
5235
|
+
import { dirname as dirname4, isAbsolute as isAbsolute4, join as join15, relative as relative4, sep as sep3 } from "path";
|
|
4964
5236
|
import { fileURLToPath } from "url";
|
|
4965
5237
|
var bootstrapModules = [
|
|
4966
5238
|
"app/value-guards.js",
|
|
@@ -4987,23 +5259,23 @@ async function prepareInstallerCiBootstrap(env = process.env) {
|
|
|
4987
5259
|
if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
|
|
4988
5260
|
throw new Error("Runner temp cannot represent a Bun preload path");
|
|
4989
5261
|
const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
|
|
4990
|
-
const directory = await mkdtemp5(
|
|
5262
|
+
const directory = await mkdtemp5(join15(parent, "framework-ci-"));
|
|
4991
5263
|
try {
|
|
4992
5264
|
for (const name of bootstrapModules) {
|
|
4993
|
-
const contents = await readBoundedFile(
|
|
4994
|
-
await mkdir5(dirname4(
|
|
4995
|
-
await writeFile4(
|
|
5265
|
+
const contents = await readBoundedFile(join15(source, name), 2 * 1024 * 1024, "installer bootstrap module");
|
|
5266
|
+
await mkdir5(dirname4(join15(directory, name)), { recursive: true, mode: 448 });
|
|
5267
|
+
await writeFile4(join15(directory, name), contents, { flag: "wx", mode: 384 });
|
|
4996
5268
|
}
|
|
4997
|
-
await writeFile4(
|
|
5269
|
+
await writeFile4(join15(directory, "package.json"), `{"type":"module"}
|
|
4998
5270
|
`, {
|
|
4999
5271
|
flag: "wx",
|
|
5000
5272
|
mode: 384
|
|
5001
5273
|
});
|
|
5002
|
-
const worker =
|
|
5274
|
+
const worker = join15(directory, "installer/installer-ci-worker.js");
|
|
5003
5275
|
return {
|
|
5004
5276
|
directory,
|
|
5005
5277
|
worker,
|
|
5006
|
-
preflight:
|
|
5278
|
+
preflight: join15(directory, "installer/installer-ci-preflight.js"),
|
|
5007
5279
|
bunOptions: `--preload=${worker}`
|
|
5008
5280
|
};
|
|
5009
5281
|
} catch (error) {
|
|
@@ -5018,7 +5290,7 @@ async function preflightInstallerRuntime(options) {
|
|
|
5018
5290
|
throw new Error("Runtime preflight requires a disposable hosted runner");
|
|
5019
5291
|
const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
|
|
5020
5292
|
const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
|
|
5021
|
-
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !==
|
|
5293
|
+
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join15(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join15(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
|
|
5022
5294
|
throw new Error("Invalid installer bootstrap location");
|
|
5023
5295
|
await runInstallerPreflight({
|
|
5024
5296
|
env,
|
|
@@ -5038,7 +5310,7 @@ async function runInstallerPreflight(options) {
|
|
|
5038
5310
|
const info = await lstat9(runtime);
|
|
5039
5311
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
|
|
5040
5312
|
throw new Error("Invalid candidate Bun runtime");
|
|
5041
|
-
const temporary = await mkdtemp5(
|
|
5313
|
+
const temporary = await mkdtemp5(join15(options.parent, "framework-preflight-"));
|
|
5042
5314
|
try {
|
|
5043
5315
|
const clean = {};
|
|
5044
5316
|
for (const key of [
|
|
@@ -5063,11 +5335,11 @@ async function runInstallerPreflight(options) {
|
|
|
5063
5335
|
BUN_OPTIONS: `--preload=${worker}`,
|
|
5064
5336
|
FRAMEWORK_CI_WORKER_ENTRY: preflight,
|
|
5065
5337
|
FRAMEWORK_CI_NONCE: nonce,
|
|
5066
|
-
FRAMEWORK_CI_ACK:
|
|
5067
|
-
FRAMEWORK_CI_PERMIT:
|
|
5338
|
+
FRAMEWORK_CI_ACK: join15(temporary, "ack"),
|
|
5339
|
+
FRAMEWORK_CI_PERMIT: join15(temporary, "permit"),
|
|
5068
5340
|
FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
|
|
5069
|
-
FRAMEWORK_CI_OBSERVATION:
|
|
5070
|
-
FRAMEWORK_CI_UNEXPECTED:
|
|
5341
|
+
FRAMEWORK_CI_OBSERVATION: join15(temporary, "observation"),
|
|
5342
|
+
FRAMEWORK_CI_UNEXPECTED: join15(temporary, "unexpected"),
|
|
5071
5343
|
FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
|
|
5072
5344
|
"https://example.invalid/framework-ci-sentinel"
|
|
5073
5345
|
])
|
|
@@ -5102,7 +5374,7 @@ async function runInstallerPreflight(options) {
|
|
|
5102
5374
|
if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
|
|
5103
5375
|
throw new Error("Candidate Bun runtime failed installer preflight");
|
|
5104
5376
|
try {
|
|
5105
|
-
await lstat9(
|
|
5377
|
+
await lstat9(join15(temporary, "unexpected"));
|
|
5106
5378
|
throw new Error("Runtime preflight recorded unexpected activity");
|
|
5107
5379
|
} catch (error) {
|
|
5108
5380
|
if (errorCode(error) !== "ENOENT")
|
|
@@ -5115,7 +5387,7 @@ async function runInstallerPreflight(options) {
|
|
|
5115
5387
|
|
|
5116
5388
|
// ../../src/installer/installer-extraction.ts
|
|
5117
5389
|
import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir6, realpath as realpath3 } from "fs/promises";
|
|
5118
|
-
import { join as
|
|
5390
|
+
import { join as join16, resolve as resolve11, win32 as win322 } from "path";
|
|
5119
5391
|
async function run(cmd, env) {
|
|
5120
5392
|
return runInstallerCommand(cmd, env, {
|
|
5121
5393
|
outputLimit: 8 * 1024 * 1024,
|
|
@@ -5123,7 +5395,7 @@ async function run(cmd, env) {
|
|
|
5123
5395
|
failureMessage: "Installer preparation command failed"
|
|
5124
5396
|
});
|
|
5125
5397
|
}
|
|
5126
|
-
async function
|
|
5398
|
+
async function digest2(path) {
|
|
5127
5399
|
const info = await lstat10(path);
|
|
5128
5400
|
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
|
|
5129
5401
|
throw new Error("Invalid extracted file");
|
|
@@ -5167,10 +5439,10 @@ async function prepareInstallerExecution(options) {
|
|
|
5167
5439
|
archive: sourceArchive,
|
|
5168
5440
|
env
|
|
5169
5441
|
});
|
|
5170
|
-
const directory = await mkdtemp6(
|
|
5442
|
+
const directory = await mkdtemp6(join16(parent, "framework-installer-"));
|
|
5171
5443
|
const imageIo = defaultInstallerImageMountIo(run);
|
|
5172
5444
|
try {
|
|
5173
|
-
const profile =
|
|
5445
|
+
const profile = join16(directory, "profile"), incoming = join16(directory, "incoming");
|
|
5174
5446
|
await mkdir6(profile, { mode: 448 });
|
|
5175
5447
|
await mkdir6(incoming, { mode: 448 });
|
|
5176
5448
|
const clean = cleanEnv(env);
|
|
@@ -5186,31 +5458,31 @@ async function prepareInstallerExecution(options) {
|
|
|
5186
5458
|
const appName = `${options.appName}.app`, apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
|
|
5187
5459
|
if (apps.length !== 1 || apps[0] !== appName)
|
|
5188
5460
|
throw new Error("Unexpected installer application");
|
|
5189
|
-
const sourceApp = await realpath3(
|
|
5461
|
+
const sourceApp = await realpath3(join16(mount, appName)), mountRoot = await realpath3(mount);
|
|
5190
5462
|
if (!isWithin(mountRoot, sourceApp))
|
|
5191
5463
|
throw new Error("Installer application escapes image");
|
|
5192
|
-
const app =
|
|
5464
|
+
const app = join16(incoming, appName);
|
|
5193
5465
|
await run(["/usr/bin/ditto", sourceApp, app], clean);
|
|
5194
|
-
const actualApp = await realpath3(app), resources = await realpath3(
|
|
5466
|
+
const actualApp = await realpath3(app), resources = await realpath3(join16(actualApp, "Contents", "Resources"));
|
|
5195
5467
|
if (!isWithin(await realpath3(incoming), actualApp) || !isWithin(actualApp, resources))
|
|
5196
5468
|
throw new Error("Copied installer escapes profile");
|
|
5197
|
-
const plist =
|
|
5469
|
+
const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
|
|
5198
5470
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5199
5471
|
throw new Error("Invalid installer property list");
|
|
5200
5472
|
const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
|
|
5201
5473
|
if (!name || name === "." || name === ".." || /[\\/]/.test(name))
|
|
5202
5474
|
throw new Error("Invalid installer executable");
|
|
5203
|
-
const appExecutable =
|
|
5204
|
-
const sourceExecutable =
|
|
5475
|
+
const appExecutable = join16(actualApp, "Contents", "MacOS", name);
|
|
5476
|
+
const sourceExecutable = join16(sourceApp, "Contents", "MacOS", name);
|
|
5205
5477
|
if (!isWithin(actualApp, await realpath3(appExecutable)) || !isWithin(sourceApp, await realpath3(sourceExecutable)))
|
|
5206
5478
|
throw new Error("Installer executable escapes application");
|
|
5207
5479
|
await assertInstallerExecutable(appExecutable, options.platform);
|
|
5208
|
-
if (JSON.stringify(await
|
|
5480
|
+
if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
|
|
5209
5481
|
throw new Error("Copied installer executable differs");
|
|
5210
5482
|
const archives = (await readdir6(resources)).filter((value) => value.endsWith(".tar.zst"));
|
|
5211
5483
|
if (archives.length !== 1)
|
|
5212
5484
|
throw new Error("Missing installer archive");
|
|
5213
|
-
const embedded = await
|
|
5485
|
+
const embedded = await digest2(join16(resources, archives[0]));
|
|
5214
5486
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5215
5487
|
throw new Error("Copied installer archive differs");
|
|
5216
5488
|
return executable;
|
|
@@ -5225,9 +5497,9 @@ async function prepareInstallerExecution(options) {
|
|
|
5225
5497
|
assertInstallerLayout(options.platform, options.appName, names);
|
|
5226
5498
|
const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
|
|
5227
5499
|
if (options.platform === "windows-x64") {
|
|
5228
|
-
const subdirectory =
|
|
5500
|
+
const subdirectory = join16(incoming, ".installer");
|
|
5229
5501
|
await mkdir6(subdirectory);
|
|
5230
|
-
executable =
|
|
5502
|
+
executable = join16(incoming, `${options.appName}-Setup.exe`);
|
|
5231
5503
|
await extractArchiveMember({
|
|
5232
5504
|
tar,
|
|
5233
5505
|
archive: sourceInstaller,
|
|
@@ -5241,11 +5513,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5241
5513
|
tar,
|
|
5242
5514
|
archive: sourceInstaller,
|
|
5243
5515
|
member: find(`.installer/${options.appName}-Setup.metadata.json`),
|
|
5244
|
-
destination:
|
|
5516
|
+
destination: join16(subdirectory, `${options.appName}-Setup.metadata.json`),
|
|
5245
5517
|
maximum: 1024 * 1024,
|
|
5246
5518
|
env: clean
|
|
5247
5519
|
});
|
|
5248
|
-
const embeddedPath =
|
|
5520
|
+
const embeddedPath = join16(subdirectory, `${options.appName}-Setup.tar.zst`);
|
|
5249
5521
|
await extractArchiveMember({
|
|
5250
5522
|
tar,
|
|
5251
5523
|
archive: sourceInstaller,
|
|
@@ -5254,11 +5526,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5254
5526
|
maximum: verified.archive.size,
|
|
5255
5527
|
env: clean
|
|
5256
5528
|
});
|
|
5257
|
-
const embedded = await
|
|
5529
|
+
const embedded = await digest2(embeddedPath);
|
|
5258
5530
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5259
5531
|
throw new Error("Copied installer archive differs");
|
|
5260
5532
|
} else {
|
|
5261
|
-
executable =
|
|
5533
|
+
executable = join16(incoming, "installer");
|
|
5262
5534
|
await extractArchiveMember({
|
|
5263
5535
|
tar,
|
|
5264
5536
|
archive: sourceInstaller,
|
|
@@ -5317,7 +5589,7 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
5317
5589
|
import { createHash as createHash11 } from "crypto";
|
|
5318
5590
|
import { lstat as lstat11, open as open5, realpath as realpath4, rm as rm6 } from "fs/promises";
|
|
5319
5591
|
import { once } from "events";
|
|
5320
|
-
import { join as
|
|
5592
|
+
import { join as join17, resolve as resolve12 } from "path";
|
|
5321
5593
|
import { createZstdDecompress } from "zlib";
|
|
5322
5594
|
import { Parser } from "tar";
|
|
5323
5595
|
function cleanEnv2(parent, forceLocal) {
|
|
@@ -5488,7 +5760,7 @@ async function verifyInstalledPayload(options) {
|
|
|
5488
5760
|
const member = members.get(path);
|
|
5489
5761
|
if (!member || member.count !== 1)
|
|
5490
5762
|
throw new Error("Archive member missing or ambiguous");
|
|
5491
|
-
const current = await installed(
|
|
5763
|
+
const current = await installed(join17(root, name), root, limit);
|
|
5492
5764
|
if (member.size !== current.size || member.digest !== current.digest)
|
|
5493
5765
|
throw new Error(`Installed file differs from archive: ${name}`);
|
|
5494
5766
|
if (name === "Resources/version.json") {
|
|
@@ -5523,7 +5795,7 @@ async function extractCandidateRuntime(options) {
|
|
|
5523
5795
|
const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
5524
5796
|
const expected = `${prefix}/bun${suffix}`;
|
|
5525
5797
|
const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
|
|
5526
|
-
const destination =
|
|
5798
|
+
const destination = join17(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
|
|
5527
5799
|
const spawn = () => Bun.spawn({
|
|
5528
5800
|
cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
|
|
5529
5801
|
env: tarEnv,
|
|
@@ -5730,7 +6002,7 @@ async function windowsRunningExecutable(pid) {
|
|
|
5730
6002
|
|
|
5731
6003
|
// ../../src/updates/install/update-swap-stage.ts
|
|
5732
6004
|
import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
|
|
5733
|
-
import { join as
|
|
6005
|
+
import { join as join27 } from "path";
|
|
5734
6006
|
|
|
5735
6007
|
// ../../src/updates/install/update-handoff-plan.ts
|
|
5736
6008
|
import { basename as basename6 } from "path";
|
|
@@ -5772,7 +6044,7 @@ function planUpdateHandoff(options) {
|
|
|
5772
6044
|
import { createHash as createHash12 } from "crypto";
|
|
5773
6045
|
import { constants as constants4 } from "fs";
|
|
5774
6046
|
import { lstat as lstat12, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open6, readFile as readFile6, realpath as realpath6, rm as rm7, symlink } from "fs/promises";
|
|
5775
|
-
import { isAbsolute as isAbsolute5, join as
|
|
6047
|
+
import { isAbsolute as isAbsolute5, join as join18 } from "path";
|
|
5776
6048
|
import { Transform } from "stream";
|
|
5777
6049
|
import { pipeline } from "stream/promises";
|
|
5778
6050
|
import { createZstdDecompress as createZstdDecompress2 } from "zlib";
|
|
@@ -5818,8 +6090,8 @@ async function extractVerifiedUpdate(options) {
|
|
|
5818
6090
|
const parent = await realpath6(options.directory);
|
|
5819
6091
|
if (!(await lstat12(parent)).isDirectory())
|
|
5820
6092
|
throw new Error("Invalid update staging directory");
|
|
5821
|
-
directory = await mkdtemp7(
|
|
5822
|
-
const payloadRoot =
|
|
6093
|
+
directory = await mkdtemp7(join18(parent, "framework-update-extract-"));
|
|
6094
|
+
const payloadRoot = join18(directory, "payload"), decompressed = join18(directory, "payload.tar");
|
|
5823
6095
|
await mkdir7(payloadRoot, { mode: 448 });
|
|
5824
6096
|
const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
|
|
5825
6097
|
let invalid = false;
|
|
@@ -5937,14 +6209,14 @@ async function extractVerifiedUpdate(options) {
|
|
|
5937
6209
|
if (invalid)
|
|
5938
6210
|
throw new Error("Unsafe or unsupported update archive entry");
|
|
5939
6211
|
if (links.length) {
|
|
5940
|
-
const bin =
|
|
5941
|
-
for (const path of [
|
|
6212
|
+
const bin = join18(payloadRoot, archiveRoot, "bin"), cef = join18(bin, "cef");
|
|
6213
|
+
for (const path of [join18(payloadRoot, archiveRoot), bin, cef]) {
|
|
5942
6214
|
const value = await lstat12(path);
|
|
5943
6215
|
if (!value.isDirectory() || value.isSymbolicLink())
|
|
5944
6216
|
throw new Error("Invalid CEF link directory");
|
|
5945
6217
|
}
|
|
5946
6218
|
for (const link of links) {
|
|
5947
|
-
const destination =
|
|
6219
|
+
const destination = join18(payloadRoot, link.path), target = join18(bin, link.target), value = await lstat12(target);
|
|
5948
6220
|
if (!value.isFile() || value.isSymbolicLink())
|
|
5949
6221
|
throw new Error("Invalid CEF link target");
|
|
5950
6222
|
await symlink(link.target, destination);
|
|
@@ -5952,12 +6224,12 @@ async function extractVerifiedUpdate(options) {
|
|
|
5952
6224
|
}
|
|
5953
6225
|
await rm7(decompressed);
|
|
5954
6226
|
assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
|
|
5955
|
-
const prefix = platform === "macos-arm64" ?
|
|
5956
|
-
const resources =
|
|
6227
|
+
const prefix = platform === "macos-arm64" ? join18(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
|
|
6228
|
+
const resources = join18(payloadRoot, prefix, "Resources");
|
|
5957
6229
|
const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
|
|
5958
6230
|
const executables = [
|
|
5959
|
-
|
|
5960
|
-
|
|
6231
|
+
join18(bin, `launcher${suffix}`),
|
|
6232
|
+
join18(bin, `bun${suffix}`),
|
|
5961
6233
|
...sidecars.map((name) => sidecarBundlePath(name, platform))
|
|
5962
6234
|
];
|
|
5963
6235
|
const critical = [
|
|
@@ -5967,21 +6239,21 @@ async function extractVerifiedUpdate(options) {
|
|
|
5967
6239
|
"Resources/app/client/index.html"
|
|
5968
6240
|
];
|
|
5969
6241
|
for (const path of critical) {
|
|
5970
|
-
const item = await lstat12(
|
|
6242
|
+
const item = await lstat12(join18(payloadRoot, prefix, path));
|
|
5971
6243
|
if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
|
|
5972
6244
|
throw new Error("Invalid critical update file");
|
|
5973
6245
|
}
|
|
5974
6246
|
for (const name of ["version.json", "build.json"]) {
|
|
5975
|
-
const metadata = await lstat12(
|
|
6247
|
+
const metadata = await lstat12(join18(resources, name));
|
|
5976
6248
|
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
|
|
5977
6249
|
throw new Error("Invalid update metadata");
|
|
5978
6250
|
}
|
|
5979
|
-
if (JSON.parse(await readFile6(
|
|
6251
|
+
if (JSON.parse(await readFile6(join18(resources, "version.json"), "utf8")).version !== descriptor.version)
|
|
5980
6252
|
throw new Error("Update version mismatch");
|
|
5981
|
-
assertBuildMetadata(JSON.parse(await readFile6(
|
|
6253
|
+
assertBuildMetadata(JSON.parse(await readFile6(join18(resources, "build.json"), "utf8")), renderer);
|
|
5982
6254
|
return {
|
|
5983
6255
|
directory,
|
|
5984
|
-
payload:
|
|
6256
|
+
payload: join18(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
|
|
5985
6257
|
};
|
|
5986
6258
|
} catch (error) {
|
|
5987
6259
|
if (directory)
|
|
@@ -5996,16 +6268,16 @@ async function extractVerifiedUpdate(options) {
|
|
|
5996
6268
|
import { createHash as createHash13 } from "crypto";
|
|
5997
6269
|
import { constants as constants7 } from "fs";
|
|
5998
6270
|
import { lstat as lstat13, open as open9, readdir as readdir7, readFile as readFile7, readlink as readlink2 } from "fs/promises";
|
|
5999
|
-
import { basename as basename8, dirname as dirname6, join as
|
|
6271
|
+
import { basename as basename8, dirname as dirname6, join as join21 } from "path";
|
|
6000
6272
|
|
|
6001
6273
|
// ../../src/updates/update-state-store.ts
|
|
6002
6274
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6003
6275
|
import { constants as constants6 } from "fs";
|
|
6004
6276
|
import { open as open8, rename, unlink, writeFile as writeFile5 } from "fs/promises";
|
|
6005
|
-
import { join as
|
|
6277
|
+
import { join as join20 } from "path";
|
|
6006
6278
|
|
|
6007
6279
|
// ../../src/updates/locks/update-lock.ts
|
|
6008
|
-
import { basename as basename7, dirname as dirname5, join as
|
|
6280
|
+
import { basename as basename7, dirname as dirname5, join as join19 } from "path";
|
|
6009
6281
|
|
|
6010
6282
|
// ../../src/updates/locks/native-file-lock.ts
|
|
6011
6283
|
import { constants as constants5 } from "fs";
|
|
@@ -6173,7 +6445,7 @@ async function tryAcquireWindows(path, mode) {
|
|
|
6173
6445
|
function updateLockPath(target) {
|
|
6174
6446
|
if (!isCanonicalPath(target))
|
|
6175
6447
|
throw new Error("Invalid update lock target");
|
|
6176
|
-
return
|
|
6448
|
+
return join19(dirname5(target), `.${basename7(target)}.framework-update.lock`);
|
|
6177
6449
|
}
|
|
6178
6450
|
async function tryAcquireUpdateLock(target) {
|
|
6179
6451
|
return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
|
|
@@ -6238,7 +6510,7 @@ function parseState(value) {
|
|
|
6238
6510
|
return Object.freeze(record);
|
|
6239
6511
|
}
|
|
6240
6512
|
async function readUpdateStageState(staging) {
|
|
6241
|
-
const text = await readSmallStateFile(
|
|
6513
|
+
const text = await readSmallStateFile(join20(staging, "state.json"), 4096, "Invalid update staging state");
|
|
6242
6514
|
return text === undefined ? undefined : parseState(JSON.parse(text));
|
|
6243
6515
|
}
|
|
6244
6516
|
async function writeUpdateStageState(staging, state) {
|
|
@@ -6247,8 +6519,8 @@ async function writeUpdateStageState(staging, state) {
|
|
|
6247
6519
|
async function replaceUpdateStageState(staging, state, durable) {
|
|
6248
6520
|
if (typeof state.generation !== "string" || !isUuid(state.generation))
|
|
6249
6521
|
throw new Error("Invalid update staging state");
|
|
6250
|
-
const path =
|
|
6251
|
-
const temporary =
|
|
6522
|
+
const path = join20(staging, "state.json");
|
|
6523
|
+
const temporary = join20(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
|
|
6252
6524
|
const contents = JSON.stringify(state) + `
|
|
6253
6525
|
`;
|
|
6254
6526
|
let renamed = false;
|
|
@@ -6286,10 +6558,10 @@ async function withUpdateLock(target, operation) {
|
|
|
6286
6558
|
function updateStagingFor(target) {
|
|
6287
6559
|
if (!isCanonicalPath(target))
|
|
6288
6560
|
throw new Error("Invalid update target");
|
|
6289
|
-
return
|
|
6561
|
+
return join21(dirname6(target), `.${basename8(target)}.framework-update`);
|
|
6290
6562
|
}
|
|
6291
6563
|
async function readUpdateTreeVersion(tree) {
|
|
6292
|
-
const versionPath =
|
|
6564
|
+
const versionPath = join21(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
6293
6565
|
try {
|
|
6294
6566
|
const value = JSON.parse(await readFile7(versionPath, "utf8"));
|
|
6295
6567
|
if (typeof value !== "object" || value === null || typeof value.version !== "string")
|
|
@@ -6383,7 +6655,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6383
6655
|
if (before.isDirectory()) {
|
|
6384
6656
|
const names = (await limit(() => readdir7(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
|
|
6385
6657
|
const children = await Promise.all(names.map(async (name) => {
|
|
6386
|
-
const childPath =
|
|
6658
|
+
const childPath = join21(path, name);
|
|
6387
6659
|
return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat13(childPath, { bigint: true })));
|
|
6388
6660
|
}));
|
|
6389
6661
|
return [{ kind: "directory", path, relative, before }, ...children.flat()];
|
|
@@ -6526,8 +6798,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6526
6798
|
const { target, staging } = options;
|
|
6527
6799
|
if (dirname6(staging) !== dirname6(target) || staging === target)
|
|
6528
6800
|
throw new Error("Invalid update swap context");
|
|
6529
|
-
const candidate =
|
|
6530
|
-
const legacyOld =
|
|
6801
|
+
const candidate = join21(staging, "candidate");
|
|
6802
|
+
const legacyOld = join21(staging, "old");
|
|
6531
6803
|
if (await pathExists(legacyOld))
|
|
6532
6804
|
throw new Error("A legacy update tree requires recovery before another swap");
|
|
6533
6805
|
await assertDirectory(target);
|
|
@@ -6557,10 +6829,10 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6557
6829
|
|
|
6558
6830
|
// ../../src/updates/retention/retirement-inventory.ts
|
|
6559
6831
|
import { lstat as lstat15, readdir as readdir9 } from "fs/promises";
|
|
6560
|
-
import { basename as basename12, dirname as dirname10, join as
|
|
6832
|
+
import { basename as basename12, dirname as dirname10, join as join25 } from "path";
|
|
6561
6833
|
|
|
6562
6834
|
// ../../src/updates/retention/update-retention-marker.ts
|
|
6563
|
-
import { basename as basename9, dirname as dirname7, join as
|
|
6835
|
+
import { basename as basename9, dirname as dirname7, join as join22 } from "path";
|
|
6564
6836
|
var LOWERCASE_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6565
6837
|
var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
|
|
6566
6838
|
function assertCanonicalTarget(target) {
|
|
@@ -6579,28 +6851,28 @@ function isTreeIdentity(value) {
|
|
|
6579
6851
|
function updateRetentionIntentPath(target, generation) {
|
|
6580
6852
|
assertCanonicalTarget(target);
|
|
6581
6853
|
assertGeneration(generation);
|
|
6582
|
-
return
|
|
6854
|
+
return join22(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
|
|
6583
6855
|
}
|
|
6584
6856
|
|
|
6585
6857
|
// ../../src/updates/retention/retention-prune-progress.ts
|
|
6586
|
-
import { basename as basename11, dirname as dirname9, join as
|
|
6858
|
+
import { basename as basename11, dirname as dirname9, join as join24 } from "path";
|
|
6587
6859
|
|
|
6588
6860
|
// ../../src/updates/retention/retirement-records.ts
|
|
6589
6861
|
import { lstat as lstat14, readdir as readdir8, writeFile as writeFile6 } from "fs/promises";
|
|
6590
|
-
import { basename as basename10, dirname as dirname8, join as
|
|
6862
|
+
import { basename as basename10, dirname as dirname8, join as join23 } from "path";
|
|
6591
6863
|
function updateRetirementPaths(target, generation) {
|
|
6592
6864
|
if (!isCanonicalPath(target) || !isUuid(generation))
|
|
6593
6865
|
throw new Error("Invalid update retirement identity");
|
|
6594
6866
|
const prefix = `.${basename10(target)}.framework-retired-${generation}`;
|
|
6595
|
-
const container =
|
|
6867
|
+
const container = join23(dirname8(target), prefix);
|
|
6596
6868
|
return Object.freeze({
|
|
6597
6869
|
container,
|
|
6598
|
-
tree:
|
|
6599
|
-
healthReceipt:
|
|
6870
|
+
tree: join23(container, "tree"),
|
|
6871
|
+
healthReceipt: join23(container, "healthy.json"),
|
|
6600
6872
|
healthTemporaryPrefix: ".healthy-",
|
|
6601
|
-
claim:
|
|
6873
|
+
claim: join23(dirname8(target), `${prefix}.claim.json`),
|
|
6602
6874
|
claimTemporaryPrefix: `${prefix}.claim-`,
|
|
6603
|
-
cleanupMarker:
|
|
6875
|
+
cleanupMarker: join23(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
|
|
6604
6876
|
cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
|
|
6605
6877
|
});
|
|
6606
6878
|
}
|
|
@@ -6704,10 +6976,10 @@ async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
|
|
|
6704
6976
|
|
|
6705
6977
|
// ../../src/updates/retention/update-retirement.ts
|
|
6706
6978
|
import { lstat as lstat16, mkdir as mkdir8, readdir as readdir10, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
|
|
6707
|
-
import { basename as basename13, dirname as dirname11, join as
|
|
6979
|
+
import { basename as basename13, dirname as dirname11, join as join26 } from "path";
|
|
6708
6980
|
async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
6709
6981
|
const { target, staging, currentVersion } = options;
|
|
6710
|
-
const markerPath =
|
|
6982
|
+
const markerPath = join26(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
|
|
6711
6983
|
const markerInfo = await pathInfo(markerPath);
|
|
6712
6984
|
if (!markerInfo)
|
|
6713
6985
|
return "none";
|
|
@@ -6748,7 +7020,7 @@ async function assertInstalledVersion(options) {
|
|
|
6748
7020
|
const info = await lstat17(options.target);
|
|
6749
7021
|
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(options.target) !== options.target)
|
|
6750
7022
|
throw new Error("Invalid update install target");
|
|
6751
|
-
const versionFile =
|
|
7023
|
+
const versionFile = join27(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
6752
7024
|
const versionInfo = await lstat17(versionFile);
|
|
6753
7025
|
if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
|
|
6754
7026
|
throw new Error("Installed update version mismatch");
|
|
@@ -6772,7 +7044,7 @@ async function stageUpdateSwap(options) {
|
|
|
6772
7044
|
});
|
|
6773
7045
|
const staging = updateStagingFor(plan.target);
|
|
6774
7046
|
const preparing = await mkdtemp8(`${staging}.preparing-`);
|
|
6775
|
-
const candidate =
|
|
7047
|
+
const candidate = join27(staging, "candidate");
|
|
6776
7048
|
let published = false;
|
|
6777
7049
|
try {
|
|
6778
7050
|
const extracted = await extractVerifiedUpdate({
|
|
@@ -6786,12 +7058,12 @@ async function stageUpdateSwap(options) {
|
|
|
6786
7058
|
maxExpandedBytes: options.maxExpandedBytes,
|
|
6787
7059
|
...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
|
|
6788
7060
|
});
|
|
6789
|
-
renameExclusive(extracted.payload,
|
|
7061
|
+
renameExclusive(extracted.payload, join27(preparing, "candidate"));
|
|
6790
7062
|
await rm8(extracted.directory, { recursive: true, force: true });
|
|
6791
|
-
const candidateTreeIdentity = await readUpdateTreeIdentity(
|
|
7063
|
+
const candidateTreeIdentity = await readUpdateTreeIdentity(join27(preparing, "candidate"));
|
|
6792
7064
|
if (!candidateTreeIdentity)
|
|
6793
7065
|
throw new Error("Update candidate tree identity could not be read");
|
|
6794
|
-
const candidateTreeDigest = await readUpdateTreeDigest(
|
|
7066
|
+
const candidateTreeDigest = await readUpdateTreeDigest(join27(preparing, "candidate"));
|
|
6795
7067
|
await writeUpdateStageState(preparing, newUpdateStageState({
|
|
6796
7068
|
version: plan.version,
|
|
6797
7069
|
previousVersion: options.currentVersion,
|
|
@@ -6876,11 +7148,11 @@ function isolatedEnv(parent, profile, platform) {
|
|
|
6876
7148
|
RUNNER_ENVIRONMENT: "github-hosted",
|
|
6877
7149
|
HOME: profile,
|
|
6878
7150
|
USERPROFILE: profile,
|
|
6879
|
-
LOCALAPPDATA:
|
|
6880
|
-
XDG_DATA_HOME:
|
|
6881
|
-
TMP:
|
|
6882
|
-
TEMP:
|
|
6883
|
-
TMPDIR:
|
|
7151
|
+
LOCALAPPDATA: join28(profile, "LocalAppData"),
|
|
7152
|
+
XDG_DATA_HOME: join28(profile, ".local", "share"),
|
|
7153
|
+
TMP: join28(profile, "tmp"),
|
|
7154
|
+
TEMP: join28(profile, "tmp"),
|
|
7155
|
+
TMPDIR: join28(profile, "tmp"),
|
|
6884
7156
|
ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
|
|
6885
7157
|
});
|
|
6886
7158
|
if (platform === "windows-x64")
|
|
@@ -6975,15 +7247,15 @@ async function observeInstalledApp(options) {
|
|
|
6975
7247
|
await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
|
|
6976
7248
|
stage("runtime-preflight-passed");
|
|
6977
7249
|
for (const path of [
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
7250
|
+
join28(prepared.profile, "LocalAppData"),
|
|
7251
|
+
join28(prepared.profile, ".local", "share"),
|
|
7252
|
+
join28(prepared.profile, "tmp")
|
|
6981
7253
|
])
|
|
6982
7254
|
await mkdir9(path, { recursive: true, mode: 448 });
|
|
6983
7255
|
const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
|
|
6984
|
-
const installedRoot = mac ?
|
|
6985
|
-
const resources =
|
|
6986
|
-
const worker =
|
|
7256
|
+
const installedRoot = mac ? join28(prepared.incoming, `${options.appName}.app`, "Contents") : join28(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
|
|
7257
|
+
const resources = join28(installedRoot, "Resources"), binary = join28(installedRoot, mac ? "MacOS" : "bin"), launcher = join28(binary, windows ? "launcher.exe" : "launcher"), runtime = join28(binary, windows ? "bun.exe" : "bun");
|
|
7258
|
+
const worker = join28(resources, "app", "bun", "index.js");
|
|
6987
7259
|
const sidecars = options.sidecars ?? [];
|
|
6988
7260
|
let foreignHits = 0;
|
|
6989
7261
|
const sentinel = policy ? Bun.serve({
|
|
@@ -7034,7 +7306,7 @@ async function observeInstalledApp(options) {
|
|
|
7034
7306
|
throw new Error("Foreign network sentinel unavailable");
|
|
7035
7307
|
foreignHits = 0;
|
|
7036
7308
|
const nonce = randomBytes2(24).toString("hex");
|
|
7037
|
-
const ack =
|
|
7309
|
+
const ack = join28(run.directory, "ack"), permit = join28(run.directory, "permit"), observation = join28(run.directory, "observation"), unexpected = join28(run.directory, "unexpected"), pidRecord = join28(run.directory, "worker-pid");
|
|
7038
7310
|
const env = {
|
|
7039
7311
|
...baseEnv,
|
|
7040
7312
|
FRAMEWORK_CI_NONCE: nonce,
|
|
@@ -7047,13 +7319,13 @@ async function observeInstalledApp(options) {
|
|
|
7047
7319
|
};
|
|
7048
7320
|
let launchRecord, expectedApp;
|
|
7049
7321
|
if (mac && viaInstaller) {
|
|
7050
|
-
const shimDir =
|
|
7322
|
+
const shimDir = join28(run.directory, "launch-shim");
|
|
7051
7323
|
await mkdir9(shimDir, { mode: 448 });
|
|
7052
|
-
const path =
|
|
7324
|
+
const path = join28(shimDir, "open");
|
|
7053
7325
|
await writeFile8(path, shim, { flag: "wx", mode: 448 });
|
|
7054
7326
|
await chmod2(path, 448);
|
|
7055
|
-
expectedApp =
|
|
7056
|
-
launchRecord =
|
|
7327
|
+
expectedApp = join28(await realpath8(prepared.incoming), `${options.appName}.app`);
|
|
7328
|
+
launchRecord = join28(run.directory, "launch-record");
|
|
7057
7329
|
Object.assign(env, {
|
|
7058
7330
|
PATH: shimDir + delimiter + (env.PATH ?? ""),
|
|
7059
7331
|
FRAMEWORK_CI_EXPECTED_APP: expectedApp,
|
|
@@ -7089,7 +7361,7 @@ async function observeInstalledApp(options) {
|
|
|
7089
7361
|
const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
|
|
7090
7362
|
throw new Error(`Installer exited unsuccessfully (exit=${installer.exitCode}, signal=${installer.signalCode ?? "none"}, ` + `ready=${await pathExists(worker) && await pathExists(launcher)}, acknowledged=${await pathExists(ack)}, ` + `error=${error ?? "none"})`);
|
|
7091
7363
|
}
|
|
7092
|
-
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(
|
|
7364
|
+
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join28(resources, "version.json"));
|
|
7093
7365
|
if (installer && shouldLaunchInstalledApp({
|
|
7094
7366
|
platform: options.platform,
|
|
7095
7367
|
ready,
|
|
@@ -7265,7 +7537,7 @@ async function observeInstalledApp(options) {
|
|
|
7265
7537
|
await swapAfterExit(target, staged.staging);
|
|
7266
7538
|
stage("update-swapped");
|
|
7267
7539
|
await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
|
|
7268
|
-
const directory =
|
|
7540
|
+
const directory = join28(prepared.directory, "update");
|
|
7269
7541
|
await mkdir9(directory, { mode: 448 });
|
|
7270
7542
|
const updated = await observeRun({
|
|
7271
7543
|
directory,
|
|
@@ -7314,7 +7586,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
7314
7586
|
const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
|
|
7315
7587
|
if (!policy || !names || names.length !== 2)
|
|
7316
7588
|
throw new Error("Installer qualification requires an explicit offline policy and payloads");
|
|
7317
|
-
const directory = resolve13(options.directory), destination =
|
|
7589
|
+
const directory = resolve13(options.directory), destination = join29(directory, `installer-test-${platform}.json`);
|
|
7318
7590
|
try {
|
|
7319
7591
|
await lstat18(destination);
|
|
7320
7592
|
throw new Error("Installer receipt already exists");
|
|
@@ -7330,8 +7602,8 @@ async function qualifyInstallerCommand(options) {
|
|
|
7330
7602
|
appName: app.appName,
|
|
7331
7603
|
appId: app.appId,
|
|
7332
7604
|
version: plan.version,
|
|
7333
|
-
installer:
|
|
7334
|
-
archive:
|
|
7605
|
+
installer: join29(directory, names[0]),
|
|
7606
|
+
archive: join29(directory, names[1]),
|
|
7335
7607
|
expectedReads: parsed.expectedReads,
|
|
7336
7608
|
offlinePolicy: policy,
|
|
7337
7609
|
sidecars: parsed.sidecars
|
|
@@ -7363,7 +7635,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
7363
7635
|
|
|
7364
7636
|
// ../../src/installer/installer-upgrade-command.ts
|
|
7365
7637
|
import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
|
|
7366
|
-
import { join as
|
|
7638
|
+
import { join as join31, resolve as resolve15 } from "path";
|
|
7367
7639
|
|
|
7368
7640
|
// ../../src/installer/upgrade-asset-download.ts
|
|
7369
7641
|
import { createHash as createHash14 } from "crypto";
|
|
@@ -7499,7 +7771,7 @@ async function discoverSignedRelease(options) {
|
|
|
7499
7771
|
|
|
7500
7772
|
// ../../src/updates/install/update-download.ts
|
|
7501
7773
|
import { mkdtemp as mkdtemp9, open as open11, realpath as realpath9, rm as rm9 } from "fs/promises";
|
|
7502
|
-
import { basename as basename14, dirname as dirname13, join as
|
|
7774
|
+
import { basename as basename14, dirname as dirname13, join as join30, resolve as resolve14 } from "path";
|
|
7503
7775
|
async function downloadVerifiedRelease(options) {
|
|
7504
7776
|
const { descriptor, maxBytes } = options;
|
|
7505
7777
|
const timeout = options.timeoutMs ?? 120000;
|
|
@@ -7532,12 +7804,12 @@ async function downloadVerifiedRelease(options) {
|
|
|
7532
7804
|
throw new Error("Release download size mismatch");
|
|
7533
7805
|
}
|
|
7534
7806
|
const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
|
|
7535
|
-
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(
|
|
7807
|
+
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join30(root, "framework-update-"));
|
|
7536
7808
|
const temporaryDirectory = resolve14(allocated);
|
|
7537
7809
|
if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
|
|
7538
7810
|
throw new Error("Invalid update download directory");
|
|
7539
7811
|
temporary = temporaryDirectory;
|
|
7540
|
-
const path =
|
|
7812
|
+
const path = join30(temporary, "archive");
|
|
7541
7813
|
const file = await open11(path, "wx", 384);
|
|
7542
7814
|
try {
|
|
7543
7815
|
async function* writeChunks() {
|
|
@@ -7640,7 +7912,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7640
7912
|
const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
|
|
7641
7913
|
if (!requirements.offlinePolicy || !names || names.length !== 2)
|
|
7642
7914
|
throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
|
|
7643
|
-
const directory = resolve15(options.directory), destination =
|
|
7915
|
+
const directory = resolve15(options.directory), destination = join31(directory, `upgrade-test-${platform}.json`);
|
|
7644
7916
|
try {
|
|
7645
7917
|
await lstat19(destination);
|
|
7646
7918
|
throw new Error("Upgrade receipt already exists");
|
|
@@ -7663,7 +7935,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7663
7935
|
const channel = "daily";
|
|
7664
7936
|
const trust = { ...base, channel };
|
|
7665
7937
|
const discovery = discoveryName(config, channel, platform);
|
|
7666
|
-
const signed = await readJsonFile(
|
|
7938
|
+
const signed = await readJsonFile(join31(directory, discovery), 65536, "staged descriptor");
|
|
7667
7939
|
const verified = verifyReleaseDescriptor(signed, trust);
|
|
7668
7940
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
|
|
7669
7941
|
throw new Error("Untrusted staged descriptor");
|
|
@@ -7686,7 +7958,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7686
7958
|
return null;
|
|
7687
7959
|
if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
|
|
7688
7960
|
throw new Error("Previous release is not older than this release");
|
|
7689
|
-
const work =
|
|
7961
|
+
const work = join31(directory, `upgrade-${platform}`);
|
|
7690
7962
|
await mkdir10(work, { mode: 448 });
|
|
7691
7963
|
const downloaded = await downloadVerifiedRelease({
|
|
7692
7964
|
descriptor: previous,
|
|
@@ -7695,12 +7967,12 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7695
7967
|
timeoutMs: 600000,
|
|
7696
7968
|
fetch: fetcher
|
|
7697
7969
|
});
|
|
7698
|
-
const previousArchive =
|
|
7970
|
+
const previousArchive = join31(work, previous.asset.name);
|
|
7699
7971
|
await rename2(downloaded.path, previousArchive);
|
|
7700
7972
|
const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
|
|
7701
7973
|
if (!installerName)
|
|
7702
7974
|
throw new Error("Previous release has no installer for this platform");
|
|
7703
|
-
const previousInstaller =
|
|
7975
|
+
const previousInstaller = join31(work, installerName);
|
|
7704
7976
|
await downloadAsset({
|
|
7705
7977
|
feed,
|
|
7706
7978
|
tag: previous.tag,
|
|
@@ -7724,7 +7996,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7724
7996
|
update: {
|
|
7725
7997
|
descriptor,
|
|
7726
7998
|
trust,
|
|
7727
|
-
archive:
|
|
7999
|
+
archive: join31(directory, names[1]),
|
|
7728
8000
|
maxCompressedBytes: MAX_COMPRESSED_BYTES2,
|
|
7729
8001
|
maxExpandedBytes: MAX_EXPANDED_BYTES2
|
|
7730
8002
|
}
|
|
@@ -7779,7 +8051,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
7779
8051
|
}
|
|
7780
8052
|
|
|
7781
8053
|
// src/library/steps.ts
|
|
7782
|
-
var selectRetainedStepEffect = (context) =>
|
|
8054
|
+
var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
|
|
7783
8055
|
const output = context.env.GITHUB_OUTPUT;
|
|
7784
8056
|
if (!output)
|
|
7785
8057
|
return yield* fail("Expected GITHUB_OUTPUT");
|
|
@@ -7791,7 +8063,7 @@ runId=${result.runId}
|
|
|
7791
8063
|
` : `reuse=false
|
|
7792
8064
|
`));
|
|
7793
8065
|
});
|
|
7794
|
-
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") =>
|
|
8066
|
+
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
|
|
7795
8067
|
const fs = yield* ReleaseFs;
|
|
7796
8068
|
const [installerAsset, archiveAsset] = platformAssets(context);
|
|
7797
8069
|
const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
|
|
@@ -7800,12 +8072,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
|
|
|
7800
8072
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
7801
8073
|
const packed = yield* scopedTempDirectory("framework-command-pack-");
|
|
7802
8074
|
const sources = {
|
|
7803
|
-
[installerAsset]:
|
|
7804
|
-
[archiveAsset]:
|
|
8075
|
+
[installerAsset]: join32(artifacts, installer),
|
|
8076
|
+
[archiveAsset]: join32(artifacts, archive)
|
|
7805
8077
|
};
|
|
7806
8078
|
for (const policy of parsed.commandArtifacts) {
|
|
7807
8079
|
const name = requirements.commandArtifacts[policy.kind][context.platform];
|
|
7808
|
-
sources[name] =
|
|
8080
|
+
sources[name] = join32(packed, name);
|
|
7809
8081
|
yield* step(() => packCommandArtifact({
|
|
7810
8082
|
source: policy.build,
|
|
7811
8083
|
archive: sources[name],
|
|
@@ -7814,8 +8086,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
|
|
|
7814
8086
|
}));
|
|
7815
8087
|
}
|
|
7816
8088
|
return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
|
|
7817
|
-
}).pipe(
|
|
7818
|
-
var inspectStagedStepEffect = (context, directory) =>
|
|
8089
|
+
}).pipe(Effect24.scoped);
|
|
8090
|
+
var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
|
|
7819
8091
|
const fs = yield* ReleaseFs;
|
|
7820
8092
|
const parsed = parseReleaseConfig(context.config);
|
|
7821
8093
|
const requirements = parsed.requirements(context.tag);
|
|
@@ -7823,10 +8095,10 @@ var inspectStagedStepEffect = (context, directory) => Effect22.gen(function* ()
|
|
|
7823
8095
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
7824
8096
|
if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
|
|
7825
8097
|
return yield* fail("Staged platform directory contains unexpected files");
|
|
7826
|
-
const [installer, archive] = platformAssets(context).map((name) =>
|
|
8098
|
+
const [installer, archive] = platformAssets(context).map((name) => join32(directory, name));
|
|
7827
8099
|
for (const policy of parsed.commandArtifacts)
|
|
7828
8100
|
yield* step(() => readCommandArtifact({
|
|
7829
|
-
archive:
|
|
8101
|
+
archive: join32(directory, requirements.commandArtifacts[policy.kind][context.platform]),
|
|
7830
8102
|
executable: policy.executable,
|
|
7831
8103
|
platform: context.platform
|
|
7832
8104
|
}));
|
|
@@ -7842,12 +8114,12 @@ var inspectStagedStepEffect = (context, directory) => Effect22.gen(function* ()
|
|
|
7842
8114
|
}))
|
|
7843
8115
|
};
|
|
7844
8116
|
});
|
|
7845
|
-
var qualifyStepEffect = (context, directory) =>
|
|
8117
|
+
var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
|
|
7846
8118
|
const mode = stepRenderer(context.env);
|
|
7847
8119
|
yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
|
|
7848
8120
|
yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
|
|
7849
8121
|
});
|
|
7850
|
-
var qualifyUpgradeStepEffect = (context, directory, onStage) =>
|
|
8122
|
+
var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
|
|
7851
8123
|
const renderer = stepRenderer(context.env);
|
|
7852
8124
|
return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
|
|
7853
8125
|
});
|
|
@@ -7857,13 +8129,216 @@ var stageBuildStep = (context, directory, artifacts) => run2(context, stageBuild
|
|
|
7857
8129
|
var inspectStagedStep = (context, directory) => run2(context, inspectStagedStepEffect(context, directory));
|
|
7858
8130
|
var qualifyStep = (context, directory) => run2(context, qualifyStepEffect(context, directory));
|
|
7859
8131
|
var qualifyUpgradeStep = (context, directory, onStage) => run2(context, qualifyUpgradeStepEffect(context, directory, onStage));
|
|
8132
|
+
// src/library/linux-package-pair.ts
|
|
8133
|
+
import { execFile as execFile3 } from "child_process";
|
|
8134
|
+
import {
|
|
8135
|
+
chmod as chmod3,
|
|
8136
|
+
link,
|
|
8137
|
+
mkdir as mkdir11,
|
|
8138
|
+
mkdtemp as mkdtemp10,
|
|
8139
|
+
open as open12,
|
|
8140
|
+
readFile as readFile10,
|
|
8141
|
+
realpath as realpath10,
|
|
8142
|
+
rm as rm10,
|
|
8143
|
+
writeFile as writeFile11
|
|
8144
|
+
} from "fs/promises";
|
|
8145
|
+
import { dirname as dirname14, join as join33, resolve as resolve16 } from "path";
|
|
8146
|
+
import { promisify as promisify2 } from "util";
|
|
8147
|
+
var shasum = /^[a-f0-9]{64}$/;
|
|
8148
|
+
var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
8149
|
+
var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
8150
|
+
var exec = promisify2(execFile3);
|
|
8151
|
+
function requireThat2(condition, message) {
|
|
8152
|
+
if (!condition)
|
|
8153
|
+
throw new Error(message);
|
|
8154
|
+
}
|
|
8155
|
+
function record2(value) {
|
|
8156
|
+
requireThat2(typeof value === "object" && value !== null && !Array.isArray(value), "Invalid producer receipt");
|
|
8157
|
+
return value;
|
|
8158
|
+
}
|
|
8159
|
+
function validIdentity(value) {
|
|
8160
|
+
const { name, size, sha256 } = record2(value);
|
|
8161
|
+
requireThat2(typeof name === "string" && basename15.test(name) && typeof size === "number" && Number.isSafeInteger(size) && size > 0 && typeof sha256 === "string" && shasum.test(sha256), "Invalid package artifact identity");
|
|
8162
|
+
return { name, size, sha256 };
|
|
8163
|
+
}
|
|
8164
|
+
var inspectWithNativeTools = async (tool, args) => {
|
|
8165
|
+
try {
|
|
8166
|
+
const { stdout } = await exec(tool, [...args], {
|
|
8167
|
+
encoding: "utf8",
|
|
8168
|
+
maxBuffer: 128 * 1024,
|
|
8169
|
+
timeout: 30000,
|
|
8170
|
+
env: { PATH: process.env.PATH, LC_ALL: "C" }
|
|
8171
|
+
});
|
|
8172
|
+
return stdout;
|
|
8173
|
+
} catch (error) {
|
|
8174
|
+
if (error.code === "ENOENT")
|
|
8175
|
+
throw new Error(`${tool} is required to inspect Linux package candidates`, { cause: error });
|
|
8176
|
+
throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
|
|
8177
|
+
}
|
|
8178
|
+
};
|
|
8179
|
+
function parseDebianIdentity(text, packageName, version) {
|
|
8180
|
+
const fields = text.trimEnd().split(/\r?\n/);
|
|
8181
|
+
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`, "Architecture: amd64"].every((value) => fields.includes(value)), "Debian package name, version or architecture does not match the release policy");
|
|
8182
|
+
}
|
|
8183
|
+
function requireRegularDesktopEntry(listing, id) {
|
|
8184
|
+
const lines = listing.trimEnd().split(/\r?\n/);
|
|
8185
|
+
const fields = /^[d-][-rwxstST]{9} +\d+\/\d+ +\d+ +\d{4}-\d{2}-\d{2} \d{2}:\d{2} (.+)$/;
|
|
8186
|
+
requireThat2(lines.length === 2 && lines[0]?.startsWith("d") && fields.exec(lines[0])?.[1] === "squashfs-root" && lines[1]?.startsWith("-") && fields.exec(lines[1])?.[1] === `squashfs-root/${id}`, "AppImage must contain one regular root desktop entry");
|
|
8187
|
+
}
|
|
8188
|
+
function requireDesktopIdentity(text, name, version) {
|
|
8189
|
+
let inDesktop = false;
|
|
8190
|
+
let foundGroup = false;
|
|
8191
|
+
const fields = new Map;
|
|
8192
|
+
for (const line of text.split(/\r?\n/)) {
|
|
8193
|
+
if (/^\[.*\]$/.test(line)) {
|
|
8194
|
+
inDesktop = line === "[Desktop Entry]";
|
|
8195
|
+
if (inDesktop) {
|
|
8196
|
+
requireThat2(!foundGroup, "Duplicate AppImage desktop entry");
|
|
8197
|
+
foundGroup = true;
|
|
8198
|
+
}
|
|
8199
|
+
continue;
|
|
8200
|
+
}
|
|
8201
|
+
if (!inDesktop || !line || line.startsWith("#"))
|
|
8202
|
+
continue;
|
|
8203
|
+
const match = /^([^=]+)=(.*)$/.exec(line);
|
|
8204
|
+
requireThat2(match && !fields.has(match[1]), "Malformed or duplicate AppImage desktop fields");
|
|
8205
|
+
fields.set(match[1], match[2]);
|
|
8206
|
+
}
|
|
8207
|
+
requireThat2(fields.get("Type") === "Application" && fields.get("Name") === name && fields.get("X-AppImage-Version") === version, "AppImage desktop entry has wrong app identity or release version");
|
|
8208
|
+
}
|
|
8209
|
+
function digestWindow(runtime) {
|
|
8210
|
+
const sectionStart = Number(runtime.readBigUInt64LE(40));
|
|
8211
|
+
const sectionSize = runtime.readUInt16LE(58);
|
|
8212
|
+
const count = runtime.readUInt16LE(60);
|
|
8213
|
+
const namesIndex = runtime.readUInt16LE(62);
|
|
8214
|
+
requireThat2(Number.isSafeInteger(sectionStart) && sectionStart >= 64 && sectionSize === 64 && namesIndex < count && sectionStart + count * sectionSize <= runtime.length, "Invalid pinned AppImage runtime ELF section table");
|
|
8215
|
+
const namesHeader = sectionStart + sectionSize * namesIndex;
|
|
8216
|
+
const namesStart = Number(runtime.readBigUInt64LE(namesHeader + 24));
|
|
8217
|
+
const namesSize = Number(runtime.readBigUInt64LE(namesHeader + 32));
|
|
8218
|
+
requireThat2(Number.isSafeInteger(namesStart) && Number.isSafeInteger(namesSize) && namesStart >= 64 && namesStart + namesSize <= runtime.length, "Invalid pinned AppImage runtime ELF section names");
|
|
8219
|
+
const names = runtime.subarray(namesStart, namesStart + namesSize);
|
|
8220
|
+
const matches = [];
|
|
8221
|
+
for (let i = 0;i < count; i++) {
|
|
8222
|
+
const section = sectionStart + sectionSize * i;
|
|
8223
|
+
const nameAt = runtime.readUInt32LE(section);
|
|
8224
|
+
const end = names.indexOf(0, nameAt);
|
|
8225
|
+
if (end < 0 || names.toString("ascii", nameAt, end) !== ".digest_md5")
|
|
8226
|
+
continue;
|
|
8227
|
+
const dataAt = Number(runtime.readBigUInt64LE(section + 24));
|
|
8228
|
+
const dataSize = Number(runtime.readBigUInt64LE(section + 32));
|
|
8229
|
+
requireThat2(Number.isSafeInteger(dataAt) && Number.isSafeInteger(dataSize) && dataAt >= 64 && dataSize >= 16 && dataAt + dataSize <= runtime.length, "Invalid pinned AppImage runtime digest section");
|
|
8230
|
+
matches.push(dataAt);
|
|
8231
|
+
}
|
|
8232
|
+
requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
|
|
8233
|
+
return matches[0];
|
|
8234
|
+
}
|
|
8235
|
+
function type2X64(bytes) {
|
|
8236
|
+
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === 62;
|
|
8237
|
+
}
|
|
8238
|
+
async function verifyEmbeddedRuntime(path, runtime) {
|
|
8239
|
+
requireThat2(type2X64(runtime), "Expected a pinned Type 2 x86_64 AppImage runtime");
|
|
8240
|
+
const ignored = digestWindow(runtime);
|
|
8241
|
+
const fd = await open12(path, "r");
|
|
8242
|
+
try {
|
|
8243
|
+
const prefix = Buffer.alloc(runtime.length + 4);
|
|
8244
|
+
let filled = 0;
|
|
8245
|
+
while (filled < prefix.length) {
|
|
8246
|
+
const { bytesRead } = await fd.read(prefix, filled, prefix.length - filled, filled);
|
|
8247
|
+
if (!bytesRead)
|
|
8248
|
+
throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
|
|
8249
|
+
filled += bytesRead;
|
|
8250
|
+
}
|
|
8251
|
+
requireThat2(type2X64(prefix), "Expected a Type 2 x86_64 AppImage");
|
|
8252
|
+
requireThat2(runtime.subarray(0, ignored).equals(prefix.subarray(0, ignored)) && runtime.subarray(ignored + 16).equals(prefix.subarray(ignored + 16, runtime.length)), "AppImage runtime differs from its trusted pin outside the tool-generated digest");
|
|
8253
|
+
requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
|
|
8254
|
+
} finally {
|
|
8255
|
+
await fd.close();
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
8259
|
+
const { expected, sources } = options;
|
|
8260
|
+
const receipt = record2(options.producer);
|
|
8261
|
+
const archive = validIdentity(expected.archive);
|
|
8262
|
+
const runtime = validIdentity(expected.runtime);
|
|
8263
|
+
requireThat2(validTag.test(expected.tag) && /^[a-f0-9]{40}$/.test(expected.sourceSha) && basename15.test(expected.debName) && expected.debName.endsWith(".deb") && basename15.test(expected.appImageName) && expected.appImageName.endsWith(".AppImage") && archive.name.endsWith(".tar.zst") && /^[a-z0-9][a-z0-9+.-]+$/.test(expected.debPackage) && /^[A-Za-z0-9][A-Za-z0-9_.-]*\.desktop$/.test(expected.desktopId) && expected.desktopName.length > 0 && !/[\r\n]/.test(expected.desktopName) && Number.isSafeInteger(expected.runtime.size) && expected.runtime.size >= 64 && expected.runtime.size <= 64 * 1024 * 1024 && shasum.test(expected.runtime.sha256), "Invalid trusted Linux package policy");
|
|
8264
|
+
requireThat2(receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === "linux-x64" && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
|
|
8265
|
+
const names = [expected.debName, expected.appImageName];
|
|
8266
|
+
const artifacts = receipt.artifacts.map(validIdentity);
|
|
8267
|
+
const trustedArtifacts = expected.artifacts.map(validIdentity);
|
|
8268
|
+
requireThat2(trustedArtifacts.length === 2 && names.every((name) => {
|
|
8269
|
+
const fromProducer = artifacts.find((file) => file.name === name);
|
|
8270
|
+
const trusted = trustedArtifacts.find((file) => file.name === name);
|
|
8271
|
+
return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
|
|
8272
|
+
}), "Package producer receipt must describe exactly the protected DEB and AppImage");
|
|
8273
|
+
const destination = resolve16(options.output);
|
|
8274
|
+
const parent = await realpath10(dirname14(destination));
|
|
8275
|
+
const work = await mkdtemp10(join33(parent, ".linux-package-pair-"));
|
|
8276
|
+
try {
|
|
8277
|
+
const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
|
|
8278
|
+
directory: work,
|
|
8279
|
+
expected: [...names, archive.name, runtime.name],
|
|
8280
|
+
sources
|
|
8281
|
+
})));
|
|
8282
|
+
requireThat2([...artifacts, archive, runtime].every((asset) => files.some((file) => file.name === asset.name && file.size === asset.size && file.digest === `sha256:${asset.sha256}`)), "Staged package or update archive does not agree with its bound size and digest");
|
|
8283
|
+
const deb = join33(work, expected.debName);
|
|
8284
|
+
const image = join33(work, expected.appImageName);
|
|
8285
|
+
const version = expected.tag.slice(1);
|
|
8286
|
+
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
|
|
8287
|
+
await verifyEmbeddedRuntime(image, await readFile10(join33(work, runtime.name)));
|
|
8288
|
+
const offset = String(runtime.size);
|
|
8289
|
+
requireRegularDesktopEntry(await inspect("unsquashfs", [
|
|
8290
|
+
"-offset",
|
|
8291
|
+
offset,
|
|
8292
|
+
"-lln",
|
|
8293
|
+
"-no-wildcards",
|
|
8294
|
+
image,
|
|
8295
|
+
expected.desktopId
|
|
8296
|
+
]), expected.desktopId);
|
|
8297
|
+
requireDesktopIdentity(await inspect("unsquashfs", [
|
|
8298
|
+
"-offset",
|
|
8299
|
+
offset,
|
|
8300
|
+
"-cat",
|
|
8301
|
+
"-no-wildcards",
|
|
8302
|
+
image,
|
|
8303
|
+
expected.desktopId
|
|
8304
|
+
]), expected.desktopName, version);
|
|
8305
|
+
await chmod3(image, 493);
|
|
8306
|
+
const staged = {
|
|
8307
|
+
schema: "linux-package-pair/v1",
|
|
8308
|
+
tag: expected.tag,
|
|
8309
|
+
sourceSha: expected.sourceSha,
|
|
8310
|
+
platform: "linux-x64",
|
|
8311
|
+
updateArchiveSha256: archive.sha256,
|
|
8312
|
+
artifacts: names.map((name) => artifacts.find((file) => file.name === name))
|
|
8313
|
+
};
|
|
8314
|
+
await mkdir11(destination);
|
|
8315
|
+
try {
|
|
8316
|
+
for (const name of names)
|
|
8317
|
+
await link(join33(work, name), join33(destination, name));
|
|
8318
|
+
await writeFile11(join33(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
|
|
8319
|
+
`, {
|
|
8320
|
+
flag: "wx"
|
|
8321
|
+
});
|
|
8322
|
+
} catch (error) {
|
|
8323
|
+
await rm10(destination, { recursive: true, force: true });
|
|
8324
|
+
throw error;
|
|
8325
|
+
}
|
|
8326
|
+
return staged;
|
|
8327
|
+
} finally {
|
|
8328
|
+
await rm10(work, { recursive: true, force: true });
|
|
8329
|
+
}
|
|
8330
|
+
}
|
|
8331
|
+
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
7860
8332
|
export {
|
|
8333
|
+
createDailyNativeReceipt,
|
|
7861
8334
|
createGitHubPromotionProvider,
|
|
7862
8335
|
createGitHubReleasePublisher,
|
|
7863
8336
|
createMacosDmg,
|
|
8337
|
+
desktopDailyProfile,
|
|
7864
8338
|
fileIdentity2 as fileIdentity,
|
|
7865
8339
|
finalizeReleasePleaseDraft,
|
|
7866
8340
|
inspectStagedStep,
|
|
8341
|
+
planDailyReleaseMatrix,
|
|
7867
8342
|
planQualificationRun2 as planQualificationRun,
|
|
7868
8343
|
planReleaseAssets2 as planReleaseAssets,
|
|
7869
8344
|
publishFrameworkPackage,
|
|
@@ -7878,8 +8353,10 @@ export {
|
|
|
7878
8353
|
selectRetainedStep,
|
|
7879
8354
|
signReleaseArtifact,
|
|
7880
8355
|
stageBuildStep,
|
|
8356
|
+
stageLinuxPackagePair,
|
|
7881
8357
|
stagePlatformArtifacts,
|
|
7882
8358
|
stageReleaseDescriptors,
|
|
8359
|
+
verifyDailyReleaseMatrix,
|
|
7883
8360
|
verifyImage,
|
|
7884
8361
|
writeDescriptors
|
|
7885
8362
|
};
|