|
| 1 | +# DEBUG Nx Plugin |
| 2 | + |
| 3 | +A plugin that provides a set of tools to debug your Nx workspace. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Register the plugin in your `nx.json` |
| 8 | + |
| 9 | +```jsonc |
| 10 | +// nx.json |
| 11 | +{ |
| 12 | + //... |
| 13 | + "plugins": ["tools/src/debug/debug.plugin.ts"] |
| 14 | +} |
| 15 | +``` |
| 16 | + |
| 17 | +### Options |
| 18 | + |
| 19 | +You can configure the plugin by providing options object in addition to the plugin path |
| 20 | + |
| 21 | +**Options:** |
| 22 | + |
| 23 | +| Name | Type | Default | Description | |
| 24 | +| ---------- | -------- | --------------------------- | ------------------------- | |
| 25 | +| `tsconfig` | `string` | `tools/tsconfig.tools.json` | The tsconfig file to use. | |
| 26 | + |
| 27 | +Example: |
| 28 | + |
| 29 | +```jsonc |
| 30 | +// nx.json |
| 31 | +{ |
| 32 | + //... |
| 33 | + "plugins": [ |
| 34 | + { |
| 35 | + "plugin": "tools/src/debug/debug.plugin.ts", |
| 36 | + "options": { |
| 37 | + "tsconfig": "tools/tsconfig.tools.json" |
| 38 | + } |
| 39 | + } |
| 40 | + ] |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +### Targets |
| 45 | + |
| 46 | +#### `list-process` |
| 47 | + |
| 48 | +Lists all the processes running in the workspace. |
| 49 | + |
| 50 | +Options: |
| 51 | + |
| 52 | +| Name | Type | Default | Description | |
| 53 | +| --------------- | -------- | ----------- | ---------------------------- | |
| 54 | +| `pidFilter` | `number` | `undefined` | Filter processes by PID. | |
| 55 | +| `commandFilter` | `string` | `undefined` | Filter processes by command. | |
| 56 | +| `slice` | `number` | `undefined` | Slice the list of processes. | |
| 57 | + |
| 58 | +Example: |
| 59 | + |
| 60 | +- `nx run <project-name>:list-process` |
| 61 | +- `nx run <project-name>:list-process --pidFilter=1234` |
| 62 | +- `nx run <project-name>:list-process --commandFilter=verdaccio` |
| 63 | +- `nx run <project-name>:list-process --commandFilter=verdaccio --pidFilter=1234` |
| 64 | +- `nx run <project-name>:list-process --commandFilter=verdaccio --slice=5` |
| 65 | + |
| 66 | +#### `kill-process` |
| 67 | + |
| 68 | +Kills a process by its PID or filter |
| 69 | + |
| 70 | +Options: |
| 71 | + |
| 72 | +| Name | Type | Default | Description | |
| 73 | +| --------------- | -------- | ----------- | ---------------------------- | |
| 74 | +| `pidFilter` | `number` | `undefined` | Filter processes by PID. | |
| 75 | +| `commandFilter` | `string` | `undefined` | Filter processes by command. | |
| 76 | + |
| 77 | +Example: |
| 78 | + |
| 79 | +- `nx run <project-name>:kill-process --pidFilter=1234` |
| 80 | +- `nx run <project-name>:kill-process --commandFilter=verdaccio` |
| 81 | + |
| 82 | +## Scripts |
| 83 | + |
| 84 | +### `list-process.ts` |
| 85 | + |
| 86 | +Lists all the processes running in the workspace. |
| 87 | + |
| 88 | +Options: |
| 89 | + |
| 90 | +| Name | Type | Default | Description | |
| 91 | +| --------------- | -------- | ----------- | ---------------------------- | |
| 92 | +| `pidFilter` | `number` | `undefined` | Filter processes by PID. | |
| 93 | +| `commandFilter` | `string` | `undefined` | Filter processes by command. | |
| 94 | +| `slice` | `number` | `undefined` | Slice the list of processes. | |
| 95 | + |
| 96 | +Example: |
| 97 | + |
| 98 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/list-process.ts` |
| 99 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/list-process.ts --pidFilter=1234` |
| 100 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/list-process.ts --commandFilter=verdaccio` |
| 101 | + |
| 102 | +### `kill-process.ts` |
| 103 | + |
| 104 | +Kills a process by its PID or command string. |
| 105 | + |
| 106 | +Options: |
| 107 | + |
| 108 | +| Name | Type | Default | Description | |
| 109 | +| --------------- | --------- | ----------- | ---------------------------- | |
| 110 | +| `pidFilter` | `number` | `undefined` | Filter processes by PID. | |
| 111 | +| `commandFilter` | `string` | `undefined` | Filter processes by command. | |
| 112 | +| `slice` | `number` | `undefined` | Slice the list of processes. | |
| 113 | +| `verbose` | `boolean` | `undefined` | Log the process to kill. | |
| 114 | + |
| 115 | +Example: |
| 116 | + |
| 117 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/kill-process.ts --pidFilter=1234` |
| 118 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/kill-process.ts --commandFilter=verdaccio --pidFilter=1234` |
| 119 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/kill-process.ts --commandFilter=verdaccio --pidFilter=1234 --verbose` |
| 120 | + |
| 121 | +### `clean-npmrc.ts` |
| 122 | + |
| 123 | +Cleans the `.npmrc` file in the workspace. |
| 124 | + |
| 125 | +Options: |
| 126 | + |
| 127 | +| Name | Type | Default | Description | |
| 128 | +| ------------ | ---------------------- | ------- | --------------------------------------------- | |
| 129 | +| `userconfig` | `string` | none | The path to the `.npmrc` file. | |
| 130 | +| `entryMatch` | `string` \| `string[]` | none | The entries to remove from the `.npmrc` file. | |
| 131 | + |
| 132 | +Example: |
| 133 | + |
| 134 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/clean-npmrc.ts --entryMatch=secretVerddacioToken` |
| 135 | +- `tsx --tsconfig=tools/tsconfig.tools.json tools/src/debug/bin/clean-npmrc.ts --userconfig=.npmrc --entryMatch=secretVerddacioToken` |
| 136 | + |
| 137 | +Log npm config settings: |
| 138 | + |
| 139 | +- `npm config list` |
| 140 | +- `npm config list -l` |
| 141 | +- `npm config list -l --location=global` |
| 142 | +- `npm config list -l --userconfig=path/to/file.npmrc` |
0 commit comments