shadcn-svelte 0.0.1 → 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.
- package/dist/index.js +31 -31
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { existsSync as existsSync2, promises as fs3 } from "fs";
|
|
5
|
+
import path3 from "path";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
import { execa } from "execa";
|
|
8
|
+
import ora from "ora";
|
|
9
|
+
import prompts from "prompts";
|
|
10
|
+
|
|
3
11
|
// src/utils/get-components.ts
|
|
4
12
|
import fetch from "node-fetch";
|
|
5
13
|
import * as z from "zod";
|
|
6
|
-
var baseUrl = process.env.COMPONENTS_BASE_URL ?? "
|
|
14
|
+
var baseUrl = process.env.COMPONENTS_BASE_URL ?? "https://shadcn-svelte.com";
|
|
7
15
|
var componentSchema = z.object({
|
|
8
16
|
component: z.string(),
|
|
9
17
|
name: z.string(),
|
|
@@ -30,8 +38,8 @@ async function getAvailableComponents() {
|
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
// src/utils/get-package-info.ts
|
|
33
|
-
import fs from "fs-extra";
|
|
34
41
|
import path from "path";
|
|
42
|
+
import fs from "fs-extra";
|
|
35
43
|
function getPackageInfo() {
|
|
36
44
|
const packageJsonPath = path.join("package.json");
|
|
37
45
|
return fs.readJSONSync(packageJsonPath);
|
|
@@ -54,14 +62,12 @@ function getPackageManager() {
|
|
|
54
62
|
|
|
55
63
|
// src/utils/get-project-info.ts
|
|
56
64
|
import { existsSync } from "fs";
|
|
57
|
-
import fs2 from "fs-extra";
|
|
58
65
|
import path2 from "path";
|
|
66
|
+
import fs2 from "fs-extra";
|
|
59
67
|
async function getProjectInfo() {
|
|
60
68
|
const info = {
|
|
61
69
|
tsconfig: null,
|
|
62
|
-
alias: null
|
|
63
|
-
srcDir: false,
|
|
64
|
-
appDir: false
|
|
70
|
+
alias: null
|
|
65
71
|
};
|
|
66
72
|
try {
|
|
67
73
|
const tsconfig = await getTsConfig();
|
|
@@ -171,7 +177,7 @@ var STYLES = `@tailwind base;
|
|
|
171
177
|
--accent: 216 34% 17%;
|
|
172
178
|
--accent-foreground: 210 40% 98%;
|
|
173
179
|
|
|
174
|
-
--destructive:
|
|
180
|
+
--destructive: 360 62% 55%;
|
|
175
181
|
--destructive-foreground: 210 40% 98%;
|
|
176
182
|
|
|
177
183
|
--ring: 216 34% 17%;
|
|
@@ -200,9 +206,7 @@ var TAILWIND_CONFIG = `const { fontFamily } = require("tailwindcss/defaultTheme"
|
|
|
200
206
|
/** @type {import('tailwindcss').Config} */
|
|
201
207
|
module.exports = {
|
|
202
208
|
darkMode: ["class"],
|
|
203
|
-
content: [
|
|
204
|
-
"./src/**/*.{html,js,svelte,ts}",
|
|
205
|
-
],
|
|
209
|
+
content: ["./src/**/*.{html,js,svelte,ts}"],
|
|
206
210
|
theme: {
|
|
207
211
|
container: {
|
|
208
212
|
center: true,
|
|
@@ -261,12 +265,6 @@ module.exports = {
|
|
|
261
265
|
}`;
|
|
262
266
|
|
|
263
267
|
// src/index.ts
|
|
264
|
-
import { Command } from "commander";
|
|
265
|
-
import { execa } from "execa";
|
|
266
|
-
import { existsSync as existsSync2, promises as fs3 } from "fs";
|
|
267
|
-
import ora from "ora";
|
|
268
|
-
import path3 from "path";
|
|
269
|
-
import prompts from "prompts";
|
|
270
268
|
process.on("SIGINT", () => process.exit(0));
|
|
271
269
|
process.on("SIGTERM", () => process.exit(0));
|
|
272
270
|
var PROJECT_DEPENDENCIES = [
|
|
@@ -304,23 +302,18 @@ async function main() {
|
|
|
304
302
|
process.exit(0);
|
|
305
303
|
}
|
|
306
304
|
}
|
|
307
|
-
const dependenciesSpinner = ora(
|
|
305
|
+
const dependenciesSpinner = ora(
|
|
306
|
+
`Installing dependencies...`
|
|
307
|
+
).start();
|
|
308
308
|
await execa(packageManager, [
|
|
309
309
|
packageManager === "npm" ? "install" : "add",
|
|
310
310
|
...PROJECT_DEPENDENCIES
|
|
311
311
|
]);
|
|
312
312
|
dependenciesSpinner.succeed();
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
let stylesDestination = "./src/styles/globals.css";
|
|
320
|
-
if (projectInfo?.appDir) {
|
|
321
|
-
stylesDestination = "./src/app/globals.css";
|
|
322
|
-
}
|
|
323
|
-
const stylesSpinner = ora(`Adding styles with CSS variables...`).start();
|
|
313
|
+
let stylesDestination = "./src/app.postcss";
|
|
314
|
+
const stylesSpinner = ora(
|
|
315
|
+
`Adding styles with CSS variables...`
|
|
316
|
+
).start();
|
|
324
317
|
await fs3.writeFile(stylesDestination, STYLES, "utf8");
|
|
325
318
|
stylesSpinner.succeed();
|
|
326
319
|
const libDir = "./src/lib";
|
|
@@ -332,7 +325,9 @@ async function main() {
|
|
|
332
325
|
await fs3.writeFile(utilsDestination, UTILS, "utf8");
|
|
333
326
|
utilsSpinner.succeed();
|
|
334
327
|
const tailwindDestination = "./tailwind.config.cjs";
|
|
335
|
-
const tailwindSpinner = ora(
|
|
328
|
+
const tailwindSpinner = ora(
|
|
329
|
+
`Updating tailwind.config.cjs...`
|
|
330
|
+
).start();
|
|
336
331
|
await fs3.writeFile(tailwindDestination, TAILWIND_CONFIG, "utf8");
|
|
337
332
|
tailwindSpinner.succeed();
|
|
338
333
|
});
|
|
@@ -355,7 +350,9 @@ async function main() {
|
|
|
355
350
|
(component) => components.includes(component.component)
|
|
356
351
|
);
|
|
357
352
|
if (!selectedComponents?.length) {
|
|
358
|
-
selectedComponents = await promptForComponents(
|
|
353
|
+
selectedComponents = await promptForComponents(
|
|
354
|
+
availableComponents
|
|
355
|
+
);
|
|
359
356
|
}
|
|
360
357
|
const dir = await promptForDestinationDir();
|
|
361
358
|
if (!selectedComponents?.length) {
|
|
@@ -375,7 +372,10 @@ async function main() {
|
|
|
375
372
|
const componentSpinner = ora(`${component.name}...`).start();
|
|
376
373
|
for (const file of component.files) {
|
|
377
374
|
if (projectInfo?.alias) {
|
|
378
|
-
file.content = file.content.replace(
|
|
375
|
+
file.content = file.content.replace(
|
|
376
|
+
/$\//g,
|
|
377
|
+
projectInfo.alias
|
|
378
|
+
);
|
|
379
379
|
}
|
|
380
380
|
const dirPath = path3.join(dir, file.dir);
|
|
381
381
|
await fs3.mkdir(dirPath, { recursive: true });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/get-components.ts","../src/utils/get-package-info.ts","../src/utils/get-package-manager.ts","../src/utils/get-project-info.ts","../src/utils/logger.ts","../src/utils/templates.ts","../src/index.ts"],"sourcesContent":["import fetch from \"node-fetch\"\nimport * as z from \"zod\"\n\nconst baseUrl =\n process.env.COMPONENTS_BASE_URL ?? \"http://localhost:5173\"\n\nconst componentSchema = z.object({\n component: z.string(),\n name: z.string(),\n dependencies: z.array(z.string()).optional(),\n files: z.array(\n z.object({\n name: z.string(),\n dir: z.string(),\n content: z.string(),\n })\n ),\n})\n\nexport type Component = z.infer<typeof componentSchema>\n\nconst componentsSchema = z.array(componentSchema)\n\nexport async function getAvailableComponents() {\n try {\n const response = await fetch(`${baseUrl}/api/components`)\n const components = await response.json()\n\n return componentsSchema.parse(components)\n } catch (error) {\n throw new Error(\n `Failed to fetch components from ${baseUrl}/api/components.`\n )\n }\n}\n","import fs from \"fs-extra\"\nimport path from \"path\"\nimport { type PackageJson } from \"type-fest\"\n\nexport function getPackageInfo() {\n const packageJsonPath = path.join(\"package.json\")\n\n return fs.readJSONSync(packageJsonPath) as PackageJson\n}\n","export function getPackageManager() {\n const userAgent = process.env.npm_config_user_agent\n\n if (!userAgent) {\n return \"npm\"\n }\n\n if (userAgent.startsWith(\"yarn\")) {\n return \"yarn\"\n }\n\n if (userAgent.startsWith(\"pnpm\")) {\n return \"pnpm\"\n }\n\n return \"npm\"\n}\n","import { existsSync } from \"fs\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\n\nexport async function getProjectInfo() {\n const info = {\n tsconfig: null,\n alias: null,\n srcDir: false,\n appDir: false\n };\n\n try {\n const tsconfig = await getTsConfig();\n const paths = tsconfig?.compilerOptions?.paths;\n const alias = paths ? Object.keys(paths)[0].replace(\"*\", \"\") : null;\n\n return {\n tsconfig,\n alias,\n srcDir: existsSync(path.resolve(\"./src\")),\n appDir:\n existsSync(path.resolve(\"./app\")) ||\n existsSync(path.resolve(\"./src/app\"))\n };\n } catch (error) {\n return info;\n }\n}\n\nexport async function getTsConfig() {\n try {\n const tsconfigPath = path.join(\"tsconfig.json\");\n const tsconfig = await fs.readJSON(tsconfigPath);\n\n if (!tsconfig) {\n throw new Error(\"tsconfig.json is missing\");\n }\n\n return tsconfig;\n } catch (error) {\n return null;\n }\n}\n","import chalk from \"chalk\";\n\nexport const logger = {\n error(...args: unknown[]) {\n console.log(chalk.red(...args));\n },\n warn(...args: unknown[]) {\n console.log(chalk.yellow(...args));\n },\n info(...args: unknown[]) {\n console.log(chalk.cyan(...args));\n },\n success(...args: unknown[]) {\n console.log(chalk.green(...args));\n }\n};\n","export const STYLES = `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n \n@layer base {\n :root {\n --background: 0 0% 100%;\n --foreground: 222.2 47.4% 11.2%;\n \n --muted: 210 40% 96.1%;\n --muted-foreground: 215.4 16.3% 46.9%;\n \n --popover: 0 0% 100%;\n --popover-foreground: 222.2 47.4% 11.2%;\n \n --card: 0 0% 100%;\n --card-foreground: 222.2 47.4% 11.2%;\n \n --border: 214.3 31.8% 91.4%;\n --input: 214.3 31.8% 91.4%;\n \n --primary: 222.2 47.4% 11.2%;\n --primary-foreground: 210 40% 98%;\n \n --secondary: 210 40% 96.1%;\n --secondary-foreground: 222.2 47.4% 11.2%;\n \n --accent: 210 40% 96.1%;\n --accent-foreground: 222.2 47.4% 11.2%;\n \n --destructive: 0 100% 50%;\n --destructive-foreground: 210 40% 98%;\n \n --ring: 215 20.2% 65.1%;\n \n --radius: 0.5rem;\n }\n \n .dark {\n --background: 224 71% 4%;\n --foreground: 213 31% 91%;\n \n --muted: 223 47% 11%;\n --muted-foreground: 215.4 16.3% 56.9%;\n \n --popover: 224 71% 4%;\n --popover-foreground: 215 20.2% 65.1%;\n \n --card: 224 71% 4%;\n --card-foreground: 213 31% 91%;\n \n --border: 216 34% 17%;\n --input: 216 34% 17%;\n \n --primary: 210 40% 98%;\n --primary-foreground: 222.2 47.4% 1.2%;\n \n --secondary: 222.2 47.4% 11.2%;\n --secondary-foreground: 210 40% 98%;\n \n --accent: 216 34% 17%;\n --accent-foreground: 210 40% 98%;\n \n --destructive: 0 63% 31%;\n --destructive-foreground: 210 40% 98%;\n \n --ring: 216 34% 17%;\n \n --radius: 0.5rem;\n }\n}\n \n@layer base {\n * {\n @apply border-border;\n }\n body {\n @apply bg-background text-foreground;\n font-feature-settings: \"rlig\" 1, \"calt\" 1;\n }\n}`;\n\nexport const UTILS = `import { ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n \nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`;\n\nexport const TAILWIND_CONFIG = `const { fontFamily } = require(\"tailwindcss/defaultTheme\")\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n darkMode: [\"class\"],\n content: [\n \"./src/**/*.{html,js,svelte,ts}\",\n ],\n theme: {\n container: {\n center: true,\n padding: \"2rem\",\n screens: {\n \"2xl\": \"1400px\",\n },\n },\n extend: {\n colors: {\n border: \"hsl(var(--border))\",\n input: \"hsl(var(--input))\",\n ring: \"hsl(var(--ring))\",\n background: \"hsl(var(--background))\",\n foreground: \"hsl(var(--foreground))\",\n primary: {\n DEFAULT: \"hsl(var(--primary))\",\n foreground: \"hsl(var(--primary-foreground))\",\n },\n secondary: {\n DEFAULT: \"hsl(var(--secondary))\",\n foreground: \"hsl(var(--secondary-foreground))\",\n },\n destructive: {\n DEFAULT: \"hsl(var(--destructive))\",\n foreground: \"hsl(var(--destructive-foreground))\",\n },\n muted: {\n DEFAULT: \"hsl(var(--muted))\",\n foreground: \"hsl(var(--muted-foreground))\",\n },\n accent: {\n DEFAULT: \"hsl(var(--accent))\",\n foreground: \"hsl(var(--accent-foreground))\",\n },\n popover: {\n DEFAULT: \"hsl(var(--popover))\",\n foreground: \"hsl(var(--popover-foreground))\",\n },\n card: {\n DEFAULT: \"hsl(var(--card))\",\n foreground: \"hsl(var(--card-foreground))\",\n },\n },\n borderRadius: {\n lg: \"var(--radius)\",\n md: \"calc(var(--radius) - 2px)\",\n sm: \"calc(var(--radius) - 4px)\",\n },\n fontFamily: {\n sans: [...fontFamily.sans]\n }\n }\n },\n plugins: [require(\"tailwindcss-animate\")],\n}`;\n","#!/usr/bin/env node\nimport { Component, getAvailableComponents } from \"./utils/get-components\";\nimport { getPackageInfo } from \"./utils/get-package-info\";\nimport { getPackageManager } from \"./utils/get-package-manager\";\nimport { getProjectInfo } from \"./utils/get-project-info\";\nimport { logger } from \"./utils/logger\";\nimport { STYLES, TAILWIND_CONFIG, UTILS } from \"./utils/templates\";\nimport { Command } from \"commander\";\nimport { execa } from \"execa\";\nimport { existsSync, promises as fs } from \"fs\";\nimport ora from \"ora\";\nimport path, { dirname } from \"path\";\nimport prompts from \"prompts\";\n\nprocess.on(\"SIGINT\", () => process.exit(0));\nprocess.on(\"SIGTERM\", () => process.exit(0));\n\nconst PROJECT_DEPENDENCIES = [\n \"tailwindcss-animate\",\n \"class-variance-authority\",\n \"clsx\",\n \"tailwind-merge\",\n \"lucide-svelte\"\n];\n\nasync function main() {\n const packageInfo = getPackageInfo();\n const projectInfo = await getProjectInfo();\n const packageManager = getPackageManager();\n\n const program = new Command()\n .name(\"shadcn-svelte\")\n .description(\"Add shadcn-svelte components to your project\")\n .version(\n packageInfo.version || \"1.0.0\",\n \"-v, --version\",\n \"display the version number\"\n );\n\n program\n .command(\"init\")\n .description(\"Configure your SvelteKit project.\")\n .option(\"-y, --yes\", \"Skip confirmation prompt.\")\n .action(async (options) => {\n logger.warn(\n \"This command assumes a SvelteKit project with TypeScript and Tailwind CSS.\"\n );\n logger.warn(\n \"If you don't have these, follow the manual steps at https://ui.shadcn.com/docs/installation.\"\n );\n logger.warn(\"\");\n\n if (!options.yes) {\n const { proceed } = await prompts({\n type: \"confirm\",\n name: \"proceed\",\n message:\n \"Running this command will install dependencies and overwrite your existing tailwind.config.cjs. Proceed?\",\n initial: true\n });\n\n if (!proceed) {\n process.exit(0);\n }\n }\n\n // Install dependencies.\n const dependenciesSpinner = ora(`Installing dependencies...`).start();\n await execa(packageManager, [\n packageManager === \"npm\" ? \"install\" : \"add\",\n ...PROJECT_DEPENDENCIES\n ]);\n dependenciesSpinner.succeed();\n\n // Ensure styles directory exists.\n if (!projectInfo?.appDir) {\n const stylesDir = \"./src/styles\";\n if (!existsSync(path.resolve(stylesDir))) {\n await fs.mkdir(path.resolve(stylesDir), { recursive: true });\n }\n }\n\n // Update styles.css\n let stylesDestination = \"./src/styles/globals.css\";\n if (projectInfo?.appDir) {\n stylesDestination = \"./src/app/globals.css\";\n }\n const stylesSpinner = ora(`Adding styles with CSS variables...`).start();\n await fs.writeFile(stylesDestination, STYLES, \"utf8\");\n stylesSpinner.succeed();\n\n // Ensure lib directory exists.\n const libDir = \"./src/lib\";\n if (!existsSync(path.resolve(libDir))) {\n await fs.mkdir(path.resolve(libDir), { recursive: true });\n }\n\n // Create lib/utils.ts\n const utilsDestination = \"./src/lib/utils.ts\";\n\n const utilsSpinner = ora(`Adding utils...`).start();\n await fs.writeFile(utilsDestination, UTILS, \"utf8\");\n utilsSpinner.succeed();\n\n const tailwindDestination = \"./tailwind.config.cjs\";\n const tailwindSpinner = ora(`Updating tailwind.config.cjs...`).start();\n await fs.writeFile(tailwindDestination, TAILWIND_CONFIG, \"utf8\");\n tailwindSpinner.succeed();\n });\n\n program\n .command(\"add\")\n .description(\"add components to your project\")\n .argument(\"[components...]\", \"name of components\")\n .action(async (components: string[]) => {\n logger.warn(\n \"Running the following command will overwrite existing files.\"\n );\n logger.warn(\n \"Make sure you have committed your changes before proceeding.\"\n );\n logger.warn(\"\");\n\n const availableComponents = await getAvailableComponents();\n\n if (!availableComponents?.length) {\n logger.error(\n \"An error occurred while fetching components. Please try again.\"\n );\n process.exit(0);\n }\n\n let selectedComponents = availableComponents.filter((component) =>\n components.includes(component.component)\n );\n\n if (!selectedComponents?.length) {\n selectedComponents = await promptForComponents(availableComponents);\n }\n\n const dir = await promptForDestinationDir();\n\n if (!selectedComponents?.length) {\n logger.warn(\"No components selected. Nothing to install.\");\n process.exit(0);\n }\n\n // Create componentPath directory if it doesn't exist.\n const destinationDir = path.resolve(dir);\n if (!existsSync(destinationDir)) {\n const spinner = ora(`Creating ${dir}...`).start();\n await fs.mkdir(destinationDir, { recursive: true });\n spinner.succeed();\n }\n\n logger.success(\n `Installing ${selectedComponents.length} component(s) and dependencies...`\n );\n for (const component of selectedComponents) {\n const componentSpinner = ora(`${component.name}...`).start();\n\n // Write the files.\n for (const file of component.files) {\n // Replace alias with the project's alias.\n if (projectInfo?.alias) {\n file.content = file.content.replace(/$\\//g, projectInfo.alias);\n }\n const dirPath = path.join(dir, file.dir)\n await fs.mkdir(dirPath, { recursive: true })\n const filePath = path.resolve(dirPath, file.name)\n await fs.writeFile(filePath, file.content)\n\n }\n\n // Install dependencies.\n if (component.dependencies?.length) {\n await execa(packageManager, [\n packageManager === \"npm\" ? \"install\" : \"add\",\n ...component.dependencies\n ]);\n }\n componentSpinner.succeed(component.name);\n }\n });\n\n program.parse();\n}\n\nasync function promptForComponents(components: Component[]) {\n const { components: selectedComponents } = await prompts({\n type: \"autocompleteMultiselect\",\n name: \"components\",\n message: \"Which component(s) would you like to add?\",\n hint: \"Space to select. A to select all. I to invert selection.\",\n instructions: false,\n choices: components.map((component) => ({\n title: component.name,\n value: component\n }))\n });\n\n return selectedComponents;\n}\n\nasync function promptForDestinationDir() {\n const { dir } = await prompts([\n {\n type: \"text\",\n name: \"dir\",\n message: \"Where would you like to install the component(s)?\",\n initial: \"./src/lib/components/ui\"\n }\n ]);\n\n return dir;\n}\n\nmain();\n"],"mappings":";;;AAAA,OAAO,WAAW;AAClB,YAAY,OAAO;AAEnB,IAAM,UACF,QAAQ,IAAI,uBAAuB;AAEvC,IAAM,kBAAoB,SAAO;AAAA,EAC7B,WAAa,SAAO;AAAA,EACpB,MAAQ,SAAO;AAAA,EACf,cAAgB,QAAQ,SAAO,CAAC,EAAE,SAAS;AAAA,EAC3C,OAAS;AAAA,IACH,SAAO;AAAA,MACL,MAAQ,SAAO;AAAA,MACf,KAAO,SAAO;AAAA,MACd,SAAW,SAAO;AAAA,IACtB,CAAC;AAAA,EACL;AACJ,CAAC;AAID,IAAM,mBAAqB,QAAM,eAAe;AAEhD,eAAsB,yBAAyB;AAC3C,MAAI;AACA,UAAM,WAAW,MAAM,MAAM,GAAG,wBAAwB;AACxD,UAAM,aAAa,MAAM,SAAS,KAAK;AAEvC,WAAO,iBAAiB,MAAM,UAAU;AAAA,EAC5C,SAAS,OAAP;AACE,UAAM,IAAI;AAAA,MACN,mCAAmC;AAAA,IACvC;AAAA,EACJ;AACJ;;;AClCA,OAAO,QAAQ;AACf,OAAO,UAAU;AAGV,SAAS,iBAAiB;AAC7B,QAAM,kBAAkB,KAAK,KAAK,cAAc;AAEhD,SAAO,GAAG,aAAa,eAAe;AAC1C;;;ACRO,SAAS,oBAAoB;AAChC,QAAM,YAAY,QAAQ,IAAI;AAE9B,MAAI,CAAC,WAAW;AACZ,WAAO;AAAA,EACX;AAEA,MAAI,UAAU,WAAW,MAAM,GAAG;AAC9B,WAAO;AAAA,EACX;AAEA,MAAI,UAAU,WAAW,MAAM,GAAG;AAC9B,WAAO;AAAA,EACX;AAEA,SAAO;AACX;;;AChBA,SAAS,kBAAkB;AAC3B,OAAOA,SAAQ;AACf,OAAOC,WAAU;AAEjB,e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","existsSync","fs","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/get-components.ts","../src/utils/get-package-info.ts","../src/utils/get-package-manager.ts","../src/utils/get-project-info.ts","../src/utils/logger.ts","../src/utils/templates.ts"],"sourcesContent":["#!/usr/bin/env node\n// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\nimport { existsSync, promises as fs } from \"fs\";\nimport path from \"path\";\nimport { Command } from \"commander\";\nimport { execa } from \"execa\";\nimport ora from \"ora\";\nimport prompts from \"prompts\";\nimport { Component, getAvailableComponents } from \"./utils/get-components\";\nimport { getPackageInfo } from \"./utils/get-package-info\";\nimport { getPackageManager } from \"./utils/get-package-manager\";\nimport { getProjectInfo } from \"./utils/get-project-info\";\nimport { logger } from \"./utils/logger\";\nimport { STYLES, TAILWIND_CONFIG, UTILS } from \"./utils/templates\";\n\nprocess.on(\"SIGINT\", () => process.exit(0));\nprocess.on(\"SIGTERM\", () => process.exit(0));\n\nconst PROJECT_DEPENDENCIES = [\n\t\"tailwindcss-animate\",\n\t\"class-variance-authority\",\n\t\"clsx\",\n\t\"tailwind-merge\",\n\t\"lucide-svelte\"\n];\n\nasync function main() {\n\tconst packageInfo = getPackageInfo();\n\tconst projectInfo = await getProjectInfo();\n\tconst packageManager = getPackageManager();\n\n\tconst program = new Command()\n\t\t.name(\"shadcn-svelte\")\n\t\t.description(\"Add shadcn-svelte components to your project\")\n\t\t.version(\n\t\t\tpackageInfo.version || \"1.0.0\",\n\t\t\t\"-v, --version\",\n\t\t\t\"display the version number\"\n\t\t);\n\n\tprogram\n\t\t.command(\"init\")\n\t\t.description(\"Configure your SvelteKit project.\")\n\t\t.option(\"-y, --yes\", \"Skip confirmation prompt.\")\n\t\t.action(async (options) => {\n\t\t\tlogger.warn(\n\t\t\t\t\"This command assumes a SvelteKit project with TypeScript and Tailwind CSS.\"\n\t\t\t);\n\t\t\tlogger.warn(\n\t\t\t\t\"If you don't have these, follow the manual steps at https://ui.shadcn.com/docs/installation.\"\n\t\t\t);\n\t\t\tlogger.warn(\"\");\n\n\t\t\tif (!options.yes) {\n\t\t\t\tconst { proceed } = await prompts({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"proceed\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Running this command will install dependencies and overwrite your existing tailwind.config.cjs. Proceed?\",\n\t\t\t\t\tinitial: true\n\t\t\t\t});\n\n\t\t\t\tif (!proceed) {\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Install dependencies.\n\t\t\tconst dependenciesSpinner = ora(\n\t\t\t\t`Installing dependencies...`\n\t\t\t).start();\n\t\t\tawait execa(packageManager, [\n\t\t\t\tpackageManager === \"npm\" ? \"install\" : \"add\",\n\t\t\t\t...PROJECT_DEPENDENCIES\n\t\t\t]);\n\t\t\tdependenciesSpinner.succeed();\n\n\t\t\t// Update styles\n\t\t\tlet stylesDestination = \"./src/app.postcss\";\n\n\t\t\tconst stylesSpinner = ora(\n\t\t\t\t`Adding styles with CSS variables...`\n\t\t\t).start();\n\t\t\tawait fs.writeFile(stylesDestination, STYLES, \"utf8\");\n\t\t\tstylesSpinner.succeed();\n\n\t\t\t// Ensure lib directory exists.\n\t\t\tconst libDir = \"./src/lib\";\n\t\t\tif (!existsSync(path.resolve(libDir))) {\n\t\t\t\tawait fs.mkdir(path.resolve(libDir), { recursive: true });\n\t\t\t}\n\n\t\t\t// Create lib/utils.ts\n\t\t\tconst utilsDestination = \"./src/lib/utils.ts\";\n\n\t\t\tconst utilsSpinner = ora(`Adding utils...`).start();\n\t\t\tawait fs.writeFile(utilsDestination, UTILS, \"utf8\");\n\t\t\tutilsSpinner.succeed();\n\n\t\t\t// Update tailwind.config.cjs\n\t\t\tconst tailwindDestination = \"./tailwind.config.cjs\";\n\t\t\tconst tailwindSpinner = ora(\n\t\t\t\t`Updating tailwind.config.cjs...`\n\t\t\t).start();\n\t\t\tawait fs.writeFile(tailwindDestination, TAILWIND_CONFIG, \"utf8\");\n\t\t\ttailwindSpinner.succeed();\n\t\t});\n\n\tprogram\n\t\t.command(\"add\")\n\t\t.description(\"add components to your project\")\n\t\t.argument(\"[components...]\", \"name of components\")\n\t\t.action(async (components: string[]) => {\n\t\t\tlogger.warn(\n\t\t\t\t\"Running the following command will overwrite existing files.\"\n\t\t\t);\n\t\t\tlogger.warn(\n\t\t\t\t\"Make sure you have committed your changes before proceeding.\"\n\t\t\t);\n\t\t\tlogger.warn(\"\");\n\n\t\t\tconst availableComponents = await getAvailableComponents();\n\n\t\t\tif (!availableComponents?.length) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"An error occurred while fetching components. Please try again.\"\n\t\t\t\t);\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tlet selectedComponents = availableComponents.filter((component) =>\n\t\t\t\tcomponents.includes(component.component)\n\t\t\t);\n\n\t\t\tif (!selectedComponents?.length) {\n\t\t\t\tselectedComponents = await promptForComponents(\n\t\t\t\t\tavailableComponents\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst dir = await promptForDestinationDir();\n\n\t\t\tif (!selectedComponents?.length) {\n\t\t\t\tlogger.warn(\"No components selected. Nothing to install.\");\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\t// Create componentPath directory if it doesn't exist.\n\t\t\tconst destinationDir = path.resolve(dir);\n\t\t\tif (!existsSync(destinationDir)) {\n\t\t\t\tconst spinner = ora(`Creating ${dir}...`).start();\n\t\t\t\tawait fs.mkdir(destinationDir, { recursive: true });\n\t\t\t\tspinner.succeed();\n\t\t\t}\n\n\t\t\tlogger.success(\n\t\t\t\t`Installing ${selectedComponents.length} component(s) and dependencies...`\n\t\t\t);\n\t\t\tfor (const component of selectedComponents) {\n\t\t\t\tconst componentSpinner = ora(`${component.name}...`).start();\n\n\t\t\t\t// Write the files.\n\t\t\t\tfor (const file of component.files) {\n\t\t\t\t\t// Replace alias with the project's alias.\n\t\t\t\t\tif (projectInfo?.alias) {\n\t\t\t\t\t\tfile.content = file.content.replace(\n\t\t\t\t\t\t\t/$\\//g,\n\t\t\t\t\t\t\tprojectInfo.alias\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst dirPath = path.join(dir, file.dir);\n\t\t\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t\t\t\tconst filePath = path.resolve(dirPath, file.name);\n\t\t\t\t\tawait fs.writeFile(filePath, file.content);\n\t\t\t\t}\n\n\t\t\t\t// Install dependencies.\n\t\t\t\tif (component.dependencies?.length) {\n\t\t\t\t\tawait execa(packageManager, [\n\t\t\t\t\t\tpackageManager === \"npm\" ? \"install\" : \"add\",\n\t\t\t\t\t\t...component.dependencies\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\tcomponentSpinner.succeed(component.name);\n\t\t\t}\n\t\t});\n\n\tprogram.parse();\n}\n\nasync function promptForComponents(components: Component[]) {\n\tconst { components: selectedComponents } = await prompts({\n\t\ttype: \"autocompleteMultiselect\",\n\t\tname: \"components\",\n\t\tmessage: \"Which component(s) would you like to add?\",\n\t\thint: \"Space to select. A to select all. I to invert selection.\",\n\t\tinstructions: false,\n\t\tchoices: components.map((component) => ({\n\t\t\ttitle: component.name,\n\t\t\tvalue: component\n\t\t}))\n\t});\n\n\treturn selectedComponents;\n}\n\nasync function promptForDestinationDir() {\n\tconst { dir } = await prompts([\n\t\t{\n\t\t\ttype: \"text\",\n\t\t\tname: \"dir\",\n\t\t\tmessage: \"Where would you like to install the component(s)?\",\n\t\t\tinitial: \"./src/lib/components/ui\"\n\t\t}\n\t]);\n\n\treturn dir;\n}\n\nmain();\n","// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\n\nimport fetch from \"node-fetch\";\nimport * as z from \"zod\";\n\nconst baseUrl = process.env.COMPONENTS_BASE_URL ?? \"https://shadcn-svelte.com\";\n\nconst componentSchema = z.object({\n\tcomponent: z.string(),\n\tname: z.string(),\n\tdependencies: z.array(z.string()).optional(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tname: z.string(),\n\t\t\tdir: z.string(),\n\t\t\tcontent: z.string()\n\t\t})\n\t)\n});\n\nexport type Component = z.infer<typeof componentSchema>;\n\nconst componentsSchema = z.array(componentSchema);\n\nexport async function getAvailableComponents() {\n\ttry {\n\t\tconst response = await fetch(`${baseUrl}/api/components`);\n\t\tconst components = await response.json();\n\n\t\treturn componentsSchema.parse(components);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to fetch components from ${baseUrl}/api/components.`\n\t\t);\n\t}\n}\n","// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\n\nimport path from \"path\";\nimport fs from \"fs-extra\";\nimport { type PackageJson } from \"type-fest\";\n\nexport function getPackageInfo() {\n\tconst packageJsonPath = path.join(\"package.json\");\n\n\treturn fs.readJSONSync(packageJsonPath) as PackageJson;\n}\n","// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\n\nexport function getPackageManager() {\n\tconst userAgent = process.env.npm_config_user_agent;\n\n\tif (!userAgent) {\n\t\treturn \"npm\";\n\t}\n\n\tif (userAgent.startsWith(\"yarn\")) {\n\t\treturn \"yarn\";\n\t}\n\n\tif (userAgent.startsWith(\"pnpm\")) {\n\t\treturn \"pnpm\";\n\t}\n\n\treturn \"npm\";\n}\n","// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\n\nimport { existsSync } from \"fs\";\nimport path from \"path\";\nimport fs from \"fs-extra\";\n\nexport async function getProjectInfo() {\n\tconst info = {\n\t\ttsconfig: null,\n\t\talias: null\n\t};\n\n\ttry {\n\t\tconst tsconfig = await getTsConfig();\n\t\tconst paths = tsconfig?.compilerOptions?.paths;\n\t\tconst alias = paths ? Object.keys(paths)[0].replace(\"*\", \"\") : null;\n\n\t\treturn {\n\t\t\ttsconfig,\n\t\t\talias,\n\t\t\tsrcDir: existsSync(path.resolve(\"./src\")),\n\t\t\tappDir:\n\t\t\t\texistsSync(path.resolve(\"./app\")) ||\n\t\t\t\texistsSync(path.resolve(\"./src/app\"))\n\t\t};\n\t} catch (error) {\n\t\treturn info;\n\t}\n}\n\nexport async function getTsConfig() {\n\ttry {\n\t\tconst tsconfigPath = path.join(\"tsconfig.json\");\n\t\tconst tsconfig = await fs.readJSON(tsconfigPath);\n\n\t\tif (!tsconfig) {\n\t\t\tthrow new Error(\"tsconfig.json is missing\");\n\t\t}\n\n\t\treturn tsconfig;\n\t} catch (error) {\n\t\treturn null;\n\t}\n}\n","// Credit to @shadcn for the original code. It has been slightly modified to fit the needs of this project.\n\nimport chalk from \"chalk\";\n\nexport const logger = {\n\terror(...args: unknown[]) {\n\t\tconsole.log(chalk.red(...args));\n\t},\n\twarn(...args: unknown[]) {\n\t\tconsole.log(chalk.yellow(...args));\n\t},\n\tinfo(...args: unknown[]) {\n\t\tconsole.log(chalk.cyan(...args));\n\t},\n\tsuccess(...args: unknown[]) {\n\t\tconsole.log(chalk.green(...args));\n\t}\n};\n","export const STYLES = `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n \n@layer base {\n :root {\n --background: 0 0% 100%;\n --foreground: 222.2 47.4% 11.2%;\n \n --muted: 210 40% 96.1%;\n --muted-foreground: 215.4 16.3% 46.9%;\n \n --popover: 0 0% 100%;\n --popover-foreground: 222.2 47.4% 11.2%;\n \n --card: 0 0% 100%;\n --card-foreground: 222.2 47.4% 11.2%;\n \n --border: 214.3 31.8% 91.4%;\n --input: 214.3 31.8% 91.4%;\n \n --primary: 222.2 47.4% 11.2%;\n --primary-foreground: 210 40% 98%;\n \n --secondary: 210 40% 96.1%;\n --secondary-foreground: 222.2 47.4% 11.2%;\n \n --accent: 210 40% 96.1%;\n --accent-foreground: 222.2 47.4% 11.2%;\n \n --destructive: 0 100% 50%;\n --destructive-foreground: 210 40% 98%;\n \n --ring: 215 20.2% 65.1%;\n \n --radius: 0.5rem;\n }\n \n .dark {\n --background: 224 71% 4%;\n --foreground: 213 31% 91%;\n \n --muted: 223 47% 11%;\n --muted-foreground: 215.4 16.3% 56.9%;\n \n --popover: 224 71% 4%;\n --popover-foreground: 215 20.2% 65.1%;\n \n --card: 224 71% 4%;\n --card-foreground: 213 31% 91%;\n \n --border: 216 34% 17%;\n --input: 216 34% 17%;\n \n --primary: 210 40% 98%;\n --primary-foreground: 222.2 47.4% 1.2%;\n \n --secondary: 222.2 47.4% 11.2%;\n --secondary-foreground: 210 40% 98%;\n \n --accent: 216 34% 17%;\n --accent-foreground: 210 40% 98%;\n \n --destructive: 360 62% 55%;\n --destructive-foreground: 210 40% 98%;\n \n --ring: 216 34% 17%;\n \n --radius: 0.5rem;\n }\n}\n \n@layer base {\n * {\n @apply border-border;\n }\n body {\n @apply bg-background text-foreground;\n font-feature-settings: \"rlig\" 1, \"calt\" 1;\n }\n}`;\n\nexport const UTILS = `import { ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n \nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`;\n\nexport const TAILWIND_CONFIG = `const { fontFamily } = require(\"tailwindcss/defaultTheme\")\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n darkMode: [\"class\"],\n content: [\"./src/**/*.{html,js,svelte,ts}\"],\n theme: {\n container: {\n center: true,\n padding: \"2rem\",\n screens: {\n \"2xl\": \"1400px\",\n },\n },\n extend: {\n colors: {\n border: \"hsl(var(--border))\",\n input: \"hsl(var(--input))\",\n ring: \"hsl(var(--ring))\",\n background: \"hsl(var(--background))\",\n foreground: \"hsl(var(--foreground))\",\n primary: {\n DEFAULT: \"hsl(var(--primary))\",\n foreground: \"hsl(var(--primary-foreground))\",\n },\n secondary: {\n DEFAULT: \"hsl(var(--secondary))\",\n foreground: \"hsl(var(--secondary-foreground))\",\n },\n destructive: {\n DEFAULT: \"hsl(var(--destructive))\",\n foreground: \"hsl(var(--destructive-foreground))\",\n },\n muted: {\n DEFAULT: \"hsl(var(--muted))\",\n foreground: \"hsl(var(--muted-foreground))\",\n },\n accent: {\n DEFAULT: \"hsl(var(--accent))\",\n foreground: \"hsl(var(--accent-foreground))\",\n },\n popover: {\n DEFAULT: \"hsl(var(--popover))\",\n foreground: \"hsl(var(--popover-foreground))\",\n },\n card: {\n DEFAULT: \"hsl(var(--card))\",\n foreground: \"hsl(var(--card-foreground))\",\n },\n },\n borderRadius: {\n lg: \"var(--radius)\",\n md: \"calc(var(--radius) - 2px)\",\n sm: \"calc(var(--radius) - 4px)\",\n },\n fontFamily: {\n sans: [...fontFamily.sans]\n }\n }\n },\n plugins: [require(\"tailwindcss-animate\")],\n}`;\n\nexport const SVELTE_CONFIG = `import adapter from '@sveltejs/adapter-auto';\nimport { vitePreprocess } from '@sveltejs/kit/vite';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n // Consult https://kit.svelte.dev/docs/integrations#preprocessors\n // for more information about preprocessors\n preprocess: vitePreprocess(),\n\n kit: {\n // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.\n // If your environment is not supported or you settled on a specific environment, switch out the adapter.\n // See https://kit.svelte.dev/docs/adapters for more information about adapters.\n adapter: adapter(),\n alias: {\n $components: \"src/lib/components\",\n \"$components/*\": \"src/lib/components/*\"\n }\n }\n};\n\nexport default config;`;\n"],"mappings":";;;AAEA,SAAS,cAAAA,aAAY,YAAYC,WAAU;AAC3C,OAAOC,WAAU;AACjB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,OAAO,SAAS;AAChB,OAAO,aAAa;;;ACLpB,OAAO,WAAW;AAClB,YAAY,OAAO;AAEnB,IAAM,UAAU,QAAQ,IAAI,uBAAuB;AAEnD,IAAM,kBAAoB,SAAO;AAAA,EAChC,WAAa,SAAO;AAAA,EACpB,MAAQ,SAAO;AAAA,EACf,cAAgB,QAAQ,SAAO,CAAC,EAAE,SAAS;AAAA,EAC3C,OAAS;AAAA,IACN,SAAO;AAAA,MACR,MAAQ,SAAO;AAAA,MACf,KAAO,SAAO;AAAA,MACd,SAAW,SAAO;AAAA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;AAAA,IACd,SAAS,WAAW,IAAI,CAAC,eAAe;AAAA,MACvC,OAAO,UAAU;AAAA,MACjB,OAAO;AAAA,IACR,EAAE;AAAA,EACH,CAAC;AAED,SAAO;AACR;AAEA,eAAe,0BAA0B;AACxC,QAAM,EAAE,IAAI,IAAI,MAAM,QAAQ;AAAA,IAC7B;AAAA,MACC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,IACV;AAAA,EACD,CAAC;AAED,SAAO;AACR;AAEA,KAAK;","names":["existsSync","fs","path","path","fs","fs","existsSync","path"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shadcn-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Add components to your apps.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"author": {
|
|
10
|
-
"name": "huntabyte",
|
|
10
|
+
"name": "huntabyte & shadcn",
|
|
11
11
|
"url": "https://twitter.com/huntabyte"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",
|
|
46
46
|
"@types/fs-extra": "^11.0.1",
|
|
47
47
|
"@types/prompts": "^2.4.2",
|
|
48
|
-
"prettier": "^2.8.8",
|
|
49
48
|
"rimraf": "^4.1.3",
|
|
50
49
|
"tsup": "^6.6.3",
|
|
51
50
|
"type-fest": "^3.8.0",
|
|
@@ -58,8 +57,8 @@
|
|
|
58
57
|
"clean": "rimraf dist && rimraf components",
|
|
59
58
|
"start:dev": "cross-env COMPONENTS_BASE_URL=http://localhost:5173 node dist/index.js",
|
|
60
59
|
"start": "node dist/index.js",
|
|
61
|
-
"format:write": "prettier --write
|
|
62
|
-
"format:check": "prettier --check
|
|
60
|
+
"format:write": "prettier --write .",
|
|
61
|
+
"format:check": "prettier --check .",
|
|
63
62
|
"release": "changeset version",
|
|
64
63
|
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
65
64
|
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next",
|