code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

[Compose] Code connect, publish function problem

Open thxallgrace opened this issue 1 year ago • 5 comments

Please provide:

Code Connect CLI version: 1.2.4 Code Connect lib: 1.1.3 Code Connect Plugin lib: 1.2.1 Kotlin Gradle Plugin: 2.0.21

figma.config.json (I input this file in app directiory)

{
  "codeConnect": {
    "include": ["src/main/**"],
    "exclude": ["src/androidTest/**", "src/test/**", "build/**"],
    "parser": "compose",
    "gradleWrapperPath": "../gradlew"
  }
}

Issue

npx figma connect --token="{PERSONAL_ACCESS_TOKEN}" --verbose
 Welcome to Code Connect  ~~

Config file found, parsing {path}/app using specified include globs

✔ What is the URL of the Figma file containing design components you'd like to connect? … https://www.figma.com/design/~~
  Fetching component information from https://api.figma.com/v1/code_connect/{FIILE_KEY}/cli_data

Error returned from parser: Parser exited with code 1. Try re-running the command with --verbose for more information.

I got this error when I try to connect figma without detailed error reason. Do you have any solution about this? And I want to try connect and select component without interactive setup. Is there any way to connect figma with single line command ?

Oh, I have a extra question. Why tmp directory is created automatically? It seems that made it whenever i try to connect figma, I think. In my case, tmp directory made in app directory. (app/tmp)

Thanks

thxallgrace avatar Dec 19 '24 05:12 thxallgrace

Hey @thxallgrace! Thanks for the report. Would you mind rerunning it with --verbose? That should give us a bit more info to help track down the issue.

You can connect a single component with npx figma connect create "{URL of Figma component}" --token=PERSONAL_ACCESS_TOKEN. That command also works with --verbose and might be easier to run!

We do create a tmp directory to send data between the node + Kotlin code, but we should be cleaning up this directory. Will take a look.

slees-figma avatar Dec 19 '24 16:12 slees-figma

Hello @slees-figma! Thank you for your quick feedback! As I input the command line, I already used the --verbose option. The full command line I used is: npx figma connect --token="{PERSONAL_ACCESS_TOKEN}" --verbose Even though I used this option, I couldn't get any detailed error description at all.

thxallgrace avatar Dec 20 '24 00:12 thxallgrace

Thanks @thxallgrace, I've tried running npx figma connect publish with your same lib/plugin versions and not able to repro.

It might be worth trying out npx figma connect publish on a very basic composable (you can either run the command from a directory with just that composable in it, or temporarily change your config include) just to eliminate any concerns that it can't parse your code. Please could you try this?

slees-figma avatar Dec 20 '24 11:12 slees-figma

Hi,

We encounter the exact same issue on our Compose project:

npx figma connect
Error returned from parser: Parser exited with code 1. Try re-running the command with --verbose for more information.

Adding --verbose to the command line does not change the output (maybe the --verbose here refers to the underlying Gradle command?)

Environment

Code Connect CLI version: 1.3.2 Code Connect lib: 1.1.3 Code Connect Plugin lib: 1.2.1 Kotlin Gradle Plugin: 2.1.21 Android Studio: Meerkat Feature Drop | 2024.3.2

How to reproduce

  • Create a new empty Compose project in Android Studio
  • In the app build.gradle.kts file, add id("com.figma.code.connect") version "1.2.1" in the plugins section and implementation("com.figma.code.connect:code-connect-lib:1.1.3") in the dependencies.
  • Set Kotlin version to 2.1.21 (default value was 2.0.21).
  • Launch npx figma connect, the error appears right after this step: ? Select the pages with the Figma components you'd like to map (Press space to select and enter to continue) ›

Please note that npx figma connect seems to be working fine with Kotlin 2.0.21.

florentmaitre avatar May 22 '25 12:05 florentmaitre

Hey @florentmaitre, unfortunately we don't support Kotlin Gradle Plugin 2.1.0 right now (see https://www.figma.com/code-connect-docs/quickstart-guide/). We're working to resolve this at the moment and hope to have an update soon.

We'll also shortly be releasing another version of Code Connect that'll improve logging for Compose to help us debug this issues.

slees-figma avatar May 22 '25 17:05 slees-figma