Skip to content

Commit e6a9db9

Browse files
author
figma-bot
committed
Code Connect v1.3.3
1 parent ef2a9f0 commit e6a9db9

File tree

10 files changed

+64
-20
lines changed

10 files changed

+64
-20
lines changed

CHANGELOG.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
# Code Connect v1.3.3 (TBD)
1+
# Code Connect v1.3.4 (TBD)
22

3-
# Code Connect v1.3.2
3+
# Code Connect v1.3.3 (22nd May 2025)
4+
5+
## Features
6+
7+
### Compose
8+
- Enhanced `--verbose` command to output detailed stacktrace.
9+
10+
## Fixed
11+
12+
### General
13+
- Bumped Undici version to address security issue
14+
15+
# Code Connect v1.3.2 (4th April 2025)
416

517
## Fixed
618

@@ -14,7 +26,7 @@
1426
### HTML
1527
- Allow examples to return strings to support icon IDs (fixes https://github.com/figma/code-connect/issues/252)
1628

17-
# Code Connect v1.3.1
29+
# Code Connect v1.3.1 (14th February 2025)
1830

1931
## Fixed
2032

cli/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
testPathIgnorePatterns: ['/dist/'],
66

77
// Some of these tests can be long running, e.g. e2e ones, so set the timeout higher globally
8-
testTimeout: 15000,
8+
testTimeout: 20000,
99

1010
modulePathIgnorePatterns: [
1111
// Ignore changes to figma.config.json and figma.config.json.backup otherwise

cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@figma/code-connect",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "A tool for connecting your design system components in code with your design system in Figma",
55
"keywords": [],
66
"author": "Figma",
@@ -107,8 +107,8 @@
107107
"strip-ansi": "^6.0.0",
108108
"ts-morph": "^23.0.0",
109109
"typescript": "5.5.4",
110-
"undici": "^5.28.4",
110+
"undici": "^5.29.0",
111111
"zod": "3.23.8",
112-
"zod-validation-error": "^3.2.0"
112+
"zod-validation-error": "3.4.0"
113113
}
114114
}

cli/src/commands/connect.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export async function getCodeConnectObjects(
242242
mode: 'PARSE',
243243
paths: projectInfo.files,
244244
config: projectInfo.config,
245+
verbose: cmd.verbose,
245246
}
246247

247248
try {
@@ -268,10 +269,16 @@ export async function getCodeConnectObjects(
268269
},
269270
}))
270271
} catch (e) {
271-
// zod-validation-error formats the error message into a readable format
272-
exitWithError(
273-
`Error returned from parser: ${fromError(e)}. Try re-running the command with --verbose for more information.`,
274-
)
272+
if (cmd.verbose) {
273+
console.trace(e)
274+
275+
// Don't say to enable verbose if the user has already enabled it.
276+
exitWithError(`Error calling parser: ${e}.`)
277+
} else {
278+
exitWithError(
279+
`Error returned from parser: ${fromError(e)}. Try re-running the command with --verbose for more information.`,
280+
)
281+
}
275282
}
276283
}
277284

@@ -543,5 +550,6 @@ async function handleCreate(nodeUrl: string, cmd: BaseCommand) {
543550
outFile: cmd.outFile,
544551
outDir: cmd.outDir,
545552
projectInfo,
553+
cmd,
546554
})
547555
}

cli/src/connect/__test__/e2e/e2e_create_command.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ Received: ${JSON.stringify({
7878
},
7979
},
8080
},
81-
config: { parser: '__unit_test__', include: ['*.test'], exclude: ['Excluded.test'] },
81+
config: {
82+
parser: '__unit_test__',
83+
include: ['*.test'],
84+
exclude: ['Excluded.test'],
85+
},
86+
verbose: true,
8287
})}
8388
Success from parser!
8489
Code Connect files generated successfully:

cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/StorybookComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ReactNode } from 'react'
22
import React from 'react'
33

4-
interface Props {
4+
export interface Props {
55
disabled: boolean
66
children: ReactNode
77
}

cli/src/connect/create.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ import {
1919
import { fromError } from 'zod-validation-error'
2020
import { createHtmlCodeConnect } from '../html/create'
2121
import { isFetchError, request } from '../common/fetch'
22+
import { BaseCommand } from '../commands/connect'
23+
2224
interface GenerateDocsArgs {
2325
accessToken: string
2426
figmaNodeUrl: string
2527
outFile: string
2628
outDir: string
2729
projectInfo: ProjectInfo
30+
cmd: BaseCommand
2831
}
2932

3033
export function normalizeComponentName(name: string) {
@@ -43,6 +46,7 @@ export async function createCodeConnectFromUrl({
4346
outFile,
4447
outDir,
4548
projectInfo,
49+
cmd,
4650
}: GenerateDocsArgs) {
4751
try {
4852
const fileKey = parseFileKey(figmaNodeUrl)
@@ -122,6 +126,7 @@ export async function createCodeConnectFromUrl({
122126
destinationFile: outFile,
123127
component: componentPayload,
124128
config: projectInfo.config,
129+
verbose: cmd.verbose,
125130
}
126131
const stdout = await callParser(
127132
// We use `as` because the React parser makes the types difficult

cli/src/connect/parser_executable_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type ParseRequestPayload = {
1212
// Each parser's configuration is separate and can take any shape, though we
1313
// will recommend using the same naming for common concepts like "importPaths".
1414
config: Record<string, any>
15+
verbose?: boolean
1516
}
1617

1718
const FigmaConnectLink = z.object({
@@ -193,6 +194,7 @@ export type CreateRequestPayload = {
193194
// Each parser's configuration is separate and can take any shape, though we
194195
// will recommend using the same naming for common concepts like "importPaths".
195196
config: Record<string, any>
197+
verbose?: boolean
196198
}
197199

198200
export type CreateRequestPayloadMulti = {

cli/src/connect/parser_executables.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const FIRST_PARTY_PARSERS: Record<CodeConnectExecutableParser, ParserInfo> = {
3838
command: async (cwd, config, mode) => {
3939
const gradlewPath = await getGradleWrapperPath(cwd, (config as any).gradleWrapperPath)
4040
const gradleExecutableInvocation = getGradleWrapperExecutablePath(gradlewPath)
41+
const verboseFlags = (config as any).verbose ? ' --stacktrace' : ''
4142
if (mode === 'CREATE') {
42-
return `${gradleExecutableInvocation} -p ${gradlewPath} createCodeConnect -PfilePath=${temporaryIOFilePath} -q`
43+
return `${gradleExecutableInvocation} -p ${gradlewPath} createCodeConnect -PfilePath=${temporaryIOFilePath}${verboseFlags}`
4344
} else {
44-
return `${gradleExecutableInvocation} -p ${gradlewPath} parseCodeConnect -PfilePath=${temporaryIOFilePath} -q`
45+
return `${gradleExecutableInvocation} -p ${gradlewPath} parseCodeConnect -PfilePath=${temporaryIOFilePath}${verboseFlags}`
4546
}
4647
},
4748
temporaryIOFilePath: temporaryIOFilePath,
@@ -82,7 +83,11 @@ export async function callParser(
8283
return new Promise<object>(async (resolve, reject) => {
8384
try {
8485
const parser = getParser(config)
85-
const command = await parser.command(cwd, config, payload.mode)
86+
const configWithVerbose = {
87+
...config,
88+
verbose: (payload as any).verbose,
89+
}
90+
const command = await parser.command(cwd, configWithVerbose, payload.mode)
8691
if (parser.temporaryIOFilePath) {
8792
fs.mkdirSync(path.dirname(parser.temporaryIOFilePath), { recursive: true })
8893
fs.writeFileSync(temporaryIOFilePath, JSON.stringify(payload))
@@ -162,9 +167,16 @@ export async function callParser(
162167
child.stdin.end()
163168
}
164169
} catch (e) {
165-
exitWithError(
166-
`Error calling parser: ${e}. Try re-running the command with --verbose for more information.`,
167-
)
170+
if ((payload as any).verbose) {
171+
console.trace(e)
172+
173+
// Don't say to enable verbose if the user has already enabled it.
174+
exitWithError(`Error calling parser: ${e}.`)
175+
} else {
176+
exitWithError(
177+
`Error calling parser: ${e}. Try re-running the command with --verbose for more information.`,
178+
)
179+
}
168180
}
169181
})
170182
}

cli/src/storybook/__test__/examples/ArrowComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ReactNode } from 'react'
22
import React from 'react'
33

4-
interface Props {
4+
export interface Props {
55
disabled: boolean
66
children: ReactNode
77
}

0 commit comments

Comments
 (0)