Skip to content

Commit

Permalink
feat(@carbon/upgrade): add check for git status before upgrading (#9685)
Browse files Browse the repository at this point in the history
* feat: add is-git-clean

* feat: check git status
  • Loading branch information
jnm2377 authored Sep 17, 2021
1 parent 9e9df89 commit 08354d2
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 2 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions packages/upgrade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"fast-glob": "^3.2.7",
"fs-extra": "^10.0.0",
"inquirer": "^8.1.0",
"is-git-clean": "^1.1.0",
"jest-diff": "^27.0.6",
"jscodeshift": "^0.13.0",
"lodash.clonedeep": "^4.5.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/upgrade/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict';

const cli = require('yargs');
const isGitClean = require('is-git-clean');
const packageJson = require('../package.json');
const { UpgradeError } = require('./error');
const { Migration } = require('./migration');
Expand Down Expand Up @@ -67,7 +68,18 @@ async function main({ argv, cwd }) {

function run(command) {
return async (...args) => {
// checks git status on pwd, returns true if clean / false if not
let isClean = isGitClean.sync();

console.log('Thanks for trying out @carbon/upgrade! 🙏');
console.log('Checking git status...👀');

if (!isClean) {
console.error(
'Git directory is not clean. Please stash or commit your changes.'
);
process.exit(1);
}

try {
await command(...args);
Expand Down
75 changes: 73 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,7 @@ __metadata:
fast-glob: ^3.2.7
fs-extra: ^10.0.0
inquirer: ^8.1.0
is-git-clean: ^1.1.0
jest-diff: ^27.0.6
jscodeshift: ^0.13.0
lodash.clonedeep: ^4.5.0
Expand Down Expand Up @@ -8298,6 +8299,13 @@ __metadata:
languageName: node
linkType: hard

"array-differ@npm:^1.0.0":
version: 1.0.0
resolution: "array-differ@npm:1.0.0"
checksum: ac6060952c7cb0a534c06ea3c6c960432d605d905e9901afe386e841aadc6e102ed81e0e6abe5eb4b50dd43907fc6426f6012b5ca784ec7741a5b398690c0998
languageName: node
linkType: hard

"array-differ@npm:^2.0.3":
version: 2.1.0
resolution: "array-differ@npm:2.1.0"
Expand Down Expand Up @@ -12246,6 +12254,16 @@ __metadata:
languageName: node
linkType: hard

"cross-spawn-async@npm:^2.1.1":
version: 2.2.5
resolution: "cross-spawn-async@npm:2.2.5"
dependencies:
lru-cache: ^4.0.0
which: ^1.2.8
checksum: 6d9059a68a643d9a7506c0d7ca518a803a4293d62cbd3763bdb18cac0dd7bfa9b07d6705361a23c486c7b790e4a2fbfc3d63b93e21de52ad862794b12c6f055f
languageName: node
linkType: hard

"cross-spawn-promise@npm:^0.10.1":
version: 0.10.1
resolution: "cross-spawn-promise@npm:0.10.1"
Expand Down Expand Up @@ -15177,6 +15195,20 @@ __metadata:
languageName: node
linkType: hard

"execa@npm:^0.4.0":
version: 0.4.0
resolution: "execa@npm:0.4.0"
dependencies:
cross-spawn-async: ^2.1.1
is-stream: ^1.1.0
npm-run-path: ^1.0.0
object-assign: ^4.0.1
path-key: ^1.0.0
strip-eof: ^1.0.0
checksum: aa78c841cbb11b279127f2155e243f7fd766369f8a928ccab9aaa88687ee765e60f7de626ed4056c540ea6c4d7347819a4ae4426076a481edc47585dce989f8e
languageName: node
linkType: hard

"execa@npm:^0.7.0":
version: 0.7.0
resolution: "execa@npm:0.7.0"
Expand Down Expand Up @@ -19492,6 +19524,17 @@ __metadata:
languageName: node
linkType: hard

"is-git-clean@npm:^1.1.0":
version: 1.1.0
resolution: "is-git-clean@npm:1.1.0"
dependencies:
execa: ^0.4.0
is-obj: ^1.0.1
multimatch: ^2.1.0
checksum: aa89b03f97f02e9dbf5990ad002b33f75bdb83abd0626e60e76d03f62981ad2500b33e7b9eea9f2fdf861ae818ee40663d052902f4c7c0897067463d36072259
languageName: node
linkType: hard

"is-glob@npm:^2.0.0, is-glob@npm:^2.0.1":
version: 2.0.1
resolution: "is-glob@npm:2.0.1"
Expand Down Expand Up @@ -23689,7 +23732,7 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:2 || 3, minimatch@npm:3.0.4, minimatch@npm:^3.0.2, minimatch@npm:^3.0.4, minimatch@npm:~3.0.2":
"minimatch@npm:2 || 3, minimatch@npm:3.0.4, minimatch@npm:^3.0.0, minimatch@npm:^3.0.2, minimatch@npm:^3.0.4, minimatch@npm:~3.0.2":
version: 3.0.4
resolution: "minimatch@npm:3.0.4"
dependencies:
Expand Down Expand Up @@ -24067,6 +24110,18 @@ __metadata:
languageName: node
linkType: hard

"multimatch@npm:^2.1.0":
version: 2.1.0
resolution: "multimatch@npm:2.1.0"
dependencies:
array-differ: ^1.0.0
array-union: ^1.0.1
arrify: ^1.0.0
minimatch: ^3.0.0
checksum: 19259848ec28e5b3ee150ef3ac4a7d3d4afd0c285556e58f349e393b6b4cb6d99abe14415aa2183f4e6309c42d4d3cf941da7ad1b088753024c41ad8b280b03b
languageName: node
linkType: hard

"multimatch@npm:^3.0.0":
version: 3.0.0
resolution: "multimatch@npm:3.0.0"
Expand Down Expand Up @@ -24836,6 +24891,15 @@ __metadata:
languageName: node
linkType: hard

"npm-run-path@npm:^1.0.0":
version: 1.0.0
resolution: "npm-run-path@npm:1.0.0"
dependencies:
path-key: ^1.0.0
checksum: ffabf15b6e4cb6f511a49cb9c824db67cd13198938988d18362fb62e793650b10d5e87695016625d3bed06fb9ab6a3b359265d97910d8971c8fdca845d3aaadd
languageName: node
linkType: hard

"npm-run-path@npm:^2.0.0":
version: 2.0.2
resolution: "npm-run-path@npm:2.0.2"
Expand Down Expand Up @@ -26037,6 +26101,13 @@ __metadata:
languageName: node
linkType: hard

"path-key@npm:^1.0.0":
version: 1.0.0
resolution: "path-key@npm:1.0.0"
checksum: 41c4aa248d3b2e4f98b98c753b3721da7a25060cdce1ac95944ae19c71b7d85702b790558763c0371bab46269f40aa8b5ec4a3353954d0c05c8231c41dae9cf0
languageName: node
linkType: hard

"path-key@npm:^2.0.0, path-key@npm:^2.0.1":
version: 2.0.1
resolution: "path-key@npm:2.0.1"
Expand Down Expand Up @@ -34920,7 +34991,7 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"which@npm:^1.0.5, which@npm:^1.2.1, which@npm:^1.2.10, which@npm:^1.2.14, which@npm:^1.2.9, which@npm:^1.3.1":
"which@npm:^1.0.5, which@npm:^1.2.1, which@npm:^1.2.10, which@npm:^1.2.14, which@npm:^1.2.8, which@npm:^1.2.9, which@npm:^1.3.1":
version: 1.3.1
resolution: "which@npm:1.3.1"
dependencies:
Expand Down

0 comments on commit 08354d2

Please sign in to comment.