-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): remove @nrwl/workspace when adding nx to monorepo (#9813)
- Loading branch information
1 parent
7f89488
commit bfbe8fc
Showing
18 changed files
with
258 additions
and
76 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
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
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
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,40 @@ | ||
`workspace.json`: | ||
|
||
```json | ||
"frontend": { | ||
"root": "packages/frontend", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/workspace:run-script", | ||
"options": { | ||
"script": "build-my-project" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```bash | ||
nx run frontend:build | ||
``` | ||
|
||
The `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory. | ||
|
||
#### Caching Artifacts | ||
|
||
By default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows: | ||
|
||
```json | ||
"frontend": { | ||
"root": "packages/frontend", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/workspace:run-script", | ||
"outputs": ["packages/frontend/dist", "packaged/frontend/docs"], | ||
"options": { | ||
"script": "build-my-project" | ||
} | ||
} | ||
} | ||
} | ||
``` |
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 @@ | ||
{ | ||
"executors": { | ||
"run-script": { | ||
"implementation": "./src/executors/run-script/run-script.impl", | ||
"schema": "./src/executors/run-script/schema.json", | ||
"description": "Run an NPM script using Nx." | ||
} | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"migrations": {} | ||
} |
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
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,21 @@ | ||
{ | ||
"implicitDependencies": { | ||
"package.json": { | ||
"dependencies": "*", | ||
"devDependencies": "*" | ||
}, | ||
".eslintrc.json": "*" | ||
}, | ||
"targetDependencies": { | ||
"build": [ | ||
{ | ||
"target": "build", | ||
"projects": "dependencies" | ||
} | ||
] | ||
}, | ||
"workspaceLayout": { | ||
"appsDir": "packages", | ||
"libsDir": "packages" | ||
} | ||
} |
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,20 @@ | ||
{ | ||
"implicitDependencies": { | ||
"package.json": { | ||
"dependencies": "*", | ||
"devDependencies": "*" | ||
}, | ||
".eslintrc.json": "*" | ||
}, | ||
"targetDependencies": { | ||
"build": [ | ||
{ | ||
"target": "build", | ||
"projects": "dependencies" | ||
} | ||
] | ||
}, | ||
"workspaceLayout": { | ||
"libsDir": "packages" | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -771,9 +771,15 @@ describe('Migration', () => { | |
expect( | ||
parseMigrationsOptions({ packageAndVersion: 'next' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetPackage: 'nx', | ||
targetVersion: 'next', | ||
}); | ||
expect( | ||
parseMigrationsOptions({ packageAndVersion: '13.10.0' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '13.10.0', | ||
}); | ||
expect( | ||
parseMigrationsOptions({ packageAndVersion: '@nrwl/[email protected]' }) | ||
).toMatchObject({ | ||
|
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
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 { execSync } from 'child_process'; | ||
import { getPackageManagerCommand } from '../../utils/package-manager'; | ||
import type { ExecutorContext } from '../../config/misc-interfaces'; | ||
import * as path from 'path'; | ||
|
||
export interface RunScriptOptions { | ||
script: string; | ||
} | ||
|
||
export default async function ( | ||
options: RunScriptOptions, | ||
context: ExecutorContext | ||
) { | ||
const pm = getPackageManagerCommand(); | ||
const script = options.script; | ||
delete options.script; | ||
|
||
const args = []; | ||
Object.keys(options).forEach((r) => { | ||
args.push(`--${r}=${options[r]}`); | ||
}); | ||
|
||
try { | ||
execSync(pm.run(script, args.join(' ')), { | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
cwd: path.join( | ||
context.root, | ||
context.workspace.projects[context.projectName].root | ||
), | ||
}); | ||
return { success: true }; | ||
} catch (e) { | ||
return { success: false }; | ||
} | ||
} |
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 @@ | ||
{ | ||
"title": "Run Script", | ||
"description": "Run any NPM script of a project in the project's root directory.", | ||
"type": "object", | ||
"cli": "nx", | ||
"outputCapture": "pipe", | ||
"properties": { | ||
"script": { | ||
"type": "string", | ||
"description": "An npm script name in the `package.json` file of the project (e.g., `build`)." | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"required": ["script"], | ||
"examplesFile": "../../../docs/run-script-examples.md" | ||
} |
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
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
Oops, something went wrong.
bfbe8fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev