-
Notifications
You must be signed in to change notification settings - Fork 27
DOT-5874: Add pdf upload support in SmartUI-CLI #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85c0c7e
Merge pull request #347 from LambdaTest/stage
sushobhit-lt 479c010
Add PDF upload functionality and related commands
lt-zeeshan 1258ca9
Refactor PDF upload logic to use FormData headers and clean up unused…
lt-zeeshan 2eec99f
Enhance PDF upload function to handle single PDF files and improve fi…
lt-zeeshan 2ff20b7
Refactor PDF upload methods to improve error handling and logging
lt-zeeshan 3cf9ad0
Update error handling in PDF upload to exit process on directory not …
lt-zeeshan 0c78566
Changes
lt-zeeshan 3cfd4a6
Fix http client
lt-zeeshan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {Command} from "commander"; | ||
import { Context } from '../types.js'; | ||
import ctxInit from '../lib/ctx.js'; | ||
import { color, Listr, ListrDefaultRendererLogLevels, LoggerFormat } from 'listr2'; | ||
import fs from 'fs'; | ||
import auth from '../tasks/auth.js'; | ||
import uploadPdfs from '../tasks/uploadPdfs.js'; | ||
import {startPdfPolling} from "../lib/utils.js"; | ||
const command = new Command(); | ||
|
||
command | ||
.name('upload-pdf') | ||
.description('Upload PDFs for visual comparison') | ||
.argument('<directory>', 'Path of the directory containing PDFs') | ||
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json') | ||
.option('--buildName <string>', 'Specify the build name') | ||
.action(async function(directory, _, command) { | ||
const options = command.optsWithGlobals(); | ||
if (options.buildName === '') { | ||
console.log(`Error: The '--buildName' option cannot be an empty string.`); | ||
process.exit(1); | ||
} | ||
let ctx: Context = ctxInit(command.optsWithGlobals()); | ||
|
||
if (!fs.existsSync(directory)) { | ||
console.log(`Error: The provided directory ${directory} not found.`); | ||
process.exit(1); | ||
} | ||
|
||
ctx.uploadFilePath = directory; | ||
|
||
let tasks = new Listr<Context>( | ||
[ | ||
auth(ctx), | ||
uploadPdfs(ctx) | ||
], | ||
{ | ||
rendererOptions: { | ||
icon: { | ||
[ListrDefaultRendererLogLevels.OUTPUT]: `→` | ||
}, | ||
color: { | ||
[ListrDefaultRendererLogLevels.OUTPUT]: color.gray as LoggerFormat | ||
} | ||
} | ||
} | ||
); | ||
|
||
try { | ||
await tasks.run(ctx); | ||
|
||
if (ctx.options.fetchResults) { | ||
startPdfPolling(ctx); | ||
} | ||
} catch (error) { | ||
console.log('\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add process.exit(1); |
||
process.exit(1); | ||
} | ||
}); | ||
|
||
export default command; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add process.exit(1);