@brickflow/cli 0.0.40 → 0.0.43
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/CHANGELOG.md +18 -0
- package/README.md +22 -0
- package/package.json +6 -5
- package/src/svg-fix/index.js +116 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @brickflow/cli
|
|
2
2
|
|
|
3
|
+
## 0.0.43
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add svg-fix script
|
|
8
|
+
|
|
9
|
+
## 0.0.42
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix file and type generate
|
|
14
|
+
|
|
15
|
+
## 0.0.41
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- UI kit update demo
|
|
20
|
+
|
|
3
21
|
## 0.0.40
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @brickflow/cli
|
|
2
|
+
|
|
3
|
+
## Fix SVG files
|
|
4
|
+
|
|
5
|
+
Recursively process SVG files in place with [oslllo-svg-fixer](https://github.com/oslllo/svg-fixer), converting strokes to filled paths for icon fonts.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
brick svg-fix ./icons
|
|
9
|
+
brick svg-fix ./icons ./assets/icons ./logo.svg
|
|
10
|
+
brick svg-fix --path ./icons --path ./assets/icons
|
|
11
|
+
brick svg-fix --help
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
From the repository root:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pnpm svg-fix ./icons ./assets/icons
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Pass one or more paths as separate arguments, or repeat `--path` (`-p`). Each path can be a directory or an individual SVG file. Relative paths are resolved from the current working directory. Directories are searched recursively, and files with an `.svg` extension (case-insensitive) are processed. Other files and symbolic links discovered inside directories are skipped.
|
|
21
|
+
|
|
22
|
+
SVG files are overwritten at their original paths; there is no `--output` option. Repeated or overlapping paths do not cause a file to be processed more than once. All input paths are scanned before any files are changed. Processing stops with exit code 1 if a file fails; files already processed remain changed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brickflow/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
"@babel/parser": "8.0.4",
|
|
19
19
|
"@babel/traverse": "8.0.4",
|
|
20
20
|
"@babel/types": "8.0.4",
|
|
21
|
-
"@google/genai": "2.
|
|
22
|
-
"@vue/compiler-sfc": "3.5.
|
|
21
|
+
"@google/genai": "2.21.0",
|
|
22
|
+
"@vue/compiler-sfc": "3.5.42",
|
|
23
23
|
"fantasticon": "4.1.0",
|
|
24
24
|
"glob": "13.0.6",
|
|
25
25
|
"looks-same": "10.0.1",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"oslllo-svg-fixer": "6.0.1",
|
|
27
|
+
"sharp": "0.35.4",
|
|
28
|
+
"svgo": "4.1.0"
|
|
28
29
|
},
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"access": "public"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { readdir, readFile, realpath, stat, writeFile } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { parseArgs } from 'node:util'
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
await main()
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(`SVG fix failed: ${error.message}`)
|
|
9
|
+
process.exitCode = 1
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function collectSvgFiles(input, files, visited) {
|
|
13
|
+
if (visited.has(input)) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
visited.add(input)
|
|
18
|
+
const inputStat = await stat(input)
|
|
19
|
+
|
|
20
|
+
if (inputStat.isFile() && path.extname(input).toLowerCase() === '.svg') {
|
|
21
|
+
files.add(input)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!inputStat.isDirectory()) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const entries = await readdir(input, { withFileTypes: true })
|
|
30
|
+
|
|
31
|
+
for (const entry of entries.sort((first, second) => first.name.localeCompare(second.name))) {
|
|
32
|
+
const entryPath = path.join(input, entry.name)
|
|
33
|
+
|
|
34
|
+
if (entry.isDirectory()) {
|
|
35
|
+
await collectSvgFiles(entryPath, files, visited)
|
|
36
|
+
} else if (entry.isFile() && path.extname(entry.name).toLowerCase() === '.svg') {
|
|
37
|
+
files.add(entryPath)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function main() {
|
|
43
|
+
const { positionals, values } = parseArgs({
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
args: process.argv.slice(3),
|
|
46
|
+
options: {
|
|
47
|
+
help: { short: 'h', type: 'boolean' },
|
|
48
|
+
path: { multiple: true, short: 'p', type: 'string' },
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
if (values.help) {
|
|
53
|
+
printHelp()
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const inputs = [...positionals, ...(values.path ?? [])]
|
|
58
|
+
|
|
59
|
+
if (inputs.length === 0 || inputs.some((input) => input.length === 0)) {
|
|
60
|
+
printHelp()
|
|
61
|
+
throw new Error('Provide at least one path to a directory or SVG file.')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const files = new Set()
|
|
65
|
+
const visited = new Set()
|
|
66
|
+
|
|
67
|
+
for (const input of inputs) {
|
|
68
|
+
await collectSvgFiles(await realpath(path.resolve(input)), files, visited)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const svgFiles = [...files]
|
|
72
|
+
|
|
73
|
+
if (svgFiles.length === 0) {
|
|
74
|
+
console.log('No SVG files found in the supplied paths')
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { default: svgFixer } = await import('oslllo-svg-fixer')
|
|
79
|
+
|
|
80
|
+
console.log(`Fixing ${svgFiles.length} SVG file(s) in place`)
|
|
81
|
+
|
|
82
|
+
for (const [index, source] of svgFiles.entries()) {
|
|
83
|
+
const relativePath = path.relative(process.cwd(), source)
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
const fixed = await svgFixer.fixString(await readFile(source))
|
|
87
|
+
await writeFile(source, fixed)
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw new Error(`${relativePath}: ${error.message}`, { cause: error })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(`[${index + 1}/${svgFiles.length}] ${relativePath}`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log(`Fixed ${svgFiles.length} SVG file(s)`)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function printHelp() {
|
|
99
|
+
console.log(`brick svg-fix <path...>
|
|
100
|
+
|
|
101
|
+
Usage:
|
|
102
|
+
brick svg-fix ./icons
|
|
103
|
+
brick svg-fix ./icons ./assets/icons ./logo.svg
|
|
104
|
+
brick svg-fix --path ./icons --path ./assets/icons
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
-p, --path Directory or SVG file; may be repeated
|
|
108
|
+
-h, --help Show this help
|
|
109
|
+
|
|
110
|
+
Notes:
|
|
111
|
+
Recursively converts SVG strokes to fills using oslllo-svg-fixer
|
|
112
|
+
Paths are resolved from the current working directory
|
|
113
|
+
SVG files are overwritten in place; no output directory is needed
|
|
114
|
+
Each SVG is processed once, even when supplied paths overlap
|
|
115
|
+
Other files and symbolic links discovered inside directories are skipped`)
|
|
116
|
+
}
|