Skip to content

Commit c1f59cf

Browse files
authored
Add local testing option (#11)
1 parent 09d1b10 commit c1f59cf

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

cli/index.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Choice<T> = {
2424
type OptionConfig<T> = {
2525
id: string;
2626
description: string;
27-
message: string;
27+
message?: string;
2828
choices: ReadonlyArray<Choice<T>>;
2929
};
3030

@@ -34,6 +34,7 @@ type OptionConfigs = {
3434
database: OptionConfig<DatabaseType>;
3535
auth: OptionConfig<void>;
3636
outputDir: OptionConfig<void>;
37+
testing: OptionConfig<void>;
3738
};
3839

3940
const OPTIONS: OptionConfigs = {
@@ -77,6 +78,11 @@ const OPTIONS: OptionConfigs = {
7778
"Which directory would you like the starter code folder to be in (default is current directory)?",
7879
choices: [],
7980
},
81+
testing: {
82+
id: "t",
83+
description: "Test locally without cloning repo",
84+
choices: [],
85+
},
8086
};
8187

8288
const OPTION_COMBINATION_DENY_LIST = [
@@ -123,7 +129,7 @@ const parseArguments = (args: CommandLineArgs): CommandLineOptions => {
123129
database: {
124130
alias: OPTIONS.database.id,
125131
type: "string",
126-
description: OPTIONS.api.description,
132+
description: OPTIONS.database.description,
127133
choices: OPTIONS.database.choices.map((choice) => choice.value),
128134
},
129135
auth: {
@@ -136,13 +142,20 @@ const parseArguments = (args: CommandLineArgs): CommandLineOptions => {
136142
type: "string",
137143
description: OPTIONS.outputDir.description,
138144
},
145+
testing: {
146+
alias: OPTIONS.testing.id,
147+
type: "boolean",
148+
description: OPTIONS.testing.description,
149+
},
139150
});
140151

141152
return {
142153
backend: argv.backend as BackendType,
143154
api: argv.api as APIType,
144155
database: argv.database as DatabaseType,
145156
auth: argv.auth,
157+
outputDir: argv.outputDir,
158+
testing: argv.testing,
146159
};
147160
};
148161

@@ -287,19 +300,21 @@ async function cli(args: CommandLineArgs): Promise<Options> {
287300
return Promise.reject(new Error("No directory exists. Exiting..."));
288301
}
289302

290-
const clone = shell.exec(
291-
"git clone https://github.com/uwblueprint/starter-code-v2.git",
292-
);
303+
if (!commandLineOptions.testing) {
304+
const clone = shell.exec(
305+
"git clone https://github.com/uwblueprint/starter-code-v2.git",
306+
);
293307

294-
if (clone.code !== 0) {
295-
return Promise.reject(new Error("Git clone failed. Exiting..."));
296-
}
308+
if (clone.code !== 0) {
309+
return Promise.reject(new Error("Git clone failed. Exiting..."));
310+
}
297311

298-
console.log(chalk.green.bold("Removing .git ..."));
299-
const removeGit = shell.exec("rm -rf starter-code-v2/.git");
312+
console.log(chalk.green.bold("Removing .git ..."));
313+
const removeGit = shell.exec("rm -rf starter-code-v2/.git");
300314

301-
if (removeGit.code !== 0) {
302-
return Promise.reject(new Error("Remove .git failed. Exiting..."));
315+
if (removeGit.code !== 0) {
316+
return Promise.reject(new Error("Remove .git failed. Exiting..."));
317+
}
303318
}
304319

305320
return appOptions;

cli/optionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type CommandLineOptions = {
1919
database?: DatabaseType;
2020
auth?: boolean;
2121
outputDir?: string;
22+
testing?: boolean;
2223
};
2324

2425
export type UserResponse = {

scrubber/scrubberConfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"cliOptionsToActions": {
33
"typescript": {
44
"tagsToKeep": ["typescript"],
5-
"filesToDelete": ["python/"]
5+
"filesToDelete": ["backend/python/"]
66
},
77
"python": {
88
"tagsToKeep": ["python"],
9-
"filesToDelete": ["typescript/"]
9+
"filesToDelete": ["backend/typescript/"]
1010
},
1111
"rest": {
1212
"tagsToKeep": ["rest"]

0 commit comments

Comments
 (0)