@@ -12,8 +12,18 @@ import replace from "replace-in-file";
12
12
import { titleCase } from "title-case" ;
13
13
14
14
let exitCode = 0 ;
15
+ let skipRestore = true ;
15
16
const s = prompts . spinner ( ) ;
16
17
18
+ function handlePromptCancel ( value ) {
19
+ if ( prompts . isCancel ( value ) ) {
20
+ prompts . cancel (
21
+ "Operation cancelled. Exiting setup - maybe another time? 👋"
22
+ ) ;
23
+ process . exit ( 0 ) ;
24
+ }
25
+ }
26
+
17
27
try {
18
28
console . clear ( ) ;
19
29
console . log (
@@ -31,12 +41,15 @@ try {
31
41
repository : { type : "string" } ,
32
42
title : { type : "string" } ,
33
43
"skip-api" : { type : "boolean" } ,
44
+ "skip-restore" : { type : "boolean" } ,
34
45
"skip-uninstalls" : { type : "boolean" } ,
35
46
} ,
36
47
tokens : true ,
37
48
strict : false ,
38
49
} ) ;
39
50
51
+ skipRestore = values [ "skip-restore" ] ;
52
+
40
53
async function getDefaultSettings ( ) {
41
54
let gitRemoteFetch ;
42
55
try {
@@ -90,12 +103,7 @@ try {
90
103
} ,
91
104
} ) ;
92
105
93
- if ( prompts . isCancel ( value ) ) {
94
- prompts . cancel (
95
- "Operation cancelled. Exiting setup - maybe another time? 👋"
96
- ) ;
97
- process . exit ( 0 ) ;
98
- }
106
+ handlePromptCancel ( value ) ;
99
107
100
108
return value ;
101
109
}
@@ -571,7 +579,30 @@ try {
571
579
572
580
console . log ( ) ;
573
581
console . log ( error ) ;
574
- console . log ( ) ;
582
+
583
+ if ( skipRestore ) {
584
+ console . log ( ) ;
585
+ console . log ( chalk . gray `Skipping restoring local repository, as requested.` ) ;
586
+ console . log ( ) ;
587
+ } else {
588
+ const shouldRestore = await prompts . confirm ( {
589
+ message :
590
+ "Do you want to restore the repository to how it was before running setup?" ,
591
+ } ) ;
592
+
593
+ handlePromptCancel ( shouldRestore ) ;
594
+
595
+ if ( shouldRestore ) {
596
+ console . log ( ) ;
597
+ console . log (
598
+ chalk . gray `Resetting repository using` ,
599
+ chalk . reset `git restore .`
600
+ ) ;
601
+ await $ `git restore .` ;
602
+ console . log ( "Repository is reset. Ready to try again?" ) ;
603
+ console . log ( ) ;
604
+ }
605
+ }
575
606
576
607
exitCode = 1 ;
577
608
} finally {
0 commit comments