shadcn-solid-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # shadcn-solid
2
+
3
+ SolidJS용 shadcn 컴포넌트를 프로젝트에 추가하는 CLI 도구입니다.
4
+
5
+ ## 설치
6
+
7
+ ```bash
8
+ npx shadcn-solid@latest init
9
+ ```
10
+
11
+ ## 사용법
12
+
13
+ ### 프로젝트 초기화
14
+
15
+ ```bash
16
+ npx shadcn-solid@latest init
17
+ ```
18
+
19
+ 대화형 프롬프트를 통해 프로젝트를 설정하고 `components.json` 파일을 생성합니다.
20
+
21
+ ### 컴포넌트 추가
22
+
23
+ ```bash
24
+ npx shadcn-solid@latest add button
25
+ ```
26
+
27
+ 여러 컴포넌트를 한 번에 추가할 수도 있습니다:
28
+
29
+ ```bash
30
+ npx shadcn-solid@latest add button card dialog
31
+ ```
32
+
33
+ ### 사용 가능한 컴포넌트 목록 보기
34
+
35
+ ```bash
36
+ npx shadcn-solid@latest list
37
+ ```
38
+
39
+ ## 옵션
40
+
41
+ ### `init`
42
+
43
+ ```bash
44
+ npx shadcn-solid@latest init [options]
45
+ ```
46
+
47
+ 옵션:
48
+ - `-y, --yes` - 확인 프롬프트를 건너뜁니다
49
+ - `-c, --cwd <cwd>` - 작업 디렉토리를 지정합니다
50
+
51
+ ### `add`
52
+
53
+ ```bash
54
+ npx shadcn-solid@latest add [components...] [options]
55
+ ```
56
+
57
+ 옵션:
58
+ - `-y, --yes` - 확인 프롬프트를 건너뜁니다
59
+ - `-o, --overwrite` - 기존 파일을 덮어씁니다
60
+ - `-c, --cwd <cwd>` - 작업 디렉토리를 지정합니다
61
+
62
+ ## 개발
63
+
64
+ ```bash
65
+ # 의존성 설치
66
+ bun install
67
+
68
+ # 빌드
69
+ bun run build
70
+
71
+ # 로컬 테스트
72
+ node dist/index.js init
73
+ ```
74
+
75
+ ## License
76
+
77
+ MIT
@@ -0,0 +1,115 @@
1
+ import kleur from 'kleur';
2
+ import path from 'path';
3
+ import { cosmiconfig } from 'cosmiconfig';
4
+ import { z } from 'zod';
5
+
6
+ // src/utils/logger.ts
7
+ var logger = {
8
+ error(message) {
9
+ console.log(kleur.red(message));
10
+ },
11
+ warn(message) {
12
+ console.log(kleur.yellow(message));
13
+ },
14
+ info(message) {
15
+ console.log(kleur.cyan(message));
16
+ },
17
+ success(message) {
18
+ console.log(kleur.green(message));
19
+ },
20
+ break() {
21
+ console.log("");
22
+ }
23
+ };
24
+ var configSchema = z.object({
25
+ $schema: z.string().optional(),
26
+ style: z.string().default("default"),
27
+ tailwind: z.object({
28
+ config: z.string(),
29
+ css: z.string(),
30
+ baseColor: z.string().optional(),
31
+ cssVariables: z.boolean().default(true)
32
+ }),
33
+ solidjs: z.object({
34
+ componentsPath: z.string(),
35
+ utilsPath: z.string()
36
+ }),
37
+ aliases: z.object({
38
+ components: z.string(),
39
+ utils: z.string()
40
+ })
41
+ });
42
+ var explorer = cosmiconfig("components", {
43
+ searchPlaces: [
44
+ "components.json",
45
+ ".componentsrc",
46
+ ".componentsrc.json"
47
+ ]
48
+ });
49
+ async function getConfig(cwd) {
50
+ try {
51
+ const configResult = await explorer.search(cwd);
52
+ if (!configResult) {
53
+ return null;
54
+ }
55
+ return configSchema.parse(configResult.config);
56
+ } catch (error) {
57
+ return null;
58
+ }
59
+ }
60
+ async function resolveConfigPaths(cwd, config) {
61
+ return {
62
+ ...config,
63
+ resolvedPaths: {
64
+ tailwindConfig: path.resolve(cwd, config.tailwind.config),
65
+ tailwindCss: path.resolve(cwd, config.tailwind.css),
66
+ components: path.resolve(cwd, config.solidjs.componentsPath),
67
+ utils: path.resolve(cwd, config.solidjs.utilsPath)
68
+ }
69
+ };
70
+ }
71
+ var registryItemFileSchema = z.object({
72
+ path: z.string(),
73
+ content: z.string(),
74
+ type: z.enum(["registry:ui", "registry:lib", "registry:hook"]),
75
+ target: z.string().optional()
76
+ });
77
+ var registryItemSchema = z.object({
78
+ name: z.string(),
79
+ type: z.enum(["registry:ui", "registry:lib", "registry:hook"]),
80
+ files: z.array(registryItemFileSchema),
81
+ dependencies: z.array(z.string()).optional(),
82
+ devDependencies: z.array(z.string()).optional(),
83
+ registryDependencies: z.array(z.string()).optional()
84
+ });
85
+ var REGISTRY_URL = process.env.REGISTRY_URL || "http://localhost:3000/r";
86
+ async function fetchRegistry(name) {
87
+ try {
88
+ const response = await fetch(`${REGISTRY_URL}/${name}.json`);
89
+ if (!response.ok) {
90
+ return null;
91
+ }
92
+ const data = await response.json();
93
+ return registryItemSchema.parse(data);
94
+ } catch (error) {
95
+ console.error(`Failed to fetch registry item: ${name}`, error);
96
+ return null;
97
+ }
98
+ }
99
+ async function fetchRegistryIndex() {
100
+ try {
101
+ const response = await fetch(`${REGISTRY_URL}/index.json`);
102
+ if (!response.ok) {
103
+ return [];
104
+ }
105
+ const data = await response.json();
106
+ return z.array(z.string()).parse(data);
107
+ } catch (error) {
108
+ console.error("Failed to fetch registry index", error);
109
+ return [];
110
+ }
111
+ }
112
+
113
+ export { configSchema, fetchRegistry, fetchRegistryIndex, getConfig, logger, registryItemFileSchema, registryItemSchema, resolveConfigPaths };
114
+ //# sourceMappingURL=chunk-5YAIISX4.js.map
115
+ //# sourceMappingURL=chunk-5YAIISX4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/logger.ts","../src/utils/get-config.ts","../src/utils/registry.ts"],"names":["z"],"mappings":";;;;;;AAEO,IAAM,MAAA,GAAS;AAAA,EACpB,MAAM,OAAA,EAAiB;AACrB,IAAA,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAM,GAAA,CAAI,OAAO,CAAC,CAAA;AAAA,EAChC,CAAA;AAAA,EACA,KAAK,OAAA,EAAiB;AACpB,IAAA,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAM,MAAA,CAAO,OAAO,CAAC,CAAA;AAAA,EACnC,CAAA;AAAA,EACA,KAAK,OAAA,EA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,CAAAA,CAAE,QAAQ,CAAA,CAAE,MAAM,IAAI,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA,CAAM,kCAAkC,KAAK,CAAA;AACrD,IAAA,OAAO,EAAC;AAAA,EACV;AACF","file":"chunk-5YAIISX4.js","sourcesContent":["import kleur from \"kleur\"\n\nexport const logger = {\n error(message: string) {\n console.log(kleur.red(message))\n },\n warn(message: string) {\n console.log(kleur.yellow(message))\n },\n info(message: string) {\n console.log(kleur.cyan(message))\n },\n success(message: string) {\n console.log(kleur.green(message))\n },\n break() {\n console.log(\"\")\n },\n}\n","import path from \"path\"\nimport { cosmiconfig } from \"cosmiconfig\"\nimport { z } from \"zod\"\n\nexport const configSchema = z.object({\n $schema: z.string().optional(),\n style: z.string().default(\"default\"),\n tailwind: z.object({\n config: z.string(),\n css: z.string(),\n baseColor: z.string().optional(),\n cssVariables: z.boolean().default(true),\n }),\n solidjs: z.object({\n componentsPath: z.string(),\n utilsPath: z.string(),\n }),\n aliases: z.object({\n components: z.string(),\n utils: z.string(),\n }),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nconst explorer = cosmiconfig(\"components\", {\n searchPlaces: [\n \"components.json\",\n \".componentsrc\",\n \".componentsrc.json\",\n ],\n})\n\nexport async function getConfig(cwd: string): Promise<Config | null> {\n try {\n const configResult = await explorer.search(cwd)\n\n if (!configResult) {\n return null\n }\n\n return configSchema.parse(configResult.config)\n } catch (error) {\n return null\n }\n}\n\nexport async function resolveConfigPaths(cwd: string, config: Config) {\n return {\n ...config,\n resolvedPaths: {\n tailwindConfig: path.resolve(cwd, config.tailwind.config),\n tailwindCss: path.resolve(cwd, config.tailwind.css),\n components: path.resolve(cwd, config.solidjs.componentsPath),\n utils: path.resolve(cwd, config.solidjs.utilsPath),\n },\n }\n}\n","import { z } from \"zod\"\n\nexport const registryItemFileSchema = z.object({\n path: z.string(),\n content: z.string(),\n type: z.enum([\"registry:ui\", \"registry:lib\", \"registry:hook\"]),\n target: z.string().optional(),\n})\n\nexport const registryItemSchema = z.object({\n name: z.string(),\n type: z.enum([\"registry:ui\", \"registry:lib\", \"registry:hook\"]),\n files: z.array(registryItemFileSchema),\n dependencies: z.array(z.string()).optional(),\n devDependencies: z.array(z.string()).optional(),\n registryDependencies: z.array(z.string()).optional(),\n})\n\nexport type RegistryItem = z.infer<typeof registryItemSchema>\n\nconst REGISTRY_URL = process.env.REGISTRY_URL || \"http://localhost:3000/r\"\n\nexport async function fetchRegistry(name: string): Promise<RegistryItem | null> {\n try {\n const response = await fetch(`${REGISTRY_URL}/${name}.json`)\n \n if (!response.ok) {\n return null\n }\n\n const data = await response.json()\n return registryItemSchema.parse(data)\n } catch (error) {\n console.error(`Failed to fetch registry item: ${name}`, error)\n return null\n }\n}\n\nexport async function fetchRegistryIndex(): Promise<string[]> {\n try {\n const response = await fetch(`${REGISTRY_URL}/index.json`)\n \n if (!response.ok) {\n return []\n }\n\n const data = await response.json()\n return z.array(z.string()).parse(data)\n } catch (error) {\n console.error(\"Failed to fetch registry index\", error)\n return []\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env node
2
+ import { getConfig, logger, resolveConfigPaths, fetchRegistry, fetchRegistryIndex } from './chunk-5YAIISX4.js';
3
+ import { Command } from 'commander';
4
+ import { existsSync, promises } from 'fs';
5
+ import path from 'path';
6
+ import ora from 'ora';
7
+ import prompts from 'prompts';
8
+ import { z } from 'zod';
9
+
10
+ var addOptionsSchema = z.object({
11
+ components: z.array(z.string()).optional(),
12
+ cwd: z.string(),
13
+ overwrite: z.boolean(),
14
+ yes: z.boolean()
15
+ });
16
+ var add = new Command().name("add").description("add a component to your project").argument("[components...]", "the components to add").option(
17
+ "-c, --cwd <cwd>",
18
+ "the working directory. defaults to the current directory.",
19
+ process.cwd()
20
+ ).option("-o, --overwrite", "overwrite existing files.", false).option("-y, --yes", "skip confirmation prompt.", false).action(async (components, opts) => {
21
+ try {
22
+ const options = addOptionsSchema.parse({
23
+ components,
24
+ cwd: path.resolve(opts.cwd),
25
+ ...opts
26
+ });
27
+ const config = await getConfig(options.cwd);
28
+ if (!config) {
29
+ logger.error(
30
+ "Configuration not found. Please run 'shadcn-solid init' first."
31
+ );
32
+ process.exit(1);
33
+ }
34
+ const resolvedConfig = await resolveConfigPaths(options.cwd, config);
35
+ let selectedComponents = options.components || [];
36
+ if (selectedComponents.length === 0) {
37
+ const { component } = await prompts({
38
+ type: "text",
39
+ name: "component",
40
+ message: "Which component would you like to add?"
41
+ });
42
+ if (!component) {
43
+ logger.info("No component selected.");
44
+ process.exit(0);
45
+ }
46
+ selectedComponents = [component];
47
+ }
48
+ for (const componentName of selectedComponents) {
49
+ const spinner = ora(`Adding ${componentName}...`).start();
50
+ try {
51
+ const registryItem = await fetchRegistry(componentName);
52
+ if (!registryItem) {
53
+ spinner.fail(`Component "${componentName}" not found in registry.`);
54
+ continue;
55
+ }
56
+ if (registryItem.dependencies && registryItem.dependencies.length > 0) {
57
+ spinner.text = `Installing dependencies for ${componentName}...`;
58
+ }
59
+ for (const file of registryItem.files) {
60
+ const targetPath = file.target ? path.resolve(options.cwd, file.target) : path.resolve(
61
+ resolvedConfig.resolvedPaths.components,
62
+ file.path
63
+ );
64
+ if (existsSync(targetPath) && !options.overwrite && !options.yes) {
65
+ spinner.stop();
66
+ const { overwrite } = await prompts({
67
+ type: "confirm",
68
+ name: "overwrite",
69
+ message: `File ${path.basename(targetPath)} already exists. Overwrite?`,
70
+ initial: false
71
+ });
72
+ if (!overwrite) {
73
+ logger.info(`Skipped ${componentName}`);
74
+ continue;
75
+ }
76
+ spinner.start();
77
+ }
78
+ await promises.mkdir(path.dirname(targetPath), { recursive: true });
79
+ await promises.writeFile(targetPath, file.content, "utf-8");
80
+ }
81
+ spinner.succeed(`Added ${componentName}`);
82
+ } catch (error) {
83
+ spinner.fail(`Failed to add ${componentName}`);
84
+ console.error(error);
85
+ }
86
+ }
87
+ logger.break();
88
+ logger.success("Done!");
89
+ } catch (error) {
90
+ logger.error("Failed to add components");
91
+ console.error(error);
92
+ process.exit(1);
93
+ }
94
+ });
95
+ var initOptionsSchema = z.object({
96
+ cwd: z.string(),
97
+ yes: z.boolean()
98
+ });
99
+ var init = new Command().name("init").description("initialize your project and install dependencies").option(
100
+ "-c, --cwd <cwd>",
101
+ "the working directory. defaults to the current directory.",
102
+ process.cwd()
103
+ ).option("-y, --yes", "skip confirmation prompt.", false).action(async (opts) => {
104
+ try {
105
+ const options = initOptionsSchema.parse({
106
+ cwd: path.resolve(opts.cwd),
107
+ ...opts
108
+ });
109
+ logger.info("Initializing shadcn-solid in your project...");
110
+ logger.break();
111
+ const configPath = path.resolve(options.cwd, "components.json");
112
+ if (existsSync(configPath) && !options.yes) {
113
+ const { overwrite } = await prompts({
114
+ type: "confirm",
115
+ name: "overwrite",
116
+ message: "components.json already exists. Would you like to overwrite it?",
117
+ initial: false
118
+ });
119
+ if (!overwrite) {
120
+ logger.info("Initialization cancelled.");
121
+ process.exit(0);
122
+ }
123
+ }
124
+ const answers = options.yes ? {
125
+ style: "default",
126
+ tailwindConfig: "tailwind.config.ts",
127
+ tailwindCss: "src/styles/app.css",
128
+ cssVariables: true,
129
+ componentsPath: "~/components",
130
+ utilsPath: "~/lib/utils"
131
+ } : await prompts([
132
+ {
133
+ type: "select",
134
+ name: "style",
135
+ message: "Which style would you like to use?",
136
+ choices: [
137
+ { title: "Default", value: "default" },
138
+ { title: "New York", value: "new-york" }
139
+ ],
140
+ initial: 0
141
+ },
142
+ {
143
+ type: "text",
144
+ name: "tailwindConfig",
145
+ message: "Where is your tailwind.config located?",
146
+ initial: "tailwind.config.ts"
147
+ },
148
+ {
149
+ type: "text",
150
+ name: "tailwindCss",
151
+ message: "Where is your global CSS file?",
152
+ initial: "src/styles/app.css"
153
+ },
154
+ {
155
+ type: "confirm",
156
+ name: "cssVariables",
157
+ message: "Would you like to use CSS variables for theming?",
158
+ initial: true
159
+ },
160
+ {
161
+ type: "text",
162
+ name: "componentsPath",
163
+ message: "Configure the import alias for components:",
164
+ initial: "~/components"
165
+ },
166
+ {
167
+ type: "text",
168
+ name: "utilsPath",
169
+ message: "Configure the import alias for utils:",
170
+ initial: "~/lib/utils"
171
+ }
172
+ ]);
173
+ if (!options.yes && !answers) {
174
+ logger.info("Initialization cancelled.");
175
+ process.exit(0);
176
+ }
177
+ const config = {
178
+ $schema: "https://shadcn-solid.com/schema.json",
179
+ style: answers.style,
180
+ tailwind: {
181
+ config: answers.tailwindConfig,
182
+ css: answers.tailwindCss,
183
+ cssVariables: answers.cssVariables
184
+ },
185
+ solidjs: {
186
+ componentsPath: answers.componentsPath.replace("~/", "src/"),
187
+ utilsPath: answers.utilsPath.replace("~/", "src/")
188
+ },
189
+ aliases: {
190
+ components: answers.componentsPath,
191
+ utils: answers.utilsPath
192
+ }
193
+ };
194
+ await promises.writeFile(
195
+ configPath,
196
+ JSON.stringify(config, null, 2),
197
+ "utf-8"
198
+ );
199
+ logger.success("Created components.json");
200
+ logger.break();
201
+ logger.info("You can now add components using:");
202
+ logger.info(" npx shadcn-solid add button");
203
+ logger.break();
204
+ } catch (error) {
205
+ logger.error("Failed to initialize project");
206
+ console.error(error);
207
+ process.exit(1);
208
+ }
209
+ });
210
+ var list = new Command().name("list").description("list all available components").action(async () => {
211
+ try {
212
+ logger.info("Fetching available components...");
213
+ logger.break();
214
+ const components = await fetchRegistryIndex();
215
+ if (components.length === 0) {
216
+ logger.warn("No components found in registry.");
217
+ return;
218
+ }
219
+ logger.success(`Found ${components.length} components:
220
+ `);
221
+ components.forEach((component) => {
222
+ console.log(` - ${component}`);
223
+ });
224
+ logger.break();
225
+ logger.info("Add a component using:");
226
+ logger.info(" npx shadcn-solid add <component-name>");
227
+ } catch (error) {
228
+ logger.error("Failed to fetch component list");
229
+ console.error(error);
230
+ process.exit(1);
231
+ }
232
+ });
233
+
234
+ // src/index.ts
235
+ var packageJson = {
236
+ version: "0.1.0"
237
+ };
238
+ process.on("SIGINT", () => process.exit(0));
239
+ process.on("SIGTERM", () => process.exit(0));
240
+ async function main() {
241
+ const program = new Command().name("shadcn-solid").description("Add SolidJS components to your project").version(
242
+ packageJson.version,
243
+ "-v, --version",
244
+ "display the version number"
245
+ );
246
+ program.addCommand(init).addCommand(add).addCommand(list);
247
+ program.parse();
248
+ }
249
+ main();
250
+ //# sourceMappingURL=index.js.map
251
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/add.ts","../src/commands/init.ts","../src/commands/list.ts","../src/index.ts"],"names":["fs","z","Command","path","existsSync","prompts"],"mappings":";;;;;;;;;AAUA,IAAM,gBAAA,GAAmB,EAAE,MAAA,CAAO;AAAA,EAChC,YAAY,CAAA,CAAE,KAAA,CAAM,EAAE,MAAA,EAAQ,EAAE,QAAA,EAAS;AAAA,EACzC,GAAA,EAAK,EAAE,MAAA,EAAO;AAAA,EACd,SAAA,EAAW,EAAE,OAAA,EAAQ;AAAA,EACrB,GAAA,EAAK,EAAE,OAAA;AACT,CAAC,CAAA;AAEM,IAAM,GAAA,GAAM,IAAI,OAAA,EAAQ,CAC5B,IAAA,CAAK,KAAK,CAAA,CACV,WAAA,CAAY,iCAAiC,CAAA,CAC7C,QAAA,CAAS,iBAAA,EAAmB,uBAAuB,CAAA,CACnD,MAAA;AAAA,EACC,iBAAA;AAAA,EACA,2DAAA;AAAA,EACA,QAAQ,GAAA;AACV,CAAA,CACC,MAAA,CAAO,iBAAA,EAAmB,2BAAA,EAA6B,KAAK,CAAA,CAC5D,MAAA,CAAO,WAAA,EAAa,2BAAA,EAA6B,KAAK,CAAA,CACtD,MAAA,CAAO,OAAO,YAAY,IAAA,KAAS;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,iBAAiB,KAAA,CAAM;AAAA,MACrC,UAAA;AAAA,MACA,GAAA,EAAK,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK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;AAAA,EACvD,SAAS,KAAA,EAAO;AACd,IAAA,MAAA,CAAO,MAAM,gCAAgC,CAAA;AAC7C,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AACnB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;;;AC3BH,IAAM,WAAA,GAAc;AAAA,EAElB,OAAA,EAAS;AACX,CAAA;AAEA,OAAA,CAAQ,GAAG,QAAA,EAAU,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AAC1C,OAAA,CAAQ,GAAG,SAAA,EAAW,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AAE3C,eAAe,IAAA,GAAO;AACpB,EAAA,MAAM,OAAA,GAAU,IAAIA,OAAAA,EAAQ,CACzB,KAAK,cAAc,CAAA,CACnB,WAAA,CAAY,wCAAwC,CAAA,CACpD,OAAA;AAAA,IACC,YAAY,OAAW;AAAA,IACvB,eAAA;AAAA,IACA;AAAA,GACF;AAEF,EAAA,OAAA,CACG,WAAW,IAAI,CAAA,CACf,WAAW,GAAG,CAAA,CACd,WAAW,IAAI,CAAA;AAElB,EAAA,OAAA,CAAQ,KAAA,EAAM;AAChB;AAEA,IAAA,EAAK","file":"index.js","sourcesContent":["import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\nimport prompts from \"prompts\"\nimport { z } from \"zod\"\nimport { logger } from \"../utils/logger\"\nimport { getConfig, resolveConfigPaths } from \"../utils/get-config\"\nimport { fetchRegistry } from \"../utils/registry\"\n\nconst addOptionsSchema = z.object({\n components: z.array(z.string()).optional(),\n cwd: z.string(),\n overwrite: z.boolean(),\n yes: z.boolean(),\n})\n\nexport const add = new Command()\n .name(\"add\")\n .description(\"add a component to your project\")\n .argument(\"[components...]\", \"the components to add\")\n .option(\n \"-c, --cwd <cwd>\",\n \"the working directory. defaults to the current directory.\",\n process.cwd()\n )\n .option(\"-o, --overwrite\", \"overwrite existing files.\", false)\n .option(\"-y, --yes\", \"skip confirmation prompt.\", false)\n .action(async (components, opts) => {\n try {\n const options = addOptionsSchema.parse({\n components,\n cwd: path.resolve(opts.cwd),\n ...opts,\n })\n\n // Check if config exists\n const config = await getConfig(options.cwd)\n if (!config) {\n logger.error(\n \"Configuration not found. Please run 'shadcn-solid init' first.\"\n )\n process.exit(1)\n }\n\n const resolvedConfig = await resolveConfigPaths(options.cwd, config)\n\n // If no components specified, prompt user\n let selectedComponents = options.components || []\n if (selectedComponents.length === 0) {\n const { component } = await prompts({\n type: \"text\",\n name: \"component\",\n message: \"Which component would you like to add?\",\n })\n\n if (!component) {\n logger.info(\"No component selected.\")\n process.exit(0)\n }\n\n selectedComponents = [component]\n }\n\n // Fetch and install components\n for (const componentName of selectedComponents) {\n const spinner = ora(`Adding ${componentName}...`).start()\n\n try {\n const registryItem = await fetchRegistry(componentName)\n\n if (!registryItem) {\n spinner.fail(`Component \"${componentName}\" not found in registry.`)\n continue\n }\n\n // Install dependencies\n if (registryItem.dependencies && registryItem.dependencies.length > 0) {\n spinner.text = `Installing dependencies for ${componentName}...`\n // TODO: Install npm dependencies\n }\n\n // Write component files\n for (const file of registryItem.files) {\n // Use target path if available, otherwise use components path + file.path\n const targetPath = file.target\n ? path.resolve(options.cwd, file.target)\n : path.resolve(\n resolvedConfig.resolvedPaths.components,\n file.path\n )\n\n // Check if file exists\n if (existsSync(targetPath) && !options.overwrite && !options.yes) {\n spinner.stop()\n const { overwrite } = await prompts({\n type: \"confirm\",\n name: \"overwrite\",\n message: `File ${path.basename(targetPath)} already exists. Overwrite?`,\n initial: false,\n })\n\n if (!overwrite) {\n logger.info(`Skipped ${componentName}`)\n continue\n }\n spinner.start()\n }\n\n // Create directory if it doesn't exist\n await fs.mkdir(path.dirname(targetPath), { recursive: true })\n\n // Write file\n await fs.writeFile(targetPath, file.content, \"utf-8\")\n }\n\n spinner.succeed(`Added ${componentName}`)\n } catch (error) {\n spinner.fail(`Failed to add ${componentName}`)\n console.error(error)\n }\n }\n\n logger.break()\n logger.success(\"Done!\")\n } catch (error) {\n logger.error(\"Failed to add components\")\n console.error(error)\n process.exit(1)\n }\n })\n","import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { Command } from \"commander\"\nimport prompts from \"prompts\"\nimport { z } from \"zod\"\nimport { logger } from \"../utils/logger\"\nimport { type Config } from \"../utils/get-config\"\n\nconst initOptionsSchema = z.object({\n cwd: z.string(),\n yes: z.boolean(),\n})\n\nexport const init = new Command()\n .name(\"init\")\n .description(\"initialize your project and install dependencies\")\n .option(\n \"-c, --cwd <cwd>\",\n \"the working directory. defaults to the current directory.\",\n process.cwd()\n )\n .option(\"-y, --yes\", \"skip confirmation prompt.\", false)\n .action(async (opts) => {\n try {\n const options = initOptionsSchema.parse({\n cwd: path.resolve(opts.cwd),\n ...opts,\n })\n\n logger.info(\"Initializing shadcn-solid in your project...\")\n logger.break()\n\n // Check if components.json already exists\n const configPath = path.resolve(options.cwd, \"components.json\")\n if (existsSync(configPath) && !options.yes) {\n const { overwrite } = await prompts({\n type: \"confirm\",\n name: \"overwrite\",\n message:\n \"components.json already exists. Would you like to overwrite it?\",\n initial: false,\n })\n\n if (!overwrite) {\n logger.info(\"Initialization cancelled.\")\n process.exit(0)\n }\n }\n\n // Prompt for configuration\n const answers = options.yes\n ? {\n style: \"default\",\n tailwindConfig: \"tailwind.config.ts\",\n tailwindCss: \"src/styles/app.css\",\n cssVariables: true,\n componentsPath: \"~/components\",\n utilsPath: \"~/lib/utils\",\n }\n : await prompts([\n {\n type: \"select\",\n name: \"style\",\n message: \"Which style would you like to use?\",\n choices: [\n { title: \"Default\", value: \"default\" },\n { title: \"New York\", value: \"new-york\" },\n ],\n initial: 0,\n },\n {\n type: \"text\",\n name: \"tailwindConfig\",\n message: \"Where is your tailwind.config located?\",\n initial: \"tailwind.config.ts\",\n },\n {\n type: \"text\",\n name: \"tailwindCss\",\n message: \"Where is your global CSS file?\",\n initial: \"src/styles/app.css\",\n },\n {\n type: \"confirm\",\n name: \"cssVariables\",\n message: \"Would you like to use CSS variables for theming?\",\n initial: true,\n },\n {\n type: \"text\",\n name: \"componentsPath\",\n message: \"Configure the import alias for components:\",\n initial: \"~/components\",\n },\n {\n type: \"text\",\n name: \"utilsPath\",\n message: \"Configure the import alias for utils:\",\n initial: \"~/lib/utils\",\n },\n ])\n\n if (!options.yes && !answers) {\n logger.info(\"Initialization cancelled.\")\n process.exit(0)\n }\n\n // Create config\n const config: Config = {\n $schema: \"https://shadcn-solid.com/schema.json\",\n style: answers.style,\n tailwind: {\n config: answers.tailwindConfig,\n css: answers.tailwindCss,\n cssVariables: answers.cssVariables,\n },\n solidjs: {\n componentsPath: answers.componentsPath.replace(\"~/\", \"src/\"),\n utilsPath: answers.utilsPath.replace(\"~/\", \"src/\"),\n },\n aliases: {\n components: answers.componentsPath,\n utils: answers.utilsPath,\n },\n }\n\n // Write config file\n await fs.writeFile(\n configPath,\n JSON.stringify(config, null, 2),\n \"utf-8\"\n )\n\n logger.success(\"Created components.json\")\n logger.break()\n logger.info(\"You can now add components using:\")\n logger.info(\" npx shadcn-solid add button\")\n logger.break()\n } catch (error) {\n logger.error(\"Failed to initialize project\")\n console.error(error)\n process.exit(1)\n }\n })\n","import { Command } from \"commander\"\nimport { logger } from \"../utils/logger\"\nimport { fetchRegistryIndex } from \"../utils/registry\"\n\nexport const list = new Command()\n .name(\"list\")\n .description(\"list all available components\")\n .action(async () => {\n try {\n logger.info(\"Fetching available components...\")\n logger.break()\n\n const components = await fetchRegistryIndex()\n\n if (components.length === 0) {\n logger.warn(\"No components found in registry.\")\n return\n }\n\n logger.success(`Found ${components.length} components:\\n`)\n \n components.forEach((component) => {\n console.log(` - ${component}`)\n })\n\n logger.break()\n logger.info(\"Add a component using:\")\n logger.info(\" npx shadcn-solid add <component-name>\")\n } catch (error) {\n logger.error(\"Failed to fetch component list\")\n console.error(error)\n process.exit(1)\n }\n })\n","#!/usr/bin/env node\nimport { Command } from \"commander\"\nimport { add } from \"./commands/add\"\nimport { init } from \"./commands/init\"\nimport { list } from \"./commands/list\"\n\nconst packageJson = {\n name: \"shadcn-solid\",\n version: \"0.1.0\",\n}\n\nprocess.on(\"SIGINT\", () => process.exit(0))\nprocess.on(\"SIGTERM\", () => process.exit(0))\n\nasync function main() {\n const program = new Command()\n .name(\"shadcn-solid\")\n .description(\"Add SolidJS components to your project\")\n .version(\n packageJson.version || \"0.1.0\",\n \"-v, --version\",\n \"display the version number\"\n )\n\n program\n .addCommand(init)\n .addCommand(add)\n .addCommand(list)\n\n program.parse()\n}\n\nmain()\n"]}
@@ -0,0 +1,179 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const logger: {
4
+ error(message: string): void;
5
+ warn(message: string): void;
6
+ info(message: string): void;
7
+ success(message: string): void;
8
+ break(): void;
9
+ };
10
+
11
+ declare const configSchema: z.ZodObject<{
12
+ $schema: z.ZodOptional<z.ZodString>;
13
+ style: z.ZodDefault<z.ZodString>;
14
+ tailwind: z.ZodObject<{
15
+ config: z.ZodString;
16
+ css: z.ZodString;
17
+ baseColor: z.ZodOptional<z.ZodString>;
18
+ cssVariables: z.ZodDefault<z.ZodBoolean>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ config: string;
21
+ css: string;
22
+ cssVariables: boolean;
23
+ baseColor?: string | undefined;
24
+ }, {
25
+ config: string;
26
+ css: string;
27
+ baseColor?: string | undefined;
28
+ cssVariables?: boolean | undefined;
29
+ }>;
30
+ solidjs: z.ZodObject<{
31
+ componentsPath: z.ZodString;
32
+ utilsPath: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ componentsPath: string;
35
+ utilsPath: string;
36
+ }, {
37
+ componentsPath: string;
38
+ utilsPath: string;
39
+ }>;
40
+ aliases: z.ZodObject<{
41
+ components: z.ZodString;
42
+ utils: z.ZodString;
43
+ }, "strip", z.ZodTypeAny, {
44
+ components: string;
45
+ utils: string;
46
+ }, {
47
+ components: string;
48
+ utils: string;
49
+ }>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ style: string;
52
+ tailwind: {
53
+ config: string;
54
+ css: string;
55
+ cssVariables: boolean;
56
+ baseColor?: string | undefined;
57
+ };
58
+ solidjs: {
59
+ componentsPath: string;
60
+ utilsPath: string;
61
+ };
62
+ aliases: {
63
+ components: string;
64
+ utils: string;
65
+ };
66
+ $schema?: string | undefined;
67
+ }, {
68
+ tailwind: {
69
+ config: string;
70
+ css: string;
71
+ baseColor?: string | undefined;
72
+ cssVariables?: boolean | undefined;
73
+ };
74
+ solidjs: {
75
+ componentsPath: string;
76
+ utilsPath: string;
77
+ };
78
+ aliases: {
79
+ components: string;
80
+ utils: string;
81
+ };
82
+ $schema?: string | undefined;
83
+ style?: string | undefined;
84
+ }>;
85
+ type Config = z.infer<typeof configSchema>;
86
+ declare function getConfig(cwd: string): Promise<Config | null>;
87
+ declare function resolveConfigPaths(cwd: string, config: Config): Promise<{
88
+ resolvedPaths: {
89
+ tailwindConfig: string;
90
+ tailwindCss: string;
91
+ components: string;
92
+ utils: string;
93
+ };
94
+ style: string;
95
+ tailwind: {
96
+ config: string;
97
+ css: string;
98
+ cssVariables: boolean;
99
+ baseColor?: string | undefined;
100
+ };
101
+ solidjs: {
102
+ componentsPath: string;
103
+ utilsPath: string;
104
+ };
105
+ aliases: {
106
+ components: string;
107
+ utils: string;
108
+ };
109
+ $schema?: string | undefined;
110
+ }>;
111
+
112
+ declare const registryItemFileSchema: z.ZodObject<{
113
+ path: z.ZodString;
114
+ content: z.ZodString;
115
+ type: z.ZodEnum<["registry:ui", "registry:lib", "registry:hook"]>;
116
+ target: z.ZodOptional<z.ZodString>;
117
+ }, "strip", z.ZodTypeAny, {
118
+ path: string;
119
+ type: "registry:ui" | "registry:lib" | "registry:hook";
120
+ content: string;
121
+ target?: string | undefined;
122
+ }, {
123
+ path: string;
124
+ type: "registry:ui" | "registry:lib" | "registry:hook";
125
+ content: string;
126
+ target?: string | undefined;
127
+ }>;
128
+ declare const registryItemSchema: z.ZodObject<{
129
+ name: z.ZodString;
130
+ type: z.ZodEnum<["registry:ui", "registry:lib", "registry:hook"]>;
131
+ files: z.ZodArray<z.ZodObject<{
132
+ path: z.ZodString;
133
+ content: z.ZodString;
134
+ type: z.ZodEnum<["registry:ui", "registry:lib", "registry:hook"]>;
135
+ target: z.ZodOptional<z.ZodString>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ path: string;
138
+ type: "registry:ui" | "registry:lib" | "registry:hook";
139
+ content: string;
140
+ target?: string | undefined;
141
+ }, {
142
+ path: string;
143
+ type: "registry:ui" | "registry:lib" | "registry:hook";
144
+ content: string;
145
+ target?: string | undefined;
146
+ }>, "many">;
147
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
148
+ devDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
149
+ registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ type: "registry:ui" | "registry:lib" | "registry:hook";
152
+ name: string;
153
+ files: {
154
+ path: string;
155
+ type: "registry:ui" | "registry:lib" | "registry:hook";
156
+ content: string;
157
+ target?: string | undefined;
158
+ }[];
159
+ dependencies?: string[] | undefined;
160
+ devDependencies?: string[] | undefined;
161
+ registryDependencies?: string[] | undefined;
162
+ }, {
163
+ type: "registry:ui" | "registry:lib" | "registry:hook";
164
+ name: string;
165
+ files: {
166
+ path: string;
167
+ type: "registry:ui" | "registry:lib" | "registry:hook";
168
+ content: string;
169
+ target?: string | undefined;
170
+ }[];
171
+ dependencies?: string[] | undefined;
172
+ devDependencies?: string[] | undefined;
173
+ registryDependencies?: string[] | undefined;
174
+ }>;
175
+ type RegistryItem = z.infer<typeof registryItemSchema>;
176
+ declare function fetchRegistry(name: string): Promise<RegistryItem | null>;
177
+ declare function fetchRegistryIndex(): Promise<string[]>;
178
+
179
+ export { type Config, type RegistryItem, configSchema, fetchRegistry, fetchRegistryIndex, getConfig, logger, registryItemFileSchema, registryItemSchema, resolveConfigPaths };
@@ -0,0 +1,3 @@
1
+ export { configSchema, fetchRegistry, fetchRegistryIndex, getConfig, logger, registryItemFileSchema, registryItemSchema, resolveConfigPaths } from '../chunk-5YAIISX4.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "shadcn-solid-js",
3
+ "version": "0.1.0",
4
+ "description": "Add SolidJS components to your apps.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "license": "MIT",
9
+ "author": {
10
+ "name": "shadcn-solid-js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/ljho01/shadcn-solid-js.git",
15
+ "directory": "packages/cli"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "components",
22
+ "ui",
23
+ "solidjs",
24
+ "solid",
25
+ "tailwind",
26
+ "radix-ui",
27
+ "shadcn"
28
+ ],
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./utils": {
36
+ "types": "./dist/utils/index.d.ts",
37
+ "default": "./dist/utils/index.js"
38
+ }
39
+ },
40
+ "bin": "./dist/index.js",
41
+ "scripts": {
42
+ "dev": "tsup --watch",
43
+ "build": "tsup",
44
+ "typecheck": "tsc --noEmit",
45
+ "clean": "rm -rf dist",
46
+ "test": "vitest run"
47
+ },
48
+ "dependencies": {
49
+ "commander": "^14.0.0",
50
+ "cosmiconfig": "^9.0.0",
51
+ "execa": "^9.6.0",
52
+ "fast-glob": "^3.3.3",
53
+ "fs-extra": "^11.3.1",
54
+ "kleur": "^4.1.5",
55
+ "node-fetch": "^3.3.2",
56
+ "ora": "^8.2.0",
57
+ "prompts": "^2.4.2",
58
+ "zod": "^3.24.1"
59
+ },
60
+ "devDependencies": {
61
+ "@types/fs-extra": "^11.0.4",
62
+ "@types/prompts": "^2.4.9",
63
+ "tsup": "^8.5.0",
64
+ "typescript": "^5.9.2"
65
+ }
66
+ }