ezx 0.0.0 → 0.0.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/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -0
- package/dist/preprocessor.d.ts +30 -0
- package/dist/preprocessor.d.ts.map +1 -0
- package/dist/preprocessor.js +268 -0
- package/dist/preprocessor.js.map +1 -0
- package/package.json +62 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Ronan Sandford
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# ezx - Enhanced zx
|
|
2
|
+
|
|
3
|
+
An enhanced version of zx with markdown preprocessing features to solve common annoyances when writing shell scripts in markdown.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### 1. Directory Context Persistence
|
|
8
|
+
|
|
9
|
+
In standard zx, each bash code block runs in a fresh context, so `cd` commands don't persist across blocks. ezx solves this with a special comment syntax:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# set the current directory
|
|
13
|
+
mkdir -p my-project
|
|
14
|
+
cd my-project
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
All subsequent bash blocks will automatically prepend `cd my-project`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
echo "We're still in my-project!"
|
|
21
|
+
pwd
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. File Extraction
|
|
25
|
+
|
|
26
|
+
Extract code blocks to files using language-specific comment syntax:
|
|
27
|
+
|
|
28
|
+
**TypeScript/JavaScript:**
|
|
29
|
+
```typescript
|
|
30
|
+
// file: package.json
|
|
31
|
+
{
|
|
32
|
+
"name": "my-project",
|
|
33
|
+
"version": "1.0.0"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Bash/Shell:**
|
|
38
|
+
```bash
|
|
39
|
+
# file: .npmrc
|
|
40
|
+
shared-workspace-lockfile=false
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Markdown:**
|
|
44
|
+
```markdown
|
|
45
|
+
<!-- file: README.md -->
|
|
46
|
+
# My Project
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Supported languages include: typescript, javascript, js, ts, bash, sh, shell, python, ruby, go, rust, java, sql, html, xml, and more.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install ezx
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### CLI Usage
|
|
60
|
+
|
|
61
|
+
Run markdown scripts with ezx enhancements:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
ezx script.md
|
|
65
|
+
ezx --verbose script.md
|
|
66
|
+
ezx --shell=/bin/bash script.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Programmatic Usage
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { runMarkdownFile, runMarkdownContent } from 'ezx'
|
|
73
|
+
|
|
74
|
+
// Run markdown file
|
|
75
|
+
await runMarkdownFile('./script.md', { verbose: true })
|
|
76
|
+
|
|
77
|
+
// Run markdown content directly
|
|
78
|
+
await runMarkdownContent(`
|
|
79
|
+
\`\`\`bash
|
|
80
|
+
# set the current directory
|
|
81
|
+
mkdir -p my-project
|
|
82
|
+
cd my-project
|
|
83
|
+
\`\`\`
|
|
84
|
+
|
|
85
|
+
\`\`\`bash
|
|
86
|
+
echo "Still in my-project!"
|
|
87
|
+
\`\`\`
|
|
88
|
+
`, { verbose: true })
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Preprocessor API
|
|
92
|
+
|
|
93
|
+
You can also use the preprocessor directly:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { preprocessMarkdown, preprocessFile } from 'ezx'
|
|
97
|
+
|
|
98
|
+
// Preprocess markdown content
|
|
99
|
+
const { preprocessedMarkdown, extractedFiles } = preprocessMarkdown(markdown)
|
|
100
|
+
|
|
101
|
+
// Preprocess markdown file with auto-extraction
|
|
102
|
+
const result = preprocessFile('./script.md', {
|
|
103
|
+
outputFiles: true, // Write files to disk
|
|
104
|
+
cwd: process.cwd()
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Example
|
|
109
|
+
|
|
110
|
+
Here's a complete example showing both features:
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
# Setup a new project
|
|
114
|
+
|
|
115
|
+
\`\`\`bash
|
|
116
|
+
# set the current directory
|
|
117
|
+
mkdir -p my-app
|
|
118
|
+
cd my-app
|
|
119
|
+
npm init -y
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
\`\`\`typescript
|
|
123
|
+
// file: package.json
|
|
124
|
+
{
|
|
125
|
+
"name": "my-app",
|
|
126
|
+
"version": "1.0.0",
|
|
127
|
+
"scripts": {
|
|
128
|
+
"start": "node index.js"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
\`\`\`typescript
|
|
134
|
+
// file: index.ts
|
|
135
|
+
console.log('Hello from ezx!')
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
\`\`\`bash
|
|
139
|
+
npm install
|
|
140
|
+
npm start
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
\`\`\`bash
|
|
144
|
+
cd ..
|
|
145
|
+
rm -rf my-app
|
|
146
|
+
\`\`\`
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## API Reference
|
|
150
|
+
|
|
151
|
+
### `runMarkdown(markdown, options)`
|
|
152
|
+
|
|
153
|
+
Run markdown content or file with CLI-like options.
|
|
154
|
+
|
|
155
|
+
**Parameters:**
|
|
156
|
+
- `markdown` (string | Buffer) - Markdown content or file path
|
|
157
|
+
- `options` (RunMarkdownOptions) - CLI-like options
|
|
158
|
+
|
|
159
|
+
**Options:**
|
|
160
|
+
- `verbose` (boolean) - Enable verbose mode
|
|
161
|
+
- `quiet` (boolean) - Suppress output
|
|
162
|
+
- `shell` (string) - Custom shell binary
|
|
163
|
+
- `prefix` (string) - Prefix all commands
|
|
164
|
+
- `postfix` (string) - Postfix all commands
|
|
165
|
+
- `cwd` (string) - Current working directory
|
|
166
|
+
- `preferLocal` (boolean) - Prefer locally installed packages
|
|
167
|
+
|
|
168
|
+
### `runMarkdownFile(filePath, options)`
|
|
169
|
+
|
|
170
|
+
Convenience function to run a markdown file from disk.
|
|
171
|
+
|
|
172
|
+
### `runMarkdownContent(markdownContent, options)`
|
|
173
|
+
|
|
174
|
+
Convenience function to run markdown content directly as a string.
|
|
175
|
+
|
|
176
|
+
### `preprocessMarkdown(input, options)`
|
|
177
|
+
|
|
178
|
+
Preprocess markdown content.
|
|
179
|
+
|
|
180
|
+
**Parameters:**
|
|
181
|
+
- `input` (string) - Markdown content
|
|
182
|
+
- `options` (object)
|
|
183
|
+
- `outputFiles` (boolean) - Write extracted files to disk
|
|
184
|
+
- `cwd` (string) - Current working directory
|
|
185
|
+
|
|
186
|
+
**Returns:** PreprocessResult
|
|
187
|
+
- `preprocessedMarkdown` (string) - The preprocessed markdown
|
|
188
|
+
- `extractedFiles` (FileExtraction[]) - Array of extracted files
|
|
189
|
+
|
|
190
|
+
### `preprocessFile(filePath, options)`
|
|
191
|
+
|
|
192
|
+
Read and preprocess a markdown file.
|
|
193
|
+
|
|
194
|
+
## Development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Install dependencies
|
|
198
|
+
npm install
|
|
199
|
+
|
|
200
|
+
# Build
|
|
201
|
+
npm run build
|
|
202
|
+
|
|
203
|
+
# Watch mode
|
|
204
|
+
npm run dev
|
|
205
|
+
|
|
206
|
+
# Run tests
|
|
207
|
+
node dist/cli.js test-preprocessor.md --verbose
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
Apache-2.0
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { runMarkdownFile } from './index.js';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
program
|
|
6
|
+
.name('ezx')
|
|
7
|
+
.description('Enhanced zx - A tool for writing better scripts with markdown support')
|
|
8
|
+
.version('0.0.0')
|
|
9
|
+
.argument('<script>', 'Path to markdown script')
|
|
10
|
+
.option('-v, --verbose', 'enable verbose mode')
|
|
11
|
+
.option('-q, --quiet', 'suppress any outputs')
|
|
12
|
+
.option('--shell <path>', 'custom shell binary')
|
|
13
|
+
.option('--prefix <command>', 'prefix all commands')
|
|
14
|
+
.option('--postfix <command>', 'postfix all commands')
|
|
15
|
+
.option('--cwd <path>', 'set current directory')
|
|
16
|
+
.action(async (script, options) => {
|
|
17
|
+
try {
|
|
18
|
+
await runMarkdownFile(script, options);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
program.parse();
|
|
26
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +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;AAEpE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACL,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,uEAAuE,CAAC;KACpF,OAAO,CAAC,OAAO,CAAC;KAChB,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,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
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface RunMarkdownOptions {
|
|
2
|
+
verbose?: boolean;
|
|
3
|
+
quiet?: boolean;
|
|
4
|
+
shell?: string;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
postfix?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
preferLocal?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Run markdown content or file with CLI-like options
|
|
12
|
+
*
|
|
13
|
+
* @param markdown - Markdown content or file path
|
|
14
|
+
* @param options - CLI-like options
|
|
15
|
+
*/
|
|
16
|
+
export declare function runMarkdown(markdown: string | Buffer, options?: RunMarkdownOptions): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Run a markdown file from disk
|
|
19
|
+
*
|
|
20
|
+
* @param filePath - Path to markdown file
|
|
21
|
+
* @param options - CLI-like options
|
|
22
|
+
*/
|
|
23
|
+
export declare function runMarkdownFile(filePath: string, options?: RunMarkdownOptions): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Run markdown content directly
|
|
26
|
+
*
|
|
27
|
+
* @param markdownContent - Markdown content as string
|
|
28
|
+
* @param options - CLI-like options
|
|
29
|
+
*/
|
|
30
|
+
export declare function runMarkdownContent(markdownContent: string, options?: RunMarkdownOptions): Promise<void>;
|
|
31
|
+
export * from 'zx';
|
|
32
|
+
export * from './preprocessor.js';
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgE5G;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
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { transformMarkdown } from 'zx/cli';
|
|
2
|
+
import { $, fs, path } from 'zx';
|
|
3
|
+
import { randomBytes } from 'node:crypto';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { preprocessMarkdown } from './preprocessor.js';
|
|
6
|
+
// Import zx globals to make $, path, fs, etc. available globally
|
|
7
|
+
await import('zx/globals');
|
|
8
|
+
/**
|
|
9
|
+
* Run markdown content or file with CLI-like options
|
|
10
|
+
*
|
|
11
|
+
* @param markdown - Markdown content or file path
|
|
12
|
+
* @param options - CLI-like options
|
|
13
|
+
*/
|
|
14
|
+
export async function runMarkdown(markdown, options = {}) {
|
|
15
|
+
// Save current state
|
|
16
|
+
const savedState = {
|
|
17
|
+
verbose: $.verbose,
|
|
18
|
+
quiet: $.quiet,
|
|
19
|
+
shell: $.shell,
|
|
20
|
+
prefix: $.prefix,
|
|
21
|
+
postfix: $.postfix,
|
|
22
|
+
cwd: $.cwd,
|
|
23
|
+
preferLocal: $.preferLocal,
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
// Apply options
|
|
27
|
+
if (options.verbose !== undefined)
|
|
28
|
+
$.verbose = options.verbose;
|
|
29
|
+
if (options.quiet !== undefined)
|
|
30
|
+
$.quiet = options.quiet;
|
|
31
|
+
if (options.shell)
|
|
32
|
+
$.shell = options.shell;
|
|
33
|
+
if (options.prefix)
|
|
34
|
+
$.prefix = options.prefix;
|
|
35
|
+
if (options.postfix)
|
|
36
|
+
$.postfix = options.postfix;
|
|
37
|
+
if (options.cwd)
|
|
38
|
+
$.cwd = options.cwd;
|
|
39
|
+
if (options.preferLocal !== undefined)
|
|
40
|
+
$.preferLocal = options.preferLocal;
|
|
41
|
+
// Read markdown content if it's a file path
|
|
42
|
+
let markdownContent;
|
|
43
|
+
if (typeof markdown === 'string' && (markdown.endsWith('.md') || markdown.includes('\n') === false)) {
|
|
44
|
+
markdownContent = await fs.readFile(markdown, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
markdownContent = markdown.toString();
|
|
48
|
+
}
|
|
49
|
+
// Preprocess markdown with ezx enhancements
|
|
50
|
+
// Write extracted files to disk
|
|
51
|
+
const { preprocessedMarkdown, extractedFiles } = preprocessMarkdown(markdownContent, {
|
|
52
|
+
cwd: options.cwd || process.cwd(),
|
|
53
|
+
outputFiles: true,
|
|
54
|
+
});
|
|
55
|
+
// Transform markdown to JavaScript
|
|
56
|
+
let jsCode = transformMarkdown(preprocessedMarkdown);
|
|
57
|
+
// Resolve the absolute path to zx/globals using Node's module resolution
|
|
58
|
+
// This will work regardless of where ezx is installed (local, global, or as a dependency)
|
|
59
|
+
const zxGlobalsPath = await import.meta.resolve('zx/globals');
|
|
60
|
+
// Prepend globals import to make $, fs, path, etc. available in the script context
|
|
61
|
+
// Use the resolved absolute path to ensure zx is found
|
|
62
|
+
jsCode = `await import('${zxGlobalsPath}')\n\n${jsCode}`;
|
|
63
|
+
// Write to temp file in current directory (not tmpdir) so zx can be resolved
|
|
64
|
+
const cwd = options.cwd || process.cwd();
|
|
65
|
+
const tempFile = path.join(cwd, `.ezx-${randomBytes(8).toString('hex')}.mjs`);
|
|
66
|
+
await fs.writeFile(tempFile, jsCode);
|
|
67
|
+
try {
|
|
68
|
+
// Import and execute the transformed code (same as CLI)
|
|
69
|
+
await import(pathToFileURL(tempFile).toString());
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
// Clean up temp file
|
|
73
|
+
await fs.rm(tempFile, { force: true }).catch(() => { });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
// Restore state
|
|
78
|
+
Object.assign($, savedState);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Run a markdown file from disk
|
|
83
|
+
*
|
|
84
|
+
* @param filePath - Path to markdown file
|
|
85
|
+
* @param options - CLI-like options
|
|
86
|
+
*/
|
|
87
|
+
export async function runMarkdownFile(filePath, options = {}) {
|
|
88
|
+
return runMarkdown(filePath, options);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Run markdown content directly
|
|
92
|
+
*
|
|
93
|
+
* @param markdownContent - Markdown content as string
|
|
94
|
+
* @param options - CLI-like options
|
|
95
|
+
*/
|
|
96
|
+
export async function runMarkdownContent(markdownContent, options = {}) {
|
|
97
|
+
return runMarkdown(markdownContent, options);
|
|
98
|
+
}
|
|
99
|
+
// Re-export everything from zx for convenience
|
|
100
|
+
export * from 'zx';
|
|
101
|
+
// Export preprocessor functions
|
|
102
|
+
export * from './preprocessor.js';
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,EAAC,MAAM,mBAAmB,CAAC;AAErD,iEAAiE;AACjE,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;AAY3B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAyB,EAAE,UAA8B,EAAE;IAC5F,qBAAqB;IACrB,MAAM,UAAU,GAAG;QAClB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,WAAW,EAAE,CAAC,CAAC,WAAW;KAC1B,CAAC;IAEF,IAAI,CAAC;QACJ,gBAAgB;QAChB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/D,IA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CAAgC;AAChC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface CodeBlock {
|
|
2
|
+
language: string;
|
|
3
|
+
content: string;
|
|
4
|
+
startLine: number;
|
|
5
|
+
endLine: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FileExtraction {
|
|
8
|
+
filePath: string;
|
|
9
|
+
content: string;
|
|
10
|
+
language: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PreprocessResult {
|
|
13
|
+
preprocessedMarkdown: string;
|
|
14
|
+
extractedFiles: FileExtraction[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Preprocess markdown file
|
|
18
|
+
*/
|
|
19
|
+
export declare function preprocessMarkdown(input: string, options?: {
|
|
20
|
+
outputFiles?: boolean;
|
|
21
|
+
cwd?: string;
|
|
22
|
+
}): PreprocessResult;
|
|
23
|
+
/**
|
|
24
|
+
* Read and preprocess a markdown file
|
|
25
|
+
*/
|
|
26
|
+
export declare function preprocessFile(filePath: string, options?: {
|
|
27
|
+
outputFiles?: boolean;
|
|
28
|
+
cwd?: string;
|
|
29
|
+
}): PreprocessResult;
|
|
30
|
+
//# sourceMappingURL=preprocessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CAChB;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;CACjC;AAwID;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAM,GACjD,gBAAgB,CAyJlB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAM,GACjD,gBAAgB,CAGlB"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
2
|
+
import { resolve, dirname } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Comment tokens for different languages
|
|
5
|
+
*/
|
|
6
|
+
const COMMENT_TOKENS = {
|
|
7
|
+
// Languages with // comment
|
|
8
|
+
typescript: '//',
|
|
9
|
+
javascript: '//',
|
|
10
|
+
js: '//',
|
|
11
|
+
ts: '//',
|
|
12
|
+
cpp: '//',
|
|
13
|
+
c: '//',
|
|
14
|
+
csharp: '//',
|
|
15
|
+
go: '//',
|
|
16
|
+
rust: '//',
|
|
17
|
+
java: '//',
|
|
18
|
+
kotlin: '//',
|
|
19
|
+
swift: '//',
|
|
20
|
+
php: '//',
|
|
21
|
+
// Languages with # comment
|
|
22
|
+
bash: '#',
|
|
23
|
+
sh: '#',
|
|
24
|
+
shell: '#',
|
|
25
|
+
python: '#',
|
|
26
|
+
rb: '#',
|
|
27
|
+
ruby: '#',
|
|
28
|
+
perl: '#',
|
|
29
|
+
r: '#',
|
|
30
|
+
// Languages with -- comment
|
|
31
|
+
sql: '--',
|
|
32
|
+
lua: '--',
|
|
33
|
+
haskell: '--',
|
|
34
|
+
// Languages with ; comment
|
|
35
|
+
asm: ';',
|
|
36
|
+
// Languages with <!-- comment -->
|
|
37
|
+
html: '<!--',
|
|
38
|
+
xml: '<!--',
|
|
39
|
+
markdown: '<!--',
|
|
40
|
+
md: '<!--',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Get the comment token for a language
|
|
44
|
+
*/
|
|
45
|
+
function getCommentToken(language) {
|
|
46
|
+
const lowerLang = language.toLowerCase().trim();
|
|
47
|
+
return COMMENT_TOKENS[lowerLang] || null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse markdown and extract all code blocks with their line numbers
|
|
51
|
+
*/
|
|
52
|
+
function parseCodeBlocks(markdown) {
|
|
53
|
+
const codeBlocks = [];
|
|
54
|
+
const lines = markdown.split('\n');
|
|
55
|
+
let inCodeBlock = false;
|
|
56
|
+
let currentBlock = {};
|
|
57
|
+
let blockStartLine = 0;
|
|
58
|
+
for (let i = 0; i < lines.length; i++) {
|
|
59
|
+
const line = lines[i];
|
|
60
|
+
// Check for code block start
|
|
61
|
+
if (line.match(/^```(\w+)?/)) {
|
|
62
|
+
if (!inCodeBlock) {
|
|
63
|
+
// Starting a new code block
|
|
64
|
+
const languageMatch = line.match(/^```(\w+)?/);
|
|
65
|
+
currentBlock = {
|
|
66
|
+
language: languageMatch?.[1] || '',
|
|
67
|
+
content: '',
|
|
68
|
+
startLine: i,
|
|
69
|
+
};
|
|
70
|
+
inCodeBlock = true;
|
|
71
|
+
blockStartLine = i;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Ending the current code block
|
|
75
|
+
if (currentBlock.language !== undefined &&
|
|
76
|
+
currentBlock.content !== undefined &&
|
|
77
|
+
currentBlock.startLine !== undefined) {
|
|
78
|
+
codeBlocks.push({
|
|
79
|
+
language: currentBlock.language,
|
|
80
|
+
content: currentBlock.content,
|
|
81
|
+
startLine: currentBlock.startLine,
|
|
82
|
+
endLine: i,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
inCodeBlock = false;
|
|
86
|
+
currentBlock = {};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (inCodeBlock && currentBlock.content !== undefined) {
|
|
90
|
+
// Add line to current block content
|
|
91
|
+
currentBlock.content += (currentBlock.content ? '\n' : '') + line;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return codeBlocks;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if a line contains a directory set command
|
|
98
|
+
*/
|
|
99
|
+
function isDirectorySetCommand(line) {
|
|
100
|
+
const trimmed = line.trim().toLowerCase();
|
|
101
|
+
return trimmed === '# set the current directory';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if a line contains a file extraction comment
|
|
105
|
+
*/
|
|
106
|
+
function isFileExtractionComment(line, commentToken) {
|
|
107
|
+
const trimmed = line.trim();
|
|
108
|
+
// For HTML/XML style comments, we need to remove the closing -->
|
|
109
|
+
let searchLine = trimmed;
|
|
110
|
+
if (commentToken === '<!--') {
|
|
111
|
+
searchLine = trimmed.replace(/-->.*$/, '');
|
|
112
|
+
}
|
|
113
|
+
const filePattern = new RegExp(`^${escapeRegExp(commentToken)}\\s*file:\\s*(.+)$`, 'i');
|
|
114
|
+
const match = searchLine.match(filePattern);
|
|
115
|
+
if (match) {
|
|
116
|
+
return match[1].trim();
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Escape special regex characters
|
|
122
|
+
*/
|
|
123
|
+
function escapeRegExp(string) {
|
|
124
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Preprocess markdown file
|
|
128
|
+
*/
|
|
129
|
+
export function preprocessMarkdown(input, options = {}) {
|
|
130
|
+
const { outputFiles = false, cwd = process.cwd() } = options;
|
|
131
|
+
const lines = input.split('\n');
|
|
132
|
+
const codeBlocks = parseCodeBlocks(input);
|
|
133
|
+
const extractedFiles = [];
|
|
134
|
+
// Track the current directory context
|
|
135
|
+
let currentDirectory = null;
|
|
136
|
+
// Set of block indices to remove completely (for file extraction)
|
|
137
|
+
const blocksToRemove = new Set();
|
|
138
|
+
// Map of block indices to transformations (prepend cd)
|
|
139
|
+
const blocksToTransform = new Map();
|
|
140
|
+
// Process each code block
|
|
141
|
+
for (let i = 0; i < codeBlocks.length; i++) {
|
|
142
|
+
const block = codeBlocks[i];
|
|
143
|
+
const blockLines = block.content.split('\n');
|
|
144
|
+
const isBash = block.language === 'bash' || block.language === 'sh' || block.language === 'shell';
|
|
145
|
+
const commentToken = getCommentToken(block.language);
|
|
146
|
+
// Check if this is a file extraction block
|
|
147
|
+
if (commentToken) {
|
|
148
|
+
const firstLine = blockLines[0] || '';
|
|
149
|
+
const filePath = isFileExtractionComment(firstLine, commentToken);
|
|
150
|
+
if (filePath) {
|
|
151
|
+
// This is a file extraction block
|
|
152
|
+
// Remove the comment line from the file content
|
|
153
|
+
const fileContent = blockLines.slice(1).join('\n').trim();
|
|
154
|
+
extractedFiles.push({
|
|
155
|
+
filePath: resolve(cwd, filePath),
|
|
156
|
+
content: fileContent,
|
|
157
|
+
language: block.language,
|
|
158
|
+
});
|
|
159
|
+
// Mark this block for removal
|
|
160
|
+
blocksToRemove.add(i);
|
|
161
|
+
// If outputFiles is true, write the file
|
|
162
|
+
if (outputFiles) {
|
|
163
|
+
const filePath = extractedFiles[extractedFiles.length - 1].filePath;
|
|
164
|
+
const dir = dirname(filePath);
|
|
165
|
+
// Create directory if it doesn't exist
|
|
166
|
+
mkdirSync(dir, { recursive: true });
|
|
167
|
+
writeFileSync(filePath, fileContent, 'utf-8');
|
|
168
|
+
console.log(`Extracted file: ${filePath}`);
|
|
169
|
+
}
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Check for directory set command in bash blocks
|
|
174
|
+
if (isBash) {
|
|
175
|
+
let justSetDirectory = false;
|
|
176
|
+
// First, check if this block has a directory set command
|
|
177
|
+
const hasDirectorySet = blockLines.some((line) => isDirectorySetCommand(line));
|
|
178
|
+
if (hasDirectorySet) {
|
|
179
|
+
// If we have a current directory from a PREVIOUS block, prepend cd to this block
|
|
180
|
+
// This ensures the cd command in this block is relative to the current virtual directory
|
|
181
|
+
if (currentDirectory) {
|
|
182
|
+
blocksToTransform.set(i, currentDirectory);
|
|
183
|
+
}
|
|
184
|
+
for (let j = 0; j < blockLines.length; j++) {
|
|
185
|
+
const line = blockLines[j];
|
|
186
|
+
if (isDirectorySetCommand(line)) {
|
|
187
|
+
// Found directory set command, now look for the next cd command
|
|
188
|
+
for (let k = j + 1; k < blockLines.length; k++) {
|
|
189
|
+
const lineAfter = blockLines[k];
|
|
190
|
+
const cdMatch = lineAfter.match(/^\s*cd\s+(.+)$/);
|
|
191
|
+
if (cdMatch) {
|
|
192
|
+
// The cd command will execute relative to the prepended virtual directory
|
|
193
|
+
const newPath = cdMatch[1].trim();
|
|
194
|
+
// Update the virtual directory context
|
|
195
|
+
if (currentDirectory) {
|
|
196
|
+
currentDirectory = `${currentDirectory}/${newPath}`;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
currentDirectory = newPath;
|
|
200
|
+
}
|
|
201
|
+
justSetDirectory = true;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// If we have a current directory from a PREVIOUS block, prepend cd to this bash block
|
|
210
|
+
// Only prepend if this is NOT the block where we just set the directory (we already did above)
|
|
211
|
+
if (currentDirectory && !justSetDirectory) {
|
|
212
|
+
blocksToTransform.set(i, currentDirectory);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Build preprocessed markdown
|
|
217
|
+
const preprocessedLines = [];
|
|
218
|
+
let processedBlocks = 0;
|
|
219
|
+
for (let i = 0; i < lines.length; i++) {
|
|
220
|
+
const line = lines[i];
|
|
221
|
+
// Check if this is the start of a code block
|
|
222
|
+
if (line.match(/^```(\w+)?/)) {
|
|
223
|
+
const blockIndex = codeBlocks.findIndex((b) => b.startLine === i);
|
|
224
|
+
if (blockIndex !== -1) {
|
|
225
|
+
const block = codeBlocks[blockIndex];
|
|
226
|
+
// Check if this block should be removed
|
|
227
|
+
if (blocksToRemove.has(blockIndex)) {
|
|
228
|
+
// Skip this entire block
|
|
229
|
+
i = block.endLine;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
// Output the opening ``` line
|
|
233
|
+
preprocessedLines.push(line);
|
|
234
|
+
// Check if we need to prepend cd command
|
|
235
|
+
if (blocksToTransform.has(blockIndex)) {
|
|
236
|
+
const dir = blocksToTransform.get(blockIndex);
|
|
237
|
+
preprocessedLines.push(`cd ${dir}`);
|
|
238
|
+
}
|
|
239
|
+
// Output the block content
|
|
240
|
+
if (block.content) {
|
|
241
|
+
preprocessedLines.push(block.content);
|
|
242
|
+
}
|
|
243
|
+
// Skip to the closing ```
|
|
244
|
+
i = block.endLine - 1;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// This is a closing ``` we've already processed
|
|
248
|
+
preprocessedLines.push(line);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
// Regular line
|
|
253
|
+
preprocessedLines.push(line);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
preprocessedMarkdown: preprocessedLines.join('\n'),
|
|
258
|
+
extractedFiles,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Read and preprocess a markdown file
|
|
263
|
+
*/
|
|
264
|
+
export function preprocessFile(filePath, options = {}) {
|
|
265
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
266
|
+
return preprocessMarkdown(content, options);
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.js","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAA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EAChB,UAAiD,EAAE;IAEnD,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,8 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"name": "ezx",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Enhanced zx - Write better shell scripts with markdown preprocessing features including directory context persistence and file extraction",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"zx",
|
|
7
|
+
"shell",
|
|
8
|
+
"bash",
|
|
9
|
+
"script",
|
|
10
|
+
"markdown",
|
|
11
|
+
"cli",
|
|
12
|
+
"terminal",
|
|
13
|
+
"automation",
|
|
14
|
+
"preprocessor",
|
|
15
|
+
"code-extraction"
|
|
16
|
+
],
|
|
17
|
+
"author": "Ronan Sandford",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://github.com/wighawag/ezx#readme",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/wighawag/ezx.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/wighawag/ezx/issues"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
5
31
|
"access": "public"
|
|
6
32
|
},
|
|
7
|
-
|
|
33
|
+
"type": "module",
|
|
34
|
+
"main": "dist/index.js",
|
|
35
|
+
"module": "dist/index.js",
|
|
36
|
+
"types": "dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"bin": {
|
|
46
|
+
"ezx": "dist/cli.js"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"commander": "^14.0.2",
|
|
55
|
+
"zx": "^8.8.5"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^25.0.10",
|
|
59
|
+
"as-soon": "^0.1.5",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc --project tsconfig.json",
|
|
64
|
+
"dev": "as-soon -w src pnpm build"
|
|
65
|
+
}
|
|
8
66
|
}
|