components-differ 1.0.8 → 1.0.10
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 +188 -21
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +17 -4
- package/dist/components.js.map +1 -1
- package/dist/create-diff.d.ts.map +1 -1
- package/dist/create-diff.js +201 -28
- package/dist/create-diff.js.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/parse-file-path.d.ts.map +1 -1
- package/dist/parse-file-path.js +22 -5
- package/dist/parse-file-path.js.map +1 -1
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +112 -0
- package/dist/registry.js.map +1 -0
- package/dist/shadcn-init.d.ts +11 -0
- package/dist/shadcn-init.d.ts.map +1 -0
- package/dist/shadcn-init.js +208 -0
- package/dist/shadcn-init.js.map +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,39 +1,206 @@
|
|
|
1
|
-
#
|
|
1
|
+
# components-differ
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`components-differ` is a companion CLI for shadcn/ui projects. It compares the current state of a codebase to its initial shadcn scaffold, then emits an installable registry entry that captures only the changes you made. You can pipe that output straight into the official shadcn CLI to bootstrap new projects, patch existing installs, or maintain a fully fledged custom registry.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
- Generates shadcn-compatible registry items from real projects
|
|
8
|
+
- Detects component dependencies based on the latest shadcn/ui catalog
|
|
9
|
+
- Understands both `src/` and app-root layouts
|
|
10
|
+
- Skips built-in primitives so the diff contains only custom code
|
|
11
|
+
- Creates or updates `registry.json` in-place (schema: [`registry.json`](https://ui.shadcn.com/docs/registry/registry-json))
|
|
12
|
+
- Supports environment-based configuration for registry metadata
|
|
13
|
+
- Ships with TypeScript types, tests, and build scripts for local development
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## Prerequisites
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
- Node.js 18+
|
|
18
|
+
- `pnpm` (recommended) or `npm`
|
|
19
|
+
- A project that has already been initialised with the shadcn CLI
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install globally or run via `npx`:
|
|
16
24
|
|
|
17
25
|
```bash
|
|
18
|
-
|
|
26
|
+
pnpm add -g components-differ
|
|
27
|
+
# or
|
|
28
|
+
npx components-differ --help
|
|
19
29
|
```
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
During local development, clone the repo and install dependencies:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/componentshost/components-differ.git
|
|
35
|
+
cd components-differ
|
|
36
|
+
pnpm install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
1. Create a fresh Next.js app.
|
|
42
|
+
2. Initialise shadcn/ui (`npx shadcn@latest init`).
|
|
43
|
+
3. Commit the baseline scaffold:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
rm -fr .git && git init
|
|
47
|
+
git add .
|
|
48
|
+
git commit -m "Initial shadcn scaffold"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
_Tip: use `npx components-differ --init` to automate the reset + commit._
|
|
22
52
|
|
|
23
|
-
|
|
53
|
+
4. Build out your custom components, hooks, utilities, and pages.
|
|
54
|
+
5. Run the differ:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx components-differ > registry-item.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
6. Publish or host the JSON output, then use it with the shadcn CLI:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx shadcn@latest add https://example.com/registry-item.json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## CLI Usage
|
|
24
67
|
|
|
25
68
|
```bash
|
|
26
|
-
npx
|
|
69
|
+
npx components-differ [options]
|
|
27
70
|
```
|
|
28
71
|
|
|
29
|
-
|
|
72
|
+
| Option | Description |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `-n, --name <name>` | Override the generated item name (defaults to the current directory name). |
|
|
75
|
+
| `--init` | Reset the git repository and recreate the initial commit (useful for fresh scaffolds). |
|
|
76
|
+
| `--registry [path]` | Create or update a `registry.json` file. If no path is provided, `./registry.json` is used. |
|
|
77
|
+
| `--initshadcn [type]` | Configure shadcn/ui for your project. Detects project type automatically; pass `next` or `vite` to force a specific scaffold. |
|
|
78
|
+
|
|
79
|
+
When `--registry` is omitted, the CLI prints a single registry item (JSON) to stdout. The item includes inferred dependencies, registry dependencies, file payloads, and metadata compatible with the shadcn registry tooling.
|
|
80
|
+
|
|
81
|
+
### Bootstrapping shadcn/ui
|
|
82
|
+
|
|
83
|
+
Use `--initshadcn` to apply the official shadcn setup steps for supported frameworks:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Auto-detect (looks at package.json)
|
|
87
|
+
npx components-differ --initshadcn
|
|
88
|
+
|
|
89
|
+
# Explicit Vite support (adds Tailwind deps, config files, and runs the shadcn CLI)
|
|
90
|
+
npx components-differ --initshadcn vite
|
|
91
|
+
|
|
92
|
+
# Explicit Next.js support (runs the shadcn CLI in your project)
|
|
93
|
+
npx components-differ --initshadcn next
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For Vite projects the command will:
|
|
97
|
+
|
|
98
|
+
- Add `tailwindcss`, `@tailwindcss/vite`, and `@types/node`
|
|
99
|
+
- Locate the first CSS file imported by the Vite entry file (`src/main.{ts,tsx,js,jsx}`) and replace its contents with the Tailwind entrypoint
|
|
100
|
+
- Inject the required `baseUrl`/`paths` aliases into `tsconfig.json` and `tsconfig.app.json`
|
|
101
|
+
- Overwrite `vite.config.ts` with the recommended configuration (includes Tailwind and path aliases)
|
|
102
|
+
- Run the interactive `shadcn@latest init` command
|
|
103
|
+
|
|
104
|
+
Next.js projects skip the file edits (Next provides the required Tailwind setup) and go straight to the `shadcn` CLI.
|
|
105
|
+
|
|
106
|
+
## Working with `registry.json`
|
|
107
|
+
|
|
108
|
+
Passing `--registry` switches the CLI into registry mode:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npx components-differ --registry # writes ./registry.json
|
|
112
|
+
npx components-differ --registry configs/registry.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- Existing files are parsed and updated; if the item already exists (matching `name`), it is replaced.
|
|
116
|
+
- New files are created with the official schema URL and project metadata.
|
|
117
|
+
- Parent directories are created automatically.
|
|
118
|
+
|
|
119
|
+
### Registry metadata
|
|
120
|
+
|
|
121
|
+
By default the generated file uses:
|
|
122
|
+
|
|
123
|
+
- `name`: `shadcn`
|
|
124
|
+
- `homepage`: `https://ui.shadcn.com`
|
|
125
|
+
|
|
126
|
+
Override these values by defining environment variables at runtime:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
REGISTRY_NAME=acme \
|
|
130
|
+
REGISTRY_HOMEPAGE=https://acme.dev \
|
|
131
|
+
npx components-differ --registry
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
If the variables are absent, the CLI also reads a `.env` file in the project root:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
REGISTRY_NAME=acme
|
|
138
|
+
REGISTRY_HOMEPAGE=https://acme.dev
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Building registry artifacts
|
|
142
|
+
|
|
143
|
+
Add a script to your `package.json` so you can build the registry payload with the official shadcn toolchain:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"scripts": {
|
|
148
|
+
"registry:build": "shadcn build"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Then run:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pnpm registry:build
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Combine this with the differ to capture changes, sync `registry.json`, and ship ready-to-install artifacts in a single workflow.
|
|
160
|
+
|
|
161
|
+
## Recommended Workflow
|
|
162
|
+
|
|
163
|
+
1. Run `pnpm build && pnpm test` to ensure your project is green.
|
|
164
|
+
2. Execute `npx components-differ --registry` to keep `registry.json` current.
|
|
165
|
+
3. Publish the updated registry (via HTTP or a git-backed registry).
|
|
166
|
+
4. Consumers install the latest slice using `npx shadcn@latest add <url>`.
|
|
167
|
+
|
|
168
|
+
## Development Scripts
|
|
169
|
+
|
|
170
|
+
| Command | Description |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `pnpm build` | Compile TypeScript sources to `dist/`. |
|
|
173
|
+
| `pnpm test` | Run the Vitest suite once. |
|
|
174
|
+
| `pnpm test:watch` | Run tests in watch mode. |
|
|
175
|
+
| `pnpm bump` | Increment the package version (patch) and update `package.json`. |
|
|
176
|
+
| `pnpm registry:build` | Run the shadcn CLI build pipeline (requires `shadcn` CLI). |
|
|
177
|
+
|
|
178
|
+
During development you can execute the CLI locally:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pnpm build
|
|
182
|
+
node dist/index.js --registry
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Or link it globally:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pnpm link --global
|
|
189
|
+
components-differ --help
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Releasing
|
|
193
|
+
|
|
194
|
+
1. Bump the version: `pnpm bump` (or adjust `package.json` manually).
|
|
195
|
+
2. Rebuild and test: `pnpm build && pnpm test`.
|
|
196
|
+
3. Publish: `npm publish`.
|
|
197
|
+
|
|
198
|
+
Ensure you are authenticated with an npm account that has publish rights (`npm whoami`).
|
|
30
199
|
|
|
31
|
-
|
|
200
|
+
## Contributing
|
|
32
201
|
|
|
33
|
-
|
|
202
|
+
Contributions are welcome! Please open an issue or pull request with a clear description of the change. Run the full test suite before submitting (`pnpm test`), and include updates to the documentation where relevant.
|
|
34
203
|
|
|
35
|
-
|
|
36
|
-
- `pnpm build` – compile the TypeScript sources to `dist/`.
|
|
37
|
-
- `pnpm test` or `pnpm test:watch` – run the Vitest suite.
|
|
204
|
+
## License
|
|
38
205
|
|
|
39
|
-
|
|
206
|
+
MIT © Izet Molla
|
package/dist/components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyE9D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAoBjG;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAepE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAQlE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQtF"}
|
package/dist/components.js
CHANGED
|
@@ -2,12 +2,13 @@ import path from "node:path";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
const WHITELISTED_COMPONENTS = new Set([
|
|
4
4
|
"accordion",
|
|
5
|
-
"alert",
|
|
6
5
|
"alert-dialog",
|
|
6
|
+
"alert",
|
|
7
7
|
"aspect-ratio",
|
|
8
8
|
"avatar",
|
|
9
9
|
"badge",
|
|
10
10
|
"breadcrumb",
|
|
11
|
+
"button-group",
|
|
11
12
|
"button",
|
|
12
13
|
"calendar",
|
|
13
14
|
"card",
|
|
@@ -15,18 +16,26 @@ const WHITELISTED_COMPONENTS = new Set([
|
|
|
15
16
|
"chart",
|
|
16
17
|
"checkbox",
|
|
17
18
|
"collapsible",
|
|
19
|
+
"combobox",
|
|
18
20
|
"command",
|
|
19
21
|
"context-menu",
|
|
20
|
-
"table",
|
|
22
|
+
"data-table",
|
|
23
|
+
"date-picker",
|
|
21
24
|
"dialog",
|
|
22
25
|
"drawer",
|
|
23
26
|
"dropdown-menu",
|
|
27
|
+
"empty",
|
|
28
|
+
"field",
|
|
24
29
|
"form",
|
|
25
30
|
"hover-card",
|
|
26
|
-
"input",
|
|
31
|
+
"input-group",
|
|
27
32
|
"input-otp",
|
|
33
|
+
"input",
|
|
34
|
+
"item",
|
|
35
|
+
"kbd",
|
|
28
36
|
"label",
|
|
29
37
|
"menubar",
|
|
38
|
+
"native-select",
|
|
30
39
|
"navigation-menu",
|
|
31
40
|
"pagination",
|
|
32
41
|
"popover",
|
|
@@ -37,16 +46,20 @@ const WHITELISTED_COMPONENTS = new Set([
|
|
|
37
46
|
"select",
|
|
38
47
|
"separator",
|
|
39
48
|
"sheet",
|
|
49
|
+
"sidebar",
|
|
40
50
|
"skeleton",
|
|
41
51
|
"slider",
|
|
42
52
|
"sonner",
|
|
53
|
+
"spinner",
|
|
43
54
|
"switch",
|
|
55
|
+
"table",
|
|
44
56
|
"tabs",
|
|
45
57
|
"textarea",
|
|
46
58
|
"toast",
|
|
47
|
-
"toggle",
|
|
48
59
|
"toggle-group",
|
|
60
|
+
"toggle",
|
|
49
61
|
"tooltip",
|
|
62
|
+
"typography",
|
|
50
63
|
]);
|
|
51
64
|
function resolveAlias(config, key) {
|
|
52
65
|
const alias = config[key];
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,WAAW;IACX,OAAO;IACP,cAAc;IACd,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,WAAW;IACX,cAAc;IACd,OAAO;IACP,cAAc;IACd,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,UAAU;IACV,MAAM;IACN,UAAU;IACV,OAAO;IACP,UAAU;IACV,aAAa;IACb,UAAU;IACV,SAAS;IACT,cAAc;IACd,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,OAAO;IACP,OAAO;IACP,MAAM;IACN,YAAY;IACZ,aAAa;IACb,WAAW;IACX,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,SAAS;IACT,eAAe;IACf,iBAAiB;IACjB,YAAY;IACZ,SAAS;IACT,UAAU;IACV,aAAa;IACb,WAAW;IACX,aAAa;IACb,QAAQ;IACR,WAAW;IACX,OAAO;IACP,SAAS;IACT,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,OAAO;IACP,MAAM;IACN,UAAU;IACV,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;IACT,YAAY;CACb,CAAC,CAAC;AAEH,SAAS,YAAY,CAAC,MAAwB,EAAE,GAA2B;IACzE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,QAAQ,EAAE,8BAA8B,CAAC,CAAC;IACrF,CAAC;IA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AI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAuC,CAAC;IAEhE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAwB;IACtD,OAAO;QACL,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAwB,EAAE,QAAgB;IAC3E,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,OAAO,sBAAsB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-diff.d.ts","sourceRoot":"","sources":["../src/create-diff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-diff.d.ts","sourceRoot":"","sources":["../src/create-diff.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1E,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACjD,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AA2LD,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,EAAE,gBAAgB,GAAG,UAAU,CAsI/B"}
|
package/dist/create-diff.js
CHANGED
|
@@ -1,40 +1,137 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import { findComponentFiles, getAliasedPaths, isBuiltinComponent } from "./components.js";
|
|
2
3
|
import { parseFilePath } from "./parse-file-path.js";
|
|
4
|
+
const IMPORT_EXPORT_REGEX = /(?:import|export)\s+(?:[^"'`;]*?\s+from\s+)?["']([^"'`]+)["']/g;
|
|
5
|
+
const DYNAMIC_IMPORT_REGEX = /import\(\s*["']([^"'`]+)["']\s*\)/g;
|
|
6
|
+
const REQUIRE_REGEX = /require\(\s*["']([^"'`]+)["']\s*\)/g;
|
|
7
|
+
const RESOLVABLE_EXTENSIONS = [
|
|
8
|
+
".ts",
|
|
9
|
+
".tsx",
|
|
10
|
+
".js",
|
|
11
|
+
".jsx",
|
|
12
|
+
".mjs",
|
|
13
|
+
".cjs",
|
|
14
|
+
".cts",
|
|
15
|
+
".mts",
|
|
16
|
+
".json",
|
|
17
|
+
".css",
|
|
18
|
+
".scss",
|
|
19
|
+
".sass",
|
|
20
|
+
".pcss",
|
|
21
|
+
".less",
|
|
22
|
+
".mdx",
|
|
23
|
+
];
|
|
3
24
|
function addFile(output, config, inSrcDir, relativeFilePath, content) {
|
|
4
25
|
if (isBuiltinComponent(config, relativeFilePath)) {
|
|
5
26
|
return;
|
|
6
27
|
}
|
|
7
28
|
output.files.push(parseFilePath(inSrcDir, config, `./${relativeFilePath}`, content));
|
|
8
29
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const currentDependencies = (currentPackageJson.dependencies ?? {});
|
|
15
|
-
const currentDevDependencies = (currentPackageJson.devDependencies ?? {});
|
|
16
|
-
output.dependencies = Object.keys(currentDependencies).filter((dep) => !(dep in initialDependencies));
|
|
17
|
-
output.devDependencies = Object.keys(currentDevDependencies).filter((dep) => !(dep in initialDevDependencies));
|
|
30
|
+
function isInAppDir(filePath) {
|
|
31
|
+
return filePath.startsWith("app/");
|
|
32
|
+
}
|
|
33
|
+
function normalizeProjectPath(filePath) {
|
|
34
|
+
return filePath.replace(/^\.\//, "").replace(/\\/g, "/");
|
|
18
35
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
function buildAliasMap(config) {
|
|
37
|
+
const aliasEntries = [];
|
|
38
|
+
const aliasKeys = ["components", "utils", "ui", "lib", "hooks"];
|
|
39
|
+
for (const key of aliasKeys) {
|
|
40
|
+
const alias = config[key];
|
|
41
|
+
if (typeof alias !== "string") {
|
|
42
|
+
continue;
|
|
23
43
|
}
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
const normalizedAlias = alias.startsWith("@/") ? alias : `@/${alias.replace(/^\.\//, "")}`;
|
|
45
|
+
const resolvedPath = alias.startsWith("@/")
|
|
46
|
+
? alias.replace("@/", config.isSrcDir ? "src/" : "")
|
|
47
|
+
: alias.replace(/^\.\//, config.isSrcDir ? "src/" : "");
|
|
48
|
+
aliasEntries.push([normalizedAlias, normalizeProjectPath(resolvedPath)]);
|
|
49
|
+
}
|
|
50
|
+
aliasEntries.sort((a, b) => b[0].length - a[0].length);
|
|
51
|
+
return Object.fromEntries(aliasEntries);
|
|
52
|
+
}
|
|
53
|
+
function resolveWithExtensions(candidate, fileMap) {
|
|
54
|
+
const normalized = normalizeProjectPath(candidate);
|
|
55
|
+
if (fileMap.has(normalized)) {
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
const hasExtension = path.posix.extname(normalized).length > 0;
|
|
59
|
+
if (hasExtension) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
63
|
+
const withExtension = `${normalized}${extension}`;
|
|
64
|
+
if (fileMap.has(withExtension)) {
|
|
65
|
+
return withExtension;
|
|
26
66
|
}
|
|
27
67
|
}
|
|
68
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
69
|
+
const indexPath = `${normalized}/index${extension}`;
|
|
70
|
+
if (fileMap.has(indexPath)) {
|
|
71
|
+
return indexPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
28
75
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
76
|
+
function resolveAliasImport(specifier, aliasMap, fileMap) {
|
|
77
|
+
for (const [alias, target] of Object.entries(aliasMap)) {
|
|
78
|
+
if (!specifier.startsWith(alias)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const suffix = specifier.slice(alias.length);
|
|
82
|
+
const candidate = suffix.length > 0 ? `${target}${suffix}` : target;
|
|
83
|
+
const resolved = resolveWithExtensions(candidate, fileMap);
|
|
84
|
+
if (resolved) {
|
|
85
|
+
return resolved;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function resolveRelativeImport(specifier, fromPath, fileMap) {
|
|
91
|
+
const baseDir = path.posix.dirname(fromPath);
|
|
92
|
+
const candidate = path.posix.normalize(path.posix.join(baseDir, specifier));
|
|
93
|
+
if (candidate.startsWith("..")) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return resolveWithExtensions(candidate, fileMap);
|
|
97
|
+
}
|
|
98
|
+
function extractModuleSpecifiers(content) {
|
|
99
|
+
const specifiers = [];
|
|
100
|
+
const matchers = [IMPORT_EXPORT_REGEX, DYNAMIC_IMPORT_REGEX, REQUIRE_REGEX];
|
|
101
|
+
for (const matcher of matchers) {
|
|
102
|
+
matcher.lastIndex = 0;
|
|
103
|
+
let match;
|
|
104
|
+
while ((match = matcher.exec(content)) !== null) {
|
|
105
|
+
const specifier = match[1];
|
|
106
|
+
if (typeof specifier === "string" && specifier.length > 0) {
|
|
107
|
+
specifiers.push(specifier);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return specifiers;
|
|
112
|
+
}
|
|
113
|
+
function normalizeModuleName(specifier) {
|
|
114
|
+
if (specifier.startsWith("@")) {
|
|
115
|
+
const scoped = specifier.split("/");
|
|
116
|
+
if (scoped.length >= 2) {
|
|
117
|
+
return `${scoped[0]}/${scoped[1]}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const parts = specifier.split("/");
|
|
121
|
+
return parts[0];
|
|
31
122
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
123
|
+
function computeRelativePath(config, aliasedRoots, projectPath) {
|
|
124
|
+
if (config.isSrcDir) {
|
|
125
|
+
if (projectPath.startsWith("src/")) {
|
|
126
|
+
return { relativePath: projectPath.replace(/^src\//, ""), inSrcDir: true };
|
|
127
|
+
}
|
|
128
|
+
return { relativePath: projectPath, inSrcDir: false };
|
|
129
|
+
}
|
|
130
|
+
const inAliasRoot = aliasedRoots.some((alias) => projectPath === alias || projectPath.startsWith(`${alias}/`));
|
|
131
|
+
if (inAliasRoot || isInAppDir(projectPath)) {
|
|
132
|
+
return { relativePath: projectPath, inSrcDir: true };
|
|
37
133
|
}
|
|
134
|
+
return { relativePath: projectPath, inSrcDir: false };
|
|
38
135
|
}
|
|
39
136
|
export function createDiff({ name, config, alteredFiles, specificFiles, currentFiles, currentPackageJson, }) {
|
|
40
137
|
const output = {
|
|
@@ -48,14 +145,90 @@ export function createDiff({ name, config, alteredFiles, specificFiles, currentF
|
|
|
48
145
|
cssVars: {},
|
|
49
146
|
meta: {},
|
|
50
147
|
};
|
|
51
|
-
|
|
52
|
-
|
|
148
|
+
const fileMap = new Map(currentFiles.map((file) => [normalizeProjectPath(file.path), file]));
|
|
149
|
+
const aliasedRoots = getAliasedPaths(config).map((alias) => normalizeProjectPath(alias));
|
|
150
|
+
const aliasMap = buildAliasMap(config);
|
|
151
|
+
const visited = new Set();
|
|
152
|
+
const added = new Set();
|
|
153
|
+
const bareImports = new Set();
|
|
154
|
+
const usedRegistryComponents = new Set();
|
|
155
|
+
function addToOutput(projectPath) {
|
|
156
|
+
const normalizedPath = normalizeProjectPath(projectPath);
|
|
157
|
+
if (added.has(normalizedPath)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const fileEntry = fileMap.get(normalizedPath);
|
|
161
|
+
if (!fileEntry) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const { relativePath, inSrcDir } = computeRelativePath(config, aliasedRoots, normalizedPath);
|
|
165
|
+
if (isBuiltinComponent(config, relativePath)) {
|
|
166
|
+
const dependencyName = path.posix.basename(relativePath, path.posix.extname(relativePath));
|
|
167
|
+
usedRegistryComponents.add(dependencyName);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
addFile(output, config, inSrcDir, relativePath, fileEntry.content);
|
|
171
|
+
added.add(normalizedPath);
|
|
53
172
|
}
|
|
54
|
-
|
|
55
|
-
|
|
173
|
+
function walkFile(projectPath) {
|
|
174
|
+
const normalizedPath = normalizeProjectPath(projectPath);
|
|
175
|
+
if (visited.has(normalizedPath)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
visited.add(normalizedPath);
|
|
179
|
+
const fileEntry = fileMap.get(normalizedPath);
|
|
180
|
+
if (!fileEntry) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
addToOutput(normalizedPath);
|
|
184
|
+
const specifiers = extractModuleSpecifiers(fileEntry.content);
|
|
185
|
+
for (const specifier of specifiers) {
|
|
186
|
+
const trimmed = specifier.trim();
|
|
187
|
+
if (trimmed.startsWith(".") && !trimmed.startsWith("...")) {
|
|
188
|
+
const resolved = resolveRelativeImport(trimmed, normalizedPath, fileMap);
|
|
189
|
+
if (resolved) {
|
|
190
|
+
walkFile(resolved);
|
|
191
|
+
}
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const resolved = resolveAliasImport(trimmed, aliasMap, fileMap);
|
|
195
|
+
if (resolved) {
|
|
196
|
+
walkFile(resolved);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (!trimmed.startsWith("node:") && !trimmed.startsWith("/")) {
|
|
200
|
+
bareImports.add(normalizeModuleName(trimmed));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (const file of alteredFiles) {
|
|
205
|
+
walkFile(file.path);
|
|
206
|
+
}
|
|
207
|
+
const initialPackageJson = specificFiles["./package.json"]
|
|
208
|
+
? JSON.parse(specificFiles["./package.json"])
|
|
209
|
+
: {};
|
|
210
|
+
const currentPackage = JSON.parse(currentPackageJson);
|
|
211
|
+
const currentDependencies = (currentPackage.dependencies ?? {});
|
|
212
|
+
const currentDevDependencies = (currentPackage.devDependencies ?? {});
|
|
213
|
+
const currentPeerDependencies = (currentPackage.peerDependencies ?? {});
|
|
214
|
+
const currentOptionalDependencies = (currentPackage.optionalDependencies ?? {});
|
|
215
|
+
const initialDependencies = (initialPackageJson.dependencies ?? {});
|
|
216
|
+
const initialDevDependencies = (initialPackageJson.devDependencies ?? {});
|
|
217
|
+
const newDependencies = Object.keys(currentDependencies).filter((dep) => !(dep in initialDependencies));
|
|
218
|
+
const newDevDependencies = Object.keys(currentDevDependencies).filter((dep) => !(dep in initialDevDependencies));
|
|
219
|
+
const installedPackages = new Set([
|
|
220
|
+
...Object.keys(currentDependencies),
|
|
221
|
+
...Object.keys(currentDevDependencies),
|
|
222
|
+
...Object.keys(currentPeerDependencies),
|
|
223
|
+
...Object.keys(currentOptionalDependencies),
|
|
224
|
+
]);
|
|
225
|
+
const missingDependencies = Array.from(bareImports).filter((dep) => dep.length > 0 && !installedPackages.has(dep));
|
|
226
|
+
output.dependencies = Array.from(new Set([...newDependencies, ...missingDependencies])).sort();
|
|
227
|
+
output.devDependencies = Array.from(new Set(newDevDependencies)).sort();
|
|
228
|
+
for (const dependency of findComponentFiles(config, currentFiles)) {
|
|
229
|
+
usedRegistryComponents.add(dependency);
|
|
56
230
|
}
|
|
57
|
-
output.registryDependencies =
|
|
58
|
-
addDependencies(output, specificFiles["./package.json"], currentPackageJson);
|
|
231
|
+
output.registryDependencies = Array.from(usedRegistryComponents).sort();
|
|
59
232
|
return output;
|
|
60
233
|
}
|
|
61
234
|
//# sourceMappingURL=create-diff.js.map
|
package/dist/create-diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-diff.js","sourceRoot":"","sources":["../src/create-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-diff.js","sourceRoot":"","sources":["../src/create-diff.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAcrD,MAAM,mBAAmB,GAAG,gEAAgE,CAAC;AAC7F,MAAM,oBAAoB,GAA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sB,CAAC,CAC1C,CAAC;IAEF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;QAChC,GAAG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC;QACnC,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC;QACtC,GAAG,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC;QACvC,GAAG,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC;KAC5C,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CACxD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CACvD,CAAC;IAEF,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,eAAe,EAAE,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/F,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAExE,KAAK,MAAM,UAAU,IAAI,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;QAClE,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,IAAI,EAAE,CAAC;IAExE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,12 @@ import { program } from "commander";
|
|
|
6
6
|
import { scanForAlteredFiles, scanForFiles, hasSrcDir } from "./git.js";
|
|
7
7
|
import { readComponentsManifest } from "./components.js";
|
|
8
8
|
import { createDiff } from "./create-diff.js";
|
|
9
|
+
import { writeRegistryFile } from "./registry.js";
|
|
10
|
+
import { initShadcnProject } from "./shadcn-init.js";
|
|
9
11
|
program.option("-n, --name <name>", "Name of the component set to diff");
|
|
10
12
|
program.option("--init", "Initialise a git repository for the current directory");
|
|
13
|
+
program.option("--registry [path]", "Create or update a registry.json file. Defaults to ./registry.json when no path is provided.");
|
|
14
|
+
program.option("--initshadcn [type]", "Initialise shadcn/ui configuration (supports Next.js and Vite). Detects project type automatically when omitted.");
|
|
11
15
|
program.parse();
|
|
12
16
|
const options = program.opts();
|
|
13
17
|
function runCommand(command) {
|
|
@@ -83,6 +87,23 @@ function main() {
|
|
|
83
87
|
initRepository();
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
90
|
+
if (options.initshadcn !== undefined) {
|
|
91
|
+
const specifiedType = typeof options.initshadcn === "string" && options.initshadcn.length > 0
|
|
92
|
+
? options.initshadcn
|
|
93
|
+
: undefined;
|
|
94
|
+
try {
|
|
95
|
+
initShadcnProject({
|
|
96
|
+
cwd: process.cwd(),
|
|
97
|
+
projectType: specifiedType,
|
|
98
|
+
execCommand: runCommand,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error(error.message);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
86
107
|
const name = options.name ?? path.basename(process.cwd());
|
|
87
108
|
const { alteredFiles, specificFiles } = scanForAlteredFiles(["./package.json"]);
|
|
88
109
|
const currentFiles = scanForFiles(process.cwd());
|
|
@@ -97,6 +118,14 @@ function main() {
|
|
|
97
118
|
currentFiles,
|
|
98
119
|
currentPackageJson,
|
|
99
120
|
});
|
|
121
|
+
if (options.registry !== undefined) {
|
|
122
|
+
const registryPath = typeof options.registry === "string" && options.registry.length > 0
|
|
123
|
+
? options.registry
|
|
124
|
+
: "./registry.json";
|
|
125
|
+
const resolvedPath = writeRegistryFile(process.cwd(), registryPath, output);
|
|
126
|
+
console.log(`Registry file updated at ${resolvedPath}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
100
129
|
console.log(JSON.stringify(output, null, 2));
|
|
101
130
|
}
|
|
102
131
|
main();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,CAAC,CAAC;AACzE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,uDAAuD,CAAC,CAAC;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S,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,UAAU,CAAC;QACxB,IAAI;QACJ,MAAM,EAAE,MAA+C;QACvD,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,kBAAkB;KACnB,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAChB,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YACjE,CAAC,CAAC,OAAO,CAAC,QAAQ;YAClB,CAAC,CAAC,iBAAiB,CAAC;QAExB,MAAM,YAAY,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAC;QACxD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-file-path.d.ts","sourceRoot":"","sources":["../src/parse-file-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-file-path.d.ts","sourceRoot":"","sources":["../src/parse-file-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAsB7D,wBAAgB,aAAa,CAC3B,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,QAAQ,CA0CV"}
|
package/dist/parse-file-path.js
CHANGED
|
@@ -8,28 +8,45 @@ function isWithinAlias(config, filePath, aliasKey) {
|
|
|
8
8
|
}
|
|
9
9
|
return filePath.startsWith(fixAlias(alias));
|
|
10
10
|
}
|
|
11
|
+
function normalizeTargetPath(filePath) {
|
|
12
|
+
return filePath.replace(/^\.\//, "");
|
|
13
|
+
}
|
|
14
|
+
function isAppRoutePath(targetPath) {
|
|
15
|
+
return targetPath.startsWith("app/") || targetPath.startsWith("src/app/");
|
|
16
|
+
}
|
|
11
17
|
export function parseFilePath(wasInSrcDir, config, filePath, content) {
|
|
18
|
+
const normalizedTarget = normalizeTargetPath(filePath);
|
|
19
|
+
const defaultTarget = wasInSrcDir ? normalizedTarget : `~/${normalizedTarget}`;
|
|
12
20
|
const output = {
|
|
13
21
|
path: filePath,
|
|
14
22
|
content: content ?? "",
|
|
15
|
-
type: "registry:
|
|
16
|
-
target:
|
|
23
|
+
type: "registry:file",
|
|
24
|
+
target: defaultTarget,
|
|
17
25
|
};
|
|
18
26
|
if (isWithinAlias(config, filePath, "ui")) {
|
|
19
27
|
output.type = "registry:ui";
|
|
20
28
|
output.target = undefined;
|
|
29
|
+
return output;
|
|
21
30
|
}
|
|
22
|
-
|
|
31
|
+
if (isWithinAlias(config, filePath, "components")) {
|
|
23
32
|
output.type = "registry:block";
|
|
24
33
|
output.target = undefined;
|
|
34
|
+
return output;
|
|
25
35
|
}
|
|
26
|
-
|
|
36
|
+
if (isWithinAlias(config, filePath, "hooks")) {
|
|
27
37
|
output.type = "registry:hook";
|
|
28
38
|
output.target = undefined;
|
|
39
|
+
return output;
|
|
29
40
|
}
|
|
30
|
-
|
|
41
|
+
if (isWithinAlias(config, filePath, "lib")) {
|
|
31
42
|
output.type = "registry:lib";
|
|
32
43
|
output.target = undefined;
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
if (isAppRoutePath(normalizedTarget)) {
|
|
47
|
+
output.type = "registry:page";
|
|
48
|
+
output.target = defaultTarget;
|
|
49
|
+
return output;
|
|
33
50
|
}
|
|
34
51
|
return output;
|
|
35
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-file-path.js","sourceRoot":"","sources":["../src/parse-file-path.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,aAAa,CAAC,MAAwB,EAAE,QAAgB,EAAE,QAAgC;IACjG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,WAAoB,EACpB,MAAwB,EACxB,QAAgB,EAChB,OAAgB;IAEhB,MAAM,
|
|
1
|
+
{"version":3,"file":"parse-file-path.js","sourceRoot":"","sources":["../src/parse-file-path.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,aAAa,CAAC,MAAwB,EAAE,QAAgB,EAAE,QAAgC;IACjG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC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c,CAAC;QAC7B,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,cAAc,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC;QAC9B,MAAM,CAAC,MAAM,GAAG,aAAa,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AA6G3D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CA4BjG"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const REGISTRY_SCHEMA_URL = "https://ui.shadcn.com/schema/registry.json";
|
|
4
|
+
function parseEnvFile(fileContents) {
|
|
5
|
+
const envValues = {};
|
|
6
|
+
const lines = fileContents.split(/\r?\n/);
|
|
7
|
+
for (const line of lines) {
|
|
8
|
+
const trimmed = line.trim();
|
|
9
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const separatorIndex = trimmed.indexOf("=");
|
|
13
|
+
if (separatorIndex === -1) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const key = trimmed.slice(0, separatorIndex).trim();
|
|
17
|
+
const value = trimmed.slice(separatorIndex + 1).trim();
|
|
18
|
+
if (!key) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
envValues[key] = value.replace(/^['"]|['"]$/g, "");
|
|
22
|
+
}
|
|
23
|
+
return envValues;
|
|
24
|
+
}
|
|
25
|
+
function readDotEnv(rootDir) {
|
|
26
|
+
const dotenvPath = path.join(rootDir, ".env");
|
|
27
|
+
if (!fs.existsSync(dotenvPath)) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
const contents = fs.readFileSync(dotenvPath, "utf8");
|
|
31
|
+
return parseEnvFile(contents);
|
|
32
|
+
}
|
|
33
|
+
function resolveRegistryMetadata(rootDir) {
|
|
34
|
+
const defaults = {
|
|
35
|
+
name: "shadcn",
|
|
36
|
+
homepage: "https://ui.shadcn.com",
|
|
37
|
+
};
|
|
38
|
+
const envFromProcess = {
|
|
39
|
+
name: process.env.REGISTRY_NAME ?? "",
|
|
40
|
+
homepage: process.env.REGISTRY_HOMEPAGE ?? "",
|
|
41
|
+
};
|
|
42
|
+
let metadata = {
|
|
43
|
+
name: envFromProcess.name || defaults.name,
|
|
44
|
+
homepage: envFromProcess.homepage || defaults.homepage,
|
|
45
|
+
};
|
|
46
|
+
if (!envFromProcess.name || !envFromProcess.homepage) {
|
|
47
|
+
const envFileValues = readDotEnv(rootDir);
|
|
48
|
+
metadata = {
|
|
49
|
+
name: envFromProcess.name || envFileValues.REGISTRY_NAME || defaults.name,
|
|
50
|
+
homepage: envFromProcess.homepage || envFileValues.REGISTRY_HOMEPAGE || defaults.homepage,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return metadata;
|
|
54
|
+
}
|
|
55
|
+
function ensureDirectoryExists(filePath) {
|
|
56
|
+
const dir = path.dirname(filePath);
|
|
57
|
+
if (fs.existsSync(dir)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
function loadExistingRegistry(registryPath) {
|
|
63
|
+
if (!fs.existsSync(registryPath)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const contents = fs.readFileSync(registryPath, "utf8");
|
|
67
|
+
try {
|
|
68
|
+
const file = JSON.parse(contents);
|
|
69
|
+
if (!Array.isArray(file.items)) {
|
|
70
|
+
throw new Error("Invalid registry.json: missing items array");
|
|
71
|
+
}
|
|
72
|
+
return file;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new Error(`Failed to parse existing registry.json at ${registryPath}: ${error.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function upsertRegistryItem(registry, diff) {
|
|
79
|
+
const existingIndex = registry.items.findIndex((item) => item.name === diff.name);
|
|
80
|
+
if (existingIndex >= 0) {
|
|
81
|
+
registry.items[existingIndex] = diff;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
registry.items.push(diff);
|
|
85
|
+
}
|
|
86
|
+
return registry;
|
|
87
|
+
}
|
|
88
|
+
export function writeRegistryFile(rootDir, relativePath, diff) {
|
|
89
|
+
const registryPath = path.isAbsolute(relativePath) ? relativePath : path.join(rootDir, relativePath);
|
|
90
|
+
const existingRegistry = loadExistingRegistry(registryPath);
|
|
91
|
+
const metadata = resolveRegistryMetadata(rootDir);
|
|
92
|
+
const registry = existingRegistry ?? {
|
|
93
|
+
$schema: REGISTRY_SCHEMA_URL,
|
|
94
|
+
name: metadata.name,
|
|
95
|
+
homepage: metadata.homepage,
|
|
96
|
+
items: [],
|
|
97
|
+
};
|
|
98
|
+
if (!existingRegistry) {
|
|
99
|
+
registry.name = metadata.name;
|
|
100
|
+
registry.homepage = metadata.homepage;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
registry.name = existingRegistry.name || metadata.name;
|
|
104
|
+
registry.homepage = existingRegistry.homepage || metadata.homepage;
|
|
105
|
+
}
|
|
106
|
+
registry.$schema = existingRegistry?.$schema ?? REGISTRY_SCHEMA_URL;
|
|
107
|
+
upsertRegistryItem(registry, diff);
|
|
108
|
+
ensureDirectoryExists(registryPath);
|
|
109
|
+
fs.writeFileSync(registryPath, `${JSON.stringify(registry, null, 2)}\n`, "utf8");
|
|
110
|
+
return registryPath;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAOzE,SAAS,YAAY,CAAC,YAAoB;IACxC,MAAM,SAAS,GAA2B,EAAE,CAAC;IAE7C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QAED,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEvD,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,SAAS;QACX,CAAC;QAED,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE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types.js";
|
|
2
|
+
type ExecCommand = (command: string) => void;
|
|
3
|
+
interface InitShadcnOptions {
|
|
4
|
+
cwd: string;
|
|
5
|
+
projectType?: string | ProjectType;
|
|
6
|
+
execCommand: ExecCommand;
|
|
7
|
+
}
|
|
8
|
+
export declare function initShadcnProject({ cwd, projectType, execCommand }: InitShadcnOptions): void;
|
|
9
|
+
export declare function determineProjectTypeFromPackageJson(packageJson: Record<string, unknown>): ProjectType | null;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=shadcn-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadcn-init.d.ts","sourceRoot":"","sources":["../src/shadcn-init.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,KAAK,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE7C,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACnC,WAAW,EAAE,WAAW,CAAC;CAC1B;AA8OD,wBAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAyB5F;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,GAAG,IAAI,CAE5G"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const VITE_INDEX_CSS_CONTENT = '@import "tailwindcss";\n';
|
|
4
|
+
const VITE_CONFIG_TEMPLATE = `import path from "path";
|
|
5
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
6
|
+
import react from "@vitejs/plugin-react";
|
|
7
|
+
import { defineConfig } from "vite";
|
|
8
|
+
|
|
9
|
+
// https://vite.dev/config/
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
plugins: [react(), tailwindcss()],
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
"@": path.resolve(__dirname, "./src"),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
`;
|
|
19
|
+
function readPackageJson(cwd) {
|
|
20
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
21
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
22
|
+
throw new Error("package.json not found. Run this command from the project root.");
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const contents = fs.readFileSync(packageJsonPath, "utf8");
|
|
26
|
+
return JSON.parse(contents);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new Error(`Failed to parse package.json: ${error.message}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function normalizeProjectType(input) {
|
|
33
|
+
const value = input.toLowerCase();
|
|
34
|
+
if (value === "next" || value === "nextjs") {
|
|
35
|
+
return "next";
|
|
36
|
+
}
|
|
37
|
+
if (value === "vite") {
|
|
38
|
+
return "vite";
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function detectProjectType(packageJson) {
|
|
43
|
+
const dependencies = {
|
|
44
|
+
...packageJson.dependencies,
|
|
45
|
+
...packageJson.devDependencies,
|
|
46
|
+
};
|
|
47
|
+
if (!dependencies) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if ("next" in dependencies) {
|
|
51
|
+
return "next";
|
|
52
|
+
}
|
|
53
|
+
if (Object.keys(dependencies).some((dep) => dep === "vite" || dep.startsWith("@vitejs/plugin-"))) {
|
|
54
|
+
return "vite";
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function detectPackageManager(cwd) {
|
|
59
|
+
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
|
|
60
|
+
return "pnpm";
|
|
61
|
+
}
|
|
62
|
+
if (fs.existsSync(path.join(cwd, "yarn.lock"))) {
|
|
63
|
+
return "yarn";
|
|
64
|
+
}
|
|
65
|
+
if (fs.existsSync(path.join(cwd, "bun.lockb"))) {
|
|
66
|
+
return "bun";
|
|
67
|
+
}
|
|
68
|
+
return "npm";
|
|
69
|
+
}
|
|
70
|
+
function installDependencies(manager, dependencies, options = {}) {
|
|
71
|
+
const dev = options.dev ?? false;
|
|
72
|
+
switch (manager) {
|
|
73
|
+
case "pnpm":
|
|
74
|
+
return dev ? `pnpm add -D ${dependencies.join(" ")}` : `pnpm add ${dependencies.join(" ")}`;
|
|
75
|
+
case "yarn":
|
|
76
|
+
return dev ? `yarn add -D ${dependencies.join(" ")}` : `yarn add ${dependencies.join(" ")}`;
|
|
77
|
+
case "bun":
|
|
78
|
+
return dev ? `bun add -d ${dependencies.join(" ")}` : `bun add ${dependencies.join(" ")}`;
|
|
79
|
+
case "npm":
|
|
80
|
+
default:
|
|
81
|
+
return dev
|
|
82
|
+
? `npm install --save-dev ${dependencies.join(" ")}`
|
|
83
|
+
: `npm install ${dependencies.join(" ")}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getShadcnInitCommand(manager) {
|
|
87
|
+
switch (manager) {
|
|
88
|
+
case "pnpm":
|
|
89
|
+
return "pnpm dlx shadcn@latest init";
|
|
90
|
+
case "yarn":
|
|
91
|
+
return "yarn dlx shadcn@latest init";
|
|
92
|
+
case "bun":
|
|
93
|
+
return "bunx shadcn@latest init";
|
|
94
|
+
case "npm":
|
|
95
|
+
default:
|
|
96
|
+
return "npx shadcn@latest init";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function ensureDirectory(filePath) {
|
|
100
|
+
const dir = path.dirname(filePath);
|
|
101
|
+
if (!fs.existsSync(dir)) {
|
|
102
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function writeFileIfChanged(filePath, content) {
|
|
106
|
+
ensureDirectory(filePath);
|
|
107
|
+
const current = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : "";
|
|
108
|
+
if (current === content) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
fs.writeFileSync(filePath, content, "utf8");
|
|
112
|
+
}
|
|
113
|
+
const VITE_ENTRY_FILES = ["src/main.tsx", "src/main.jsx", "src/main.ts", "src/main.js"];
|
|
114
|
+
function findCssImport(content) {
|
|
115
|
+
const importRegex = /import\s+(?:.+?\s+from\s+)?["'](.+?\.css)["'];?/g;
|
|
116
|
+
let match;
|
|
117
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
118
|
+
const [, cssPath] = match;
|
|
119
|
+
if (cssPath) {
|
|
120
|
+
return cssPath;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function resolveCssEntryPath(cwd) {
|
|
126
|
+
for (const entry of VITE_ENTRY_FILES) {
|
|
127
|
+
const entryPath = path.join(cwd, entry);
|
|
128
|
+
if (!fs.existsSync(entryPath)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const contents = fs.readFileSync(entryPath, "utf8");
|
|
132
|
+
const cssImport = findCssImport(contents);
|
|
133
|
+
if (!cssImport) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const absoluteCssPath = path.resolve(path.dirname(entryPath), cssImport);
|
|
137
|
+
return absoluteCssPath;
|
|
138
|
+
}
|
|
139
|
+
return path.join(cwd, "src", "index.css");
|
|
140
|
+
}
|
|
141
|
+
function updateJsonFile(filePath, mutator, fallback) {
|
|
142
|
+
let data = fallback;
|
|
143
|
+
if (fs.existsSync(filePath)) {
|
|
144
|
+
try {
|
|
145
|
+
data = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new Error(`Failed to parse ${filePath}: ${error.message}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
mutator(data);
|
|
152
|
+
fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
153
|
+
}
|
|
154
|
+
function updateTsConfig(cwd, fileName) {
|
|
155
|
+
const filePath = path.join(cwd, fileName);
|
|
156
|
+
updateJsonFile(filePath, (tsconfig) => {
|
|
157
|
+
const compilerOptions = (tsconfig.compilerOptions ??= {});
|
|
158
|
+
if (typeof compilerOptions.baseUrl !== "string") {
|
|
159
|
+
compilerOptions.baseUrl = ".";
|
|
160
|
+
}
|
|
161
|
+
const paths = (compilerOptions.paths ??= {});
|
|
162
|
+
const existing = paths["@/*"];
|
|
163
|
+
if (!Array.isArray(existing) || !existing.includes("./src/*")) {
|
|
164
|
+
paths["@/*"] = ["./src/*"];
|
|
165
|
+
}
|
|
166
|
+
}, { compilerOptions: {} });
|
|
167
|
+
}
|
|
168
|
+
function updateViteFiles(cwd) {
|
|
169
|
+
const cssEntryFile = resolveCssEntryPath(cwd);
|
|
170
|
+
writeFileIfChanged(cssEntryFile, VITE_INDEX_CSS_CONTENT);
|
|
171
|
+
updateTsConfig(cwd, "tsconfig.json");
|
|
172
|
+
updateTsConfig(cwd, "tsconfig.app.json");
|
|
173
|
+
const viteConfigPathTs = path.join(cwd, "vite.config.ts");
|
|
174
|
+
const viteConfigPathJs = path.join(cwd, "vite.config.js");
|
|
175
|
+
const targetPath = fs.existsSync(viteConfigPathTs) ? viteConfigPathTs : viteConfigPathJs;
|
|
176
|
+
if (!targetPath) {
|
|
177
|
+
throw new Error("vite.config.ts/js not found. Ensure you are running this inside a Vite project.");
|
|
178
|
+
}
|
|
179
|
+
writeFileIfChanged(targetPath, VITE_CONFIG_TEMPLATE);
|
|
180
|
+
}
|
|
181
|
+
function setupViteProject(cwd, manager, execCommand) {
|
|
182
|
+
execCommand(installDependencies(manager, ["tailwindcss", "@tailwindcss/vite"]));
|
|
183
|
+
execCommand(installDependencies(manager, ["@types/node"], { dev: true }));
|
|
184
|
+
updateViteFiles(cwd);
|
|
185
|
+
}
|
|
186
|
+
export function initShadcnProject({ cwd, projectType, execCommand }) {
|
|
187
|
+
const packageJson = readPackageJson(cwd);
|
|
188
|
+
const detectedType = projectType ?? detectProjectType(packageJson) ?? null;
|
|
189
|
+
if (!detectedType) {
|
|
190
|
+
throw new Error("Unable to determine project type. Pass --initshadcn <next|vite> or install Next.js / Vite dependencies.");
|
|
191
|
+
}
|
|
192
|
+
const normalizedType = normalizeProjectType(String(detectedType));
|
|
193
|
+
if (!normalizedType) {
|
|
194
|
+
throw new Error(`Unsupported project type "${detectedType}". Expected "next" or "vite".`);
|
|
195
|
+
}
|
|
196
|
+
const manager = detectPackageManager(cwd);
|
|
197
|
+
if (normalizedType === "vite") {
|
|
198
|
+
setupViteProject(cwd, manager, execCommand);
|
|
199
|
+
execCommand(getShadcnInitCommand(manager));
|
|
200
|
+
}
|
|
201
|
+
else if (normalizedType === "next") {
|
|
202
|
+
execCommand(getShadcnInitCommand(manager));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export function determineProjectTypeFromPackageJson(packageJson) {
|
|
206
|
+
return detectProjectType(packageJson);
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=shadcn-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadcn-init.js","sourceRoot":"","sources":["../src/shadcn-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAc7B,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAE1D,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;CAc5B,CAAC;AAEF,SAAS,eAAe,CAAC,GAAW;IAClC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;Q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I,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,YAAY,+BAA+B,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;QAC9B,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAC5C,WAAW,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;QACrC,WAAW,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,WAAoC;IACtF,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ export interface FileEntry {
|
|
|
10
10
|
path: string;
|
|
11
11
|
content: string;
|
|
12
12
|
}
|
|
13
|
+
export type DiffFileType = "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:lib" | "registry:page" | "registry:file" | "registry:style" | "registry:theme" | "registry:item";
|
|
13
14
|
export interface DiffFile {
|
|
14
15
|
path: string;
|
|
15
16
|
content: string;
|
|
16
|
-
type:
|
|
17
|
+
type: DiffFileType;
|
|
17
18
|
target?: string;
|
|
18
19
|
}
|
|
19
20
|
export interface DiffResult {
|
|
@@ -31,4 +32,11 @@ export interface AlteredFilesResult {
|
|
|
31
32
|
alteredFiles: FileEntry[];
|
|
32
33
|
specificFiles: Record<string, string>;
|
|
33
34
|
}
|
|
35
|
+
export interface RegistryFile {
|
|
36
|
+
$schema: string;
|
|
37
|
+
name: string;
|
|
38
|
+
homepage: string;
|
|
39
|
+
items: DiffResult[];
|
|
40
|
+
}
|
|
41
|
+
export type ProjectType = "next" | "vite";
|
|
34
42
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,eAAe,GACf,cAAc,GACd,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,CAAC;AAEpB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "components-differ",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Simple CLI to create Shadcn components from project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,12 +22,6 @@
|
|
|
22
22
|
"typescript": "^5.9.3",
|
|
23
23
|
"vitest": "^4.0.8"
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc --project tsconfig.json",
|
|
27
|
-
"bump": "node scripts/bump-version.mjs",
|
|
28
|
-
"test": "vitest run",
|
|
29
|
-
"test:watch": "vitest"
|
|
30
|
-
},
|
|
31
25
|
"repository": {
|
|
32
26
|
"type": "git",
|
|
33
27
|
"url": "git+https://github.com/componentshost/components-differ.git"
|
|
@@ -44,5 +38,11 @@
|
|
|
44
38
|
"bugs": {
|
|
45
39
|
"url": "https://github.com/componentshost/components-differ/issues"
|
|
46
40
|
},
|
|
47
|
-
"homepage": "https://github.com/componentshost/components-differ#readme"
|
|
41
|
+
"homepage": "https://github.com/componentshost/components-differ#readme",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc --project tsconfig.json",
|
|
44
|
+
"bump": "node scripts/bump-version.mjs",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest"
|
|
47
|
+
}
|
|
48
48
|
}
|