jsmdcui 0.11.1 → 0.11.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable user-visible changes to jsmdcui are documented here.
4
4
 
5
+ ## [0.11.2] - 2026-07-26
6
+
7
+ ### Added
8
+
9
+ - Add `--build-md-exe <file.md>` as a convenience alias for building a
10
+ current-platform executable with `global.MDCUI_MAIN` set to the specified
11
+ Markdown app.
12
+ - Add `--build-md-for <platform> <file.md>` for the equivalent
13
+ cross-compilation workflow. Both aliases expand into the existing build
14
+ arguments before generated application files are written.
15
+
16
+ ### Fixed
17
+
18
+ - Fix the final executable existence check for Windows builds by checking the
19
+ `.exe` output path for Windows targets, or for native Windows builds when no
20
+ target is specified.
21
+
5
22
  ## [0.11.1] - 2026-07-26
6
23
 
7
24
  ### Changed
package/README.md CHANGED
@@ -775,6 +775,25 @@ use `=1` to make this explicit.
775
775
  - `global.MDCUI_MAIN_BASE`: internal define generated automatically from
776
776
  `global.MDCUI_MAIN`; do not pass it manually.
777
777
 
778
+ For the current platform, build an executable embedding `myapp.md` with:
779
+
780
+ ```shell
781
+ npx jsmdcui --build-md-exe myapp.md
782
+ ```
783
+
784
+ This is a convenience alias for
785
+ `--build-exe --define global.MDCUI_MAIN=myapp.md`.
786
+
787
+ For cross-compilation, specify the Bun target before the Markdown file:
788
+
789
+ ```shell
790
+ npx jsmdcui --build-md-for bun-linux-x64-v1.3.14 myapp.md
791
+ ```
792
+
793
+ This similarly expands to
794
+ `--build-for bun-linux-x64 --define global.MDCUI_MAIN=myapp.md`. Both aliases
795
+ are expanded before any generated application files are written.
796
+
778
797
  Place every build define after `--build-exe`, or after the target argument of
779
798
  `--build-for`. Choose at most one of `MDCUI_DEFAULT_EDIT`,
780
799
  `MDCUI_DEFAULT_DEMO`, and `MDCUI_DEFAULT_DEMO_WUI`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsmdcui",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Markdown as a Common UI for Terminals and Web Browsers",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -775,6 +775,25 @@ use `=1` to make this explicit.
775
775
  - `global.MDCUI_MAIN_BASE`: internal define generated automatically from
776
776
  `global.MDCUI_MAIN`; do not pass it manually.
777
777
 
778
+ For the current platform, build an executable embedding `myapp.md` with:
779
+
780
+ ```shell
781
+ npx jsmdcui --build-md-exe myapp.md
782
+ ```
783
+
784
+ This is a convenience alias for
785
+ `--build-exe --define global.MDCUI_MAIN=myapp.md`.
786
+
787
+ For cross-compilation, specify the Bun target before the Markdown file:
788
+
789
+ ```shell
790
+ npx jsmdcui --build-md-for bun-linux-x64-v1.3.14 myapp.md
791
+ ```
792
+
793
+ This similarly expands to
794
+ `--build-for bun-linux-x64 --define global.MDCUI_MAIN=myapp.md`. Both aliases
795
+ are expanded before any generated application files are written.
796
+
778
797
  Place every build define after `--build-exe`, or after the target argument of
779
798
  `--build-for`. Choose at most one of `MDCUI_DEFAULT_EDIT`,
780
799
  `MDCUI_DEFAULT_DEMO`, and `MDCUI_DEFAULT_DEMO_WUI`.
@@ -92,7 +92,7 @@ export function stringifyNonPrimitiveDefineValues(argv, name) {
92
92
 
93
93
  export async function buildExecutable(target = "",build_outfile="single.exe", bunArgs = []) {
94
94
 
95
- const outfile = resolve(process.cwd(), build_outfile);
95
+ let outfile = resolve(process.cwd(), build_outfile);
96
96
  const normalizedTarget = String(target || "").trim();
97
97
  const extraBunArgs = Array.from(bunArgs ?? [], String);
98
98
  if(!globalThis.Bun || IS_COMPILED)
@@ -164,6 +164,12 @@ export async function buildExecutable(target = "",build_outfile="single.exe", bu
164
164
 
165
165
  } // for steps of build
166
166
 
167
+ const isWindows = normalizedTarget
168
+ ? normalizedTarget.toLowerCase().includes("windows")
169
+ : process.platform === "win32";
170
+ if (isWindows && !outfile.toLowerCase().endsWith(".exe")) {
171
+ outfile += ".exe";
172
+ }
167
173
  if(await Bun.file(outfile).exists())
168
174
  {
169
175
  console.log(`Built executable: ${outfile}`);
@@ -0,0 +1,40 @@
1
+ export function expandBuildMdAliases(argv = process.argv) {
2
+ const buildMdExeIndex = argv.indexOf("--build-md-exe");
3
+ if (buildMdExeIndex !== -1) {
4
+ const markdown = argv[buildMdExeIndex + 1];
5
+ if (!markdown || markdown.startsWith("-")) {
6
+ throw new Error("Missing Markdown path for --build-md-exe");
7
+ }
8
+
9
+ argv.splice(
10
+ buildMdExeIndex,
11
+ 2,
12
+ "--build-exe",
13
+ "--define",
14
+ `global.MDCUI_MAIN=${markdown}`,
15
+ );
16
+ return true;
17
+ }
18
+
19
+ const buildMdForIndex = argv.indexOf("--build-md-for");
20
+ if (buildMdForIndex === -1) return false;
21
+
22
+ const platform = argv[buildMdForIndex + 1];
23
+ if (!platform || platform.startsWith("-")) {
24
+ throw new Error("Missing platform for --build-md-for");
25
+ }
26
+ const markdown = argv[buildMdForIndex + 2];
27
+ if (!markdown || markdown.startsWith("-")) {
28
+ throw new Error("Missing Markdown path for --build-md-for");
29
+ }
30
+
31
+ argv.splice(
32
+ buildMdForIndex,
33
+ 3,
34
+ "--build-for",
35
+ platform,
36
+ "--define",
37
+ `global.MDCUI_MAIN=${markdown}`,
38
+ );
39
+ return true;
40
+ }
package/src/index.js CHANGED
@@ -129,6 +129,7 @@ import { createInterface } from "node:readline/promises";
129
129
 
130
130
  import pkg from "../package.json" with { type: "json" };
131
131
  import { REPO_ROOT,IS_COMPILED, buildExecutable,buildEarlyExit,stringifyNonPrimitiveDefineValues } from "../single-exe/compiled.js";
132
+ import { expandBuildMdAliases } from "./build-args.js";
132
133
 
133
134
 
134
135
  const __filename = fileURLToPath(import.meta.url);
@@ -1349,14 +1350,20 @@ Remote Markdown:
1349
1350
  Download HTTP(S) Markdown and, with Kitty mode, its HTTP(S) images; allow its code to run
1350
1351
 
1351
1352
  Experimental single-exe:
1353
+ --build-md-exe <file.md> [BUN_ARGS...]
1354
+ Build with <file.md> embedded as global.MDCUI_MAIN & exit
1355
+ --build-md-for <platform> <file.md> [BUN_ARGS...]
1356
+ Build for <platform> with <file.md> embedded & exit
1357
+
1352
1358
  --build-exe [BUN_ARGS...]
1353
1359
  Build a Bun single-file executable & exit
1354
1360
  --build-for <target> [BUN_ARGS...]
1355
1361
  Build a Bun single-file executable for target & exit
1356
1362
 
1357
1363
  [BUN_ARGS...]
1358
- --define MDCUI_XXX=1
1359
- More info in --readme
1364
+ --define MDCUI_OVERWRITE_DEMO=1
1365
+ --define global.MDCUI_MAIN=myapp.md
1366
+ More info in --readme
1360
1367
  https://bun.com/docs/bundler/executables
1361
1368
  `
1362
1369
  ].join("\n");
@@ -5024,7 +5031,7 @@ class App {
5024
5031
  const name = buf?.name ?? "No name";
5025
5032
  const filename = /^[^\s"'\\]+$/.test(name) ? name : JSON.stringify(name);
5026
5033
  this.openCommandMode(`save ${filename}`);
5027
- break;
5034
+ break; //"
5028
5035
  }
5029
5036
  case "row":
5030
5037
  if (isTerm) {
@@ -8257,6 +8264,7 @@ function stringDefineFromArgv(argv, name) {
8257
8264
  async function main() {
8258
8265
  addCheckpoint("Argument Parsing");
8259
8266
 
8267
+ expandBuildMdAliases(process.argv);
8260
8268
  stringifyNonPrimitiveDefineValues(process.argv, "global.MDCUI_MAIN");
8261
8269
  const argvMdcuiMain = stringDefineFromArgv(
8262
8270
  process.argv,
@@ -1,4 +1,5 @@
1
1
  import { expect, test } from "bun:test";
2
+ import { expandBuildMdAliases } from "../src/build-args.js";
2
3
  import {
3
4
  isCompiledBinary as isSingleExeCompiled,
4
5
  stringifyNonPrimitiveDefineValues,
@@ -10,6 +11,69 @@ test("single-exe recognizes Bun compiled virtual paths", () => {
10
11
  expect(isSingleExeCompiled(["bun", "/project/src/index.js"])).toBe(false);
11
12
  });
12
13
 
14
+ test("--build-md-exe expands before the existing build flow", () => {
15
+ const argv = [
16
+ "bun",
17
+ "src/index.js",
18
+ "--build-md-exe",
19
+ "../中文工具.md",
20
+ "--sourcemap",
21
+ ];
22
+ expect(expandBuildMdAliases(argv)).toBe(true);
23
+ expect(argv).toEqual([
24
+ "bun",
25
+ "src/index.js",
26
+ "--build-exe",
27
+ "--define",
28
+ "global.MDCUI_MAIN=../中文工具.md",
29
+ "--sourcemap",
30
+ ]);
31
+ expect(expandBuildMdAliases(argv)).toBe(false);
32
+ });
33
+
34
+ test("--build-md-exe requires a Markdown path", () => {
35
+ expect(() => expandBuildMdAliases(["bun", "index.js", "--build-md-exe"]))
36
+ .toThrow("Missing Markdown path for --build-md-exe");
37
+ expect(() => expandBuildMdAliases([
38
+ "bun",
39
+ "index.js",
40
+ "--build-md-exe",
41
+ "--sourcemap",
42
+ ])).toThrow("Missing Markdown path for --build-md-exe");
43
+ });
44
+
45
+ test("--build-md-for expands before the existing cross-build flow", () => {
46
+ const argv = [
47
+ "bun",
48
+ "src/index.js",
49
+ "--build-md-for",
50
+ "bun-linux-x64",
51
+ "../中文工具.md",
52
+ "--sourcemap",
53
+ ];
54
+ expect(expandBuildMdAliases(argv)).toBe(true);
55
+ expect(argv).toEqual([
56
+ "bun",
57
+ "src/index.js",
58
+ "--build-for",
59
+ "bun-linux-x64",
60
+ "--define",
61
+ "global.MDCUI_MAIN=../中文工具.md",
62
+ "--sourcemap",
63
+ ]);
64
+ });
65
+
66
+ test("--build-md-for requires a platform and Markdown path", () => {
67
+ expect(() => expandBuildMdAliases(["bun", "index.js", "--build-md-for"]))
68
+ .toThrow("Missing platform for --build-md-for");
69
+ expect(() => expandBuildMdAliases([
70
+ "bun",
71
+ "index.js",
72
+ "--build-md-for",
73
+ "bun-linux-x64",
74
+ ])).toThrow("Missing Markdown path for --build-md-for");
75
+ });
76
+
13
77
  test("non-primitive MDCUI_MAIN define values become strings", () => {
14
78
  const split = [
15
79
  "bun",