Skip to content

Commit

Permalink
Code Connect v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
figma-bot committed Jul 23, 2024
1 parent 9911b18 commit 444f438
Show file tree
Hide file tree
Showing 51 changed files with 3,119 additions and 215 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# Code Connect v1.0.3 (23th July 2024)

## Fixed

### General

### React
- Add support for hyphens in prop names (fixes https://github.com/figma/code-connect/issues/97)

### SwiftUI
- Fixed `checkouts` folder resolution edge case

### Compose
- Fixed issue with `create` command creating invalid code
- Added import resolution for components

## Features

### General
- Added support for SwiftUI and Compose in the CLI Assistant
- Added `--skip-update-check` flag
- Added `--label` flag to the `publish` and `unpublish` commands to publish or unpublish to a custom label
- We now print the label used when running the `publish` command
- Improved autolinking algorithm


# Code Connect v1.0.2 (10th July 2024)

## Fixed
Expand Down
1 change: 1 addition & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ npx figma connect unpublish --token <token>
- `--skip-validation` By default, `publish` will validate your Code Connect file with the Figma component to ensure that their properties match. This flag can be used to skip this validation.
- `--verbose` Enable verbose logging for debugging
- `--node <node-url>` For unpublishing only a single specific component with `unpublish`
- `--label <label>` For publishing or unpublishing under a custom label

## Configuration

Expand Down
13 changes: 8 additions & 5 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@figma/code-connect",
"version": "1.0.2",
"version": "1.0.3",
"description": "A tool for connecting your design system components in code with your design system in Figma",
"keywords": [],
"author": "Figma",
Expand All @@ -17,17 +17,20 @@
"files": [
"dist/**/*"
],
"engines": {
"node": ">=16"
},
"scripts": {
"dev": "tsx src/cli.ts",
"build": "tsc",
"build:web": "pnpm build",
"build:webpack": "webpack --mode production",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --coverage",
"test:fast": "npm run test -- --testPathIgnorePatterns=template_rendering.test.ts --testPathIgnorePatterns=e2e_connect_command_swift.test.ts",
"test:fast": "npm run test -- --testPathIgnorePatterns=template_rendering.test.ts --testPathIgnorePatterns=e2e_connect_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.test.ts",
"test:swift": "npm run test -- --runInBand --testPathPattern=e2e_connect_command_swift.test.ts",
"test:non-mac": "npm run test -- --testPathIgnorePatterns=e2e_connect_command_swift.test.ts",
"test:wizard": "npm run test -- --runInBand --testPathPattern=e2e_wizard_react.test.ts --testPathPattern=e2e_wizard_swift.test.ts",
"test:swift": "npm run test -- --runInBand --testPathPattern=e2e_connect_command_swift.test.ts --testPathPattern=e2e_wizard_swift.test.ts",
"test:non-mac": "npm run test -- --testPathIgnorePatterns=e2e_connect_command_swift.test.ts --testPathIgnorePatterns=e2e_wizard_swift.test.ts",
"bundle": "npm run build && npm pack && mkdir -p bundle && mv figma-code-connect*.tgz bundle",
"bundle:npm": "npm run build && npm pack && mkdir -p bundle-npm && mv figma-code-connect*.tgz bundle-npm",
"bundle:cli": "npm run build:webpack && mkdir -p bundle-cli && pkg --compress Brotli webpack-dist/figma.js",
Expand Down
21 changes: 12 additions & 9 deletions cli/src/__test__/e2e_connect_command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ describe('e2e test for `connect` command', () => {
async () => {
const testPath = path.join(__dirname, 'e2e_connect_command/react_storybook')

const result = await promisify(exec)(`npx tsx ../cli connect parse --dir ${testPath}`, {
cwd: __dirname,
})
const result = await promisify(exec)(
`npx tsx ../cli connect parse --skip-update-check --dir ${testPath}`,
{
cwd: __dirname,
},
)

expect(tidyStdOutput(result.stderr)).toBe(
`No config file found in ${testPath}, proceeding with default options
Expand Down Expand Up @@ -94,7 +97,7 @@ export default figma.tsx\`<ReactApiComponent />\``,
'successfully calls a first party parser executable',
async () => {
const result = await promisify(exec)(
`npx tsx ../cli connect parse --dir ./e2e_connect_command/unit_test_parser --verbose`,
`npx tsx ../cli connect parse --skip-update-check --dir ./e2e_connect_command/unit_test_parser --verbose`,
{
cwd: __dirname,
},
Expand All @@ -114,7 +117,7 @@ Success from parser!`,

it('does not fail with an error if a parser executable returns a warning', async () => {
const result = await promisify(exec)(
`npx tsx ../cli connect parse --dir ./e2e_connect_command/unit_test_parser_warning`,
`npx tsx ../cli connect parse --skip-update-check --dir ./e2e_connect_command/unit_test_parser_warning`,
{
cwd: __dirname,
},
Expand All @@ -131,7 +134,7 @@ Warning from parser!`,
it('fails with an error if a parser executable returns an error', async () => {
try {
await promisify(exec)(
`npx tsx ../cli connect parse --dir ./e2e_connect_command/unit_test_parser_error`,
`npx tsx ../cli connect parse --skip-update-check --dir ./e2e_connect_command/unit_test_parser_error`,
{
cwd: __dirname,
},
Expand All @@ -149,7 +152,7 @@ Errors encountered calling parser, exiting`,
it('returns an error if the first party parser does not exist', async () => {
try {
await promisify(exec)(
`npx tsx ../cli connect parse --dir ./e2e_connect_command/invalid_parser`,
`npx tsx ../cli connect parse --skip-update-check --dir ./e2e_connect_command/invalid_parser`,
{
cwd: __dirname,
},
Expand All @@ -166,7 +169,7 @@ Invalid parser specified: "does-not-exist". Valid parsers are: swift, compose, _
it('returns an error if the first party parser does not return a valid response', async () => {
try {
await promisify(exec)(
`npx tsx ../cli connect parse --dir ./e2e_connect_command/unit_test_parser_invalid_response`,
`npx tsx ../cli connect parse --skip-update-check --dir ./e2e_connect_command/unit_test_parser_invalid_response`,
{
cwd: __dirname,
},
Expand All @@ -175,7 +178,7 @@ Invalid parser specified: "does-not-exist". Valid parsers are: swift, compose, _
expect(e.code).toBe(1)
expect(tidyStdOutput(e.stderr)).toBe(
`Config file found, parsing ./e2e_connect_command/unit_test_parser_invalid_response using specified include globs
Error returned from parser: Validation error: Required at "docs[0].figmaNode"; Required at "docs[0].template"; Required at "docs[0].templateData"; Required at "docs[0].language"; Required at "docs[0].label"`,
Error returned from parser: Validation error: Required at "docs[0].figmaNode"; Required at "docs[0].template"; Required at "docs[0].templateData"; Required at "docs[0].language"; Required at "docs[0].label", try re-running the command with --verbose for more information.`,
)
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"originHash" : "6a0c41426781b92fbb7d0d41c10518f801bc269242a05db722f964e3783da238",
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax",
"state" : {
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
"version" : "509.1.1"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "dd989a46d0c6f15c016484bab8afe5e7a67a4022",
"version" : "0.54.0"
}
}
],
"version" : 3
}
20 changes: 20 additions & 0 deletions cli/src/__test__/e2e_connect_command/swift_package/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SwiftPackageCodeConnectE2ETest",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "CodeConnectE2ETest",
targets: ["CodeConnectE2ETest"]),
],
dependencies: [.package(path: "../../../../../../figmadoc")],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(name: "CodeConnectE2ETest"),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Figma
import SwiftUI

struct Toggle_doc: FigmaConnect {
let component = Toggle<AnyView>.self;

let figmaNodeUrl = "https://www.figma.com/file/test/test?node-id=12-345"

@State private var isOn = true
var body: some View {
Toggle(isOn: $isOn) {
// Add a label here
}
}

}

#Preview {
Toggle_doc()
}
Loading

0 comments on commit 444f438

Please sign in to comment.