@dudko.dev/vectorize-cli 0.4.6 → 0.4.8
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/dist/cli.js +26 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { basename, extname } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
|
-
import { toDxf, toEps, toPdf, traceEncoded, withSize } from '@dudko.dev/vectorize-core';
|
|
7
|
+
import { coreVersion, toDxf, toEps, toPdf, traceEncoded, withSize } from '@dudko.dev/vectorize-core';
|
|
8
|
+
/**
|
|
9
|
+
* This package's own version, read from the manifest that ships beside the
|
|
10
|
+
* built file rather than baked in at build time — a baked constant is one more
|
|
11
|
+
* thing that can disagree with package.json, and this one would disagree
|
|
12
|
+
* silently.
|
|
13
|
+
*/
|
|
14
|
+
function cliVersion() {
|
|
15
|
+
try {
|
|
16
|
+
const manifest = new URL('../package.json', import.meta.url);
|
|
17
|
+
return JSON.parse(readFileSync(manifest, 'utf8')).version;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 'unknown';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
const FORMATS = ['svg', 'eps', 'pdf', 'dxf'];
|
|
9
24
|
const HELP = `vectorize — convert raster images (PNG/JPEG/GIF/BMP/WebP) to vector graphics
|
|
10
25
|
|
|
@@ -49,6 +64,7 @@ Tracing:
|
|
|
49
64
|
--stroke-width <px> Fixed centre-line width (default: measured)
|
|
50
65
|
--stroke-color <hex> Centre-line colour (default #000000)
|
|
51
66
|
-h, --help Show this help
|
|
67
|
+
-V, --version Print the CLI and core versions
|
|
52
68
|
`;
|
|
53
69
|
function num(v) {
|
|
54
70
|
if (v === undefined)
|
|
@@ -106,8 +122,16 @@ export async function main(argv) {
|
|
|
106
122
|
threshold: { type: 'string' },
|
|
107
123
|
json: { type: 'boolean', default: false },
|
|
108
124
|
help: { type: 'boolean', short: 'h', default: false },
|
|
125
|
+
version: { type: 'boolean', short: 'V', default: false },
|
|
109
126
|
},
|
|
110
127
|
});
|
|
128
|
+
if (values.version) {
|
|
129
|
+
// Two versions, because they answer different questions: the CLI's own,
|
|
130
|
+
// and the tracing core it is bound to — which is the one that decides what
|
|
131
|
+
// the output looks like.
|
|
132
|
+
process.stdout.write(`vectorize ${cliVersion()}\ncore ${await coreVersion()}\n`);
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
111
135
|
if (values.help || positionals.length === 0) {
|
|
112
136
|
process.stdout.write(HELP);
|
|
113
137
|
return values.help ? 0 : 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudko.dev/vectorize-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Command-line raster → SVG converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dudko.dev/vectorize-core": "0.4.
|
|
21
|
+
"@dudko.dev/vectorize-core": "0.4.7"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.18.0",
|