@akanjs/devkit 3.3.1-rc.0 → 3.4.0-rc.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/codeAgent/skills/akan-runtime/SKILL.md +1 -1
- package/mobile/nativeApi.test.ts +2 -2
- package/mobile/nativeApi.ts +4 -3
- package/mobile/nativeApp.test.ts +105 -0
- package/mobile/nativeApp.ts +120 -3
- package/mobile/updatePackFolder.test.ts +5 -0
- package/mobile/updatePackFolder.ts +40 -4
- package/mobile/updateUploader.test.ts +41 -3
- package/mobile/updateUploader.ts +12 -4
- package/package.json +3 -3
- package/pipeline/PipelineCompiler.test.ts +224 -0
- package/pipeline/PipelineCompiler.ts +59 -19
- package/pipeline/PipelineDefinition.test.ts +25 -0
- package/pipeline/PipelineDefinition.ts +2 -1
- package/pipeline/PipelineDryRun.test.ts +54 -0
- package/pipeline/PipelineDryRun.ts +11 -4
- package/pipeline/PipelineInputReader.ts +42 -2
- package/pipeline/PipelineRules.ts +5 -1
|
@@ -56,7 +56,7 @@ A `start-*` command loads its pages from a running `akan start`; a desktop app c
|
|
|
56
56
|
akan start-desktop <app> # Run the desktop app on this computer
|
|
57
57
|
akan start-ios <app> # Run it in a simulator or on an iPhone (start-android alike)
|
|
58
58
|
akan build-desktop <app> # Build it for this computer into dist/native/<app>/<target>/build
|
|
59
|
-
akan build-desktop <app> --installer true #
|
|
59
|
+
akan build-desktop <app> --installer true # Add its installer: a setup program, a dmg, an AppImage and tar.gz
|
|
60
60
|
akan update-keygen <app> # Make the update signing key once; print its public key
|
|
61
61
|
akan publish-update <app> # Build a key-signed release for updates.url; --sign true also code-signs it
|
|
62
62
|
```
|
package/mobile/nativeApi.test.ts
CHANGED
|
@@ -42,7 +42,7 @@ describe("NativeApi", () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test("refuses an API older than the one the build calls into, and another major, before anything builds", async () => {
|
|
45
|
-
await expect(NativeApi.load(await installVendoredApi("0.
|
|
45
|
+
await expect(NativeApi.load(await installVendoredApi("0.13.4"))).rejects.toThrow(
|
|
46
46
|
"install matching versions of akanjs and @akanjs/cli",
|
|
47
47
|
);
|
|
48
48
|
await expect(NativeApi.load(await installVendoredApi("0.10.0"))).rejects.toThrow(
|
|
@@ -54,6 +54,6 @@ describe("NativeApi", () => {
|
|
|
54
54
|
expect((await NativeApi.load(await installVendoredApi(NativeApi.minimumVersion))).API_VERSION).toBe(
|
|
55
55
|
NativeApi.minimumVersion,
|
|
56
56
|
);
|
|
57
|
-
expect((await NativeApi.load(await installVendoredApi("0.
|
|
57
|
+
expect((await NativeApi.load(await installVendoredApi("0.14.4"))).API_VERSION).toBe("0.14.4");
|
|
58
58
|
});
|
|
59
59
|
});
|
package/mobile/nativeApi.ts
CHANGED
|
@@ -6,9 +6,10 @@ export type NativeBuildApiModule = typeof NativeBuildApi;
|
|
|
6
6
|
export class NativeApi {
|
|
7
7
|
//* The build API versions itself; a major this devkit was not written against is refused before anything builds.
|
|
8
8
|
static readonly supportedMajor = 0;
|
|
9
|
-
//? A desktop
|
|
10
|
-
//?
|
|
11
|
-
|
|
9
|
+
//? A desktop app's unsigned pack and `republishUpdate` arrived in 0.14.0; a desktop release's envelope and
|
|
10
|
+
//? `updates.target` in 0.13.0, and an older API refuses the key; an update release's `revoke` and `resetSequence` in
|
|
11
|
+
//? 0.12.0; `requestedDistribution` in 0.11.0; akanjs 3.0.x vendors 0.10.0.
|
|
12
|
+
static readonly minimumVersion = "0.14.0";
|
|
12
13
|
|
|
13
14
|
/** The API of the akanjs the app installed: the workspace package inside this repo, akanjs's vendored copy elsewhere. */
|
|
14
15
|
static entryOf(appDir: string): string {
|
package/mobile/nativeApp.test.ts
CHANGED
|
@@ -223,6 +223,111 @@ describe("NativeApp", () => {
|
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
+
describe("a desktop app's unsigned pack", () => {
|
|
227
|
+
const updates = { url: "https://releases.example.com/portal", publicKey: `${"a".repeat(43)}=` };
|
|
228
|
+
const sha = (char: string) => char.repeat(64);
|
|
229
|
+
const packing = async (config: Partial<AkanNativeTarget>) => {
|
|
230
|
+
const root = await makeTempRoot();
|
|
231
|
+
const app = {
|
|
232
|
+
...fakeApp(),
|
|
233
|
+
workspace: { workspaceRoot: root },
|
|
234
|
+
logger: { info: () => undefined, warn: () => undefined },
|
|
235
|
+
} as unknown as App;
|
|
236
|
+
const nativeApp = new NativeApp(app, target(config), "main");
|
|
237
|
+
const asked: Record<string, unknown>[] = [];
|
|
238
|
+
nativeApp.assembleWeb = async () => undefined as never;
|
|
239
|
+
nativeApp.prepare = async () =>
|
|
240
|
+
({
|
|
241
|
+
config: { updates: { channel: "pilot" } },
|
|
242
|
+
api: {
|
|
243
|
+
requestedDistribution: () => ({ macos: { sign: true }, unused: [] }),
|
|
244
|
+
packAppUpdate: async (options: Record<string, unknown> & { out: string; previous?: string }) => {
|
|
245
|
+
asked.push(options);
|
|
246
|
+
return {
|
|
247
|
+
build: { artifacts: [], warnings: [] },
|
|
248
|
+
out: options.out,
|
|
249
|
+
signer: { teamId: "TEAM123456" },
|
|
250
|
+
manifest: {
|
|
251
|
+
schema: 2,
|
|
252
|
+
kind: "app",
|
|
253
|
+
app: "com.portal.app",
|
|
254
|
+
platform: "macos",
|
|
255
|
+
arch: "arm64",
|
|
256
|
+
version: "1.0.0",
|
|
257
|
+
build: 1700000000,
|
|
258
|
+
server: true,
|
|
259
|
+
files: [{ path: "app.tar", sha256: sha("b"), size: 4096 }],
|
|
260
|
+
archive: { url: `app/${sha("b")}.tar.gz`, sha256: sha("b"), gzSha256: sha("c"), size: 1024 },
|
|
261
|
+
patches: options.previous
|
|
262
|
+
? [{ from: sha("a"), url: `app/${sha("a")}-${sha("b")}.delta.gz`, sha256: sha("d"), size: 64 }]
|
|
263
|
+
: [],
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
}) as never;
|
|
269
|
+
return { root, nativeApp, asked };
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
test("is recorded in pack.json: the archive, the app's signer and build, and the delta --previous asked for", async () => {
|
|
273
|
+
const { root, nativeApp, asked } = await packing({ updates });
|
|
274
|
+
const out = nativeApp.appPackDir("macos", "arm64");
|
|
275
|
+
expect(out).toBe(path.join(root, "dist/native/portal/default/updates/macos-arm64"));
|
|
276
|
+
|
|
277
|
+
const { pack } = await nativeApp.packAppUpdate("macos", { arch: "arm64", sign: true });
|
|
278
|
+
expect(asked[0]).toMatchObject({ platform: "macos", out, arch: "arm64", macos: { sign: true } });
|
|
279
|
+
expect(asked[0]).not.toHaveProperty("previous");
|
|
280
|
+
const record = await Bun.file(path.join(out, "pack.json")).json();
|
|
281
|
+
expect(record).toEqual({ ...pack, out: undefined });
|
|
282
|
+
expect(record).toMatchObject({
|
|
283
|
+
schema: 2,
|
|
284
|
+
kind: "app",
|
|
285
|
+
app: "portal",
|
|
286
|
+
target: "default",
|
|
287
|
+
platform: "macos",
|
|
288
|
+
arch: "arm64",
|
|
289
|
+
env: "main",
|
|
290
|
+
channel: "pilot",
|
|
291
|
+
appId: "com.portal.app",
|
|
292
|
+
appVersion: "1.0.0",
|
|
293
|
+
build: 1700000000,
|
|
294
|
+
server: true,
|
|
295
|
+
signer: { teamId: "TEAM123456" },
|
|
296
|
+
archive: {
|
|
297
|
+
url: `app/${sha("b")}.tar.gz`,
|
|
298
|
+
tarSha256: sha("b"),
|
|
299
|
+
tarSize: 4096,
|
|
300
|
+
gzSha256: sha("c"),
|
|
301
|
+
gzSize: 1024,
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
expect(record).not.toHaveProperty("patch");
|
|
305
|
+
expect(typeof record.cli).toBe("string");
|
|
306
|
+
expect(Number.isNaN(Date.parse(record.builtAt))).toBe(false);
|
|
307
|
+
|
|
308
|
+
const elsewhere = path.join(root, "elsewhere");
|
|
309
|
+
const previous = `https://releases.example.com/portal/macos-arm64/app/${sha("a")}.tar.gz`;
|
|
310
|
+
const delta = await nativeApp.packAppUpdate("macos", { out: elsewhere, previous });
|
|
311
|
+
expect(asked[1]).toMatchObject({ out: elsewhere, previous });
|
|
312
|
+
expect(delta.pack.patch).toEqual({
|
|
313
|
+
from: sha("a"),
|
|
314
|
+
url: `app/${sha("a")}-${sha("b")}.delta.gz`,
|
|
315
|
+
sha256: sha("d"),
|
|
316
|
+
size: 64,
|
|
317
|
+
});
|
|
318
|
+
expect((await Bun.file(path.join(elsewhere, "pack.json")).json()).patch).toEqual(delta.pack.patch);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("is refused, like a republish, for a target with no updates before anything builds", async () => {
|
|
322
|
+
const { nativeApp, asked } = await packing({});
|
|
323
|
+
await expect(nativeApp.packAppUpdate("macos")).rejects.toThrow("Native target 'default' has no updates");
|
|
324
|
+
await expect(nativeApp.republishUpdate("macos", { bundle: "1.0.0-1" })).rejects.toThrow(
|
|
325
|
+
"Native target 'default' has no updates",
|
|
326
|
+
);
|
|
327
|
+
expect(asked).toEqual([]);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
226
331
|
test("a dev build bundles no page a release build left, and builds apart from the release it would empty", async () => {
|
|
227
332
|
const root = await makeTempRoot();
|
|
228
333
|
const app = {
|
package/mobile/nativeApp.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { NativePluginFolders } from "./nativePluginFolders";
|
|
|
21
21
|
import { NativePublicEnv, type PublicEnv } from "./nativePublicEnv";
|
|
22
22
|
import { NativeWebDir } from "./nativeWebDir";
|
|
23
23
|
import { ServerBundleSecrets } from "./serverBundleSecrets";
|
|
24
|
-
import { type NativeUpdatePack, UpdatePackFolder } from "./updatePackFolder";
|
|
24
|
+
import { type DesktopUpdatePack, type NativeUpdatePack, UpdatePackFolder } from "./updatePackFolder";
|
|
25
25
|
|
|
26
26
|
type TaskOptions = Parameters<NativeBuildApiModule["build"]>[0];
|
|
27
27
|
type DeviceSelector = NonNullable<Parameters<NativeBuildApiModule["run"]>[0]["device"]>;
|
|
@@ -44,7 +44,7 @@ export interface NativeBuildOptions {
|
|
|
44
44
|
profile?: "debug" | "release";
|
|
45
45
|
/** The server a desktop app carries (the target's `desktop.server`), staged by DesktopServerStage. */
|
|
46
46
|
server?: DesktopServerBundle;
|
|
47
|
-
/** What a person downloads beside the app: a Windows NSIS setup program, a macOS dmg, a Linux AppImage. */
|
|
47
|
+
/** What a person downloads beside the app: a Windows NSIS setup program, a macOS dmg, a Linux AppImage and tar.gz. */
|
|
48
48
|
installer?: boolean;
|
|
49
49
|
/** The CPU the desktop app runs on, of the same OS; a macOS app is arm64 only. Default this computer's. */
|
|
50
50
|
arch?: DesktopArch;
|
|
@@ -376,6 +376,122 @@ export class NativeApp {
|
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
//? Beside the releases publishUpdate signs for the same OS and CPU: both name an archive by its hash, so one a pack
|
|
380
|
+
//? wrote is the one a later publish or --previous finds.
|
|
381
|
+
appPackDir(platform: DesktopPlatform, arch: DesktopArch = process.arch as DesktopArch) {
|
|
382
|
+
return path.join(this.updatesDir, `${platform}-${arch}`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* A desktop release this target's updates folder published, signed again as its channel's newest: the same archive
|
|
387
|
+
* under a new sequence, so installs on a later build go back to it. Nothing is built.
|
|
388
|
+
*/
|
|
389
|
+
async republishUpdate(
|
|
390
|
+
platform: DesktopPlatform,
|
|
391
|
+
{
|
|
392
|
+
bundle,
|
|
393
|
+
channel,
|
|
394
|
+
arch,
|
|
395
|
+
revoke,
|
|
396
|
+
resetSequence,
|
|
397
|
+
}: { bundle: string; channel?: string; arch?: DesktopArch } & ReleaseRevocation,
|
|
398
|
+
) {
|
|
399
|
+
this.#assertUpdates();
|
|
400
|
+
const [api, { config }] = await Promise.all([
|
|
401
|
+
NativeApi.load(this.app.cwdPath),
|
|
402
|
+
this.config({ platform, stageBin: false }),
|
|
403
|
+
]);
|
|
404
|
+
this.#assertValid(api, config);
|
|
405
|
+
const { log } = this.#task(platform, config);
|
|
406
|
+
return await api.republishUpdate({
|
|
407
|
+
appDir: this.app.cwdPath,
|
|
408
|
+
config,
|
|
409
|
+
platform,
|
|
410
|
+
bundle,
|
|
411
|
+
out: this.updatesDir,
|
|
412
|
+
log,
|
|
413
|
+
...(channel ? { channel } : {}),
|
|
414
|
+
...(arch ? { arch } : {}),
|
|
415
|
+
...(revoke?.length ? { revoke } : {}),
|
|
416
|
+
...(resetSequence ? { resetSequence } : {}),
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* An unsigned update of this target's desktop app: a release build as publishUpdate makes it, its archive and the
|
|
422
|
+
* manifest template whoever holds the update key fills and signs, and the record `pack.json` keeps of it.
|
|
423
|
+
*/
|
|
424
|
+
async packAppUpdate(
|
|
425
|
+
platform: DesktopPlatform,
|
|
426
|
+
{
|
|
427
|
+
out,
|
|
428
|
+
server,
|
|
429
|
+
arch,
|
|
430
|
+
sign = false,
|
|
431
|
+
notarize = false,
|
|
432
|
+
previous,
|
|
433
|
+
}: {
|
|
434
|
+
out?: string;
|
|
435
|
+
server?: DesktopServerBundle;
|
|
436
|
+
arch?: DesktopArch;
|
|
437
|
+
sign?: boolean;
|
|
438
|
+
notarize?: boolean;
|
|
439
|
+
/** The archive of the release the channel has now, a path or a URL: the pack carries the delta from it. */
|
|
440
|
+
previous?: string;
|
|
441
|
+
} = {},
|
|
442
|
+
) {
|
|
443
|
+
this.#assertUpdates();
|
|
444
|
+
await this.assembleWeb(platform);
|
|
445
|
+
const { api, config } = await this.prepare(platform, server, arch);
|
|
446
|
+
const distribution = await this.#distribution(api, platform, "release", { sign, notarize }, server);
|
|
447
|
+
const packed = await api.packAppUpdate({
|
|
448
|
+
...this.#task(platform, config, { env: await this.#runtimeEnv(server) }),
|
|
449
|
+
platform,
|
|
450
|
+
out: path.resolve(out ?? this.appPackDir(platform, arch)),
|
|
451
|
+
...(arch ? { arch } : {}),
|
|
452
|
+
...(distribution.macos ? { macos: distribution.macos } : {}),
|
|
453
|
+
...(distribution.windows ? { windows: distribution.windows } : {}),
|
|
454
|
+
...(previous ? { previous } : {}),
|
|
455
|
+
});
|
|
456
|
+
const { manifest } = packed;
|
|
457
|
+
const { archive } = manifest;
|
|
458
|
+
const [file] = manifest.files;
|
|
459
|
+
if (!archive || !file || !manifest.arch || manifest.build === undefined)
|
|
460
|
+
throw new Error(`The native build API packed no app archive for '${this.target.name}'.`);
|
|
461
|
+
const [patch] = manifest.patches ?? [];
|
|
462
|
+
const tool = (await Bun.file(path.join(import.meta.dir, "..", "package.json"))
|
|
463
|
+
.json()
|
|
464
|
+
.catch(() => null)) as { version?: string } | null;
|
|
465
|
+
const pack: DesktopUpdatePack = {
|
|
466
|
+
schema: 2,
|
|
467
|
+
kind: "app",
|
|
468
|
+
...(tool?.version ? { cli: tool.version } : {}),
|
|
469
|
+
builtAt: new Date().toISOString(),
|
|
470
|
+
app: this.app.name,
|
|
471
|
+
target: this.target.name,
|
|
472
|
+
platform,
|
|
473
|
+
arch: manifest.arch,
|
|
474
|
+
env: this.env ?? "main",
|
|
475
|
+
channel: config.updates?.channel ?? "production",
|
|
476
|
+
appId: manifest.app,
|
|
477
|
+
appVersion: manifest.version,
|
|
478
|
+
build: manifest.build,
|
|
479
|
+
server: manifest.server === true,
|
|
480
|
+
signer: packed.signer,
|
|
481
|
+
archive: {
|
|
482
|
+
url: archive.url,
|
|
483
|
+
tarSha256: archive.sha256,
|
|
484
|
+
tarSize: file.size,
|
|
485
|
+
gzSha256: archive.gzSha256,
|
|
486
|
+
gzSize: archive.size,
|
|
487
|
+
},
|
|
488
|
+
...(patch ? { patch } : {}),
|
|
489
|
+
out: packed.out,
|
|
490
|
+
};
|
|
491
|
+
await UpdatePackFolder.write(pack);
|
|
492
|
+
return { ...packed, pack };
|
|
493
|
+
}
|
|
494
|
+
|
|
379
495
|
//* Only what the command asked for is signed or uploaded. A release's server is searched for the workspace's secret
|
|
380
496
|
//* values first, signed or not: an unsigned app is handed out too, and an update is published to every install. The
|
|
381
497
|
//* one line naming the identity and the service comes right before the build.
|
|
@@ -582,7 +698,8 @@ export class NativeApp {
|
|
|
582
698
|
return `/${home.join("/")}?${params}${hash ? `#${hash}` : ""}`;
|
|
583
699
|
}
|
|
584
700
|
|
|
585
|
-
//* `installer` is
|
|
701
|
+
//* `installer` is what a person downloads: a setup program on Windows, a disk image on macOS, and on Linux an
|
|
702
|
+
//* AppImage and a tar.gz whose install.sh installs the folder that updates itself.
|
|
586
703
|
static assertInstaller(platform: NativePlatform, installer: boolean) {
|
|
587
704
|
if (installer && (platform === "ios" || platform === "android"))
|
|
588
705
|
throw new Error(`An installer is built for a desktop app (Windows, macOS, Linux), not for ${platform}.`);
|
|
@@ -31,6 +31,11 @@ describe("a pack read back from its folder", () => {
|
|
|
31
31
|
const later = path.join(root, "later");
|
|
32
32
|
await writeText(path.join(later, "pack.json"), JSON.stringify({ ...pack, schema: 2 }));
|
|
33
33
|
await expect(UpdatePackFolder.read(later)).rejects.toThrow("schema 2");
|
|
34
|
+
const desktop = path.join(root, "desktop");
|
|
35
|
+
await writeText(path.join(desktop, "pack.json"), JSON.stringify({ schema: 2, kind: "app", platform: "macos" }));
|
|
36
|
+
await expect(UpdatePackFolder.read(desktop)).rejects.toThrow(
|
|
37
|
+
`${desktop} holds a desktop app's pack, which whoever holds the update key signs`,
|
|
38
|
+
);
|
|
34
39
|
const refused = path.join(root, "refused");
|
|
35
40
|
const compat = { against: "store/bundle.json", compatible: false, problems: ["deepLinks differ"] };
|
|
36
41
|
await writeText(path.join(refused, "pack.json"), JSON.stringify({ ...pack, compat }));
|
|
@@ -2,9 +2,10 @@ import { mkdtemp, rm } from "node:fs/promises";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import type { NativeEnv } from "akanjs";
|
|
5
|
-
import type { BundleInfo, UpdateManifest } from "akanjs/native/api";
|
|
5
|
+
import type { AppSigner, BundleInfo, UpdateManifest } from "akanjs/native/api";
|
|
6
6
|
import { ExitCodeError } from "../commandDecorators/exitCodeError";
|
|
7
|
-
import type {
|
|
7
|
+
import type { DesktopArch } from "./desktopBin";
|
|
8
|
+
import type { DesktopPlatform, MobilePlatform } from "./mobileTarget";
|
|
8
9
|
|
|
9
10
|
export interface NativeUpdatePackCompat {
|
|
10
11
|
/** The store build's bundle.json the pack was compared with. */
|
|
@@ -35,6 +36,37 @@ export interface NativeUpdatePack {
|
|
|
35
36
|
compat?: NativeUpdatePackCompat;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* `<out>/pack.json` of a desktop pack: what whoever signs it needs to know of the app in `app/`. Schema 2, so a reader
|
|
41
|
+
* of a phone's pack refuses it by its number.
|
|
42
|
+
*/
|
|
43
|
+
export interface DesktopUpdatePack {
|
|
44
|
+
schema: 2;
|
|
45
|
+
kind: "app";
|
|
46
|
+
/** The @akanjs/cli version that packed it. */
|
|
47
|
+
cli?: string;
|
|
48
|
+
builtAt: string;
|
|
49
|
+
app: string;
|
|
50
|
+
target: string;
|
|
51
|
+
platform: DesktopPlatform;
|
|
52
|
+
arch: DesktopArch;
|
|
53
|
+
env: NativeEnv;
|
|
54
|
+
/** The target's `updates.channel`; the signer decides the release's. */
|
|
55
|
+
channel: string;
|
|
56
|
+
appId: string;
|
|
57
|
+
appVersion: string;
|
|
58
|
+
/** The manifest's `build`: the packed app's own sequence, by which an installed copy knows a release is itself. */
|
|
59
|
+
build: number;
|
|
60
|
+
server: boolean;
|
|
61
|
+
/** Who signed the app's files (not the update key); null for an app signed ad hoc or not at all. */
|
|
62
|
+
signer: AppSigner | null;
|
|
63
|
+
archive: { url: string; tarSha256: string; tarSize: number; gzSha256: string; gzSize: number };
|
|
64
|
+
/** With --previous: the delta the manifest template names in `patches`. */
|
|
65
|
+
patch?: { from: string; url: string; sha256: string; size: number };
|
|
66
|
+
/** The folder it was packed to; pack.json leaves it out. */
|
|
67
|
+
out: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
38
70
|
//* The folder `akan pack-update` writes for a signer or Akan Cloud: the native build API writes `files/<sha256>`,
|
|
39
71
|
//* bundle.json and manifest.template.json, and akan writes pack.json and compat.json beside them.
|
|
40
72
|
export class UpdatePackFolder {
|
|
@@ -63,14 +95,18 @@ export class UpdatePackFolder {
|
|
|
63
95
|
const file = Bun.file(path.join(dir, UpdatePackFolder.packFile));
|
|
64
96
|
if (!(await file.exists()))
|
|
65
97
|
throw new Error(`${dir} holds no ${UpdatePackFolder.packFile}: give the folder \`akan pack-update\` wrote.`);
|
|
66
|
-
const pack = (await file.json()) as NativeUpdatePack;
|
|
98
|
+
const pack = (await file.json()) as NativeUpdatePack | DesktopUpdatePack;
|
|
99
|
+
if (pack.schema === 2 && pack.kind === "app")
|
|
100
|
+
throw new Error(
|
|
101
|
+
`${dir} holds a desktop app's pack, which whoever holds the update key signs (fillManifest, manifestBytes and updateEnvelope of akanjs/native/api); a phone's pack is read here.`,
|
|
102
|
+
);
|
|
67
103
|
if (pack.schema !== 1)
|
|
68
104
|
throw new Error(`${dir}/${UpdatePackFolder.packFile} is schema ${pack.schema}, and this akan reads schema 1.`);
|
|
69
105
|
return { ...pack, out: path.resolve(dir) };
|
|
70
106
|
}
|
|
71
107
|
|
|
72
108
|
//? Without `out`: the record travels in the pack's archive, and the folder is wherever it is read from.
|
|
73
|
-
static async write({ out, ...record }: NativeUpdatePack) {
|
|
109
|
+
static async write({ out, ...record }: NativeUpdatePack | DesktopUpdatePack) {
|
|
74
110
|
await Bun.write(path.join(out, UpdatePackFolder.packFile), `${JSON.stringify(record, null, 2)}\n`);
|
|
75
111
|
}
|
|
76
112
|
|
|
@@ -83,12 +83,14 @@ describe("UpdateUploader", () => {
|
|
|
83
83
|
);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
test("uploads a desktop release's envelope, with the v1 pair only when the pair is that release", async () => {
|
|
86
|
+
test("uploads a desktop release's envelope and the copy kept of it, with the v1 pair only when the pair is that release", async () => {
|
|
87
87
|
const manifest = { kind: "app", bundle: "1.3.0-3000", archive: { url: `app/${sha("c")}.tar.gz` }, patches: [] };
|
|
88
88
|
await inUpdatesDir(
|
|
89
89
|
{
|
|
90
90
|
[`macos-arm64/app/${sha("c")}.tar.gz`]: "tar",
|
|
91
91
|
"macos-arm64/main/app.json": envelope(manifest),
|
|
92
|
+
"macos-arm64/main/releases/1.3.0-3000.json": envelope(manifest),
|
|
93
|
+
"macos-arm64/main/releases/1.2.0-2000.json": envelope({ ...manifest, bundle: "1.2.0-2000" }),
|
|
92
94
|
"macos-arm64/main.json": JSON.stringify({ ...manifest, bundle: "1.2.0-2000" }),
|
|
93
95
|
"macos-arm64/main.json.sig": "sig",
|
|
94
96
|
"macos-arm64/beta/app.json": envelope({ ...manifest, bundle: "1.4.0-4000" }),
|
|
@@ -97,13 +99,18 @@ describe("UpdateUploader", () => {
|
|
|
97
99
|
},
|
|
98
100
|
async (updatesDir) => {
|
|
99
101
|
const dir = path.join(updatesDir, "macos-arm64");
|
|
100
|
-
const upload = async (channel: string, bundle: string) => {
|
|
101
|
-
const { bucket, writes } = fakeBucket();
|
|
102
|
+
const upload = async (channel: string, bundle: string, held: string[] = []) => {
|
|
103
|
+
const { bucket, writes } = fakeBucket(held);
|
|
102
104
|
await new UpdateUploader(bucket, "").upload(updatesDir, { dir, channel, bundle });
|
|
103
105
|
return writes.map(({ key }) => key);
|
|
104
106
|
};
|
|
105
107
|
|
|
106
108
|
expect(await upload("main", "1.3.0-3000")).toEqual([
|
|
109
|
+
`macos-arm64/app/${sha("c")}.tar.gz`,
|
|
110
|
+
"macos-arm64/main/releases/1.3.0-3000.json",
|
|
111
|
+
"macos-arm64/main/app.json",
|
|
112
|
+
]);
|
|
113
|
+
expect(await upload("main", "1.3.0-3000", ["macos-arm64/main/releases/1.3.0-3000.json"])).toEqual([
|
|
107
114
|
`macos-arm64/app/${sha("c")}.tar.gz`,
|
|
108
115
|
"macos-arm64/main/app.json",
|
|
109
116
|
]);
|
|
@@ -148,6 +155,37 @@ describe("UpdateUploader", () => {
|
|
|
148
155
|
);
|
|
149
156
|
});
|
|
150
157
|
|
|
158
|
+
test("writes the live envelope of a channel named releases every time, on a phone and a desktop alike", async () => {
|
|
159
|
+
const app = { kind: "app", bundle: "1.3.0-3000", archive: { url: `app/${sha("c")}.tar.gz` }, patches: [] };
|
|
160
|
+
await inUpdatesDir(
|
|
161
|
+
{
|
|
162
|
+
[`ios/files/${sha("a")}`]: "index.html",
|
|
163
|
+
"ios/releases/api2.json": envelope({ bundle: "3000-aaaaaaaa", files: [{ sha256: sha("a") }] }),
|
|
164
|
+
[`macos-arm64/app/${sha("c")}.tar.gz`]: "tar",
|
|
165
|
+
"macos-arm64/releases/app.json": envelope(app),
|
|
166
|
+
"macos-arm64/releases/releases/1.3.0-3000.json": envelope(app),
|
|
167
|
+
},
|
|
168
|
+
async (updatesDir) => {
|
|
169
|
+
const upload = async (platform: string, bundle: string, held: string[]) => {
|
|
170
|
+
const { bucket, writes } = fakeBucket(held);
|
|
171
|
+
const release = { dir: path.join(updatesDir, platform), channel: "releases", bundle };
|
|
172
|
+
await new UpdateUploader(bucket, "").upload(updatesDir, release);
|
|
173
|
+
return writes.map(({ key }) => key);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
expect(await upload("ios", "3000-aaaaaaaa", [`ios/files/${sha("a")}`, "ios/releases/api2.json"])).toEqual([
|
|
177
|
+
"ios/releases/api2.json",
|
|
178
|
+
]);
|
|
179
|
+
const desktopHeld = [
|
|
180
|
+
`macos-arm64/app/${sha("c")}.tar.gz`,
|
|
181
|
+
"macos-arm64/releases/app.json",
|
|
182
|
+
"macos-arm64/releases/releases/1.3.0-3000.json",
|
|
183
|
+
];
|
|
184
|
+
expect(await upload("macos-arm64", "1.3.0-3000", desktopHeld)).toEqual(["macos-arm64/releases/app.json"]);
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
|
|
151
189
|
test("uploads nothing when the release is not there or names a file outside its folder", async () => {
|
|
152
190
|
await inUpdatesDir(
|
|
153
191
|
{
|
package/mobile/updateUploader.ts
CHANGED
|
@@ -29,6 +29,10 @@ export interface PublishedUpdate {
|
|
|
29
29
|
//* hash), so one the bucket holds is skipped; a manifest is always written.
|
|
30
30
|
export class UpdateUploader {
|
|
31
31
|
static readonly #manifest = /\.json(?:\.sig)?$/;
|
|
32
|
+
//? `<os>-<arch>/<channel>/releases/<bundle>.json`: a desktop release's envelope as it was signed, which `--republish`
|
|
33
|
+
//? reads back from the feed on a computer that never published it. Named by its bundle, it never changes either. Held
|
|
34
|
+
//? to that depth: a channel may itself be named `releases`, and its live envelope must still be written every time.
|
|
35
|
+
static readonly #kept = /^[^/]+\/[^/]+\/releases\/[^/]+\.json$/;
|
|
32
36
|
|
|
33
37
|
/** `s3://bucket/prefix`: the credentials and endpoint come from S3_* (or AWS_*) in the environment. */
|
|
34
38
|
static parseTarget(target: string): { bucket: string; prefix: string } {
|
|
@@ -38,9 +42,10 @@ export class UpdateUploader {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
static order(files: string[]): { releases: string[]; manifests: string[] } {
|
|
41
|
-
const
|
|
45
|
+
const live = (file: string) => UpdateUploader.#manifest.test(file) && !UpdateUploader.#kept.test(file);
|
|
46
|
+
const manifests = files.filter(live);
|
|
42
47
|
return {
|
|
43
|
-
releases: files.filter((file) => !
|
|
48
|
+
releases: files.filter((file) => !live(file)).sort((a, b) => a.localeCompare(b)),
|
|
44
49
|
manifests: manifests.sort(
|
|
45
50
|
(a, b) => Number(a.endsWith(".json")) - Number(b.endsWith(".json")) || a.localeCompare(b),
|
|
46
51
|
),
|
|
@@ -61,8 +66,11 @@ export class UpdateUploader {
|
|
|
61
66
|
? UpdateUploader.#parse<UpdateManifest>(Buffer.from(envelope.manifest, "base64").toString("utf8"))
|
|
62
67
|
: null;
|
|
63
68
|
if (manifest?.bundle !== bundle) continue;
|
|
64
|
-
if (manifest.kind === "app")
|
|
65
|
-
|
|
69
|
+
if (manifest.kind === "app") {
|
|
70
|
+
const kept = `${channel}/releases/${bundle}.json`;
|
|
71
|
+
const history = (await Bun.file(path.join(dir, kept)).exists()) ? [kept] : [];
|
|
72
|
+
return [...UpdateUploader.#appFiles(manifest), ...history, ...pair, `${channel}/${name}`].map(keyOf);
|
|
73
|
+
}
|
|
66
74
|
const hashes = [...new Set(UpdateUploader.#field(manifest.files, "sha256"))];
|
|
67
75
|
if (!hashes.every((hash): hash is string => typeof hash === "string" && /^[0-9a-f]{64}$/.test(hash)))
|
|
68
76
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-rc.0",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@akanjs/language": "3.
|
|
55
|
+
"@akanjs/language": "3.4.0-rc.0",
|
|
56
56
|
"@inquirer/prompts": "^8.7.3",
|
|
57
57
|
"@tailwindcss/node": "^4.3.3",
|
|
58
|
-
"akanjs": "3.
|
|
58
|
+
"akanjs": "3.4.0-rc.0",
|
|
59
59
|
"chalk": "^6.0.1",
|
|
60
60
|
"commander": "^15.0.0",
|
|
61
61
|
"dayjs": "^1.11.23",
|
|
@@ -550,6 +550,230 @@ describe("PipelineCompiler", () => {
|
|
|
550
550
|
});
|
|
551
551
|
});
|
|
552
552
|
|
|
553
|
+
describe("desktop-ota", () => {
|
|
554
|
+
const webTargets: Record<string, PipelineNativeTargets> = {
|
|
555
|
+
web: {
|
|
556
|
+
targets: [
|
|
557
|
+
{ name: "default", updates: true },
|
|
558
|
+
{ name: "pilot", updates: true },
|
|
559
|
+
{ name: "kiosk", updates: false },
|
|
560
|
+
],
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
const mac = { os: "macos", arch: "arm64" } as const;
|
|
564
|
+
const windows = { os: "windows", arch: "x64" } as const;
|
|
565
|
+
const desktopPhase = (plan: PipelinePlan) => plan.phases.find((phase) => phase.action === "desktop-ota");
|
|
566
|
+
|
|
567
|
+
test("is opt-in: zero-config and an app that takes only ota never pack a desktop update", () => {
|
|
568
|
+
expect(desktopPhase(planOf(compile({ nativeTargets: webTargets })))).toBeUndefined();
|
|
569
|
+
const phones = planOf(compile({ nativeTargets: webTargets, apps: { web: { stages: [{ use: "ota" }] } } }));
|
|
570
|
+
expect(desktopPhase(phones)).toBeUndefined();
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
test("runs after ota, one pack per target with updates and platform entry, with its own slot behind it", () => {
|
|
574
|
+
const plan = planOf(
|
|
575
|
+
compile({
|
|
576
|
+
nativeTargets: webTargets,
|
|
577
|
+
apps: {
|
|
578
|
+
web: {
|
|
579
|
+
stages: [
|
|
580
|
+
{ use: "build" },
|
|
581
|
+
{ use: "docker" },
|
|
582
|
+
{ use: "deploy" },
|
|
583
|
+
{ use: "ota" },
|
|
584
|
+
{ name: "Notify phones", sh: "echo phones" },
|
|
585
|
+
{ use: "desktop-ota", platforms: [mac, windows, { os: "linux", arch: "arm64" }] },
|
|
586
|
+
{ name: "Notify desktops", sh: "echo desktops" },
|
|
587
|
+
{ name: "Announce", sh: "echo released" },
|
|
588
|
+
],
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
}),
|
|
592
|
+
);
|
|
593
|
+
expect(phaseIds(plan)).toEqual([
|
|
594
|
+
"build",
|
|
595
|
+
"docker",
|
|
596
|
+
"deploy",
|
|
597
|
+
"ota",
|
|
598
|
+
"after-ota",
|
|
599
|
+
"desktop-ota",
|
|
600
|
+
"after-desktop-ota",
|
|
601
|
+
"after-desktop-ota-2",
|
|
602
|
+
]);
|
|
603
|
+
expect(desktopPhase(plan)).toMatchObject({
|
|
604
|
+
slot: "desktop-ota",
|
|
605
|
+
milestone: "deploy",
|
|
606
|
+
name: "Desktop OTA",
|
|
607
|
+
order: "parallel",
|
|
608
|
+
});
|
|
609
|
+
expect(desktopPhase(plan)?.stages).toEqual([
|
|
610
|
+
{
|
|
611
|
+
id: "web:desktop-ota",
|
|
612
|
+
name: "web",
|
|
613
|
+
description: null,
|
|
614
|
+
app: "web",
|
|
615
|
+
milestone: "deploy",
|
|
616
|
+
skip: null,
|
|
617
|
+
runtimeWhen: null,
|
|
618
|
+
allowFailure: false,
|
|
619
|
+
timeoutSeconds: null,
|
|
620
|
+
steps: [
|
|
621
|
+
{
|
|
622
|
+
id: "web:desktop-ota/desktop-ota",
|
|
623
|
+
name: "desktop ota web",
|
|
624
|
+
timeoutSeconds: null,
|
|
625
|
+
retry: null,
|
|
626
|
+
allowFailure: false,
|
|
627
|
+
kind: "action",
|
|
628
|
+
actionVersion: 1,
|
|
629
|
+
action: "desktop-ota",
|
|
630
|
+
with: {
|
|
631
|
+
app: "web",
|
|
632
|
+
targets: ["default", "pilot"],
|
|
633
|
+
platforms: [mac, windows, { os: "linux", arch: "arm64" }],
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
],
|
|
637
|
+
},
|
|
638
|
+
]);
|
|
639
|
+
const stagesOf = (id: string) => plan.phases.find((phase) => phase.id === id)?.stages.map((stage) => stage.id);
|
|
640
|
+
expect(stagesOf("after-ota")).toEqual(["web:notify-phones"]);
|
|
641
|
+
expect(stagesOf("after-desktop-ota")).toEqual(["web:notify-desktops"]);
|
|
642
|
+
expect(stagesOf("after-desktop-ota-2")).toEqual(["web:announce"]);
|
|
643
|
+
expect(plan.phases.find((phase) => phase.id === "after-desktop-ota")).toMatchObject({
|
|
644
|
+
slot: "after-desktop-ota",
|
|
645
|
+
name: "After desktop OTA",
|
|
646
|
+
milestone: "deploy",
|
|
647
|
+
action: null,
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test("an app with no other action packs on its own, and named targets, retry and timeout are kept", () => {
|
|
652
|
+
const plan = planOf(
|
|
653
|
+
compile({
|
|
654
|
+
ctx: context({ apps: ["web"] }),
|
|
655
|
+
nativeTargets: webTargets,
|
|
656
|
+
apps: {
|
|
657
|
+
web: {
|
|
658
|
+
stages: [{ use: "desktop-ota", targets: ["pilot"], platforms: [windows], timeout: "30m", retry: 2 }],
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
}),
|
|
662
|
+
);
|
|
663
|
+
expect(phaseIds(plan)).toEqual(["desktop-ota"]);
|
|
664
|
+
expect(desktopPhase(plan)?.stages[0]).toMatchObject({ skip: null, timeoutSeconds: 1800 });
|
|
665
|
+
expect(desktopPhase(plan)?.stages[0]?.steps[0]).toMatchObject({
|
|
666
|
+
retry: { attempts: 2, delaySeconds: 0 },
|
|
667
|
+
with: { app: "web", targets: ["pilot"], platforms: [windows] },
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
test("is skipped with the app's earlier action, ota included, and takes when.changed like any action", () => {
|
|
672
|
+
const plan = planOf(
|
|
673
|
+
compile({
|
|
674
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
675
|
+
nativeTargets: webTargets,
|
|
676
|
+
apps: {
|
|
677
|
+
web: {
|
|
678
|
+
stages: [
|
|
679
|
+
{ use: "ota", when: { branch: "main" } },
|
|
680
|
+
{ use: "desktop-ota", platforms: [mac], when: { changed: ["apps/web/**"] } },
|
|
681
|
+
],
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
}),
|
|
685
|
+
);
|
|
686
|
+
expect(desktopPhase(plan)?.stages[0]).toMatchObject({
|
|
687
|
+
skip: { reason: "ota of web is skipped" },
|
|
688
|
+
runtimeWhen: { changed: ["apps/web/**"] },
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
test("a workspace stage may not take the id of its phase or of the slot behind it", () => {
|
|
693
|
+
for (const name of ["Desktop OTA", "After desktop OTA", "After desktop OTA 2"])
|
|
694
|
+
expect(codes(compile({ workspace: { before: [{ name, sh: "x" }] } }))).toEqual(["pipeline.id.reserved"]);
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
const desktopOta = (
|
|
698
|
+
stage: Record<string, unknown>,
|
|
699
|
+
nativeTargets: Record<string, PipelineNativeTargets> = webTargets,
|
|
700
|
+
) =>
|
|
701
|
+
compile({
|
|
702
|
+
ctx: context({ apps: ["web"] }),
|
|
703
|
+
nativeTargets,
|
|
704
|
+
apps: { web: { stages: [{ use: "desktop-ota", platforms: [mac], ...stage } as never] } },
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
test("refuses targets without native.updates, unknown targets, and apps whose targets could not be read", () => {
|
|
708
|
+
const without = desktopOta({ targets: ["default", "kiosk"] });
|
|
709
|
+
expect(without.ok).toBe(false);
|
|
710
|
+
expect(without.diagnostics).toEqual([
|
|
711
|
+
expect.objectContaining({ code: "pipeline.desktopOta.noUpdates", path: "pipeline.stages[0].targets" }),
|
|
712
|
+
]);
|
|
713
|
+
expect(without.diagnostics[0]?.message).toContain("`desktop-ota` packs updates");
|
|
714
|
+
expect(without.diagnostics[0]?.message).toContain('"kiosk"');
|
|
715
|
+
expect(codes(desktopOta({ targets: ["ghost"] }))).toEqual(["pipeline.desktopOta.unknownTarget"]);
|
|
716
|
+
expect(codes(desktopOta({}, { web: { targets: [{ name: "default", updates: false }] } }))).toEqual([
|
|
717
|
+
"pipeline.desktopOta.noUpdates",
|
|
718
|
+
]);
|
|
719
|
+
expect(codes(desktopOta({}, { web: { error: "boom" } }))).toEqual(["pipeline.desktopOta.targets"]);
|
|
720
|
+
expect(codes(desktopOta({}, {}))).toEqual(["pipeline.desktopOta.targets"]);
|
|
721
|
+
expect(codes(desktopOta({ targets: [] }))).toEqual(["pipeline.schema.invalid"]);
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
test("refuses a stage with no platforms, a platform listed twice, and a macOS x64 build", () => {
|
|
725
|
+
const refused = (platforms: unknown, code: string, path: string) => {
|
|
726
|
+
const result = desktopOta({ platforms });
|
|
727
|
+
expect(result.ok).toBe(false);
|
|
728
|
+
expect(result.diagnostics).toEqual([expect.objectContaining({ severity: "error", code, path })]);
|
|
729
|
+
return result.diagnostics[0]?.message;
|
|
730
|
+
};
|
|
731
|
+
const at = "pipeline.stages[0].platforms";
|
|
732
|
+
expect(refused(undefined, "pipeline.desktopOta.noPlatforms", at)).toContain("no default");
|
|
733
|
+
const untyped: AppPipelineConfig = {
|
|
734
|
+
// @ts-expect-error `platforms` is required: `desktop-ota` has no default
|
|
735
|
+
stages: [{ use: "desktop-ota" }],
|
|
736
|
+
};
|
|
737
|
+
expect(codes(compile({ nativeTargets: webTargets, apps: { web: untyped } }))).toEqual([
|
|
738
|
+
"pipeline.desktopOta.noPlatforms",
|
|
739
|
+
]);
|
|
740
|
+
refused([], "pipeline.desktopOta.noPlatforms", at);
|
|
741
|
+
expect(refused([mac, windows, { ...mac }], "pipeline.desktopOta.duplicatePlatform", `${at}[2]`)).toBe(
|
|
742
|
+
'{ os: "macos", arch: "arm64" } is listed twice',
|
|
743
|
+
);
|
|
744
|
+
expect(
|
|
745
|
+
refused([windows, { os: "macos", arch: "x64" }], "pipeline.desktopOta.unsupportedPlatform", `${at}[1]`),
|
|
746
|
+
).toContain("a macOS app is built for arm64 only");
|
|
747
|
+
expect(refused([{ os: "ios", arch: "arm64" }], "pipeline.schema.invalid", `${at}[0].os`)).toBe(
|
|
748
|
+
'"ios" is not one of macos, windows, linux',
|
|
749
|
+
);
|
|
750
|
+
expect(refused([mac, { os: "linux", arch: "ia32" }], "pipeline.schema.invalid", `${at}[1].arch`)).toBe(
|
|
751
|
+
'"ia32" is not one of arm64, x64',
|
|
752
|
+
);
|
|
753
|
+
refused(["macos"], "pipeline.schema.invalid", `${at}[0]`);
|
|
754
|
+
refused("macos", "pipeline.schema.invalid", at);
|
|
755
|
+
refused([{ ...mac, sign: true }], "pipeline.schema.unknownKey", `${at}[0].sign`);
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
test("keeps its own place and keys: once, after ota, and no platform objects on ota", () => {
|
|
759
|
+
const stages = (...list: Record<string, unknown>[]) =>
|
|
760
|
+
codes(
|
|
761
|
+
compile({
|
|
762
|
+
ctx: context({ apps: ["web"] }),
|
|
763
|
+
nativeTargets: webTargets,
|
|
764
|
+
apps: { web: { stages: list as never } },
|
|
765
|
+
}),
|
|
766
|
+
);
|
|
767
|
+
expect(stages({ use: "desktop-ota", platforms: [mac] }, { use: "ota" })).toEqual(["pipeline.action.order"]);
|
|
768
|
+
expect(stages({ use: "desktop-ota", platforms: [mac] }, { use: "desktop-ota", platforms: [windows] })).toContain(
|
|
769
|
+
"pipeline.action.duplicate",
|
|
770
|
+
);
|
|
771
|
+
expect(stages({ use: "ota", platforms: [mac] })).toContain("pipeline.schema.invalid");
|
|
772
|
+
expect(stages({ use: "desktop-ota", platforms: ["ios"] })).toEqual(["pipeline.schema.invalid"]);
|
|
773
|
+
expect(stages({ use: "desktop-ota", platforms: [mac], arch: "arm64" })).toContain("pipeline.schema.unknownKey");
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
|
|
553
777
|
test("the context is echoed, and an unknown or doubled app is refused rather than corrected", () => {
|
|
554
778
|
expect(planOf(compile({ ctx: context({ apps: ["web", "api"] }) })).context.apps).toEqual(["web", "api"]);
|
|
555
779
|
expect(codes(compile({ ctx: context({ apps: ["web", "web"] }) }))).toContain("pipeline.context.duplicateApp");
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "akanjs";
|
|
8
8
|
import {
|
|
9
9
|
type PipelineActionName,
|
|
10
|
+
type PipelineDesktopOtaPlatform,
|
|
10
11
|
type PipelineDiagnostic,
|
|
11
12
|
type PipelineMilestone,
|
|
12
13
|
type PipelineOtaPlatform,
|
|
@@ -56,7 +57,7 @@ export interface PipelineCompileInput {
|
|
|
56
57
|
workspaceApps: readonly string[];
|
|
57
58
|
workspace: PipelineSourceFile<WorkspacePipelineConfig> | null;
|
|
58
59
|
apps: ReadonlyMap<string, PipelineSourceFile<AppPipelineConfig>>;
|
|
59
|
-
/** Read only for an app whose pipeline takes `ota`. */
|
|
60
|
+
/** Read only for an app whose pipeline takes `ota` or `desktop-ota`. */
|
|
60
61
|
nativeTargets?: ReadonlyMap<string, PipelineNativeTargets>;
|
|
61
62
|
akanVersion: string;
|
|
62
63
|
/** Function forms run against a sample context (`validate`), which is said once per file. */
|
|
@@ -64,7 +65,9 @@ export interface PipelineCompileInput {
|
|
|
64
65
|
diagnostics?: readonly PipelineDiagnostic[];
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
type CustomSlot = "before-build" | "after-build" | "after-docker" | "after-deploy" | "after-ota";
|
|
68
|
+
type CustomSlot = "before-build" | "after-build" | "after-docker" | "after-deploy" | "after-ota" | "after-desktop-ota";
|
|
69
|
+
|
|
70
|
+
type OtaAction = Extract<PipelineActionName, "ota" | "desktop-ota">;
|
|
68
71
|
|
|
69
72
|
interface AppLane {
|
|
70
73
|
file: string;
|
|
@@ -74,6 +77,7 @@ interface AppLane {
|
|
|
74
77
|
skips: Map<PipelineActionName, PipelineSkip | null>;
|
|
75
78
|
slots: Record<CustomSlot, PipelineShellStageRule[]>;
|
|
76
79
|
ota: { targets: string[]; platforms: PipelineOtaPlatform[] } | null;
|
|
80
|
+
desktopOta: { targets: string[]; platforms: PipelineDesktopOtaPlatform[] } | null;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
interface StageOptions {
|
|
@@ -94,6 +98,7 @@ export class PipelineCompiler {
|
|
|
94
98
|
docker: "after-docker",
|
|
95
99
|
deploy: "after-deploy",
|
|
96
100
|
ota: "after-ota",
|
|
101
|
+
"desktop-ota": "after-desktop-ota",
|
|
97
102
|
} as const;
|
|
98
103
|
static readonly #slotMilestones = {
|
|
99
104
|
"before-build": "prepare",
|
|
@@ -101,6 +106,7 @@ export class PipelineCompiler {
|
|
|
101
106
|
"after-docker": "package",
|
|
102
107
|
"after-deploy": "deploy",
|
|
103
108
|
"after-ota": "deploy",
|
|
109
|
+
"after-desktop-ota": "deploy",
|
|
104
110
|
} as const;
|
|
105
111
|
static readonly #slotNames = {
|
|
106
112
|
"before-build": "Before build",
|
|
@@ -108,10 +114,18 @@ export class PipelineCompiler {
|
|
|
108
114
|
"after-docker": "After docker",
|
|
109
115
|
"after-deploy": "After deploy",
|
|
110
116
|
"after-ota": "After OTA",
|
|
117
|
+
"after-desktop-ota": "After desktop OTA",
|
|
111
118
|
} as const;
|
|
112
119
|
static readonly #reservedPhaseId =
|
|
113
|
-
/^(?:build|docker|deploy|ota|(?:before-build|after-build|
|
|
114
|
-
static readonly #actionStepNames = {
|
|
120
|
+
/^(?:build|docker|deploy|ota|desktop-ota|(?:before-build|after-(?:build|docker|deploy|ota|desktop-ota))(?:-\d+)?)$/;
|
|
121
|
+
static readonly #actionStepNames = {
|
|
122
|
+
build: "akan build",
|
|
123
|
+
docker: "image",
|
|
124
|
+
deploy: "deploy",
|
|
125
|
+
ota: "ota",
|
|
126
|
+
"desktop-ota": "desktop ota",
|
|
127
|
+
} as const;
|
|
128
|
+
static readonly #otaCodes = { ota: "pipeline.ota", "desktop-ota": "pipeline.desktopOta" } as const;
|
|
115
129
|
//? PipelinePlanSchema reads at most 1024 characters of a skip reason.
|
|
116
130
|
static readonly #reasonChars = 1024;
|
|
117
131
|
|
|
@@ -265,8 +279,16 @@ export class PipelineCompiler {
|
|
|
265
279
|
after: rule.after,
|
|
266
280
|
actions: new Map(),
|
|
267
281
|
skips: new Map(),
|
|
268
|
-
slots: {
|
|
282
|
+
slots: {
|
|
283
|
+
"before-build": [],
|
|
284
|
+
"after-build": [],
|
|
285
|
+
"after-docker": [],
|
|
286
|
+
"after-deploy": [],
|
|
287
|
+
"after-ota": [],
|
|
288
|
+
"after-desktop-ota": [],
|
|
289
|
+
},
|
|
269
290
|
ota: null,
|
|
291
|
+
desktopOta: null,
|
|
270
292
|
};
|
|
271
293
|
let last: PipelineActionName | null = null;
|
|
272
294
|
let lastMilestone = -1;
|
|
@@ -320,7 +342,10 @@ export class PipelineCompiler {
|
|
|
320
342
|
deploy.path,
|
|
321
343
|
);
|
|
322
344
|
const ota = lane.actions.get("ota");
|
|
323
|
-
if (ota) lane.ota = this.#otaTargets(app, ota, file);
|
|
345
|
+
if (ota) lane.ota = this.#otaTargets(app, "ota", ota, file, ota.platforms ?? [...pipelineOtaPlatforms]);
|
|
346
|
+
const desktopOta = lane.actions.get("desktop-ota");
|
|
347
|
+
if (desktopOta)
|
|
348
|
+
lane.desktopOta = this.#otaTargets(app, "desktop-ota", desktopOta, file, desktopOta.desktopPlatforms);
|
|
324
349
|
if (!lane.actions.size)
|
|
325
350
|
this.#warning(
|
|
326
351
|
"pipeline.app.noActions",
|
|
@@ -339,14 +364,20 @@ export class PipelineCompiler {
|
|
|
339
364
|
return lane;
|
|
340
365
|
}
|
|
341
366
|
|
|
342
|
-
//? Checked here, not by the executor: a pack for a target without updates fails
|
|
343
|
-
#otaTargets(
|
|
344
|
-
|
|
367
|
+
//? Checked here, not by the executor: a pack for a target without updates fails only where it runs, after its build.
|
|
368
|
+
#otaTargets<Platform>(
|
|
369
|
+
app: string,
|
|
370
|
+
action: OtaAction,
|
|
371
|
+
stage: PipelineActionStageRule,
|
|
372
|
+
file: string,
|
|
373
|
+
platforms: Platform[] | null,
|
|
374
|
+
): { targets: string[]; platforms: Platform[] } | null {
|
|
375
|
+
const code = PipelineCompiler.#otaCodes[action];
|
|
345
376
|
const native = this.#input.nativeTargets?.get(app);
|
|
346
377
|
if (!native || "error" in native) {
|
|
347
378
|
this.#error(
|
|
348
|
-
|
|
349
|
-
|
|
379
|
+
`${code}.targets`,
|
|
380
|
+
`\`${action}\` needs the native targets of ${app}, which could not be read${native ? `: ${native.error}` : ""}`,
|
|
350
381
|
file,
|
|
351
382
|
stage.path,
|
|
352
383
|
);
|
|
@@ -355,10 +386,10 @@ export class PipelineCompiler {
|
|
|
355
386
|
const known = new Map(native.targets.map((target) => [target.name, target.updates]));
|
|
356
387
|
if (!stage.targets) {
|
|
357
388
|
const targets = native.targets.filter((target) => target.updates).map((target) => target.name);
|
|
358
|
-
if (targets.length) return { targets, platforms };
|
|
389
|
+
if (targets.length) return platforms && { targets, platforms };
|
|
359
390
|
this.#error(
|
|
360
|
-
|
|
361
|
-
|
|
391
|
+
`${code}.noUpdates`,
|
|
392
|
+
`\`${action}\` packs updates for targets that declare native.updates, and no native target of ${app} does`,
|
|
362
393
|
file,
|
|
363
394
|
stage.path,
|
|
364
395
|
);
|
|
@@ -368,19 +399,19 @@ export class PipelineCompiler {
|
|
|
368
399
|
const withoutUpdates = stage.targets.filter((name) => known.get(name) === false);
|
|
369
400
|
if (unknown.length)
|
|
370
401
|
this.#error(
|
|
371
|
-
|
|
402
|
+
`${code}.unknownTarget`,
|
|
372
403
|
`${unknown.map((name) => `"${name}"`).join(", ")} ${unknown.length > 1 ? "are not native targets" : "is not a native target"} of ${app}: ${[...known.keys()].join(", ")}`,
|
|
373
404
|
file,
|
|
374
405
|
`${stage.path}.targets`,
|
|
375
406
|
);
|
|
376
407
|
if (withoutUpdates.length)
|
|
377
408
|
this.#error(
|
|
378
|
-
|
|
379
|
-
|
|
409
|
+
`${code}.noUpdates`,
|
|
410
|
+
`\`${action}\` packs updates for targets that declare native.updates, and ${withoutUpdates.map((name) => `"${name}"`).join(", ")} of ${app} ${withoutUpdates.length > 1 ? "do" : "does"} not`,
|
|
380
411
|
file,
|
|
381
412
|
`${stage.path}.targets`,
|
|
382
413
|
);
|
|
383
|
-
return unknown.length || withoutUpdates.length ? null : { targets: stage.targets, platforms };
|
|
414
|
+
return unknown.length || withoutUpdates.length || !platforms ? null : { targets: stage.targets, platforms };
|
|
384
415
|
}
|
|
385
416
|
|
|
386
417
|
#appOrder(lanes: ReadonlyMap<string, AppLane>): string[] {
|
|
@@ -461,7 +492,16 @@ export class PipelineCompiler {
|
|
|
461
492
|
actionVersion: pipelineActions[action].version,
|
|
462
493
|
...(action === "ota"
|
|
463
494
|
? { action, with: { app, targets: lane.ota?.targets ?? [], platforms: lane.ota?.platforms ?? [] } }
|
|
464
|
-
:
|
|
495
|
+
: action === "desktop-ota"
|
|
496
|
+
? {
|
|
497
|
+
action,
|
|
498
|
+
with: {
|
|
499
|
+
app,
|
|
500
|
+
targets: lane.desktopOta?.targets ?? [],
|
|
501
|
+
platforms: lane.desktopOta?.platforms ?? [],
|
|
502
|
+
},
|
|
503
|
+
}
|
|
504
|
+
: { action, with: { app } }),
|
|
465
505
|
},
|
|
466
506
|
],
|
|
467
507
|
},
|
|
@@ -79,6 +79,31 @@ describe("PipelineDefinition", () => {
|
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
test("an app's native targets are read when its pipeline takes ota or desktop-ota, and only then", async () => {
|
|
83
|
+
const updates = `{ url: "https://cdn.example.com/ota", publicKey: "${Buffer.alloc(32, 7).toString("base64")}" }`;
|
|
84
|
+
const native = `native: { targets: { store: { updates: ${updates} }, kiosk: {} } }`;
|
|
85
|
+
const appConfig = (stage: string) => `export default { ${native}, pipeline: { stages: [${stage}] } };\n`;
|
|
86
|
+
await withWorkspace(
|
|
87
|
+
{
|
|
88
|
+
"package.json": '{ "name": "repo", "version": "1.0.0" }\n',
|
|
89
|
+
"apps/desk/akan.config.ts": appConfig('{ use: "desktop-ota", platforms: [{ os: "linux", arch: "x64" }] }'),
|
|
90
|
+
"apps/phone/akan.config.ts": appConfig('{ use: "ota" }'),
|
|
91
|
+
"apps/web/akan.config.ts": appConfig('{ use: "build" }'),
|
|
92
|
+
},
|
|
93
|
+
async (workspace) => {
|
|
94
|
+
const definition = await PipelineDefinition.load(workspace, ["desk", "phone", "web"]);
|
|
95
|
+
const targets = [
|
|
96
|
+
{ name: "store", updates: true },
|
|
97
|
+
{ name: "kiosk", updates: false },
|
|
98
|
+
];
|
|
99
|
+
expect([...definition.nativeTargets]).toEqual([
|
|
100
|
+
["desk", { targets }],
|
|
101
|
+
["phone", { targets }],
|
|
102
|
+
]);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
82
107
|
test("a config that cannot load is an error naming the file, never a silent default", async () => {
|
|
83
108
|
await withWorkspace(
|
|
84
109
|
{
|
|
@@ -60,7 +60,8 @@ export class PipelineDefinition {
|
|
|
60
60
|
static #mayTakeOta(pipeline: AppPipelineConfig | null) {
|
|
61
61
|
if (typeof pipeline === "function") return true;
|
|
62
62
|
const stages: unknown = pipeline?.stages;
|
|
63
|
-
|
|
63
|
+
const uses = Array.isArray(stages) ? stages.map((stage) => (stage as { use?: unknown } | null)?.use) : [];
|
|
64
|
+
return uses.includes("ota") || uses.includes("desktop-ota");
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
//? The whole app config, libs included: a target's `updates` may come from `native.updates` or its own section.
|
|
@@ -103,6 +103,60 @@ describe("PipelineDryRun", () => {
|
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
test("an ota and a desktop-ota stage say what they pack, a desktop build as os-arch", () => {
|
|
107
|
+
const result = PipelineCompiler.compile({
|
|
108
|
+
context: { ...context, apps: ["web"] },
|
|
109
|
+
workspaceApps: ["web"],
|
|
110
|
+
workspace: null,
|
|
111
|
+
apps: new Map([
|
|
112
|
+
[
|
|
113
|
+
"web",
|
|
114
|
+
{
|
|
115
|
+
file: "apps/web/akan.config.ts",
|
|
116
|
+
sha256: sha,
|
|
117
|
+
pipeline: {
|
|
118
|
+
stages: [
|
|
119
|
+
{ use: "ota", platforms: ["android"] },
|
|
120
|
+
{
|
|
121
|
+
use: "desktop-ota",
|
|
122
|
+
targets: ["store"],
|
|
123
|
+
platforms: [
|
|
124
|
+
{ os: "macos", arch: "arm64" },
|
|
125
|
+
{ os: "windows", arch: "x64" },
|
|
126
|
+
],
|
|
127
|
+
when: { branch: "main" },
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
]),
|
|
134
|
+
nativeTargets: new Map([
|
|
135
|
+
[
|
|
136
|
+
"web",
|
|
137
|
+
{
|
|
138
|
+
targets: [
|
|
139
|
+
{ name: "store", updates: true },
|
|
140
|
+
{ name: "pilot", updates: true },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
]),
|
|
145
|
+
akanVersion: "3.0.3",
|
|
146
|
+
});
|
|
147
|
+
expect(PipelineDryRun.render(result)).toBe(
|
|
148
|
+
[
|
|
149
|
+
"plan v1 · branch develop · env develop · trigger push · apps web",
|
|
150
|
+
"from apps/web/akan.config.ts",
|
|
151
|
+
"",
|
|
152
|
+
"prepare (executor) checkout · env · install · plan",
|
|
153
|
+
"deploy ota OTA web (store, pilot × android) action ota",
|
|
154
|
+
'deploy desktop-ota Desktop OTA web (store × macos-arm64, windows-x64; skipped: branch "develop" does not match "main") action desktop-ota',
|
|
155
|
+
"finish (executor) cleanup",
|
|
156
|
+
].join("\n"),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
106
160
|
test("a failed plan prints its diagnostics", () => {
|
|
107
161
|
const rendered = PipelineDryRun.render({
|
|
108
162
|
ok: false,
|
|
@@ -68,11 +68,8 @@ export class PipelineDryRun {
|
|
|
68
68
|
|
|
69
69
|
static #stage(phase: PipelinePlanPhase, stage: PipelinePlanStage) {
|
|
70
70
|
const label = stage.app && !phase.action && stage.name !== stage.app ? `${stage.app}:${stage.name}` : stage.name;
|
|
71
|
-
const ota = stage.steps.find((step) => step.kind === "action" && step.action === "ota");
|
|
72
71
|
const notes = [
|
|
73
|
-
|
|
74
|
-
? `${ota.with.targets.join(", ")} × ${ota.with.platforms.join(", ")}`
|
|
75
|
-
: null,
|
|
72
|
+
PipelineDryRun.#packs(stage),
|
|
76
73
|
stage.skip ? `skipped: ${stage.skip.reason}` : null,
|
|
77
74
|
stage.allowFailure ? "may fail" : null,
|
|
78
75
|
stage.runtimeWhen ? `if changed: ${stage.runtimeWhen.changed.join(", ")}` : null,
|
|
@@ -80,6 +77,16 @@ export class PipelineDryRun {
|
|
|
80
77
|
return notes.length ? `${label} (${notes.join("; ")})` : label;
|
|
81
78
|
}
|
|
82
79
|
|
|
80
|
+
static #packs(stage: PipelinePlanStage) {
|
|
81
|
+
for (const step of stage.steps) {
|
|
82
|
+
if (step.kind !== "action" || (step.action !== "ota" && step.action !== "desktop-ota")) continue;
|
|
83
|
+
const platforms =
|
|
84
|
+
step.action === "ota" ? step.with.platforms : step.with.platforms.map(({ os, arch }) => `${os}-${arch}`);
|
|
85
|
+
return `${step.with.targets.join(", ")} × ${platforms.join(", ")}`;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
static diagnostics(diagnostics: readonly PipelineDiagnostic[]) {
|
|
84
91
|
return diagnostics.map((diagnostic) => {
|
|
85
92
|
const where = [diagnostic.file, diagnostic.path].filter(Boolean).join(" · ");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type PipelineDesktopOtaPlatform,
|
|
2
3
|
type PipelineDiagnostic,
|
|
3
4
|
PipelineNames,
|
|
4
5
|
PipelinePattern,
|
|
@@ -6,6 +7,8 @@ import {
|
|
|
6
7
|
type PipelineValueProblem,
|
|
7
8
|
PipelineValueReader,
|
|
8
9
|
pipelineActionNames,
|
|
10
|
+
pipelineDesktopOtaArchs,
|
|
11
|
+
pipelineDesktopOtaSystems,
|
|
9
12
|
pipelineMilestones,
|
|
10
13
|
pipelineOtaPlatforms,
|
|
11
14
|
pipelinePlanLimits,
|
|
@@ -136,7 +139,7 @@ export class PipelineInputReader {
|
|
|
136
139
|
"use",
|
|
137
140
|
...PipelineInputReader.#stageKeys,
|
|
138
141
|
"retry",
|
|
139
|
-
...(raw.use === "ota" ? ["targets", "platforms"] : []),
|
|
142
|
+
...(raw.use === "ota" || raw.use === "desktop-ota" ? ["targets", "platforms"] : []),
|
|
140
143
|
])
|
|
141
144
|
)
|
|
142
145
|
return null;
|
|
@@ -165,7 +168,7 @@ export class PipelineInputReader {
|
|
|
165
168
|
? null
|
|
166
169
|
: this.#nonEmptySet(this.#strings(raw.targets, `${path}.targets`), `${path}.targets`),
|
|
167
170
|
platforms:
|
|
168
|
-
raw.platforms === undefined
|
|
171
|
+
action !== "ota" || raw.platforms === undefined
|
|
169
172
|
? null
|
|
170
173
|
: this.#nonEmptySet(
|
|
171
174
|
this.#list(raw.platforms, `${path}.platforms`).flatMap((platform, idx) => {
|
|
@@ -174,10 +177,47 @@ export class PipelineInputReader {
|
|
|
174
177
|
}),
|
|
175
178
|
`${path}.platforms`,
|
|
176
179
|
),
|
|
180
|
+
desktopPlatforms: action === "desktop-ota" ? this.#desktopPlatforms(raw.platforms, `${path}.platforms`) : null,
|
|
177
181
|
path,
|
|
178
182
|
};
|
|
179
183
|
}
|
|
180
184
|
|
|
185
|
+
#desktopPlatforms(value: unknown, path: string): PipelineDesktopOtaPlatform[] | null {
|
|
186
|
+
if (value === undefined || (Array.isArray(value) && !value.length)) {
|
|
187
|
+
this.#report(
|
|
188
|
+
"pipeline.desktopOta.noPlatforms",
|
|
189
|
+
'`desktop-ota` names the `platforms` it packs for, like { os: "macos", arch: "arm64" }: it has no default, since each needs a build host of its own OS',
|
|
190
|
+
path,
|
|
191
|
+
);
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const seen = new Set<string>();
|
|
195
|
+
const platforms = this.#list(value, path).flatMap((entry, idx): PipelineDesktopOtaPlatform[] => {
|
|
196
|
+
const entryPath = `${path}[${idx}]`;
|
|
197
|
+
const raw = this.#read.object(entry, entryPath, ["os", "arch"]);
|
|
198
|
+
if (!raw) return [];
|
|
199
|
+
const os = this.#read.oneOf(raw.os, `${entryPath}.os`, pipelineDesktopOtaSystems);
|
|
200
|
+
const arch = this.#read.oneOf(raw.arch, `${entryPath}.arch`, pipelineDesktopOtaArchs);
|
|
201
|
+
if (!os || !arch) return [];
|
|
202
|
+
const shown = `{ os: "${os}", arch: "${arch}" }`;
|
|
203
|
+
if (os === "macos" && arch === "x64") {
|
|
204
|
+
this.#report(
|
|
205
|
+
"pipeline.desktopOta.unsupportedPlatform",
|
|
206
|
+
`${shown} cannot be packed: a macOS app is built for arm64 only`,
|
|
207
|
+
entryPath,
|
|
208
|
+
);
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
if (seen.has(shown)) {
|
|
212
|
+
this.#report("pipeline.desktopOta.duplicatePlatform", `${shown} is listed twice`, entryPath);
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
seen.add(shown);
|
|
216
|
+
return [{ os, arch }];
|
|
217
|
+
});
|
|
218
|
+
return platforms.length ? platforms : null;
|
|
219
|
+
}
|
|
220
|
+
|
|
181
221
|
#nonEmptySet<T>(items: T[], path: string): T[] | null {
|
|
182
222
|
if (!items.length) {
|
|
183
223
|
this.#report("pipeline.schema.invalid", "lists none: leave it out to take the default", path);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PipelineActionName,
|
|
3
|
+
PipelineDesktopOtaPlatform,
|
|
3
4
|
PipelineMilestone,
|
|
4
5
|
PipelineOtaPlatform,
|
|
5
6
|
PipelinePlanRetry,
|
|
@@ -49,9 +50,12 @@ export interface PipelineActionStageRule extends PipelineStageRuleBase {
|
|
|
49
50
|
action: PipelineActionName;
|
|
50
51
|
named: boolean;
|
|
51
52
|
retry: PipelinePlanRetry | null;
|
|
52
|
-
/** `ota` only; `null` takes the default. */
|
|
53
|
+
/** `ota` and `desktop-ota` only; `null` takes the default. */
|
|
53
54
|
targets: string[] | null;
|
|
55
|
+
/** `ota` only; `null` takes the default. */
|
|
54
56
|
platforms: PipelineOtaPlatform[] | null;
|
|
57
|
+
/** `desktop-ota` only, which has no default: `null` there was reported by the reader. */
|
|
58
|
+
desktopPlatforms: PipelineDesktopOtaPlatform[] | null;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export interface PipelineParallelStageRule extends PipelineStageRuleBase {
|