solidui-cli 0.1.3 → 0.1.4

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,43 @@
1
+ # solid-ui
2
+
3
+ A CLI for adding components to your project.
4
+
5
+ ## Usage
6
+
7
+ Use the `init` command to initialize dependencies for a new project.
8
+
9
+ The `init` command installs dependencies, adds the `cn` util, configures `tailwind.config.cjs`, and sets up CSS variables for the project.
10
+
11
+ ```bash
12
+ npx solidui-cli@latest init
13
+ ```
14
+
15
+ ## add
16
+
17
+ Use the `add` command to add components to your project.
18
+
19
+ The `add` command adds a component to your project and installs all required dependencies.
20
+
21
+ ```bash
22
+ npx solidui-cli@latest add [component]
23
+ ```
24
+
25
+ ### Example
26
+
27
+ ```bash
28
+ npx solidui-cli@latest add alert-dialog
29
+ ```
30
+
31
+ You can also run the command without any arguments to view a list of all available components:
32
+
33
+ ```bash
34
+ npx solidui-cli@latest add
35
+ ```
36
+
37
+ ## Documentation
38
+
39
+ Visit https://solid-ui.com to view the documentation.
40
+
41
+ ## License
42
+
43
+ Licensed under the [MIT license](https://github.com/sek-consulting/solid-ui/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,27 +1,38 @@
1
1
  {
2
2
  "name": "solidui-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Add Solid UI Components to your application using the Solid-UI CLI tool",
5
- "main": "dist/index.mjs",
6
- "bin": {
7
- "suc": "./dist/index.mjs"
5
+ "publishConfig": {
6
+ "access": "public"
8
7
  },
9
- "devDependencies": {
10
- "@types/node": "^18.14.0",
11
- "@types/prompts": "^2.4.5",
12
- "tsup": "^7.2.0",
13
- "typescript": "^5.1.6"
8
+ "license": "MIT",
9
+ "author": {
10
+ "name": "Stefan E-K & Michael Essiet",
11
+ "url": "https://twitter.com/stefan_e_k"
14
12
  },
15
13
  "repository": {
16
14
  "type": "git",
17
- "url": "git+https://github.com/sek-consulting/solid-ui.git"
15
+ "url": "https://github.com/sek-consulting/solid-ui.git",
16
+ "directory": "packages/cli"
18
17
  },
19
- "author": "Stefan E-K & Michael Essiet",
20
- "license": "MIT",
21
18
  "bugs": {
22
19
  "url": "https://github.com/sek-consulting/solid-ui/issues"
23
20
  },
24
- "homepage": "https://github.com/sek-consulting/solid-ui#readme",
21
+ "type": "module",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "exports": "./dist/index.js",
26
+ "bin": "./dist/index.js",
27
+ "keywords": [
28
+ "components",
29
+ "ui",
30
+ "tailwind",
31
+ "kobalte",
32
+ "solid",
33
+ "solidjs",
34
+ "shadcn"
35
+ ],
25
36
  "dependencies": {
26
37
  "@babel/core": "^7.22.20",
27
38
  "@babel/parser": "^7.22.16",
@@ -36,8 +47,13 @@
36
47
  "recast": "^0.23.4",
37
48
  "ts-morph": "^20.0.0"
38
49
  },
50
+ "devDependencies": {
51
+ "@types/node": "^18.14.0",
52
+ "@types/prompts": "^2.4.5",
53
+ "tsup": "^7.2.0",
54
+ "typescript": "^5.1.6"
55
+ },
39
56
  "scripts": {
40
- "test": "echo \"Error: no test specified\" && exit 1",
41
57
  "build": "tsup",
42
58
  "release": "changeset version",
43
59
  "pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
@@ -1,13 +0,0 @@
1
-
2
- > solidui-cli@0.1.3 build /home/runner/work/solid-ui/solid-ui/packages/cli
3
- > tsup
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.2.0
8
- CLI Using tsup config: /home/runner/work/solid-ui/solid-ui/packages/cli/tsup.config.json
9
- CLI Target: esnext
10
- CLI Cleaning output folder
11
- ESM Build start
12
- ESM dist/index.mjs 22.54 KB
13
- ESM ⚡️ Build success in 45ms
package/CHANGELOG.md DELETED
@@ -1,28 +0,0 @@
1
- # @solid-ui/cli
2
-
3
- ## 0.1.3
4
-
5
- ### Patch Changes
6
-
7
- - [`cdb3cb1`](https://github.com/sek-consulting/solid-ui/commit/cdb3cb12116790a170b64186432340d91821157e) Thanks [@sek-consulting](https://github.com/sek-consulting)! - fix: fixing release workflow
8
-
9
- ## 0.1.2
10
-
11
- ### Patch Changes
12
-
13
- - [#26](https://github.com/sek-consulting/solid-ui/pull/26) [`c283e78`](https://github.com/sek-consulting/solid-ui/commit/c283e78feeba71a3cfcd3dac0464bd66ad8d6c29) Thanks [@sek-consulting](https://github.com/sek-consulting)! - Changes:
14
-
15
- - add examples to docs frontpage
16
- - add npmjs publishing to workflow
17
-
18
- ## 0.1.1
19
-
20
- ### Patch Changes
21
-
22
- - [`27f2321`](https://github.com/sek-consulting/solid-ui/commit/27f23214bf912ab4ea828a04298503643094f6c6) Thanks [@sek-consulting](https://github.com/sek-consulting)! - changed changeset PR title
23
-
24
- ## 0.1.0
25
-
26
- ### Minor Changes
27
-
28
- - [#19](https://github.com/sek-consulting/solid-ui-components/pull/19) [`7e69fac`](https://github.com/sek-consulting/solid-ui-components/commit/7e69fac95dc6e3e90ca8f0271ae9a2c5751df0de) Thanks [@sek-consulting](https://github.com/sek-consulting)! - initial release
@@ -1,110 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
2
- import path from "path"
3
- import { cwd } from "process"
4
-
5
- import { log, spinner } from "@clack/prompts"
6
- import chalk from "chalk"
7
- import prompts from "prompts"
8
- import { parse } from "valibot"
9
-
10
- import { registryIndexUrl, registryUIUrl } from "~/lib/constants"
11
- import { transformImports } from "~/lib/transformImports"
12
- import { transpileTS } from "~/lib/transpileTS"
13
- import {
14
- configSchema,
15
- type RegistryComponentResponse,
16
- type RegistryComponentsList
17
- } from "~/lib/types"
18
- import { installPackages, removeExtension } from "~/lib/utils"
19
-
20
- async function getComponent(componentName: string): Promise<RegistryComponentResponse> {
21
- const componentUri = `${registryUIUrl}/${componentName}.json`
22
- const res = await (await fetch(componentUri)).json()
23
-
24
- return res
25
- }
26
-
27
- async function componentSelectionPrompt() {
28
- try {
29
- const componentList: RegistryComponentsList = await (await fetch(registryIndexUrl)).json()
30
-
31
- const selectedComponents = await prompts({
32
- name: "Selected Components",
33
- type: "multiselect",
34
- message: "Which components would you like to add?",
35
- choices: componentList.map((component) => ({ title: component.name, value: component.name }))
36
- })
37
-
38
- await add(selectedComponents["Selected Components"])
39
- } catch (error) {
40
- log.info(`Error: ${error}`)
41
- log.error("Command terminated.")
42
- process.exit(1)
43
- }
44
- }
45
-
46
- export async function add(componentNames: string[]) {
47
- if (componentNames.length === 0) await componentSelectionPrompt()
48
-
49
- const activityIndicator = spinner()
50
- activityIndicator.start("Creating components...")
51
-
52
- try {
53
- const readSUCConfig = readFileSync(path.resolve(cwd(), "suc.config.json"))
54
- const sucConfig = parse(configSchema, JSON.parse(readSUCConfig.toString()))
55
- const isTypescriptEnabled = sucConfig.tsx
56
- const componentFolderDir = path.resolve(cwd(), sucConfig.componentDir)
57
- const dirExists = existsSync(componentFolderDir)
58
-
59
- if (!dirExists) mkdirSync(componentFolderDir, { recursive: true })
60
-
61
- const components = await Promise.all(
62
- componentNames.map(async (name) => await getComponent(name))
63
- )
64
-
65
- try {
66
- for (const component of components) {
67
- log.message(`Adding ${component.name} component`)
68
-
69
- if (component.dependencies?.length > 0) {
70
- log.step(`Installing ${component.name} component dependencies`)
71
- await installPackages(...component.dependencies)
72
- }
73
-
74
- if (component.registryDependencies?.length > 0) {
75
- log.step("Installing any other required components")
76
- await add(component.registryDependencies)
77
- }
78
-
79
- for (const file of component.files) {
80
- log.step(`Creating ${file.name}`)
81
-
82
- const content = transformImports(file.content, sucConfig)
83
-
84
- if (isTypescriptEnabled) {
85
- writeFileSync(componentFolderDir + "/" + `${file.name}`, content)
86
- } else {
87
- writeFileSync(
88
- componentFolderDir + "/" + `${removeExtension(file.name)}.jsx`,
89
- transpileTS(content)
90
- )
91
- }
92
- }
93
- }
94
- } catch (error) {
95
- log.error(`Something went wrong: ${error}`)
96
- process.exit(1)
97
- }
98
-
99
- activityIndicator.stop("Successfully created components! 🎉")
100
- return
101
- } catch (error) {
102
- activityIndicator.stop()
103
- log.error(
104
- `Something went wrong while creating your components. Have you ran ${chalk.green(
105
- "@solid-ui/cli init"
106
- )}?`
107
- )
108
- process.exit(1)
109
- }
110
- }
@@ -1,166 +0,0 @@
1
- import { existsSync, mkdirSync, writeFile, writeFileSync } from "fs"
2
- import { cwd } from "process"
3
-
4
- import { text, confirm, log, spinner, select } from "@clack/prompts"
5
- import { parse } from "valibot"
6
-
7
- import { PROJECT_DEPS, ROOT_CSS, TAILWIND_CONFIG, TAILWIND_PRESET, UTILS } from "~/lib/constants"
8
- import { configSchema, type Config } from "~/lib/types"
9
- import { readJsonFile, runCommand } from "~/lib/utils"
10
-
11
- export default async function init() {
12
- const isTypescript = await confirm({
13
- message: "Would you like to use TypeScript? (recommended)",
14
- initialValue: true
15
- })
16
- const globalCssDir = await text({
17
- message: "Where is your global CSS file?",
18
- initialValue: "src/root.css"
19
- })
20
- const tailwindConfigDir = await text({
21
- message: "Where is your tailwind.config.js located?",
22
- initialValue: "tailwind.config.cjs"
23
- })
24
- const pathAlias = await text({
25
- message: "Configure the import alias for the src directory:",
26
- initialValue: "~/*"
27
- })
28
-
29
- const config = parse(configSchema, {
30
- tsx: isTypescript,
31
- componentDir: "./src/components/ui",
32
- tailwind: {
33
- config: tailwindConfigDir,
34
- css: globalCssDir
35
- },
36
- aliases: {
37
- path: pathAlias
38
- }
39
- })
40
-
41
- saveConfig(config)
42
- writeTsconfig(config.aliases.path)
43
- writeUtils()
44
- await writeSUCPreset()
45
- await writeTailwindConfig(config.tailwind.config)
46
- await writeCSS(config.tailwind.css)
47
-
48
- log.success("Project configuration completed.")
49
-
50
- await installDeps()
51
-
52
- log.success(
53
- "Success! Try 'npx @solid-ui/cli add button' to add a button component to your project"
54
- )
55
- process.exit(0)
56
- }
57
-
58
- function writeUtils() {
59
- const doesLibPathExist = existsSync(cwd() + "/src/lib")
60
-
61
- const indicator = spinner()
62
- indicator.start("Creating utils.ts file...")
63
-
64
- if (!doesLibPathExist) mkdirSync(cwd() + "/src/lib")
65
-
66
- writeFileSync(cwd() + "/src/lib/utils.ts", UTILS)
67
- indicator.stop("Done creating utils.ts file!")
68
- }
69
-
70
- async function writeCSS(cssPath: string) {
71
- const indicator = spinner()
72
-
73
- indicator.start("Writing CSS styles...")
74
-
75
- writeFile(
76
- cssPath,
77
- ROOT_CSS,
78
- (error) => error && log.error(error.message || "Something went wrong")
79
- )
80
-
81
- indicator.stop("Done Writing CSS styles!")
82
- }
83
-
84
- async function installDeps() {
85
- const shouldInstallDeps = await confirm({
86
- message: "Would you like to install the required dependencies? (recommended)",
87
- initialValue: true
88
- })
89
-
90
- if (shouldInstallDeps) {
91
- const packageManager = await select({
92
- message: "Which package manager would you like to use?",
93
- options: [
94
- { label: "npm", value: "npm" },
95
- { label: "yarn", value: "yarn" },
96
- { label: "pnpm", value: "pnpm" },
97
- { label: "bun", value: "bun" }
98
- ],
99
- initialValue: "npm"
100
- })
101
-
102
- runCommand(
103
- `${packageManager as string} install ${PROJECT_DEPS.join(" ")}`,
104
- "Installing Solid UI Component dependencies",
105
- "Dependencies installed"
106
- )
107
- }
108
- }
109
-
110
- function saveConfig(config: Config) {
111
- const indicator = spinner()
112
- indicator.start("Writing suc.config.json...")
113
-
114
- writeFile("suc.config.json", JSON.stringify(config, null, 2), (error) => {
115
- if (error) log.error("There was an error while saving your preferences")
116
- })
117
- indicator.stop("suc.config.json successfully created!")
118
- }
119
-
120
- async function writeSUCPreset() {
121
- const indicator = spinner()
122
- indicator.start("Writing Solid UI Components tailwind preset...")
123
-
124
- try {
125
- writeFile("suc.preset.js", TAILWIND_PRESET, (error) => {
126
- if (error) log.error(`There was an error while writing the sui.preset.js: ${error}`)
127
- })
128
- } catch (error) {
129
- log.error(`Sorry, something went wrong while getting the tailwind presets: ${error}`)
130
- }
131
-
132
- indicator.stop("suc.preset.js successfully created!")
133
- }
134
-
135
- async function writeTailwindConfig(tailwindConfigDir: string) {
136
- const indicator = spinner()
137
- indicator.start("Configuring tailwind.config.cjs to support Solid UI Components...")
138
-
139
- writeFile(tailwindConfigDir, TAILWIND_CONFIG, (error) => {
140
- if (error) log.error(`Something went wrong while writing your tailwind.config.cjs: ${error}`)
141
- })
142
-
143
- indicator.stop("Done done configuring your tailwind.config.cjs")
144
- }
145
-
146
- function writeTsconfig(alias: string) {
147
- const indicator = spinner()
148
- indicator.start("Configuring your tsconfig.json")
149
-
150
- readJsonFile(process.cwd() + "/tsconfig.json", (error, data) => {
151
- if (error) log.error("Something went wrong while configuring your tsconfig.json")
152
-
153
- const tsconfigData = data as Record<string, { paths: Record<string, unknown> }>
154
-
155
- if (!tsconfigData.compilerOptions.paths) {
156
- tsconfigData.compilerOptions.paths = {}
157
- }
158
- tsconfigData.compilerOptions.paths[alias] = ["./src/*"]
159
-
160
- writeFile("tsconfig.json", JSON.stringify(tsconfigData, null, 2), (error) => {
161
- if (error) log.error(`Something went wrong while configuring your tsconfig.json: ${error}`)
162
- })
163
- })
164
-
165
- indicator.stop("Done configuring your tsconfig.json")
166
- }
package/src/index.ts DELETED
@@ -1,23 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import { Command } from "commander"
4
-
5
- import {add} from "./commands/add"
6
- import init from "./commands/init"
7
-
8
- const program = new Command()
9
-
10
- program.name("suc").description("A CLI used for the Solid UI components library").version("0.1")
11
-
12
- program
13
- .command("init")
14
- .description("Initialize and install the necessary things to make use of Solid UI Components")
15
- .action(async () => await init())
16
-
17
- program
18
- .command("add")
19
- .argument("[components...]", "Components to be added to your project")
20
- .description("Add a component to your project")
21
- .action(async (component: string[]) => await add(component))
22
-
23
- program.parse()
@@ -1,236 +0,0 @@
1
- export const PROJECT_DEPS = [
2
- "tailwindcss-animate",
3
- "class-variance-authority",
4
- "clsx",
5
- "tailwind-merge",
6
- "@kobalte/core",
7
- "tailwindcss"
8
- ]
9
-
10
- export const registryUrl = "https://solid-ui-components.vercel.app/registry"
11
- export const registryUIUrl = "https://solid-ui-components.vercel.app/registry/ui"
12
- export const registryIndexUrl = "https://solid-ui-components.vercel.app/registry/index.json"
13
-
14
- export const UTILS = `import type { ClassValue } from "clsx"
15
- import { clsx } from "clsx"
16
- import { twMerge } from "tailwind-merge"
17
-
18
- export function cn(...inputs: ClassValue[]) {
19
- return twMerge(clsx(inputs))
20
- }`
21
-
22
- export const ROOT_CSS = `@tailwind base;
23
- @tailwind components;
24
- @tailwind utilities;
25
-
26
- @layer base {
27
- :root {
28
- --background: 0 0% 100%;
29
- --foreground: 240 10% 3.9%;
30
-
31
- --muted: 240 4.8% 95.9%;
32
- --muted-foreground: 240 3.8% 46.1%;
33
-
34
- --popover: 0 0% 100%;
35
- --popover-foreground: 240 10% 3.9%;
36
-
37
- --border: 240 5.9% 90%;
38
- --input: 240 5.9% 90%;
39
-
40
- --card: 0 0% 100%;
41
- --card-foreground: 240 10% 3.9%;
42
-
43
- --primary: 240 5.9% 10%;
44
- --primary-foreground: 0 0% 98%;
45
-
46
- --secondary: 240 4.8% 95.9%;
47
- --secondary-foreground: 240 5.9% 10%;
48
-
49
- --accent: 240 4.8% 95.9%;
50
- --accent-foreground: 240 5.9% 10%;
51
-
52
- --destructive: 0 84.2% 60.2%;
53
- --destructive-foreground: 0 0% 98%;
54
-
55
- --info: 204 94% 94%;
56
- --info-foreground: 199 89% 48%;
57
-
58
- --success: 149 80% 90%;
59
- --success-foreground: 160 84% 39%;
60
-
61
- --warning: 48 96% 89%;
62
- --warning-foreground: 25 95% 53%;
63
-
64
- --error: 0 93% 94%;
65
- --error-foreground: 0 84% 60%;
66
-
67
- --ring: 240 5.9% 10%;
68
-
69
- --radius: 0.5rem;
70
- }
71
-
72
- [data-kb-theme="dark"] {
73
- --background: 240 10% 3.9%;
74
- --foreground: 0 0% 98%;
75
-
76
- --muted: 240 3.7% 15.9%;
77
- --muted-foreground: 240 5% 64.9%;
78
-
79
- --accent: 240 3.7% 15.9%;
80
- --accent-foreground: 0 0% 98%;
81
-
82
- --popover: 240 10% 3.9%;
83
- --popover-foreground: 0 0% 98%;
84
-
85
- --border: 240 3.7% 15.9%;
86
- --input: 240 3.7% 15.9%;
87
-
88
- --card: 240 10% 3.9%;
89
- --card-foreground: 0 0% 98%;
90
-
91
- --primary: 0 0% 98%;
92
- --primary-foreground: 240 5.9% 10%;
93
-
94
- --secondary: 240 3.7% 15.9%;
95
- --secondary-foreground: 0 0% 98%;
96
-
97
- --destructive: 0 62.8% 30.6%;
98
- --destructive-foreground: 0 0% 98%;
99
-
100
- --info: 204 94% 94%;
101
- --info-foreground: 199 89% 48%;
102
-
103
- --success: 149 80% 90%;
104
- --success-foreground: 160 84% 39%;
105
-
106
- --warning: 48 96% 89%;
107
- --warning-foreground: 25 95% 53%;
108
-
109
- --error: 0 93% 94%;
110
- --error-foreground: 0 84% 60%;
111
-
112
- --ring: 240 4.9% 83.9%;
113
-
114
- --radius: 0.5rem;
115
- }
116
- }
117
-
118
- @layer base {
119
- * {
120
- @apply border-border;
121
- }
122
- body {
123
- @apply bg-background text-foreground;
124
- font-feature-settings:
125
- "rlig" 1,
126
- "calt" 1;
127
- }
128
- }
129
-
130
- @media (max-width: 640px) {
131
- .container {
132
- @apply px-4;
133
- }
134
- }`
135
-
136
- export const TAILWIND_PRESET = `const {fontFamily} = require("tailwindcss/defaultTheme")
137
-
138
- /**@type {import("tailwindcss").Config} */
139
- module.exports = {
140
- darkMode: ["class", '[data-kb-theme="dark"]'],
141
- content: ["./src/**/*.{js,jsx,md,mdx,ts,tsx}"],
142
- theme: {
143
- container: {
144
- center: true,
145
- padding: "2rem",
146
- screens: {
147
- "2xl": "1400px"
148
- }
149
- },
150
- extend: {
151
- colors: {
152
- border: "hsl(var(--border))",
153
- input: "hsl(var(--input))",
154
- ring: "hsl(var(--ring))",
155
- background: "hsl(var(--background))",
156
- foreground: "hsl(var(--foreground))",
157
- primary: {
158
- DEFAULT: "hsl(var(--primary))",
159
- foreground: "hsl(var(--primary-foreground))"
160
- },
161
- secondary: {
162
- DEFAULT: "hsl(var(--secondary))",
163
- foreground: "hsl(var(--secondary-foreground))"
164
- },
165
- destructive: {
166
- DEFAULT: "hsl(var(--destructive))",
167
- foreground: "hsl(var(--destructive-foreground))"
168
- },
169
- info: {
170
- DEFAULT: "hsl(var(--info))",
171
- foreground: "hsl(var(--info-foreground))"
172
- },
173
- success: {
174
- DEFAULT: "hsl(var(--success))",
175
- foreground: "hsl(var(--success-foreground))"
176
- },
177
- warning: {
178
- DEFAULT: "hsl(var(--warning))",
179
- foreground: "hsl(var(--warning-foreground))"
180
- },
181
- error: {
182
- DEFAULT: "hsl(var(--error))",
183
- foreground: "hsl(var(--error-foreground))"
184
- },
185
- muted: {
186
- DEFAULT: "hsl(var(--muted))",
187
- foreground: "hsl(var(--muted-foreground))"
188
- },
189
- accent: {
190
- DEFAULT: "hsl(var(--accent))",
191
- foreground: "hsl(var(--accent-foreground))"
192
- },
193
- popover: {
194
- DEFAULT: "hsl(var(--popover))",
195
- foreground: "hsl(var(--popover-foreground))"
196
- },
197
- card: {
198
- DEFAULT: "hsl(var(--card))",
199
- foreground: "hsl(var(--card-foreground))"
200
- }
201
- },
202
- borderRadius: {
203
- lg: "var(--radius)",
204
- md: "calc(var(--radius) - 2px)",
205
- sm: "calc(var(--radius) - 4px)"
206
- },
207
- fontFamily: {
208
- sans: ["Inter", ...fontFamily.sans]
209
- },
210
- keyframes: {
211
- "accordion-down": {
212
- from: { height: 0 },
213
- to: { height: "var(--kb-accordion-content-height)" }
214
- },
215
- "accordion-up": {
216
- from: { height: "var(--kb-accordion-content-height)" },
217
- to: { height: 0 }
218
- }
219
- },
220
- animation: {
221
- "accordion-down": "accordion-down 0.2s ease-out",
222
- "accordion-up": "accordion-up 0.2s ease-out"
223
- }
224
- }
225
- },
226
- plugins: [require("tailwindcss-animate")]
227
- }`
228
-
229
- export const TAILWIND_CONFIG = `/** @type {import('tailwindcss').Config} */
230
- export default {
231
- darkMode: ["class"],
232
- content: [
233
- "./src/**/*.{html,js,jsx,md,mdx,ts,tsx}"
234
- ],
235
- presets: [require("./suc.preset.js")]
236
- }`
@@ -1,8 +0,0 @@
1
- import type { Config } from "./types"
2
-
3
- export function transformImports(source: string, config: Config) {
4
- const pathAlias = config.aliases.path.replace("/*", "")
5
- return source
6
- .replaceAll(/~\/registry\/ui/g, `${pathAlias}/components/ui`)
7
- .replaceAll(/~\/lib\/utils/g, `${pathAlias}/lib/utils`)
8
- }
@@ -1,85 +0,0 @@
1
- import { transformFromAstSync } from "@babel/core"
2
- import { type ParserOptions, parse } from "@babel/parser"
3
- // @ts-ignore
4
- import transformTypescript from "@babel/plugin-transform-typescript"
5
- import * as recast from "recast"
6
-
7
- // TODO.
8
- // I'm using recast for the AST here.
9
- // Figure out if ts-morph AST is compatible with Babel.
10
-
11
- // This is a copy of the babel options from recast/parser.
12
- // The goal here is to tolerate as much syntax as possible.
13
- // We want to be able to parse any valid tsx code.
14
- // See https://github.com/benjamn/recast/blob/master/parsers/_babel_options.ts.
15
- const PARSE_OPTIONS: ParserOptions = {
16
- sourceType: "module",
17
- allowImportExportEverywhere: true,
18
- allowReturnOutsideFunction: true,
19
- startLine: 1,
20
- tokens: true,
21
- plugins: [
22
- "asyncGenerators",
23
- "bigInt",
24
- "classPrivateMethods",
25
- "classPrivateProperties",
26
- "classProperties",
27
- "classStaticBlock",
28
- "decimal",
29
- "decorators-legacy",
30
- "doExpressions",
31
- "dynamicImport",
32
- "exportDefaultFrom",
33
- "exportNamespaceFrom",
34
- "functionBind",
35
- "functionSent",
36
- "importAssertions",
37
- "importMeta",
38
- "nullishCoalescingOperator",
39
- "numericSeparator",
40
- "objectRestSpread",
41
- "optionalCatchBinding",
42
- "optionalChaining",
43
- [
44
- "pipelineOperator",
45
- {
46
- proposal: "minimal"
47
- }
48
- ],
49
- [
50
- "recordAndTuple",
51
- {
52
- syntaxType: "hash"
53
- }
54
- ],
55
- "throwExpressions",
56
- "topLevelAwait",
57
- "v8intrinsic",
58
- "typescript",
59
- "jsx"
60
- ]
61
- }
62
-
63
- export const transpileTS = (source: string) => {
64
- const ast = recast.parse(source, {
65
- parser: {
66
- parse: (code: string) => {
67
- return parse(code, PARSE_OPTIONS)
68
- }
69
- }
70
- })
71
-
72
- const result = transformFromAstSync(ast, source, {
73
- cloneInputAst: false,
74
- code: false,
75
- ast: true,
76
- plugins: [transformTypescript],
77
- configFile: false
78
- })
79
-
80
- if (!result || !result.ast) {
81
- throw new Error("Failed to transform JSX")
82
- }
83
-
84
- return recast.print(result.ast).code
85
- }
package/src/lib/types.ts DELETED
@@ -1,40 +0,0 @@
1
- import type { Output } from "valibot"
2
- import { boolean, object, string } from "valibot"
3
-
4
- export enum CommandTypes {
5
- "init",
6
- "add"
7
- }
8
-
9
- export interface ComponentFile {
10
- name: string
11
- content: string
12
- }
13
-
14
- export interface RegistryComponentResponse {
15
- name: string
16
- dependencies: string[]
17
- registryDependencies: string[]
18
- files: ComponentFile[]
19
- type: string
20
- }
21
-
22
- export type RegistryComponentsList = {
23
- name: string
24
- files: string[]
25
- dependencies: string[]
26
- type: string
27
- }[]
28
-
29
- export const configSchema = object({
30
- tsx: boolean(),
31
- componentDir: string(),
32
- tailwind: object({
33
- config: string(),
34
- css: string()
35
- }),
36
- aliases: object({
37
- path: string()
38
- })
39
- })
40
- export type Config = Output<typeof configSchema>
package/src/lib/utils.ts DELETED
@@ -1,56 +0,0 @@
1
- import { execSync } from "child_process"
2
- import { readFile } from "fs"
3
-
4
- import { log, spinner } from "@clack/prompts"
5
- import { detect } from "detect-package-manager"
6
-
7
- export function readJsonFile(
8
- filePath: string,
9
- callback: (error: Error | null, data: unknown | null) => void
10
- ): void {
11
- readFile(filePath, "utf8", (err, data) => {
12
- if (err) {
13
- callback(err, null)
14
- return
15
- }
16
-
17
- try {
18
- const jsonObject = JSON.parse(data)
19
- callback(null, jsonObject)
20
- } catch (parseError) {
21
- callback(parseError as Error, null)
22
- }
23
- })
24
- }
25
-
26
- export function runCommand(command: string, message?: string, endMessage?: string) {
27
- try {
28
- const indicator = spinner()
29
- indicator.start(message)
30
-
31
- execSync(command)
32
-
33
- indicator.stop(endMessage ?? "Done")
34
- } catch (error) {
35
- log.error(`${error}`)
36
- }
37
- }
38
-
39
- export function removeExtension(value: string) {
40
- const splitWords = value.split(".")
41
-
42
- return splitWords[0]
43
- }
44
-
45
- export async function installPackages(...packages: string[]) {
46
- const packageManager = await detect()
47
-
48
- switch (packageManager) {
49
- case "yarn":
50
- case "pnpm":
51
- runCommand(`${packageManager} add ${packages.join(" ")}`, "Installing dependencies")
52
- break
53
- default:
54
- runCommand(`${packageManager} install ${packages.join(" ")}`, "Installing dependencies")
55
- }
56
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "exclude": ["node_modules", "dist"],
3
- "compilerOptions": {
4
- "allowSyntheticDefaultImports": true,
5
- "esModuleInterop": false,
6
- "target": "ESNext",
7
- "module": "ESNext",
8
- "moduleResolution": "Node",
9
- "noEmit": false,
10
- "allowArbitraryExtensions": true,
11
- "strict": true,
12
- "baseUrl": "./",
13
- "outDir": "./dist",
14
- "paths": {
15
- "~/*": ["./src/*"]
16
- }
17
- }
18
- }
package/tsup.config.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "https://cdn.jsdelivr.net/npm/tsup/schema.json",
3
- "entry": ["src/index.ts"],
4
- "splitting": false,
5
- "clean": true,
6
- "format": "esm"
7
- }
File without changes