@jsrepo/shadcn 0.0.1-beta.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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/output-CKieuEU1.d.ts +10 -0
- package/dist/output-DDcMhxlx.js +3783 -0
- package/dist/output.d.ts +2 -0
- package/dist/output.js +3 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jsrepo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @jsrepo/shadcn
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@jsrepo/shadcn)
|
|
4
|
+
[](https://npmjs.com/package/@jsrepo/shadcn)
|
|
5
|
+
|
|
6
|
+
A package to help you distribute your jsrepo registry as a shadcn registry.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Install the package:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pnpm install @jsrepo/shadcn
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use the output to output a shadcn registry:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { defineConfig } from "jsrepo";
|
|
20
|
+
import { output } from "@jsrepo/shadcn/output";
|
|
21
|
+
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
registry: {
|
|
24
|
+
// ...
|
|
25
|
+
outputs: [output({ dir: "./public/r/shadcn" })],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
> [!IMPORTANT]
|
|
31
|
+
> If you have multiple outputs you need to ensure that the directory is unique for each output. jsrepo outputs will conflict with shadcn outputs.
|
|
32
|
+
|
|
33
|
+
If you want to ensure compatibility with the shadcn registry while losing access to some of the features of the jsrepo registry you can use the `defineShadcnRegistry` function. This can also be useful for incremental adoption as it closely matches the shadcn registry schema.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { defineShadcnRegistry, output } from "@jsrepo/shadcn";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
registry: defineShadcnRegistry({
|
|
40
|
+
// ...
|
|
41
|
+
// make sure you still include the output
|
|
42
|
+
outputs: [output({ dir: "./public/r/shadcn" })],
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { n as output, t as OutputOptions } from "./output-CKieuEU1.js";
|
|
2
|
+
import { Output, RegistryConfig } from "jsrepo";
|
|
3
|
+
import { registryItemTypeSchema } from "shadcn/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
type ShadcnRegistryItemType = (typeof registryItemTypeSchema.options)[number];
|
|
7
|
+
type ShadcnRegistry = {
|
|
8
|
+
name: string;
|
|
9
|
+
homepage: string;
|
|
10
|
+
excludeDeps: string[];
|
|
11
|
+
items: ShadcnRegistryItem[];
|
|
12
|
+
outputs: Output[];
|
|
13
|
+
};
|
|
14
|
+
type ShadcnRegistryItem = {
|
|
15
|
+
name: string;
|
|
16
|
+
type: ShadcnRegistryItemType;
|
|
17
|
+
description?: string;
|
|
18
|
+
files: Array<{
|
|
19
|
+
path: string;
|
|
20
|
+
type: 'registry:file' | 'registry:page';
|
|
21
|
+
target: string;
|
|
22
|
+
} | {
|
|
23
|
+
path: string;
|
|
24
|
+
type: Exclude<ShadcnRegistryItemType, 'registry:file' | 'registry:page'>;
|
|
25
|
+
target?: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Requires that all dependencies of the item must be part of the registry.
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
strict?: boolean;
|
|
33
|
+
/** Whether the dependency resolution should be automatic or manual. @default "auto" */
|
|
34
|
+
dependencyResolution?: 'auto' | 'manual';
|
|
35
|
+
registryDependencies?: string[];
|
|
36
|
+
dependencies?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Environment variables that are required for the item to work. These will be added to the users `.env` or `.env.local` file. NEVER ADD SECRETS HERE.
|
|
39
|
+
*/
|
|
40
|
+
envVars?: Record<string, string>;
|
|
41
|
+
};
|
|
42
|
+
declare function defineShadcnRegistry(registry: ShadcnRegistry): RegistryConfig;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { OutputOptions, ShadcnRegistry, ShadcnRegistryItem, ShadcnRegistryItemType, defineShadcnRegistry, output };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { t as output } from "./output-DDcMhxlx.js";
|
|
2
|
+
import { JsrepoError } from "jsrepo";
|
|
3
|
+
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Adapted from https://github.com/egoist/parse-package-name/blob/main/src/index.ts
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
const RE_SCOPED = /^(@[^/]+\/[^@/]+)(?:@([^/]+))?(\/.*)?$/;
|
|
10
|
+
const RE_NON_SCOPED = /^([^@/]+)(?:@([^/]+))?(\/.*)?$/;
|
|
11
|
+
function parsePackageName(input) {
|
|
12
|
+
const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);
|
|
13
|
+
if (!m) return void 0;
|
|
14
|
+
return {
|
|
15
|
+
name: m[1] || "",
|
|
16
|
+
version: m[2] || void 0,
|
|
17
|
+
path: m[3] || ""
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/index.ts
|
|
23
|
+
function defineShadcnRegistry(registry) {
|
|
24
|
+
return {
|
|
25
|
+
...registry,
|
|
26
|
+
items: registry.items.map((item) => {
|
|
27
|
+
return {
|
|
28
|
+
...item,
|
|
29
|
+
remoteDependencies: item.dependencies?.map((dependency) => {
|
|
30
|
+
const parsed = parsePackageName(dependency);
|
|
31
|
+
if (parsed === void 0) throw new JsrepoError(`Invalid package name: ${dependency}`, { suggestion: "Please provide a valid package name." });
|
|
32
|
+
return {
|
|
33
|
+
ecosystem: "js",
|
|
34
|
+
name: parsed.name,
|
|
35
|
+
version: parsed.version
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { defineShadcnRegistry, output };
|