@panomc/theme-core 1.0.0-dev.50 → 1.0.0-dev.51

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 (2) hide show
  1. package/bin/ui.js +41 -14
  2. package/package.json +1 -1
package/bin/ui.js CHANGED
@@ -4,29 +4,56 @@
4
4
  * Wraps @clack/prompts + picocolors so every command speaks the same visual
5
5
  * language (styled intro/outro, spinners, prompts) and shares the TTY/CI
6
6
  * detection that keeps sync/check/package safe to run non-interactively.
7
+ *
8
+ * Both packages are OPTIONAL at runtime: a consumer whose installer skipped
9
+ * the engine's transitive dependencies (bun does this for file:-linked
10
+ * submodule setups with a stale lockfile) must still be able to run
11
+ * sync/check/package — they just get plain, unstyled output. Only the
12
+ * interactive wizard genuinely needs @clack and says so when it's missing.
7
13
  */
8
14
  import { readFileSync } from "node:fs";
9
15
  import { join, dirname } from "node:path";
10
16
  import { fileURLToPath } from "node:url";
11
- import * as clack from "@clack/prompts";
12
- import pc from "picocolors";
17
+
18
+ let clack;
19
+ try {
20
+ // computed specifier: keeps bun from resolving the import eagerly at load
21
+ clack = await import("@clack/" + "prompts");
22
+ } catch {
23
+ const line = (msg = "") => console.log(msg);
24
+ const missing = () => {
25
+ console.error(
26
+ "the interactive wizard needs @clack/prompts (run bun install in the theme, or pass arguments instead)",
27
+ );
28
+ process.exit(1);
29
+ };
30
+ clack = {
31
+ intro: line,
32
+ outro: line,
33
+ note: (msg, title) => line(title ? `\n${title}\n${msg}` : msg),
34
+ log: { info: line, warn: line, error: line, success: line, step: line, message: line },
35
+ cancel: line,
36
+ isCancel: () => false,
37
+ spinner: () => ({ start: line, stop: line, message: line }),
38
+ text: missing,
39
+ confirm: missing,
40
+ select: missing,
41
+ };
42
+ }
43
+
44
+ let pc;
45
+ try {
46
+ pc = (await import("pico" + "colors")).default;
47
+ } catch {
48
+ pc = new Proxy({}, { get: () => (s) => String(s) });
49
+ }
13
50
 
14
51
  export { clack, pc };
15
52
 
16
53
  // Re-export the clack primitives the commands reach for, so callers import
17
54
  // from one place instead of poking at the namespace.
18
- export const {
19
- intro,
20
- outro,
21
- text,
22
- confirm,
23
- select,
24
- spinner,
25
- cancel,
26
- isCancel,
27
- note,
28
- log,
29
- } = clack;
55
+ export const { intro, outro, text, confirm, select, spinner, cancel, isCancel, note, log } =
56
+ clack;
30
57
 
31
58
  const binDir = dirname(fileURLToPath(import.meta.url));
32
59
  export const corePkg = JSON.parse(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panomc/theme-core",
3
- "version": "1.0.0-dev.50",
3
+ "version": "1.0.0-dev.51",
4
4
  "description": "The Pano theme engine: hooks factories, plugin engine, headless page controllers, default views and the theme CLI. Themes depend on this package instead of forking vanilla-theme.",
5
5
  "author": "PanoMC",
6
6
  "license": "MIT",