@mx-space/cli 0.6.2 → 0.6.4

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/bin/mxs.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as run } from "../mxs-BxXhmqqF.mjs";
2
+ import { t as run } from "../mxs-BGjeCBcT.mjs";
3
3
  export { run };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-BxXhmqqF.mjs";
1
+ import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-BGjeCBcT.mjs";
2
2
  export { codeForTag, defaultGlobalFlags, defaultMessageFor, exitCodeForError, exitCodeForTag, parseGlobalFlags, run, tagToCode, toErrorEnvelope };
@@ -31768,6 +31768,10 @@ registerCommandHelp({
31768
31768
  {
31769
31769
  flag: "--print",
31770
31770
  description: "emit HTML to stdout instead of opening a browser"
31771
+ },
31772
+ {
31773
+ flag: "--open",
31774
+ description: "explicitly open the rendered HTML in a browser (default behavior)"
31771
31775
  }
31772
31776
  ]
31773
31777
  });
@@ -31780,6 +31784,7 @@ const variantOpt = choice("variant", [
31780
31784
  ]).pipe(optional$2);
31781
31785
  const saveOpt = text$1("save").pipe(optional$2);
31782
31786
  const printOpt = boolean("print").pipe(optional$2);
31787
+ const openOpt = boolean("open").pipe(optional$2);
31783
31788
  const requireFrom$3 = createRequire(import.meta.url);
31784
31789
  const resolveLitexmlBin = () => {
31785
31790
  try {
@@ -31857,11 +31862,17 @@ const previewCmd = make$13("preview", {
31857
31862
  theme: themeOpt,
31858
31863
  variant: variantOpt,
31859
31864
  save: saveOpt,
31860
- print: printOpt
31861
- }, ({ file, theme, variant, save, print }) => gen(function* () {
31865
+ print: printOpt,
31866
+ open: openOpt
31867
+ }, ({ file, theme, variant, save, print, open: openFlag }) => gen(function* () {
31862
31868
  const editor = yield* Editor;
31863
31869
  const renderer = yield* Renderer;
31864
31870
  const filePath = getOrUndefined(file);
31871
+ const stdinIsTty = Boolean(process.stdin.isTTY);
31872
+ if ((filePath === void 0 || filePath === "-" || filePath === "") && stdinIsTty) return yield* fail$2(new ValidationXml({
31873
+ message: "mxs preview requires a file path or piped LiteXML on stdin",
31874
+ hint: "pass `mxs preview <file>` or pipe content: `cat post.xml | mxs preview -`"
31875
+ }));
31865
31876
  const raw = yield* editor.readFileOrStdin(filePath);
31866
31877
  let body;
31867
31878
  let detectedVariant = "article";
@@ -31876,6 +31887,9 @@ const previewCmd = make$13("preview", {
31876
31887
  const resolvedTheme = getOrUndefined(theme);
31877
31888
  const savePath = getOrUndefined(save);
31878
31889
  const printMode = getOrElse(print, () => false);
31890
+ const explicitOpen = getOrElse(openFlag, () => false);
31891
+ if (printMode && savePath) return yield* fail$2(new ValidationXml({ message: "--print and --save are mutually exclusive" }));
31892
+ if (explicitOpen && (printMode || savePath)) return yield* fail$2(new ValidationXml({ message: "--open conflicts with --print / --save" }));
31879
31893
  const args = [
31880
31894
  "--format",
31881
31895
  "html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/cli",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Command line interface for mx-space (mx-core) — auth, content, configuration",
5
5
  "keywords": [
6
6
  "mx-space",
@@ -54,7 +54,7 @@
54
54
  "@effect/platform-node": "0.106.0",
55
55
  "@haklex/rich-headless": "0.13.0",
56
56
  "@haklex/rich-litexml": "0.15.2",
57
- "@haklex/rich-litexml-cli": "0.15.2",
57
+ "@haklex/rich-litexml-cli": "0.15.3",
58
58
  "@lexical/headless": "^0.44.0",
59
59
  "better-auth": "^1.6.9",
60
60
  "effect": "3.21.2",
@@ -12,9 +12,12 @@ order: 39
12
12
  | Command | Behavior |
13
13
  | ---------------------------------------- | --------------------------------------------------------------------------- |
14
14
  | `mxs preview <file>` | Render the file and open the preview in a browser. |
15
+ | `mxs preview <file> --open` | Same as above, but explicit. Useful in scripts. |
15
16
  | `mxs preview -` | Read LiteXML or envelope from stdin and open the preview. |
16
- | `mxs preview <file> --print` | Emit HTML to stdout instead of opening a browser. |
17
- | `mxs preview <file> --save <out.html>` | Write HTML to `<out.html>` instead of opening a browser. |
17
+ | `mxs preview --print <file>` | Emit HTML to stdout instead of opening a browser. |
18
+ | `mxs preview --save <out.html> <file>` | Write HTML to `<out.html>` instead of opening a browser. |
19
+
20
+ Flags must precede the positional `<file>` argument. `mxs preview <file> --print` is rejected by `@effect/cli` ("unknown argument") — write `mxs preview --print <file>` or `cat file | mxs preview --print -`.
18
21
 
19
22
  ## Flags
20
23
 
@@ -22,8 +25,9 @@ order: 39
22
25
  | ------------------------------------------ | ------------------------------------------------------------------------------------------------ |
23
26
  | `--theme <light\|dark>` | HTML theme. Default `light`. |
24
27
  | `--variant <article\|note\|comment>` | HTML variant. Auto-detected from the envelope root (`<mxpost>` → `article`, `<mxnote>` → `note`). |
25
- | `--save <path>` | Write HTML to a file instead of opening the browser. Mutually exclusive with `--print`. |
26
- | `--print` | Emit HTML to stdout. Mutually exclusive with `--save`. |
28
+ | `--save <path>` | Write HTML to a file instead of opening the browser. Mutually exclusive with `--print` / `--open`. |
29
+ | `--print` | Emit HTML to stdout. Mutually exclusive with `--save` / `--open`. |
30
+ | `--open` | Explicitly open the rendered HTML in a browser (default behavior; mutually exclusive with `--print` / `--save`). |
27
31
 
28
32
  ## Behavior notes
29
33