diff --git a/package.json b/package.json index f481dcb..ec9d3c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lambdatest/smartui-cli", - "version": "4.1.45", + "version": "4.1.46", "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest", "files": [ "dist/**/*" diff --git a/src/commander/commander.ts b/src/commander/commander.ts index fb85fb0..e62a162 100644 --- a/src/commander/commander.ts +++ b/src/commander/commander.ts @@ -23,6 +23,7 @@ program .option('--baselineBranch ', 'Mark this build baseline') .option('--baselineBuild ', 'Mark this build baseline') .option('--githubURL ', 'GitHub URL including commitId') + .option('--gitURL ', 'Git URL including commitId') .option('--userName ', 'Specify the LT username') .option('--accessKey ', 'Specify the LT accesskey') .addCommand(exec) diff --git a/src/lib/ctx.ts b/src/lib/ctx.ts index 2c971ce..ae1b194 100644 --- a/src/lib/ctx.ts +++ b/src/lib/ctx.ts @@ -114,6 +114,12 @@ export default (options: Record): Context => { orientation: config.mobile.orientation || constants.MOBILE_ORIENTATION_PORTRAIT, } } + if (env.BASIC_AUTH_USERNAME && env.BASIC_AUTH_PASSWORD) { + basicAuthObj = { + 'username': env.BASIC_AUTH_USERNAME, + 'password': env.BASIC_AUTH_PASSWORD + } + } if (config.basicAuthorization) { basicAuthObj = config.basicAuthorization; } @@ -213,7 +219,7 @@ export default (options: Record): Context => { fetchResultsFileName: fetchResultsFileObj, baselineBranch: options.baselineBranch || '', baselineBuild: options.baselineBuild || '', - githubURL : options.githubURL || '', + githubURL : options.gitURL || options.githubURL || '', showRenderErrors: options.showRenderErrors ? true : false, userName: options.userName || '', accessKey: options.accessKey || '' diff --git a/src/lib/env.ts b/src/lib/env.ts index 4901f49..32a67b5 100644 --- a/src/lib/env.ts +++ b/src/lib/env.ts @@ -11,7 +11,9 @@ export default (): Env => { HTTPS_PROXY, SMARTUI_HTTP_PROXY, SMARTUI_HTTPS_PROXY, - GITHUB_ACTIONS, + GIT_URL, + BASIC_AUTH_USERNAME, + BASIC_AUTH_PASSWORD, FIGMA_TOKEN, LT_USERNAME, LT_ACCESS_KEY, @@ -39,7 +41,9 @@ export default (): Env => { HTTPS_PROXY, SMARTUI_HTTP_PROXY, SMARTUI_HTTPS_PROXY, - GITHUB_ACTIONS, + GIT_URL, + BASIC_AUTH_USERNAME, + BASIC_AUTH_PASSWORD, FIGMA_TOKEN, LT_USERNAME, LT_ACCESS_KEY, diff --git a/src/lib/git.ts b/src/lib/git.ts index fc01ec6..3a5989a 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -38,6 +38,9 @@ export default (ctx: Context): Git => { if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) { githubURL = ctx.options.githubURL; } + if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) { + githubURL = ctx.options.gitURL; + } if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) { let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8')); @@ -51,7 +54,7 @@ export default (ctx: Context): Git => { commitId: gitInfo.commit_id.slice(0,6) || '', commitMessage: gitInfo.commit_body || '', commitAuthor: gitInfo.commit_author || '', - githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '', + githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}`, baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || '' } } else { @@ -78,7 +81,7 @@ export default (ctx: Context): Git => { commitId: res[0] || '', commitMessage: res[2] || '', commitAuthor: res[7] || '', - githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '', + githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}`, baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || '' }; } @@ -95,6 +98,9 @@ function setNonGitInfo(ctx: Context) { if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) { githubURL = ctx.options.githubURL; } + if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) { + githubURL = ctx.options.gitURL; + } ctx.git = { branch: branch, diff --git a/src/types.ts b/src/types.ts index 2a735b3..5cbe561 100644 --- a/src/types.ts +++ b/src/types.ts @@ -82,6 +82,7 @@ export interface Context { baselineBranch?: string, baselineBuild?: string, githubURL?: string, + gitURL?: string, showRenderErrors?: boolean, userName?: string, accessKey?: string @@ -121,7 +122,9 @@ export interface Env { HTTPS_PROXY: string | undefined; SMARTUI_HTTP_PROXY: string | undefined; SMARTUI_HTTPS_PROXY: string | undefined; - GITHUB_ACTIONS: string | undefined; + GIT_URL: string | undefined; + BASIC_AUTH_USERNAME: string | undefined; + BASIC_AUTH_PASSWORD: string | undefined; FIGMA_TOKEN: string | undefined; LT_USERNAME : string | undefined; LT_ACCESS_KEY : string | undefined;