shadcn-svelte 0.7.0 → 0.8.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/LICENSE.md +2 -1
- package/dist/index.js +57 -74
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
+
Copyright (c) 2023 Hunter Johnston <https://github.com/huntabyte>
|
|
4
|
+
Copyright (c) 2023 CokaKoala <https://github.com/adriangonz97>
|
|
3
5
|
Copyright (c) 2023 shadcn
|
|
4
|
-
Copyright (c) 2023 huntabyte
|
|
5
6
|
|
|
6
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
8
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.js
CHANGED
|
@@ -5207,7 +5207,7 @@ var logger = {
|
|
|
5207
5207
|
console.log(chalk.green(...args));
|
|
5208
5208
|
},
|
|
5209
5209
|
highlight(...args) {
|
|
5210
|
-
return chalk.cyan(...args);
|
|
5210
|
+
return chalk.bold(chalk.cyan(...args));
|
|
5211
5211
|
}
|
|
5212
5212
|
};
|
|
5213
5213
|
|
|
@@ -5258,13 +5258,9 @@ async function resolveConfigPaths(cwd, config) {
|
|
|
5258
5258
|
const isSvelteKit = isUsingSvelteKit(cwd);
|
|
5259
5259
|
if (isSvelteKit) {
|
|
5260
5260
|
const packageManager = await getPackageManager(cwd);
|
|
5261
|
-
await execa2(
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
{
|
|
5265
|
-
cwd
|
|
5266
|
-
}
|
|
5267
|
-
);
|
|
5261
|
+
await execa2(packageManager === "npm" ? "npx" : packageManager, ["svelte-kit", "sync"], {
|
|
5262
|
+
cwd
|
|
5263
|
+
});
|
|
5268
5264
|
}
|
|
5269
5265
|
const tsconfigPath = await find(path8.resolve(cwd, "package.json"), { root: cwd });
|
|
5270
5266
|
if (tsconfigPath === null) {
|
|
@@ -5313,9 +5309,7 @@ async function getRawConfig(cwd) {
|
|
|
5313
5309
|
const config = JSON.parse(configResult);
|
|
5314
5310
|
return rawConfigSchema.parse(config);
|
|
5315
5311
|
} catch (error) {
|
|
5316
|
-
throw new Error(
|
|
5317
|
-
`Invalid configuration found in ${logger.highlight(configPath)}.`
|
|
5318
|
-
);
|
|
5312
|
+
throw new Error(`Invalid configuration found in ${logger.highlight(configPath)}.`);
|
|
5319
5313
|
}
|
|
5320
5314
|
}
|
|
5321
5315
|
|
|
@@ -5470,10 +5464,7 @@ async function getItemTargetPath(config, item2, override2) {
|
|
|
5470
5464
|
if (!(parent in config.resolvedPaths)) {
|
|
5471
5465
|
return null;
|
|
5472
5466
|
}
|
|
5473
|
-
return path9.join(
|
|
5474
|
-
config.resolvedPaths[parent],
|
|
5475
|
-
type
|
|
5476
|
-
);
|
|
5467
|
+
return path9.join(config.resolvedPaths[parent], type);
|
|
5477
5468
|
}
|
|
5478
5469
|
async function fetchRegistry(paths) {
|
|
5479
5470
|
try {
|
|
@@ -5489,7 +5480,7 @@ async function fetchRegistry(paths) {
|
|
|
5489
5480
|
);
|
|
5490
5481
|
return results;
|
|
5491
5482
|
} catch (error) {
|
|
5492
|
-
console.
|
|
5483
|
+
console.error(error);
|
|
5493
5484
|
throw new Error(`Failed to fetch registry from ${baseUrl}.`);
|
|
5494
5485
|
}
|
|
5495
5486
|
}
|
|
@@ -6559,7 +6550,6 @@ var add = new Command().command("add").description("add components to your proje
|
|
|
6559
6550
|
"the working directory. defaults to the current directory.",
|
|
6560
6551
|
process.cwd()
|
|
6561
6552
|
).option("-p, --path <path>", "the path to add the component to.").action(async (components, opts) => {
|
|
6562
|
-
const highlight = logger.highlight;
|
|
6563
6553
|
try {
|
|
6564
6554
|
const options = addOptionsSchema.parse({
|
|
6565
6555
|
components,
|
|
@@ -6620,7 +6610,7 @@ var add = new Command().command("add").description("add components to your proje
|
|
|
6620
6610
|
return;
|
|
6621
6611
|
}
|
|
6622
6612
|
logger.info(`Selected components:
|
|
6623
|
-
${highlight(selectedComponents)}`);
|
|
6613
|
+
${logger.highlight(selectedComponents)}`);
|
|
6624
6614
|
if (!options.yes) {
|
|
6625
6615
|
const { proceed } = await prompts2({
|
|
6626
6616
|
type: "confirm",
|
|
@@ -6660,9 +6650,9 @@ ${highlight(selectedComponents)}`);
|
|
|
6660
6650
|
if (selectedComponents.includes(item2.name)) {
|
|
6661
6651
|
logger.warn(
|
|
6662
6652
|
`
|
|
6663
|
-
Component ${highlight(
|
|
6653
|
+
Component ${logger.highlight(
|
|
6664
6654
|
item2.name
|
|
6665
|
-
)} already exists at ${highlight(
|
|
6655
|
+
)} already exists at ${logger.highlight(
|
|
6666
6656
|
componentPath
|
|
6667
6657
|
)}. Use ${chalk3.green("--overwrite")} to overwrite.`
|
|
6668
6658
|
);
|
|
@@ -6687,16 +6677,9 @@ Component ${highlight(
|
|
|
6687
6677
|
continue;
|
|
6688
6678
|
}
|
|
6689
6679
|
const packageManager = await getPackageManager(cwd);
|
|
6690
|
-
await execa3(
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
packageManager === "npm" ? "install" : "add",
|
|
6694
|
-
...item2.dependencies
|
|
6695
|
-
],
|
|
6696
|
-
{
|
|
6697
|
-
cwd
|
|
6698
|
-
}
|
|
6699
|
-
);
|
|
6680
|
+
await execa3(packageManager, ["add", ...item2.dependencies], {
|
|
6681
|
+
cwd
|
|
6682
|
+
});
|
|
6700
6683
|
}
|
|
6701
6684
|
componentPaths.push(componentPath);
|
|
6702
6685
|
}
|
|
@@ -6711,10 +6694,8 @@ Component ${highlight(
|
|
|
6711
6694
|
);
|
|
6712
6695
|
}
|
|
6713
6696
|
spinner.succeed(`Done.`);
|
|
6714
|
-
logger.info(
|
|
6715
|
-
|
|
6716
|
-
- ${[...componentPaths].join("\n- ")}`
|
|
6717
|
-
);
|
|
6697
|
+
logger.info("Components installed at:");
|
|
6698
|
+
logger.info(logger.highlight(componentPaths.map((path13) => `- ${path13}`).join("\n")));
|
|
6718
6699
|
} catch (error) {
|
|
6719
6700
|
handleError(error);
|
|
6720
6701
|
}
|
|
@@ -6945,9 +6926,7 @@ var init2 = new Command2().command("init").description("Configure your SvelteKit
|
|
|
6945
6926
|
logger.info("");
|
|
6946
6927
|
logger.info(`${chalk4.green("Success!")} Project initialization completed.`);
|
|
6947
6928
|
logger.info("");
|
|
6948
|
-
logger.info(
|
|
6949
|
-
"Don't forget to add the aliases you configured to your svelte.config.js!"
|
|
6950
|
-
);
|
|
6929
|
+
logger.info("Don't forget to add the aliases you configured to your svelte.config.js!");
|
|
6951
6930
|
logger.info("");
|
|
6952
6931
|
} catch (e) {
|
|
6953
6932
|
handleError(e);
|
|
@@ -7084,11 +7063,7 @@ async function runInit(cwd, config) {
|
|
|
7084
7063
|
await fs7.unlink(cjsConfig).catch((e) => e);
|
|
7085
7064
|
const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
|
|
7086
7065
|
if (baseColor) {
|
|
7087
|
-
await fs7.writeFile(
|
|
7088
|
-
config.resolvedPaths.tailwindCss,
|
|
7089
|
-
baseColor.cssVarsTemplate,
|
|
7090
|
-
"utf8"
|
|
7091
|
-
);
|
|
7066
|
+
await fs7.writeFile(config.resolvedPaths.tailwindCss, baseColor.cssVarsTemplate, "utf8");
|
|
7092
7067
|
}
|
|
7093
7068
|
const utilsPath = config.resolvedPaths.utils + (config.typescript ? ".ts" : ".js");
|
|
7094
7069
|
const utilsTemplate = config.typescript ? UTILS : UTILS_JS;
|
|
@@ -7098,9 +7073,9 @@ async function runInit(cwd, config) {
|
|
|
7098
7073
|
const packageManager = await getPackageManager(cwd);
|
|
7099
7074
|
const deps = [
|
|
7100
7075
|
...PROJECT_DEPENDENCIES,
|
|
7101
|
-
config.style === "new-york" ? "radix
|
|
7076
|
+
config.style === "new-york" ? "svelte-radix" : "lucide-svelte"
|
|
7102
7077
|
];
|
|
7103
|
-
await execa4(packageManager, [
|
|
7078
|
+
await execa4(packageManager, ["add", ...deps], {
|
|
7104
7079
|
cwd
|
|
7105
7080
|
});
|
|
7106
7081
|
dependenciesSpinner?.succeed();
|
|
@@ -7163,9 +7138,7 @@ var update = new Command3().command("update").description("update components in
|
|
|
7163
7138
|
});
|
|
7164
7139
|
for (const file of files) {
|
|
7165
7140
|
if (file.isDirectory()) {
|
|
7166
|
-
const component = registryIndex.find(
|
|
7167
|
-
(comp) => comp.name === file.name
|
|
7168
|
-
);
|
|
7141
|
+
const component = registryIndex.find((comp) => comp.name === file.name);
|
|
7169
7142
|
if (component) {
|
|
7170
7143
|
existingComponents.push(component);
|
|
7171
7144
|
}
|
|
@@ -7205,9 +7178,7 @@ var update = new Command3().command("update").description("update components in
|
|
|
7205
7178
|
const extension = config.typescript ? ".ts" : ".js";
|
|
7206
7179
|
const utilsPath = config.resolvedPaths.utils + extension;
|
|
7207
7180
|
if (!existsSync4(utilsPath)) {
|
|
7208
|
-
spinner.fail(
|
|
7209
|
-
`utils at ${logger.highlight(utilsPath)} does not exist.`
|
|
7210
|
-
);
|
|
7181
|
+
spinner.fail(`utils at ${logger.highlight(utilsPath)} does not exist.`);
|
|
7211
7182
|
process.exitCode = 1;
|
|
7212
7183
|
return;
|
|
7213
7184
|
}
|
|
@@ -7217,9 +7188,12 @@ var update = new Command3().command("update").description("update components in
|
|
|
7217
7188
|
registryIndex,
|
|
7218
7189
|
selectedComponents.map((com) => com.name)
|
|
7219
7190
|
);
|
|
7220
|
-
const payload = await fetchTree(config, tree)
|
|
7221
|
-
|
|
7222
|
-
|
|
7191
|
+
const payload = (await fetchTree(config, tree)).sort(
|
|
7192
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
7193
|
+
);
|
|
7194
|
+
const componentsToRemove = {};
|
|
7195
|
+
for (const [index, item2] of payload.entries()) {
|
|
7196
|
+
spinner.text = `Updating ${logger.highlight(item2.name)} (${index + 1}/${payload.length})...`;
|
|
7223
7197
|
const targetDir = await getItemTargetPath(config, item2);
|
|
7224
7198
|
if (!targetDir) {
|
|
7225
7199
|
continue;
|
|
@@ -7227,30 +7201,43 @@ var update = new Command3().command("update").description("update components in
|
|
|
7227
7201
|
if (!existsSync4(targetDir)) {
|
|
7228
7202
|
await fs8.mkdir(targetDir, { recursive: true });
|
|
7229
7203
|
}
|
|
7204
|
+
const componentDir2 = path12.resolve(targetDir, item2.name);
|
|
7205
|
+
if (!existsSync4(componentDir2)) {
|
|
7206
|
+
await fs8.mkdir(componentDir2, { recursive: true });
|
|
7207
|
+
}
|
|
7230
7208
|
for (const file of item2.files) {
|
|
7231
|
-
const
|
|
7232
|
-
let filePath = path12.resolve(targetDir, item2.name, file.name);
|
|
7209
|
+
const filePath = path12.resolve(targetDir, item2.name, file.name);
|
|
7233
7210
|
const content = transformImports(file.content, config);
|
|
7234
|
-
if (!existsSync4(componentDir2)) {
|
|
7235
|
-
await fs8.mkdir(componentDir2, { recursive: true });
|
|
7236
|
-
}
|
|
7237
7211
|
await fs8.writeFile(filePath, content);
|
|
7238
7212
|
}
|
|
7213
|
+
const installedFiles = await fs8.readdir(componentDir2);
|
|
7214
|
+
const remoteFiles = item2.files.map((file) => file.name);
|
|
7215
|
+
const filesToDelete = installedFiles.filter((file) => !remoteFiles.includes(file)).map((file) => path12.resolve(targetDir, item2.name, file));
|
|
7216
|
+
if (filesToDelete.length > 0) {
|
|
7217
|
+
componentsToRemove[item2.name] = filesToDelete;
|
|
7218
|
+
}
|
|
7239
7219
|
if (item2.dependencies?.length) {
|
|
7240
7220
|
const packageManager = await getPackageManager(cwd);
|
|
7241
|
-
await execa5(
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
packageManager === "npm" ? "install" : "add",
|
|
7245
|
-
...item2.dependencies
|
|
7246
|
-
],
|
|
7247
|
-
{
|
|
7248
|
-
cwd
|
|
7249
|
-
}
|
|
7250
|
-
);
|
|
7221
|
+
await execa5(packageManager, ["add", ...item2.dependencies], {
|
|
7222
|
+
cwd
|
|
7223
|
+
});
|
|
7251
7224
|
}
|
|
7252
7225
|
}
|
|
7253
|
-
spinner.succeed(
|
|
7226
|
+
spinner.succeed("Done.");
|
|
7227
|
+
for (const [component, files2] of Object.entries(componentsToRemove)) {
|
|
7228
|
+
logger.warn(
|
|
7229
|
+
`
|
|
7230
|
+
The ${logger.highlight(
|
|
7231
|
+
component
|
|
7232
|
+
)} component does not use the following files:`
|
|
7233
|
+
);
|
|
7234
|
+
logger.warn(
|
|
7235
|
+
files2.map((file) => chalk5.white(`- ${path12.relative(cwd, file)}`)).join("\n")
|
|
7236
|
+
);
|
|
7237
|
+
}
|
|
7238
|
+
if (Object.keys(componentsToRemove)) {
|
|
7239
|
+
logger.warn("\nYou may want to remove them.");
|
|
7240
|
+
}
|
|
7254
7241
|
} catch (e) {
|
|
7255
7242
|
handleError(e);
|
|
7256
7243
|
}
|
|
@@ -7275,11 +7262,7 @@ process.on("SIGINT", () => process.exit(0));
|
|
|
7275
7262
|
process.on("SIGTERM", () => process.exit(0));
|
|
7276
7263
|
async function main2() {
|
|
7277
7264
|
const packageInfo = getPackageInfo();
|
|
7278
|
-
const program = new Command4().name("shadcn-svelte").description("Add shadcn-svelte components to your project").version(
|
|
7279
|
-
packageInfo.version || "1.0.0",
|
|
7280
|
-
"-v, --version",
|
|
7281
|
-
"display the version number"
|
|
7282
|
-
);
|
|
7265
|
+
const program = new Command4().name("shadcn-svelte").description("Add shadcn-svelte components to your project").version(packageInfo.version || "1.0.0", "-v, --version", "display the version number");
|
|
7283
7266
|
program.addCommand(init2).addCommand(add).addCommand(update);
|
|
7284
7267
|
program.parse();
|
|
7285
7268
|
}
|