md-pipe 0.7.3 → 0.7.5

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.
@@ -3,7 +3,7 @@
3
3
  A rendering engine that transforms Markdown manuscripts into HTML/PDF through HTML-comment directives and DOM transformations, without polluting the Markdown source.
4
4
 
5
5
 
6
- **Version:** 0.3.0
6
+ **Version:** 0.7.5
7
7
 
8
8
  ## Table of Contents
9
9
 
@@ -110,7 +110,8 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
110
110
 
111
111
  **Exit 0:** Rendering succeeded.
112
112
 
113
- **Exit 1:** Rendering error (Chromium launch failure, PDF generation failure, etc.).
113
+ **Exit 1:** Rendering error (Chromium launch failure, PDF generation failure, etc.). Every failure md-pipe does not attribute to the invocation lands here, including failures reported by its dependencies, whatever their wording.
114
+
114
115
 
115
116
  - **stderr:** format=`text`
116
117
 
@@ -153,7 +154,7 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
153
154
 
154
155
  </details>
155
156
 
156
- **Exit 2:** Input error (file not found, syntax error, invalid pipeline specification, undefined directive in strict mode, etc.).
157
+ **Exit 2:** Input error (file not found, syntax error, invalid pipeline specification, missing required option, undefined directive in strict mode, etc.). Reserved for faults md-pipe raises against the invocation or the files it names, which retrying unchanged cannot clear.
157
158
 
158
159
 
159
160
  - **stderr:** format=`text`
@@ -200,14 +201,14 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
200
201
  #### Extensions
201
202
 
202
203
  ```yaml
203
- x-agent:
204
- recommended_before_use:
204
+ x-agent:
205
+ recommended_before_use:
205
206
  - Check that md-pipe.config.yml exists when using themes or custom directives
206
- - Verify Chromium is available when targeting pdf output
207
- rollback:
207
+ - Verify the optional puppeteer peer dependency is installed and Chromium is available when targeting pdf output
208
+ rollback:
208
209
  supported: false
209
210
  notes: Output files can be deleted manually; no side effects beyond file writes.
210
- retryable_exit_codes:
211
+ retryable_exit_codes:
211
212
  - 1
212
213
  expected_duration_ms: 5000
213
214
  ```
@@ -258,6 +259,50 @@ md-pipe init --theme business-report
258
259
 
259
260
  **Exit 1:** Initialization error (file write failure, etc.).
260
261
 
262
+ - **stderr:** format=`text`
263
+
264
+ | Property | Type | Required | Description |
265
+ |---|---|---|---|
266
+ | `message` | `string` | Yes | Error message. |
267
+ | `file` | `string` | No | File path where the error occurred. |
268
+ | `line` | `integer` | No | Line number where the error occurred. |
269
+ | `detail` | `string` | No | Detailed error information. |
270
+
271
+ <details>
272
+ <summary>JSON Schema</summary>
273
+
274
+ ```json
275
+ {
276
+ "type": "object",
277
+ "required": [
278
+ "message"
279
+ ],
280
+ "properties": {
281
+ "message": {
282
+ "type": "string",
283
+ "description": "Error message."
284
+ },
285
+ "file": {
286
+ "type": "string",
287
+ "description": "File path where the error occurred."
288
+ },
289
+ "line": {
290
+ "type": "integer",
291
+ "description": "Line number where the error occurred."
292
+ },
293
+ "detail": {
294
+ "type": "string",
295
+ "description": "Detailed error information."
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ </details>
302
+
303
+ **Exit 2:** Input error (unknown option, missing option argument, excess argument, etc.). Reserved for faults md-pipe raises against the invocation, which retrying unchanged cannot clear.
304
+
305
+
261
306
  - **stderr:** format=`text`
262
307
 
263
308
  | Property | Type | Required | Description |
@@ -345,13 +390,13 @@ md-pipe init --theme business-report
345
390
  #### Extensions
346
391
 
347
392
  ```yaml
348
- x-agent:
349
- recommended_before_use:
393
+ x-agent:
394
+ recommended_before_use:
350
395
  - Check whether md-pipe.config.yml already exists
351
- human_review:
396
+ human_review:
352
397
  required: false
353
398
  reason: Safe scaffolding operation; --force requires attention.
354
- rollback:
399
+ rollback:
355
400
  supported: true
356
401
  notes: Delete the generated md-pipe.config.yml.
357
402
  ```
package/package.json CHANGED
@@ -1,22 +1,18 @@
1
1
  {
2
2
  "name": "md-pipe",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "A rendering engine that transforms Markdown to HTML/PDF via directive-driven pipelines",
5
5
  "type": "module",
6
- "main": "dist/cli.js",
7
6
  "bin": {
8
7
  "md-pipe": "dist/md-pipe.bundle.mjs"
9
8
  },
10
9
  "scripts": {
11
- "generate": "cli-contracts generate && node scripts/postgenerate.js",
12
- "prebuild": "npm run generate --silent 2>/dev/null || true",
13
- "build": "tsc",
14
- "bundle": "node esbuild.bundle.mjs",
15
- "bundle:min": "node esbuild.bundle.mjs --minify",
10
+ "generate": "cli-contracts generate",
11
+ "build": "tsc && tsc -p tsconfig.peer-floor.json",
12
+ "bundle": "node esbuild.bundle.mjs --minify",
16
13
  "clean": "rm -rf dist",
17
14
  "test": "vitest run",
18
15
  "test:unit": "vitest run test/unit",
19
- "prepublishOnly": "npm run clean && npm run build && npm run bundle:min",
20
16
  "test:ci": "vitest run"
21
17
  },
22
18
  "keywords": [
@@ -36,22 +32,31 @@
36
32
  "README.md"
37
33
  ],
38
34
  "engines": {
39
- "node": ">=20.0.0"
35
+ "node": ">=22.12.0"
40
36
  },
41
37
  "dependencies": {
42
- "puppeteer": "^25.0.2",
43
38
  "tsx": "^4.21.0"
44
39
  },
40
+ "peerDependencies": {
41
+ "puppeteer": ">=22.15.0"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "puppeteer": {
45
+ "optional": true
46
+ }
47
+ },
45
48
  "devDependencies": {
46
49
  "@types/js-yaml": "^4.0.9",
47
50
  "@types/node": "^22.15.21",
48
51
  "cheerio": "^1.2.0",
49
- "cli-contracts": "^0.32.0",
52
+ "cli-contracts": "^0.34.6",
50
53
  "commander": "^14.0.3",
51
54
  "esbuild": "^0.28.0",
52
55
  "handlebars": "^4.7.9",
53
56
  "js-yaml": "^4.1.1",
54
57
  "marked": "^18.0.3",
58
+ "puppeteer": "^25.0.2",
59
+ "puppeteer-floor": "npm:puppeteer@22.15.0",
55
60
  "typescript": "^6.0.3",
56
61
  "vitest": "^4.1.7"
57
62
  }
package/dist/cli.js DELETED
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env node
2
- import { register } from "tsx/esm/api";
3
- register();
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- import { createProgram } from "./generated/program.js";
8
- import { loadProjectConfig, parseFrontmatter, resolveConfig, loadTransforms, } from "./config.js";
9
- import { runPipeline } from "./pipeline/index.js";
10
- import { runInit } from "./commands/init.js";
11
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
- const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
13
- async function readInput(filePath) {
14
- if (filePath) {
15
- if (!fs.existsSync(filePath)) {
16
- throw new Error(`Input file not found: ${filePath}`);
17
- }
18
- return fs.readFileSync(filePath, "utf-8");
19
- }
20
- if (process.stdin.isTTY) {
21
- throw new Error("No input file specified and stdin is a terminal");
22
- }
23
- return new Promise((resolve, reject) => {
24
- let data = "";
25
- process.stdin.setEncoding("utf-8");
26
- process.stdin.on("data", (chunk) => (data += chunk));
27
- process.stdin.on("end", () => resolve(data));
28
- process.stdin.on("error", reject);
29
- });
30
- }
31
- const handlers = {
32
- async render(input, opts, globalOpts) {
33
- try {
34
- const source = await readInput(input);
35
- const inputPath = input ? path.resolve(input) : undefined;
36
- const inputDir = inputPath ? path.dirname(inputPath) : process.cwd();
37
- const project = loadProjectConfig(globalOpts.config);
38
- const { frontmatter, body } = parseFrontmatter(source);
39
- const normalizedOpts = {
40
- ...opts,
41
- styles: opts.styles ? (Array.isArray(opts.styles) ? opts.styles : [opts.styles]) : undefined,
42
- scripts: opts.scripts ? (Array.isArray(opts.scripts) ? opts.scripts : [opts.scripts]) : undefined,
43
- paperSize: opts.paperSize ?? "A4",
44
- };
45
- const config = resolveConfig(normalizedOpts, {
46
- config: globalOpts.config,
47
- verbose: globalOpts.verbose,
48
- strict: globalOpts.strict,
49
- }, frontmatter, project, inputDir);
50
- if (project.transforms && project.transforms.length > 0) {
51
- config.transforms = await loadTransforms(project.transforms, inputDir);
52
- }
53
- const startIsSource = config.pipeline.start === "preprocess";
54
- const content = startIsSource ? body : source;
55
- const result = await runPipeline(content, config, input);
56
- if (result !== "" && config.pipeline.end !== "pdf") {
57
- if (config.output) {
58
- const outPath = path.resolve(config.output);
59
- const dir = path.dirname(outPath);
60
- if (!fs.existsSync(dir)) {
61
- fs.mkdirSync(dir, { recursive: true });
62
- }
63
- fs.writeFileSync(outPath, result, "utf-8");
64
- if (config.verbose) {
65
- process.stderr.write(`[md-pipe] Written to ${outPath}\n`);
66
- }
67
- }
68
- else {
69
- process.stdout.write(result);
70
- }
71
- }
72
- }
73
- catch (err) {
74
- process.stderr.write(`${err.message}\n`);
75
- process.exit(err.message?.includes("not found") ||
76
- err.message?.includes("Invalid pipeline")
77
- ? 2
78
- : 1);
79
- }
80
- },
81
- async init(opts) {
82
- runInit({ theme: opts.theme ?? "default", force: opts.force ?? false });
83
- },
84
- };
85
- const program = createProgram(handlers, pkg.version);
86
- program.parse();
87
- //# sourceMappingURL=cli.js.map