sverka 0.2.32 → 0.2.34

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.
@@ -0,0 +1,58 @@
1
+ import { CliError, ExitCode } from "./index.mjs";
2
+ //#region src/commands/hub.ts
3
+ /** Node's "module not found" codes — only these mean "not installed". */
4
+ const MODULE_NOT_FOUND = {
5
+ MODULE_NOT_FOUND: true,
6
+ ERR_MODULE_NOT_FOUND: true
7
+ };
8
+ /**
9
+ * Load the hub package on demand.
10
+ *
11
+ * A static import cannot work here: `@sverka/hub` is an optional
12
+ * dependency (its name is not on npm yet), so in a plain `npm i sverka`
13
+ * the module is absent and a static import would turn a missing feature
14
+ * into a startup crash.
15
+ *
16
+ * Only a "module not found" failure means "not installed" — an error
17
+ * raised *inside* the package is rethrown unchanged, so a broken install
18
+ * is not reported as a missing one.
19
+ */
20
+ async function loadHub(load = () => import("@sverka/hub")) {
21
+ try {
22
+ return await load();
23
+ } catch (e) {
24
+ const code = typeof e === "object" && e !== null && "code" in e ? e.code : void 0;
25
+ if (typeof code !== "string" || MODULE_NOT_FOUND[code] !== true) throw e;
26
+ throw new CliError("sverka hub: the @sverka/hub package is not installed — npm i @sverka/hub", "PACKAGE_ERROR", ExitCode.RuntimeError, e);
27
+ }
28
+ }
29
+ async function hubCommand(args, global, output, _start) {
30
+ if (args.action !== "serve") throw new CliError(`unknown hub action "${args.action ?? ""}" (supported: serve)`, "UNKNOWN_COMMAND", ExitCode.UsageError);
31
+ if (args.port !== void 0 && (!Number.isInteger(args.port) || args.port < 0 || args.port > 65535)) throw new CliError("--port must be an integer in [0, 65535]", "INVALID_FLAG", ExitCode.UsageError);
32
+ const dataDir = args.data ?? `${global.root}/.sverka-hub`;
33
+ const { startHubServer } = await loadHub();
34
+ const server = await startHubServer({
35
+ dataDir,
36
+ ...args.port !== void 0 ? { port: args.port } : {},
37
+ ...args.host !== void 0 ? { host: args.host } : {}
38
+ });
39
+ output.writeLine(`sverka hub listening on ${server.url}`);
40
+ output.writeLine(` data: ${server.dataDir}`);
41
+ output.writeLine(` dashboard: ${server.url}/`);
42
+ output.writeLine(" (Ctrl+C to stop)");
43
+ await new Promise((done) => {
44
+ const stop = () => {
45
+ process.removeListener("SIGINT", stop);
46
+ process.removeListener("SIGTERM", stop);
47
+ done();
48
+ };
49
+ process.on("SIGINT", stop);
50
+ process.on("SIGTERM", stop);
51
+ });
52
+ await server.close();
53
+ return ExitCode.Success;
54
+ }
55
+ //#endregion
56
+ export { hubCommand };
57
+
58
+ //# sourceMappingURL=hub-DaJpQXUp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub-DaJpQXUp.mjs","names":[],"sources":["../src/commands/hub.ts"],"sourcesContent":["// hub command — run the self-hosted remote run hub (Spec 55).\n// `sverka hub serve --port 7357 --data ./.sverka-hub`\n\nimport type { GlobalFlags, OutputWriter } from \"../types.js\";\nimport { CliError, ExitCode } from \"../types.js\";\n// Type-only import — erased at runtime, so it costs no dependency. The\n// runtime import below is the dynamic one.\nimport type * as HubModule from \"@sverka/hub\";\n\nexport interface HubArgs {\n action?: string;\n port?: number;\n data?: string;\n host?: string;\n}\n\n/** Import the hub package — the seam the tests drive. */\nexport type HubLoader = () => Promise<typeof HubModule>;\n\n/** Node's \"module not found\" codes — only these mean \"not installed\". */\nconst MODULE_NOT_FOUND: Record<string, true> = {\n MODULE_NOT_FOUND: true,\n ERR_MODULE_NOT_FOUND: true,\n};\n\n/**\n * Load the hub package on demand.\n *\n * A static import cannot work here: `@sverka/hub` is an optional\n * dependency (its name is not on npm yet), so in a plain `npm i sverka`\n * the module is absent and a static import would turn a missing feature\n * into a startup crash.\n *\n * Only a \"module not found\" failure means \"not installed\" — an error\n * raised *inside* the package is rethrown unchanged, so a broken install\n * is not reported as a missing one.\n */\nexport async function loadHub(\n load: HubLoader = () => import(\"@sverka/hub\"),\n): Promise<typeof HubModule> {\n try {\n return await load();\n } catch (e) {\n const code =\n typeof e === \"object\" && e !== null && \"code\" in e ? e.code : undefined;\n if (typeof code !== \"string\" || MODULE_NOT_FOUND[code] !== true) {\n throw e;\n }\n throw new CliError(\n \"sverka hub: the @sverka/hub package is not installed — npm i @sverka/hub\",\n \"PACKAGE_ERROR\",\n ExitCode.RuntimeError,\n e,\n );\n }\n}\n\nexport async function hubCommand(\n args: HubArgs,\n global: GlobalFlags,\n output: OutputWriter,\n _start: number,\n): Promise<number> {\n if (args.action !== \"serve\") {\n throw new CliError(\n `unknown hub action \"${args.action ?? \"\"}\" (supported: serve)`,\n \"UNKNOWN_COMMAND\",\n ExitCode.UsageError,\n );\n }\n if (\n args.port !== undefined &&\n (!Number.isInteger(args.port) || args.port < 0 || args.port > 65535)\n ) {\n throw new CliError(\n \"--port must be an integer in [0, 65535]\",\n \"INVALID_FLAG\",\n ExitCode.UsageError,\n );\n }\n const dataDir = args.data ?? `${global.root}/.sverka-hub`;\n const { startHubServer } = await loadHub();\n const server = await startHubServer({\n dataDir,\n ...(args.port !== undefined ? { port: args.port } : {}),\n ...(args.host !== undefined ? { host: args.host } : {}),\n });\n output.writeLine(`sverka hub listening on ${server.url}`);\n output.writeLine(` data: ${server.dataDir}`);\n output.writeLine(` dashboard: ${server.url}/`);\n output.writeLine(\" (Ctrl+C to stop)\");\n\n // Serve until interrupted — the process owns the lifecycle.\n await new Promise<void>((done) => {\n const stop = () => {\n process.removeListener(\"SIGINT\", stop);\n process.removeListener(\"SIGTERM\", stop);\n done();\n };\n process.on(\"SIGINT\", stop);\n process.on(\"SIGTERM\", stop);\n });\n await server.close();\n return ExitCode.Success;\n}\n"],"mappings":";;;AAoBA,MAAM,mBAAyC;CAC7C,kBAAkB;CAClB,sBAAsB;AACxB;;;;;;;;;;;;;AAcA,eAAsB,QACpB,aAAwB,OAAO,gBACJ;CAC3B,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,SAAS,GAAG;EACV,MAAM,OACJ,OAAO,MAAM,YAAY,MAAM,QAAQ,UAAU,IAAI,EAAE,OAAO,KAAA;EAChE,IAAI,OAAO,SAAS,YAAY,iBAAiB,UAAU,MACzD,MAAM;EAER,MAAM,IAAI,SACR,4EACA,iBACA,SAAS,cACT,CACF;CACF;AACF;AAEA,eAAsB,WACpB,MACA,QACA,QACA,QACiB;CACjB,IAAI,KAAK,WAAW,SAClB,MAAM,IAAI,SACR,uBAAuB,KAAK,UAAU,GAAG,uBACzC,mBACA,SAAS,UACX;CAEF,IACE,KAAK,SAAS,KAAA,MACb,CAAC,OAAO,UAAU,KAAK,IAAI,KAAK,KAAK,OAAO,KAAK,KAAK,OAAO,QAE9D,MAAM,IAAI,SACR,2CACA,gBACA,SAAS,UACX;CAEF,MAAM,UAAU,KAAK,QAAQ,GAAG,OAAO,KAAK;CAC5C,MAAM,EAAE,mBAAmB,MAAM,QAAQ;CACzC,MAAM,SAAS,MAAM,eAAe;EAClC;EACA,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;EACrD,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACvD,CAAC;CACD,OAAO,UAAU,2BAA2B,OAAO,KAAK;CACxD,OAAO,UAAU,WAAW,OAAO,SAAS;CAC5C,OAAO,UAAU,gBAAgB,OAAO,IAAI,EAAE;CAC9C,OAAO,UAAU,oBAAoB;CAGrC,MAAM,IAAI,SAAe,SAAS;EAChC,MAAM,aAAa;GACjB,QAAQ,eAAe,UAAU,IAAI;GACrC,QAAQ,eAAe,WAAW,IAAI;GACtC,KAAK;EACP;EACA,QAAQ,GAAG,UAAU,IAAI;EACzB,QAAQ,GAAG,WAAW,IAAI;CAC5B,CAAC;CACD,MAAM,OAAO,MAAM;CACnB,OAAO,SAAS;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/main.ts","../src/output.ts"],"mappings":";;iBAGiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;iBAIe;EACf,MAAM;EACN,UAAU;EACV,MAAM;EACN,UAAU;;EAEV,MAAM;;;qBAIK;;;;;;YAOD,mBAAmB,uBAAuB;;YAG1C;;qBAWC,iBAAiB;WACnB,MAAM;WACN,UAAU;WACD;EAEhB,YAAA,iBACA,MAAM,cACN,UAAU,UACV;;;;;UC3Ba;EACf,SAAS;;;;;;;wBAwjBW,KAAK,gBAAgB,OAAO,WAAW;;;;KCnlBjD,aAAa;;;;;;qBAOZ,+BAA+B;;EAM9B,YAAA,KAAK,WAAW,KAAK,WAAW,iBAAe;EAO3D,MAAM;EAKN,UAAU;EAKV,MAAM;EAIN,UAAU;;EAKV,MAAM;;;;;;wBAwDQ,mBACd,QAAQ,aACR,KAAK,WACL,KAAK,YACJ;;;;;wBAYa,iBACd,QAAQ,aACR,MAAM,eACL"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/main.ts","../src/output.ts"],"mappings":";;iBAGiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;iBAIe;EACf,MAAM;EACN,UAAU;EACV,MAAM;EACN,UAAU;;EAEV,MAAM;;;qBAIK;;;;;;YAOD,mBAAmB,uBAAuB;;YAG1C;;qBAWC,iBAAiB;WACnB,MAAM;WACN,UAAU;WACD;EAEhB,YAAA,iBACA,MAAM,cACN,UAAU,UACV;;;;;UC3Ba;EACf,SAAS;;;;;;;wBA6jBW,KAAK,gBAAgB,OAAO,WAAW;;;;KCxlBjD,aAAa;;;;;;qBAOZ,+BAA+B;;EAM9B,YAAA,KAAK,WAAW,KAAK,WAAW,iBAAe;EAO3D,MAAM;EAKN,UAAU;EAKV,MAAM;EAIN,UAAU;;EAKV,MAAM;;;;;;wBAwDQ,mBACd,QAAQ,aACR,KAAK,WACL,KAAK,YACJ;;;;;wBAYa,iBACd,QAAQ,aACR,MAAM,eACL"}
package/dist/index.mjs CHANGED
@@ -17,7 +17,6 @@ import { homedir } from "node:os";
17
17
  import { createRemoteCacheStore, createRemoteCircuit, createRemoteSnapshotStore, createTieredCacheStore } from "@sverka/storage";
18
18
  import { compileGithub, compileGitlab } from "@sverka/compiler";
19
19
  import { z } from "zod";
20
- import { startHubServer } from "@sverka/hub";
21
20
  //#region src/types.ts
22
21
  /** Exit codes used by the CLI. */
23
22
  const ExitCode = {
@@ -2704,33 +2703,6 @@ async function loginCommand(args, _global, output, _start) {
2704
2703
  return ExitCode.Success;
2705
2704
  }
2706
2705
  //#endregion
2707
- //#region src/commands/hub.ts
2708
- async function hubCommand(args, global, output, _start) {
2709
- if (args.action !== "serve") throw new CliError(`unknown hub action "${args.action ?? ""}" (supported: serve)`, "UNKNOWN_COMMAND", ExitCode.UsageError);
2710
- if (args.port !== void 0 && (!Number.isInteger(args.port) || args.port < 0 || args.port > 65535)) throw new CliError("--port must be an integer in [0, 65535]", "INVALID_FLAG", ExitCode.UsageError);
2711
- const dataDir = args.data ?? `${global.root}/.sverka-hub`;
2712
- const server = await startHubServer({
2713
- dataDir,
2714
- ...args.port !== void 0 ? { port: args.port } : {},
2715
- ...args.host !== void 0 ? { host: args.host } : {}
2716
- });
2717
- output.writeLine(`sverka hub listening on ${server.url}`);
2718
- output.writeLine(` data: ${server.dataDir}`);
2719
- output.writeLine(` dashboard: ${server.url}/`);
2720
- output.writeLine(" (Ctrl+C to stop)");
2721
- await new Promise((done) => {
2722
- const stop = () => {
2723
- process.removeListener("SIGINT", stop);
2724
- process.removeListener("SIGTERM", stop);
2725
- done();
2726
- };
2727
- process.on("SIGINT", stop);
2728
- process.on("SIGTERM", stop);
2729
- });
2730
- await server.close();
2731
- return ExitCode.Success;
2732
- }
2733
- //#endregion
2734
2706
  //#region src/commands/runs.ts
2735
2707
  function listLocalRuns(root) {
2736
2708
  const dir = join(root, ".sverka", "runs");
@@ -3134,12 +3106,13 @@ function dispatchLogin(parsed, global, output, start) {
3134
3106
  if (typeof parsed.token === "string") args.token = parsed.token;
3135
3107
  return loginCommand(args, global, output, start);
3136
3108
  }
3137
- function dispatchHub(parsed, global, output, start) {
3109
+ async function dispatchHub(parsed, global, output, start) {
3138
3110
  const args = {};
3139
3111
  if (typeof parsed.action === "string") args.action = parsed.action;
3140
3112
  if (typeof parsed.port === "number") args.port = parsed.port;
3141
3113
  if (typeof parsed.data === "string") args.data = parsed.data;
3142
3114
  if (typeof parsed.host === "string") args.host = parsed.host;
3115
+ const { hubCommand } = await import("./hub-DaJpQXUp.mjs");
3143
3116
  return hubCommand(args, global, output, start);
3144
3117
  }
3145
3118
  function dispatchRuns(parsed, global, output, start) {