-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate NX #98
Open
mahmut-gundogdu
wants to merge
2
commits into
master
Choose a base branch
from
migrate-nx
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Migrate NX #98
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,42 @@ | ||
{ | ||
"root": true, | ||
"ignorePatterns": ["**/*"], | ||
"plugins": ["@nrwl/nx"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": { | ||
"@nrwl/nx/enforce-module-boundaries": [ | ||
"error", | ||
{ | ||
"enforceBuildableLibDependency": true, | ||
"allow": [], | ||
"depConstraints": [ | ||
{ | ||
"sourceTag": "*", | ||
"onlyDependOnLibsWithTags": ["*"] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"extends": ["plugin:@nrwl/nx/typescript"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"extends": ["plugin:@nrwl/nx/javascript"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"], | ||
"env": { | ||
"jest": true | ||
}, | ||
"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 |
---|---|---|
|
@@ -45,3 +45,5 @@ package-lock.json | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
.angular |
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,73 @@ | ||
/** | ||
* This file decorates the Angular CLI with the Nx CLI to enable features such as computation caching | ||
* and faster execution of tasks. | ||
* | ||
* It does this by: | ||
* | ||
* - Patching the Angular CLI to warn you in case you accidentally use the undecorated ng command. | ||
* - Symlinking the ng to nx command, so all commands run through the Nx CLI | ||
* - Updating the package.json postinstall script to give you control over this script | ||
* | ||
* The Nx CLI decorates the Angular CLI, so the Nx CLI is fully compatible with it. | ||
* Every command you run should work the same when using the Nx CLI, except faster. | ||
* | ||
* Because of symlinking you can still type `ng build/test/lint` in the terminal. The ng command, in this case, | ||
* will point to nx, which will perform optimizations before invoking ng. So the Angular CLI is always invoked. | ||
* The Nx CLI simply does some optimizations before invoking the Angular CLI. | ||
* | ||
* To opt out of this patch: | ||
* - Replace occurrences of nx with ng in your package.json | ||
* - Remove the script from your postinstall script in your package.json | ||
* - Delete and reinstall your node_modules | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const cp = require('child_process'); | ||
const isWindows = os.platform() === 'win32'; | ||
let output; | ||
try { | ||
output = require('@nrwl/workspace').output; | ||
} catch (e) { | ||
console.warn( | ||
'Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.', | ||
); | ||
process.exit(0); | ||
} | ||
|
||
/** | ||
* Symlink of ng to nx, so you can keep using `ng build/test/lint` and still | ||
* invoke the Nx CLI and get the benefits of computation caching. | ||
*/ | ||
function symlinkNgCLItoNxCLI() { | ||
try { | ||
const ngPath = './node_modules/.bin/ng'; | ||
const nxPath = './node_modules/.bin/nx'; | ||
if (isWindows) { | ||
/** | ||
* This is the most reliable way to create symlink-like behavior on Windows. | ||
* Such that it works in all shells and works with npx. | ||
*/ | ||
['', '.cmd', '.ps1'].forEach(ext => { | ||
if (fs.existsSync(nxPath + ext)) | ||
fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext)); | ||
}); | ||
} else { | ||
// If unix-based, symlink | ||
cp.execSync(`ln -sf ./nx ${ngPath}`); | ||
} | ||
} catch (e) { | ||
output.error({ | ||
title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message, | ||
}); | ||
throw e; | ||
} | ||
} | ||
|
||
try { | ||
symlinkNgCLItoNxCLI(); | ||
require('nx/src/adapter/decorate-cli').decorateCli(); | ||
output.log({ title: 'Angular CLI has been decorated to enable computation caching.' }); | ||
} catch (e) { | ||
output.error({ title: 'Decoration of the Angular CLI did not complete successfully' }); | ||
} |
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 { getJestProjects } from '@nrwl/jest'; | ||
|
||
export default { | ||
projects: getJestProjects(), | ||
}; |
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 @@ | ||
const nxPreset = require('@nrwl/jest/preset').default; | ||
|
||
module.exports = { ...nxPreset }; |
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,55 @@ | ||
{ | ||
"npmScope": "ngx-validate", | ||
"affected": { | ||
"defaultBase": "main" | ||
}, | ||
"implicitDependencies": { | ||
"package.json": { | ||
"dependencies": "*", | ||
"devDependencies": "*" | ||
}, | ||
".eslintrc.json": "*" | ||
}, | ||
"tasksRunnerOptions": { | ||
"default": { | ||
"runner": "nx/tasks-runners/default", | ||
"options": { | ||
"cacheableOperations": ["build", "lint", "test", "e2e"] | ||
} | ||
} | ||
}, | ||
"targetDefaults": { | ||
"build": { | ||
"dependsOn": ["^build"] | ||
}, | ||
"test": { | ||
"inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"] | ||
}, | ||
"lint": { | ||
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"] | ||
} | ||
}, | ||
"workspaceLayout": { | ||
"appsDir": "packages", | ||
"libsDir": "packages" | ||
}, | ||
"cli": { | ||
"analytics": false | ||
}, | ||
"defaultProject": "ngx-validate", | ||
"generators": { | ||
"@nrwl/angular:application": { | ||
"style": "css", | ||
"linter": "eslint", | ||
"unitTestRunner": "jest", | ||
"e2eTestRunner": "none" | ||
}, | ||
"@nrwl/angular:library": { | ||
"linter": "eslint", | ||
"unitTestRunner": "jest" | ||
}, | ||
"@nrwl/angular:component": { | ||
"style": "css" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
test executor different from other packages' test executor.