Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I publish a single node instead of everything? #236

Open
renandf opened this issue Jan 30, 2025 · 5 comments
Open

Can I publish a single node instead of everything? #236

renandf opened this issue Jan 30, 2025 · 5 comments

Comments

@renandf
Copy link

renandf commented Jan 30, 2025

The title says it all. I'd like to publish a single node like I can do with the unpublish. for Example, I'd like this to work:

npx figma connect publish --node=NODE_URL

But I get error: unknown option '--node=NODE_URL' when trying to publish a single node.

The use case here is that I'm working on multiple branches to connect the components in our Design System. Given that we have Component 1, Component 2, ... Component X, and I'm working on individual git branches to update each component with Code Connect, once I publish Component 1 then work on Component 2, I'd like to be able to publish only Component 2. What happens is that I have to publish it all and an outdated version of Component 1 is published as well, because the updated version is on a different branch. This is causing workflow confusion because my team keeps publishing everything at once, updating the intended single component and bringing outdated versions of all other components in that branch.

Is there a way to publish just the component I'm currently working on?


  • Code Connect CLI version: 1.2.4
  • Operating system: macOS Sequoia 15.3 (24D60)
  • Code Connect file: (not relevant)
@lucoel
Copy link

lucoel commented Jan 30, 2025

What you can do is publishing only a specific component folder using --dir:

npx figma connect publish --dir src/components/Component1/

@renandf
Copy link
Author

renandf commented Jan 31, 2025

Thanks, that's very insightful! I didn't see that --dir flag in the docs 🙏

Testing it here, it's not working with our current setup using documentUrlSubstitutions inside figma.config.json, but it does work if I use the actual Figma node link directly inside the .figma.tsx file. More details below:

Setup

Inside figma.config.json, we have a list of url substitutions like the following:

{
  "codeConnect": {
    "parser": "react",
    "...": "...",
    "documentUrlSubstitutions": {
      "<FIGMA_BANNER>": "https://www.figma.com/design/<figma-node-1>",
      "<FIGMA_BUTTONS>": "https://www.figma.com/design/<figma-node-2>",
      "...": "...",
    }
  }
}

Then, inside the component file itself, for example Button.figma.tsx, we have:

figma.connect(Button, '<FIGMA_BUTTONS>', {...})

Failed to parse

If I run the following command with the setup above:

npx figma connect publish --dir src/button/

I get a Failed to parse <FIGMA_BUTTONS> error.

However, if I replace the <FIGMA_BUTTONS> inside the Button.figma.tsx with the actual Figma node link (e.g., https://www.figma.com/design/<figma-node-2>) then the command with the --dir flag works.

NB: Running the default command (npx figma connect publish) works fine and exports all components with a .figma.tsx file.

@rgullyfigma
Copy link

rgullyfigma commented Feb 20, 2025

Hi @renandf, there is a limitation here in that we look for the figma.config.json inside the --dir that is provided. The directory you're providing doesn't contain your figma.config.json so we fail to resolve your documentUrlSubstitutions.

A workaround for this is to also use the --config option and supply the path to your figma.config.json.

@renandf
Copy link
Author

renandf commented Feb 21, 2025

Thanks. Still struggling to make it work here. I'm getting different issues depending on "where I run the command from."

As mentioned before, if I run npx figma connect publish --dir src/button/ from the elements directory (where figma.config.json is), I get the No config file found in src/button error (as @rgullyfigma explained above). Then, I tried adding --config figma.config.json:

npx figma connect publish --dir src/button --config figma.config.json

Which oddly gives me the error:

Config file found, parsing src/button using specified include globs
No Code Connect files found in src/button - Make sure you have configured `include` and `exclude` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.

So it was able to find the config file, but now it's complaining about the Code Connect file, which it shouldn't be because it was exactly the same file it found in the previous command. The only difference was adding the --config flag. My include inside the config file is "include": ["src/**"].

Important

I get the same error even if I replace the <FIGMA_BUTTONS> inside the Button.figma.tsx with the actual Figma node link (e.g., https://www.figma.com/design/<figma-node-2>). Replacing the link works to publish the individual directory if I don't use the --config flag and only use --dir but it doesn't when I add --config.

If I move to the root directory (or any level above for that matter) and run the command with adjusted paths:

npx figma connect publish --dir packages/elements/src/button --config packages/elements/figma.config.json

I get a different error:

npm ERR! could not determine executable to run

@rgullyfigma
Copy link

rgullyfigma commented Feb 21, 2025

When running --dir src/button alongside "include": ["src/**"] it seems that an unresolvable path is produced like this .../src/button/src/** combining the include and the dir. I'll reach out to the team, because this seems like a bug.

In the meantime a workaround could be to temporarily remove the include from your figma.config.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants