Skip to content

Commit

Permalink
Add all shadcn-ui components (#258)
Browse files Browse the repository at this point in the history
Fixes #256
  • Loading branch information
TriPSs committed Apr 26, 2024
2 parents 463bb4b + 0481ecb commit df0e11a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 6 additions & 0 deletions packages/shadcn-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const links: LinksFunction = () => [
nx add <ui lib name> button
```

### All all components

```sh
nx add <ui lib name>
```

## Updating the theme

The generated `global.css` uses the default shadcn/ui theme.
Expand Down
21 changes: 11 additions & 10 deletions packages/shadcn-ui/src/executors/add/add.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExecutorContext } from '@nx/devkit'
import { buildCommand, execPackageManagerCommand } from '@nx-extend/core'

export interface ExecutorSchema {
component: string
component?: string
overwrite?: boolean
}

Expand All @@ -12,15 +12,16 @@ export async function addExecutor(
): Promise<{ success: boolean }> {
const { root } = context.workspace.projects[context.projectName]

return execPackageManagerCommand(buildCommand([
'shadcn-ui@latest add',
options.component,
options.overwrite && '--overwrite',
'--path=src',
`--cwd=${root}`
]),{

})
return execPackageManagerCommand(
buildCommand([
'shadcn-ui@latest add',
(options.component ?? '').length === 0 ? '--all' : options.component,
options.overwrite && '--overwrite',
'--path=src',
`--cwd=${root}`
]),
{}
)
}

export default addExecutor
7 changes: 2 additions & 5 deletions packages/shadcn-ui/src/executors/add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
"$source": "argv",
"index": 0
},
"x-prompt": "What component would you like to add?"
"x-prompt": "What component would you like to add? (Keep empty to add all)"
}
},
"required": [
"component"
]
}
}

0 comments on commit df0e11a

Please sign in to comment.