Skip to content

Commit 3c71977

Browse files
authored
Merge pull request #183 from parthlambdatest/build_name_addition
[Dot-4333] add support for buildName in CLI
2 parents c6bfb44 + bd1f0e7 commit 3c71977

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

src/commander/capture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ command
1919
.option('-C, --parallel [number]', 'Specify the number of instances per browser', parseInt)
2020
.option('-F, --force', 'forcefully apply the specified parallel instances per browser')
2121
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
22+
.option('--buildName <string>', 'Specify the build name')
2223
.action(async function(file, _, command) {
2324
let ctx: Context = ctxInit(command.optsWithGlobals());
2425

src/commander/exec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ command
2020
.argument('<command...>', 'Command supplied for running tests')
2121
.option('-P, --port <number>', 'Port number for the server')
2222
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
23+
.option('--buildName <string>', 'Specify the build name')
2324
.action(async function(execCommand, _, command) {
2425
let ctx: Context = ctxInit(command.optsWithGlobals());
2526

src/commander/upload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ command
2626
return val.split(',').map(pattern => pattern.trim());
2727
})
2828
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
29+
.option('--buildName <string>', 'Specify the build name')
2930
.action(async function(directory, _, command) {
3031
let ctx: Context = ctxInit(command.optsWithGlobals());
3132

src/lib/ctx.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default (options: Record<string, string>): Context => {
2121
let parallelObj: number;
2222
let fetchResultObj: boolean;
2323
let fetchResultsFileObj: string;
24+
let buildNameObj: string;
2425
try {
2526
if (options.config) {
2627
config = JSON.parse(fs.readFileSync(options.config, 'utf-8'));
@@ -57,6 +58,7 @@ export default (options: Record<string, string>): Context => {
5758
fetchResultObj = false
5859
fetchResultsFileObj = ''
5960
}
61+
buildNameObj = options.buildName || ''
6062
} catch (error: any) {
6163
console.log(`[smartui] Error: ${error.message}`);
6264
process.exit();
@@ -105,7 +107,7 @@ export default (options: Record<string, string>): Context => {
105107
},
106108
build: {
107109
id: '',
108-
name: '',
110+
name: buildNameObj,
109111
baseline: false,
110112
url: ''
111113
},

src/lib/httpClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ export default class httpClient {
8282
}
8383
}
8484

85-
createBuild(git: Git, config: any, log: Logger) {
85+
createBuild(git: Git, config: any, log: Logger, buildName: string) {
8686
return this.request({
8787
url: '/build',
8888
method: 'POST',
8989
data: {
9090
git,
91-
config
91+
config,
92+
buildName
9293
}
9394
}, log)
9495
}

src/tasks/createBuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1010
updateLogContext({task: 'createBuild'});
1111

1212
try {
13-
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log);
13+
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name);
1414
ctx.build = {
1515
id: resp.data.buildId,
1616
name: resp.data.buildName,

0 commit comments

Comments
 (0)