preskok-ui 0.0.2 → 0.0.4
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 +2 -3
- package/bin/preskok-ui.mjs +37 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Thin CLI wrapper around shadcn with Preskok registry wiring.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npx preskok-ui@latest init
|
|
7
|
-
npx preskok-ui@latest add button
|
|
6
|
+
npx preskok-ui@latest init button
|
|
8
7
|
```
|
|
9
8
|
|
|
10
|
-
The CLI delegates to `shadcn@latest`. `init`
|
|
9
|
+
The CLI delegates to `shadcn@latest`. `init` installs the Preskok base and optional components in one pass, and `add` resolves bare component names through the Preskok registry.
|
|
11
10
|
|
|
12
11
|
```bash
|
|
13
12
|
npx preskok-ui@latest registry
|
package/bin/preskok-ui.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from "node:child_process"
|
|
3
3
|
|
|
4
4
|
const REGISTRY = "@preskok=https://ui-three-mu.vercel.app/r/{name}.json"
|
|
5
|
+
const DEFAULT_REGISTRY_ITEM = "https://ui-three-mu.vercel.app/r/default.json"
|
|
5
6
|
|
|
6
7
|
const args = process.argv.slice(2)
|
|
7
8
|
const [command, ...commandArgs] = args
|
|
@@ -24,13 +25,9 @@ if (command === "add") {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
if (command === "init") {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
process.exit(initStatus)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
process.exit(runShadcn(["registry", "add", REGISTRY]))
|
|
28
|
+
process.exit(
|
|
29
|
+
runShadcn(["init", DEFAULT_REGISTRY_ITEM, ...toPreskokInitItems(commandArgs)])
|
|
30
|
+
)
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
if (command === "registry") {
|
|
@@ -72,16 +69,47 @@ function toPreskokItems(values) {
|
|
|
72
69
|
})
|
|
73
70
|
}
|
|
74
71
|
|
|
72
|
+
function toPreskokInitItems(values) {
|
|
73
|
+
const initOptionsWithValues = new Set([
|
|
74
|
+
"-t",
|
|
75
|
+
"--template",
|
|
76
|
+
"-b",
|
|
77
|
+
"--base",
|
|
78
|
+
"-p",
|
|
79
|
+
"--preset",
|
|
80
|
+
"-c",
|
|
81
|
+
"--cwd",
|
|
82
|
+
"-n",
|
|
83
|
+
"--name",
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
let skipNext = false
|
|
87
|
+
|
|
88
|
+
return values.map((value) => {
|
|
89
|
+
if (skipNext) {
|
|
90
|
+
skipNext = false
|
|
91
|
+
return value
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (initOptionsWithValues.has(value)) {
|
|
95
|
+
skipNext = true
|
|
96
|
+
return value
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return toPreskokItems([value])[0]
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
75
103
|
function printHelp() {
|
|
76
104
|
console.log(`Usage: preskok-ui <command> [options]
|
|
77
105
|
|
|
78
106
|
Commands:
|
|
79
|
-
init
|
|
107
|
+
init [items...] run shadcn init with the Preskok base and optional items
|
|
80
108
|
add <items...> register Preskok and add items by name
|
|
81
109
|
registry register the @preskok namespace in components.json
|
|
82
110
|
|
|
83
111
|
Examples:
|
|
84
|
-
npx preskok-ui@latest init
|
|
112
|
+
npx preskok-ui@latest init button
|
|
85
113
|
npx preskok-ui@latest add button
|
|
86
114
|
npx preskok-ui@latest diff
|
|
87
115
|
npx preskok-ui@latest registry`)
|