oward-ui 0.0.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +30 -41
  2. package/package.json +1 -4
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
- 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
- });
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
- 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
- });
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,6 +1,6 @@
1
1
  {
2
2
  "name": "oward-ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "CLI wrapper for Oward UI registry with unified tracking",
5
5
  "type": "module",
6
6
  "bin": "./dist/index.js",
@@ -12,9 +12,6 @@
12
12
  "build": "tsup",
13
13
  "start": "node dist/index.js"
14
14
  },
15
- "dependencies": {
16
- "commander": "^12.0.0"
17
- },
18
15
  "devDependencies": {
19
16
  "@repo/typescript-config": "workspace:*",
20
17
  "@types/node": "^20.0.0",