oward-ui 0.0.1 → 0.0.3
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/dist/index.js +30 -41
- package/package.json +3 -13
package/dist/index.js
CHANGED
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { program } from "commander";
|
|
5
4
|
import { spawn } from "child_process";
|
|
6
5
|
var REGISTRY_BASE_URL = "https://ui.oward.net";
|
|
7
6
|
var REGISTRY_TRACK_PATH = "/r";
|
|
8
7
|
var REGISTRY_IGNORE_PATH = "/r-ignore";
|
|
8
|
+
function runShadcn(args2) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const child = spawn("npx", ["shadcn", ...args2], {
|
|
11
|
+
stdio: "inherit",
|
|
12
|
+
shell: true
|
|
13
|
+
});
|
|
14
|
+
child.on("close", (code) => resolve(code ?? 0));
|
|
15
|
+
child.on("error", () => resolve(1));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
9
18
|
async function trackComponent(componentName) {
|
|
10
19
|
const trackUrl = `${REGISTRY_BASE_URL}${REGISTRY_TRACK_PATH}/${componentName}.json`;
|
|
11
20
|
try {
|
|
12
21
|
await fetch(trackUrl, {
|
|
13
22
|
method: "GET",
|
|
14
|
-
headers: {
|
|
15
|
-
"User-Agent": "oward-cli/0.0.1 (https://ui.oward.net)"
|
|
16
|
-
}
|
|
23
|
+
headers: { "User-Agent": "oward-ui/0.0.3 (https://ui.oward.net)" }
|
|
17
24
|
});
|
|
18
25
|
} catch {
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
|
-
function runShadcn(args) {
|
|
22
|
-
return new Promise((resolve) => {
|
|
23
|
-
const child = spawn("npx", ["shadcn", ...args], {
|
|
24
|
-
stdio: "inherit",
|
|
25
|
-
shell: true
|
|
26
|
-
});
|
|
27
|
-
child.on("close", (code) => {
|
|
28
|
-
resolve(code ?? 0);
|
|
29
|
-
});
|
|
30
|
-
child.on("error", () => {
|
|
31
|
-
resolve(1);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
28
|
function transformToIgnoreUrl(component) {
|
|
36
29
|
if (component.startsWith("http://") || component.startsWith("https://")) {
|
|
37
30
|
if (component.includes(REGISTRY_BASE_URL)) {
|
|
@@ -48,28 +41,24 @@ function extractComponentName(component) {
|
|
|
48
41
|
}
|
|
49
42
|
return component;
|
|
50
43
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
async function handleAdd(args2) {
|
|
45
|
+
const components = [];
|
|
46
|
+
const options = [];
|
|
47
|
+
for (const arg of args2) {
|
|
48
|
+
if (arg.startsWith("-")) {
|
|
49
|
+
options.push(arg);
|
|
50
|
+
} else {
|
|
51
|
+
components.push(arg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
components.forEach((c) => trackComponent(extractComponentName(c)));
|
|
58
55
|
const transformedComponents = components.map(transformToIgnoreUrl);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var passthroughCommands = ["init", "diff", "build"];
|
|
68
|
-
for (const cmd of passthroughCommands) {
|
|
69
|
-
program.command(cmd, { hidden: false }).description(`Pass-through to shadcn ${cmd}`).allowUnknownOption().action(async (_, command) => {
|
|
70
|
-
const args = [cmd, ...command.args];
|
|
71
|
-
const exitCode = await runShadcn(args);
|
|
72
|
-
process.exit(exitCode);
|
|
73
|
-
});
|
|
56
|
+
return runShadcn(["add", ...transformedComponents, ...options]);
|
|
57
|
+
}
|
|
58
|
+
var args = process.argv.slice(2);
|
|
59
|
+
var command = args[0];
|
|
60
|
+
if (command === "add" && args.length > 1) {
|
|
61
|
+
handleAdd(args.slice(1)).then((code) => process.exit(code));
|
|
62
|
+
} else {
|
|
63
|
+
runShadcn(args).then((code) => process.exit(code));
|
|
74
64
|
}
|
|
75
|
-
program.parse();
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oward-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "CLI wrapper for Oward UI registry with unified tracking",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin":
|
|
7
|
-
"oward-ui": "./dist/index.js"
|
|
8
|
-
},
|
|
6
|
+
"bin": "./dist/index.js",
|
|
9
7
|
"files": [
|
|
10
8
|
"dist"
|
|
11
9
|
],
|
|
@@ -14,21 +12,13 @@
|
|
|
14
12
|
"build": "tsup",
|
|
15
13
|
"start": "node dist/index.js"
|
|
16
14
|
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"commander": "^12.0.0"
|
|
19
|
-
},
|
|
20
15
|
"devDependencies": {
|
|
21
16
|
"@repo/typescript-config": "workspace:*",
|
|
22
17
|
"@types/node": "^20.0.0",
|
|
23
18
|
"tsup": "^8.0.0",
|
|
24
19
|
"typescript": "^5.0.0"
|
|
25
20
|
},
|
|
26
|
-
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "https://github.com/Oward-Studio/ui.git",
|
|
29
|
-
"directory": "packages/cli"
|
|
30
|
-
},
|
|
31
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
32
22
|
"shadcn",
|
|
33
23
|
"ui",
|
|
34
24
|
"registry",
|