shadcn-nuxt 2.0.1 → 2.2.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/dist/module.d.mts +4 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +13 -29
- package/dist/types.d.mts +1 -1
- package/package.json +11 -13
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -16
- package/dist/types.d.ts +0 -1
package/dist/module.d.mts
CHANGED
|
@@ -3,11 +3,14 @@ import * as _nuxt_schema from '@nuxt/schema';
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Prefix for all the imported component.
|
|
6
|
+
* @default "Ui"
|
|
6
7
|
*/
|
|
7
8
|
prefix?: string;
|
|
8
9
|
/**
|
|
9
10
|
* Directory that the component lives in.
|
|
10
|
-
*
|
|
11
|
+
* Will respect the Nuxt aliases.
|
|
12
|
+
* @link https://nuxt.com/docs/api/nuxt-config#alias
|
|
13
|
+
* @default "@/components/ui"
|
|
11
14
|
*/
|
|
12
15
|
componentDir?: string;
|
|
13
16
|
}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { defineNuxtModule, createResolver,
|
|
4
|
-
import { parseSync } from '
|
|
5
|
-
|
|
6
|
-
const UTILS = `import { type ClassValue, clsx } from 'clsx'
|
|
7
|
-
import { twMerge } from 'tailwind-merge'
|
|
8
|
-
|
|
9
|
-
export function cn(...inputs: ClassValue[]) {
|
|
10
|
-
return twMerge(clsx(inputs))
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
3
|
+
import { defineNuxtModule, createResolver, addComponent } from '@nuxt/kit';
|
|
4
|
+
import { parseSync } from 'oxc-parser';
|
|
13
5
|
|
|
14
6
|
const module = defineNuxtModule({
|
|
15
7
|
meta: {
|
|
@@ -18,24 +10,17 @@ const module = defineNuxtModule({
|
|
|
18
10
|
},
|
|
19
11
|
defaults: {
|
|
20
12
|
prefix: "Ui",
|
|
21
|
-
componentDir: "
|
|
13
|
+
componentDir: "@/components/ui"
|
|
22
14
|
},
|
|
23
15
|
async setup({ prefix, componentDir }, nuxt) {
|
|
24
16
|
const COMPONENT_DIR_PATH = componentDir;
|
|
25
17
|
const ROOT_DIR_PATH = nuxt.options.rootDir;
|
|
26
|
-
const UTILS_ALIAS = "@/lib/utils";
|
|
27
18
|
const { resolve, resolvePath } = createResolver(ROOT_DIR_PATH);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
nuxt.options.alias = { [UTILS_ALIAS]: utilsTemplate.dst, ...nuxt.options.alias };
|
|
35
|
-
const isRootUtilsExists = await findPath("./lib/utils.ts", { cwd: ROOT_DIR_PATH });
|
|
36
|
-
if (isRootUtilsExists)
|
|
37
|
-
logger.warn("[shadcn-nuxt] `lib/utils.ts` is auto generated by the module and can be safely removed.");
|
|
38
|
-
const componentsPath = resolve(COMPONENT_DIR_PATH);
|
|
19
|
+
const componentsPath = await resolvePath(COMPONENT_DIR_PATH);
|
|
20
|
+
if (!existsSync(componentsPath)) {
|
|
21
|
+
console.warn(`Component directory does not exist: ${componentsPath}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
39
24
|
nuxt.hook("components:dirs", (dirs) => {
|
|
40
25
|
dirs.unshift({
|
|
41
26
|
path: componentsPath,
|
|
@@ -43,15 +28,14 @@ const module = defineNuxtModule({
|
|
|
43
28
|
});
|
|
44
29
|
});
|
|
45
30
|
try {
|
|
46
|
-
readdirSync(
|
|
31
|
+
readdirSync(componentsPath).forEach(async (dir) => {
|
|
47
32
|
try {
|
|
48
33
|
const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, "index"), { extensions: [".ts", ".js"] });
|
|
49
34
|
const content = readFileSync(filePath, { encoding: "utf8" });
|
|
50
|
-
const ast = parseSync(content, {
|
|
51
|
-
sourceType: "module"
|
|
52
|
-
sourceFilename: filePath
|
|
35
|
+
const ast = parseSync(filePath, content, {
|
|
36
|
+
sourceType: "module"
|
|
53
37
|
});
|
|
54
|
-
const exportedKeys = ast.program.body.filter((node) => node.type === "ExportNamedDeclaration").flatMap((node) => node.specifiers
|
|
38
|
+
const exportedKeys = ast.program.body.filter((node) => node.type === "ExportNamedDeclaration").flatMap((node) => node.specifiers?.map((specifier) => specifier.exported?.name) || []).filter((key) => /^[A-Z]/.test(key));
|
|
55
39
|
exportedKeys.forEach((key) => {
|
|
56
40
|
addComponent({
|
|
57
41
|
name: `${prefix}${key}`,
|
package/dist/types.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type ModuleOptions, default } from './module.
|
|
1
|
+
export { type ModuleOptions, default } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shadcn-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Add shadcn-vue module to Nuxt",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -14,30 +14,28 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./dist/types.d.
|
|
18
|
-
"import": "./dist/module.mjs"
|
|
19
|
-
"require": "./dist/module.cjs"
|
|
17
|
+
"types": "./dist/types.d.mts",
|
|
18
|
+
"import": "./dist/module.mjs"
|
|
20
19
|
}
|
|
21
20
|
},
|
|
22
|
-
"main": "./dist/module.
|
|
23
|
-
"types": "./dist/types.d.ts",
|
|
21
|
+
"main": "./dist/module.mjs",
|
|
24
22
|
"files": [
|
|
25
23
|
"dist"
|
|
26
24
|
],
|
|
27
25
|
"dependencies": {
|
|
28
|
-
"@nuxt/kit": "^3.
|
|
29
|
-
"
|
|
30
|
-
"typescript": "5.6.3"
|
|
26
|
+
"@nuxt/kit": "^3.17.3",
|
|
27
|
+
"oxc-parser": "^0.72.0"
|
|
31
28
|
},
|
|
32
29
|
"devDependencies": {
|
|
33
|
-
"@nuxt/eslint-config": "^1.
|
|
34
|
-
"@nuxt/module-builder": "^0.
|
|
35
|
-
"@nuxt/schema": "^3.
|
|
30
|
+
"@nuxt/eslint-config": "^1.3.1",
|
|
31
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
32
|
+
"@nuxt/schema": "^3.17.3",
|
|
36
33
|
"@nuxt/test-utils": "^3.15.4",
|
|
37
34
|
"@nuxtjs/color-mode": "^3.5.2",
|
|
38
35
|
"@nuxtjs/tailwindcss": "^6.13.1",
|
|
39
36
|
"@types/node": "^22.13.1",
|
|
40
|
-
"nuxt": "^3.
|
|
37
|
+
"nuxt": "^3.17.3",
|
|
38
|
+
"typescript": "^5.8.3"
|
|
41
39
|
},
|
|
42
40
|
"scripts": {
|
|
43
41
|
"dev": "nuxi dev playground",
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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, ModuleOptions, false>;
|
|
15
|
-
|
|
16
|
-
export { type ModuleOptions, _default as default };
|
package/dist/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { type ModuleOptions, default } from './module'
|