Development
How to develop the extractor locally
Useful commands in the repository:
pnpm dev # run the extractor from sources (ts-node ./src/bin.ts)
pnpm build # compile TypeScript to dist/
pnpm test # run jest tests
pnpm lint # run eslintThere are 3 ways to develop:
-
Change and run tests on the local machine:
- add new functionality or change any existing
- change the
variables.jsonfile in the root folder - change related tests of the changed functionality
-
Link this repository with your real project as its dependency:
- In the
figma-extractorrepository, runpnpm link --global. It creates a link inside the pnpm cache folder with the name@shakuroinc/figma-extractor - Inside your project, run
pnpm link --global @shakuroinc/figma-extractor. It replaces the real@shakuroinc/figma-extractorpackage innode_moduleswith a symlink to the created link - Inside the
figma-extractorfolder, runpnpm buildafter every change. It's necessary to create compiled JS files in thedistfolder - Inside the project folder, run
pnpm extractto launch your linkedfigma-extractor
Remember! You need to run
pnpm buildafter any changes in thefigma-extractorrepositoryNote: this way you create just a link between the extractor and your project without installing
peerDependenciesoffigma-extractor. If you want to installpeerDependencies, use the 3rd way described below - In the
-
Link this repository with your real project through the file protocol:
- Inside your project, replace the version line in
package.json(e.g."@shakuroinc/figma-extractor": "^7.5.1") with"@shakuroinc/figma-extractor": "file:{absolute path to the figma-extractor folder}" - This way creates a link between your project and figma-extractor and installs all
peerDependenciesof figma-extractor - Run
pnpm installin the root of your project to create the link - Use
pnpm extractas usual
Remember! You need to run
pnpm buildas well when there are any changes in thefigma-extractorrepository - Inside your project, replace the version line in