@zenbujs/core 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-electron-B4Gd0Gi4.mjs → build-electron-BzHa_hRi.mjs} +31 -67
- package/dist/{build-source-_q1n1zTV.mjs → build-source-CnTfQBGK.mjs} +2 -1
- package/dist/cli/bin.mjs +7 -7
- package/dist/index.mjs +1 -1
- package/dist/launcher.mjs +18142 -27
- package/dist/load-build-config-DozuRhAN.mjs +40 -0
- package/dist/loaders/zenbu.mjs +1 -1
- package/dist/{mirror-sync-CodOnwkD.mjs → mirror-sync-BN59kMCG.mjs} +2 -101
- package/dist/{publish-source-BVgB62Zj.mjs → publish-source-BJdpDAFH.mjs} +2 -1
- package/dist/{setup-gate-BeD6WS6d.mjs → setup-gate-BcoqWu8S.mjs} +2 -2
- package/dist/setup-gate.mjs +1 -1
- package/package.json +4 -4
- package/dist/pause-DvAUNmKn.mjs +0 -52
- /package/dist/{db-DhuAJrye.mjs → db-BXadETOb.mjs} +0 -0
- /package/dist/{dev-BuqklM0k.mjs → dev-BU_llQh1.mjs} +0 -0
- /package/dist/{link-6roQ7Cn6.mjs → link-VOoGs-pY.mjs} +0 -0
- /package/dist/{monorepo-CmGPHsVm.mjs → monorepo-CQeQBIpa.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as loadBuildConfig, t as findBuildConfig } from "./load-build-config-DozuRhAN.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
@@ -7,8 +7,8 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import fsp from "node:fs/promises";
|
|
9
9
|
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
10
|
-
import { promisify } from "node:util";
|
|
11
10
|
import https from "node:https";
|
|
11
|
+
import { promisify } from "node:util";
|
|
12
12
|
//#region src/cli/lib/toolchain.ts
|
|
13
13
|
const execFileAsync = promisify(execFile);
|
|
14
14
|
/**
|
|
@@ -216,10 +216,7 @@ function resolveProjectDir() {
|
|
|
216
216
|
* as a zen flag (and unknown flags error out).
|
|
217
217
|
*/
|
|
218
218
|
function parseFlags(argv) {
|
|
219
|
-
const flags = {
|
|
220
|
-
noSource: false,
|
|
221
|
-
passthrough: []
|
|
222
|
-
};
|
|
219
|
+
const flags = { passthrough: [] };
|
|
223
220
|
let sawSeparator = false;
|
|
224
221
|
for (let i = 0; i < argv.length; i++) {
|
|
225
222
|
const arg = argv[i];
|
|
@@ -233,10 +230,9 @@ function parseFlags(argv) {
|
|
|
233
230
|
}
|
|
234
231
|
if (arg === "--config" || arg === "-c") flags.config = argv[++i];
|
|
235
232
|
else if (arg.startsWith("--config=")) flags.config = arg.slice(9);
|
|
236
|
-
else if (arg === "--no-source") flags.noSource = true;
|
|
237
233
|
else {
|
|
238
234
|
console.error(`zen build:electron: unknown flag "${arg}"`);
|
|
239
|
-
console.error(`valid: zen build:electron [--config <zenbu.build.ts>] [--
|
|
235
|
+
console.error(`valid: zen build:electron [--config <zenbu.build.ts>] [-- <electron-builder args>]`);
|
|
240
236
|
process.exit(1);
|
|
241
237
|
}
|
|
242
238
|
}
|
|
@@ -330,35 +326,15 @@ function readElectronBuilderConfig(projectDir) {
|
|
|
330
326
|
if (path.basename(found.path) === "package.json") return { ...readJson(found.path).build ?? {} };
|
|
331
327
|
return readJson(found.path);
|
|
332
328
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}).trim();
|
|
342
|
-
} catch {
|
|
343
|
-
return "uncommitted";
|
|
344
|
-
}
|
|
345
|
-
})();
|
|
346
|
-
if (fs.existsSync(shaPath)) {
|
|
347
|
-
const meta = readJson(shaPath);
|
|
348
|
-
if (meta.sourceSha === currentSha) return meta;
|
|
349
|
-
if (noSource) {
|
|
350
|
-
console.warn(`[build:electron] --no-source: using stale staging (built from ${meta.sourceSha.slice(0, 7)}, current HEAD ${currentSha.slice(0, 7)})`);
|
|
351
|
-
return meta;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
if (noSource) {
|
|
355
|
-
console.error("zen build:electron: --no-source given but no staging found. Run `zen build:source` first.");
|
|
356
|
-
process.exit(1);
|
|
329
|
+
function currentSourceSha(projectDir) {
|
|
330
|
+
try {
|
|
331
|
+
return execFileSync("git", ["rev-parse", "HEAD"], {
|
|
332
|
+
cwd: projectDir,
|
|
333
|
+
encoding: "utf8"
|
|
334
|
+
}).trim();
|
|
335
|
+
} catch {
|
|
336
|
+
return "uncommitted";
|
|
357
337
|
}
|
|
358
|
-
console.log(` → running zen build:source (seed is missing or stale)`);
|
|
359
|
-
const { runBuildSource } = await import("./build-source-_q1n1zTV.mjs");
|
|
360
|
-
await runBuildSource([]);
|
|
361
|
-
return readJson(shaPath);
|
|
362
338
|
}
|
|
363
339
|
async function spawnAsync(cmd, args, cwd, env = process.env) {
|
|
364
340
|
await new Promise((resolve, reject) => {
|
|
@@ -384,9 +360,10 @@ async function spawnAsync(cmd, args, cwd, env = process.env) {
|
|
|
384
360
|
* entries would not resolve anyway
|
|
385
361
|
* - `extraResources` additive — we APPEND the toolchain entry to
|
|
386
362
|
* whatever the user already declared
|
|
387
|
-
* - `npmRebuild` forced to false — the
|
|
388
|
-
*
|
|
389
|
-
*
|
|
363
|
+
* - `npmRebuild` forced to false — the launcher clones the
|
|
364
|
+
* source from the mirror at first launch and
|
|
365
|
+
* runs `pnpm install` then; nothing to rebuild
|
|
366
|
+
* at electron-builder time
|
|
390
367
|
*
|
|
391
368
|
* Everything else (`appId`, `productName`, `mac`, `win`, `linux`,
|
|
392
369
|
* `publish`, `directories.output`, `directories.buildResources`, `asar`,
|
|
@@ -399,7 +376,7 @@ function mergeElectronBuilderConfig(userConfig, overlay) {
|
|
|
399
376
|
app: overlay.appDir,
|
|
400
377
|
output: overlay.output
|
|
401
378
|
};
|
|
402
|
-
merged.files = overlay.
|
|
379
|
+
merged.files = overlay.bundleFiles;
|
|
403
380
|
merged.extraResources = [...Array.isArray(userConfig.extraResources) ? userConfig.extraResources : [], overlay.extraResource];
|
|
404
381
|
if (userConfig.npmRebuild !== false) merged.npmRebuild = false;
|
|
405
382
|
if (userConfig.asar === void 0) merged.asar = false;
|
|
@@ -413,40 +390,28 @@ async function runBuildElectron(argv) {
|
|
|
413
390
|
const projectDir = resolveProjectDir();
|
|
414
391
|
const flags = parseFlags(argv);
|
|
415
392
|
const config = await loadBuildConfig(flags.config ? path.resolve(projectDir, flags.config) : findBuildConfig(projectDir));
|
|
416
|
-
const
|
|
417
|
-
|
|
393
|
+
const mirrorTarget = config.mirror?.target;
|
|
394
|
+
if (!mirrorTarget) throw new Error("zen build:electron: `mirror.target` is required in zenbu.build.ts. Set mirror: { target: \"<owner>/<repo>\", branch: \"main\" } and run `zen publish:source init` before building.");
|
|
395
|
+
const mirrorBranch = config.mirror?.branch ?? "main";
|
|
396
|
+
const mirrorUrl = expandMirrorUrl(mirrorTarget);
|
|
418
397
|
const projectPkg = readJson(path.join(projectDir, "package.json"));
|
|
419
398
|
const appName = projectPkg.name ?? path.basename(projectDir);
|
|
420
399
|
const appVersion = projectPkg.version ?? "0.0.1";
|
|
421
400
|
const bundleDir = await fsp.mkdtemp(path.join(os.tmpdir(), `zenbu-electron-${appName}-`));
|
|
422
|
-
const stagedSeed = path.join(bundleDir, "seed");
|
|
423
401
|
const toolchainDir = path.join(bundleDir, "toolchain");
|
|
424
402
|
const launcherOut = path.join(bundleDir, "launcher.mjs");
|
|
425
403
|
const bundlePkgOut = path.join(bundleDir, "package.json");
|
|
426
404
|
const appConfigOut = path.join(bundleDir, "app-config.json");
|
|
427
405
|
const mergedConfigPath = path.join(bundleDir, "electron-builder.merged.json");
|
|
428
|
-
const
|
|
429
|
-
const mirrorBranch = config.mirror?.branch ?? "main";
|
|
430
|
-
const mirrorUrl = mirrorTarget ? expandMirrorUrl(mirrorTarget) : null;
|
|
406
|
+
const sourceSha = currentSourceSha(projectDir);
|
|
431
407
|
console.log(`\n zen build:electron`);
|
|
432
408
|
console.log(` name: ${appName}`);
|
|
433
409
|
console.log(` version: ${appVersion}`);
|
|
434
|
-
console.log(` source: ${
|
|
435
|
-
console.log(` mirror: ${mirrorTarget
|
|
410
|
+
console.log(` source: ${sourceSha === "uncommitted" ? "uncommitted" : sourceSha.slice(0, 7)}`);
|
|
411
|
+
console.log(` mirror: ${mirrorTarget} (${mirrorBranch})`);
|
|
436
412
|
console.log(` bundle: ${bundleDir}`);
|
|
437
413
|
console.log(" → staging launcher.mjs");
|
|
438
414
|
await copyFile(resolveLauncher(projectDir), launcherOut);
|
|
439
|
-
console.log(" → staging seed/");
|
|
440
|
-
await fsp.cp(seedDir, stagedSeed, {
|
|
441
|
-
recursive: true,
|
|
442
|
-
filter: (src) => path.basename(src) !== ".sha"
|
|
443
|
-
});
|
|
444
|
-
if (mirrorUrl) await initSeedRepo({
|
|
445
|
-
dir: stagedSeed,
|
|
446
|
-
mirrorUrl,
|
|
447
|
-
branch: mirrorBranch,
|
|
448
|
-
sourceSha: meta.sourceSha === "uncommitted" ? "0000000000000000000000000000000000000000" : meta.sourceSha
|
|
449
|
-
});
|
|
450
415
|
console.log(" → provisioning bundled toolchain (bun + pnpm)");
|
|
451
416
|
await provisionToolchain(toolchainDir);
|
|
452
417
|
console.log(" → writing bundle package.json + app-config.json");
|
|
@@ -456,11 +421,11 @@ async function runBuildElectron(argv) {
|
|
|
456
421
|
version: appVersion,
|
|
457
422
|
main: "launcher.mjs",
|
|
458
423
|
type: "module",
|
|
459
|
-
zenbu: { host }
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
424
|
+
zenbu: { host },
|
|
425
|
+
repository: {
|
|
426
|
+
type: "git",
|
|
427
|
+
url: mirrorUrl
|
|
428
|
+
}
|
|
464
429
|
};
|
|
465
430
|
await fsp.writeFile(bundlePkgOut, JSON.stringify(bundlePkg, null, 2) + "\n");
|
|
466
431
|
const appConfig = {
|
|
@@ -477,11 +442,10 @@ async function runBuildElectron(argv) {
|
|
|
477
442
|
const merged = mergeElectronBuilderConfig(userConfig, {
|
|
478
443
|
appDir: bundleDir,
|
|
479
444
|
output: resolvedOutput,
|
|
480
|
-
|
|
445
|
+
bundleFiles: [
|
|
481
446
|
"package.json",
|
|
482
447
|
"app-config.json",
|
|
483
448
|
"launcher.mjs",
|
|
484
|
-
"seed/**/*",
|
|
485
449
|
"!node_modules",
|
|
486
450
|
"!**/node_modules",
|
|
487
451
|
"!**/node_modules/**"
|
|
@@ -495,7 +459,7 @@ async function runBuildElectron(argv) {
|
|
|
495
459
|
console.log(" → injected into electron-builder config:");
|
|
496
460
|
console.log(` directories.app = ${bundleDir}`);
|
|
497
461
|
console.log(` directories.output = ${resolvedOutput}`);
|
|
498
|
-
console.log(` files = [
|
|
462
|
+
console.log(` files = [launcher + app-config + bundle pkg]`);
|
|
499
463
|
console.log(` extraResources += { from: <bundle>/toolchain, to: toolchain }`);
|
|
500
464
|
console.log(` asar = ${merged.asar !== void 0 ? merged.asar : "(unset)"}`);
|
|
501
465
|
console.log(` npmRebuild = false`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as loadBuildConfig, t as findBuildConfig } from "./load-build-config-DozuRhAN.mjs";
|
|
2
|
+
import { t as hashDir } from "./mirror-sync-BN59kMCG.mjs";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import fsp from "node:fs/promises";
|
package/dist/cli/bin.mjs
CHANGED
|
@@ -44,37 +44,37 @@ async function main() {
|
|
|
44
44
|
const rest = argv.slice(1);
|
|
45
45
|
switch (first) {
|
|
46
46
|
case "dev": {
|
|
47
|
-
const { runDev } = await import("../dev-
|
|
47
|
+
const { runDev } = await import("../dev-BU_llQh1.mjs");
|
|
48
48
|
await runDev(rest);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
case "build:source": {
|
|
52
|
-
const { runBuildSource } = await import("../build-source-
|
|
52
|
+
const { runBuildSource } = await import("../build-source-CnTfQBGK.mjs");
|
|
53
53
|
await runBuildSource(rest);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
case "build:electron": {
|
|
57
|
-
const { runBuildElectron } = await import("../build-electron-
|
|
57
|
+
const { runBuildElectron } = await import("../build-electron-BzHa_hRi.mjs");
|
|
58
58
|
await runBuildElectron(rest);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
case "publish:source": {
|
|
62
|
-
const { runPublishSource } = await import("../publish-source-
|
|
62
|
+
const { runPublishSource } = await import("../publish-source-BJdpDAFH.mjs");
|
|
63
63
|
await runPublishSource(rest);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
case "link": {
|
|
67
|
-
const { runLink } = await import("../link-
|
|
67
|
+
const { runLink } = await import("../link-VOoGs-pY.mjs");
|
|
68
68
|
await runLink(rest);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
case "monorepo": {
|
|
72
|
-
const { runMonorepo } = await import("../monorepo-
|
|
72
|
+
const { runMonorepo } = await import("../monorepo-CQeQBIpa.mjs");
|
|
73
73
|
await runMonorepo(rest);
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
case "db": {
|
|
77
|
-
const { runDb } = await import("../db-
|
|
77
|
+
const { runDb } = await import("../db-BXadETOb.mjs");
|
|
78
78
|
await runDb(rest);
|
|
79
79
|
return;
|
|
80
80
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as bootstrapEnv } from "./env-bootstrap-rj7I-59x.mjs";
|
|
2
|
-
import { t as setupGate } from "./setup-gate-
|
|
2
|
+
import { t as setupGate } from "./setup-gate-BcoqWu8S.mjs";
|
|
3
3
|
import { a as serviceWithDeps, i as runtime, n as ServiceRuntime, r as optional, t as Service } from "./runtime-DUFKDIe4.mjs";
|
|
4
4
|
import { t as schema } from "./schema-dGK6qkfR.mjs";
|
|
5
5
|
export { Service, ServiceRuntime, bootstrapEnv, schema as coreSchema, optional, runtime, serviceWithDeps, setupGate };
|