Skip to content

Commit

Permalink
Code Connect v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
figma-bot committed Feb 14, 2025
1 parent 8206e0b commit cfed2bf
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 82 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Code Connect v1.3.1 (TBD)

## Fixed

- Allow .gradle files to be detected as Android/Compose projects. Thanks to @sebastienrouif for the [PR](https://github.com/figma/code-connect/pull/237)
- Remove prompts patching (fixes https://github.com/figma/code-connect/issues/241)

## Features

- Added `interactiveSetupFigmaFileUrl` to the interactive setup, allowing you to specify the Figma file to use for connecting components in your `figma.config.json` file.
- Rename `--include-raw-templates` flag to `--include-template-files`. Further details of this feature can be found in the [documentation](https://www.figma.com/code-connect-docs/no-parser/).

### SwiftUI
- Updated `swift-syntax` to point to the new URL. Thanks to @pontusJPaf for the [PR](https://github.com/figma/code-connect/pull/239).

# Code Connect v1.3.0 (28th January 2025)

## Features
Expand Down
16 changes: 8 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ let package = Package(
name: "Figma",
platforms: [
.iOS(.v15),
.macOS(.v13)
.macOS(.v13),
],
products: [
.library(name: "Figma", targets: ["Figma"]),
.executable(name: "figma-swift", targets: ["CodeConnectCLI"])
.executable(name: "figma-swift", targets: ["CodeConnectCLI"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", "510.0.3"..."600.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", "510.0.3"..."600.0.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.55.3"),
],
Expand All @@ -28,7 +28,7 @@ let package = Package(
name: "CodeConnectCLI",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.target(name: "CodeConnectParser")
.target(name: "CodeConnectParser"),
],
path: "swiftui/cli"
),
Expand All @@ -39,7 +39,7 @@ let package = Package(
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftFormat", package: "SwiftFormat"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.target(name: "Figma")
.target(name: "Figma"),
],
path: "swiftui/lib"
),
Expand All @@ -48,12 +48,12 @@ let package = Package(
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.target(name: "CodeConnectParser"),
.target(name: "Figma")
.target(name: "Figma"),
],
path: "swiftui/Tests/CodeConnectParserTest",
resources: [
.copy("Samples.figma.test"),
.copy("Samples.figma.test")
]
)
),
]
)
22 changes: 10 additions & 12 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@figma/code-connect",
"version": "1.3.0",
"version": "1.3.1",
"description": "A tool for connecting your design system components in code with your design system in Figma",
"keywords": [],
"author": "Figma",
Expand Down Expand Up @@ -29,8 +29,7 @@
"figma": "bin/figma"
},
"files": [
"dist/**/*",
"patches/**/*"
"dist/**/*"
],
"engines": {
"node": ">=18"
Expand All @@ -41,7 +40,7 @@
"build:web": "pnpm build",
"build:webpack": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" webpack --mode production",
"test": "npm run test:no-coverage -- --coverage",
"test:no-coverage": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-deprecation\" npx jest",
"test:no-coverage": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-deprecation --max-old-space-size=10240\" npx jest --logHeapUsage --workerIdleMemoryLimit=1.5G",
"test:fast": "npm run test -- --testPathIgnorePatterns=template_rendering.test.ts --testPathIgnorePatterns=e2e_parse_command_swift.test.ts --testPathIgnorePatterns=e2e_wizard_swift.test.ts",
"test:ci": "npm run test:non-mac -- --runInBand",
"test:wizard": "npm run test -- --runInBand --testPathPattern=e2e_wizard_react.test.ts --testPathPattern=e2e_wizard_swift.test.ts",
Expand All @@ -59,11 +58,15 @@
"bundle:cli:win": "npm run bundle:cli -- -o bundle-cli/figma-win --target node18-win-x64",
"publish:npm": "npm install && npm run build && npm run bundle:npm-readme:prepare && npm publish --access public; npm run bundle:npm-readme:restore",
"typecheck": "tsc --noEmit -p tsconfig-typecheck.json",
"benchmarking:run": "npx tsx ./src/connect/wizard/__test__/prop_mapping/prop_mapping_benchmarking.ts",
"postinstall": "patch-package"
"benchmarking:run": "npx tsx ./src/connect/wizard/__test__/prop_mapping/prop_mapping_benchmarking.ts"
},
"devDependencies": {
"@babel/core": "7.26.0",
"@babel/generator": "7.26.2",
"@babel/parser": "7.26.0",
"@babel/types": "7.26.0",

"@storybook/csf-tools": "^8.4.7",
"@types/cross-spawn": "^6.0.6",
"@types/jest": "^29.5.13",
"@types/jsdom": "^21.1.7",
Expand All @@ -74,6 +77,7 @@
"@types/react": "18.0.26",
"cross-env": "^7.0.3",
"jest": "^29.7.0",
"patch-package": "^8.0.0",
"pkg": "^5.8.1",
"react": "18.2.0",
"ts-jest": "^29.2.5",
Expand All @@ -83,12 +87,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@babel/core": "7.26.0",
"@babel/generator": "7.26.2",
"@babel/parser": "7.26.0",
"@babel/types": "7.26.0",

"@storybook/csf-tools": "^8.4.7",
"boxen": "5.1.1",
"chalk": "^4.1.2",
"commander": "^11.1.0",
Expand All @@ -103,7 +102,6 @@
"minimatch": "^9.0.3",
"ora": "^5.4.1",
"parse5": "^7.1.2",
"patch-package": "^8.0.0",
"prettier": "^2.8.8",
"prompts": "^2.4.2",
"strip-ansi": "^6.0.0",
Expand Down
12 changes: 0 additions & 12 deletions cli/patches/@types+prompts+2.4.9.patch

This file was deleted.

14 changes: 0 additions & 14 deletions cli/patches/prompts+2.4.2.patch

This file was deleted.

10 changes: 5 additions & 5 deletions cli/src/commands/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function addConnectCommandToProgram(program: commander.Command) {
)
.option('--skip-validation', 'skip validation of Code Connect docs')
.option('-l --label <label>', 'label to apply to the published files')
.option('--include-raw-templates', 'flag to include any raw figma.template.js files')
.option('--include-template-files', 'flag to include any figma.template.js files')
.option(
'-b --batch-size <batch_size>',
'optional batch size (in number of documents) to use when uploading. Use this if you hit "request too large" errors. See README for more information.',
Expand All @@ -106,7 +106,7 @@ export function addConnectCommandToProgram(program: commander.Command) {
'specify the node to unpublish. This will unpublish for both React and Storybook.',
)
.option('-l --label <label>', 'label to unpublish for')
.option('--include-raw-templates', 'flag to include any raw figma.template.js files')
.option('--include-template-files', 'flag to include any figma.template.js files')
.action(withUpdateCheck(handleUnpublish))

addBaseCommand(
Expand All @@ -115,7 +115,7 @@ export function addConnectCommandToProgram(program: commander.Command) {
'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.',
)
.option('-l --label <label>', 'label to apply to the parsed files')
.option('--include-raw-templates', 'flag to include any raw figma.template.js files')
.option('--include-template-files', 'flag to include any figma.template.js files')
.action(withUpdateCheck(handleParse))

addBaseCommand(
Expand Down Expand Up @@ -209,7 +209,7 @@ export function parseRawFile(filePath: string, label: string | undefined): CodeC
}

export async function getCodeConnectObjects(
cmd: BaseCommand & { label?: string; includeRawTemplates?: boolean },
cmd: BaseCommand & { label?: string; includeTemplateFiles?: boolean },
projectInfo: ProjectInfo,
silent = false,
): Promise<CodeConnectJSON[]> {
Expand Down Expand Up @@ -275,7 +275,7 @@ export async function getCodeConnectObjects(
}
}

if (cmd.includeRawTemplates) {
if (cmd.includeTemplateFiles) {
const rawTemplateFiles = projectInfo.files.filter((f: string) =>
f.endsWith('.figma.template.js'),
)
Expand Down
2 changes: 1 addition & 1 deletion cli/src/connect/__test__/e2e/e2e_parse_command_raw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('e2e test for `parse` command (raw)', () => {
const testPath = path.join(__dirname, 'e2e_parse_command/raw')

const result = await promisify(exec)(
`npx tsx ../../../cli connect parse --skip-update-check --dir ${testPath} --include-raw-templates`,
`npx tsx ../../../cli connect parse --skip-update-check --dir ${testPath} --include-template-files`,
{
cwd: __dirname,
},
Expand Down
3 changes: 2 additions & 1 deletion cli/src/connect/__test__/e2e/test_wizard_e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export function testWizardE2e(testCase: {
? `{
"codeConnect": {
"include": ${JSON.stringify(testCase.expectedIncludeGlobs)},
"label": "${testCase.expectedLabel}"
"label": "${testCase.expectedLabel}",
"interactiveSetupFigmaFileUrl": "https://www.figma.com/design/abc123/my-design-system"
}
}
`
Expand Down
11 changes: 11 additions & 0 deletions cli/src/connect/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export type BaseCodeConnectConfig = {
* Label to use for the uploaded code examples
*/
label?: string

/**
* The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.
*/
interactiveSetupFigmaFileUrl?: string
}

export type CodeConnectExecutableParserConfig = BaseCodeConnectConfig & {
Expand Down Expand Up @@ -202,6 +207,12 @@ function determineParserFromProject(dir: string): CodeConnectParser | undefined
)
parser = 'compose'
return findUp.stop
} else if (globSync([`${currentDir}/build.gradle`]).length > 0) {
showParserMessage(
`Using "compose" parser as a file matching build.gradle was found in ${currentDir}`,
)
parser = 'compose'
return findUp.stop
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions cli/src/connect/wizard/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ export async function createCodeConnectConfig({
dir,
componentDirectory,
config,
figmaUrl,
}: {
dir: string
componentDirectory: string | null
config: CodeConnectConfig
figmaUrl: string
}) {
const label = DEFAULT_LABEL_PER_PARSER[config.parser as CodeConnectParser]
const includesGlob = getIncludesGlob({ dir, componentDirectory, config })
Expand All @@ -84,12 +86,14 @@ export async function createCodeConnectConfig({
? `{
"codeConnect": {
"include": ["${includesGlob}"],
"label": "${label}"
}
"label": "${label}",
"interactiveSetupFigmaFileUrl": "${figmaUrl}",
}
}`
: `{
"codeConnect": {
"include": ["${includesGlob}"]
"include": ["${includesGlob}"],
"interactiveSetupFigmaFileUrl": "${figmaUrl}",
}
}`

Expand Down
Loading

0 comments on commit cfed2bf

Please sign in to comment.