akanjs 3.3.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/common/PipelinePlanSchema.ts +31 -7
- package/common/index.ts +6 -0
- package/common/pipelinePlan.ts +31 -5
- package/index.ts +7 -5
- package/package.json +1 -1
- package/pipelineConfig.ts +25 -2
- package/service/agentLoop/agentLoop.ts +19 -12
- package/service/predefinedAdaptor/anthropicTools.ts +8 -2
- package/types/common/index.d.ts +1 -1
- package/types/common/pipelinePlan.d.ts +35 -6
- package/types/index.d.ts +7 -5
- package/types/pipelineConfig.d.ts +20 -3
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/service/predefinedAdaptor/anthropicTools.d.ts +1 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api-updates.d.ts +149 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +16 -162
- package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +3 -2
- package/types/vendor/@akanjs/native/packages/cli/src/lib/api-task.d.ts +79 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +17 -5
- package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +29 -2
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.d.ts +36 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.d.ts +15 -0
- package/types/vendor/@akanjs/native/packages/core/src/kernel.d.ts +16 -5
- package/types/vendor/@akanjs/native/packages/desktop/src/commands.d.ts +81 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/deeplinks.d.ts +5 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +3 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/lifecycle.d.ts +8 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +21 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/desktop.d.ts +4 -4
- package/types/vendor/@akanjs/native/plugins/updates/src/reports.d.ts +49 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/signer.d.ts +21 -0
- package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +55 -3
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +209 -54
- package/vendor/@akanjs/native/packages/cli/src/api-updates.ts +332 -0
- package/vendor/@akanjs/native/packages/cli/src/api.ts +67 -419
- package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +4 -1
- package/vendor/@akanjs/native/packages/cli/src/config.ts +3 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/api-task.ts +223 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +2 -7
- package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +164 -19
- package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +90 -3
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +195 -43
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-appimage.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.ts +206 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux.ts +5 -1
- package/vendor/@akanjs/native/packages/core/src/kernel.ts +21 -6
- package/vendor/@akanjs/native/packages/core/vectors/updates.json +2 -1
- package/vendor/@akanjs/native/packages/desktop/src/commands.ts +380 -0
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +20 -3
- package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +28 -13
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +6 -18
- package/vendor/@akanjs/native/packages/desktop/src/lifecycle.ts +8 -1
- package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +21 -0
- package/vendor/@akanjs/native/packages/desktop/src/server.ts +1 -1
- package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +90 -164
- package/vendor/@akanjs/native/plugins/updates/src/reports.ts +255 -0
- package/vendor/@akanjs/native/plugins/updates/src/signer.ts +133 -0
- package/vendor/@akanjs/native/plugins/window/native-plugin.json +6 -1
- package/vendor/@akanjs/native/plugins/window/src/desktop.ts +20 -4
- package/vendor/@akanjs/native/plugins/window/src/index.ts +55 -3
|
@@ -1,50 +1,49 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
checkPublishUpdate,
|
|
6
|
+
compareBundles,
|
|
7
|
+
packAppUpdate,
|
|
8
|
+
packUpdate,
|
|
9
|
+
publishUpdate,
|
|
10
|
+
republishUpdate,
|
|
11
|
+
updateKeygen,
|
|
12
|
+
} from "./api-updates.ts";
|
|
5
13
|
import { type DoctorCheck, doctorChecks, hostPlatforms, runFixes } from "./commands/doctor.ts";
|
|
6
14
|
import type { AkanNativeConfig } from "./config.ts";
|
|
7
|
-
import {
|
|
8
|
-
|
|
15
|
+
import {
|
|
16
|
+
AkanNativeError,
|
|
17
|
+
type AkanNativeErrorCode,
|
|
18
|
+
type Artifact,
|
|
19
|
+
type BuildResult,
|
|
20
|
+
buildIn,
|
|
21
|
+
type TaskOptions,
|
|
22
|
+
task,
|
|
23
|
+
toAkanNativeError,
|
|
24
|
+
} from "./lib/api-task.ts";
|
|
9
25
|
import { requestedDistribution } from "./lib/distribution.ts";
|
|
10
|
-
import { CancelledError, withSignal } from "./lib/exec.ts";
|
|
11
26
|
import { type HmrContext, lanAddress, resolveDevEntry, startHmrServer } from "./lib/hmr.ts";
|
|
12
27
|
import type { Device, DeviceSelector, Launched } from "./lib/launch.ts";
|
|
13
|
-
import { CliError, type LogEvent, type LogSink, log
|
|
28
|
+
import { CliError, type LogEvent, type LogSink, log } from "./lib/log.ts";
|
|
14
29
|
import {
|
|
15
30
|
type MacosBuild,
|
|
16
31
|
type MacosNotarization,
|
|
17
32
|
type MacosSigning,
|
|
18
33
|
macosDistributionFromEnv,
|
|
19
34
|
} from "./lib/macossigning.ts";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
prepare,
|
|
30
|
-
SigningError,
|
|
31
|
-
WebBuildError,
|
|
32
|
-
WebInputError,
|
|
33
|
-
type WindowsBuild,
|
|
35
|
+
import type {
|
|
36
|
+
AndroidSigning,
|
|
37
|
+
BuildContext,
|
|
38
|
+
BuildProfile,
|
|
39
|
+
IosBuild,
|
|
40
|
+
IosSigning,
|
|
41
|
+
IosSigningResult,
|
|
42
|
+
LinuxBuild,
|
|
43
|
+
WindowsBuild,
|
|
34
44
|
} from "./lib/prepare.ts";
|
|
35
45
|
import { ConfigError, type Project, projectFromConfig } from "./lib/project.ts";
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
assertChannel,
|
|
39
|
-
type DesktopArch,
|
|
40
|
-
generateUpdateKey,
|
|
41
|
-
keyIdOf,
|
|
42
|
-
type UpdateManifest,
|
|
43
|
-
updateKeyPath,
|
|
44
|
-
validateUpdates,
|
|
45
|
-
webManifest,
|
|
46
|
-
writeWebBundle,
|
|
47
|
-
} from "./lib/updates.ts";
|
|
46
|
+
import type { DesktopArch } from "./lib/updates.ts";
|
|
48
47
|
import { type WindowsSigning, windowsSigningFromEnv } from "./lib/windowssigning.ts";
|
|
49
48
|
import { androidDevices, launchAndroid } from "./platforms/android.ts";
|
|
50
49
|
import { PLATFORM_TARGETS, type TargetPlatform } from "./platforms/index.ts";
|
|
@@ -54,12 +53,14 @@ export {
|
|
|
54
53
|
MAX_REVOKE_KEYS,
|
|
55
54
|
MAX_UPDATE_MANIFEST,
|
|
56
55
|
UPDATE_REPORT_BATCH,
|
|
56
|
+
UPDATE_REPORT_DESKTOP_REASONS,
|
|
57
57
|
UPDATE_REPORT_EVENTS,
|
|
58
58
|
UPDATE_REPORT_LIMIT,
|
|
59
59
|
UPDATE_REPORT_REASONS,
|
|
60
60
|
type UpdateDecision,
|
|
61
61
|
type UpdateDecisionInput,
|
|
62
62
|
type UpdateReportBody,
|
|
63
|
+
type UpdateReportDesktopReason,
|
|
63
64
|
type UpdateReportEntry,
|
|
64
65
|
type UpdateReportEvent,
|
|
65
66
|
type UpdateReportOutcome,
|
|
@@ -69,17 +70,32 @@ export {
|
|
|
69
70
|
} from "../../core/src/kernel.ts";
|
|
70
71
|
/** How a desktop app's launcher keeps the server it carries running: desktop.server's restart and watchdog. */
|
|
71
72
|
export type { ServerPolicy } from "../../desktop/src/server.ts";
|
|
73
|
+
export type { AppUpdatePack, PublishCheckOptions, PublishResult, RepublishResult } from "./api-updates.ts";
|
|
72
74
|
/** A build's bundle.json, and the manifest and envelope of a release, as a signer or server reads them. */
|
|
73
75
|
export type { BundleInfo, NativeApi } from "./lib/compat.ts";
|
|
74
|
-
export type { UpdateEnvelope, UpdateFile, UpdateManifest } from "./lib/updates.ts";
|
|
76
|
+
export type { ManifestRelease, UpdateEnvelope, UpdateFile, UpdateManifest } from "./lib/updates.ts";
|
|
75
77
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
+
* The update protocol as the apps run it, for a signer or a server that checks what it publishes or registers: the
|
|
79
|
+
* envelope's verification, the keyId of a public key, and what a verified manifest means to a binary. And what signs
|
|
80
|
+
* a pack: its template made a release's manifest (fillManifest), that manifest's exact bytes (manifestBytes), and
|
|
81
|
+
* their envelope from a key file (sealManifest) or from a signature made elsewhere (updateEnvelope).
|
|
78
82
|
*/
|
|
79
|
-
export {
|
|
83
|
+
export {
|
|
84
|
+
fillManifest,
|
|
85
|
+
keyIdOf,
|
|
86
|
+
manifestBytes,
|
|
87
|
+
openEnvelope,
|
|
88
|
+
sealManifest,
|
|
89
|
+
updateEnvelope,
|
|
90
|
+
verifyManifest,
|
|
91
|
+
} from "./lib/updates.ts";
|
|
92
|
+
export type { AppSigner } from "./platforms/desktop-update.ts";
|
|
80
93
|
export type {
|
|
81
94
|
AkanNativeConfig,
|
|
95
|
+
AkanNativeErrorCode,
|
|
82
96
|
AndroidSigning,
|
|
97
|
+
Artifact,
|
|
98
|
+
BuildResult,
|
|
83
99
|
DesktopArch,
|
|
84
100
|
Device,
|
|
85
101
|
DeviceSelector,
|
|
@@ -93,6 +109,7 @@ export type {
|
|
|
93
109
|
MacosNotarization,
|
|
94
110
|
MacosSigning,
|
|
95
111
|
TargetPlatform,
|
|
112
|
+
TaskOptions,
|
|
96
113
|
WindowsBuild,
|
|
97
114
|
WindowsSigning,
|
|
98
115
|
};
|
|
@@ -101,88 +118,22 @@ export type {
|
|
|
101
118
|
* environment (the API itself reads no variable): pass the result as `macos`.
|
|
102
119
|
*/
|
|
103
120
|
/** The Authenticode settings the AKAN_NATIVE_WINDOWS_* variables name: pass the result as `windows.signing`. */
|
|
104
|
-
export {
|
|
121
|
+
export {
|
|
122
|
+
AkanNativeError,
|
|
123
|
+
checkPublishUpdate,
|
|
124
|
+
compareBundles,
|
|
125
|
+
macosDistributionFromEnv,
|
|
126
|
+
packAppUpdate,
|
|
127
|
+
packUpdate,
|
|
128
|
+
publishUpdate,
|
|
129
|
+
republishUpdate,
|
|
130
|
+
requestedDistribution,
|
|
131
|
+
updateKeygen,
|
|
132
|
+
windowsSigningFromEnv,
|
|
133
|
+
};
|
|
105
134
|
|
|
106
135
|
/** semver of this API. A caller checks the major before it relies on anything here. */
|
|
107
|
-
export const API_VERSION = "0.
|
|
108
|
-
|
|
109
|
-
export type AkanNativeErrorCode =
|
|
110
|
-
| "CONFIG_INVALID"
|
|
111
|
-
| "TOOLCHAIN_MISSING"
|
|
112
|
-
| "WEB_INPUT_INVALID"
|
|
113
|
-
| "WEB_BUILD_FAILED"
|
|
114
|
-
| "NATIVE_BUILD_FAILED"
|
|
115
|
-
| "SIGNING_FAILED"
|
|
116
|
-
| "DEVICE_FAILED"
|
|
117
|
-
| "CANCELLED"
|
|
118
|
-
| "INTERNAL";
|
|
119
|
-
|
|
120
|
-
export class AkanNativeError extends Error {
|
|
121
|
-
constructor(
|
|
122
|
-
readonly code: AkanNativeErrorCode,
|
|
123
|
-
message: string,
|
|
124
|
-
readonly details: { problems?: string[]; hint?: string; logTail?: string[]; cause?: unknown } = {},
|
|
125
|
-
) {
|
|
126
|
-
super(message);
|
|
127
|
-
this.name = "AkanNativeError";
|
|
128
|
-
}
|
|
129
|
-
get problems(): string[] | undefined {
|
|
130
|
-
return this.details.problems;
|
|
131
|
-
}
|
|
132
|
-
get hint(): string | undefined {
|
|
133
|
-
return this.details.hint;
|
|
134
|
-
}
|
|
135
|
-
get logTail(): string[] | undefined {
|
|
136
|
-
return this.details.logTail;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface TaskOptions {
|
|
141
|
-
/** Base of the config's relative paths (web.dir, icon, relative plugin folders). */
|
|
142
|
-
appDir: string;
|
|
143
|
-
/** What akan-native.config.ts would export. No file is read. */
|
|
144
|
-
config: AkanNativeConfig;
|
|
145
|
-
platform: TargetPlatform;
|
|
146
|
-
/** Default <appDir>/.akan/native/build/<platform>. */
|
|
147
|
-
outDir?: string;
|
|
148
|
-
/** Picks .env.<mode>. Default "production" for build, "development" for run. */
|
|
149
|
-
mode?: string;
|
|
150
|
-
/** false: no .env files from appDir. Default true. */
|
|
151
|
-
envFiles?: boolean;
|
|
152
|
-
/** PUBLIC_ values above .env files and config.env. */
|
|
153
|
-
env?: Record<string, string>;
|
|
154
|
-
/** Skip config.web.build and use web.dir as it is. */
|
|
155
|
-
skipWebBuild?: boolean;
|
|
156
|
-
/** Where plugin package names resolve from. Default appDir. */
|
|
157
|
-
resolveFrom?: string;
|
|
158
|
-
/** Receives the log. Without it nothing is logged. */
|
|
159
|
-
log?: LogSink;
|
|
160
|
-
/** Kills the running tools and rejects with CANCELLED. */
|
|
161
|
-
signal?: AbortSignal;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface Artifact {
|
|
165
|
-
kind: "app" | "apk" | "aab" | "ipa" | "folder" | "web" | "installer";
|
|
166
|
-
path: string;
|
|
167
|
-
signing: "none" | "adhoc" | "debug" | "development" | "distribution";
|
|
168
|
-
device?: "simulator" | "device";
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export interface BuildResult {
|
|
172
|
-
platform: TargetPlatform;
|
|
173
|
-
profile: BuildProfile;
|
|
174
|
-
outDir: string;
|
|
175
|
-
artifacts: Artifact[];
|
|
176
|
-
warnings: string[];
|
|
177
|
-
durationMs: number;
|
|
178
|
-
/** iPhone builds: the identity and provisioning profile found (docs/api.md §3 "Finding the signing"). */
|
|
179
|
-
signing?: IosSigningResult;
|
|
180
|
-
/**
|
|
181
|
-
* Android builds that contain pinned libraries (push's FCM module, iap): the license notices file
|
|
182
|
-
* (akan-native-licenses.json, also served in the app at /akan-native-licenses.json).
|
|
183
|
-
*/
|
|
184
|
-
licenses?: string;
|
|
185
|
-
}
|
|
136
|
+
export const API_VERSION = "0.14.0";
|
|
186
137
|
|
|
187
138
|
export interface RunningApp {
|
|
188
139
|
build: BuildResult;
|
|
@@ -259,182 +210,6 @@ export function release(
|
|
|
259
210
|
});
|
|
260
211
|
}
|
|
261
212
|
|
|
262
|
-
/**
|
|
263
|
-
* An unsigned web bundle update (UP-2), for a signer that keeps the key off the build machine. Writes
|
|
264
|
-
* `<out>/files/<sha256>`, `<out>/manifest.template.json` (the manifest with `channel`, `sequence` and `bundle` left
|
|
265
|
-
* empty for the signer) and `<out>/bundle.json` (the native API the bundle needs, UP-3). Prepares the web bundle as a
|
|
266
|
-
* release build does, without building the native app.
|
|
267
|
-
*/
|
|
268
|
-
export function packUpdate(
|
|
269
|
-
options: TaskOptions & { platform: "ios" | "android"; out: string },
|
|
270
|
-
): Promise<{ manifest: UpdateManifest; out: string }> {
|
|
271
|
-
return task(options, async () => {
|
|
272
|
-
const appDir = resolve(options.appDir);
|
|
273
|
-
let project: Project;
|
|
274
|
-
try {
|
|
275
|
-
project = projectFromConfig(options.config, appDir, { resolveFrom: options.resolveFrom });
|
|
276
|
-
} catch (error) {
|
|
277
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const out = resolve(options.out);
|
|
281
|
-
mkdirSync(out, { recursive: true });
|
|
282
|
-
const ctx = await prepare(project, options.platform, {
|
|
283
|
-
mode: options.mode ?? "production",
|
|
284
|
-
profile: "release",
|
|
285
|
-
skipWebBuild: options.skipWebBuild ?? false,
|
|
286
|
-
outDir: out,
|
|
287
|
-
envFiles: options.envFiles,
|
|
288
|
-
env: options.env,
|
|
289
|
-
api: true,
|
|
290
|
-
}).catch((error) => {
|
|
291
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
292
|
-
});
|
|
293
|
-
makeNativeBoot(ctx, options.platform);
|
|
294
|
-
const info = readBundleInfo(join(out, BUNDLE_FILE));
|
|
295
|
-
const manifest = webManifest({
|
|
296
|
-
app: project.config.app,
|
|
297
|
-
platform: options.platform,
|
|
298
|
-
channel: "",
|
|
299
|
-
nativeApi: info.nativeApi.hash,
|
|
300
|
-
sequence: 0,
|
|
301
|
-
bundle: "",
|
|
302
|
-
files: writeWebBundle(out, ctx.webDir, ctx.html, ctx.env),
|
|
303
|
-
});
|
|
304
|
-
writeFileSync(join(out, "manifest.template.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
305
|
-
return { manifest, out };
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export interface PublishResult {
|
|
310
|
-
build: BuildResult;
|
|
311
|
-
/** `<out>/<os>-<arch>` (desktop) or `<out>/<platform>` (a phone's web bundle): what to upload under updates.url. */
|
|
312
|
-
dir: string;
|
|
313
|
-
bundle: string;
|
|
314
|
-
channel: string;
|
|
315
|
-
files: number;
|
|
316
|
-
/** Bytes of the files the manifest names. */
|
|
317
|
-
size: number;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export interface PublishCheckOptions extends Pick<TaskOptions, "appDir" | "config"> {
|
|
321
|
-
platform: Exclude<TargetPlatform, "web">;
|
|
322
|
-
channel?: string;
|
|
323
|
-
out?: string;
|
|
324
|
-
/** Whether the release will carry a server; the config's `desktop.server` by default. */
|
|
325
|
-
server?: boolean;
|
|
326
|
-
/** A desktop release's CPU, which names its feed folder: this computer's by default. */
|
|
327
|
-
arch?: DesktopArch;
|
|
328
|
-
/**
|
|
329
|
-
* keyIds of updates.publicKeys the release starts revoking, beside updates.revokedKeys and what the channel's releases
|
|
330
|
-
* revoke. It is signed with a key listed after every key it revokes.
|
|
331
|
-
*/
|
|
332
|
-
revoke?: string[];
|
|
333
|
-
/** A release that revokes a key: apps compare it with their own build instead of the running release. */
|
|
334
|
-
resetSequence?: boolean;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* What publishUpdate() refuses before it builds, without building (CONFIG_INVALID): no updates settings, a channel no
|
|
339
|
-
* app could be configured for, no signing key on this machine or another app's, a desktop release whose server
|
|
340
|
-
* presence is not the channel's previous release's, and a release whose revocations no app would take. For a
|
|
341
|
-
* caller with a long build of its own before publishUpdate.
|
|
342
|
-
*/
|
|
343
|
-
export function checkPublishUpdate(options: PublishCheckOptions): { channel: string; out: string } {
|
|
344
|
-
if (!options.config.updates)
|
|
345
|
-
throw new AkanNativeError("CONFIG_INVALID", "the config has no updates: { url, publicKeys } to publish for");
|
|
346
|
-
const channel = options.channel ?? options.config.updates.channel ?? "production";
|
|
347
|
-
const out = resolve(options.out ?? resolve(options.appDir, ".akan", "native", "updates"));
|
|
348
|
-
const problems: string[] = [];
|
|
349
|
-
const updates = validateUpdates(options.config.updates, problems);
|
|
350
|
-
if (!updates || problems.length)
|
|
351
|
-
throw new AkanNativeError("CONFIG_INVALID", "the config's updates are not valid", { problems });
|
|
352
|
-
try {
|
|
353
|
-
if (options.channel !== undefined) assertChannel(options.channel);
|
|
354
|
-
const target = { app: options.config.app, updates };
|
|
355
|
-
assertSigningKey(target);
|
|
356
|
-
releaseRevocations(target, options.platform, out, channel, options, options.arch);
|
|
357
|
-
const server = options.server ?? !!options.config.desktop?.server;
|
|
358
|
-
assertServerOfChannel({ desktop: server ? { server } : {} }, options.platform, out, channel, options.arch);
|
|
359
|
-
} catch (error) {
|
|
360
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
361
|
-
}
|
|
362
|
-
return { channel, out };
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* A signed release for the updates plugin (UP-1, UP-2): a release build, then its envelope and its files under `out`
|
|
367
|
-
* (default <appDir>/.akan/native/updates), signed with the key updateKeygen() made.
|
|
368
|
-
*/
|
|
369
|
-
export function publishUpdate(
|
|
370
|
-
options: TaskOptions & {
|
|
371
|
-
platform: Exclude<TargetPlatform, "web">;
|
|
372
|
-
channel?: string;
|
|
373
|
-
out?: string;
|
|
374
|
-
/** The signature a macOS release carries: the installed app's own, or the updater refuses it. No dmg is made. */
|
|
375
|
-
macos?: Pick<MacosBuild, "signing" | "notarize">;
|
|
376
|
-
/** Authenticode for a Windows release's files. No setup program is made. */
|
|
377
|
-
windows?: Pick<WindowsBuild, "signing">;
|
|
378
|
-
/** A desktop release's CPU, of the same OS: an x64 release from an arm64 machine. Default this computer's. */
|
|
379
|
-
arch?: DesktopArch;
|
|
380
|
-
/** keyIds of updates.publicKeys the release starts revoking (PublishCheckOptions.revoke). */
|
|
381
|
-
revoke?: string[];
|
|
382
|
-
/** A release that revokes a key: apps compare it with their own build instead of the running release. */
|
|
383
|
-
resetSequence?: boolean;
|
|
384
|
-
},
|
|
385
|
-
): Promise<PublishResult> {
|
|
386
|
-
return task(options, async (warnings) => {
|
|
387
|
-
const { channel, out } = checkPublishUpdate(options);
|
|
388
|
-
const { ctx, artifact, result } = await buildIn(options, "release", options.mode ?? "production", warnings, {
|
|
389
|
-
...(options.macos ? { macos: { ...options.macos, dmg: false } } : {}),
|
|
390
|
-
...(options.windows?.signing ? { windows: { signing: options.windows.signing } } : {}),
|
|
391
|
-
...(options.arch ? { arch: options.arch } : {}),
|
|
392
|
-
});
|
|
393
|
-
const { dir, manifest } = await publishRelease(ctx, options.platform, artifact, out, channel, options).catch(
|
|
394
|
-
(error) => {
|
|
395
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
396
|
-
},
|
|
397
|
-
);
|
|
398
|
-
return {
|
|
399
|
-
build: result,
|
|
400
|
-
dir,
|
|
401
|
-
bundle: manifest.bundle,
|
|
402
|
-
channel,
|
|
403
|
-
files: manifest.files.length,
|
|
404
|
-
size: manifest.files.reduce((n, f) => n + f.size, 0),
|
|
405
|
-
};
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Whether a web bundle can run in the binary a store release shipped (UP-3): `shipped` is that build's bundle.json,
|
|
411
|
-
* `bundle` the one `packUpdate` wrote. Anything in `problems` means a new binary.
|
|
412
|
-
*/
|
|
413
|
-
export function compareBundles(shipped: string, bundle: string): { compatible: boolean; problems: string[] } {
|
|
414
|
-
const [before, now] = [readBundleInfo(resolve(shipped)), readBundleInfo(resolve(bundle))];
|
|
415
|
-
const problems =
|
|
416
|
-
before.app.id !== now.app.id
|
|
417
|
-
? [`${shipped} is for ${before.app.id}, the bundle for ${now.app.id}`]
|
|
418
|
-
: compatProblems(before.nativeApi.inputs, now.nativeApi.inputs);
|
|
419
|
-
return { compatible: problems.length === 0, problems };
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* The app's update signing key: made once (AKAN_NATIVE_UPDATE_KEY, else ~/.akan/native/keys/<app id>.update.key),
|
|
424
|
-
* then read. `publicKey` goes into the config's `updates.publicKeys`; the key file never leaves the machine. `keyId`
|
|
425
|
-
* is what a revocation names it by (`publishUpdate({ revoke })`, `updates.revokedKeys`).
|
|
426
|
-
*/
|
|
427
|
-
export function updateKeygen(options: { config: AkanNativeConfig }): {
|
|
428
|
-
publicKey: string;
|
|
429
|
-
keyId: string;
|
|
430
|
-
keyPath: string;
|
|
431
|
-
created: boolean;
|
|
432
|
-
} {
|
|
433
|
-
const keyPath = updateKeyPath(options.config.app.id);
|
|
434
|
-
const key = generateUpdateKey(keyPath);
|
|
435
|
-
return { ...key, keyId: keyIdOf(key.publicKey), keyPath };
|
|
436
|
-
}
|
|
437
|
-
|
|
438
213
|
/** Builds (default profile debug) and launches the app on a simulator, emulator, desktop or browser. */
|
|
439
214
|
export function run(
|
|
440
215
|
options: TaskOptions & {
|
|
@@ -725,130 +500,3 @@ async function selectDevice(
|
|
|
725
500
|
if (problem) throw new AkanNativeError("DEVICE_FAILED", `${found.name} ${problem}`);
|
|
726
501
|
return found.id;
|
|
727
502
|
}
|
|
728
|
-
|
|
729
|
-
/** Builds with one outDir at a time: a second call for the same folder waits for the first. */
|
|
730
|
-
const outDirLocks = new Map<string, Promise<unknown>>();
|
|
731
|
-
|
|
732
|
-
async function buildIn(
|
|
733
|
-
options: TaskOptions,
|
|
734
|
-
profile: BuildProfile,
|
|
735
|
-
mode: string,
|
|
736
|
-
warnings: string[],
|
|
737
|
-
extra: Pick<
|
|
738
|
-
BuildOptions,
|
|
739
|
-
"android" | "ios" | "windows" | "macos" | "linux" | "arch" | "devServer" | "startPath"
|
|
740
|
-
> = {},
|
|
741
|
-
): Promise<{ ctx: BuildContext; artifact: string; result: BuildResult }> {
|
|
742
|
-
const started = performance.now();
|
|
743
|
-
const appDir = resolve(options.appDir);
|
|
744
|
-
let project: Project;
|
|
745
|
-
try {
|
|
746
|
-
project = projectFromConfig(options.config, appDir, { resolveFrom: options.resolveFrom });
|
|
747
|
-
} catch (error) {
|
|
748
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
749
|
-
}
|
|
750
|
-
const outDir = resolve(options.outDir ?? resolve(appDir, ".akan", "native", "build", options.platform));
|
|
751
|
-
const previous = outDirLocks.get(outDir) ?? Promise.resolve();
|
|
752
|
-
const mine = previous
|
|
753
|
-
.catch(() => {})
|
|
754
|
-
.then(async () => {
|
|
755
|
-
const ctx = await prepare(project, options.platform, {
|
|
756
|
-
mode,
|
|
757
|
-
profile,
|
|
758
|
-
skipWebBuild: options.skipWebBuild ?? false,
|
|
759
|
-
outDir,
|
|
760
|
-
envFiles: options.envFiles,
|
|
761
|
-
env: options.env,
|
|
762
|
-
api: true,
|
|
763
|
-
...extra,
|
|
764
|
-
}).catch((error) => {
|
|
765
|
-
throw toAkanNativeError(error, "CONFIG_INVALID");
|
|
766
|
-
});
|
|
767
|
-
const artifact = await PLATFORM_TARGETS[options.platform].build(ctx).catch((error) => {
|
|
768
|
-
throw toAkanNativeError(error, "NATIVE_BUILD_FAILED");
|
|
769
|
-
});
|
|
770
|
-
return { ctx, artifact };
|
|
771
|
-
});
|
|
772
|
-
outDirLocks.set(outDir, mine);
|
|
773
|
-
try {
|
|
774
|
-
const { ctx, artifact } = await mine;
|
|
775
|
-
const artifacts = [
|
|
776
|
-
describe(options.platform, artifact, ctx),
|
|
777
|
-
...ctx.artifacts.map((a): Artifact => ({ kind: a.kind, path: a.path, signing: ctx.signedAs ?? "none" })),
|
|
778
|
-
];
|
|
779
|
-
const result: BuildResult = {
|
|
780
|
-
platform: options.platform,
|
|
781
|
-
profile,
|
|
782
|
-
outDir: ctx.outDir,
|
|
783
|
-
artifacts,
|
|
784
|
-
warnings,
|
|
785
|
-
durationMs: Math.round(performance.now() - started),
|
|
786
|
-
...(ctx.iosSigning ? { signing: ctx.iosSigning } : {}),
|
|
787
|
-
...(ctx.licenses ? { licenses: ctx.licenses } : {}),
|
|
788
|
-
};
|
|
789
|
-
return { ctx, artifact, result };
|
|
790
|
-
} finally {
|
|
791
|
-
if (outDirLocks.get(outDir) === mine) outDirLocks.delete(outDir);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
function describe(platform: TargetPlatform, path: string, ctx: BuildContext): Artifact {
|
|
796
|
-
switch (platform) {
|
|
797
|
-
case "web":
|
|
798
|
-
return { kind: "web", path, signing: "none" };
|
|
799
|
-
case "macos":
|
|
800
|
-
return { kind: "app", path, signing: ctx.signedAs ?? "adhoc" };
|
|
801
|
-
case "windows":
|
|
802
|
-
case "linux":
|
|
803
|
-
return { kind: "folder", path, signing: ctx.signedAs ?? "none" };
|
|
804
|
-
case "ios":
|
|
805
|
-
return ctx.ios?.device
|
|
806
|
-
? { kind: "app", path, signing: ctx.signedAs ?? "development", device: "device" }
|
|
807
|
-
: { kind: "app", path, signing: "adhoc", device: "simulator" };
|
|
808
|
-
case "android":
|
|
809
|
-
return { kind: "apk", path, signing: ctx.signedAs ?? "debug" };
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
/** Runs an API call with its own log sink (warnings collected) and abort signal; failures become AkanNativeError. */
|
|
814
|
-
async function task<T>(
|
|
815
|
-
options: { log?: LogSink; signal?: AbortSignal },
|
|
816
|
-
fn: (warnings: string[]) => Promise<T>,
|
|
817
|
-
): Promise<T> {
|
|
818
|
-
const warnings: string[] = [];
|
|
819
|
-
const sink: LogSink = (event) => {
|
|
820
|
-
if (event.level === "warn") warnings.push(event.message);
|
|
821
|
-
options.log?.(event);
|
|
822
|
-
};
|
|
823
|
-
if (options.signal?.aborted) throw new AkanNativeError("CANCELLED", "cancelled before it started");
|
|
824
|
-
try {
|
|
825
|
-
return await withLogSink(sink, () => withSignal(options.signal, () => fn(warnings)));
|
|
826
|
-
} catch (error) {
|
|
827
|
-
throw toAkanNativeError(error, "INTERNAL");
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/** An error as an AkanNativeError: its own kind decides the code, else the phase it happened in. */
|
|
832
|
-
function toAkanNativeError(error: unknown, phase: AkanNativeErrorCode): AkanNativeError {
|
|
833
|
-
if (error instanceof AkanNativeError) return error;
|
|
834
|
-
if (error instanceof CancelledError || (error as Error)?.name === "AbortError")
|
|
835
|
-
return new AkanNativeError("CANCELLED", "cancelled", { cause: error });
|
|
836
|
-
if (error instanceof ConfigError)
|
|
837
|
-
return new AkanNativeError("CONFIG_INVALID", error.message, { problems: error.problems, cause: error });
|
|
838
|
-
if (error instanceof ToolchainError)
|
|
839
|
-
return new AkanNativeError("TOOLCHAIN_MISSING", error.message, { hint: "akan-native doctor", cause: error });
|
|
840
|
-
if (error instanceof WebBuildError) return new AkanNativeError("WEB_BUILD_FAILED", error.message, { cause: error });
|
|
841
|
-
if (error instanceof WebInputError) return new AkanNativeError("WEB_INPUT_INVALID", error.message, { cause: error });
|
|
842
|
-
if (error instanceof SigningError)
|
|
843
|
-
return new AkanNativeError("SIGNING_FAILED", error.message, {
|
|
844
|
-
...(error.problems.length ? { problems: error.problems } : {}),
|
|
845
|
-
cause: error,
|
|
846
|
-
});
|
|
847
|
-
if (error instanceof ToolError)
|
|
848
|
-
return new AkanNativeError(phase === "CONFIG_INVALID" ? "NATIVE_BUILD_FAILED" : phase, error.message, {
|
|
849
|
-
logTail: error.tail,
|
|
850
|
-
cause: error,
|
|
851
|
-
});
|
|
852
|
-
if (error instanceof CliError) return new AkanNativeError(phase, error.message, { cause: error });
|
|
853
|
-
return new AkanNativeError("INTERNAL", (error as Error)?.message ?? String(error), { cause: error });
|
|
854
|
-
}
|
|
@@ -83,7 +83,10 @@ export async function buildFromArgs(
|
|
|
83
83
|
|
|
84
84
|
if (args.flags.aab === true && platform !== "android") throw new CliError("--aab is for android", 2);
|
|
85
85
|
if (args.flags.installer === true && platform !== "windows" && platform !== "macos" && platform !== "linux")
|
|
86
|
-
throw new CliError(
|
|
86
|
+
throw new CliError(
|
|
87
|
+
"--installer is for windows (a setup program), macos (a dmg) and linux (an AppImage and a tar.gz that installs)",
|
|
88
|
+
2,
|
|
89
|
+
);
|
|
87
90
|
|
|
88
91
|
const device = args.flags.device;
|
|
89
92
|
const iphone = platform === "ios" && typeof device === "string" ? await physicalIosDevice(device) : null;
|
|
@@ -117,8 +117,9 @@ export interface AkanNativeConfig {
|
|
|
117
117
|
* @akanjs/native/plugins/updates. `akan-native update keygen` makes the signing key and prints its public key;
|
|
118
118
|
* `akan-native update publish <platform>` writes signed releases for `url`. `publicKeys` lists the keys an app
|
|
119
119
|
* trusts, the online signing key first and offline spares after (a key revokes only keys before it); `publicKey` is
|
|
120
|
-
* the one-key form, and a desktop app built before protocol v2 trusts the first. `report.url` is where
|
|
121
|
-
* what became of each release
|
|
120
|
+
* the one-key form, and a desktop app built before protocol v2 trusts the first. `report.url` is where an app posts
|
|
121
|
+
* what became of each release: a phone at its next launch or return to the foreground, a desktop app at launch and
|
|
122
|
+
* with each check.
|
|
122
123
|
*/
|
|
123
124
|
updates?: {
|
|
124
125
|
url: string;
|