compivia 0.0.1 → 0.0.1128

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,40 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: FSL-1.1-ALv2
3
+
4
+ // Публичный bin пакета `compivia` (#403): тонкий вход. COMPIVIA_NO_LOADER=1 —
5
+ // прямой режим (#313): импорт собственного dist/compivia.mjs (дев-прогоны,
6
+ // юнит-тесты, e2e движка, аварийный проход). Иначе — загрузчик: dist/loader.mjs
7
+ // ставит/делегирует установку в COMPIVIA_HOME (§4.3 спеки #403).
8
+ import { existsSync } from "node:fs";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ const cliUrl = new URL("../dist/compivia.mjs", import.meta.url);
12
+ const loaderUrl = new URL("../dist/loader.mjs", import.meta.url);
13
+ const manifestUrl = new URL("../dist/files.json", import.meta.url);
14
+
15
+ if (process.env.COMPIVIA_NO_LOADER === "1") {
16
+ if (!existsSync(fileURLToPath(cliUrl))) {
17
+ process.stderr.write("compivia: dist/compivia.mjs not found — run pnpm build\n");
18
+ process.exit(1);
19
+ }
20
+ try {
21
+ await import(cliUrl.href);
22
+ } catch (error) {
23
+ process.stderr.write(`compivia: failed to load dist/compivia.mjs: ${String(error)}\n`);
24
+ if (error instanceof Error && error.stack !== undefined) process.stderr.write(`${error.stack}\n`);
25
+ process.exit(1);
26
+ }
27
+ } else {
28
+ if (!existsSync(fileURLToPath(loaderUrl)) || !existsSync(fileURLToPath(manifestUrl))) {
29
+ process.stderr.write("compivia: dist/loader.mjs or dist/files.json not found — run pnpm build\n");
30
+ process.exit(1);
31
+ }
32
+ try {
33
+ const { runLoader } = await import(loaderUrl.href);
34
+ await runLoader();
35
+ } catch (error) {
36
+ process.stderr.write(`compivia: failed to load dist/loader.mjs: ${String(error)}\n`);
37
+ if (error instanceof Error && error.stack !== undefined) process.stderr.write(`${error.stack}\n`);
38
+ process.exit(1);
39
+ }
40
+ }