-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
743 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
displayName: 'shadcn-ui-e2e', | ||
preset: '../../jest.preset.js', | ||
globals: {}, | ||
transform: { | ||
'^.+\\.[tj]s$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig.spec.json' | ||
} | ||
] | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/e2e/shadcn-ui-e2e' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "shadcn-ui-e2e", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"sourceRoot": "e2e/shadcn-ui-e2e/src", | ||
"targets": { | ||
"e2e": { | ||
"executor": "@nx/jest:jest", | ||
"options": { | ||
"jestConfig": "e2e/shadcn-ui-e2e/jest.config.ts", | ||
"runInBand": true, | ||
"passWithNoTests": false | ||
}, | ||
"dependsOn": ["shadcn-ui:build"] | ||
} | ||
}, | ||
"tags": [], | ||
"implicitDependencies": ["shadcn-ui"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ensureNxProject } from '../../utils/workspace' | ||
import { runNxCommandAsync } from '../../utils/run-nx-command-async' | ||
import { checkFilesExist } from '@nx/plugin/testing' | ||
|
||
describe('shadcn/ui e2e', () => { | ||
|
||
beforeAll(() => ensureNxProject([ | ||
'@nx-extend/core:dist/packages/core', | ||
'@nx-extend/shadcn-ui:dist/packages/shadcn-ui' | ||
])) | ||
|
||
const uiLibName = 'shadcn-ui/ui' | ||
const utilsLibName = 'shadcn-ui/utils' | ||
|
||
it('should be able to init', async () => { | ||
await runNxCommandAsync(`generate @nx-extend/shadcn-ui:init ${uiLibName} ${utilsLibName}`) | ||
|
||
expect(() => checkFilesExist( | ||
`${utilsLibName}/src/tailwind.config.js`, | ||
`${utilsLibName}/src/global.css`, | ||
`${utilsLibName}/src/cn.ts`, | ||
`${utilsLibName}/src/index.ts`, | ||
'components.json' | ||
)).not.toThrow() | ||
}) | ||
|
||
// it('should be able add a button', async () => { | ||
// await runNxCommandAsync(`add ${uiLibName} button`) | ||
// | ||
// expect(() => checkFilesExist( | ||
// `${uiLibName}/src/button.tsx`, | ||
// )).not.toThrow() | ||
// }) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.e2e.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.spec.ts", "**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"extends": "../../.eslintrc.json", | ||
"ignorePatterns": [ | ||
"!**/*" | ||
], | ||
"rules": {}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"parserOptions": { | ||
"project": [ | ||
"packages/shadcn-ui/tsconfig.*?.json" | ||
] | ||
}, | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# @nx-extend/shadcn-ui | ||
|
||
<a href="https://www.npmjs.com/package/@nx-extend/shadcn-ui" rel="nofollow"> | ||
<img src="https://badgen.net/npm/v/@nx-extend/shadcn-ui" alt="@nx-extend/shadcn-ui NPM package"> | ||
</a> | ||
|
||
**Nx plugin for working with [shadcn/ui](https://ui.shadcn.com/)**. | ||
|
||
## Setup | ||
|
||
### Install | ||
|
||
```sh | ||
npm install -D @nx-extend/shadcn-ui | ||
nx g @nx-extend/shadcn-ui:init | ||
``` | ||
|
||
## Usage | ||
|
||
### Add | ||
|
||
```sh | ||
nx g @nx-extend/shadcn-ui:add button | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"executors": { | ||
"add": { | ||
"implementation": "./src/executors/add/add.impl", | ||
"schema": "./src/executors/add/schema.json", | ||
"description": "add executor" | ||
} | ||
}, | ||
"builders": { | ||
"add": { | ||
"implementation": "./src/executors/add/add.impl", | ||
"schema": "./src/executors/add/schema.json", | ||
"description": "add executor" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://json-schema.org/schema", | ||
"name": "shadcn-ui", | ||
"version": "0.0.1", | ||
"generators": { | ||
"init": { | ||
"factory": "./src/generators/init/init.impl", | ||
"schema": "./src/generators/init/schema.json", | ||
"description": "init generator" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'shadcn-ui', | ||
preset: '../../jest.preset.js', | ||
globals: {}, | ||
transform: { | ||
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }] | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../coverage/packages/shadcn-ui', | ||
testEnvironment: 'node' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@nx-extend/shadcn-ui", | ||
"version": "0.0.1", | ||
"keywords": [ | ||
"nx", | ||
"shadcn-ui" | ||
], | ||
"homepage": "https://github.com/TriPSs/nx-extend/blob/master/packages/shadcn-ui/README.md", | ||
"bugs": { | ||
"url": "https://github.com/tripss/nx-extend/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tripss/nx-extend" | ||
}, | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
"devDependencies": { | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.0", | ||
"lucide-react": "^0.312.0", | ||
"tailwind-merge": "^2.2.0", | ||
"tailwindcss-animate": "^1.0.7" | ||
}, | ||
"builders": "./executors.json", | ||
"generators": "./generators.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "shadcn-ui", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/shadcn-ui/src", | ||
"projectType": "library", | ||
"targets": { | ||
"lint": { | ||
"executor": "@nrwl/linter:eslint", | ||
"options": { | ||
"lintFilePatterns": ["packages/shadcn-ui/**/*.ts"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/packages/shadcn-ui"], | ||
"options": { | ||
"jestConfig": "packages/shadcn-ui/jest.config.ts" | ||
} | ||
}, | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/shadcn-ui", | ||
"tsConfig": "packages/shadcn-ui/tsconfig.lib.json", | ||
"packageJson": "packages/shadcn-ui/package.json", | ||
"main": "packages/shadcn-ui/src/index.ts", | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"assets": [ | ||
"packages/shadcn-ui/*.md", | ||
{ | ||
"input": "./packages/shadcn-ui/src", | ||
"glob": "**/*.!(ts)", | ||
"output": "./src" | ||
}, | ||
{ | ||
"input": "./packages/shadcn-ui", | ||
"glob": "generators.json", | ||
"output": "." | ||
}, | ||
{ | ||
"input": "./packages/shadcn-ui", | ||
"glob": "executors.json", | ||
"output": "." | ||
} | ||
], | ||
"updateBuildableProjectDepsInPackageJson": true | ||
} | ||
}, | ||
"version": { | ||
"executor": "@jscutlery/semver:version", | ||
"options": { | ||
"tagPrefix": "${target}@" | ||
} | ||
}, | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "npm publish ./dist/packages/shadcn-ui --access public || true" | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ExecutorContext } from '@nx/devkit' | ||
import { buildCommand, execCommand } from '@nx-extend/core' | ||
|
||
export interface ExecutorSchema { | ||
component: string | ||
overwrite?: boolean | ||
} | ||
|
||
export async function addExecutor( | ||
options: ExecutorSchema, | ||
context: ExecutorContext | ||
): Promise<{ success: boolean }> { | ||
const { root } = context.workspace.projects[context.projectName] | ||
|
||
return execCommand(buildCommand([ | ||
'npx shadcn-ui@latest add', | ||
options.component, | ||
options.overwrite && '--overwrite', | ||
'--path=src', | ||
`--cwd=${root}` | ||
]),{ | ||
|
||
}) | ||
} | ||
|
||
export default addExecutor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { convertNxExecutor } from '@nx/devkit' | ||
|
||
import { addExecutor } from './add.impl' | ||
|
||
export default convertNxExecutor(addExecutor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"version": 2, | ||
"outputCapture": "direct-nodejs", | ||
"$schema": "http://json-schema.org/schema", | ||
"type": "object", | ||
"title": "add executor", | ||
"description": "", | ||
"properties": { | ||
"component": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What component would you like to add?" | ||
} | ||
}, | ||
"required": [ | ||
"component" | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/shadcn-ui/src/generators/init/files-utils/cn.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { clsx, type ClassValue } from 'clsx'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
export const cn = function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)); | ||
}; |
Oops, something went wrong.