Skip to content

Commit 8404e85

Browse files
Merge pull request #440 from shreyansh-chandel/git-url-env-support
Added support for using gitURL with ENV
2 parents e43042d + 9d615ee commit 8404e85

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.45",
3+
"version": "4.1.46",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/commander/commander.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ program
2323
.option('--baselineBranch <string>', 'Mark this build baseline')
2424
.option('--baselineBuild <string>', 'Mark this build baseline')
2525
.option('--githubURL <string>', 'GitHub URL including commitId')
26+
.option('--gitURL <string>', 'Git URL including commitId')
2627
.option('--userName <string>', 'Specify the LT username')
2728
.option('--accessKey <string>', 'Specify the LT accesskey')
2829
.addCommand(exec)

src/lib/ctx.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ export default (options: Record<string, string>): Context => {
114114
orientation: config.mobile.orientation || constants.MOBILE_ORIENTATION_PORTRAIT,
115115
}
116116
}
117+
if (env.BASIC_AUTH_USERNAME && env.BASIC_AUTH_PASSWORD) {
118+
basicAuthObj = {
119+
'username': env.BASIC_AUTH_USERNAME,
120+
'password': env.BASIC_AUTH_PASSWORD
121+
}
122+
}
117123
if (config.basicAuthorization) {
118124
basicAuthObj = config.basicAuthorization;
119125
}
@@ -213,7 +219,7 @@ export default (options: Record<string, string>): Context => {
213219
fetchResultsFileName: fetchResultsFileObj,
214220
baselineBranch: options.baselineBranch || '',
215221
baselineBuild: options.baselineBuild || '',
216-
githubURL : options.githubURL || '',
222+
githubURL : options.gitURL || options.githubURL || '',
217223
showRenderErrors: options.showRenderErrors ? true : false,
218224
userName: options.userName || '',
219225
accessKey: options.accessKey || ''

src/lib/env.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default (): Env => {
1111
HTTPS_PROXY,
1212
SMARTUI_HTTP_PROXY,
1313
SMARTUI_HTTPS_PROXY,
14-
GITHUB_ACTIONS,
14+
GIT_URL,
15+
BASIC_AUTH_USERNAME,
16+
BASIC_AUTH_PASSWORD,
1517
FIGMA_TOKEN,
1618
LT_USERNAME,
1719
LT_ACCESS_KEY,
@@ -39,7 +41,9 @@ export default (): Env => {
3941
HTTPS_PROXY,
4042
SMARTUI_HTTP_PROXY,
4143
SMARTUI_HTTPS_PROXY,
42-
GITHUB_ACTIONS,
44+
GIT_URL,
45+
BASIC_AUTH_USERNAME,
46+
BASIC_AUTH_PASSWORD,
4347
FIGMA_TOKEN,
4448
LT_USERNAME,
4549
LT_ACCESS_KEY,

src/lib/git.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default (ctx: Context): Git => {
3838
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
3939
githubURL = ctx.options.githubURL;
4040
}
41+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
42+
githubURL = ctx.options.gitURL;
43+
}
4144
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
4245
let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8'));
4346

@@ -51,7 +54,7 @@ export default (ctx: Context): Git => {
5154
commitId: gitInfo.commit_id.slice(0,6) || '',
5255
commitMessage: gitInfo.commit_body || '',
5356
commitAuthor: gitInfo.commit_author || '',
54-
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
57+
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}`,
5558
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
5659
}
5760
} else {
@@ -78,7 +81,7 @@ export default (ctx: Context): Git => {
7881
commitId: res[0] || '',
7982
commitMessage: res[2] || '',
8083
commitAuthor: res[7] || '',
81-
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
84+
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}`,
8285
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
8386
};
8487
}
@@ -95,6 +98,9 @@ function setNonGitInfo(ctx: Context) {
9598
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
9699
githubURL = ctx.options.githubURL;
97100
}
101+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
102+
githubURL = ctx.options.gitURL;
103+
}
98104

99105
ctx.git = {
100106
branch: branch,

src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export interface Context {
8282
baselineBranch?: string,
8383
baselineBuild?: string,
8484
githubURL?: string,
85+
gitURL?: string,
8586
showRenderErrors?: boolean,
8687
userName?: string,
8788
accessKey?: string
@@ -121,7 +122,9 @@ export interface Env {
121122
HTTPS_PROXY: string | undefined;
122123
SMARTUI_HTTP_PROXY: string | undefined;
123124
SMARTUI_HTTPS_PROXY: string | undefined;
124-
GITHUB_ACTIONS: string | undefined;
125+
GIT_URL: string | undefined;
126+
BASIC_AUTH_USERNAME: string | undefined;
127+
BASIC_AUTH_PASSWORD: string | undefined;
125128
FIGMA_TOKEN: string | undefined;
126129
LT_USERNAME : string | undefined;
127130
LT_ACCESS_KEY : string | undefined;

0 commit comments

Comments
 (0)