Skip to content

Commit

Permalink
Merge pull request #33 from LambdaTest/stage
Browse files Browse the repository at this point in the history
Release v2.0.3
  • Loading branch information
sushobhit-lt authored Jan 3, 2024
2 parents be9c2c8 + 4c90c08 commit 197c876
Show file tree
Hide file tree
Showing 18 changed files with 884 additions and 674 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lambdatest/smartui-cli",
"version": "2.0.2",
"version": "2.0.3",
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
"files": [
"dist/**/*"
Expand All @@ -21,17 +21,22 @@
"author": "LambdaTest <[email protected]>",
"license": "MIT",
"dependencies": {
"@playwright/browser-chromium": "^1.40.1",
"@playwright/browser-firefox": "^1.40.1",
"@playwright/browser-webkit": "^1.40.1",
"@playwright/test": "^1.40.1",
"@types/cross-spawn": "^6.0.4",
"@types/node": "^20.8.9",
"@types/which": "^3.0.2",
"ajv": "^8.12.0",
"ajv-errors": "^3.0.0",
"axios": "^1.6.0",
"chalk": "^4.1.2",
"commander": "^11.1.0",
"cross-spawn": "^7.0.3",
"fastify": "^4.24.3",
"form-data": "^4.0.0",
"listr2": "^7.0.1",
"playwright": "^1.39.0",
"tsup": "^7.2.0",
"which": "^4.0.0",
"winston": "^3.10.0"
Expand Down
71 changes: 63 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions src/commander/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import getGitInfo from '../tasks/getGitInfo.js'
import createBuild from '../tasks/createBuild.js'
import captureScreenshots from '../tasks/captureScreenshots.js'
import finalizeBuild from '../tasks/finalizeBuild.js'
import { validateWebStaticConfig } from '../lib/schemaValidation.js'

const command = new Command();

Expand All @@ -18,13 +19,25 @@ command
.action(async function(file, _, command) {
let ctx: Context = ctxInit(command.optsWithGlobals());

if (!fs.existsSync(file)) {
console.log(`Error: Web Static Config file ${file} not found.`);
return;
}
try {
ctx.webStaticConfig = JSON.parse(fs.readFileSync(file, 'utf8'));
if (!validateWebStaticConfig(ctx.webStaticConfig)) throw new Error(validateWebStaticConfig.errors[0].message);
} catch (error: any) {
console.log(`[smartui] Error: Invalid Web Static Config; ${error.message}`);
return;
}

let tasks = new Listr<Context>(
[
auth(ctx),
getGitInfo(ctx),
createBuild(ctx),
captureScreenshots(ctx),
finalizeBuild(ctx, 0)
finalizeBuild(ctx)
],
{
rendererOptions: {
Expand All @@ -39,12 +52,6 @@ command
)

try {
if (!fs.existsSync(file)) {
console.log(`Error: Config file ${file} not found.`);
return;
}
ctx.staticConfig = JSON.parse(fs.readFileSync(file, 'utf8'));

await tasks.run(ctx);
} catch (error) {
console.log('\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/');
Expand Down
10 changes: 5 additions & 5 deletions src/commander/config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Command } from 'commander'
import { createWebConfig, createWebStaticConfig } from '../lib/config.js'
import { createConfig, createWebStaticConfig } from '../lib/config.js'

export const configWeb = new Command();
export const configStatic = new Command();

configWeb
.name('config:create-web')
.description('Create SmartUI Web config file')
.name('config:create')
.description('Create SmartUI config file')
.argument('[filepath]', 'Optional config filepath')
.action(async function(filepath, options) {
createWebConfig(filepath);
createConfig(filepath);
})

configStatic
.name('config:web-static')
.name('config:create-web-static')
.description('Create Web Static config file')
.argument('[filepath]', 'Optional config filepath')
.action(async function(filepath, options) {
Expand Down
3 changes: 2 additions & 1 deletion src/commander/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ command
return
}
ctx.args.execCommand = execCommand
ctx.totalSnapshots = 0

let tasks = new Listr<Context>(
[
Expand All @@ -32,7 +33,7 @@ command
getGitInfo(ctx),
createBuild(ctx),
exec(ctx),
finalizeBuild(ctx, 30000)
finalizeBuild(ctx)
],
{
rendererOptions: {
Expand Down
Loading

0 comments on commit 197c876

Please sign in to comment.