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 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` registers Preskok after shadcn setup, and `add` resolves bare component names through the Preskok registry.
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
@@ -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
- const initStatus = runShadcn(["init", ...commandArgs])
28
-
29
- if (initStatus !== 0) {
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 run shadcn init and register Preskok
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`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preskok-ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {