@markdy/cli 0.7.18 → 0.7.20
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/README.md +24 -1
- package/dist/index.js +8 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,6 +8,27 @@ First-party command-line tooling for MarkdyScript.
|
|
|
8
8
|
npm i -D @markdy/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
If you install it into a project, run it with `npx markdy ...` or `npm exec markdy ...` from that project.
|
|
12
|
+
To make `markdy` available as a shell command everywhere, install it globally with `npm i -g @markdy/cli`.
|
|
13
|
+
|
|
14
|
+
## Visual guide
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<img src="https://raw.githubusercontent.com/HoangYell/markdy-com/main/website/public/images/markdy-cli-flow.webp" alt="Markdy CLI workflow visual" width="900" />
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## Love Story result
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="https://raw.githubusercontent.com/HoangYell/markdy-com/main/website/public/images/markdy-love-story-result.webp" alt="Love Story main Markdy result" width="900" />
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
Use the same command shown in this repo to generate the preview image yourself:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx markdy render examples/00-love-story.markdy --out examples/xscene.html
|
|
30
|
+
```
|
|
31
|
+
|
|
11
32
|
## Commands
|
|
12
33
|
|
|
13
34
|
```bash
|
|
@@ -27,4 +48,6 @@ markdy check-all .
|
|
|
27
48
|
|
|
28
49
|
- The CLI resolves `import "file.markdy" as ns` from disk before parsing.
|
|
29
50
|
- `fmt` prints a canonicalized scene and may expand higher-level sugar into its parsed form.
|
|
30
|
-
- `render --out` writes a self-contained HTML preview
|
|
51
|
+
- `render --out` writes a self-contained HTML preview to the exact path you pass in.
|
|
52
|
+
- If the path is relative, it is resolved from the current working directory.
|
|
53
|
+
- If you see `zsh: command not found: markdy`, the package is installed locally but that directory is not on your PATH.
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { PRESETS, PRESET_NAMES, parse } from "@markdy/core";
|
|
5
5
|
import { createRequire } from "module";
|
|
6
|
-
import { basename, dirname, extname, join, resolve } from "path";
|
|
6
|
+
import { basename, dirname, extname, join, resolve, sep } from "path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
8
8
|
import { createServer } from "http";
|
|
9
9
|
import { readdir, readFile, stat, writeFile } from "fs/promises";
|
|
@@ -157,7 +157,7 @@ var MARKDY_EXT = ".markdy";
|
|
|
157
157
|
var PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
158
158
|
async function runCli(argv, io = defaultIo(), runtime = defaultRuntime()) {
|
|
159
159
|
const parsed = parseArgv(argv);
|
|
160
|
-
if (
|
|
160
|
+
if (hasFlag(parsed, "help")) {
|
|
161
161
|
io.stdout(helpText());
|
|
162
162
|
return { exitCode: 0 };
|
|
163
163
|
}
|
|
@@ -165,10 +165,6 @@ async function runCli(argv, io = defaultIo(), runtime = defaultRuntime()) {
|
|
|
165
165
|
return launchPlayground(parsed, io, runtime);
|
|
166
166
|
}
|
|
167
167
|
const command = parsed.command;
|
|
168
|
-
if (command === "--help" || command === "-h") {
|
|
169
|
-
io.stdout(helpText());
|
|
170
|
-
return { exitCode: 0 };
|
|
171
|
-
}
|
|
172
168
|
switch (command) {
|
|
173
169
|
case "lint":
|
|
174
170
|
return lintCommand(parsed, io);
|
|
@@ -454,7 +450,7 @@ async function startPreviewServer(code, imports, sourcePath, preferredPort) {
|
|
|
454
450
|
async function servePackageFile(response, distDir, relativePath) {
|
|
455
451
|
const safePath = relativePath.replace(/^\/+/, "");
|
|
456
452
|
const fullPath = resolve(distDir, safePath);
|
|
457
|
-
if (!fullPath.startsWith(distDir)) {
|
|
453
|
+
if (fullPath !== distDir && !fullPath.startsWith(distDir + sep)) {
|
|
458
454
|
sendText(response, 403, "Forbidden", "text/plain; charset=utf-8");
|
|
459
455
|
return;
|
|
460
456
|
}
|
|
@@ -771,11 +767,13 @@ function parseArgv(argv) {
|
|
|
771
767
|
continue;
|
|
772
768
|
}
|
|
773
769
|
if (arg.startsWith("--")) {
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
770
|
+
const body = arg.slice(2);
|
|
771
|
+
const eqIndex = body.indexOf("=");
|
|
772
|
+
if (eqIndex !== -1) {
|
|
773
|
+
flags.set(body.slice(0, eqIndex), body.slice(eqIndex + 1));
|
|
777
774
|
continue;
|
|
778
775
|
}
|
|
776
|
+
const rawKey = body;
|
|
779
777
|
const next = argv[index + 1];
|
|
780
778
|
if (next && !next.startsWith("-") && expectsValue(rawKey)) {
|
|
781
779
|
flags.set(rawKey, next);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.20",
|
|
4
4
|
"description": "First-party CLI for MarkdyScript: lint, format, explain, render, and local playground tooling.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@markdy/core": "0.7.
|
|
45
|
-
"@markdy/renderer-dom": "0.7.
|
|
44
|
+
"@markdy/core": "0.7.20",
|
|
45
|
+
"@markdy/renderer-dom": "0.7.20"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^25.9.5",
|