ezx 0.0.13 → 0.0.15
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 +10 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/preprocessor.d.ts +2 -0
- package/dist/preprocessor.d.ts.map +1 -1
- package/dist/preprocessor.js +12 -3
- package/dist/preprocessor.js.map +1 -1
- package/package.json +2 -1
- package/src/cli.ts +33 -0
- package/src/index.ts +231 -0
- package/src/preprocessor.ts +556 -0
package/README.md
CHANGED
|
@@ -190,6 +190,15 @@ $`npm run dev`
|
|
|
190
190
|
|
|
191
191
|
The command runs without `await`, so execution continues immediately. zx automatically awaits all pending promises at the end of the script.
|
|
192
192
|
|
|
193
|
+
**Kill on Complete:** Use the `--kill-on-complete` (or `-k`) CLI option to kill all async processes when the script completes, instead of waiting for them:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
ezx --kill-on-complete script.md
|
|
197
|
+
ezx -k script.md
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
This is useful for development servers or other long-running processes that should be terminated after the script runs.
|
|
201
|
+
|
|
193
202
|
**Important:** The `async:` directive only works with bash/sh/shell blocks. Using it with other languages will result in an error.
|
|
194
203
|
|
|
195
204
|
## Installation
|
|
@@ -339,6 +348,7 @@ Run markdown content or file with CLI-like options.
|
|
|
339
348
|
- `cwd` (string) - Current working directory
|
|
340
349
|
- `preferLocal` (boolean) - Prefer locally installed packages
|
|
341
350
|
- `sections` (string[]) - Execute only sections under these heading titles
|
|
351
|
+
- `killOnComplete` (boolean) - Kill all spawned async processes when script completes
|
|
342
352
|
|
|
343
353
|
### `runMarkdownFile(filePath, options)`
|
|
344
354
|
|
package/dist/cli.js
CHANGED
|
@@ -17,6 +17,7 @@ program
|
|
|
17
17
|
.option('-s, --sections <headings...>', 'execute only sections under these headings (e.g., "Create a new project")')
|
|
18
18
|
.option('-p, --preprocess-only [file]', 'output preprocessed markdown without executing (optionally to a file)')
|
|
19
19
|
.option('--standalone', 'create .npmrc file after setting directory for standalone npm mode in monorepos')
|
|
20
|
+
.option('-k, --kill-on-complete', 'kill all spawned processes when script completes')
|
|
20
21
|
.action(async (script, options) => {
|
|
21
22
|
try {
|
|
22
23
|
await runMarkdownFile(script, options);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAA0B,MAAM,YAAY,CAAC;AACpE,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AAEtD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACL,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,uEAAuE,CAAC;KACpF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;KACpB,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;KAC/C,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;KAC7C,MAAM,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;KAC/C,MAAM,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;KACnD,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CAAC;KACrD,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC;KAC/C,MAAM,CAAC,8BAA8B,EAAE,2EAA2E,CAAC;KACnH,MAAM,CAAC,8BAA8B,EAAE,uEAAuE,CAAC;KAC/G,MAAM,CAAC,cAAc,EAAE,iFAAiF,CAAC;KACzG,MAAM,CAAC,KAAK,EAAE,MAAc,EA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AM,CAAC,cAAc,EAAE,iFAAiF,CAAC;KACzG,MAAM,CAAC,wBAAwB,EAAE,kDAAkD,CAAC;KACpF,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,OAA2B,EAAE,EAAE;IAC7D,IAAI,CAAC;QACJ,MAAM,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC,CAAC,CAAC;AAEJ,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAwDD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyH5G;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvG;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjH;AAGD,cAAc,IAAI,CAAC;AAGnB,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -98,9 +98,10 @@ export async function runMarkdown(markdown, options = {}) {
|
|
|
98
98
|
markdownContent = extractSectionsByHeading(markdownContent, options.sections);
|
|
99
99
|
}
|
|
100
100
|
// Preprocess markdown with ezx enhancements
|
|
101
|
-
const { preprocessedMarkdown } = preprocessMarkdown(markdownContent, {
|
|
101
|
+
const { preprocessedMarkdown, hasAsyncBlocks } = preprocessMarkdown(markdownContent, {
|
|
102
102
|
cwd: options.cwd || process.cwd(),
|
|
103
103
|
standalone: options.standalone,
|
|
104
|
+
killOnComplete: options.killOnComplete,
|
|
104
105
|
});
|
|
105
106
|
// Sanitize markdown to prevent zx from misinterpreting indented prose as code
|
|
106
107
|
// This handles edge cases like indented code blocks within list items
|
|
@@ -124,7 +125,16 @@ export async function runMarkdown(markdown, options = {}) {
|
|
|
124
125
|
const zxGlobalsPath = await import.meta.resolve('zx/globals');
|
|
125
126
|
// Prepend globals import to make $, fs, path, etc. available in the script context
|
|
126
127
|
// Use the resolved absolute path to ensure zx is found
|
|
127
|
-
|
|
128
|
+
let preamble = `await import('${zxGlobalsPath}')\n\n`;
|
|
129
|
+
// If killOnComplete is enabled and there are async blocks, add process tracking
|
|
130
|
+
if (options.killOnComplete && hasAsyncBlocks) {
|
|
131
|
+
preamble += `const __ezx_async_processes = [];\n\n`;
|
|
132
|
+
}
|
|
133
|
+
jsCode = preamble + jsCode;
|
|
134
|
+
// If killOnComplete is enabled and there are async blocks, add cleanup code
|
|
135
|
+
if (options.killOnComplete && hasAsyncBlocks) {
|
|
136
|
+
jsCode += `\n\n// Kill all async processes on completion\n__ezx_async_processes.forEach(p => p.kill());\n`;
|
|
137
|
+
}
|
|
128
138
|
// Write to temp file in current directory (not tmpdir) so zx can be resolved
|
|
129
139
|
// Node's module resolution looks for package.json starting from the file's directory,
|
|
130
140
|
// so the temp file needs to be in a location that has access to node_modules
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAC,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAgB,aAAa,EAAC,MAAM,UAAU,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAE5E,iEAAiE;AACjE,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/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AO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;IACF,CAAC;YAAS,CAAC;QACV,gBAAgB;QAChB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,UAA8B,EAAE;IACvF,OAAO,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,eAAuB,EAAE,UAA8B,EAAE;IACjG,OAAO,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+CAA+C;AAC/C,cAAc,IAAI,CAAC;AAEnB,gCAAgC;AAChC,cAAc,mBAAmB,CAAC"}
|
package/dist/preprocessor.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface FileExtraction {
|
|
|
28
28
|
export interface PreprocessResult {
|
|
29
29
|
preprocessedMarkdown: string;
|
|
30
30
|
extractedFiles: FileExtraction[];
|
|
31
|
+
hasAsyncBlocks: boolean;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Sanitize markdown to prevent zx's parser from misinterpreting
|
|
@@ -47,6 +48,7 @@ export declare function sanitizeMarkdownForZx(markdown: string): string;
|
|
|
47
48
|
export declare function preprocessMarkdown(input: string, options?: {
|
|
48
49
|
cwd?: string;
|
|
49
50
|
standalone?: boolean;
|
|
51
|
+
killOnComplete?: boolean;
|
|
50
52
|
}): PreprocessResult;
|
|
51
53
|
/**
|
|
52
54
|
* Read and preprocess a markdown file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,cAAc,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;CACxB;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuC9D;AAqLD;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAM,GAC1E,gBAAgB,CAwPlB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAM,GAC1B,gBAAgB,CAGlB"}
|
package/dist/preprocessor.js
CHANGED
|
@@ -217,7 +217,7 @@ function isDirectorySetCommand(line) {
|
|
|
217
217
|
* Preprocess markdown file
|
|
218
218
|
*/
|
|
219
219
|
export function preprocessMarkdown(input, options = {}) {
|
|
220
|
-
const { cwd = process.cwd(), standalone = false } = options;
|
|
220
|
+
const { cwd = process.cwd(), standalone = false, killOnComplete = false } = options;
|
|
221
221
|
const lines = input.split('\n');
|
|
222
222
|
const codeBlocks = parseCodeBlocks(input);
|
|
223
223
|
const extractedFiles = [];
|
|
@@ -350,8 +350,14 @@ export function preprocessMarkdown(input, options = {}) {
|
|
|
350
350
|
// Escape backticks in the command for the template literal
|
|
351
351
|
const escapedCommand = command.replace(/`/g, '\\`');
|
|
352
352
|
// Output the $ template literal (fire-and-forget, no await)
|
|
353
|
-
//
|
|
354
|
-
|
|
353
|
+
// If killOnComplete is enabled, push to tracking array so we can kill it later
|
|
354
|
+
if (killOnComplete) {
|
|
355
|
+
preprocessedLines.push(`__ezx_async_processes.push($\`${escapedCommand}\`)`);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// zx will await all pending promises at the end
|
|
359
|
+
preprocessedLines.push(`$\`${escapedCommand}\``);
|
|
360
|
+
}
|
|
355
361
|
preprocessedLines.push('```');
|
|
356
362
|
// Skip to the closing ```
|
|
357
363
|
i = block.endLine;
|
|
@@ -425,9 +431,12 @@ export function preprocessMarkdown(input, options = {}) {
|
|
|
425
431
|
preprocessedLines.push(line);
|
|
426
432
|
}
|
|
427
433
|
}
|
|
434
|
+
// Check if there are any async blocks
|
|
435
|
+
const hasAsyncBlocks = blocksToAsync.size > 0;
|
|
428
436
|
return {
|
|
429
437
|
preprocessedMarkdown: preprocessedLines.join('\n'),
|
|
430
438
|
extractedFiles,
|
|
439
|
+
hasAsyncBlocks,
|
|
431
440
|
};
|
|
432
441
|
}
|
|
433
442
|
/**
|
package/dist/preprocessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.js","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAAS,KAAK,EAAC,MAAM,QAAQ,CAAC;AAyDrC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACrD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,iEAAiE;IACjE,SAAS,aAAa,CAAC,UAAiB,EAAE,QA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O,GAAG,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACP,gDAAgD;gBAChD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;aAAM,CAAC;YACP,eAAe;YACf,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC;IAED,sCAAsC;IACtC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,CAAC;IAE9C,OAAO;QACN,oBAAoB,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;QAClD,cAAc;QACd,cAAc;KACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,QAAgB,EAChB,UAA0B,EAAE;IAE5B,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ezx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Enhanced zx - Write better shell scripts with markdown preprocessing features including directory context persistence, file extraction, and fixes for zx's indentation parsing issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zx",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
|
+
"src",
|
|
50
51
|
"README.md",
|
|
51
52
|
"LICENSE"
|
|
52
53
|
],
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {Command} from 'commander';
|
|
4
|
+
import {runMarkdownFile, type RunMarkdownOptions} from './index.js';
|
|
5
|
+
import pkg from '../package.json' with {type: 'json'};
|
|
6
|
+
|
|
7
|
+
const program = new Command();
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.name('ezx')
|
|
11
|
+
.description('Enhanced zx - A tool for writing better scripts with markdown support')
|
|
12
|
+
.version(pkg.version)
|
|
13
|
+
.argument('<script>', 'Path to markdown script')
|
|
14
|
+
.option('-v, --verbose', 'enable verbose mode')
|
|
15
|
+
.option('-q, --quiet', 'suppress any outputs')
|
|
16
|
+
.option('--shell <path>', 'custom shell binary')
|
|
17
|
+
.option('--prefix <command>', 'prefix all commands')
|
|
18
|
+
.option('--postfix <command>', 'postfix all commands')
|
|
19
|
+
.option('--cwd <path>', 'set current directory')
|
|
20
|
+
.option('-s, --sections <headings...>', 'execute only sections under these headings (e.g., "Create a new project")')
|
|
21
|
+
.option('-p, --preprocess-only [file]', 'output preprocessed markdown without executing (optionally to a file)')
|
|
22
|
+
.option('--standalone', 'create .npmrc file after setting directory for standalone npm mode in monorepos')
|
|
23
|
+
.option('-k, --kill-on-complete', 'kill all spawned processes when script completes')
|
|
24
|
+
.action(async (script: string, options: RunMarkdownOptions) => {
|
|
25
|
+
try {
|
|
26
|
+
await runMarkdownFile(script, options);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
program.parse();
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {transformMarkdown} from 'zx/cli';
|
|
2
|
+
import {$, fs, path} from 'zx';
|
|
3
|
+
import {randomBytes} from 'node:crypto';
|
|
4
|
+
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
5
|
+
import {preprocessMarkdown, sanitizeMarkdownForZx} from './preprocessor.js';
|
|
6
|
+
|
|
7
|
+
// Import zx globals to make $, path, fs, etc. available globally
|
|
8
|
+
await import('zx/globals');
|
|
9
|
+
|
|
10
|
+
export interface RunMarkdownOptions {
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
quiet?: boolean;
|
|
13
|
+
shell?: string;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
postfix?: string;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
preferLocal?: boolean;
|
|
18
|
+
sections?: string[]; // Execute only sections under these headings
|
|
19
|
+
preprocessOnly?: boolean | string; // Output preprocessed markdown without executing (optionally to file path)
|
|
20
|
+
standalone?: boolean; // Create .npmrc file after setting directory for standalone npm mode in monorepos
|
|
21
|
+
killOnComplete?: boolean; // Kill all spawned processes when script completes
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Extract sections from markdown based on heading matches
|
|
26
|
+
* Returns only the content under the specified headings
|
|
27
|
+
*/
|
|
28
|
+
function extractSectionsByHeading(markdown: string, sectionHeadings: string[]): string {
|
|
29
|
+
if (!sectionHeadings || sectionHeadings.length === 0) {
|
|
30
|
+
return markdown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const lines = markdown.split('\n');
|
|
34
|
+
const result: string[] = [];
|
|
35
|
+
let inMatchingSection = false;
|
|
36
|
+
let currentSectionLevel = 0;
|
|
37
|
+
let inCodeBlock = false;
|
|
38
|
+
|
|
39
|
+
// Normalize section headings (case-insensitive, trim whitespace)
|
|
40
|
+
const normalizedSectionHeadings = sectionHeadings.map(h => h.trim().toLowerCase());
|
|
41
|
+
const headingRegex = /^(#{1,6})\s+(.+)$/;
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44
|
+
const line = lines[i];
|
|
45
|
+
|
|
46
|
+
// Track code blocks
|
|
47
|
+
if (line.startsWith('```')) {
|
|
48
|
+
inCodeBlock = !inCodeBlock;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Only check for headings when not in a code block
|
|
52
|
+
const match = !inCodeBlock ? line.match(headingRegex) : null;
|
|
53
|
+
|
|
54
|
+
if (match) {
|
|
55
|
+
const level = match[1].length;
|
|
56
|
+
const headingText = match[2].trim().toLowerCase();
|
|
57
|
+
|
|
58
|
+
// Check if this heading matches one of our target headings
|
|
59
|
+
if (normalizedSectionHeadings.includes(headingText)) {
|
|
60
|
+
inMatchingSection = true;
|
|
61
|
+
currentSectionLevel = level;
|
|
62
|
+
result.push(line); // Include the heading itself
|
|
63
|
+
} else if (inMatchingSection) {
|
|
64
|
+
// If we're in a matching section and hit another heading of same or higher level
|
|
65
|
+
// (less # means higher in the hierarchy), exit the section
|
|
66
|
+
if (level <= currentSectionLevel) {
|
|
67
|
+
inMatchingSection = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else if (inMatchingSection) {
|
|
71
|
+
result.push(line);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result.join('\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Run markdown content or file with CLI-like options
|
|
80
|
+
*
|
|
81
|
+
* @param markdown - Markdown content or file path
|
|
82
|
+
* @param options - CLI-like options
|
|
83
|
+
*/
|
|
84
|
+
export async function runMarkdown(markdown: string | Buffer, options: RunMarkdownOptions = {}): Promise<void> {
|
|
85
|
+
// Save current state
|
|
86
|
+
const savedState = {
|
|
87
|
+
verbose: $.verbose,
|
|
88
|
+
quiet: $.quiet,
|
|
89
|
+
shell: $.shell,
|
|
90
|
+
prefix: $.prefix,
|
|
91
|
+
postfix: $.postfix,
|
|
92
|
+
cwd: $.cwd,
|
|
93
|
+
preferLocal: $.preferLocal,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
// Apply options
|
|
98
|
+
if (options.verbose !== undefined) $.verbose = options.verbose;
|
|
99
|
+
if (options.quiet !== undefined) $.quiet = options.quiet;
|
|
100
|
+
if (options.shell) $.shell = options.shell;
|
|
101
|
+
if (options.prefix) $.prefix = options.prefix;
|
|
102
|
+
if (options.postfix) $.postfix = options.postfix;
|
|
103
|
+
if (options.cwd) $.cwd = options.cwd;
|
|
104
|
+
if (options.preferLocal !== undefined) $.preferLocal = options.preferLocal;
|
|
105
|
+
|
|
106
|
+
// Read markdown content if it's a file path
|
|
107
|
+
let markdownContent: string;
|
|
108
|
+
if (typeof markdown === 'string' && (markdown.endsWith('.md') || markdown.includes('\n') === false)) {
|
|
109
|
+
markdownContent = await fs.readFile(markdown, 'utf8');
|
|
110
|
+
} else {
|
|
111
|
+
markdownContent = markdown.toString();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Extract sections if specified
|
|
115
|
+
if (options.sections && options.sections.length > 0) {
|
|
116
|
+
markdownContent = extractSectionsByHeading(markdownContent, options.sections);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Preprocess markdown with ezx enhancements
|
|
120
|
+
const {preprocessedMarkdown, hasAsyncBlocks} = preprocessMarkdown(markdownContent, {
|
|
121
|
+
cwd: options.cwd || process.cwd(),
|
|
122
|
+
standalone: options.standalone,
|
|
123
|
+
killOnComplete: options.killOnComplete,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Sanitize markdown to prevent zx from misinterpreting indented prose as code
|
|
127
|
+
// This handles edge cases like indented code blocks within list items
|
|
128
|
+
const sanitizedMarkdown = sanitizeMarkdownForZx(preprocessedMarkdown);
|
|
129
|
+
|
|
130
|
+
// If preprocessOnly is set, output the preprocessed markdown and return
|
|
131
|
+
if (options.preprocessOnly) {
|
|
132
|
+
if (typeof options.preprocessOnly === 'string') {
|
|
133
|
+
// Write to file
|
|
134
|
+
await fs.writeFile(options.preprocessOnly, sanitizedMarkdown);
|
|
135
|
+
} else {
|
|
136
|
+
// Output to stdout
|
|
137
|
+
console.log(sanitizedMarkdown);
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Transform markdown to JavaScript
|
|
143
|
+
let jsCode = transformMarkdown(sanitizedMarkdown);
|
|
144
|
+
|
|
145
|
+
// Resolve the absolute path to zx/globals using Node's module resolution
|
|
146
|
+
// This will work regardless of where ezx is installed (local, global, or as a dependency)
|
|
147
|
+
const zxGlobalsPath = await import.meta.resolve('zx/globals');
|
|
148
|
+
|
|
149
|
+
// Prepend globals import to make $, fs, path, etc. available in the script context
|
|
150
|
+
// Use the resolved absolute path to ensure zx is found
|
|
151
|
+
let preamble = `await import('${zxGlobalsPath}')\n\n`;
|
|
152
|
+
|
|
153
|
+
// If killOnComplete is enabled and there are async blocks, add process tracking
|
|
154
|
+
if (options.killOnComplete && hasAsyncBlocks) {
|
|
155
|
+
preamble += `const __ezx_async_processes = [];\n\n`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
jsCode = preamble + jsCode;
|
|
159
|
+
|
|
160
|
+
// If killOnComplete is enabled and there are async blocks, add cleanup code
|
|
161
|
+
if (options.killOnComplete && hasAsyncBlocks) {
|
|
162
|
+
jsCode += `\n\n// Kill all async processes on completion\n__ezx_async_processes.forEach(p => p.kill());\n`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Write to temp file in current directory (not tmpdir) so zx can be resolved
|
|
166
|
+
// Node's module resolution looks for package.json starting from the file's directory,
|
|
167
|
+
// so the temp file needs to be in a location that has access to node_modules
|
|
168
|
+
const cwd = options.cwd || process.cwd();
|
|
169
|
+
const tempFile = path.join(cwd, `.ezx-${randomBytes(8).toString('hex')}.mjs`);
|
|
170
|
+
await fs.writeFile(tempFile, jsCode);
|
|
171
|
+
|
|
172
|
+
// Register cleanup handlers for various exit scenarios
|
|
173
|
+
let tempFileCleaned = false;
|
|
174
|
+
const cleanup = async () => {
|
|
175
|
+
if (tempFileCleaned) return;
|
|
176
|
+
tempFileCleaned = true;
|
|
177
|
+
try {
|
|
178
|
+
await fs.rm(tempFile, {force: true});
|
|
179
|
+
} catch {
|
|
180
|
+
// Ignore cleanup errors
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Ensure cleanup on normal exit, uncaught errors, and signals
|
|
185
|
+
process.on('exit', cleanup);
|
|
186
|
+
process.on('uncaughtException', cleanup);
|
|
187
|
+
process.on('SIGINT', cleanup);
|
|
188
|
+
process.on('SIGTERM', cleanup);
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
// Import and execute the transformed code (same as CLI)
|
|
192
|
+
await import(pathToFileURL(tempFile).toString());
|
|
193
|
+
} finally {
|
|
194
|
+
// Clean up temp file and remove event listeners
|
|
195
|
+
await cleanup();
|
|
196
|
+
process.off('exit', cleanup);
|
|
197
|
+
process.off('uncaughtException', cleanup);
|
|
198
|
+
process.off('SIGINT', cleanup);
|
|
199
|
+
process.off('SIGTERM', cleanup);
|
|
200
|
+
}
|
|
201
|
+
} finally {
|
|
202
|
+
// Restore state
|
|
203
|
+
Object.assign($, savedState);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Run a markdown file from disk
|
|
209
|
+
*
|
|
210
|
+
* @param filePath - Path to markdown file
|
|
211
|
+
* @param options - CLI-like options
|
|
212
|
+
*/
|
|
213
|
+
export async function runMarkdownFile(filePath: string, options: RunMarkdownOptions = {}): Promise<void> {
|
|
214
|
+
return runMarkdown(filePath, options);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Run markdown content directly
|
|
219
|
+
*
|
|
220
|
+
* @param markdownContent - Markdown content as string
|
|
221
|
+
* @param options - CLI-like options
|
|
222
|
+
*/
|
|
223
|
+
export async function runMarkdownContent(markdownContent: string, options: RunMarkdownOptions = {}): Promise<void> {
|
|
224
|
+
return runMarkdown(markdownContent, options);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Re-export everything from zx for convenience
|
|
228
|
+
export * from 'zx';
|
|
229
|
+
|
|
230
|
+
// Export preprocessor functions
|
|
231
|
+
export * from './preprocessor.js';
|
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import {readFileSync} from 'node:fs';
|
|
2
|
+
import {marked, Lexer} from 'marked';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Directive types supported in blockquotes
|
|
6
|
+
*/
|
|
7
|
+
export type DirectiveType = 'file' | 'async';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parsed directive from a blockquote line
|
|
11
|
+
*/
|
|
12
|
+
export interface Directive {
|
|
13
|
+
type: DirectiveType;
|
|
14
|
+
value: string; // file path for 'file', description for 'async'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CodeBlock {
|
|
18
|
+
language: string;
|
|
19
|
+
content: string;
|
|
20
|
+
startLine: number;
|
|
21
|
+
endLine: number;
|
|
22
|
+
filePath?: string; // File path from file: directive
|
|
23
|
+
isAsync?: boolean; // Whether this is an async block from async: directive
|
|
24
|
+
asyncDescription?: string; // Optional description from async: directive
|
|
25
|
+
precedingBlockquoteLine?: number; // Line number of the blockquote with directive
|
|
26
|
+
sleepSeconds?: number; // Sleep duration from sleep:N modifier
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FileExtraction {
|
|
30
|
+
filePath: string;
|
|
31
|
+
content: string;
|
|
32
|
+
language: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PreprocessResult {
|
|
36
|
+
preprocessedMarkdown: string;
|
|
37
|
+
extractedFiles: FileExtraction[];
|
|
38
|
+
hasAsyncBlocks: boolean; // Whether the markdown contains async blocks
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Information about a block that will be transformed to a heredoc
|
|
43
|
+
*/
|
|
44
|
+
interface HeredocTransform {
|
|
45
|
+
filePath: string;
|
|
46
|
+
content: string;
|
|
47
|
+
directoryPrefix?: string; // Optional cd prefix for unified directory context
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Information about a block that will be transformed to async JS
|
|
52
|
+
*/
|
|
53
|
+
interface AsyncTransform {
|
|
54
|
+
content: string;
|
|
55
|
+
directoryPrefix?: string; // Optional cd prefix for unified directory context
|
|
56
|
+
description?: string; // Optional description for documentation
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sanitize markdown to prevent zx's parser from misinterpreting
|
|
62
|
+
* indented prose as code blocks.
|
|
63
|
+
*
|
|
64
|
+
* zx treats lines starting with 2+ spaces after an empty line as code.
|
|
65
|
+
* We use marked to identify actual code blocks and rebuild the markdown
|
|
66
|
+
* with only headings and code blocks (stripping all prose).
|
|
67
|
+
*
|
|
68
|
+
* This also handles the edge case of indented code blocks within list items
|
|
69
|
+
* (e.g., " ```bash" within a list), which zx's regex parser cannot handle.
|
|
70
|
+
*/
|
|
71
|
+
export function sanitizeMarkdownForZx(markdown: string): string {
|
|
72
|
+
const tokens = Lexer.lex(markdown);
|
|
73
|
+
const output: string[] = [];
|
|
74
|
+
|
|
75
|
+
// Recursively process tokens to extract code blocks and headings
|
|
76
|
+
function processTokens(tokenArray: any[], depth: number = 0) {
|
|
77
|
+
for (const token of tokenArray) {
|
|
78
|
+
if (token.type === 'code') {
|
|
79
|
+
// Keep fenced code blocks - marked handles indentation correctly
|
|
80
|
+
// Remove bracketed modifiers like [npm], [pnpm], etc. but preserve zx's modifiers like skip
|
|
81
|
+
// zx doesn't understand bracketed modifiers and will skip code blocks with them
|
|
82
|
+
const langTag = token.lang || '';
|
|
83
|
+
// Remove bracketed modifiers using regex to match [anything]
|
|
84
|
+
const cleanLangTag = langTag.replace(/\s*\[.*?\]\s*/g, ' ').trim();
|
|
85
|
+
const fence = '```';
|
|
86
|
+
output.push(`${fence}${cleanLangTag}`);
|
|
87
|
+
output.push(token.text);
|
|
88
|
+
output.push(fence);
|
|
89
|
+
output.push(''); // Empty line after for readability
|
|
90
|
+
} else if (token.type === 'heading') {
|
|
91
|
+
// Keep headings (useful for section extraction in ezx)
|
|
92
|
+
output.push(`${'#'.repeat(token.depth)} ${token.text}`);
|
|
93
|
+
output.push('');
|
|
94
|
+
} else if (token.type === 'list' && token.items) {
|
|
95
|
+
// Process list items to find nested code blocks
|
|
96
|
+
for (const item of token.items) {
|
|
97
|
+
if (item.tokens) {
|
|
98
|
+
processTokens(item.tokens, depth + 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Other content (paragraphs, lists, blockquotes, etc.) is dropped
|
|
103
|
+
// since it's not executable and could confuse zx's parser
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
processTokens(tokens);
|
|
108
|
+
|
|
109
|
+
return output.join('\n');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Check if a language is a bash/shell language
|
|
114
|
+
*/
|
|
115
|
+
function isBashLanguage(language: string): boolean {
|
|
116
|
+
const lang = language.toLowerCase();
|
|
117
|
+
return lang === 'bash' || lang === 'sh' || lang === 'shell';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Parse language tag and extract modifiers
|
|
122
|
+
* e.g., "bash sleep:3 skip" -> { language: "bash", languageTag: "bash skip", sleepSeconds: 3 }
|
|
123
|
+
* e.g., "bash [npm] skip" -> { language: "bash", languageTag: "bash skip", sleepSeconds: undefined }
|
|
124
|
+
* The languageTag has sleep:N and bracketed modifiers like [npm] removed, but preserves zx's modifiers like skip
|
|
125
|
+
*/
|
|
126
|
+
function parseLanguageTag(langTag: string): { language: string; languageTag: string; sleepSeconds?: number } {
|
|
127
|
+
const parts = langTag.trim().split(/\s+/);
|
|
128
|
+
const language = parts[0] || '';
|
|
129
|
+
let sleepSeconds: number | undefined;
|
|
130
|
+
const otherModifiers: string[] = [];
|
|
131
|
+
|
|
132
|
+
for (let i = 1; i < parts.length; i++) {
|
|
133
|
+
const part = parts[i];
|
|
134
|
+
const sleepMatch = part.match(/^sleep:(\d+)$/i);
|
|
135
|
+
if (sleepMatch) {
|
|
136
|
+
sleepSeconds = parseInt(sleepMatch[1], 10);
|
|
137
|
+
} else if (part.match(/^\[.*?\]$/)) {
|
|
138
|
+
// Skip bracketed modifiers like [npm], [pnpm], etc.
|
|
139
|
+
// These are not understood by zx and cause code blocks to be skipped
|
|
140
|
+
continue;
|
|
141
|
+
} else {
|
|
142
|
+
// Preserve other modifiers like 'skip'
|
|
143
|
+
otherModifiers.push(part);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Build language tag without sleep:N and bracketed modifiers
|
|
148
|
+
const languageTag = [language, ...otherModifiers].join(' ');
|
|
149
|
+
|
|
150
|
+
return { language, languageTag, sleepSeconds };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Extract directive from a blockquote line
|
|
155
|
+
*
|
|
156
|
+
* Supports:
|
|
157
|
+
* - file: directive: > file: `path/to/file.json` or > file: path/to/file.json
|
|
158
|
+
* - async: directive: > async: `description` or > async: description or > async:
|
|
159
|
+
*
|
|
160
|
+
* Note: The old syntax `> `filename`` without a directive prefix is NO LONGER supported.
|
|
161
|
+
* This is a breaking change - use `> file: `filename`` instead.
|
|
162
|
+
*/
|
|
163
|
+
function extractDirectiveFromBlockquote(line: string): Directive | null {
|
|
164
|
+
const trimmed = line.trim();
|
|
165
|
+
|
|
166
|
+
// Match file: directive with optional backticks
|
|
167
|
+
// e.g., > file: `package.json` or > file: package.json
|
|
168
|
+
const fileMatch = trimmed.match(/^>\s*file:\s*(?:`([^`]+)`|(\S.*?))\s*$/i);
|
|
169
|
+
if (fileMatch) {
|
|
170
|
+
const value = (fileMatch[1] || fileMatch[2] || '').trim();
|
|
171
|
+
if (!value) {
|
|
172
|
+
return null; // file: requires a path
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
type: 'file',
|
|
176
|
+
value,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Match async: directive with optional backticks
|
|
181
|
+
// e.g., > async: `start server` or > async: start server or > async:
|
|
182
|
+
const asyncMatch = trimmed.match(/^>\s*async:\s*(?:`([^`]*)`|(.*))?\s*$/i);
|
|
183
|
+
if (asyncMatch) {
|
|
184
|
+
return {
|
|
185
|
+
type: 'async',
|
|
186
|
+
value: (asyncMatch[1] || asyncMatch[2] || '').trim(),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Parse markdown and extract all code blocks with their line numbers
|
|
195
|
+
* Also extracts directives (file: or async:) from preceding blockquote if present
|
|
196
|
+
*/
|
|
197
|
+
function parseCodeBlocks(markdown: string): CodeBlock[] {
|
|
198
|
+
const codeBlocks: CodeBlock[] = [];
|
|
199
|
+
const lines = markdown.split('\n');
|
|
200
|
+
let inCodeBlock = false;
|
|
201
|
+
let currentBlock: Partial<CodeBlock> = {};
|
|
202
|
+
let blockStartLine = 0;
|
|
203
|
+
let precedingBlockquoteLine: number | undefined;
|
|
204
|
+
let pendingDirective: Directive | undefined;
|
|
205
|
+
|
|
206
|
+
for (let i = 0; i < lines.length; i++) {
|
|
207
|
+
const line = lines[i];
|
|
208
|
+
|
|
209
|
+
// Check for code block start (including indented code blocks in list items)
|
|
210
|
+
if (line.match(/^\s*```/)) {
|
|
211
|
+
if (!inCodeBlock) {
|
|
212
|
+
// Starting a new code block - extract full language tag including modifiers
|
|
213
|
+
const languageMatch = line.match(/^\s*```(.*)$/);
|
|
214
|
+
const fullLangTag = languageMatch?.[1] || '';
|
|
215
|
+
const { language, languageTag, sleepSeconds } = parseLanguageTag(fullLangTag);
|
|
216
|
+
|
|
217
|
+
// Validate async directive is only used with bash blocks
|
|
218
|
+
if (pendingDirective?.type === 'async' && !isBashLanguage(language)) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
`[ezx] async: directive error at line ${(precedingBlockquoteLine ?? 0) + 1}\n` +
|
|
221
|
+
`The async: directive can only be used with bash, sh, or shell code blocks.\n` +
|
|
222
|
+
`Found: \`\`\`${language || '(no language specified)'}\n` +
|
|
223
|
+
`\n` +
|
|
224
|
+
`To fix this, either:\n` +
|
|
225
|
+
`1. Change the code block language to bash, sh, or shell\n` +
|
|
226
|
+
`2. Remove the async: directive from the preceding blockquote`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
currentBlock = {
|
|
231
|
+
language,
|
|
232
|
+
filePath: pendingDirective?.type === 'file' ? pendingDirective.value : undefined,
|
|
233
|
+
isAsync: pendingDirective?.type === 'async',
|
|
234
|
+
asyncDescription: pendingDirective?.type === 'async' ? pendingDirective.value : undefined,
|
|
235
|
+
precedingBlockquoteLine: precedingBlockquoteLine,
|
|
236
|
+
sleepSeconds,
|
|
237
|
+
content: '',
|
|
238
|
+
startLine: i,
|
|
239
|
+
};
|
|
240
|
+
inCodeBlock = true;
|
|
241
|
+
blockStartLine = i;
|
|
242
|
+
precedingBlockquoteLine = undefined;
|
|
243
|
+
pendingDirective = undefined; // Reset for next block
|
|
244
|
+
} else {
|
|
245
|
+
// Ending the current code block
|
|
246
|
+
if (
|
|
247
|
+
currentBlock.language !== undefined &&
|
|
248
|
+
currentBlock.content !== undefined &&
|
|
249
|
+
currentBlock.startLine !== undefined
|
|
250
|
+
) {
|
|
251
|
+
codeBlocks.push({
|
|
252
|
+
language: currentBlock.language,
|
|
253
|
+
content: currentBlock.content,
|
|
254
|
+
startLine: currentBlock.startLine,
|
|
255
|
+
endLine: i,
|
|
256
|
+
filePath: currentBlock.filePath,
|
|
257
|
+
isAsync: currentBlock.isAsync,
|
|
258
|
+
asyncDescription: currentBlock.asyncDescription,
|
|
259
|
+
precedingBlockquoteLine: currentBlock.precedingBlockquoteLine,
|
|
260
|
+
sleepSeconds: currentBlock.sleepSeconds,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
inCodeBlock = false;
|
|
264
|
+
currentBlock = {};
|
|
265
|
+
}
|
|
266
|
+
} else if (!inCodeBlock) {
|
|
267
|
+
// Look for blockquote with directive (only outside code blocks)
|
|
268
|
+
const directive = extractDirectiveFromBlockquote(line);
|
|
269
|
+
if (directive) {
|
|
270
|
+
precedingBlockquoteLine = i;
|
|
271
|
+
pendingDirective = directive;
|
|
272
|
+
}
|
|
273
|
+
} else if (inCodeBlock && currentBlock.content !== undefined) {
|
|
274
|
+
// Add line to current block content
|
|
275
|
+
currentBlock.content += (currentBlock.content ? '\n' : '') + line;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return codeBlocks;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Check if a line contains a directory set command
|
|
284
|
+
*/
|
|
285
|
+
function isDirectorySetCommand(line: string): boolean {
|
|
286
|
+
const trimmed = line.trim().toLowerCase();
|
|
287
|
+
return trimmed === '# set the current directory';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Preprocess markdown file
|
|
293
|
+
*/
|
|
294
|
+
export function preprocessMarkdown(
|
|
295
|
+
input: string,
|
|
296
|
+
options: {cwd?: string; standalone?: boolean; killOnComplete?: boolean} = {},
|
|
297
|
+
): PreprocessResult {
|
|
298
|
+
const {cwd = process.cwd(), standalone = false, killOnComplete = false} = options;
|
|
299
|
+
const lines = input.split('\n');
|
|
300
|
+
const codeBlocks = parseCodeBlocks(input);
|
|
301
|
+
const extractedFiles: FileExtraction[] = [];
|
|
302
|
+
|
|
303
|
+
// Track the current directory context
|
|
304
|
+
let currentDirectory: string | null = null;
|
|
305
|
+
|
|
306
|
+
// Map of block indices to transformations (prepend cd)
|
|
307
|
+
const blocksToTransform: Map<number, string> = new Map();
|
|
308
|
+
// Map of block indices to transform to heredoc
|
|
309
|
+
const blocksToHeredoc: Map<number, HeredocTransform> = new Map();
|
|
310
|
+
// Map of block indices to transform to async JS
|
|
311
|
+
const blocksToAsync: Map<number, AsyncTransform> = new Map();
|
|
312
|
+
// Track where we need to insert .npmrc after directory set
|
|
313
|
+
const npmrcInsertBlocks: Set<number> = new Set();
|
|
314
|
+
|
|
315
|
+
// Process each code block
|
|
316
|
+
for (let i = 0; i < codeBlocks.length; i++) {
|
|
317
|
+
const block = codeBlocks[i];
|
|
318
|
+
const isBash = isBashLanguage(block.language);
|
|
319
|
+
|
|
320
|
+
// Check if this is an async block
|
|
321
|
+
if (block.isAsync) {
|
|
322
|
+
// Transform to async JS block
|
|
323
|
+
blocksToAsync.set(i, {
|
|
324
|
+
content: block.content.trim(),
|
|
325
|
+
directoryPrefix: currentDirectory || undefined,
|
|
326
|
+
description: block.asyncDescription,
|
|
327
|
+
});
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Check if this is a file extraction block (file path from file: directive)
|
|
332
|
+
if (block.filePath) {
|
|
333
|
+
// This is a file extraction block - transform to heredoc
|
|
334
|
+
const fileContent = block.content.trim();
|
|
335
|
+
extractedFiles.push({
|
|
336
|
+
filePath: block.filePath,
|
|
337
|
+
content: fileContent,
|
|
338
|
+
language: block.language,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// Mark this block for transformation to heredoc
|
|
342
|
+
// If we have a current directory, prepend it to the heredoc command
|
|
343
|
+
blocksToHeredoc.set(i, {
|
|
344
|
+
filePath: block.filePath,
|
|
345
|
+
content: fileContent,
|
|
346
|
+
directoryPrefix: currentDirectory || undefined,
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Check for directory set command in bash blocks
|
|
353
|
+
if (isBash) {
|
|
354
|
+
const blockLines = block.content.split('\n');
|
|
355
|
+
let justSetDirectory = false;
|
|
356
|
+
|
|
357
|
+
// First, check if this block has a directory set command
|
|
358
|
+
const hasDirectorySet = blockLines.some((line) => isDirectorySetCommand(line));
|
|
359
|
+
|
|
360
|
+
if (hasDirectorySet) {
|
|
361
|
+
// If we have a current directory from a PREVIOUS block, prepend cd to this block
|
|
362
|
+
// This ensures the cd command in this block is relative to the current virtual directory
|
|
363
|
+
if (currentDirectory) {
|
|
364
|
+
blocksToTransform.set(i, currentDirectory);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
for (let j = 0; j < blockLines.length; j++) {
|
|
368
|
+
const line = blockLines[j];
|
|
369
|
+
if (isDirectorySetCommand(line)) {
|
|
370
|
+
// Found directory set command, now look for the next cd command
|
|
371
|
+
for (let k = j + 1; k < blockLines.length; k++) {
|
|
372
|
+
const lineAfter = blockLines[k];
|
|
373
|
+
const cdMatch = lineAfter.match(/^\s*cd\s+(.+)$/);
|
|
374
|
+
if (cdMatch) {
|
|
375
|
+
// The cd command will execute relative to the prepended virtual directory
|
|
376
|
+
const newPath = cdMatch[1].trim();
|
|
377
|
+
// Update the virtual directory context
|
|
378
|
+
if (currentDirectory) {
|
|
379
|
+
currentDirectory = `${currentDirectory}/${newPath}`;
|
|
380
|
+
} else {
|
|
381
|
+
currentDirectory = newPath;
|
|
382
|
+
}
|
|
383
|
+
justSetDirectory = true;
|
|
384
|
+
// If standalone mode is enabled, mark this block for .npmrc insertion
|
|
385
|
+
if (standalone) {
|
|
386
|
+
npmrcInsertBlocks.add(i);
|
|
387
|
+
}
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// If we have a current directory from a PREVIOUS block, prepend cd to this bash block
|
|
397
|
+
// Only prepend if this is NOT the block where we just set the directory (we already did above)
|
|
398
|
+
if (currentDirectory && !justSetDirectory) {
|
|
399
|
+
blocksToTransform.set(i, currentDirectory);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// Build preprocessed markdown
|
|
405
|
+
const preprocessedLines: string[] = [];
|
|
406
|
+
// Track lines to skip (blockquote lines that contained directives)
|
|
407
|
+
const linesToSkip = new Set<number>();
|
|
408
|
+
for (const block of codeBlocks) {
|
|
409
|
+
if (block.precedingBlockquoteLine !== undefined && (block.filePath || block.isAsync)) {
|
|
410
|
+
linesToSkip.add(block.precedingBlockquoteLine);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
for (let i = 0; i < lines.length; i++) {
|
|
415
|
+
const line = lines[i];
|
|
416
|
+
|
|
417
|
+
// Skip blockquote lines that contained directives (they were consumed)
|
|
418
|
+
if (linesToSkip.has(i)) {
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Check if this is the start of a code block (including indented code blocks in list items)
|
|
423
|
+
if (line.match(/^\s*```/)) {
|
|
424
|
+
const blockIndex = codeBlocks.findIndex((b) => b.startLine === i);
|
|
425
|
+
|
|
426
|
+
if (blockIndex !== -1) {
|
|
427
|
+
const block = codeBlocks[blockIndex];
|
|
428
|
+
|
|
429
|
+
// Check if this block should be transformed to async JS
|
|
430
|
+
if (blocksToAsync.has(blockIndex)) {
|
|
431
|
+
const asyncBlock = blocksToAsync.get(blockIndex)!;
|
|
432
|
+
// Transform to JS block with $ template literal
|
|
433
|
+
preprocessedLines.push('```js');
|
|
434
|
+
|
|
435
|
+
// Join multiple lines with ; to execute as a single command chain
|
|
436
|
+
// Filter out empty lines and comments that start with #
|
|
437
|
+
const commandLines = asyncBlock.content
|
|
438
|
+
.split('\n')
|
|
439
|
+
.map(line => line.trim())
|
|
440
|
+
.filter(line => line && !line.startsWith('#'));
|
|
441
|
+
let command = commandLines.join('; ');
|
|
442
|
+
|
|
443
|
+
// Add cd prefix if we have a directory context
|
|
444
|
+
if (asyncBlock.directoryPrefix) {
|
|
445
|
+
command = `cd ${asyncBlock.directoryPrefix} && ${command}`;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Escape backticks in the command for the template literal
|
|
449
|
+
const escapedCommand = command.replace(/`/g, '\\`');
|
|
450
|
+
|
|
451
|
+
// Output the $ template literal (fire-and-forget, no await)
|
|
452
|
+
// If killOnComplete is enabled, push to tracking array so we can kill it later
|
|
453
|
+
if (killOnComplete) {
|
|
454
|
+
preprocessedLines.push(`__ezx_async_processes.push($\`${escapedCommand}\`)`);
|
|
455
|
+
} else {
|
|
456
|
+
// zx will await all pending promises at the end
|
|
457
|
+
preprocessedLines.push(`$\`${escapedCommand}\``);
|
|
458
|
+
}
|
|
459
|
+
preprocessedLines.push('```');
|
|
460
|
+
// Skip to the closing ```
|
|
461
|
+
i = block.endLine;
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Check if this block should be transformed to heredoc
|
|
466
|
+
if (blocksToHeredoc.has(blockIndex)) {
|
|
467
|
+
const heredoc = blocksToHeredoc.get(blockIndex)!;
|
|
468
|
+
// Transform to bash heredoc block
|
|
469
|
+
preprocessedLines.push('```bash');
|
|
470
|
+
// If we have a directory prefix, prepend cd && to the cat command
|
|
471
|
+
// Also strip the directory prefix from the file path if it matches
|
|
472
|
+
let catPath = heredoc.filePath;
|
|
473
|
+
if (heredoc.directoryPrefix) {
|
|
474
|
+
// Remove the directory prefix from the file path if it starts with it
|
|
475
|
+
if (catPath.startsWith(heredoc.directoryPrefix + '/')) {
|
|
476
|
+
catPath = catPath.slice(heredoc.directoryPrefix.length + 1);
|
|
477
|
+
}
|
|
478
|
+
preprocessedLines.push(`cd ${heredoc.directoryPrefix} && cat > '${catPath}' << 'EZXEOF'`);
|
|
479
|
+
} else {
|
|
480
|
+
preprocessedLines.push(`cat > '${catPath}' << 'EZXEOF'`);
|
|
481
|
+
}
|
|
482
|
+
preprocessedLines.push(heredoc.content);
|
|
483
|
+
preprocessedLines.push('EZXEOF');
|
|
484
|
+
preprocessedLines.push('```');
|
|
485
|
+
// Skip to the closing ```
|
|
486
|
+
i = block.endLine;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Output the opening ``` line (strip only sleep:N, preserve other modifiers like skip)
|
|
491
|
+
// We need to get the languageTag from the original line since block.language is just the base language
|
|
492
|
+
const origLangMatch = line.match(/^\s*```(.*)$/);
|
|
493
|
+
const origFullTag = origLangMatch?.[1] || '';
|
|
494
|
+
const { languageTag } = parseLanguageTag(origFullTag);
|
|
495
|
+
preprocessedLines.push(`\`\`\`${languageTag}`);
|
|
496
|
+
|
|
497
|
+
// Check if we need to prepend sleep command (only for bash blocks)
|
|
498
|
+
if (block.sleepSeconds && isBashLanguage(block.language)) {
|
|
499
|
+
preprocessedLines.push(`sleep ${block.sleepSeconds}`);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Check if we need to prepend cd command
|
|
503
|
+
if (blocksToTransform.has(blockIndex)) {
|
|
504
|
+
const dir = blocksToTransform.get(blockIndex)!;
|
|
505
|
+
preprocessedLines.push(`cd ${dir}`);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Output the block content
|
|
509
|
+
if (block.content) {
|
|
510
|
+
preprocessedLines.push(block.content);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// If standalone mode is enabled and this block set the directory, append .npmrc creation
|
|
514
|
+
if (npmrcInsertBlocks.has(blockIndex)) {
|
|
515
|
+
preprocessedLines.push('');
|
|
516
|
+
preprocessedLines.push('cat > .npmrc << \'EZXEOF\'');
|
|
517
|
+
preprocessedLines.push('# Disable workspace awareness for test project');
|
|
518
|
+
preprocessedLines.push('# This ensures that pnpm install and other commands work in standalone mode');
|
|
519
|
+
preprocessedLines.push('enable-pre-post-scripts=true');
|
|
520
|
+
preprocessedLines.push('shamefully-hoist=false');
|
|
521
|
+
preprocessedLines.push('strict-peer-dependencies=false');
|
|
522
|
+
preprocessedLines.push('EZXEOF');
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Skip to the closing ```
|
|
526
|
+
i = block.endLine - 1;
|
|
527
|
+
} else {
|
|
528
|
+
// This is a closing ``` we've already processed
|
|
529
|
+
preprocessedLines.push(line);
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
// Regular line
|
|
533
|
+
preprocessedLines.push(line);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Check if there are any async blocks
|
|
538
|
+
const hasAsyncBlocks = blocksToAsync.size > 0;
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
preprocessedMarkdown: preprocessedLines.join('\n'),
|
|
542
|
+
extractedFiles,
|
|
543
|
+
hasAsyncBlocks,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Read and preprocess a markdown file
|
|
549
|
+
*/
|
|
550
|
+
export function preprocessFile(
|
|
551
|
+
filePath: string,
|
|
552
|
+
options: {cwd?: string} = {},
|
|
553
|
+
): PreprocessResult {
|
|
554
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
555
|
+
return preprocessMarkdown(content, options);
|
|
556
|
+
}
|