-
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.
feat(schematics): add update, update:skip, and update:check commands
- Loading branch information
Showing
10 changed files
with
102 additions
and
34 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
25 changes: 25 additions & 0 deletions
25
packages/schematics/migrations/20180227-cleanup-scripts.ts
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,25 @@ | ||
import {updateJsonFile} from '../src/collection/utility/fileutils'; | ||
|
||
export default { | ||
description: 'Add update, update:skip, update:check scripts', | ||
run: () => { | ||
updateJsonFile('package.json', json => { | ||
json.scripts = { | ||
...json.scripts, | ||
"update": "./node_modules/.bin/nx update", | ||
"update:check": "./node_modules/.bin/nx update check", | ||
"update:skip": "./node_modules/.bin/nx update skip", | ||
"nx-migrate": undefined, | ||
"nx-migrate:check": undefined, | ||
"nx-migrate:skip": undefined, | ||
"apps:affected": undefined, | ||
"build:affected": undefined, | ||
"e2e:affected": undefined | ||
}; | ||
|
||
if (json.scripts.postinstall === './node_modules/.bin/nx migrate check') { | ||
json.scripts.postinstall = "./node_modules/.bin/nx postinstall"; | ||
} | ||
}); | ||
} | ||
}; |
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
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,33 @@ | ||
import {readFileSync, statSync, writeFileSync} from "fs"; | ||
import * as path from 'path'; | ||
|
||
const nxCheck = ` | ||
// nx-check | ||
if (process.argv.indexOf('update') > -1) { | ||
console.log("This is an Nx workspace, and it provides an enhanced 'update' command."); | ||
console.log('Please run "npm run update" or "yarn update" instead.'); | ||
process.exit(1); | ||
} | ||
// nx-check-end | ||
`; | ||
|
||
export function patchNg() { | ||
const ngBin = path.join('node_modules', '@angular', 'cli', 'bin', 'ng'); | ||
if (fileExists(ngBin)) { | ||
const file = readFileSync(ngBin).toString(); | ||
writeFileSync(ngBin, addNxCheck(file)); | ||
} | ||
} | ||
|
||
function addNxCheck(file: string): string { | ||
if (file.indexOf('nx-check') > -1) return file; | ||
return file.replace(`'use strict';`, `'use strict';${nxCheck}`); | ||
} | ||
|
||
function fileExists(filePath: string): boolean { | ||
try { | ||
return statSync(filePath).isFile(); | ||
} catch (err) { | ||
return 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