Skip to content

Commit 1a1ffdc

Browse files
committed
changes for git strategy
1 parent 049bb2f commit 1a1ffdc

File tree

6 files changed

+14
-27
lines changed

6 files changed

+14
-27
lines changed

src/commander/uploadFigma.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ command
3838
let tasks = new Listr<Context>(
3939
[
4040
auth(ctx),
41+
getGitInfo(ctx),
4142
uploadFigmaDesigns(ctx)
4243
],
4344
{

src/lib/constants.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,27 +239,20 @@ export default {
239239

240240
FIGMA_API : 'https://api.figma.com/v1/',
241241
DEFAULT_FIGMA_CONFIG: {
242+
"depth": 2,
242243
"figma_config": [
243244
{
244245
"figma_file_token": "token_for_first_figma_file",
245246
"figma_ids": [
246247
"id1",
247248
"id2"
248-
],
249-
"figma_names": [
250-
"Name1",
251-
"Name2"
252249
]
253250
},
254251
{
255252
"figma_file_token": "token_for_second_figma_file",
256253
"figma_ids": [
257254
"id3",
258255
"id4"
259-
],
260-
"figma_names": [
261-
"name3",
262-
"name4"
263256
]
264257
}
265258
]

src/lib/httpClient.ts

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

140-
getFigmaFilesAndImages(figmaFileToken: string, figmaToken: String | undefined, queryParams: string, authToken: string, log: Logger) {
140+
getFigmaFilesAndImages(figmaFileToken: string, figmaToken: String | undefined, queryParams: string, authToken: string, depth: number, git : any,log: Logger) {
141141
const requestBody = {
142142
figma_file_token: figmaFileToken,
143143
figma_token: figmaToken,
144144
query_params: queryParams,
145-
auth: authToken
145+
auth: authToken,
146+
depth: depth,
147+
git: git
146148
};
147149
return this.request({
148150
url: "/uploadfigma",

src/lib/schemaValidation.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
275275
const FigmaDesignConfigSchema: JSONSchemaType<FigmaDesignConfig> = {
276276
type: "object",
277277
properties: {
278+
depth: {
279+
type: "integer",
280+
minimum: 1,
281+
errorMessage: "Depth must be an integer and greater than 1"
282+
},
278283
figma_config: {
279284
type: "array",
280285
items: {
@@ -299,21 +304,6 @@ const FigmaDesignConfigSchema: JSONSchemaType<FigmaDesignConfig> = {
299304
minItems: "figma_ids cannot be empty",
300305
uniqueItems: "figma_ids must contain unique values"
301306
}
302-
},
303-
figma_names: {
304-
type: "array",
305-
items: {
306-
type: "string",
307-
minLength: 1,
308-
errorMessage: "Each name in figma_names must be a non-empty string"
309-
},
310-
minItems: 1,
311-
uniqueItems: true,
312-
errorMessage: {
313-
type: "figma_names must be an array of strings",
314-
minItems: "figma_names cannot be empty",
315-
uniqueItems: "figma_names must contain unique values"
316-
}
317307
}
318308
},
319309
required: ["figma_file_token"],

src/lib/uploadFigmaDesigns.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Context } from "../types.js";
22

33
export default async (ctx: Context): Promise<string> => {
4+
const depth = ctx.figmaDesignConfig.depth;
45
const figmaConfigs = ctx.figmaDesignConfig.figma_config;
56
let results = "";
67
let figmaFileToken = '';
@@ -16,7 +17,7 @@ export default async (ctx: Context): Promise<string> => {
1617

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

19-
const responseData = await ctx.client.getFigmaFilesAndImages(figmaFileToken, ctx.env.FIGMA_TOKEN, queryParams, authToken, ctx.log)
20+
const responseData = await ctx.client.getFigmaFilesAndImages(figmaFileToken, ctx.env.FIGMA_TOKEN, queryParams, authToken, depth, ctx.git,ctx.log)
2021

2122
if (responseData.data.message == "success") {
2223
results = responseData.data.message;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ export type WebStaticConfig = Array<{
120120
export type FigmaConfigItem = {
121121
figma_file_token: string;
122122
figma_ids: string[];
123-
figma_names: string[];
124123
};
125124

126125
export type FigmaDesignConfig = {
126+
depth: number;
127127
figma_config: FigmaConfigItem[];
128128
};

0 commit comments

Comments
 (0)