@mirinjs/cli 0.1.0-alpha.16 → 0.1.0-alpha.18
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/package.json +8 -8
- package/src/artifacts.ts +10 -2
- package/src/build.ts +8 -1
- package/src/dev.ts +5 -1
- package/src/release.ts +35 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirinjs/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.18",
|
|
4
4
|
"description": "CLI for mirin apps: dev, build, init.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"bun": ">=1.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"create-mirinjs": "0.1.0-alpha.
|
|
31
|
-
"mirinjs": "0.1.0-alpha.
|
|
30
|
+
"create-mirinjs": "0.1.0-alpha.18",
|
|
31
|
+
"mirinjs": "0.1.0-alpha.18"
|
|
32
32
|
},
|
|
33
33
|
"optionalDependencies": {
|
|
34
|
-
"@mirinjs/darwin-arm64": "0.1.0-alpha.
|
|
35
|
-
"@mirinjs/win32-x64": "0.1.0-alpha.
|
|
36
|
-
"@mirinjs/win32-arm64": "0.1.0-alpha.
|
|
37
|
-
"@mirinjs/linux-arm64": "0.1.0-alpha.
|
|
38
|
-
"@mirinjs/linux-x64": "0.1.0-alpha.
|
|
34
|
+
"@mirinjs/darwin-arm64": "0.1.0-alpha.18",
|
|
35
|
+
"@mirinjs/win32-x64": "0.1.0-alpha.18",
|
|
36
|
+
"@mirinjs/win32-arm64": "0.1.0-alpha.18",
|
|
37
|
+
"@mirinjs/linux-arm64": "0.1.0-alpha.18",
|
|
38
|
+
"@mirinjs/linux-x64": "0.1.0-alpha.18"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
package/src/artifacts.ts
CHANGED
|
@@ -35,6 +35,8 @@ const IN_REPO = existsSync(join(REPO_ROOT, "crates", "mirin-core"));
|
|
|
35
35
|
export interface Artifacts {
|
|
36
36
|
/** libmirin_core.dylib — dlopened by the host. */
|
|
37
37
|
coreDylib: string;
|
|
38
|
+
/** Standalone updater codec used by `mirin release`. */
|
|
39
|
+
codecBin: string;
|
|
38
40
|
/** mirin-helper — the CEF subprocess binary. */
|
|
39
41
|
helperBin: string;
|
|
40
42
|
/** host entry (TS/JS) compiled with `bun build --compile`. */
|
|
@@ -53,12 +55,13 @@ export async function resolveArtifacts(opts: { release: boolean }): Promise<Arti
|
|
|
53
55
|
|
|
54
56
|
if (IN_REPO) {
|
|
55
57
|
const profile = opts.release ? "release" : "debug";
|
|
56
|
-
console.log(`[mirin] building native core +
|
|
58
|
+
console.log(`[mirin] building native core + helpers (${profile})…`);
|
|
57
59
|
const flags = opts.release ? ["--release"] : [];
|
|
58
|
-
await $`cargo build -p mirin-core -p mirin-helper ${flags}`.cwd(REPO_ROOT);
|
|
60
|
+
await $`cargo build -p mirin-codec -p mirin-core -p mirin-helper ${flags}`.cwd(REPO_ROOT);
|
|
59
61
|
const target = join(REPO_ROOT, "target", profile);
|
|
60
62
|
return {
|
|
61
63
|
coreDylib: join(target, coreFileName()),
|
|
64
|
+
codecBin: join(target, codecFileName()),
|
|
62
65
|
helperBin: join(target, helperFileName()),
|
|
63
66
|
hostEntry: join(REPO_ROOT, "packages", "mirin", "src", "host.ts"),
|
|
64
67
|
cefPath,
|
|
@@ -68,6 +71,7 @@ export async function resolveArtifacts(opts: { release: boolean }): Promise<Arti
|
|
|
68
71
|
const nativeDir = resolveNativeDir();
|
|
69
72
|
return {
|
|
70
73
|
coreDylib: join(nativeDir, coreFileName()),
|
|
74
|
+
codecBin: join(nativeDir, codecFileName()),
|
|
71
75
|
helperBin: join(nativeDir, helperFileName()),
|
|
72
76
|
hostEntry: resolvePackageFile("mirinjs/host"),
|
|
73
77
|
cefPath,
|
|
@@ -86,6 +90,10 @@ function helperFileName(): string {
|
|
|
86
90
|
return process.platform === "win32" ? "mirin-helper.exe" : "mirin-helper";
|
|
87
91
|
}
|
|
88
92
|
|
|
93
|
+
function codecFileName(): string {
|
|
94
|
+
return process.platform === "win32" ? "mirin-codec.exe" : "mirin-codec";
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
function assertSupportedPlatform(): void {
|
|
90
98
|
const supported =
|
|
91
99
|
(process.platform === "darwin" && process.arch === "arm64") ||
|
package/src/build.ts
CHANGED
|
@@ -125,6 +125,8 @@ export interface BuildResult {
|
|
|
125
125
|
releaseNotes?: string;
|
|
126
126
|
/** libmirin_core path (for the updater codec at release time). */
|
|
127
127
|
coreDylib: string;
|
|
128
|
+
/** Standalone updater codec executable used at release time. */
|
|
129
|
+
codecBin: string;
|
|
128
130
|
/** Project root (so `mirin release` can resolve relative asset paths). */
|
|
129
131
|
projectDir: string;
|
|
130
132
|
/** DMG config from mirin.config.ts (`true`/object/`false`); default `true`. */
|
|
@@ -209,7 +211,11 @@ export async function build(
|
|
|
209
211
|
const workerJs = join(work, "worker.release.js");
|
|
210
212
|
const sidecars = normalizeSidecars(projectDir, config.sidecars);
|
|
211
213
|
const hostBuild = (async (): Promise<void> => {
|
|
212
|
-
|
|
214
|
+
// Bun's Windows arm64 build currently has no bun:ffi/TinyCC runtime. The
|
|
215
|
+
// win32-arm64 Mirin package therefore carries an x64 compatibility payload,
|
|
216
|
+
// which Windows 11 ARM executes through its built-in x64 emulation layer.
|
|
217
|
+
const target = IS_WINDOWS && process.arch === "arm64" ? ["--target=bun-windows-x64"] : [];
|
|
218
|
+
await $`bun build --compile --minify ${target} ${artifacts.hostEntry} --outfile ${hostExe}`.cwd(
|
|
213
219
|
projectDir,
|
|
214
220
|
);
|
|
215
221
|
if (IS_WINDOWS) {
|
|
@@ -325,6 +331,7 @@ export async function build(
|
|
|
325
331
|
baseUrl,
|
|
326
332
|
releaseNotes,
|
|
327
333
|
coreDylib: artifacts.coreDylib,
|
|
334
|
+
codecBin: artifacts.codecBin,
|
|
328
335
|
projectDir,
|
|
329
336
|
dmg,
|
|
330
337
|
nsis,
|
package/src/dev.ts
CHANGED
|
@@ -59,7 +59,11 @@ export async function dev(projectDir = process.cwd()): Promise<number> {
|
|
|
59
59
|
// `bun build --compile` emits an `.exe` on Windows; name it so explicitly.
|
|
60
60
|
const hostExe = join(work, IS_WINDOWS ? "host.exe" : "host");
|
|
61
61
|
const workerJs = join(work, "worker.js");
|
|
62
|
-
|
|
62
|
+
const hostTarget =
|
|
63
|
+
process.platform === "win32" && process.arch === "arm64" ? ["--target=bun-windows-x64"] : [];
|
|
64
|
+
await $`bun build --compile ${hostTarget} ${artifacts.hostEntry} --outfile ${hostExe}`.cwd(
|
|
65
|
+
projectDir,
|
|
66
|
+
);
|
|
63
67
|
await $`bun build ${mainEntry} --target=bun --outfile ${workerJs}`.cwd(projectDir);
|
|
64
68
|
|
|
65
69
|
// Extra assets (dev): compile workers into .mirin/workers and symlink sidecar
|
package/src/release.ts
CHANGED
|
@@ -20,7 +20,6 @@ import { existsSync, mkdirSync, mkdtempSync, rmSync, statSync } from "node:fs";
|
|
|
20
20
|
import { tmpdir } from "node:os";
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { $ } from "bun";
|
|
23
|
-
import { loadCodec } from "mirinjs/codec";
|
|
24
23
|
import { build } from "./build.ts";
|
|
25
24
|
import { notarizeAndStaple } from "./dmg.ts";
|
|
26
25
|
import { buildReleaseInstaller } from "./release/installers.ts";
|
|
@@ -35,6 +34,37 @@ import {
|
|
|
35
34
|
// The native codec uses multiple workers, so this scales across CI runner cores.
|
|
36
35
|
const RELEASE_COMPRESSION_LEVEL = 10;
|
|
37
36
|
|
|
37
|
+
interface ReleaseCodec {
|
|
38
|
+
compress(src: string, dst: string, level: number): void;
|
|
39
|
+
decompress(src: string, dst: string): void;
|
|
40
|
+
diff(oldPath: string, newPath: string, patchPath: string): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createReleaseCodec(binary: string): ReleaseCodec {
|
|
44
|
+
const run = (operation: string, ...args: string[]) => {
|
|
45
|
+
const result = Bun.spawnSync({
|
|
46
|
+
cmd: [binary, operation, ...args],
|
|
47
|
+
stdout: "inherit",
|
|
48
|
+
stderr: "pipe",
|
|
49
|
+
});
|
|
50
|
+
if (result.exitCode !== 0) {
|
|
51
|
+
const detail = new TextDecoder().decode(result.stderr).trim();
|
|
52
|
+
throw new Error(`codec ${operation} failed${detail ? `: ${detail}` : ""}`);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
compress(src, dst, level) {
|
|
57
|
+
run("compress", src, dst, String(level));
|
|
58
|
+
},
|
|
59
|
+
decompress(src, dst) {
|
|
60
|
+
run("decompress", src, dst);
|
|
61
|
+
},
|
|
62
|
+
diff(oldPath, newPath, patchPath) {
|
|
63
|
+
run("diff", oldPath, newPath, patchPath);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
38
68
|
async function sha256File(path: string): Promise<string> {
|
|
39
69
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
40
70
|
for await (const chunk of Bun.file(path).stream()) {
|
|
@@ -83,20 +113,10 @@ export async function release(projectDir = process.cwd()): Promise<number> {
|
|
|
83
113
|
isLinux,
|
|
84
114
|
});
|
|
85
115
|
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
// NEEDED libcef.so (RUNPATH $ORIGIN), so load the *bundled* .so where libcef.so
|
|
91
|
-
// sits beside it — the raw native package has no libcef.so and dlopen fails.
|
|
92
|
-
// (On macOS the framework loads at runtime, so result.coreDylib works directly.)
|
|
93
|
-
const codecCore = isWindows
|
|
94
|
-
? join(result.app, "mirin_core.dll")
|
|
95
|
-
: isLinux
|
|
96
|
-
? join(result.app, "libmirin_core.so")
|
|
97
|
-
: result.coreDylib;
|
|
98
|
-
if (isWindows) process.env.PATH = `${result.app};${process.env.PATH ?? ""}`;
|
|
99
|
-
const codec = loadCodec(codecCore);
|
|
116
|
+
// Release tooling runs in plain Bun, including Windows arm64 builds where
|
|
117
|
+
// bun:ffi is unavailable. The standalone helper also avoids loading CEF merely
|
|
118
|
+
// to compress updater artifacts.
|
|
119
|
+
const codec = createReleaseCodec(result.codecBin);
|
|
100
120
|
|
|
101
121
|
// Uncompressed tar — the identity + diff/patch basis (BSD tar keeps symlinks).
|
|
102
122
|
const newTar = join(outDir, "_new.tar");
|