@chromamark/cli 0.2.0 → 0.2.1
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.md +5 -11
- package/README.md +8 -1
- package/package.json +8 -4
- package/src/cli.js +24 -7
- package/src/index.d.ts +25 -0
package/LICENSE.md
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
# MIT License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2026 CJ Fravel
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
8
|
|
|
9
|
-
THE SOFTWARE IS PROVIDED
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Third-party components
|
|
14
|
-
|
|
15
|
-
The published browser bundles in `packages/renderer/dist/` and the bundled VS Code extension embed [markdown-it](https://github.com/markdown-it/markdown-it), which is licensed under the [MIT License](https://github.com/markdown-it/markdown-it/blob/master/LICENSE).
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -35,6 +35,9 @@ Options: `-o/--output`, `--stdout`, `--title <text>`, `--watch`,
|
|
|
35
35
|
`--color <auto|always|never>`, `--no-color`, `--disable <rules>`, `-h/--help`,
|
|
36
36
|
`-v/--version`.
|
|
37
37
|
|
|
38
|
+
Commands accept one input source. Extra positional arguments, including a second
|
|
39
|
+
`-` stdin marker, are rejected instead of being silently ignored.
|
|
40
|
+
|
|
38
41
|
The `render` command turns tones into terminal colors, pills into bracketed
|
|
39
42
|
icon chips (`[✓ PASS]`), blocks into a colored left bar, and meters into a
|
|
40
43
|
unicode bar. Color is automatic on a TTY and can be forced with `--color`; it
|
|
@@ -57,6 +60,10 @@ const ansi = renderAnsi('[!pass]', { color: 'always' }); // terminal-styled text
|
|
|
57
60
|
const problems = lint('Use `[!pass]` here'); // [{ line, column, rule, ... }]
|
|
58
61
|
```
|
|
59
62
|
|
|
63
|
+
TypeScript declarations ship with the package.
|
|
64
|
+
|
|
60
65
|
## License
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
This software package is licensed under the MIT License; see LICENSE.md. The
|
|
68
|
+
[ChromaMark specification](https://github.com/cjfravel-dev/ChromaMark/blob/main/LICENSE-SPEC.md)
|
|
69
|
+
is licensed separately under CC BY-SA 4.0.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chromamark/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ChromaMark command-line tool — compile .cm to self-contained HTML, render to a color terminal, or lint.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"author": "cjfravel-dev",
|
|
7
7
|
"homepage": "https://github.com/cjfravel-dev/ChromaMark#readme",
|
|
8
8
|
"repository": {
|
|
@@ -24,8 +24,12 @@
|
|
|
24
24
|
"chromamark": "./bin/chromamark.js"
|
|
25
25
|
},
|
|
26
26
|
"main": "./src/index.js",
|
|
27
|
+
"types": "./src/index.d.ts",
|
|
27
28
|
"exports": {
|
|
28
|
-
".":
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./src/index.d.ts",
|
|
31
|
+
"default": "./src/index.js"
|
|
32
|
+
}
|
|
29
33
|
},
|
|
30
34
|
"files": [
|
|
31
35
|
"bin/",
|
|
@@ -42,6 +46,6 @@
|
|
|
42
46
|
"html"
|
|
43
47
|
],
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@chromamark/renderer": "^0.3.
|
|
49
|
+
"@chromamark/renderer": "^0.3.1"
|
|
46
50
|
}
|
|
47
51
|
}
|
package/src/cli.js
CHANGED
|
@@ -96,9 +96,11 @@ function parseArgs(argv) {
|
|
|
96
96
|
opts.disable = opts.disable.concat(takeValue(a).split(',').map((s) => s.trim()).filter(Boolean));
|
|
97
97
|
} else if (a === '-o' || a === '--output') opts.output = takeValue(a);
|
|
98
98
|
else if (a === '--title') opts.title = takeValue(a);
|
|
99
|
-
else if (a === '-') opts.input = '-';
|
|
99
|
+
else if (a === '-' && opts.input == null) opts.input = '-';
|
|
100
|
+
else if (a === '-') throw new Error('unexpected argument: -');
|
|
100
101
|
else if (a.startsWith('-')) throw new Error(`unknown option: ${a}`);
|
|
101
102
|
else if (opts.input == null) opts.input = a;
|
|
103
|
+
else throw new Error(`unexpected argument: ${a}`);
|
|
102
104
|
}
|
|
103
105
|
return opts;
|
|
104
106
|
}
|
|
@@ -234,23 +236,38 @@ export function run(argv = process.argv.slice(2)) {
|
|
|
234
236
|
|
|
235
237
|
try {
|
|
236
238
|
info = statSync(opts.input);
|
|
237
|
-
rebuild();
|
|
238
239
|
} catch (err) {
|
|
239
240
|
process.stderr.write(`error: ${err.message}\n`);
|
|
240
241
|
return 1;
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
if (opts.watch && !opts.stdout) {
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
const onChange = (_eventType, filename) => {
|
|
246
|
+
if (info.isDirectory() && filename && extname(String(filename)) !== '.cm') return;
|
|
246
247
|
try { rebuild(); } catch (err) { process.stderr.write(`error: ${err.message}\n`); }
|
|
247
248
|
};
|
|
249
|
+
let watcher;
|
|
248
250
|
try {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
try {
|
|
252
|
+
watcher = watch(opts.input, { recursive: info.isDirectory() }, onChange);
|
|
253
|
+
} catch {
|
|
254
|
+
watcher = watch(opts.input, onChange); // non-recursive fallback (older Node / platforms)
|
|
255
|
+
}
|
|
256
|
+
process.stderr.write('watching for changes… (Ctrl+C to stop)\n');
|
|
257
|
+
rebuild();
|
|
258
|
+
} catch (err) {
|
|
259
|
+
if (watcher) watcher.close();
|
|
260
|
+
process.stderr.write(`error: ${err.message}\n`);
|
|
261
|
+
return 1;
|
|
252
262
|
}
|
|
253
263
|
return 0;
|
|
254
264
|
}
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
rebuild();
|
|
268
|
+
} catch (err) {
|
|
269
|
+
process.stderr.write(`error: ${err.message}\n`);
|
|
270
|
+
return 1;
|
|
271
|
+
}
|
|
255
272
|
return 0;
|
|
256
273
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LintDiagnostic,
|
|
3
|
+
LintOptions,
|
|
4
|
+
RendererOptions,
|
|
5
|
+
RenderAnsiOptions,
|
|
6
|
+
} from '@chromamark/renderer';
|
|
7
|
+
|
|
8
|
+
export interface CompileOptions {
|
|
9
|
+
title?: string;
|
|
10
|
+
theme?: string;
|
|
11
|
+
rendererOptions?: RendererOptions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function render(source: unknown, options?: RendererOptions): string;
|
|
15
|
+
export function renderAnsi(source: unknown, options?: RenderAnsiOptions): string;
|
|
16
|
+
export function lint(source: unknown, options?: LintOptions): LintDiagnostic[];
|
|
17
|
+
export function theme(): string;
|
|
18
|
+
export function compile(source: unknown, options?: CompileOptions): string;
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
LintDiagnostic,
|
|
22
|
+
LintOptions,
|
|
23
|
+
RendererOptions,
|
|
24
|
+
RenderAnsiOptions,
|
|
25
|
+
};
|