oward-ui 0.0.1
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 +75 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
var REGISTRY_BASE_URL = "https://ui.oward.net";
|
|
7
|
+
var REGISTRY_TRACK_PATH = "/r";
|
|
8
|
+
var REGISTRY_IGNORE_PATH = "/r-ignore";
|
|
9
|
+
async function trackComponent(componentName) {
|
|
10
|
+
const trackUrl = `${REGISTRY_BASE_URL}${REGISTRY_TRACK_PATH}/${componentName}.json`;
|
|
11
|
+
try {
|
|
12
|
+
await fetch(trackUrl, {
|
|
13
|
+
method: "GET",
|
|
14
|
+
headers: {
|
|
15
|
+
"User-Agent": "oward-cli/0.0.1 (https://ui.oward.net)"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
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
|
+
function transformToIgnoreUrl(component) {
|
|
36
|
+
if (component.startsWith("http://") || component.startsWith("https://")) {
|
|
37
|
+
if (component.includes(REGISTRY_BASE_URL)) {
|
|
38
|
+
return component.replace("/r/", "/r-ignore/");
|
|
39
|
+
}
|
|
40
|
+
return component;
|
|
41
|
+
}
|
|
42
|
+
return `${REGISTRY_BASE_URL}${REGISTRY_IGNORE_PATH}/${component}.json`;
|
|
43
|
+
}
|
|
44
|
+
function extractComponentName(component) {
|
|
45
|
+
if (component.startsWith("http://") || component.startsWith("https://")) {
|
|
46
|
+
const match = component.match(/\/r(?:-[^/]+)?\/(.+)\.json/);
|
|
47
|
+
return match ? match[1] : component;
|
|
48
|
+
}
|
|
49
|
+
return component;
|
|
50
|
+
}
|
|
51
|
+
program.name("oward-ui").description("CLI for Oward UI registry - wraps shadcn with unified tracking").version("0.0.1");
|
|
52
|
+
program.command("add").description("Add components from Oward UI registry").argument("<components...>", "Components to add").option("-y, --yes", "Skip confirmation prompt", false).option("-o, --overwrite", "Overwrite existing files", false).option("-c, --cwd <path>", "Working directory", process.cwd()).option("-p, --path <path>", "Path to install components").action(async (components, options) => {
|
|
53
|
+
const trackPromises = components.map(
|
|
54
|
+
(c) => trackComponent(extractComponentName(c))
|
|
55
|
+
);
|
|
56
|
+
Promise.all(trackPromises).catch(() => {
|
|
57
|
+
});
|
|
58
|
+
const transformedComponents = components.map(transformToIgnoreUrl);
|
|
59
|
+
const shadcnArgs = ["add", ...transformedComponents];
|
|
60
|
+
if (options.yes) shadcnArgs.push("--yes");
|
|
61
|
+
if (options.overwrite) shadcnArgs.push("--overwrite");
|
|
62
|
+
if (options.cwd !== process.cwd()) shadcnArgs.push("--cwd", options.cwd);
|
|
63
|
+
if (options.path) shadcnArgs.push("--path", options.path);
|
|
64
|
+
const exitCode = await runShadcn(shadcnArgs);
|
|
65
|
+
process.exit(exitCode);
|
|
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
|
+
});
|
|
74
|
+
}
|
|
75
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "oward-ui",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CLI wrapper for Oward UI registry with unified tracking",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"oward-ui": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "tsup --watch",
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"start": "node dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"commander": "^12.0.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@repo/typescript-config": "workspace:*",
|
|
22
|
+
"@types/node": "^20.0.0",
|
|
23
|
+
"tsup": "^8.0.0",
|
|
24
|
+
"typescript": "^5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/Oward-Studio/ui.git",
|
|
29
|
+
"directory": "packages/cli"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"shadcn",
|
|
33
|
+
"ui",
|
|
34
|
+
"registry",
|
|
35
|
+
"cli",
|
|
36
|
+
"oward"
|
|
37
|
+
],
|
|
38
|
+
"author": "Geoffrey From Oward <geoffrey@oward.fr>",
|
|
39
|
+
"license": "MIT"
|
|
40
|
+
}
|