-
Notifications
You must be signed in to change notification settings - Fork 3
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
add figma.ts with bun #36
base: main
Are you sure you want to change the base?
Conversation
@takanorip Can you please share the motivations behind rewriting the script in TypeScript? |
@jmblog |
'X-FIGMA-TOKEN': TOKEN, | ||
}, | ||
}); | ||
const { meta }: GetFileComponentsResponse = await response.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typed with @figma/rest-api-spec
'X-FIGMA-TOKEN': TOKEN, | ||
}, | ||
}); | ||
const { images }: GetImagesResponse = await svgResponse.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typed with @figma/rest-api-spec
package.json
Outdated
@@ -27,6 +27,7 @@ | |||
], | |||
"scripts": { | |||
"figma": "node ./scripts/figma.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the old one yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this is using it in GitHub Actions, but I noticed the file was deleted recently.
Since it seems unnecessary, I will remove it and add a section about Bun in the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done with fc2b434
I have rewritten the script for downloading SVGs from Figma in TypeScript, and made it runnable on Bun.
https://bun.sh/
While Bun has some problems of making it difficult to check differences in the lock file, there are means provided to check differences on Git, and since this repository only contains small scripts, I consider it not to be a problem.
https://bun.sh/docs/install/lockfile
motivation
Although the values are obtained from Figma's API, I feel that maintainability is low because we have to read the documentation to find out what structure of data is returned from the API.
Figma has published typescript types for its REST API, which will allow API responses to be typed, making them easier to develop.
https://github.com/figma/rest-api-spec
The reasons for adopting Bun are the following 3 points: