shadcn-svelte 0.5.0 → 0.6.0

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 CHANGED
@@ -4,9 +4,9 @@
4
4
  import { Command as Command4 } from "commander";
5
5
 
6
6
  // src/commands/add.ts
7
- import { existsSync as existsSync3, promises as fs2 } from "fs";
8
- import path4 from "path";
9
- import chalk2 from "chalk";
7
+ import { existsSync as existsSync2, promises as fs6 } from "fs";
8
+ import path10 from "path";
9
+ import chalk3 from "chalk";
10
10
  import { Command } from "commander";
11
11
  import { execa as execa3 } from "execa";
12
12
  import ora from "ora";
@@ -14,13 +14,434 @@ import prompts2 from "prompts";
14
14
  import { z as z3 } from "zod";
15
15
 
16
16
  // src/utils/get-config.ts
17
- import { existsSync as existsSync2 } from "fs";
18
- import { readFile } from "fs/promises";
19
- import path2 from "path";
17
+ import { promises as fs5 } from "fs";
18
+ import path8 from "path";
19
+ import chalk2 from "chalk";
20
20
  import { execa as execa2 } from "execa";
21
- import { loadConfig } from "tsconfig-paths";
21
+
22
+ // node_modules/.pnpm/tsconfck@2.1.2_typescript@5.3.3/node_modules/tsconfck/dist/index.js
23
+ import path from "path";
24
+ import { promises as fs } from "fs";
25
+ import path2 from "path";
26
+ import path3 from "path";
27
+ import { promises as fs2 } from "fs";
28
+ import path5 from "path";
29
+ import path6 from "path";
30
+ async function find(filename, options) {
31
+ let dir = path.dirname(path.resolve(filename));
32
+ const root = (options == null ? void 0 : options.root) ? path.resolve(options.root) : null;
33
+ while (dir) {
34
+ const tsconfig = await tsconfigInDir(dir, options);
35
+ if (tsconfig) {
36
+ return tsconfig;
37
+ } else {
38
+ if (root === dir) {
39
+ break;
40
+ }
41
+ const parent = path.dirname(dir);
42
+ if (parent === dir) {
43
+ break;
44
+ } else {
45
+ dir = parent;
46
+ }
47
+ }
48
+ }
49
+ throw new Error(`no tsconfig file found for ${filename}`);
50
+ }
51
+ async function tsconfigInDir(dir, options) {
52
+ const tsconfig = path.join(dir, "tsconfig.json");
53
+ if (options == null ? void 0 : options.tsConfigPaths) {
54
+ return options.tsConfigPaths.has(tsconfig) ? tsconfig : void 0;
55
+ }
56
+ try {
57
+ const stat = await fs.stat(tsconfig);
58
+ if (stat.isFile() || stat.isFIFO()) {
59
+ return tsconfig;
60
+ }
61
+ } catch (e) {
62
+ if (e.code !== "ENOENT") {
63
+ throw e;
64
+ }
65
+ }
66
+ }
67
+ var sep = path2.sep;
68
+ var singleComment = Symbol("singleComment");
69
+ var multiComment = Symbol("multiComment");
70
+ var POSIX_SEP_RE = new RegExp("\\" + path3.posix.sep, "g");
71
+ var NATIVE_SEP_RE = new RegExp("\\" + path3.sep, "g");
72
+ var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
73
+ var GLOB_ALL_PATTERN = `**/*`;
74
+ var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
75
+ var DEFAULT_EXTENSIONS_RE_GROUP = `\\.(?:${DEFAULT_EXTENSIONS.map((ext) => ext.substring(1)).join(
76
+ "|"
77
+ )})`;
78
+ var dynamicImportDefault = new Function("path", "return import(path).then(m => m.default)");
79
+ async function loadTS() {
80
+ try {
81
+ return dynamicImportDefault("typescript");
82
+ } catch (e) {
83
+ console.error('typescript must be installed to use "native" functions');
84
+ throw e;
85
+ }
86
+ }
87
+ async function resolveTSConfig(filename) {
88
+ if (path3.extname(filename) !== ".json") {
89
+ return;
90
+ }
91
+ const tsconfig = path3.resolve(filename);
92
+ try {
93
+ const stat = await fs2.stat(tsconfig);
94
+ if (stat.isFile() || stat.isFIFO()) {
95
+ return tsconfig;
96
+ }
97
+ } catch (e) {
98
+ if (e.code !== "ENOENT") {
99
+ throw e;
100
+ }
101
+ }
102
+ throw new Error(`no tsconfig file found for ${filename}`);
103
+ }
104
+ function posix2native(filename) {
105
+ return path3.posix.sep !== path3.sep && filename.includes(path3.posix.sep) ? filename.replace(POSIX_SEP_RE, path3.sep) : filename;
106
+ }
107
+ function native2posix(filename) {
108
+ return path3.posix.sep !== path3.sep && filename.includes(path3.sep) ? filename.replace(NATIVE_SEP_RE, path3.posix.sep) : filename;
109
+ }
110
+ function resolve2posix(dir, filename) {
111
+ if (path3.sep === path3.posix.sep) {
112
+ return dir ? path3.resolve(dir, filename) : path3.resolve(filename);
113
+ }
114
+ return native2posix(
115
+ dir ? path3.resolve(posix2native(dir), posix2native(filename)) : path3.resolve(posix2native(filename))
116
+ );
117
+ }
118
+ function resolveReferencedTSConfigFiles(result) {
119
+ const dir = path3.dirname(result.tsconfigFile);
120
+ return result.tsconfig.references.map((ref) => {
121
+ const refPath = ref.path.endsWith(".json") ? ref.path : path3.join(ref.path, "tsconfig.json");
122
+ return resolve2posix(dir, refPath);
123
+ });
124
+ }
125
+ function resolveSolutionTSConfig(filename, result) {
126
+ if (result.referenced && DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext)) && !isIncluded(filename, result)) {
127
+ const solutionTSConfig = result.referenced.find(
128
+ (referenced) => isIncluded(filename, referenced)
129
+ );
130
+ if (solutionTSConfig) {
131
+ return {
132
+ ...solutionTSConfig,
133
+ solution: result
134
+ };
135
+ }
136
+ }
137
+ return result;
138
+ }
139
+ function isIncluded(filename, result) {
140
+ const dir = native2posix(path3.dirname(result.tsconfigFile));
141
+ const files = (result.tsconfig.files || []).map((file) => resolve2posix(dir, file));
142
+ const absoluteFilename = resolve2posix(null, filename);
143
+ if (files.includes(filename)) {
144
+ return true;
145
+ }
146
+ const isIncluded2 = isGlobMatch(
147
+ absoluteFilename,
148
+ dir,
149
+ result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN])
150
+ );
151
+ if (isIncluded2) {
152
+ const isExcluded = isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || []);
153
+ return !isExcluded;
154
+ }
155
+ return false;
156
+ }
157
+ function isGlobMatch(filename, dir, patterns) {
158
+ return patterns.some((pattern) => {
159
+ let lastWildcardIndex = pattern.length;
160
+ let hasWildcard = false;
161
+ for (let i = pattern.length - 1; i > -1; i--) {
162
+ if (pattern[i] === "*" || pattern[i] === "?") {
163
+ lastWildcardIndex = i;
164
+ hasWildcard = true;
165
+ break;
166
+ }
167
+ }
168
+ if (lastWildcardIndex < pattern.length - 1 && !filename.endsWith(pattern.slice(lastWildcardIndex + 1))) {
169
+ return false;
170
+ }
171
+ if (pattern.endsWith("*") && !DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
172
+ return false;
173
+ }
174
+ if (pattern === GLOB_ALL_PATTERN) {
175
+ return filename.startsWith(`${dir}/`);
176
+ }
177
+ const resolvedPattern = resolve2posix(dir, pattern);
178
+ let firstWildcardIndex = -1;
179
+ for (let i = 0; i < resolvedPattern.length; i++) {
180
+ if (resolvedPattern[i] === "*" || resolvedPattern[i] === "?") {
181
+ firstWildcardIndex = i;
182
+ hasWildcard = true;
183
+ break;
184
+ }
185
+ }
186
+ if (firstWildcardIndex > 1 && !filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1))) {
187
+ return false;
188
+ }
189
+ if (!hasWildcard) {
190
+ return filename === resolvedPattern;
191
+ }
192
+ if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
193
+ return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
194
+ }
195
+ const regex2 = pattern2regex(resolvedPattern);
196
+ PATTERN_REGEX_CACHE.set(resolvedPattern, regex2);
197
+ return regex2.test(filename);
198
+ });
199
+ }
200
+ function pattern2regex(resolvedPattern) {
201
+ let regexStr = "^";
202
+ for (let i = 0; i < resolvedPattern.length; i++) {
203
+ const char = resolvedPattern[i];
204
+ if (char === "?") {
205
+ regexStr += "[^\\/]";
206
+ continue;
207
+ }
208
+ if (char === "*") {
209
+ if (resolvedPattern[i + 1] === "*" && resolvedPattern[i + 2] === "/") {
210
+ i += 2;
211
+ regexStr += "(?:[^\\/]*\\/)*";
212
+ continue;
213
+ }
214
+ regexStr += "[^\\/]*";
215
+ continue;
216
+ }
217
+ if ("/.+^${}()|[]\\".includes(char)) {
218
+ regexStr += `\\`;
219
+ }
220
+ regexStr += char;
221
+ }
222
+ if (resolvedPattern.endsWith("*")) {
223
+ regexStr += DEFAULT_EXTENSIONS_RE_GROUP;
224
+ }
225
+ regexStr += "$";
226
+ return new RegExp(regexStr);
227
+ }
228
+ async function findNative(filename) {
229
+ const ts = await loadTS();
230
+ const { findConfigFile, sys } = ts;
231
+ const tsconfigFile = findConfigFile(path5.dirname(path5.resolve(filename)), sys.fileExists);
232
+ if (!tsconfigFile) {
233
+ throw new Error(`no tsconfig file found for ${filename}`);
234
+ }
235
+ return tsconfigFile;
236
+ }
237
+ async function parseNative(filename, options) {
238
+ const cache = options == null ? void 0 : options.cache;
239
+ if (cache == null ? void 0 : cache.has(filename)) {
240
+ return cache.get(filename);
241
+ }
242
+ let tsconfigFile;
243
+ if (options == null ? void 0 : options.resolveWithEmptyIfConfigNotFound) {
244
+ try {
245
+ tsconfigFile = await resolveTSConfig(filename);
246
+ if (!tsconfigFile) {
247
+ tsconfigFile = await findNative(filename);
248
+ }
249
+ } catch (e) {
250
+ const notFoundResult = {
251
+ tsconfigFile: "no_tsconfig_file_found",
252
+ tsconfig: {},
253
+ result: null
254
+ };
255
+ cache == null ? void 0 : cache.set(filename, notFoundResult);
256
+ return notFoundResult;
257
+ }
258
+ } else {
259
+ tsconfigFile = await resolveTSConfig(filename);
260
+ if (!tsconfigFile) {
261
+ tsconfigFile = await findNative(filename);
262
+ }
263
+ }
264
+ let result;
265
+ if (cache == null ? void 0 : cache.has(tsconfigFile)) {
266
+ result = cache.get(tsconfigFile);
267
+ } else {
268
+ const ts = await loadTS();
269
+ result = await parseFile2(tsconfigFile, ts, options);
270
+ await parseReferences2(result, ts, options);
271
+ cache == null ? void 0 : cache.set(tsconfigFile, result);
272
+ }
273
+ result = resolveSolutionTSConfig(filename, result);
274
+ cache == null ? void 0 : cache.set(filename, result);
275
+ return result;
276
+ }
277
+ async function parseFile2(tsconfigFile, ts, options) {
278
+ const cache = options == null ? void 0 : options.cache;
279
+ if (cache == null ? void 0 : cache.has(tsconfigFile)) {
280
+ return cache.get(tsconfigFile);
281
+ }
282
+ const posixTSConfigFile = native2posix(tsconfigFile);
283
+ const { parseJsonConfigFileContent, readConfigFile, sys } = ts;
284
+ const { config, error } = readConfigFile(posixTSConfigFile, sys.readFile);
285
+ if (error) {
286
+ throw new TSConfckParseNativeError(error, tsconfigFile, null);
287
+ }
288
+ const host = {
289
+ useCaseSensitiveFileNames: false,
290
+ readDirectory: sys.readDirectory,
291
+ fileExists: sys.fileExists,
292
+ readFile: sys.readFile
293
+ };
294
+ if (options == null ? void 0 : options.ignoreSourceFiles) {
295
+ config.files = [];
296
+ config.include = [];
297
+ }
298
+ const nativeResult = parseJsonConfigFileContent(
299
+ config,
300
+ host,
301
+ path6.dirname(posixTSConfigFile),
302
+ void 0,
303
+ posixTSConfigFile
304
+ );
305
+ checkErrors(nativeResult, tsconfigFile);
306
+ const result = {
307
+ tsconfigFile,
308
+ tsconfig: result2tsconfig(nativeResult, ts),
309
+ result: nativeResult
310
+ };
311
+ cache == null ? void 0 : cache.set(tsconfigFile, result);
312
+ return result;
313
+ }
314
+ async function parseReferences2(result, ts, options) {
315
+ if (!result.tsconfig.references) {
316
+ return;
317
+ }
318
+ const referencedFiles = resolveReferencedTSConfigFiles(result);
319
+ result.referenced = await Promise.all(
320
+ referencedFiles.map((file) => parseFile2(file, ts, options))
321
+ );
322
+ }
323
+ function checkErrors(nativeResult, tsconfigFile) {
324
+ var _a;
325
+ const ignoredErrorCodes = [
326
+ // see https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
327
+ 18002,
328
+ // empty files list
329
+ 18003
330
+ // no inputs
331
+ ];
332
+ const criticalError = (_a = nativeResult.errors) == null ? void 0 : _a.find(
333
+ (error) => error.category === 1 && !ignoredErrorCodes.includes(error.code)
334
+ );
335
+ if (criticalError) {
336
+ throw new TSConfckParseNativeError(criticalError, tsconfigFile, nativeResult);
337
+ }
338
+ }
339
+ function result2tsconfig(result, ts) {
340
+ const tsconfig = JSON.parse(JSON.stringify(result.raw));
341
+ const ignoredOptions = ["configFilePath", "pathsBasePath"];
342
+ if (result.options && Object.keys(result.options).some((o) => !ignoredOptions.includes(o))) {
343
+ tsconfig.compilerOptions = {
344
+ ...result.options
345
+ };
346
+ for (const ignored of ignoredOptions) {
347
+ delete tsconfig.compilerOptions[ignored];
348
+ }
349
+ }
350
+ const compilerOptions = tsconfig.compilerOptions;
351
+ if (compilerOptions) {
352
+ if (compilerOptions.lib != null) {
353
+ compilerOptions.lib = compilerOptions.lib.map(
354
+ (x) => x.replace(/^lib\./, "").replace(/\.d\.ts$/, "")
355
+ );
356
+ }
357
+ const enumProperties = [
358
+ { name: "importsNotUsedAsValues", enumeration: ts.ImportsNotUsedAsValues },
359
+ { name: "module", enumeration: ts.ModuleKind },
360
+ {
361
+ name: "moduleResolution",
362
+ enumeration: {
363
+ ...ts.ModuleResolutionKind,
364
+ 2: "node"
365
+ /*ts.ModuleResolutionKind uses "Node10" but in tsconfig it is just node"*/
366
+ }
367
+ },
368
+ {
369
+ name: "newLine",
370
+ enumeration: { 0: "crlf", 1: "lf" }
371
+ /*ts.NewLineKind uses different names*/
372
+ },
373
+ { name: "target", enumeration: ts.ScriptTarget }
374
+ ];
375
+ for (const prop of enumProperties) {
376
+ if (compilerOptions[prop.name] != null && typeof compilerOptions[prop.name] === "number") {
377
+ compilerOptions[prop.name] = prop.enumeration[compilerOptions[prop.name]].toLowerCase();
378
+ }
379
+ }
380
+ if (compilerOptions.target === "latest") {
381
+ compilerOptions.target = "esnext";
382
+ }
383
+ }
384
+ if (result.watchOptions) {
385
+ tsconfig.watchOptions = {
386
+ ...result.watchOptions
387
+ };
388
+ }
389
+ const watchOptions = tsconfig.watchOptions;
390
+ if (watchOptions) {
391
+ const enumProperties = [
392
+ { name: "watchFile", enumeration: ts.WatchFileKind },
393
+ { name: "watchDirectory", enumeration: ts.WatchDirectoryKind },
394
+ { name: "fallbackPolling", enumeration: ts.PollingWatchKind }
395
+ ];
396
+ for (const prop of enumProperties) {
397
+ if (watchOptions[prop.name] != null && typeof watchOptions[prop.name] === "number") {
398
+ const enumVal = prop.enumeration[watchOptions[prop.name]];
399
+ watchOptions[prop.name] = enumVal.charAt(0).toLowerCase() + enumVal.slice(1);
400
+ }
401
+ }
402
+ }
403
+ if (tsconfig.compileOnSave === false) {
404
+ delete tsconfig.compileOnSave;
405
+ }
406
+ return tsconfig;
407
+ }
408
+ var TSConfckParseNativeError = class _TSConfckParseNativeError extends Error {
409
+ constructor(diagnostic, tsconfigFile, result) {
410
+ super(diagnostic.messageText);
411
+ Object.setPrototypeOf(this, _TSConfckParseNativeError.prototype);
412
+ this.name = _TSConfckParseNativeError.name;
413
+ this.code = `TS ${diagnostic.code}`;
414
+ this.diagnostic = diagnostic;
415
+ this.result = result;
416
+ this.tsconfigFile = tsconfigFile;
417
+ }
418
+ };
419
+
420
+ // src/utils/get-config.ts
22
421
  import * as z from "zod";
23
422
 
423
+ // src/utils/get-package-info.ts
424
+ import path4 from "path";
425
+ import { fileURLToPath } from "url";
426
+ import fs3 from "fs-extra";
427
+ function getPackageInfo() {
428
+ const packageJsonPath = getPackageFilePath("../package.json");
429
+ return fs3.readJSONSync(packageJsonPath);
430
+ }
431
+ function getPackageFilePath(filePath) {
432
+ let distPath = fileURLToPath(new URL(`.`, import.meta.url));
433
+ return path4.resolve(distPath, filePath);
434
+ }
435
+ function loadProjectPackageInfo(cwd) {
436
+ const packageJsonPath = path4.resolve(cwd, "package.json");
437
+ return fs3.readJSONSync(packageJsonPath);
438
+ }
439
+ function isUsingSvelteKit(cwd) {
440
+ const packageJSON = loadProjectPackageInfo(cwd);
441
+ const deps = { ...packageJSON.devDependencies, ...packageJSON.dependencies };
442
+ return Object.keys(deps).some((dep) => dep === "@sveltejs/kit");
443
+ }
444
+
24
445
  // node_modules/.pnpm/@antfu+ni@0.21.5/node_modules/@antfu/ni/dist/shared/ni.3ebb7310.mjs
25
446
  import path$3, { join as join$1, dirname, resolve } from "node:path";
26
447
  import process$2 from "node:process";
@@ -31,7 +452,7 @@ import childProcess, { ChildProcess } from "node:child_process";
31
452
  import require$$0$2 from "child_process";
32
453
  import require$$0$1 from "path";
33
454
  import require$$0 from "fs";
34
- import url, { fileURLToPath } from "node:url";
455
+ import url, { fileURLToPath as fileURLToPath2 } from "node:url";
35
456
  import os$1, { constants } from "node:os";
36
457
  import require$$0$3 from "assert";
37
458
  import fs$1, { promises, createWriteStream, createReadStream, existsSync } from "node:fs";
@@ -282,7 +703,7 @@ function checkType(type) {
282
703
  throw new Error(`Invalid type specified: ${type}`);
283
704
  }
284
705
  var matchType = (type, stat) => type === void 0 || stat[typeMappings[type]]();
285
- var toPath$1 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
706
+ var toPath$1 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
286
707
  async function locatePath(paths, {
287
708
  cwd = process$2.cwd(),
288
709
  type = "file",
@@ -302,7 +723,7 @@ async function locatePath(paths, {
302
723
  }
303
724
  }, { concurrency, preserveOrder });
304
725
  }
305
- var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
726
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
306
727
  var findUpStop = Symbol("findUpStop");
307
728
  async function findUpMultiple(name, options = {}) {
308
729
  let directory = path$3.resolve(toPath(options.cwd) || "");
@@ -352,8 +773,8 @@ function requireWindows() {
352
773
  hasRequiredWindows = 1;
353
774
  windows = isexe2;
354
775
  isexe2.sync = sync2;
355
- var fs6 = require$$0;
356
- function checkPathExt(path8, options) {
776
+ var fs9 = require$$0;
777
+ function checkPathExt(path13, options) {
357
778
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
358
779
  if (!pathext) {
359
780
  return true;
@@ -364,25 +785,25 @@ function requireWindows() {
364
785
  }
365
786
  for (var i = 0; i < pathext.length; i++) {
366
787
  var p = pathext[i].toLowerCase();
367
- if (p && path8.substr(-p.length).toLowerCase() === p) {
788
+ if (p && path13.substr(-p.length).toLowerCase() === p) {
368
789
  return true;
369
790
  }
370
791
  }
371
792
  return false;
372
793
  }
373
- function checkStat(stat, path8, options) {
794
+ function checkStat(stat, path13, options) {
374
795
  if (!stat.isSymbolicLink() && !stat.isFile()) {
375
796
  return false;
376
797
  }
377
- return checkPathExt(path8, options);
798
+ return checkPathExt(path13, options);
378
799
  }
379
- function isexe2(path8, options, cb) {
380
- fs6.stat(path8, function(er, stat) {
381
- cb(er, er ? false : checkStat(stat, path8, options));
800
+ function isexe2(path13, options, cb) {
801
+ fs9.stat(path13, function(er, stat) {
802
+ cb(er, er ? false : checkStat(stat, path13, options));
382
803
  });
383
804
  }
384
- function sync2(path8, options) {
385
- return checkStat(fs6.statSync(path8), path8, options);
805
+ function sync2(path13, options) {
806
+ return checkStat(fs9.statSync(path13), path13, options);
386
807
  }
387
808
  return windows;
388
809
  }
@@ -394,14 +815,14 @@ function requireMode() {
394
815
  hasRequiredMode = 1;
395
816
  mode = isexe2;
396
817
  isexe2.sync = sync2;
397
- var fs6 = require$$0;
398
- function isexe2(path8, options, cb) {
399
- fs6.stat(path8, function(er, stat) {
818
+ var fs9 = require$$0;
819
+ function isexe2(path13, options, cb) {
820
+ fs9.stat(path13, function(er, stat) {
400
821
  cb(er, er ? false : checkStat(stat, options));
401
822
  });
402
823
  }
403
- function sync2(path8, options) {
404
- return checkStat(fs6.statSync(path8), options);
824
+ function sync2(path13, options) {
825
+ return checkStat(fs9.statSync(path13), options);
405
826
  }
406
827
  function checkStat(stat, options) {
407
828
  return stat.isFile() && checkMode(stat, options);
@@ -429,7 +850,7 @@ if (process.platform === "win32" || commonjsGlobal.TESTING_WINDOWS) {
429
850
  }
430
851
  var isexe_1 = isexe$2;
431
852
  isexe$2.sync = sync;
432
- function isexe$2(path8, options, cb) {
853
+ function isexe$2(path13, options, cb) {
433
854
  if (typeof options === "function") {
434
855
  cb = options;
435
856
  options = {};
@@ -439,7 +860,7 @@ function isexe$2(path8, options, cb) {
439
860
  throw new TypeError("callback not provided");
440
861
  }
441
862
  return new Promise(function(resolve2, reject) {
442
- isexe$2(path8, options || {}, function(er, is) {
863
+ isexe$2(path13, options || {}, function(er, is) {
443
864
  if (er) {
444
865
  reject(er);
445
866
  } else {
@@ -448,7 +869,7 @@ function isexe$2(path8, options, cb) {
448
869
  });
449
870
  });
450
871
  }
451
- core(path8, options || {}, function(er, is) {
872
+ core(path13, options || {}, function(er, is) {
452
873
  if (er) {
453
874
  if (er.code === "EACCES" || options && options.ignoreErrors) {
454
875
  er = null;
@@ -458,9 +879,9 @@ function isexe$2(path8, options, cb) {
458
879
  cb(er, is);
459
880
  });
460
881
  }
461
- function sync(path8, options) {
882
+ function sync(path13, options) {
462
883
  try {
463
- return core.sync(path8, options || {});
884
+ return core.sync(path13, options || {});
464
885
  } catch (er) {
465
886
  if (options && options.ignoreErrors || er.code === "EACCES") {
466
887
  return false;
@@ -632,29 +1053,29 @@ var shebangCommand$1 = (string3 = "") => {
632
1053
  if (!match) {
633
1054
  return null;
634
1055
  }
635
- const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
636
- const binary = path8.split("/").pop();
1056
+ const [path13, argument] = match[0].replace(/#! ?/, "").split(" ");
1057
+ const binary = path13.split("/").pop();
637
1058
  if (binary === "env") {
638
1059
  return argument;
639
1060
  }
640
1061
  return argument ? `${binary} ${argument}` : binary;
641
1062
  };
642
- var fs = require$$0;
1063
+ var fs4 = require$$0;
643
1064
  var shebangCommand = shebangCommand$1;
644
1065
  function readShebang$1(command) {
645
1066
  const size = 150;
646
1067
  const buffer = Buffer.alloc(size);
647
1068
  let fd;
648
1069
  try {
649
- fd = fs.openSync(command, "r");
650
- fs.readSync(fd, buffer, 0, size, 0);
651
- fs.closeSync(fd);
1070
+ fd = fs4.openSync(command, "r");
1071
+ fs4.readSync(fd, buffer, 0, size, 0);
1072
+ fs4.closeSync(fd);
652
1073
  } catch (e) {
653
1074
  }
654
1075
  return shebangCommand(buffer.toString());
655
1076
  }
656
1077
  var readShebang_1 = readShebang$1;
657
- var path = require$$0$1;
1078
+ var path7 = require$$0$1;
658
1079
  var resolveCommand = resolveCommand_1;
659
1080
  var escape = _escape;
660
1081
  var readShebang = readShebang_1;
@@ -679,7 +1100,7 @@ function parseNonShell(parsed) {
679
1100
  const needsShell = !isExecutableRegExp.test(commandFile);
680
1101
  if (parsed.options.forceShell || needsShell) {
681
1102
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
682
- parsed.command = path.normalize(parsed.command);
1103
+ parsed.command = path7.normalize(parsed.command);
683
1104
  parsed.command = escape.command(parsed.command);
684
1105
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
685
1106
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -815,9 +1236,9 @@ function npmRunPath(options = {}) {
815
1236
  }
816
1237
  function npmRunPathEnv({ env: env2 = process$2.env, ...options } = {}) {
817
1238
  env2 = { ...env2 };
818
- const path8 = pathKey({ env: env2 });
819
- options.path = env2[path8];
820
- env2[path8] = npmRunPath(options);
1239
+ const path13 = pathKey({ env: env2 });
1240
+ options.path = env2[path13];
1241
+ env2[path13] = npmRunPath(options);
821
1242
  return env2;
822
1243
  }
823
1244
  var copyProperty = (to, from, property, ignoreNonConfigurable) => {
@@ -4397,9 +4818,9 @@ var elements = {
4397
4818
  $2.date = (args) => toPrompt("DatePrompt", args);
4398
4819
  $2.confirm = (args) => toPrompt("ConfirmPrompt", args);
4399
4820
  $2.list = (args) => {
4400
- const sep2 = args.separator || ",";
4821
+ const sep3 = args.separator || ",";
4401
4822
  return toPrompt("TextPrompt", args, {
4402
- onSubmit: (str) => str.split(sep2).map((s) => s.trim())
4823
+ onSubmit: (str) => str.split(sep3).map((s) => s.trim())
4403
4824
  });
4404
4825
  };
4405
4826
  $2.toggle = (args) => toPrompt("TogglePrompt", args);
@@ -4502,9 +4923,9 @@ var lib$1 = Object.assign(prompt, { prompt, prompts: prompts$2, inject, override
4502
4923
  var prompts = lib$1;
4503
4924
  var prompts$1 = /* @__PURE__ */ getDefaultExportFromCjs(prompts);
4504
4925
  var isexe = isexe_1;
4505
- var { join, delimiter, sep, posix } = require$$0$1;
4926
+ var { join, delimiter, sep: sep2, posix } = require$$0$1;
4506
4927
  var isWindows = process.platform === "win32";
4507
- var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
4928
+ var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
4508
4929
  var rRel = new RegExp(`^\\.${rSlash.source}`);
4509
4930
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
4510
4931
  var getPathInfo = (cmd, {
@@ -4757,15 +5178,31 @@ async function getPackageManager(targetDir) {
4757
5178
  return packageManager ?? "npm";
4758
5179
  }
4759
5180
 
5181
+ // src/utils/logger.ts
5182
+ import chalk from "chalk";
5183
+ var logger = {
5184
+ error(...args) {
5185
+ console.log(chalk.red(...args));
5186
+ },
5187
+ warn(...args) {
5188
+ console.log(chalk.yellow(...args));
5189
+ },
5190
+ info(...args) {
5191
+ console.log(chalk.cyan(...args));
5192
+ },
5193
+ success(...args) {
5194
+ console.log(chalk.green(...args));
5195
+ },
5196
+ highlight(...args) {
5197
+ return chalk.cyan(...args);
5198
+ }
5199
+ };
5200
+
4760
5201
  // src/utils/resolve-imports.ts
4761
5202
  import { createMatchPath } from "tsconfig-paths";
4762
5203
  async function resolveImport(importPath, config) {
4763
5204
  const matchPath = createMatchPath(config.absoluteBaseUrl, config.paths);
4764
- return matchPath(importPath, void 0, () => true, [
4765
- ".ts",
4766
- ".svelte",
4767
- ".js"
4768
- ]);
5205
+ return matchPath(importPath, void 0, () => true, [".ts", ".svelte", ".js"]);
4769
5206
  }
4770
5207
 
4771
5208
  // src/utils/get-config.ts
@@ -4803,8 +5240,8 @@ async function getConfig2(cwd) {
4803
5240
  return await resolveConfigPaths(cwd, config);
4804
5241
  }
4805
5242
  async function resolveConfigPaths(cwd, config) {
4806
- const TSCONFIG_PATH = ".svelte-kit/tsconfig.json";
4807
- if (!existsSync2(TSCONFIG_PATH)) {
5243
+ const isSvelteKit = isUsingSvelteKit(cwd);
5244
+ if (isSvelteKit) {
4808
5245
  const packageManager = await getPackageManager(cwd);
4809
5246
  await execa2(
4810
5247
  packageManager === "npm" ? "npx" : packageManager,
@@ -4814,32 +5251,43 @@ async function resolveConfigPaths(cwd, config) {
4814
5251
  }
4815
5252
  );
4816
5253
  }
4817
- const tsconfigPath = path2.resolve(cwd, TSCONFIG_PATH);
4818
- const tsConfig = loadConfig(tsconfigPath);
4819
- if (tsConfig.resultType === "failed") {
5254
+ const tsconfigPath = await find(path8.resolve(cwd, "package.json"), { root: cwd });
5255
+ if (tsconfigPath === null)
5256
+ throw new Error(`Failed to find ${logger.highlight("tsconfig.json")}.`);
5257
+ const parsedConfig = await parseNative(tsconfigPath);
5258
+ const absoluteBaseUrl = parsedConfig.result.options.pathsBasePath;
5259
+ let paths = parsedConfig.result.options.paths;
5260
+ if (absoluteBaseUrl === void 0 || paths === void 0) {
4820
5261
  throw new Error(
4821
- `Failed to load .svelte-kit/tsconfig.json. Error: ${tsConfig.message ?? ""}`.trim()
5262
+ `Specify a ${logger.highlight("paths")} field in your ${logger.highlight(
5263
+ "tsconfig.json"
5264
+ )} and define your path aliases.
5265
+
5266
+ See: ${chalk2.green(
5267
+ "https://www.shadcn-svelte.com/docs/installation#setup-path-aliases"
5268
+ )}`
4822
5269
  );
4823
5270
  }
4824
- const utilsPath = await resolveImport(config.aliases["utils"], tsConfig);
4825
- const componentsPath = await resolveImport(
4826
- config.aliases["components"],
4827
- tsConfig
4828
- );
5271
+ const importOpts = {
5272
+ absoluteBaseUrl,
5273
+ paths
5274
+ };
5275
+ const utilsPath = await resolveImport(config.aliases.utils, importOpts);
5276
+ const componentsPath = await resolveImport(config.aliases.components, importOpts);
4829
5277
  return configSchema.parse({
4830
5278
  ...config,
4831
5279
  resolvedPaths: {
4832
- tailwindConfig: path2.resolve(cwd, config.tailwind.config),
4833
- tailwindCss: path2.resolve(cwd, config.tailwind.css),
5280
+ tailwindConfig: path8.resolve(cwd, config.tailwind.config),
5281
+ tailwindCss: path8.resolve(cwd, config.tailwind.css),
4834
5282
  utils: utilsPath,
4835
5283
  components: componentsPath
4836
5284
  }
4837
5285
  });
4838
5286
  }
4839
5287
  async function getRawConfig(cwd) {
5288
+ const configPath = path8.resolve(cwd, "components.json");
4840
5289
  try {
4841
- const configPath = path2.resolve(cwd, "components.json");
4842
- const configResult = await readFile(configPath, {
5290
+ const configResult = await fs5.readFile(configPath, {
4843
5291
  encoding: "utf8"
4844
5292
  }).catch((e) => null);
4845
5293
  if (!configResult) {
@@ -4849,7 +5297,7 @@ async function getRawConfig(cwd) {
4849
5297
  return rawConfigSchema.parse(config);
4850
5298
  } catch (error) {
4851
5299
  throw new Error(
4852
- `Invalid configuration found in ${cwd}/components.json.`
5300
+ `Invalid configuration found in ${logger.highlight(configPath)}.`
4853
5301
  );
4854
5302
  }
4855
5303
  }
@@ -4860,42 +5308,24 @@ function getEnvProxy() {
4860
5308
  return HTTP_PROXY || http_proxy;
4861
5309
  }
4862
5310
 
4863
- // src/utils/logger.ts
4864
- import chalk from "chalk";
4865
- var logger = {
4866
- error(...args) {
4867
- console.log(chalk.red(...args));
4868
- },
4869
- warn(...args) {
4870
- console.log(chalk.yellow(...args));
4871
- },
4872
- info(...args) {
4873
- console.log(chalk.cyan(...args));
4874
- },
4875
- success(...args) {
4876
- console.log(chalk.green(...args));
4877
- },
4878
- highlight(...args) {
4879
- return chalk.cyan(...args);
4880
- }
4881
- };
4882
-
4883
5311
  // src/utils/handle-error.ts
4884
5312
  function handleError(error) {
5313
+ const PREFIX = "ERROR: ";
5314
+ logger.error();
4885
5315
  if (typeof error === "string") {
4886
- logger.error(error);
5316
+ logger.error(PREFIX + error);
4887
5317
  process.exit(1);
4888
5318
  }
4889
5319
  if (error instanceof Error) {
4890
- logger.error(error.message);
5320
+ logger.error(PREFIX + error.message);
4891
5321
  process.exit(1);
4892
5322
  }
4893
- logger.error("Something went wrong. Please try again.");
5323
+ logger.error(PREFIX + "Something went wrong. Please try again.");
4894
5324
  process.exit(1);
4895
5325
  }
4896
5326
 
4897
5327
  // src/utils/registry/index.ts
4898
- import path3 from "path";
5328
+ import path9 from "path";
4899
5329
  import { HttpsProxyAgent } from "https-proxy-agent";
4900
5330
  import fetch from "node-fetch";
4901
5331
 
@@ -4906,11 +5336,7 @@ var registryItemSchema = z2.object({
4906
5336
  dependencies: z2.array(z2.string()).optional(),
4907
5337
  registryDependencies: z2.array(z2.string()).optional(),
4908
5338
  files: z2.array(z2.string()),
4909
- type: z2.enum([
4910
- "components:ui",
4911
- "components:component",
4912
- "components:example"
4913
- ])
5339
+ type: z2.enum(["components:ui", "components:component", "components:example"])
4914
5340
  });
4915
5341
  var registryIndexSchema = z2.array(registryItemSchema);
4916
5342
  var registryItemWithContentSchema = registryItemSchema.extend({
@@ -5001,10 +5427,7 @@ async function resolveTree(index, names) {
5001
5427
  }
5002
5428
  tree.push(entry);
5003
5429
  if (entry.registryDependencies) {
5004
- const dependencies = await resolveTree(
5005
- index,
5006
- entry.registryDependencies
5007
- );
5430
+ const dependencies = await resolveTree(index, entry.registryDependencies);
5008
5431
  tree.push(...dependencies);
5009
5432
  }
5010
5433
  }
@@ -5029,7 +5452,7 @@ async function getItemTargetPath(config, item2, override2) {
5029
5452
  if (!(parent in config.resolvedPaths)) {
5030
5453
  return null;
5031
5454
  }
5032
- return path3.join(
5455
+ return path9.join(
5033
5456
  config.resolvedPaths[parent],
5034
5457
  type
5035
5458
  );
@@ -5041,11 +5464,8 @@ async function fetchRegistry(paths) {
5041
5464
  options.agent = new HttpsProxyAgent(proxyUrl);
5042
5465
  }
5043
5466
  const results = await Promise.all(
5044
- paths.map(async (path8) => {
5045
- const response = await fetch(
5046
- `${baseUrl}/registry/${path8}`,
5047
- options
5048
- );
5467
+ paths.map(async (path13) => {
5468
+ const response = await fetch(`${baseUrl}/registry/${path13}`, options);
5049
5469
  return await response.json();
5050
5470
  })
5051
5471
  );
@@ -6116,11 +6536,7 @@ var addOptionsSchema = z3.object({
6116
6536
  nodep: z3.boolean(),
6117
6537
  proxy: z3.string().optional()
6118
6538
  });
6119
- var add = new Command().command("add").description("add components to your project").argument("[components...]", "name of components").option(
6120
- "--nodep",
6121
- "disable adding & installing dependencies (advanced)",
6122
- false
6123
- ).option("-a, --all", "Add all components to your project.", false).option("-y, --yes", "Skip confirmation prompt.", false).option("-o, --overwrite", "overwrite existing files.", false).option("--proxy <proxy>", "fetch components from registry using a proxy.").option(
6539
+ var add = new Command().command("add").description("add components to your project").argument("[components...]", "name of components").option("--nodep", "disable adding & installing dependencies (advanced)", false).option("-a, --all", "Add all components to your project.", false).option("-y, --yes", "Skip confirmation prompt.", false).option("-o, --overwrite", "overwrite existing files.", false).option("--proxy <proxy>", "fetch components from registry using a proxy.").option(
6124
6540
  "-c, --cwd <cwd>",
6125
6541
  "the working directory. defaults to the current directory.",
6126
6542
  process.cwd()
@@ -6131,18 +6547,16 @@ var add = new Command().command("add").description("add components to your proje
6131
6547
  components,
6132
6548
  ...opts
6133
6549
  });
6134
- const cwd = path4.resolve(options.cwd);
6135
- if (!existsSync3(cwd)) {
6136
- logger.error(
6137
- `The path ${cwd} does not exist. Please try again.`
6138
- );
6550
+ const cwd = path10.resolve(options.cwd);
6551
+ if (!existsSync2(cwd)) {
6552
+ logger.error(`The path ${cwd} does not exist. Please try again.`);
6139
6553
  process.exitCode = 1;
6140
6554
  return;
6141
6555
  }
6142
6556
  const config = await getConfig2(cwd);
6143
6557
  if (!config) {
6144
6558
  logger.warn(
6145
- `Configuration is missing. Please run ${chalk2.green(
6559
+ `Configuration is missing. Please run ${chalk3.green(
6146
6560
  `init`
6147
6561
  )} to create a components.json file.`
6148
6562
  );
@@ -6155,7 +6569,7 @@ var add = new Command().command("add").description("add components to your proje
6155
6569
  if (isCustom)
6156
6570
  process.env.HTTP_PROXY = options.proxy;
6157
6571
  logger.warn(
6158
- `You are using a ${isCustom ? "provided" : "system environment"} proxy: ${chalk2.green(chosenProxy)}`
6572
+ `You are using a ${isCustom ? "provided" : "system environment"} proxy: ${chalk3.green(chosenProxy)}`
6159
6573
  );
6160
6574
  }
6161
6575
  const registryIndex = await getRegistryIndex();
@@ -6181,18 +6595,14 @@ var add = new Command().command("add").description("add components to your proje
6181
6595
  }
6182
6596
  const tree = await resolveTree(registryIndex, selectedComponents);
6183
6597
  const payload = await fetchTree(config.style, tree);
6184
- const baseColor = await getRegistryBaseColor(
6185
- config.tailwind.baseColor
6186
- );
6598
+ const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
6187
6599
  if (!payload.length) {
6188
6600
  logger.warn("Selected components not found. Exiting.");
6189
6601
  process.exitCode = 0;
6190
6602
  return;
6191
6603
  }
6192
- logger.info(
6193
- `Selected components:
6194
- ${highlight(selectedComponents)}`
6195
- );
6604
+ logger.info(`Selected components:
6605
+ ${highlight(selectedComponents)}`);
6196
6606
  if (!options.yes) {
6197
6607
  const { proceed } = await prompts2({
6198
6608
  type: "confirm",
@@ -6213,20 +6623,20 @@ ${highlight(selectedComponents)}`
6213
6623
  const targetDir = await getItemTargetPath(
6214
6624
  config,
6215
6625
  item2,
6216
- options.path ? path4.resolve(cwd, options.path) : void 0
6626
+ options.path ? path10.resolve(cwd, options.path) : void 0
6217
6627
  );
6218
6628
  if (!targetDir) {
6219
6629
  continue;
6220
6630
  }
6221
- if (!existsSync3(targetDir)) {
6222
- await fs2.mkdir(targetDir, { recursive: true });
6631
+ if (!existsSync2(targetDir)) {
6632
+ await fs6.mkdir(targetDir, { recursive: true });
6223
6633
  }
6224
- const componentPath = path4.relative(
6634
+ const componentPath = path10.relative(
6225
6635
  process.cwd(),
6226
- path4.resolve(targetDir, item2.name)
6636
+ path10.resolve(targetDir, item2.name)
6227
6637
  );
6228
6638
  const existingComponent = item2.files.filter(
6229
- (file) => existsSync3(path4.resolve(targetDir, item2.name, file.name))
6639
+ (file) => existsSync2(path10.resolve(targetDir, item2.name, file.name))
6230
6640
  );
6231
6641
  if (existingComponent.length && !options.overwrite) {
6232
6642
  if (selectedComponents.includes(item2.name)) {
@@ -6236,7 +6646,7 @@ Component ${highlight(
6236
6646
  item2.name
6237
6647
  )} already exists at ${highlight(
6238
6648
  componentPath
6239
- )}. Use ${chalk2.green("--overwrite")} to overwrite.`
6649
+ )}. Use ${chalk3.green("--overwrite")} to overwrite.`
6240
6650
  );
6241
6651
  spinner.stop();
6242
6652
  process.exitCode = 1;
@@ -6245,23 +6655,17 @@ Component ${highlight(
6245
6655
  continue;
6246
6656
  }
6247
6657
  for (const file of item2.files) {
6248
- const componentDir = path4.resolve(targetDir, item2.name);
6249
- let filePath = path4.resolve(
6250
- targetDir,
6251
- item2.name,
6252
- file.name
6253
- );
6658
+ const componentDir = path10.resolve(targetDir, item2.name);
6659
+ let filePath = path10.resolve(targetDir, item2.name, file.name);
6254
6660
  const content = transformImport(file.content, config);
6255
- if (!existsSync3(componentDir)) {
6256
- await fs2.mkdir(componentDir, { recursive: true });
6661
+ if (!existsSync2(componentDir)) {
6662
+ await fs6.mkdir(componentDir, { recursive: true });
6257
6663
  }
6258
- await fs2.writeFile(filePath, content);
6664
+ await fs6.writeFile(filePath, content);
6259
6665
  }
6260
6666
  if (item2.dependencies?.length) {
6261
6667
  if (options.nodep) {
6262
- item2.dependencies.forEach(
6263
- (dep) => skippedDeps.add(dep)
6264
- );
6668
+ item2.dependencies.forEach((dep) => skippedDeps.add(dep));
6265
6669
  continue;
6266
6670
  }
6267
6671
  const packageManager = await getPackageManager(cwd);
@@ -6291,9 +6695,7 @@ Component ${highlight(
6291
6695
  spinner.succeed(`Done.`);
6292
6696
  logger.info(
6293
6697
  `Components installed at:
6294
- - ${[...componentPaths].join(
6295
- "\n- "
6296
- )}`
6698
+ - ${[...componentPaths].join("\n- ")}`
6297
6699
  );
6298
6700
  } catch (error) {
6299
6701
  handleError(error);
@@ -6301,9 +6703,9 @@ Component ${highlight(
6301
6703
  });
6302
6704
 
6303
6705
  // src/commands/init.ts
6304
- import { existsSync as existsSync4, promises as fs3 } from "fs";
6305
- import path5 from "path";
6306
- import chalk3 from "chalk";
6706
+ import { existsSync as existsSync3, promises as fs7 } from "fs";
6707
+ import path11 from "path";
6708
+ import chalk4 from "chalk";
6307
6709
  import { Command as Command2 } from "commander";
6308
6710
  import { execa as execa4 } from "execa";
6309
6711
  import ora2 from "ora";
@@ -6439,17 +6841,13 @@ export default config;
6439
6841
  `;
6440
6842
 
6441
6843
  // src/commands/init.ts
6442
- var PROJECT_DEPENDENCIES = [
6443
- "tailwind-variants",
6444
- "clsx",
6445
- "tailwind-merge"
6446
- ];
6844
+ var PROJECT_DEPENDENCIES = ["tailwind-variants", "clsx", "tailwind-merge"];
6447
6845
  var init2 = new Command2().command("init").description("Configure your SvelteKit project.").option("-y, --yes", "Skip confirmation prompt.").option(
6448
6846
  "-c, --cwd <cwd>",
6449
6847
  "the working directory. defaults to the current directory.",
6450
6848
  process.cwd()
6451
6849
  ).action(async (options) => {
6452
- const cwd = path5.resolve(options.cwd);
6850
+ const cwd = path11.resolve(options.cwd);
6453
6851
  logger.warn(
6454
6852
  "This command assumes a SvelteKit project with TypeScript and Tailwind CSS."
6455
6853
  );
@@ -6472,24 +6870,16 @@ var init2 = new Command2().command("init").description("Configure your SvelteKit
6472
6870
  }
6473
6871
  }
6474
6872
  try {
6475
- if (!existsSync4(cwd)) {
6476
- logger.error(
6477
- `The path ${cwd} does not exist. Please try again.`
6478
- );
6873
+ if (!existsSync3(cwd)) {
6874
+ logger.error(`The path ${cwd} does not exist. Please try again.`);
6479
6875
  process.exitCode = 1;
6480
6876
  return;
6481
6877
  }
6482
6878
  const existingConfig = await getConfig2(cwd);
6483
- const config = await promptForConfig(
6484
- cwd,
6485
- existingConfig,
6486
- options.yes
6487
- );
6879
+ const config = await promptForConfig(cwd, existingConfig, options.yes);
6488
6880
  await runInit(cwd, config);
6489
6881
  logger.info("");
6490
- logger.info(
6491
- `${chalk3.green("Success!")} Project initialization completed.`
6492
- );
6882
+ logger.info(`${chalk4.green("Success!")} Project initialization completed.`);
6493
6883
  logger.info("");
6494
6884
  logger.info(
6495
6885
  "Don't forget to add the aliases you configured to your svelte.config.js!"
@@ -6516,9 +6906,7 @@ async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6516
6906
  {
6517
6907
  type: "select",
6518
6908
  name: "tailwindBaseColor",
6519
- message: `Which color would you like to use as ${highlight(
6520
- "base color"
6521
- )}?`,
6909
+ message: `Which color would you like to use as ${highlight("base color")}?`,
6522
6910
  choices: baseColors.map((color2) => ({
6523
6911
  title: color2.label,
6524
6912
  value: color2.name
@@ -6530,30 +6918,24 @@ async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6530
6918
  message: `Where is your ${highlight("global CSS")} file?`,
6531
6919
  initial: defaultConfig?.tailwind.css ?? DEFAULT_TAILWIND_CSS,
6532
6920
  validate: (value) => {
6533
- if (existsSync4(value)) {
6921
+ if (existsSync3(value)) {
6534
6922
  return true;
6535
6923
  }
6536
- logger.error(
6537
- `${value} does not exist. Please enter a valid path.`
6538
- );
6924
+ logger.error(`${value} does not exist. Please enter a valid path.`);
6539
6925
  return false;
6540
6926
  }
6541
6927
  },
6542
6928
  {
6543
6929
  type: "text",
6544
6930
  name: "tailwindConfig",
6545
- message: `Where is your ${highlight(
6546
- "tailwind.config.[cjs|js|ts]"
6547
- )} located?`,
6931
+ message: `Where is your ${highlight("tailwind.config.[cjs|js|ts]")} located?`,
6548
6932
  initial: defaultConfig?.tailwind.config ?? DEFAULT_TAILWIND_CONFIG,
6549
6933
  validate: (value) => {
6550
- if (existsSync4(value)) {
6934
+ if (existsSync3(value)) {
6551
6935
  return true;
6552
6936
  }
6553
6937
  logger.info("");
6554
- logger.error(
6555
- `${value} does not exist. Please enter a valid path.`
6556
- );
6938
+ logger.error(`${value} does not exist. Please enter a valid path.`);
6557
6939
  logger.info("");
6558
6940
  return false;
6559
6941
  }
@@ -6561,9 +6943,7 @@ async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6561
6943
  {
6562
6944
  type: "text",
6563
6945
  name: "components",
6564
- message: `Configure the import alias for ${highlight(
6565
- "components"
6566
- )}:`,
6946
+ message: `Configure the import alias for ${highlight("components")}:`,
6567
6947
  initial: defaultConfig?.aliases["components"] ?? DEFAULT_COMPONENTS
6568
6948
  },
6569
6949
  {
@@ -6590,9 +6970,7 @@ async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6590
6970
  const { proceed } = await prompts3({
6591
6971
  type: "confirm",
6592
6972
  name: "proceed",
6593
- message: `Write configuration to ${highlight(
6594
- "components.json"
6595
- )}. Proceed?`,
6973
+ message: `Write configuration to ${highlight("components.json")}. Proceed?`,
6596
6974
  initial: true
6597
6975
  });
6598
6976
  if (!proceed) {
@@ -6600,57 +6978,46 @@ async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6600
6978
  }
6601
6979
  }
6602
6980
  if (config.tailwind.config.endsWith(".cjs")) {
6603
- logger.info(
6604
- "Your tailwind.config.cjs has been renamed to tailwind.config.js."
6605
- );
6606
- const renamedTailwindConfigPath = config.tailwind.config.replace(
6607
- ".cjs",
6608
- ".js"
6609
- );
6981
+ logger.info("Your tailwind.config.cjs has been renamed to tailwind.config.js.");
6982
+ const renamedTailwindConfigPath = config.tailwind.config.replace(".cjs", ".js");
6610
6983
  config.tailwind.config = renamedTailwindConfigPath;
6611
6984
  }
6985
+ const configPaths = await resolveConfigPaths(cwd, config);
6612
6986
  logger.info("");
6613
6987
  const spinner = ora2(`Writing components.json...`).start();
6614
- const targetPath = path5.resolve(cwd, "components.json");
6615
- await fs3.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
6988
+ const targetPath = path11.resolve(cwd, "components.json");
6989
+ await fs7.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
6616
6990
  spinner.succeed();
6617
- return await resolveConfigPaths(cwd, config);
6991
+ return configPaths;
6618
6992
  }
6619
6993
  async function runInit(cwd, config) {
6620
6994
  const spinner = ora2(`Initializing project...`)?.start();
6621
6995
  for (const [key, resolvedPath] of Object.entries(config.resolvedPaths)) {
6622
- let dirname2 = path5.extname(resolvedPath) ? path5.dirname(resolvedPath) : resolvedPath;
6996
+ let dirname2 = path11.extname(resolvedPath) ? path11.dirname(resolvedPath) : resolvedPath;
6623
6997
  if (key === "utils" && resolvedPath.endsWith("/utils")) {
6624
6998
  dirname2 = dirname2.replace(/\/utils$/, "");
6625
6999
  }
6626
- if (!existsSync4(dirname2) && key !== "utils") {
6627
- await fs3.mkdir(dirname2, { recursive: true });
7000
+ if (!existsSync3(dirname2) && key !== "utils") {
7001
+ await fs7.mkdir(dirname2, { recursive: true });
6628
7002
  }
6629
7003
  }
6630
- await fs3.writeFile(
7004
+ await fs7.writeFile(
6631
7005
  config.resolvedPaths.tailwindConfig,
6632
7006
  TAILWIND_CONFIG_WITH_VARIABLES,
6633
7007
  "utf8"
6634
7008
  );
6635
- const cjsConfig = config.resolvedPaths.tailwindConfig.replace(
6636
- ".js",
6637
- ".cjs"
6638
- );
7009
+ const cjsConfig = config.resolvedPaths.tailwindConfig.replace(".js", ".cjs");
6639
7010
  if (cjsConfig.endsWith(".cjs"))
6640
- await fs3.unlink(cjsConfig).catch((e) => e);
7011
+ await fs7.unlink(cjsConfig).catch((e) => e);
6641
7012
  const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
6642
7013
  if (baseColor) {
6643
- await fs3.writeFile(
7014
+ await fs7.writeFile(
6644
7015
  config.resolvedPaths.tailwindCss,
6645
7016
  baseColor.cssVarsTemplate,
6646
7017
  "utf8"
6647
7018
  );
6648
7019
  }
6649
- await fs3.writeFile(
6650
- `${config.resolvedPaths.utils}.ts`,
6651
- UTILS,
6652
- "utf8"
6653
- );
7020
+ await fs7.writeFile(`${config.resolvedPaths.utils}.ts`, UTILS, "utf8");
6654
7021
  spinner?.succeed();
6655
7022
  const dependenciesSpinner = ora2(`Installing dependencies...`)?.start();
6656
7023
  const packageManager = await getPackageManager(cwd);
@@ -6658,20 +7025,16 @@ async function runInit(cwd, config) {
6658
7025
  ...PROJECT_DEPENDENCIES,
6659
7026
  config.style === "new-york" ? "radix-icons-svelte" : "lucide-svelte"
6660
7027
  ];
6661
- await execa4(
6662
- packageManager,
6663
- [packageManager === "npm" ? "install" : "add", ...deps],
6664
- {
6665
- cwd
6666
- }
6667
- );
7028
+ await execa4(packageManager, [packageManager === "npm" ? "install" : "add", ...deps], {
7029
+ cwd
7030
+ });
6668
7031
  dependenciesSpinner?.succeed();
6669
7032
  }
6670
7033
 
6671
7034
  // src/commands/update.ts
6672
- import { existsSync as existsSync5, promises as fs4 } from "fs";
6673
- import path6 from "path";
6674
- import chalk4 from "chalk";
7035
+ import { existsSync as existsSync4, promises as fs8 } from "fs";
7036
+ import path12 from "path";
7037
+ import chalk5 from "chalk";
6675
7038
  import { Command as Command3 } from "commander";
6676
7039
  import { execa as execa5 } from "execa";
6677
7040
  import ora3 from "ora";
@@ -6687,12 +7050,8 @@ var update = new Command3().command("update").description("update components in
6687
7050
  "the working directory. defaults to the current directory.",
6688
7051
  process.cwd()
6689
7052
  ).action(async (comps, opts) => {
6690
- logger.warn(
6691
- "Running the following command will overwrite existing files."
6692
- );
6693
- logger.warn(
6694
- "Make sure you have committed your changes before proceeding."
6695
- );
7053
+ logger.warn("Running the following command will overwrite existing files.");
7054
+ logger.warn("Make sure you have committed your changes before proceeding.");
6696
7055
  logger.warn("");
6697
7056
  try {
6698
7057
  const options = updateOptionsSchema.parse({
@@ -6700,18 +7059,16 @@ var update = new Command3().command("update").description("update components in
6700
7059
  ...opts
6701
7060
  });
6702
7061
  const components = options.components;
6703
- const cwd = path6.resolve(options.cwd);
6704
- if (!existsSync5(cwd)) {
6705
- logger.error(
6706
- `The path ${cwd} does not exist. Please try again.`
6707
- );
7062
+ const cwd = path12.resolve(options.cwd);
7063
+ if (!existsSync4(cwd)) {
7064
+ logger.error(`The path ${cwd} does not exist. Please try again.`);
6708
7065
  process.exitCode = 1;
6709
7066
  return;
6710
7067
  }
6711
7068
  const config = await getConfig2(cwd);
6712
7069
  if (!config) {
6713
7070
  logger.warn(
6714
- `Configuration is missing. Please run ${chalk4.green(
7071
+ `Configuration is missing. Please run ${chalk5.green(
6715
7072
  `init`
6716
7073
  )} to create a components.json file.`
6717
7074
  );
@@ -6719,17 +7076,14 @@ var update = new Command3().command("update").description("update components in
6719
7076
  return;
6720
7077
  }
6721
7078
  const registryIndex = await getRegistryIndex();
6722
- const componentDir = path6.resolve(
6723
- config.resolvedPaths.components,
6724
- "ui"
6725
- );
6726
- if (!existsSync5(componentDir)) {
7079
+ const componentDir = path12.resolve(config.resolvedPaths.components, "ui");
7080
+ if (!existsSync4(componentDir)) {
6727
7081
  logger.error(`Component dir '${componentDir}' does not exist.`);
6728
7082
  process.exitCode = 1;
6729
7083
  return;
6730
7084
  }
6731
7085
  const existingComponents = [];
6732
- const files = await fs4.readdir(componentDir, {
7086
+ const files = await fs8.readdir(componentDir, {
6733
7087
  withFileTypes: true
6734
7088
  });
6735
7089
  for (const file of files) {
@@ -6754,9 +7108,7 @@ var update = new Command3().command("update").description("update components in
6754
7108
  );
6755
7109
  }
6756
7110
  if (existingComponents.length === 0) {
6757
- logger.info(
6758
- `No shadcn components detected in '${componentDir}'.`
6759
- );
7111
+ logger.info(`No shadcn components detected in '${componentDir}'.`);
6760
7112
  process.exitCode = 0;
6761
7113
  return;
6762
7114
  }
@@ -6776,16 +7128,14 @@ var update = new Command3().command("update").description("update components in
6776
7128
  }
6777
7129
  if (selectedComponents.find((item2) => item2.name === "utils")) {
6778
7130
  const utilsPath = config.resolvedPaths.utils + ".ts";
6779
- if (!existsSync5(utilsPath)) {
7131
+ if (!existsSync4(utilsPath)) {
6780
7132
  spinner.fail(
6781
- `utils at ${logger.highlight(
6782
- utilsPath
6783
- )} does not exist.`
7133
+ `utils at ${logger.highlight(utilsPath)} does not exist.`
6784
7134
  );
6785
7135
  process.exitCode = 1;
6786
7136
  return;
6787
7137
  }
6788
- await fs4.writeFile(utilsPath, UTILS);
7138
+ await fs8.writeFile(utilsPath, UTILS);
6789
7139
  }
6790
7140
  const tree = await resolveTree(
6791
7141
  registryIndex,
@@ -6798,21 +7148,17 @@ var update = new Command3().command("update").description("update components in
6798
7148
  if (!targetDir) {
6799
7149
  continue;
6800
7150
  }
6801
- if (!existsSync5(targetDir)) {
6802
- await fs4.mkdir(targetDir, { recursive: true });
7151
+ if (!existsSync4(targetDir)) {
7152
+ await fs8.mkdir(targetDir, { recursive: true });
6803
7153
  }
6804
7154
  for (const file of item2.files) {
6805
- const componentDir2 = path6.resolve(targetDir, item2.name);
6806
- let filePath = path6.resolve(
6807
- targetDir,
6808
- item2.name,
6809
- file.name
6810
- );
7155
+ const componentDir2 = path12.resolve(targetDir, item2.name);
7156
+ let filePath = path12.resolve(targetDir, item2.name, file.name);
6811
7157
  const content = transformImport(file.content, config);
6812
- if (!existsSync5(componentDir2)) {
6813
- await fs4.mkdir(componentDir2, { recursive: true });
7158
+ if (!existsSync4(componentDir2)) {
7159
+ await fs8.mkdir(componentDir2, { recursive: true });
6814
7160
  }
6815
- await fs4.writeFile(filePath, content);
7161
+ await fs8.writeFile(filePath, content);
6816
7162
  }
6817
7163
  if (item2.dependencies?.length) {
6818
7164
  const packageManager = await getPackageManager(cwd);
@@ -6848,19 +7194,6 @@ async function promptForComponents(components, message) {
6848
7194
  return selectedComponents;
6849
7195
  }
6850
7196
 
6851
- // src/utils/get-package-info.ts
6852
- import path7 from "path";
6853
- import { fileURLToPath as fileURLToPath2 } from "url";
6854
- import fs5 from "fs-extra";
6855
- function getPackageInfo() {
6856
- const packageJsonPath = getPackageFilePath("../package.json");
6857
- return fs5.readJSONSync(packageJsonPath);
6858
- }
6859
- function getPackageFilePath(filePath) {
6860
- let distPath = fileURLToPath2(new URL(`.`, import.meta.url));
6861
- return path7.resolve(distPath, filePath);
6862
- }
6863
-
6864
7197
  // src/index.ts
6865
7198
  process.on("SIGINT", () => process.exit(0));
6866
7199
  process.on("SIGTERM", () => process.exit(0));