@nx-extend/shadcn-ui 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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ # 0.1.0 (2024-01-18)
6
+
7
+
8
+ ### Features
9
+
10
+ * **shadcn-ui:** Added `add` executor to add new components ([eac038e](https://github.com/TriPSs/nx-extend/commit/eac038e97a673493a249a6c2a5d639f54d816453))
11
+ * **shadcn-ui:** Added package ([954889d](https://github.com/TriPSs/nx-extend/commit/954889dff1b7b618a002b6f38ba62f8254806232))
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @nx-extend/shadcn-ui
2
+
3
+ <a href="https://www.npmjs.com/package/@nx-extend/shadcn-ui" rel="nofollow">
4
+ <img src="https://badgen.net/npm/v/@nx-extend/shadcn-ui" alt="@nx-extend/shadcn-ui NPM package">
5
+ </a>
6
+
7
+ **Nx plugin for working with [shadcn/ui](https://ui.shadcn.com/)**.
8
+
9
+ ## Setup
10
+
11
+ ### Install
12
+
13
+ ```sh
14
+ npm install -D @nx-extend/shadcn-ui
15
+ nx g @nx-extend/shadcn-ui:init
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Add
21
+
22
+ ```sh
23
+ nx g @nx-extend/shadcn-ui:add button
24
+ ```
package/executors.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "executors": {
3
+ "add": {
4
+ "implementation": "./src/executors/add/add.impl",
5
+ "schema": "./src/executors/add/schema.json",
6
+ "description": "add executor"
7
+ }
8
+ },
9
+ "builders": {
10
+ "add": {
11
+ "implementation": "./src/executors/add/add.impl",
12
+ "schema": "./src/executors/add/schema.json",
13
+ "description": "add executor"
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "name": "shadcn-ui",
4
+ "version": "0.0.1",
5
+ "generators": {
6
+ "init": {
7
+ "factory": "./src/generators/init/init.impl",
8
+ "schema": "./src/generators/init/schema.json",
9
+ "description": "init generator"
10
+ }
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@nx-extend/shadcn-ui",
3
+ "version": "0.1.0",
4
+ "keywords": [
5
+ "nx",
6
+ "shadcn-ui"
7
+ ],
8
+ "homepage": "https://github.com/TriPSs/nx-extend/blob/master/packages/shadcn-ui/README.md",
9
+ "bugs": {
10
+ "url": "https://github.com/tripss/nx-extend/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/tripss/nx-extend"
15
+ },
16
+ "license": "MIT",
17
+ "main": "./src/index.js",
18
+ "devDependencies": {
19
+ "class-variance-authority": "^0.7.0",
20
+ "clsx": "^2.1.0",
21
+ "lucide-react": "^0.312.0",
22
+ "tailwind-merge": "^2.2.0",
23
+ "tailwindcss-animate": "^1.0.7"
24
+ },
25
+ "builders": "./executors.json",
26
+ "generators": "./generators.json",
27
+ "dependencies": {
28
+ "@nx/devkit": "17.2.7",
29
+ "@nx/workspace": "17.2.7",
30
+ "class-variance-authority": "0.7.0",
31
+ "clsx": "2.1.0",
32
+ "lucide-react": "0.312.0",
33
+ "shelljs": "^0.8.5",
34
+ "tailwind-merge": "2.2.0",
35
+ "tailwindcss-animate": "1.0.7",
36
+ "@nx-extend/core": "5.2.1",
37
+ "tslib": "2.6.2"
38
+ },
39
+ "type": "commonjs"
40
+ }
@@ -0,0 +1,9 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ export interface ExecutorSchema {
3
+ component: string;
4
+ overwrite?: boolean;
5
+ }
6
+ export declare function addExecutor(options: ExecutorSchema, context: ExecutorContext): Promise<{
7
+ success: boolean;
8
+ }>;
9
+ export default addExecutor;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addExecutor = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@nx-extend/core");
6
+ function addExecutor(options, context) {
7
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
+ const { root } = context.workspace.projects[context.projectName];
9
+ return (0, core_1.execCommand)((0, core_1.buildCommand)([
10
+ 'npx shadcn-ui@latest add',
11
+ options.component,
12
+ options.overwrite && '--overwrite',
13
+ '--path=src',
14
+ `--cwd=${root}`
15
+ ]), {});
16
+ });
17
+ }
18
+ exports.addExecutor = addExecutor;
19
+ exports.default = addExecutor;
20
+ //# sourceMappingURL=add.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.impl.js","sourceRoot":"","sources":["../../../../../../packages/shadcn-ui/src/executors/add/add.impl.ts"],"names":[],"mappings":";;;;AACA,0CAA2D;AAO3D,SAAsB,WAAW,CAC/B,OAAuB,EACvB,OAAwB;;QAExB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAEhE,OAAO,IAAA,kBAAW,EAAC,IAAA,mBAAY,EAAC;YAC9B,0BAA0B;YAC1B,OAAO,CAAC,SAAS;YACjB,OAAO,CAAC,SAAS,IAAI,aAAa;YAClC,YAAY;YACZ,SAAS,IAAI,EAAE;SAChB,CAAC,EAAC,EAEF,CAAC,CAAA;IACJ,CAAC;CAAA;AAfD,kCAeC;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { ExecutorContext } from '@nx/devkit'
2
+ import { buildCommand, execCommand } from '@nx-extend/core'
3
+
4
+ export interface ExecutorSchema {
5
+ component: string
6
+ overwrite?: boolean
7
+ }
8
+
9
+ export async function addExecutor(
10
+ options: ExecutorSchema,
11
+ context: ExecutorContext
12
+ ): Promise<{ success: boolean }> {
13
+ const { root } = context.workspace.projects[context.projectName]
14
+
15
+ return execCommand(buildCommand([
16
+ 'npx shadcn-ui@latest add',
17
+ options.component,
18
+ options.overwrite && '--overwrite',
19
+ '--path=src',
20
+ `--cwd=${root}`
21
+ ]),{
22
+
23
+ })
24
+ }
25
+
26
+ export default addExecutor
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const add_impl_1 = require("./add.impl");
5
+ exports.default = (0, devkit_1.convertNxExecutor)(add_impl_1.addExecutor);
6
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../packages/shadcn-ui/src/executors/add/compat.ts"],"names":[],"mappings":";;AAAA,uCAA8C;AAE9C,yCAAwC;AAExC,kBAAe,IAAA,0BAAiB,EAAC,sBAAW,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "$schema": "http://json-schema.org/schema",
5
+ "type": "object",
6
+ "title": "add executor",
7
+ "description": "",
8
+ "properties": {
9
+ "component": {
10
+ "type": "string",
11
+ "description": "",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What component would you like to add?"
17
+ }
18
+ },
19
+ "required": [
20
+ "component"
21
+ ]
22
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ export const cn = function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Don't forget to update your APPs global.css to include this file!
3
+ */
4
+
5
+ @tailwind base;
6
+ @tailwind components;
7
+ @tailwind utilities;
8
+
9
+ @layer base {
10
+ :root {
11
+ --background: 0 0% 100%;
12
+ --foreground: 240 10% 3.9%;
13
+ --card: 0 0% 100%;
14
+ --card-foreground: 240 10% 3.9%;
15
+ --popover: 0 0% 100%;
16
+ --popover-foreground: 240 10% 3.9%;
17
+ --primary: 240 5.9% 10%;
18
+ --primary-foreground: 0 0% 98%;
19
+ --secondary: 240 4.8% 95.9%;
20
+ --secondary-foreground: 240 5.9% 10%;
21
+ --muted: 240 4.8% 95.9%;
22
+ --muted-foreground: 240 3.8% 46.1%;
23
+ --accent: 240 4.8% 95.9%;
24
+ --accent-foreground: 240 5.9% 10%;
25
+ --destructive: 0 84.2% 60.2%;
26
+ --destructive-foreground: 0 0% 98%;
27
+ --border: 240 5.9% 90%;
28
+ --input: 240 5.9% 90%;
29
+ --ring: 240 5.9% 10%;
30
+ --radius: 0.5rem;
31
+ }
32
+
33
+ .dark {
34
+ --background: 240 10% 3.9%;
35
+ --foreground: 0 0% 98%;
36
+ --card: 240 10% 3.9%;
37
+ --card-foreground: 0 0% 98%;
38
+ --popover: 240 10% 3.9%;
39
+ --popover-foreground: 0 0% 98%;
40
+ --primary: 0 0% 98%;
41
+ --primary-foreground: 240 5.9% 10%;
42
+ --secondary: 240 3.7% 15.9%;
43
+ --secondary-foreground: 0 0% 98%;
44
+ --muted: 240 3.7% 15.9%;
45
+ --muted-foreground: 240 5% 64.9%;
46
+ --accent: 240 3.7% 15.9%;
47
+ --accent-foreground: 0 0% 98%;
48
+ --destructive: 0 62.8% 30.6%;
49
+ --destructive-foreground: 0 0% 98%;
50
+ --border: 240 3.7% 15.9%;
51
+ --input: 240 3.7% 15.9%;
52
+ --ring: 240 4.9% 83.9%;
53
+ }
54
+ }
55
+
56
+ @layer base {
57
+ * {
58
+ @apply border-border;
59
+ }
60
+ body {
61
+ @apply bg-background text-foreground;
62
+ font-feature-settings: "rlig" 1, "calt" 1;
63
+ }
64
+ }
@@ -0,0 +1 @@
1
+ export * from './cn'
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Don't forget to update your APPs tailwind.config.js to include this file!
3
+ */
4
+ const { join } = require('path');
5
+
6
+ const defaultTheme = require('tailwindcss/defaultTheme');
7
+ const TailwindAnimate = require('tailwindcss-animate');
8
+
9
+ module.exports = {
10
+ content: [
11
+ join(
12
+ __dirname,
13
+ '{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}'
14
+ ),
15
+ ...createGlobPatternsForDependencies(__dirname),
16
+ ],
17
+ theme: {
18
+ extend: {
19
+ colors: {
20
+ border: 'hsl(var(--border))',
21
+ input: 'hsl(var(--input))',
22
+ ring: 'hsl(var(--ring))',
23
+ background: 'hsl(var(--background))',
24
+ foreground: 'hsl(var(--foreground))',
25
+ primary: {
26
+ DEFAULT: 'hsl(var(--primary))',
27
+ foreground: 'hsl(var(--primary-foreground))',
28
+ },
29
+ secondary: {
30
+ DEFAULT: 'hsl(var(--secondary))',
31
+ foreground: 'hsl(var(--secondary-foreground))',
32
+ },
33
+ destructive: {
34
+ DEFAULT: 'hsl(var(--destructive))',
35
+ foreground: 'hsl(var(--destructive-foreground))',
36
+ },
37
+ muted: {
38
+ DEFAULT: 'hsl(var(--muted))',
39
+ foreground: 'hsl(var(--muted-foreground))',
40
+ },
41
+ accent: {
42
+ DEFAULT: 'hsl(var(--accent))',
43
+ foreground: 'hsl(var(--accent-foreground))',
44
+ },
45
+ popover: {
46
+ DEFAULT: 'hsl(var(--popover))',
47
+ foreground: 'hsl(var(--popover-foreground))',
48
+ },
49
+ card: {
50
+ DEFAULT: 'hsl(var(--card))',
51
+ foreground: 'hsl(var(--card-foreground))',
52
+ },
53
+ },
54
+ borderRadius: {
55
+ lg: `var(--radius)`,
56
+ md: `calc(var(--radius) - 2px)`,
57
+ sm: 'calc(var(--radius) - 4px)',
58
+ },
59
+ keyframes: {
60
+ 'accordion-down': {
61
+ from: { height: 0 },
62
+ to: { height: 'var(--radix-accordion-content-height)' },
63
+ },
64
+ 'accordion-up': {
65
+ from: { height: 'var(--radix-accordion-content-height)' },
66
+ to: { height: 0 },
67
+ },
68
+ },
69
+ animation: {
70
+ 'accordion-down': 'accordion-down 0.2s ease-out',
71
+ 'accordion-up': 'accordion-up 0.2s ease-out',
72
+ },
73
+ },
74
+ },
75
+ plugins: [TailwindAnimate],
76
+ darkMode: ['class'],
77
+ };
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import type { ShadecnUiSchema } from './schema';
3
+ export default function (tree: Tree, options: ShadecnUiSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nx/devkit");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const js_1 = require("@nx/js");
7
+ const path_1 = require("path");
8
+ const package_json_1 = require("../../../package.json");
9
+ function cleanupLib(tree, libDirectory) {
10
+ // Remove the unneeded files
11
+ tree.delete(`${libDirectory}/package.json`);
12
+ tree.delete(`${libDirectory}/src/index.ts`);
13
+ const libFiles = tree.children(`${libDirectory}/src/lib`);
14
+ for (const file of libFiles) {
15
+ tree.delete(`${libDirectory}/src/lib/${file}`);
16
+ }
17
+ }
18
+ function addFilesToUtilsLib(host, libDirectory) {
19
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files-utils'), libDirectory, {
20
+ template: ''
21
+ });
22
+ }
23
+ function getLibRoot(host, fileName) {
24
+ return (0, devkit_1.joinPathFragments)((0, devkit_1.getWorkspaceLayout)(host).libsDir, fileName);
25
+ }
26
+ function default_1(tree, options) {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
+ yield (0, js_1.libraryGenerator)(tree, {
29
+ name: options.uiName,
30
+ skipFormat: true
31
+ });
32
+ const uiLibOptions = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
33
+ callingGenerator: '@nx-extend/shadcn-ui:init',
34
+ name: options.uiName,
35
+ projectType: 'library'
36
+ });
37
+ const uiRoot = getLibRoot(tree, uiLibOptions.projectRoot);
38
+ (0, js_1.addTsConfigPath)(tree, `${uiLibOptions.importPath}/*`, [`${uiRoot}/src/*`]);
39
+ cleanupLib(tree, uiRoot);
40
+ yield (0, js_1.libraryGenerator)(tree, {
41
+ name: options.utilsName,
42
+ skipFormat: true
43
+ });
44
+ const utilsLibOptions = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
45
+ callingGenerator: '@nx-extend/shadcn-ui:init',
46
+ name: options.utilsName,
47
+ projectType: 'library'
48
+ });
49
+ const utilRoot = getLibRoot(tree, utilsLibOptions.projectRoot);
50
+ (0, js_1.addTsConfigPath)(tree, `${utilsLibOptions.importPath}/*`, [`${utilRoot}/src/*`]);
51
+ cleanupLib(tree, utilRoot);
52
+ addFilesToUtilsLib(tree, `${getLibRoot(tree, options.utilsName)}/src`);
53
+ (0, devkit_1.writeJson)(tree, 'components.json', {
54
+ '$schema': 'https://ui.shadcn.com/schema.json',
55
+ 'style': 'default',
56
+ 'rsc': false,
57
+ 'tailwind': {
58
+ 'config': (0, path_1.join)(utilRoot, 'tailwind.config.js'),
59
+ 'css': (0, path_1.join)(utilRoot, 'global.css'),
60
+ 'baseColor': 'neutral',
61
+ 'cssVariables': true
62
+ },
63
+ 'aliases': {
64
+ 'components': uiLibOptions.importPath,
65
+ 'utils': utilsLibOptions.importPath
66
+ }
67
+ });
68
+ (0, devkit_1.updateProjectConfiguration)(tree, uiLibOptions.projectName, Object.assign(Object.assign({}, (0, devkit_1.readProjectConfiguration)(tree, uiLibOptions.projectName)), { targets: {
69
+ add: {
70
+ executor: '@nx-extend/shadcn-ui:add'
71
+ }
72
+ } }));
73
+ return (0, devkit_1.runTasksInSerial)((0, devkit_1.addDependenciesToPackageJson)(tree, {
74
+ 'class-variance-authority': package_json_1.devDependencies['class-variance-authority'],
75
+ 'clsx': package_json_1.devDependencies['clsx'],
76
+ 'lucide-react': package_json_1.devDependencies['lucide-react'],
77
+ 'tailwind-merge': package_json_1.devDependencies['tailwind-merge'],
78
+ 'tailwindcss-animate': package_json_1.devDependencies['tailwindcss-animate']
79
+ }, {}));
80
+ });
81
+ }
82
+ exports.default = default_1;
83
+ //# sourceMappingURL=init.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.impl.js","sourceRoot":"","sources":["../../../../../../packages/shadcn-ui/src/generators/init/init.impl.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,112 @@
1
+ import {
2
+ addDependenciesToPackageJson,
3
+ generateFiles,
4
+ getWorkspaceLayout,
5
+ joinPathFragments, readProjectConfiguration,
6
+ runTasksInSerial,
7
+ Tree, updateProjectConfiguration, writeJson
8
+ } from '@nx/devkit'
9
+ import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils'
10
+ import { addTsConfigPath, libraryGenerator } from '@nx/js'
11
+ import { join } from 'path'
12
+
13
+ import type { ShadecnUiSchema } from './schema'
14
+
15
+ import { devDependencies } from '../../../package.json'
16
+
17
+ function cleanupLib(tree: Tree, libDirectory: string) {
18
+ // Remove the unneeded files
19
+ tree.delete(`${libDirectory}/package.json`)
20
+ tree.delete(`${libDirectory}/src/index.ts`)
21
+ const libFiles = tree.children(`${libDirectory}/src/lib`)
22
+
23
+ for (const file of libFiles) {
24
+ tree.delete(`${libDirectory}/src/lib/${file}`)
25
+ }
26
+ }
27
+
28
+ function addFilesToUtilsLib(host: Tree, libDirectory: string) {
29
+ generateFiles(host, join(__dirname, 'files-utils'), libDirectory, {
30
+ template: ''
31
+ })
32
+ }
33
+
34
+ function getLibRoot(host: Tree, fileName: string) {
35
+ return joinPathFragments(
36
+ getWorkspaceLayout(host).libsDir,
37
+ fileName
38
+ )
39
+ }
40
+
41
+ export default async function (tree: Tree, options: ShadecnUiSchema) {
42
+ await libraryGenerator(tree, {
43
+ name: options.uiName,
44
+ skipFormat: true
45
+ })
46
+
47
+ const uiLibOptions = await determineProjectNameAndRootOptions(tree, {
48
+ callingGenerator: '@nx-extend/shadcn-ui:init',
49
+ name: options.uiName,
50
+ projectType: 'library'
51
+ })
52
+
53
+ const uiRoot = getLibRoot(tree, uiLibOptions.projectRoot)
54
+ addTsConfigPath(tree, `${uiLibOptions.importPath}/*`, [`${uiRoot}/src/*`])
55
+ cleanupLib(tree, uiRoot)
56
+
57
+ await libraryGenerator(tree, {
58
+ name: options.utilsName,
59
+ skipFormat: true
60
+ })
61
+
62
+ const utilsLibOptions = await determineProjectNameAndRootOptions(tree, {
63
+ callingGenerator: '@nx-extend/shadcn-ui:init',
64
+ name: options.utilsName,
65
+ projectType: 'library'
66
+ })
67
+
68
+ const utilRoot = getLibRoot(tree, utilsLibOptions.projectRoot)
69
+ addTsConfigPath(tree, `${utilsLibOptions.importPath}/*`, [`${utilRoot}/src/*`])
70
+ cleanupLib(tree, utilRoot)
71
+
72
+ addFilesToUtilsLib(tree, `${getLibRoot(tree, options.utilsName)}/src`)
73
+
74
+ writeJson(tree, 'components.json', {
75
+ '$schema': 'https://ui.shadcn.com/schema.json',
76
+ 'style': 'default',
77
+ 'rsc': false,
78
+ 'tailwind': {
79
+ 'config': join(utilRoot, 'tailwind.config.js'),
80
+ 'css': join(utilRoot, 'global.css'),
81
+ 'baseColor': 'neutral',
82
+ 'cssVariables': true
83
+ },
84
+ 'aliases': {
85
+ 'components': uiLibOptions.importPath,
86
+ 'utils': utilsLibOptions.importPath
87
+ }
88
+ })
89
+
90
+ updateProjectConfiguration(tree, uiLibOptions.projectName, {
91
+ ...readProjectConfiguration(tree, uiLibOptions.projectName),
92
+ targets: {
93
+ add: {
94
+ executor: '@nx-extend/shadcn-ui:add'
95
+ }
96
+ }
97
+ })
98
+
99
+ return runTasksInSerial(
100
+ addDependenciesToPackageJson(
101
+ tree,
102
+ {
103
+ 'class-variance-authority': devDependencies['class-variance-authority'],
104
+ 'clsx': devDependencies['clsx'],
105
+ 'lucide-react': devDependencies['lucide-react'],
106
+ 'tailwind-merge': devDependencies['tailwind-merge'],
107
+ 'tailwindcss-animate': devDependencies['tailwindcss-animate']
108
+ },
109
+ {}
110
+ )
111
+ )
112
+ }
@@ -0,0 +1,4 @@
1
+ export interface ShadecnUiSchema {
2
+ uiName: string
3
+ utilsName: string
4
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "id": "Strapi",
5
+ "title": "",
6
+ "properties": {
7
+ "uiName": {
8
+ "type": "string",
9
+ "description": "",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use for the ui lib?"
15
+ },
16
+ "utilsName": {
17
+ "type": "string",
18
+ "description": "",
19
+ "$default": {
20
+ "$source": "argv",
21
+ "index": 1
22
+ },
23
+ "x-prompt": "What name would you like to use for the utils lib?"
24
+ }
25
+ },
26
+ "required": [
27
+ "uiName",
28
+ "utilsName"
29
+ ]
30
+ }
package/src/index.d.ts ADDED
File without changes
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/shadcn-ui/src/index.ts"],"names":[],"mappings":""}