@mx-space/cli 0.6.3 → 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
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-
|
|
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 };
|
|
@@ -24,7 +24,7 @@ import * as ChildProcess from "node:child_process";
|
|
|
24
24
|
import childProcess, { execFile, spawn } from "node:child_process";
|
|
25
25
|
import * as readline from "node:readline";
|
|
26
26
|
import E from "node:readline";
|
|
27
|
-
import
|
|
27
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
28
28
|
import "node:tty";
|
|
29
29
|
//#region ../../node_modules/.pnpm/@effect+platform@0.96.1_effect@3.21.2/node_modules/@effect/platform/dist/esm/Error.js
|
|
30
30
|
/**
|
|
@@ -9042,7 +9042,7 @@ function isInsideContainer() {
|
|
|
9042
9042
|
//#endregion
|
|
9043
9043
|
//#region ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
9044
9044
|
const isWsl = () => {
|
|
9045
|
-
if (
|
|
9045
|
+
if (process$1.platform !== "linux") return false;
|
|
9046
9046
|
if (os.release().toLowerCase().includes("microsoft")) {
|
|
9047
9047
|
if (isInsideContainer()) return false;
|
|
9048
9048
|
return true;
|
|
@@ -9053,11 +9053,11 @@ const isWsl = () => {
|
|
|
9053
9053
|
if (fs.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs.existsSync("/run/WSL")) return !isInsideContainer();
|
|
9054
9054
|
return false;
|
|
9055
9055
|
};
|
|
9056
|
-
var is_wsl_default =
|
|
9056
|
+
var is_wsl_default = process$1.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
9057
9057
|
//#endregion
|
|
9058
9058
|
//#region ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
9059
9059
|
const execFile$2 = promisify(childProcess.execFile);
|
|
9060
|
-
const powerShellPath$1 = () => `${
|
|
9060
|
+
const powerShellPath$1 = () => `${process$1.env.SYSTEMROOT || process$1.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
9061
9061
|
const executePowerShell = async (command, options = {}) => {
|
|
9062
9062
|
const { powerShellPath: psPath, ...execFileOptions } = options;
|
|
9063
9063
|
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
@@ -9164,7 +9164,7 @@ function defineLazyProperty(object, propertyName, valueGetter) {
|
|
|
9164
9164
|
//#region ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
9165
9165
|
const execFileAsync$3 = promisify(execFile);
|
|
9166
9166
|
async function defaultBrowserId() {
|
|
9167
|
-
if (
|
|
9167
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
9168
9168
|
const { stdout } = await execFileAsync$3("defaults", [
|
|
9169
9169
|
"read",
|
|
9170
9170
|
"com.apple.LaunchServices/com.apple.launchservices.secure",
|
|
@@ -9178,7 +9178,7 @@ async function defaultBrowserId() {
|
|
|
9178
9178
|
//#region ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
9179
9179
|
const execFileAsync$2 = promisify(execFile);
|
|
9180
9180
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
9181
|
-
if (
|
|
9181
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
9182
9182
|
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
9183
9183
|
const execOptions = {};
|
|
9184
9184
|
if (signal) execOptions.signal = signal;
|
|
@@ -9289,14 +9289,14 @@ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
|
|
|
9289
9289
|
const execFileAsync = promisify(execFile);
|
|
9290
9290
|
const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
9291
9291
|
async function defaultBrowser() {
|
|
9292
|
-
if (
|
|
9292
|
+
if (process$1.platform === "darwin") {
|
|
9293
9293
|
const id = await defaultBrowserId();
|
|
9294
9294
|
return {
|
|
9295
9295
|
name: await bundleName(id),
|
|
9296
9296
|
id
|
|
9297
9297
|
};
|
|
9298
9298
|
}
|
|
9299
|
-
if (
|
|
9299
|
+
if (process$1.platform === "linux") {
|
|
9300
9300
|
const { stdout } = await execFileAsync("xdg-mime", [
|
|
9301
9301
|
"query",
|
|
9302
9302
|
"default",
|
|
@@ -9308,18 +9308,18 @@ async function defaultBrowser() {
|
|
|
9308
9308
|
id
|
|
9309
9309
|
};
|
|
9310
9310
|
}
|
|
9311
|
-
if (
|
|
9311
|
+
if (process$1.platform === "win32") return defaultBrowser$1();
|
|
9312
9312
|
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
9313
9313
|
}
|
|
9314
9314
|
//#endregion
|
|
9315
9315
|
//#region ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
9316
|
-
const isInSsh = Boolean(
|
|
9316
|
+
const isInSsh = Boolean(process$1.env.SSH_CONNECTION || process$1.env.SSH_CLIENT || process$1.env.SSH_TTY);
|
|
9317
9317
|
//#endregion
|
|
9318
9318
|
//#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
9319
9319
|
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
9320
9320
|
const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
9321
9321
|
const localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
9322
|
-
const { platform: platform$1, arch: arch$1 } =
|
|
9322
|
+
const { platform: platform$1, arch: arch$1 } = process$1;
|
|
9323
9323
|
const tryEachApp = async (apps, opener) => {
|
|
9324
9324
|
if (apps.length === 0) return;
|
|
9325
9325
|
const errors = [];
|
|
@@ -9432,7 +9432,7 @@ const baseOpen = async (options) => {
|
|
|
9432
9432
|
await fs$1.access(localXdgOpenPath, constants.X_OK);
|
|
9433
9433
|
exeLocalXdgOpen = true;
|
|
9434
9434
|
} catch {}
|
|
9435
|
-
command =
|
|
9435
|
+
command = process$1.versions.electron ?? (platform$1 === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|
|
9436
9436
|
}
|
|
9437
9437
|
if (appArguments.length > 0) cliArguments.push(...appArguments);
|
|
9438
9438
|
if (!options.wait) {
|
|
@@ -10889,7 +10889,7 @@ var ht$1 = class extends m {
|
|
|
10889
10889
|
//#endregion
|
|
10890
10890
|
//#region ../../node_modules/.pnpm/@clack+prompts@1.4.0/node_modules/@clack/prompts/dist/index.mjs
|
|
10891
10891
|
function ee() {
|
|
10892
|
-
return
|
|
10892
|
+
return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
10893
10893
|
}
|
|
10894
10894
|
const tt = ee(), w = (t, i) => tt ? t : i, Tt = w("◆", "*"), at = w("■", "x"), ut = w("▲", "x"), H = w("◇", "o");
|
|
10895
10895
|
const $ = w("│", "|"), x = w("└", "—");
|
|
@@ -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
|
-
|
|
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
|
@@ -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
|
|
17
|
-
| `mxs preview
|
|
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
|
|