@vocoder/cli 0.16.0 → 0.16.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.
@@ -44298,9 +44298,65 @@ var VocoderAPI = class {
44298
44298
  }
44299
44299
  };
44300
44300
 
44301
+ // src/utils/auth-store.ts
44302
+ import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
44303
+ import { homedir } from "os";
44304
+ import { dirname, join } from "path";
44305
+ function getAuthFilePath() {
44306
+ return join(homedir(), ".vocoder", "auth.json");
44307
+ }
44308
+ function readAuthData() {
44309
+ const filePath = getAuthFilePath();
44310
+ try {
44311
+ const raw = readFileSync(filePath, "utf8");
44312
+ const parsed = JSON.parse(raw);
44313
+ if (!parsed || typeof parsed !== "object") return null;
44314
+ const data = parsed;
44315
+ if (typeof data.token !== "string" || typeof data.userId !== "string" || typeof data.email !== "string" || typeof data.createdAt !== "string") {
44316
+ return null;
44317
+ }
44318
+ return {
44319
+ token: data.token,
44320
+ userId: data.userId,
44321
+ email: data.email,
44322
+ name: typeof data.name === "string" ? data.name : null,
44323
+ createdAt: data.createdAt
44324
+ };
44325
+ } catch {
44326
+ return null;
44327
+ }
44328
+ }
44329
+ function writeAuthData(data) {
44330
+ const filePath = getAuthFilePath();
44331
+ const dir = dirname(filePath);
44332
+ mkdirSync(dir, { recursive: true, mode: 448 });
44333
+ writeFileSync(filePath, JSON.stringify(data, null, 2), { mode: 384 });
44334
+ }
44335
+ async function verifyStoredAuth(api) {
44336
+ const stored = readAuthData();
44337
+ if (!stored) return { status: "none" };
44338
+ try {
44339
+ const userInfo = await api.getCliUserInfo(stored.token);
44340
+ return { status: "valid", token: stored.token, ...userInfo };
44341
+ } catch (err) {
44342
+ clearAuthData();
44343
+ if (err instanceof VocoderAPIError && err.status === 404) {
44344
+ return { status: "gone" };
44345
+ }
44346
+ return { status: "expired" };
44347
+ }
44348
+ }
44349
+ function clearAuthData() {
44350
+ const filePath = getAuthFilePath();
44351
+ try {
44352
+ unlinkSync(filePath);
44353
+ } catch {
44354
+ }
44355
+ }
44356
+
44301
44357
  // src/utils/detect-local.ts
44302
- import { existsSync, readFileSync } from "fs";
44303
- import { join } from "path";
44358
+ import { existsSync, readFileSync as readFileSync2 } from "fs";
44359
+ import { join as join2 } from "path";
44304
44360
  function detectLocalEcosystem(cwd = process.cwd()) {
44305
44361
  const packageManager = detectPackageManager(cwd);
44306
44362
  const pkg = readPackageJson(cwd);
@@ -44315,7 +44371,7 @@ function detectLocalEcosystem(cwd = process.cwd()) {
44315
44371
  hasConfig: false,
44316
44372
  hasUiPackage: false,
44317
44373
  sourceLocale: null,
44318
- isTypeScript: existsSync(join(cwd, "tsconfig.json"))
44374
+ isTypeScript: existsSync(join2(cwd, "tsconfig.json"))
44319
44375
  };
44320
44376
  }
44321
44377
  const allDeps = {
@@ -44325,7 +44381,7 @@ function detectLocalEcosystem(cwd = process.cwd()) {
44325
44381
  const hasUnplugin = "@vocoder/plugin" in allDeps;
44326
44382
  const hasExtractor = "@vocoder/extractor" in allDeps;
44327
44383
  const hasConfig = "@vocoder/config" in allDeps;
44328
- const isTypeScript = existsSync(join(cwd, "tsconfig.json")) || "typescript" in allDeps;
44384
+ const isTypeScript = existsSync(join2(cwd, "tsconfig.json")) || "typescript" in allDeps;
44329
44385
  const { ecosystem, framework, uiPackage } = detectFromDeps(allDeps, cwd);
44330
44386
  const hasUiPackage = uiPackage !== null && uiPackage in allDeps;
44331
44387
  return {
@@ -44342,17 +44398,17 @@ function detectLocalEcosystem(cwd = process.cwd()) {
44342
44398
  };
44343
44399
  }
44344
44400
  function detectPackageManager(cwd) {
44345
- if (existsSync(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
44346
- if (existsSync(join(cwd, "bun.lockb")) || existsSync(join(cwd, "bun.lock")))
44401
+ if (existsSync(join2(cwd, "pnpm-lock.yaml"))) return "pnpm";
44402
+ if (existsSync(join2(cwd, "bun.lockb")) || existsSync(join2(cwd, "bun.lock")))
44347
44403
  return "bun";
44348
- if (existsSync(join(cwd, "yarn.lock"))) return "yarn";
44404
+ if (existsSync(join2(cwd, "yarn.lock"))) return "yarn";
44349
44405
  return "npm";
44350
44406
  }
44351
44407
  function readPackageJson(cwd) {
44352
- const pkgPath = join(cwd, "package.json");
44408
+ const pkgPath = join2(cwd, "package.json");
44353
44409
  if (!existsSync(pkgPath)) return null;
44354
44410
  try {
44355
- return JSON.parse(readFileSync(pkgPath, "utf-8"));
44411
+ return JSON.parse(readFileSync2(pkgPath, "utf-8"));
44356
44412
  } catch {
44357
44413
  return null;
44358
44414
  }
@@ -44366,7 +44422,7 @@ function detectFromDeps(allDeps, cwd) {
44366
44422
  const framework = "@sveltejs/kit" in allDeps ? "sveltekit" : null;
44367
44423
  return { ecosystem: "svelte", framework, uiPackage: "@vocoder/svelte" };
44368
44424
  }
44369
- if ("@angular/core" in allDeps || existsSync(join(cwd, "angular.json"))) {
44425
+ if ("@angular/core" in allDeps || existsSync(join2(cwd, "angular.json"))) {
44370
44426
  return {
44371
44427
  ecosystem: "angular",
44372
44428
  framework: "angular",
@@ -44409,62 +44465,6 @@ function getPackagesToInstall(detection) {
44409
44465
  return { devPackages, runtimePackages };
44410
44466
  }
44411
44467
 
44412
- // src/utils/auth-store.ts
44413
- import { mkdirSync, readFileSync as readFileSync2, unlinkSync, writeFileSync } from "fs";
44414
- import { homedir } from "os";
44415
- import { dirname, join as join2 } from "path";
44416
- function getAuthFilePath() {
44417
- return join2(homedir(), ".vocoder", "auth.json");
44418
- }
44419
- function readAuthData() {
44420
- const filePath = getAuthFilePath();
44421
- try {
44422
- const raw = readFileSync2(filePath, "utf8");
44423
- const parsed = JSON.parse(raw);
44424
- if (!parsed || typeof parsed !== "object") return null;
44425
- const data = parsed;
44426
- if (typeof data.token !== "string" || typeof data.userId !== "string" || typeof data.email !== "string" || typeof data.createdAt !== "string") {
44427
- return null;
44428
- }
44429
- return {
44430
- token: data.token,
44431
- userId: data.userId,
44432
- email: data.email,
44433
- name: typeof data.name === "string" ? data.name : null,
44434
- createdAt: data.createdAt
44435
- };
44436
- } catch {
44437
- return null;
44438
- }
44439
- }
44440
- function writeAuthData(data) {
44441
- const filePath = getAuthFilePath();
44442
- const dir = dirname(filePath);
44443
- mkdirSync(dir, { recursive: true, mode: 448 });
44444
- writeFileSync(filePath, JSON.stringify(data, null, 2), { mode: 384 });
44445
- }
44446
- async function verifyStoredAuth(api) {
44447
- const stored = readAuthData();
44448
- if (!stored) return { status: "none" };
44449
- try {
44450
- const userInfo = await api.getCliUserInfo(stored.token);
44451
- return { status: "valid", token: stored.token, ...userInfo };
44452
- } catch (err) {
44453
- clearAuthData();
44454
- if (err instanceof VocoderAPIError && err.status === 404) {
44455
- return { status: "gone" };
44456
- }
44457
- return { status: "expired" };
44458
- }
44459
- }
44460
- function clearAuthData() {
44461
- const filePath = getAuthFilePath();
44462
- try {
44463
- unlinkSync(filePath);
44464
- } catch {
44465
- }
44466
- }
44467
-
44468
44468
  // ../extractor/src/config.ts
44469
44469
  var import_parser = __toESM(require_lib());
44470
44470
  var import_traverse = __toESM(require_lib8());
@@ -51390,15 +51390,15 @@ function deduplicateStrings(strings) {
51390
51390
  export {
51391
51391
  VocoderAPIError,
51392
51392
  VocoderAPI,
51393
- detectLocalEcosystem,
51394
- buildInstallCommand,
51395
- getPackagesToInstall,
51396
51393
  readAuthData,
51397
51394
  writeAuthData,
51398
51395
  verifyStoredAuth,
51399
51396
  clearAuthData,
51397
+ detectLocalEcosystem,
51398
+ buildInstallCommand,
51399
+ getPackagesToInstall,
51400
51400
  loadVocoderConfig,
51401
51401
  computeFingerprint,
51402
51402
  StringExtractor
51403
51403
  };
51404
- //# sourceMappingURL=chunk-IK4ZCESQ.mjs.map
51404
+ //# sourceMappingURL=chunk-2JERZ6DL.mjs.map