shadcn-nuxt 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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +16 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +47 -0
- package/dist/types.d.mts +16 -0
- package/dist/types.d.ts +16 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 radix-vue
|
|
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,93 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Get your module up and running quickly.
|
|
3
|
+
|
|
4
|
+
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
+
- Name: Shadcn Nuxt
|
|
6
|
+
- Package name: shadcn-nuxt
|
|
7
|
+
- Description: My new Nuxt module
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Shadcn Nuxt
|
|
11
|
+
|
|
12
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
13
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
14
|
+
[![License][license-src]][license-href]
|
|
15
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
16
|
+
|
|
17
|
+
Shadcn Vue module for Nuxt.
|
|
18
|
+
|
|
19
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
20
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/radix-vue/shadcn-vue?file=playground%2Fapp.vue) -->
|
|
21
|
+
- [📖 Documentation](https://www.shadcn-vue.com/docs/installation/nuxt.html)
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
<!-- Highlight some of the features your module provide here -->
|
|
26
|
+
- ⛰ Auto-import correct and relevant components
|
|
27
|
+
- more to come...
|
|
28
|
+
|
|
29
|
+
## Quick Setup
|
|
30
|
+
|
|
31
|
+
1. Add `shadcn-nuxt` dependency to your project
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Using pnpm
|
|
35
|
+
pnpm add -D shadcn-nuxt
|
|
36
|
+
|
|
37
|
+
# Using yarn
|
|
38
|
+
yarn add --dev shadcn-nuxt
|
|
39
|
+
|
|
40
|
+
# Using npm
|
|
41
|
+
npm install --save-dev shadcn-nuxt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. Add `shadcn-nuxt` to the `modules` section of `nuxt.config.ts`
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
export default defineNuxtConfig({
|
|
48
|
+
modules: [
|
|
49
|
+
'shadcn-nuxt'
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
That's it! You can now use Shadcn Nuxt in your Nuxt app ✨
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Install dependencies
|
|
60
|
+
npm install
|
|
61
|
+
|
|
62
|
+
# Generate type stubs
|
|
63
|
+
npm run dev:prepare
|
|
64
|
+
|
|
65
|
+
# Develop with the playground
|
|
66
|
+
npm run dev
|
|
67
|
+
|
|
68
|
+
# Build the playground
|
|
69
|
+
npm run dev:build
|
|
70
|
+
|
|
71
|
+
# Run ESLint
|
|
72
|
+
npm run lint
|
|
73
|
+
|
|
74
|
+
# Run Vitest
|
|
75
|
+
npm run test
|
|
76
|
+
npm run test:watch
|
|
77
|
+
|
|
78
|
+
# Release new version
|
|
79
|
+
npm run release
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
<!-- Badges -->
|
|
83
|
+
[npm-version-src]: https://img.shields.io/npm/v/shadcn-nuxt/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
84
|
+
[npm-version-href]: https://npmjs.com/package/shadcn-nuxt
|
|
85
|
+
|
|
86
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/shadcn-nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
87
|
+
[npm-downloads-href]: https://npmjs.com/package/shadcn-nuxt
|
|
88
|
+
|
|
89
|
+
[license-src]: https://img.shields.io/npm/l/shadcn-nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
90
|
+
[license-href]: https://npmjs.com/package/shadcn-nuxt
|
|
91
|
+
|
|
92
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
93
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Prefix for all the imported component
|
|
6
|
+
*/
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Directory that the component lives in.
|
|
10
|
+
* @default "./components/ui"
|
|
11
|
+
*/
|
|
12
|
+
componentDir?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
15
|
+
|
|
16
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Prefix for all the imported component
|
|
6
|
+
*/
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Directory that the component lives in.
|
|
10
|
+
* @default "./components/ui"
|
|
11
|
+
*/
|
|
12
|
+
componentDir?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
15
|
+
|
|
16
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readdirSync } from 'node:fs';
|
|
2
|
+
import { defineNuxtModule, createResolver, addComponent } from '@nuxt/kit';
|
|
3
|
+
import { Project } from 'ts-morph';
|
|
4
|
+
|
|
5
|
+
const module = defineNuxtModule({
|
|
6
|
+
meta: {
|
|
7
|
+
name: "shadcn",
|
|
8
|
+
configKey: "shadcn"
|
|
9
|
+
},
|
|
10
|
+
defaults: {
|
|
11
|
+
prefix: "",
|
|
12
|
+
componentDir: "./components/ui"
|
|
13
|
+
},
|
|
14
|
+
async setup(options, nuxt) {
|
|
15
|
+
const IGNORE_DIR = "**/components/ui";
|
|
16
|
+
const COMPONENT_DIR_PATH = options.componentDir;
|
|
17
|
+
const ROOT_DIR_PATH = nuxt.options.rootDir;
|
|
18
|
+
const { resolve } = createResolver(ROOT_DIR_PATH);
|
|
19
|
+
nuxt.options.ignore.push(IGNORE_DIR);
|
|
20
|
+
nuxt._ignore?.add(IGNORE_DIR);
|
|
21
|
+
nuxt._ignorePatterns?.push(IGNORE_DIR);
|
|
22
|
+
try {
|
|
23
|
+
readdirSync(resolve(COMPONENT_DIR_PATH)).forEach(async (dir) => {
|
|
24
|
+
const filePath = resolve(COMPONENT_DIR_PATH, dir, "index.ts");
|
|
25
|
+
const project = new Project();
|
|
26
|
+
project.addSourceFileAtPath(filePath);
|
|
27
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
28
|
+
const exportedDeclarations = sourceFile.getExportedDeclarations();
|
|
29
|
+
const exportedKeys = Array.from(exportedDeclarations.keys()).filter((key) => /^[A-Z]/.test(key));
|
|
30
|
+
exportedKeys.forEach((key) => {
|
|
31
|
+
addComponent({
|
|
32
|
+
name: `${options.prefix}${key}`,
|
|
33
|
+
// name of the component to be used in vue templates
|
|
34
|
+
export: key,
|
|
35
|
+
// (optional) if the component is a named (rather than default) export
|
|
36
|
+
filePath: resolve(filePath)
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (err instanceof Error)
|
|
42
|
+
console.warn(err.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export { module as default };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import type { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
declare module '@nuxt/schema' {
|
|
6
|
+
interface NuxtConfig { ['shadcn']?: Partial<ModuleOptions> }
|
|
7
|
+
interface NuxtOptions { ['shadcn']?: ModuleOptions }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module 'nuxt/schema' {
|
|
11
|
+
interface NuxtConfig { ['shadcn']?: Partial<ModuleOptions> }
|
|
12
|
+
interface NuxtOptions { ['shadcn']?: ModuleOptions }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type { ModuleOptions, default } from './module'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import type { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
declare module '@nuxt/schema' {
|
|
6
|
+
interface NuxtConfig { ['shadcn']?: Partial<ModuleOptions> }
|
|
7
|
+
interface NuxtOptions { ['shadcn']?: ModuleOptions }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module 'nuxt/schema' {
|
|
11
|
+
interface NuxtConfig { ['shadcn']?: Partial<ModuleOptions> }
|
|
12
|
+
interface NuxtOptions { ['shadcn']?: ModuleOptions }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type { ModuleOptions, default } from './module'
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shadcn-nuxt",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Add shadcn-vue module to Nuxt",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/radix-vue/shadcn-vue.git",
|
|
13
|
+
"directory": "packages/module"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types.d.ts",
|
|
18
|
+
"import": "./dist/module.mjs",
|
|
19
|
+
"require": "./dist/module.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/module.cjs",
|
|
23
|
+
"types": "./dist/types.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@nuxt/kit": "^3.8.2",
|
|
29
|
+
"ts-morph": "^19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@nuxt/devtools": "latest",
|
|
33
|
+
"@nuxt/eslint-config": "^0.2.0",
|
|
34
|
+
"@nuxt/module-builder": "^0.5.4",
|
|
35
|
+
"@nuxt/schema": "^3.8.2",
|
|
36
|
+
"@nuxt/test-utils": "^3.8.1",
|
|
37
|
+
"@types/node": "^20.9.3",
|
|
38
|
+
"nuxt": "^3.8.2",
|
|
39
|
+
"vitest": "^0.33.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"dev": "nuxi dev playground",
|
|
43
|
+
"dev:build": "nuxi build playground",
|
|
44
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest watch",
|
|
48
|
+
"release": "pnpm run prepack && pnpm publish && git push --follow-tags"
|
|
49
|
+
}
|
|
50
|
+
}
|