stera-ui 0.1.1 → 0.1.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.
@@ -183,7 +183,8 @@ function hasGlobalsCss(config, projectRoot) {
183
183
  // src/utils/install-deps.ts
184
184
  import fs4 from "fs";
185
185
  import path5 from "path";
186
- import { spawn } from "child_process";
186
+ import { detect } from "@antfu/ni";
187
+ import { execa } from "execa";
187
188
 
188
189
  // src/utils/format.ts
189
190
  var BRAND = "\x1B[38;2;166;244;48m";
@@ -241,10 +242,16 @@ function createSpinner(text) {
241
242
  }
242
243
 
243
244
  // src/utils/install-deps.ts
244
- function detectPackageManager(cwd) {
245
- if (fs4.existsSync(path5.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
246
- if (fs4.existsSync(path5.join(cwd, "bun.lockb"))) return "bun";
247
- if (fs4.existsSync(path5.join(cwd, "yarn.lock"))) return "yarn";
245
+ async function detectPackageManager(cwd) {
246
+ const detected = await detect({ programmatic: true, cwd });
247
+ if (detected === "pnpm@6" || detected === "pnpm") return "pnpm";
248
+ if (detected === "yarn@berry" || detected === "yarn") return "yarn";
249
+ if (detected === "bun") return "bun";
250
+ if (detected === "npm") return "npm";
251
+ const userAgent = process.env.npm_config_user_agent || "";
252
+ if (userAgent.startsWith("pnpm")) return "pnpm";
253
+ if (userAgent.startsWith("yarn")) return "yarn";
254
+ if (userAgent.startsWith("bun")) return "bun";
248
255
  return "npm";
249
256
  }
250
257
  function getInstallArgs(pm, deps) {
@@ -272,25 +279,16 @@ async function installDependencies(deps, cwd) {
272
279
  }
273
280
  const toInstall = deps.filter((dep) => !existing.has(dep));
274
281
  if (toInstall.length === 0) return;
275
- const pm = detectPackageManager(cwd);
282
+ const pm = await detectPackageManager(cwd);
276
283
  const [cmd, args] = getInstallArgs(pm, toInstall);
277
284
  const spinner = createSpinner(`Installing with ${pm}`);
278
- await new Promise((resolve, reject) => {
279
- const proc = spawn(cmd, args, { cwd, stdio: "pipe" });
280
- proc.on("close", (code) => {
281
- if (code === 0) {
282
- spinner.succeed(`Installed with ${pm}`);
283
- resolve();
284
- } else {
285
- spinner.fail(`Install failed (exit ${code})`);
286
- reject(new Error(`${pm} exited with code ${code}`));
287
- }
288
- });
289
- proc.on("error", (err) => {
290
- spinner.fail(`Install failed`);
291
- reject(err);
292
- });
293
- });
285
+ try {
286
+ await execa(cmd, args, { cwd });
287
+ spinner.succeed(`Installed with ${pm}`);
288
+ } catch (error) {
289
+ spinner.fail(`Install failed`);
290
+ throw error;
291
+ }
294
292
  }
295
293
 
296
294
  // src/utils/write-files.ts
@@ -1,5 +1,5 @@
1
1
  // src/registry/index.ts
2
- var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.stera.site/r";
2
+ var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.stera.sh/r";
3
3
  var _indexCache = null;
4
4
  async function fetchJSON(url) {
5
5
  const res = await fetch(url);
package/dist/cli.js CHANGED
@@ -43,7 +43,7 @@ function loadConfig(cwd) {
43
43
  }
44
44
 
45
45
  // src/registry/index.ts
46
- var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.stera.site/r";
46
+ var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.stera.sh/r";
47
47
  var _indexCache = null;
48
48
  async function fetchJSON(url) {
49
49
  const res = await fetch(url);
@@ -182,7 +182,8 @@ async function writeComponentFiles(items, config, projectRoot, options = {}) {
182
182
  // src/utils/install-deps.ts
183
183
  import fs3 from "fs";
184
184
  import path4 from "path";
185
- import { spawn } from "child_process";
185
+ import { detect } from "@antfu/ni";
186
+ import { execa } from "execa";
186
187
 
187
188
  // src/utils/format.ts
188
189
  var BRAND = "\x1B[38;2;166;244;48m";
@@ -240,10 +241,16 @@ function createSpinner(text) {
240
241
  }
241
242
 
242
243
  // src/utils/install-deps.ts
243
- function detectPackageManager(cwd) {
244
- if (fs3.existsSync(path4.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
245
- if (fs3.existsSync(path4.join(cwd, "bun.lockb"))) return "bun";
246
- if (fs3.existsSync(path4.join(cwd, "yarn.lock"))) return "yarn";
244
+ async function detectPackageManager(cwd) {
245
+ const detected = await detect({ programmatic: true, cwd });
246
+ if (detected === "pnpm@6" || detected === "pnpm") return "pnpm";
247
+ if (detected === "yarn@berry" || detected === "yarn") return "yarn";
248
+ if (detected === "bun") return "bun";
249
+ if (detected === "npm") return "npm";
250
+ const userAgent = process.env.npm_config_user_agent || "";
251
+ if (userAgent.startsWith("pnpm")) return "pnpm";
252
+ if (userAgent.startsWith("yarn")) return "yarn";
253
+ if (userAgent.startsWith("bun")) return "bun";
247
254
  return "npm";
248
255
  }
249
256
  function getInstallArgs(pm, deps) {
@@ -271,25 +278,16 @@ async function installDependencies(deps, cwd) {
271
278
  }
272
279
  const toInstall = deps.filter((dep) => !existing.has(dep));
273
280
  if (toInstall.length === 0) return;
274
- const pm = detectPackageManager(cwd);
281
+ const pm = await detectPackageManager(cwd);
275
282
  const [cmd, args] = getInstallArgs(pm, toInstall);
276
283
  const spinner = createSpinner(`Installing with ${pm}`);
277
- await new Promise((resolve, reject) => {
278
- const proc = spawn(cmd, args, { cwd, stdio: "pipe" });
279
- proc.on("close", (code) => {
280
- if (code === 0) {
281
- spinner.succeed(`Installed with ${pm}`);
282
- resolve();
283
- } else {
284
- spinner.fail(`Install failed (exit ${code})`);
285
- reject(new Error(`${pm} exited with code ${code}`));
286
- }
287
- });
288
- proc.on("error", (err) => {
289
- spinner.fail(`Install failed`);
290
- reject(err);
291
- });
292
- });
284
+ try {
285
+ await execa(cmd, args, { cwd });
286
+ spinner.succeed(`Installed with ${pm}`);
287
+ } catch (error) {
288
+ spinner.fail(`Install failed`);
289
+ throw error;
290
+ }
293
291
  }
294
292
 
295
293
  // src/utils/transform.ts
@@ -502,7 +500,7 @@ function buildConfig(project) {
502
500
  cssPath = "styles/globals.css";
503
501
  }
504
502
  return {
505
- $schema: "https://ui.stera.site/schema.json",
503
+ $schema: "https://ui.stera.sh/schema.json",
506
504
  version: 1,
507
505
  css: cssPath,
508
506
  aliases: {
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  getAllComponents,
5
5
  getComponent,
6
6
  resolveDependencies
7
- } from "./chunk-KEZKNZR6.js";
7
+ } from "./chunk-T3QWOVJR.js";
8
8
  import {
9
9
  configSchema,
10
10
  registryIndexSchema,
@@ -31,7 +31,7 @@ import {
31
31
  resolveOutputPath,
32
32
  transformImports,
33
33
  writeComponentFiles
34
- } from "./chunk-PUJGGJCB.js";
34
+ } from "./chunk-HCHFPFTS.js";
35
35
  export {
36
36
  CHECK,
37
37
  CONFIG_FILE,
@@ -4,7 +4,7 @@ import {
4
4
  getAllComponents,
5
5
  getComponent,
6
6
  resolveDependencies
7
- } from "../chunk-KEZKNZR6.js";
7
+ } from "../chunk-T3QWOVJR.js";
8
8
  export {
9
9
  fetchRegistryIndex,
10
10
  fetchRegistryItem,
@@ -69,7 +69,7 @@ declare function detectProject(cwd: string): ProjectInfo;
69
69
  declare function hasGlobalsCss(config: SteraConfig, projectRoot: string): boolean;
70
70
 
71
71
  type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
72
- declare function detectPackageManager(cwd: string): PackageManager;
72
+ declare function detectPackageManager(cwd: string): Promise<PackageManager>;
73
73
  /**
74
74
  * Install npm dependencies, skipping any already in the consumer's package.json.
75
75
  */
@@ -17,7 +17,7 @@ import {
17
17
  resolveOutputPath,
18
18
  transformImports,
19
19
  writeComponentFiles
20
- } from "../chunk-PUJGGJCB.js";
20
+ } from "../chunk-HCHFPFTS.js";
21
21
  export {
22
22
  CHECK,
23
23
  CONFIG_FILE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stera-ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Add Stera UI components to your project.",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "ui",
17
17
  "design-system"
18
18
  ],
19
- "homepage": "https://ui.stera.site",
19
+ "homepage": "https://ui.stera.sh",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -33,7 +33,9 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
+ "@antfu/ni": "^30.0.0",
36
37
  "commander": "^13.1.0",
38
+ "execa": "^9.6.1",
37
39
  "tsconfig-paths": "^4.2.0",
38
40
  "zod": "^3.24.0"
39
41
  },