preskok-ui 0.0.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ # preskok-ui
2
+
3
+ Thin CLI wrapper around shadcn with Preskok registry wiring.
4
+
5
+ ```bash
6
+ npx preskok-ui@latest init
7
+ npx preskok-ui@latest add button
8
+ ```
9
+
10
+ The CLI delegates to `shadcn@latest`. `init` registers Preskok after shadcn setup, and `add` resolves bare component names through the Preskok registry.
11
+
12
+ ```bash
13
+ npx preskok-ui@latest registry
14
+ npx preskok-ui@latest diff
15
+ ```
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process"
3
+
4
+ const REGISTRY = "@preskok=https://ui-three-mu.vercel.app/r/{name}.json"
5
+
6
+ const args = process.argv.slice(2)
7
+ const [command, ...commandArgs] = args
8
+
9
+ if (!command || command === "-h" || command === "--help") {
10
+ printHelp()
11
+ process.exit(0)
12
+ }
13
+
14
+ if (command === "add") {
15
+ const registryStatus = runShadcn(["registry", "add", REGISTRY])
16
+
17
+ if (registryStatus !== 0) {
18
+ process.exit(registryStatus)
19
+ }
20
+
21
+ process.exit(
22
+ runShadcn(["add", "--overwrite", "--yes", ...toPreskokItems(commandArgs)])
23
+ )
24
+ }
25
+
26
+ 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]))
34
+ }
35
+
36
+ if (command === "registry") {
37
+ const registryArgs =
38
+ commandArgs[0] === "add" ? commandArgs.slice(1) : commandArgs
39
+ process.exit(runShadcn(["registry", "add", REGISTRY, ...registryArgs]))
40
+ }
41
+
42
+ process.exit(runShadcn(args))
43
+
44
+ function runShadcn(shadcnArgs) {
45
+ const executable = process.platform === "win32" ? "npm.cmd" : "npm"
46
+ const result = spawnSync(
47
+ executable,
48
+ [
49
+ "exec",
50
+ "--yes",
51
+ "--package",
52
+ "shadcn@latest",
53
+ "--",
54
+ "shadcn",
55
+ ...shadcnArgs,
56
+ ],
57
+ {
58
+ stdio: "inherit",
59
+ }
60
+ )
61
+
62
+ return result.status ?? 1
63
+ }
64
+
65
+ function toPreskokItems(values) {
66
+ return values.map((value) => {
67
+ if (value.startsWith("-") || value.startsWith("@") || value.includes("/")) {
68
+ return value
69
+ }
70
+
71
+ return `@preskok/${value}`
72
+ })
73
+ }
74
+
75
+ function printHelp() {
76
+ console.log(`Usage: preskok-ui <command> [options]
77
+
78
+ Commands:
79
+ init run shadcn init and register Preskok
80
+ add <items...> register Preskok and add items by name
81
+ registry register the @preskok namespace in components.json
82
+
83
+ Examples:
84
+ npx preskok-ui@latest init
85
+ npx preskok-ui@latest add button
86
+ npx preskok-ui@latest diff
87
+ npx preskok-ui@latest registry`)
88
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "preskok-ui",
3
+ "version": "0.0.2",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "bin": {
7
+ "preskok-ui": "bin/preskok-ui.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "build": "node --check bin/preskok-ui.mjs",
15
+ "lint": "node --check bin/preskok-ui.mjs",
16
+ "typecheck": "node --check bin/preskok-ui.mjs"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ }
21
+ }