Skip to content

Commit 08354d2

Browse files
authored
feat(@carbon/upgrade): add check for git status before upgrading (#9685)
* feat: add is-git-clean * feat: check git status
1 parent 9e9df89 commit 08354d2

10 files changed

+86
-2
lines changed
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.

packages/upgrade/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"fast-glob": "^3.2.7",
3737
"fs-extra": "^10.0.0",
3838
"inquirer": "^8.1.0",
39+
"is-git-clean": "^1.1.0",
3940
"jest-diff": "^27.0.6",
4041
"jscodeshift": "^0.13.0",
4142
"lodash.clonedeep": "^4.5.0",

packages/upgrade/src/cli.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'use strict';
99

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

6869
function run(command) {
6970
return async (...args) => {
71+
// checks git status on pwd, returns true if clean / false if not
72+
let isClean = isGitClean.sync();
73+
7074
console.log('Thanks for trying out @carbon/upgrade! 🙏');
75+
console.log('Checking git status...👀');
76+
77+
if (!isClean) {
78+
console.error(
79+
'Git directory is not clean. Please stash or commit your changes.'
80+
);
81+
process.exit(1);
82+
}
7183

7284
try {
7385
await command(...args);

yarn.lock

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,7 @@ __metadata:
21672167
fast-glob: ^3.2.7
21682168
fs-extra: ^10.0.0
21692169
inquirer: ^8.1.0
2170+
is-git-clean: ^1.1.0
21702171
jest-diff: ^27.0.6
21712172
jscodeshift: ^0.13.0
21722173
lodash.clonedeep: ^4.5.0
@@ -8298,6 +8299,13 @@ __metadata:
82988299
languageName: node
82998300
linkType: hard
83008301

8302+
"array-differ@npm:^1.0.0":
8303+
version: 1.0.0
8304+
resolution: "array-differ@npm:1.0.0"
8305+
checksum: ac6060952c7cb0a534c06ea3c6c960432d605d905e9901afe386e841aadc6e102ed81e0e6abe5eb4b50dd43907fc6426f6012b5ca784ec7741a5b398690c0998
8306+
languageName: node
8307+
linkType: hard
8308+
83018309
"array-differ@npm:^2.0.3":
83028310
version: 2.1.0
83038311
resolution: "array-differ@npm:2.1.0"
@@ -12246,6 +12254,16 @@ __metadata:
1224612254
languageName: node
1224712255
linkType: hard
1224812256

12257+
"cross-spawn-async@npm:^2.1.1":
12258+
version: 2.2.5
12259+
resolution: "cross-spawn-async@npm:2.2.5"
12260+
dependencies:
12261+
lru-cache: ^4.0.0
12262+
which: ^1.2.8
12263+
checksum: 6d9059a68a643d9a7506c0d7ca518a803a4293d62cbd3763bdb18cac0dd7bfa9b07d6705361a23c486c7b790e4a2fbfc3d63b93e21de52ad862794b12c6f055f
12264+
languageName: node
12265+
linkType: hard
12266+
1224912267
"cross-spawn-promise@npm:^0.10.1":
1225012268
version: 0.10.1
1225112269
resolution: "cross-spawn-promise@npm:0.10.1"
@@ -15177,6 +15195,20 @@ __metadata:
1517715195
languageName: node
1517815196
linkType: hard
1517915197

15198+
"execa@npm:^0.4.0":
15199+
version: 0.4.0
15200+
resolution: "execa@npm:0.4.0"
15201+
dependencies:
15202+
cross-spawn-async: ^2.1.1
15203+
is-stream: ^1.1.0
15204+
npm-run-path: ^1.0.0
15205+
object-assign: ^4.0.1
15206+
path-key: ^1.0.0
15207+
strip-eof: ^1.0.0
15208+
checksum: aa78c841cbb11b279127f2155e243f7fd766369f8a928ccab9aaa88687ee765e60f7de626ed4056c540ea6c4d7347819a4ae4426076a481edc47585dce989f8e
15209+
languageName: node
15210+
linkType: hard
15211+
1518015212
"execa@npm:^0.7.0":
1518115213
version: 0.7.0
1518215214
resolution: "execa@npm:0.7.0"
@@ -19492,6 +19524,17 @@ __metadata:
1949219524
languageName: node
1949319525
linkType: hard
1949419526

19527+
"is-git-clean@npm:^1.1.0":
19528+
version: 1.1.0
19529+
resolution: "is-git-clean@npm:1.1.0"
19530+
dependencies:
19531+
execa: ^0.4.0
19532+
is-obj: ^1.0.1
19533+
multimatch: ^2.1.0
19534+
checksum: aa89b03f97f02e9dbf5990ad002b33f75bdb83abd0626e60e76d03f62981ad2500b33e7b9eea9f2fdf861ae818ee40663d052902f4c7c0897067463d36072259
19535+
languageName: node
19536+
linkType: hard
19537+
1949519538
"is-glob@npm:^2.0.0, is-glob@npm:^2.0.1":
1949619539
version: 2.0.1
1949719540
resolution: "is-glob@npm:2.0.1"
@@ -23689,7 +23732,7 @@ __metadata:
2368923732
languageName: node
2369023733
linkType: hard
2369123734

23692-
"minimatch@npm:2 || 3, minimatch@npm:3.0.4, minimatch@npm:^3.0.2, minimatch@npm:^3.0.4, minimatch@npm:~3.0.2":
23735+
"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":
2369323736
version: 3.0.4
2369423737
resolution: "minimatch@npm:3.0.4"
2369523738
dependencies:
@@ -24067,6 +24110,18 @@ __metadata:
2406724110
languageName: node
2406824111
linkType: hard
2406924112

24113+
"multimatch@npm:^2.1.0":
24114+
version: 2.1.0
24115+
resolution: "multimatch@npm:2.1.0"
24116+
dependencies:
24117+
array-differ: ^1.0.0
24118+
array-union: ^1.0.1
24119+
arrify: ^1.0.0
24120+
minimatch: ^3.0.0
24121+
checksum: 19259848ec28e5b3ee150ef3ac4a7d3d4afd0c285556e58f349e393b6b4cb6d99abe14415aa2183f4e6309c42d4d3cf941da7ad1b088753024c41ad8b280b03b
24122+
languageName: node
24123+
linkType: hard
24124+
2407024125
"multimatch@npm:^3.0.0":
2407124126
version: 3.0.0
2407224127
resolution: "multimatch@npm:3.0.0"
@@ -24836,6 +24891,15 @@ __metadata:
2483624891
languageName: node
2483724892
linkType: hard
2483824893

24894+
"npm-run-path@npm:^1.0.0":
24895+
version: 1.0.0
24896+
resolution: "npm-run-path@npm:1.0.0"
24897+
dependencies:
24898+
path-key: ^1.0.0
24899+
checksum: ffabf15b6e4cb6f511a49cb9c824db67cd13198938988d18362fb62e793650b10d5e87695016625d3bed06fb9ab6a3b359265d97910d8971c8fdca845d3aaadd
24900+
languageName: node
24901+
linkType: hard
24902+
2483924903
"npm-run-path@npm:^2.0.0":
2484024904
version: 2.0.2
2484124905
resolution: "npm-run-path@npm:2.0.2"
@@ -26037,6 +26101,13 @@ __metadata:
2603726101
languageName: node
2603826102
linkType: hard
2603926103

26104+
"path-key@npm:^1.0.0":
26105+
version: 1.0.0
26106+
resolution: "path-key@npm:1.0.0"
26107+
checksum: 41c4aa248d3b2e4f98b98c753b3721da7a25060cdce1ac95944ae19c71b7d85702b790558763c0371bab46269f40aa8b5ec4a3353954d0c05c8231c41dae9cf0
26108+
languageName: node
26109+
linkType: hard
26110+
2604026111
"path-key@npm:^2.0.0, path-key@npm:^2.0.1":
2604126112
version: 2.0.1
2604226113
resolution: "path-key@npm:2.0.1"
@@ -34920,7 +34991,7 @@ resolve@^2.0.0-next.3:
3492034991
languageName: node
3492134992
linkType: hard
3492234993

34923-
"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":
34994+
"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":
3492434995
version: 1.3.1
3492534996
resolution: "which@npm:1.3.1"
3492634997
dependencies:

0 commit comments

Comments
 (0)