Skip to content

Commit 9aa8622

Browse files
Merge pull request #86 from Shahnawaz-Sk/stage_10may
adding cli options
2 parents 1d44d8b + 801f0a1 commit 9aa8622

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

src/commander/uploadFigma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ command
1717
.name('upload-figma')
1818
.description('Capture screenshots of static sites')
1919
.argument('<file>', 'figma design config file')
20+
.option('--markBaseline', 'Mark the uploaded images as baseline')
21+
.option('--buildName <buildName>' , 'Name of the build')
2022
.action(async function(file, _, command) {
2123
let ctx: Context = ctxInit(command.optsWithGlobals());
2224

@@ -38,7 +40,6 @@ command
3840
let tasks = new Listr<Context>(
3941
[
4042
auth(ctx),
41-
getGitInfo(ctx),
4243
uploadFigmaDesigns(ctx)
4344
],
4445
{

src/lib/ctx.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export default (options: Record<string, string>): Context => {
7373
},
7474
args: {},
7575
options: {
76-
parallel: options.parallel ? true : false
76+
parallel: options.parallel ? true : false,
77+
markBaseline: options.markBaseline ? true : false,
78+
buildName: options.buildName || ''
7779
},
7880
cliVersion: version,
7981
totalSnapshots: -1

src/lib/httpClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,17 @@ export default class httpClient {
137137
}, log)
138138
}
139139

140-
getFigmaFilesAndImages(figmaFileToken: string, figmaToken: String | undefined, queryParams: string, authToken: string, depth: number, git : any,log: Logger) {
140+
getFigmaFilesAndImages(figmaFileToken: string, figmaToken: String | undefined, queryParams: string, authToken: string, depth: number, markBaseline: boolean, buildName: string, log: Logger) {
141141
const requestBody = {
142142
figma_file_token: figmaFileToken,
143143
figma_token: figmaToken,
144144
query_params: queryParams,
145145
auth: authToken,
146146
depth: depth,
147-
git: git
147+
mark_base_line: markBaseline,
148+
build_name: buildName
148149
};
150+
149151
return this.request({
150152
url: "/uploadfigma",
151153
method: "POST",

src/lib/uploadFigmaDesigns.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export default async (ctx: Context): Promise<string> => {
55
const figmaConfigs = ctx.figmaDesignConfig.figma_config;
66
let results = "";
77
let figmaFileToken = '';
8+
const markBaseline = ctx.options.markBaseline;
9+
const buildName = ctx.options.buildName;
810

911
for (const config of figmaConfigs) {
1012

@@ -17,7 +19,7 @@ export default async (ctx: Context): Promise<string> => {
1719

1820
const authToken = `Basic ${Buffer.from(`${ctx.env.LT_USERNAME}:${ctx.env.LT_ACCESS_KEY}`).toString("base64")}`
1921

20-
const responseData = await ctx.client.getFigmaFilesAndImages(figmaFileToken, ctx.env.FIGMA_TOKEN, queryParams, authToken, depth, ctx.git,ctx.log)
22+
const responseData = await ctx.client.getFigmaFilesAndImages(figmaFileToken, ctx.env.FIGMA_TOKEN, queryParams, authToken, depth, markBaseline, buildName ,ctx.log);
2123

2224
if (responseData.data.message == "success") {
2325
results = responseData.data.message;

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export interface Context {
2727
execCommand?: Array<string>
2828
}
2929
options: {
30-
parallel?: boolean
30+
parallel?: boolean,
31+
markBaseline?: boolean,
32+
buildName?: string,
3133
}
3234
cliVersion: string;
3335
totalSnapshots: number;

0 commit comments

Comments
 (0)