This PR adds help text for each inferred target that provides
`metadata.help.command`. To pass options/args to the target, users are
directed to open `project.json` and copy the values from `--help` output
into `options` property of the target.
To display the options help section, the inferred target must provide
metadata as follows:
```json5
metadata: {
help: {
command: `foo --help`
example: {
options: {
bar: true
},
},
},
},
```
The `help.command` value will be used to retrieve help text for the
underlying CLI (e.g. `jest --help`). The `help.example` property
contains sample options and args that users can add to their
`project.json` file -- currently rendered in the hover tooltip of
`project.json` hint text.
---
Example with `vite build --help`:
<img width="1257" alt="Screenshot 2024-06-21 at 3 06 21 PM"
src="https://github.com/nrwl/nx/assets/53559/b94cdcde-80da-4fa5-9f93-11af7fbcaf27">
Result of clicking `Run`:
<img width="1257" alt="Screenshot 2024-06-21 at 3 06 24 PM"
src="https://github.com/nrwl/nx/assets/53559/6803a5a8-9bbd-4510-b9ff-fa895a5b3402">
`project.json` tooltip hint:
<img width="1392" alt="Screenshot 2024-06-25 at 12 44 02 PM"
src="https://github.com/nrwl/nx/assets/53559/565002ae-7993-4dda-ac5d-4b685710f65e">
264 lines
6.8 KiB
Plaintext
264 lines
6.8 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`@nx/vite/plugin Library mode should exclude serve and preview targets when vite.config.ts is in library mode 1`] = `
|
|
[
|
|
[
|
|
"my-lib/vite.config.ts",
|
|
{
|
|
"projects": {
|
|
"my-lib": {
|
|
"metadata": {},
|
|
"projectType": "library",
|
|
"root": "my-lib",
|
|
"targets": {
|
|
"build": {
|
|
"cache": true,
|
|
"command": "vite build",
|
|
"dependsOn": [
|
|
"^build",
|
|
],
|
|
"inputs": [
|
|
"production",
|
|
"^production",
|
|
{
|
|
"externalDependencies": [
|
|
"vite",
|
|
],
|
|
},
|
|
],
|
|
"metadata": {
|
|
"description": "Run Vite build",
|
|
"help": {
|
|
"command": "npx vite build --help",
|
|
"example": {
|
|
"options": {
|
|
"manifest": "manifest.json",
|
|
"sourcemap": true,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": "my-lib",
|
|
},
|
|
"outputs": [
|
|
"{workspaceRoot}/dist/{projectRoot}",
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
]
|
|
`;
|
|
|
|
exports[`@nx/vite/plugin not root project should create nodes 1`] = `
|
|
[
|
|
[
|
|
"my-app/vite.config.ts",
|
|
{
|
|
"projects": {
|
|
"my-app": {
|
|
"metadata": {},
|
|
"projectType": "application",
|
|
"root": "my-app",
|
|
"targets": {
|
|
"build-something": {
|
|
"cache": true,
|
|
"command": "vite build",
|
|
"dependsOn": [
|
|
"^build-something",
|
|
],
|
|
"inputs": [
|
|
"production",
|
|
"^production",
|
|
{
|
|
"externalDependencies": [
|
|
"vite",
|
|
],
|
|
},
|
|
],
|
|
"metadata": {
|
|
"description": "Run Vite build",
|
|
"help": {
|
|
"command": "npx vite build --help",
|
|
"example": {
|
|
"options": {
|
|
"manifest": "manifest.json",
|
|
"sourcemap": true,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": "my-app",
|
|
},
|
|
"outputs": [
|
|
"{workspaceRoot}/dist/{projectRoot}",
|
|
],
|
|
},
|
|
"my-serve": {
|
|
"command": "vite serve",
|
|
"metadata": {
|
|
"description": "Starts Vite dev server",
|
|
"help": {
|
|
"command": "npx vite --help",
|
|
"example": {
|
|
"options": {
|
|
"port": 3000,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": "my-app",
|
|
},
|
|
},
|
|
"preview-site": {
|
|
"command": "vite preview",
|
|
"metadata": {
|
|
"description": "Locally preview Vite production build",
|
|
"help": {
|
|
"command": "npx vite preview --help",
|
|
"example": {
|
|
"options": {
|
|
"port": 3000,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": "my-app",
|
|
},
|
|
},
|
|
"serve-static": {
|
|
"executor": "@nx/web:file-server",
|
|
"options": {
|
|
"buildTarget": "build-something",
|
|
"spa": true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
]
|
|
`;
|
|
|
|
exports[`@nx/vite/plugin root project should create nodes 1`] = `
|
|
[
|
|
[
|
|
"vite.config.ts",
|
|
{
|
|
"projects": {
|
|
".": {
|
|
"metadata": {},
|
|
"projectType": "application",
|
|
"root": ".",
|
|
"targets": {
|
|
"build": {
|
|
"cache": true,
|
|
"command": "vite build",
|
|
"dependsOn": [
|
|
"^build",
|
|
],
|
|
"inputs": [
|
|
"production",
|
|
"^production",
|
|
{
|
|
"externalDependencies": [
|
|
"vite",
|
|
],
|
|
},
|
|
],
|
|
"metadata": {
|
|
"description": "Run Vite build",
|
|
"help": {
|
|
"command": "npx vite build --help",
|
|
"example": {
|
|
"options": {
|
|
"manifest": "manifest.json",
|
|
"sourcemap": true,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": ".",
|
|
},
|
|
"outputs": [
|
|
"{projectRoot}/dist",
|
|
],
|
|
},
|
|
"preview": {
|
|
"command": "vite preview",
|
|
"metadata": {
|
|
"description": "Locally preview Vite production build",
|
|
"help": {
|
|
"command": "npx vite preview --help",
|
|
"example": {
|
|
"options": {
|
|
"port": 3000,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": ".",
|
|
},
|
|
},
|
|
"serve": {
|
|
"command": "vite serve",
|
|
"metadata": {
|
|
"description": "Starts Vite dev server",
|
|
"help": {
|
|
"command": "npx vite --help",
|
|
"example": {
|
|
"options": {
|
|
"port": 3000,
|
|
},
|
|
},
|
|
},
|
|
"technologies": [
|
|
"vite",
|
|
],
|
|
},
|
|
"options": {
|
|
"cwd": ".",
|
|
},
|
|
},
|
|
"serve-static": {
|
|
"executor": "@nx/web:file-server",
|
|
"options": {
|
|
"buildTarget": "build",
|
|
"spa": true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
]
|
|
`;
|