preskok-ui 0.0.4 → 0.0.5

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
@@ -10,5 +10,6 @@ The CLI delegates to `shadcn@latest`. `init` installs the Preskok base and optio
10
10
 
11
11
  ```bash
12
12
  npx preskok-ui@latest registry
13
- npx preskok-ui@latest diff
13
+ npx preskok-ui@latest view button
14
+ npx preskok-ui@latest diff button
14
15
  ```
@@ -3,6 +3,7 @@ import { spawnSync } from "node:child_process"
3
3
 
4
4
  const REGISTRY = "@preskok=https://ui-three-mu.vercel.app/r/{name}.json"
5
5
  const DEFAULT_REGISTRY_ITEM = "https://ui-three-mu.vercel.app/r/default.json"
6
+ const CWD_OPTION_VALUES = new Set(["-c", "--cwd"])
6
7
 
7
8
  const args = process.argv.slice(2)
8
9
  const [command, ...commandArgs] = args
@@ -36,6 +37,22 @@ if (command === "registry") {
36
37
  process.exit(runShadcn(["registry", "add", REGISTRY, ...registryArgs]))
37
38
  }
38
39
 
40
+ if (command === "view") {
41
+ process.exit(
42
+ runShadcn(["view", ...toPreskokCommandItems(commandArgs, CWD_OPTION_VALUES)])
43
+ )
44
+ }
45
+
46
+ if (command === "diff") {
47
+ process.exit(
48
+ runShadcn([
49
+ "add",
50
+ ...toPreskokCommandItems(commandArgs, CWD_OPTION_VALUES),
51
+ "--diff",
52
+ ])
53
+ )
54
+ }
55
+
39
56
  process.exit(runShadcn(args))
40
57
 
41
58
  function runShadcn(shadcnArgs) {
@@ -60,12 +77,32 @@ function runShadcn(shadcnArgs) {
60
77
  }
61
78
 
62
79
  function toPreskokItems(values) {
80
+ return values.map(toPreskokItem)
81
+ }
82
+
83
+ function toPreskokItem(value) {
84
+ if (value.startsWith("-") || value.startsWith("@") || value.includes("/")) {
85
+ return value
86
+ }
87
+
88
+ return `@preskok/${value.replace(/\.(tsx|ts|jsx|js|json)$/, "")}`
89
+ }
90
+
91
+ function toPreskokCommandItems(values, optionsWithValues) {
92
+ let skipNext = false
93
+
63
94
  return values.map((value) => {
64
- if (value.startsWith("-") || value.startsWith("@") || value.includes("/")) {
95
+ if (skipNext) {
96
+ skipNext = false
97
+ return value
98
+ }
99
+
100
+ if (optionsWithValues.has(value)) {
101
+ skipNext = true
65
102
  return value
66
103
  }
67
104
 
68
- return `@preskok/${value}`
105
+ return toPreskokItem(value)
69
106
  })
70
107
  }
71
108
 
@@ -111,6 +148,7 @@ Commands:
111
148
  Examples:
112
149
  npx preskok-ui@latest init button
113
150
  npx preskok-ui@latest add button
114
- npx preskok-ui@latest diff
151
+ npx preskok-ui@latest view button
152
+ npx preskok-ui@latest diff button
115
153
  npx preskok-ui@latest registry`)
116
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preskok-ui",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {