shadcn-svelte 0.0.5 → 0.0.6

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
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { existsSync as existsSync2, promises as fs3 } from "fs";
5
- import path3 from "path";
4
+ import { existsSync as existsSync2, promises as fs4 } from "fs";
5
+ import path4 from "path";
6
6
  import { Command } from "commander";
7
7
  import { execa } from "execa";
8
8
  import ora from "ora";
@@ -113,6 +113,153 @@ var logger = {
113
113
  }
114
114
  };
115
115
 
116
+ // src/utils/set-config.ts
117
+ import fs3 from "fs";
118
+ import path3 from "path";
119
+ import { parse } from "acorn";
120
+ import { generate } from "astring";
121
+ import { walk } from "estree-walker";
122
+ import prettier from "prettier";
123
+
124
+ // src/utils/schemas.ts
125
+ import { z as z2 } from "zod";
126
+ var shadConfigSchema = z2.object({
127
+ value: z2.object({
128
+ type: z2.literal("ObjectExpression"),
129
+ properties: z2.array(
130
+ z2.object({
131
+ type: z2.literal("Property"),
132
+ key: z2.object({
133
+ type: z2.literal("Identifier"),
134
+ name: z2.enum(["componentPath"])
135
+ }),
136
+ value: z2.object({
137
+ type: z2.literal("Literal"),
138
+ value: z2.string()
139
+ })
140
+ })
141
+ )
142
+ })
143
+ }).transform((data) => {
144
+ return {
145
+ componentPath: data.value.properties[0].value.value
146
+ };
147
+ });
148
+
149
+ // src/utils/set-config.ts
150
+ function getConfig() {
151
+ const svelteConfigPath = path3.join(process.cwd(), "svelte.config.js");
152
+ const svelteConfig = fs3.readFileSync(svelteConfigPath, "utf8");
153
+ const ast = parse(svelteConfig, {
154
+ ecmaVersion: "latest",
155
+ sourceType: "module"
156
+ });
157
+ let shadConfigNode = null;
158
+ walk(ast, {
159
+ enter(node) {
160
+ if (node.type === "VariableDeclaration" && node.kind === "const" && node.declarations[0].type === "VariableDeclarator" && node.declarations[0].id.type === "Identifier" && node.declarations[0].id.name === "config") {
161
+ const configNode = node.declarations[0];
162
+ if (configNode.init && configNode.init.type === "ObjectExpression") {
163
+ const shadConfig = configNode.init.properties.find(
164
+ (property) => {
165
+ if (property.type !== "Property") {
166
+ return false;
167
+ }
168
+ if (property.key.type !== "Identifier") {
169
+ return false;
170
+ }
171
+ return property.key.name === "shadcn";
172
+ }
173
+ );
174
+ if (!shadConfig || shadConfig.type !== "Property") {
175
+ return;
176
+ }
177
+ shadConfigNode = shadConfig;
178
+ return;
179
+ }
180
+ }
181
+ }
182
+ });
183
+ if (!shadConfigNode) {
184
+ return null;
185
+ }
186
+ try {
187
+ const shadConfig = shadConfigSchema.parse(shadConfigNode);
188
+ return shadConfig;
189
+ } catch (e) {
190
+ return null;
191
+ }
192
+ }
193
+ function setConfig(dir = "./src/lib/components/ui") {
194
+ const svelteConfigPath = path3.join(process.cwd(), "svelte.config.js");
195
+ const svelteConfig = fs3.readFileSync(svelteConfigPath, "utf8");
196
+ const ast = parse(svelteConfig, {
197
+ ecmaVersion: "latest",
198
+ sourceType: "module"
199
+ });
200
+ const updatedSvelteConfig = walk(ast, {
201
+ enter(node) {
202
+ if (node.type === "VariableDeclaration" && node.kind === "const" && node.declarations[0].type === "VariableDeclarator" && node.declarations[0].id.type === "Identifier" && node.declarations[0].id.name === "config") {
203
+ const configNode = node.declarations[0];
204
+ if (configNode.init && configNode.init.type === "ObjectExpression") {
205
+ configNode.init.properties.push(createConfigNode(dir));
206
+ }
207
+ }
208
+ }
209
+ });
210
+ if (!updatedSvelteConfig) {
211
+ throw new Error("Could not update svelte.config.js");
212
+ }
213
+ const updatedSvelteConfigString = generate(updatedSvelteConfig);
214
+ const prettierConfigFile = prettier.resolveConfigFile.sync(svelteConfigPath);
215
+ if (!prettierConfigFile) {
216
+ return fs3.writeFileSync(svelteConfigPath, updatedSvelteConfigString);
217
+ }
218
+ const prettierConfig = prettier.resolveConfig.sync(prettierConfigFile);
219
+ if (!prettierConfig) {
220
+ return fs3.writeFileSync(svelteConfigPath, updatedSvelteConfigString);
221
+ }
222
+ const prettySvelteConfig = prettier.format(
223
+ updatedSvelteConfigString,
224
+ prettierConfig
225
+ );
226
+ return fs3.writeFileSync(svelteConfigPath, prettySvelteConfig);
227
+ }
228
+ function createConfigNode(dir) {
229
+ return {
230
+ type: "Property",
231
+ method: false,
232
+ shorthand: false,
233
+ computed: false,
234
+ key: {
235
+ type: "Identifier",
236
+ name: "shadcn"
237
+ },
238
+ value: {
239
+ type: "ObjectExpression",
240
+ properties: [
241
+ {
242
+ type: "Property",
243
+ method: false,
244
+ shorthand: false,
245
+ computed: false,
246
+ key: {
247
+ type: "Identifier",
248
+ name: "componentPath"
249
+ },
250
+ value: {
251
+ type: "Literal",
252
+ value: dir,
253
+ raw: `'${dir}'`
254
+ },
255
+ kind: "init"
256
+ }
257
+ ]
258
+ },
259
+ kind: "init"
260
+ };
261
+ }
262
+
116
263
  // src/utils/templates.ts
117
264
  var STYLES = `@tailwind base;
118
265
  @tailwind components;
@@ -295,7 +442,7 @@ async function main() {
295
442
  const { proceed } = await prompts({
296
443
  type: "confirm",
297
444
  name: "proceed",
298
- message: "Running this command will install dependencies and overwrite your existing tailwind.config.cjs. Proceed?",
445
+ message: "Running this command will install dependencies and overwrite your existing tailwind.config.cjs & svelte.config.js. Proceed?",
299
446
  initial: true
300
447
  });
301
448
  if (!proceed) {
@@ -314,22 +461,32 @@ async function main() {
314
461
  const stylesSpinner = ora(
315
462
  `Adding styles with CSS variables...`
316
463
  ).start();
317
- await fs3.writeFile(stylesDestination, STYLES, "utf8");
464
+ await fs4.writeFile(stylesDestination, STYLES, "utf8");
318
465
  stylesSpinner.succeed();
319
466
  const libDir = "./src/lib";
320
- if (!existsSync2(path3.resolve(libDir))) {
321
- await fs3.mkdir(path3.resolve(libDir), { recursive: true });
467
+ if (!existsSync2(path4.resolve(libDir))) {
468
+ await fs4.mkdir(path4.resolve(libDir), { recursive: true });
322
469
  }
323
470
  const utilsDestination = "./src/lib/utils.ts";
324
471
  const utilsSpinner = ora(`Adding utils...`).start();
325
- await fs3.writeFile(utilsDestination, UTILS, "utf8");
472
+ await fs4.writeFile(utilsDestination, UTILS, "utf8");
326
473
  utilsSpinner.succeed();
327
474
  const tailwindDestination = "./tailwind.config.cjs";
328
475
  const tailwindSpinner = ora(
329
476
  `Updating tailwind.config.cjs...`
330
477
  ).start();
331
- await fs3.writeFile(tailwindDestination, TAILWIND_CONFIG, "utf8");
478
+ await fs4.writeFile(tailwindDestination, TAILWIND_CONFIG, "utf8");
332
479
  tailwindSpinner.succeed();
480
+ const svelteConfigDestination = "./svelte.config.js";
481
+ const svelteConfigSpinner = ora(
482
+ `Updating svelte.config.js...`
483
+ ).start();
484
+ await fs4.writeFile(
485
+ svelteConfigDestination,
486
+ TAILWIND_CONFIG,
487
+ "utf8"
488
+ );
489
+ svelteConfigSpinner.succeed();
333
490
  });
334
491
  program.command("add").description("add components to your project").argument("[components...]", "name of components").action(async (components) => {
335
492
  logger.warn(
@@ -359,10 +516,10 @@ async function main() {
359
516
  logger.warn("No components selected. Nothing to install.");
360
517
  process.exit(0);
361
518
  }
362
- const destinationDir = path3.resolve(dir);
519
+ const destinationDir = path4.resolve(dir);
363
520
  if (!existsSync2(destinationDir)) {
364
521
  const spinner = ora(`Creating ${dir}...`).start();
365
- await fs3.mkdir(destinationDir, { recursive: true });
522
+ await fs4.mkdir(destinationDir, { recursive: true });
366
523
  spinner.succeed();
367
524
  }
368
525
  logger.success(
@@ -377,10 +534,10 @@ async function main() {
377
534
  projectInfo.alias
378
535
  );
379
536
  }
380
- const dirPath = path3.join(dir, file.dir);
381
- await fs3.mkdir(dirPath, { recursive: true });
382
- const filePath = path3.resolve(dirPath, file.name);
383
- await fs3.writeFile(filePath, file.content);
537
+ const dirPath = path4.join(dir, file.dir);
538
+ await fs4.mkdir(dirPath, { recursive: true });
539
+ const filePath = path4.resolve(dirPath, file.name);
540
+ await fs4.writeFile(filePath, file.content);
384
541
  }
385
542
  if (component.dependencies?.length) {
386
543
  await execa(packageManager, [
@@ -408,15 +565,20 @@ async function promptForComponents(components) {
408
565
  return selectedComponents;
409
566
  }
410
567
  async function promptForDestinationDir() {
411
- const { dir } = await prompts([
412
- {
413
- type: "text",
414
- name: "dir",
415
- message: "Where would you like to install the component(s)?",
416
- initial: "./src/lib/components/ui"
417
- }
418
- ]);
419
- return dir;
568
+ const config = getConfig();
569
+ if (!config) {
570
+ const { dir } = await prompts([
571
+ {
572
+ type: "text",
573
+ name: "dir",
574
+ message: "Where would you like to install the component(s)?",
575
+ initial: "./src/lib/components/ui"
576
+ }
577
+ ]);
578
+ setConfig(dir);
579
+ return dir;
580
+ }
581
+ return config.componentPath;
420
582
  }
421
583
  main();
422
584
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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://shadcn-svelte.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 { type 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 }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AK,QAAQ,SAAS,KAAK,IAAI;AAChD,cAAMF,IAAG,UAAU,UAAU,KAAK,OAAO;AAAA,MAC1C;AAGA,UAAI,UAAU,cAAc,QAAQ;AACnC,cAAM,MAAM,gBAAgB;AAAA,UAC3B,mBAAmB,QAAQ,YAAY;AAAA,UACvC,GAAG,UAAU;AAAA,QACd,CAAC;AAAA,MACF;AACA,uBAAiB,QAAQ,UAAU,IAAI;AAAA,IACxC;AAAA,EACD,CAAC;AAEF,UAAQ,MAAM;AACf;AAEA,eAAe,oBAAoB,YAAyB;AAC3D,QAAM,EAAE,YAAY,mBAAmB,IAAI,MAAM,QAAQ;AAAA,IACxD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,IACN,cAAc;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"]}
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/set-config.ts","../src/utils/schemas.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 { getConfig, setConfig } from \"./utils/set-config\";\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://shadcn-svelte.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 & svelte.config.js. 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\n\t\t\t// Update svelte.config.js\n\t\t\tconst svelteConfigDestination = \"./svelte.config.js\";\n\t\t\tconst svelteConfigSpinner = ora(\n\t\t\t\t`Updating svelte.config.js...`\n\t\t\t).start();\n\t\t\tawait fs.writeFile(\n\t\t\t\tsvelteConfigDestination,\n\t\t\t\tTAILWIND_CONFIG,\n\t\t\t\t\"utf8\"\n\t\t\t);\n\t\t\tsvelteConfigSpinner.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 config = getConfig();\n\n\tif (!config) {\n\t\tconst { dir } = await prompts([\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\tname: \"dir\",\n\t\t\t\tmessage: \"Where would you like to install the component(s)?\",\n\t\t\t\tinitial: \"./src/lib/components/ui\"\n\t\t\t}\n\t\t]);\n\t\tsetConfig(dir);\n\t\treturn dir;\n\t}\n\n\treturn config.componentPath;\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","import fs from \"fs\";\nimport path from \"path\";\nimport type { Property } from \"estree\";\nimport type { Node } from \"estree-walker\";\nimport { parse } from \"acorn\";\nimport { generate } from \"astring\";\nimport { walk } from \"estree-walker\";\nimport prettier from \"prettier\";\nimport { ShadConfig, shadConfigSchema } from \"./schemas\";\n\nexport function getConfig(): ShadConfig | null {\n\tconst svelteConfigPath = path.join(process.cwd(), \"svelte.config.js\");\n\n\tconst svelteConfig = fs.readFileSync(svelteConfigPath, \"utf8\");\n\n\tconst ast = parse(svelteConfig, {\n\t\tecmaVersion: \"latest\",\n\t\tsourceType: \"module\"\n\t});\n\n\tlet shadConfigNode: Node | null = null;\n\n\twalk(ast as Node, {\n\t\tenter(node) {\n\t\t\tif (\n\t\t\t\tnode.type === \"VariableDeclaration\" &&\n\t\t\t\tnode.kind === \"const\" &&\n\t\t\t\tnode.declarations[0].type === \"VariableDeclarator\" &&\n\t\t\t\tnode.declarations[0].id.type === \"Identifier\" &&\n\t\t\t\tnode.declarations[0].id.name === \"config\"\n\t\t\t) {\n\t\t\t\tconst configNode = node.declarations[0];\n\t\t\t\tif (\n\t\t\t\t\tconfigNode.init &&\n\t\t\t\t\tconfigNode.init.type === \"ObjectExpression\"\n\t\t\t\t) {\n\t\t\t\t\tconst shadConfig = configNode.init.properties.find(\n\t\t\t\t\t\t(property) => {\n\t\t\t\t\t\t\tif (property.type !== \"Property\") {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (property.key.type !== \"Identifier\") {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn property.key.name === \"shadcn\";\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!shadConfig || shadConfig.type !== \"Property\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tshadConfigNode = shadConfig;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tif (!shadConfigNode) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst shadConfig = shadConfigSchema.parse(shadConfigNode);\n\t\treturn shadConfig;\n\t} catch (e) {\n\t\treturn null;\n\t}\n}\n\nexport function setConfig(dir: string = \"./src/lib/components/ui\") {\n\t// Parse the svelte.config.js file into an abstract syntax tree (AST),\n\t// then walk the tree to find the config object and add the shadcn\n\t// property to it with the componentPath property.\n\n\tconst svelteConfigPath = path.join(process.cwd(), \"svelte.config.js\");\n\n\tconst svelteConfig = fs.readFileSync(svelteConfigPath, \"utf8\");\n\n\tconst ast = parse(svelteConfig, {\n\t\tecmaVersion: \"latest\",\n\t\tsourceType: \"module\"\n\t});\n\n\tconst updatedSvelteConfig = walk(ast as Node, {\n\t\tenter(node) {\n\t\t\tif (\n\t\t\t\tnode.type === \"VariableDeclaration\" &&\n\t\t\t\tnode.kind === \"const\" &&\n\t\t\t\tnode.declarations[0].type === \"VariableDeclarator\" &&\n\t\t\t\tnode.declarations[0].id.type === \"Identifier\" &&\n\t\t\t\tnode.declarations[0].id.name === \"config\"\n\t\t\t) {\n\t\t\t\tconst configNode = node.declarations[0];\n\t\t\t\tif (\n\t\t\t\t\tconfigNode.init &&\n\t\t\t\t\tconfigNode.init.type === \"ObjectExpression\"\n\t\t\t\t) {\n\t\t\t\t\tconfigNode.init.properties.push(createConfigNode(dir));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tif (!updatedSvelteConfig) {\n\t\tthrow new Error(\"Could not update svelte.config.js\");\n\t}\n\n\tconst updatedSvelteConfigString = generate(updatedSvelteConfig);\n\n\tconst prettierConfigFile =\n\t\tprettier.resolveConfigFile.sync(svelteConfigPath);\n\n\tif (!prettierConfigFile) {\n\t\treturn fs.writeFileSync(svelteConfigPath, updatedSvelteConfigString);\n\t}\n\n\tconst prettierConfig = prettier.resolveConfig.sync(prettierConfigFile);\n\n\tif (!prettierConfig) {\n\t\treturn fs.writeFileSync(svelteConfigPath, updatedSvelteConfigString);\n\t}\n\n\tconst prettySvelteConfig = prettier.format(\n\t\tupdatedSvelteConfigString,\n\t\tprettierConfig\n\t);\n\n\treturn fs.writeFileSync(svelteConfigPath, prettySvelteConfig);\n}\n\nfunction createConfigNode(dir: string): Property {\n\treturn {\n\t\ttype: \"Property\",\n\t\tmethod: false,\n\t\tshorthand: false,\n\t\tcomputed: false,\n\t\tkey: {\n\t\t\ttype: \"Identifier\",\n\t\t\tname: \"shadcn\"\n\t\t},\n\t\tvalue: {\n\t\t\ttype: \"ObjectExpression\",\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"Property\",\n\t\t\t\t\tmethod: false,\n\t\t\t\t\tshorthand: false,\n\t\t\t\t\tcomputed: false,\n\t\t\t\t\tkey: {\n\t\t\t\t\t\ttype: \"Identifier\",\n\t\t\t\t\t\tname: \"componentPath\"\n\t\t\t\t\t},\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\ttype: \"Literal\",\n\t\t\t\t\t\tvalue: dir,\n\t\t\t\t\t\traw: `'${dir}'`\n\t\t\t\t\t},\n\t\t\t\t\tkind: \"init\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tkind: \"init\"\n\t};\n}\n","import { z } from \"zod\";\n\nexport const shadConfigSchema = z\n\t.object({\n\t\tvalue: z.object({\n\t\t\ttype: z.literal(\"ObjectExpression\"),\n\t\t\tproperties: z.array(\n\t\t\t\tz.object({\n\t\t\t\t\ttype: z.literal(\"Property\"),\n\t\t\t\t\tkey: z.object({\n\t\t\t\t\t\ttype: z.literal(\"Identifier\"),\n\t\t\t\t\t\tname: z.enum([\"componentPath\"])\n\t\t\t\t\t}),\n\t\t\t\t\tvalue: z.object({\n\t\t\t\t\t\ttype: z.literal(\"Literal\"),\n\t\t\t\t\t\tvalue: z.string()\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t)\n\t\t})\n\t})\n\t.transform((data) => {\n\t\treturn {\n\t\t\tcomponentPath: data.value.properties[0].value.value\n\t\t};\n\t});\n\nexport type ShadConfig = z.infer<typeof shadConfigSchema>;\n","import type { Node } from \"estree-walker\";\n\nexport 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 { type 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\nexport const FULL_ALIAS_NODE: Node = {\n\ttype: \"Property\",\n\tmethod: false,\n\tshorthand: false,\n\tcomputed: false,\n\tkey: {\n\t\ttype: \"Identifier\",\n\t\tname: \"alias\"\n\t},\n\tvalue: {\n\t\ttype: \"ObjectExpression\",\n\t\tproperties: [\n\t\t\t{\n\t\t\t\ttype: \"Property\",\n\t\t\t\tmethod: false,\n\t\t\t\tshorthand: false,\n\t\t\t\tcomputed: false,\n\t\t\t\tkey: {\n\t\t\t\t\ttype: \"Identifier\",\n\t\t\t\t\tname: \"$components\"\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"Literal\",\n\t\t\t\t\tvalue: \"src/lib/components\",\n\t\t\t\t\traw: '\"src/lib/components\"'\n\t\t\t\t},\n\t\t\t\tkind: \"init\"\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: \"Property\",\n\t\t\t\tmethod: false,\n\t\t\t\tshorthand: false,\n\t\t\t\tcomputed: false,\n\t\t\t\tkey: {\n\t\t\t\t\ttype: \"Literal\",\n\t\t\t\t\tvalue: \"$components/*\",\n\t\t\t\t\traw: '\"$components/*\"'\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"Literal\",\n\t\t\t\t\tvalue: \"src/lib/components/*\",\n\t\t\t\t\traw: '\"src/lib/components/*\"'\n\t\t\t\t},\n\t\t\t\tkind: \"init\"\n\t\t\t}\n\t\t]\n\t},\n\tkind: \"init\"\n};\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,IACnB,CAAC;AAAA,EACF;AACD,CAAC;AAID,IAAM,mBAAqB,QAAM,eAAe;AAEhD,eAAsB,yBAAyB;AAC9C,MAAI;AACH,UAAM,WAAW,MAAM,MAAM,GAAG,wBAAwB;AACxD,UAAM,aAAa,MAAM,SAAS,KAAK;AAEvC,WAAO,iBAAi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AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,CAAC;AACD,cAAU,GAAG;AACb,WAAO;AAAA,EACR;AAEA,SAAO,OAAO;AACf;AAEA,KAAK;","names":["existsSync","fs","path","path","fs","fs","path","z","path","fs","fs","existsSync","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadcn-svelte",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Add components to your apps.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,18 +32,25 @@
32
32
  "exports": "./dist/index.js",
33
33
  "bin": "./dist/index.js",
34
34
  "dependencies": {
35
+ "acorn": "^8.8.2",
36
+ "astring": "^1.8.5",
35
37
  "chalk": "5.2.0",
36
38
  "commander": "^10.0.0",
39
+ "estree-walker": "^3.0.3",
37
40
  "execa": "^7.0.0",
38
41
  "fs-extra": "^11.1.0",
39
42
  "node-fetch": "^3.3.0",
40
43
  "ora": "^6.1.2",
44
+ "prettier": "^2.8.8",
41
45
  "prompts": "^2.4.2",
46
+ "radix-svelte": "^0.7.0",
42
47
  "zod": "^3.20.2"
43
48
  },
44
49
  "devDependencies": {
45
50
  "@ianvs/prettier-plugin-sort-imports": "^3.7.2",
51
+ "@types/estree": "^1.0.1",
46
52
  "@types/fs-extra": "^11.0.1",
53
+ "@types/prettier": "^2.7.2",
47
54
  "@types/prompts": "^2.4.2",
48
55
  "rimraf": "^4.1.3",
49
56
  "tsup": "^6.6.3",
@@ -62,6 +69,7 @@
62
69
  "release": "changeset version",
63
70
  "pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
64
71
  "pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next",
65
- "pub:release": "pnpm build && pnpm publish --access public"
72
+ "pub:release": "pnpm build && pnpm publish --access public",
73
+ "temp": "pnpm build && pnpm start config"
66
74
  }
67
75
  }