@pleri/olam-cli 0.1.14 → 0.1.21

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.
Files changed (37) hide show
  1. package/dist/__tests__/auth-upgrade.test.js +236 -1
  2. package/dist/__tests__/auth-upgrade.test.js.map +1 -1
  3. package/dist/__tests__/install-root.test.d.ts +2 -0
  4. package/dist/__tests__/install-root.test.d.ts.map +1 -0
  5. package/dist/__tests__/install-root.test.js +119 -0
  6. package/dist/__tests__/install-root.test.js.map +1 -0
  7. package/dist/__tests__/upgrade.test.js +292 -2
  8. package/dist/__tests__/upgrade.test.js.map +1 -1
  9. package/dist/commands/__tests__/bootstrap.test.d.ts +2 -0
  10. package/dist/commands/__tests__/bootstrap.test.d.ts.map +1 -0
  11. package/dist/commands/__tests__/bootstrap.test.js +288 -0
  12. package/dist/commands/__tests__/bootstrap.test.js.map +1 -0
  13. package/dist/commands/__tests__/upgrade.rollback.test.js +1 -1
  14. package/dist/commands/__tests__/upgrade.swap.test.js +1 -1
  15. package/dist/commands/auth-upgrade.d.ts +41 -0
  16. package/dist/commands/auth-upgrade.d.ts.map +1 -1
  17. package/dist/commands/auth-upgrade.js +158 -6
  18. package/dist/commands/auth-upgrade.js.map +1 -1
  19. package/dist/commands/bootstrap.d.ts +95 -0
  20. package/dist/commands/bootstrap.d.ts.map +1 -0
  21. package/dist/commands/bootstrap.js +329 -0
  22. package/dist/commands/bootstrap.js.map +1 -0
  23. package/dist/commands/create.d.ts.map +1 -1
  24. package/dist/commands/create.js +19 -1
  25. package/dist/commands/create.js.map +1 -1
  26. package/dist/commands/upgrade.d.ts +76 -1
  27. package/dist/commands/upgrade.d.ts.map +1 -1
  28. package/dist/commands/upgrade.js +215 -8
  29. package/dist/commands/upgrade.js.map +1 -1
  30. package/dist/image-digests.json +8 -0
  31. package/dist/index.js +951 -201
  32. package/dist/index.js.map +1 -1
  33. package/dist/install-root.d.ts +74 -0
  34. package/dist/install-root.d.ts.map +1 -0
  35. package/dist/install-root.js +98 -0
  36. package/dist/install-root.js.map +1 -0
  37. package/package.json +1 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CA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AAO,CAAC,CAAC;AACxB,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC1B,eAAe,CAAC,OAAO,CAAC,CAAC;AACzB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,eAAe,CAAC,OAAO,CAAC,CAAC;AACzB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,wEAAwE;AACxE,mBAAmB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC/D,UAAU,CAAC,OAAO,CAAC,CAAC;AACpB,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3B,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,eAAe,CAAC,OAAO,CAAC,CAAC;AACzB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,UAAU,CAAC,OAAO,CAAC,CAAC;AACpB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,eAAe,CAAC,OAAO,CAAC,CAAC;AACzB,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAE3B,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Phase B (olam-fresh-install-self-bootstrap) — B6.
3
+ *
4
+ * `installRoot()` + `isDevMode()` — the seam between an installed
5
+ * @pleri/olam-cli and a monorepo clone. Three CLI commands need to
6
+ * shell out to `packages/adapters/src/docker/build-*.sh` (legacy
7
+ * source-build paths from before Phase B's image registry):
8
+ *
9
+ * - olam auth upgrade --from-source
10
+ * - olam upgrade --from-source
11
+ * - olam create --rebuild-base
12
+ *
13
+ * From an installed CLI, those scripts don't exist (the published
14
+ * tarball ships dist/ + plugin/ + host-cp/ — not the build scripts).
15
+ * From a monorepo clone, they do.
16
+ *
17
+ * Decision #1 (Phase B) carries-forward Decision #1 (Phase C revision):
18
+ * dev mode is a 2-condition opt-in:
19
+ * 1. OLAM_DEV=1 in the environment
20
+ * 2. A `packages/` sibling exists at the installRoot
21
+ *
22
+ * Both must be true. The OLAM_DEV flag prevents a stray `packages/`
23
+ * directory adjacent to a global npm install from accidentally
24
+ * activating source-build paths (still imperfect — see S10's deferred
25
+ * 4-condition opt-in for full path-traversal hardening — but adequate
26
+ * for the local-dev / dogfood audience the epic targets).
27
+ *
28
+ * S10 simplified the 4-condition opt-in (uid match + sentinel file)
29
+ * to 2-condition per the user's "perf + leak/logic over security
30
+ * hardening" reframe in pass 3.
31
+ */
32
+ /**
33
+ * Returns the absolute path to the package's install root.
34
+ *
35
+ * - Locally (from src/): /<repo>/packages/cli
36
+ * - Globally installed: /<global-prefix>/lib/node_modules/@pleri/olam-cli
37
+ * - From dist/index.js: /<global-prefix>/lib/node_modules/@pleri/olam-cli
38
+ *
39
+ * Implementation: this file lives at <pkg>/src/install-root.ts (dev)
40
+ * or <pkg>/dist/install-root.js (when bundled). Walking up one directory
41
+ * from this file's location lands at <pkg> in both cases — the
42
+ * `import.meta.url`-resolved dirname. The fileURLToPath conversion
43
+ * handles `file:` URLs cleanly across platforms (Windows-forward-slash
44
+ * tolerance comes for free from path.dirname).
45
+ */
46
+ export declare function installRoot(metaUrl?: string): string;
47
+ /**
48
+ * 2-condition dev-mode detection.
49
+ *
50
+ * @param env - Process env. Defaults to `process.env`. Injectable for tests.
51
+ * @param installRootDir - Where to look for the `packages/` sibling. Defaults
52
+ * to `installRoot()`. Injectable for tests.
53
+ */
54
+ export declare function isDevMode(env?: NodeJS.ProcessEnv, installRootDir?: string): boolean;
55
+ /**
56
+ * Resolve the path to a build script under packages/adapters/src/docker/.
57
+ * In dev mode → returns the absolute path to the source script.
58
+ * In install mode → throws `MissingBuildScriptError` with a named remedy.
59
+ *
60
+ * The exception, not exit-code path, lets call sites decide whether to
61
+ * recover gracefully (e.g. fall back to a pull-by-digest path) or just
62
+ * surface to stderr + exit. Phase C's C6 will use the recover-gracefully
63
+ * path; today's three call sites just exit.
64
+ */
65
+ export declare class MissingBuildScriptError extends Error {
66
+ constructor(scriptRelPath: string);
67
+ }
68
+ export interface ResolveBuildScriptInput {
69
+ readonly scriptRelPath: string;
70
+ readonly env?: NodeJS.ProcessEnv;
71
+ readonly installRootDir?: string;
72
+ }
73
+ export declare function resolveBuildScript(input: ResolveBuildScriptInput): string;
74
+ //# sourceMappingURL=install-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-root.d.ts","sourceRoot":"","sources":["../src/install-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,MAAwB,GAAG,MAAM,CAIrE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,cAAc,GAAE,MAAsB,GACrC,OAAO,CAMT;AAED;;;;;;;;;GASG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,aAAa,EAAE,MAAM;CAWlC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAOzE"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Phase B (olam-fresh-install-self-bootstrap) — B6.
3
+ *
4
+ * `installRoot()` + `isDevMode()` — the seam between an installed
5
+ * @pleri/olam-cli and a monorepo clone. Three CLI commands need to
6
+ * shell out to `packages/adapters/src/docker/build-*.sh` (legacy
7
+ * source-build paths from before Phase B's image registry):
8
+ *
9
+ * - olam auth upgrade --from-source
10
+ * - olam upgrade --from-source
11
+ * - olam create --rebuild-base
12
+ *
13
+ * From an installed CLI, those scripts don't exist (the published
14
+ * tarball ships dist/ + plugin/ + host-cp/ — not the build scripts).
15
+ * From a monorepo clone, they do.
16
+ *
17
+ * Decision #1 (Phase B) carries-forward Decision #1 (Phase C revision):
18
+ * dev mode is a 2-condition opt-in:
19
+ * 1. OLAM_DEV=1 in the environment
20
+ * 2. A `packages/` sibling exists at the installRoot
21
+ *
22
+ * Both must be true. The OLAM_DEV flag prevents a stray `packages/`
23
+ * directory adjacent to a global npm install from accidentally
24
+ * activating source-build paths (still imperfect — see S10's deferred
25
+ * 4-condition opt-in for full path-traversal hardening — but adequate
26
+ * for the local-dev / dogfood audience the epic targets).
27
+ *
28
+ * S10 simplified the 4-condition opt-in (uid match + sentinel file)
29
+ * to 2-condition per the user's "perf + leak/logic over security
30
+ * hardening" reframe in pass 3.
31
+ */
32
+ import { existsSync } from 'node:fs';
33
+ import { dirname, join, resolve } from 'node:path';
34
+ import { fileURLToPath } from 'node:url';
35
+ /**
36
+ * Returns the absolute path to the package's install root.
37
+ *
38
+ * - Locally (from src/): /<repo>/packages/cli
39
+ * - Globally installed: /<global-prefix>/lib/node_modules/@pleri/olam-cli
40
+ * - From dist/index.js: /<global-prefix>/lib/node_modules/@pleri/olam-cli
41
+ *
42
+ * Implementation: this file lives at <pkg>/src/install-root.ts (dev)
43
+ * or <pkg>/dist/install-root.js (when bundled). Walking up one directory
44
+ * from this file's location lands at <pkg> in both cases — the
45
+ * `import.meta.url`-resolved dirname. The fileURLToPath conversion
46
+ * handles `file:` URLs cleanly across platforms (Windows-forward-slash
47
+ * tolerance comes for free from path.dirname).
48
+ */
49
+ export function installRoot(metaUrl = import.meta.url) {
50
+ const here = fileURLToPath(metaUrl);
51
+ // dist/install-root.js OR src/install-root.ts → <pkg>
52
+ return resolve(dirname(here), '..');
53
+ }
54
+ /**
55
+ * 2-condition dev-mode detection.
56
+ *
57
+ * @param env - Process env. Defaults to `process.env`. Injectable for tests.
58
+ * @param installRootDir - Where to look for the `packages/` sibling. Defaults
59
+ * to `installRoot()`. Injectable for tests.
60
+ */
61
+ export function isDevMode(env = process.env, installRootDir = installRoot()) {
62
+ if (env.OLAM_DEV !== '1')
63
+ return false;
64
+ // The package install root sits at <repo>/packages/cli when from a clone.
65
+ // Walking up two levels lands at <repo>; checking <repo>/packages/.
66
+ const repoRoot = resolve(installRootDir, '..', '..');
67
+ return existsSync(join(repoRoot, 'packages')) && existsSync(join(repoRoot, 'package.json'));
68
+ }
69
+ /**
70
+ * Resolve the path to a build script under packages/adapters/src/docker/.
71
+ * In dev mode → returns the absolute path to the source script.
72
+ * In install mode → throws `MissingBuildScriptError` with a named remedy.
73
+ *
74
+ * The exception, not exit-code path, lets call sites decide whether to
75
+ * recover gracefully (e.g. fall back to a pull-by-digest path) or just
76
+ * surface to stderr + exit. Phase C's C6 will use the recover-gracefully
77
+ * path; today's three call sites just exit.
78
+ */
79
+ export class MissingBuildScriptError extends Error {
80
+ constructor(scriptRelPath) {
81
+ super(`Build script ${scriptRelPath} is not available in this CLI install.\n` +
82
+ ` Source-build paths require a monorepo clone:\n` +
83
+ ` git clone https://github.com/pleri/olam && cd olam\n` +
84
+ ` OLAM_DEV=1 olam <command> --from-source\n` +
85
+ ` For published-image upgrades (Phase B+), drop the --from-source flag\n` +
86
+ ` and the CLI will pull pre-built images from ghcr.io/pleri/* by digest.`);
87
+ this.name = 'MissingBuildScriptError';
88
+ }
89
+ }
90
+ export function resolveBuildScript(input) {
91
+ const { scriptRelPath, env = process.env, installRootDir = installRoot() } = input;
92
+ if (!isDevMode(env, installRootDir)) {
93
+ throw new MissingBuildScriptError(scriptRelPath);
94
+ }
95
+ const repoRoot = resolve(installRootDir, '..', '..');
96
+ return join(repoRoot, scriptRelPath);
97
+ }
98
+ //# sourceMappingURL=install-root.js.map
@@ -0,0 +1 @@
1
+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