Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@figma-export/cli

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@figma-export/cli - npm Package Compare versions

Comparing version 0.0.1-alpha.8 to 0.0.1-alpha.9

src/commands/from-config.js

2

oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"0.0.1-alpha.8","commands":{"components":{"id":"components","description":"Exports components from a Figma file\n","pluginName":"@figma-export/cli","pluginType":"core","aliases":[],"flags":{"page":{"name":"page","type":"option","char":"p","description":"Figma page names (defaults to 'all pages')"},"output":{"name":"output","type":"option","char":"o","description":"Output directory","default":"output"},"config":{"name":"config","type":"option","char":"c","description":"Configuration file","default":".figmaexportrc.js"},"outputter":{"name":"outputter","type":"option","char":"O","description":"Outputter module or path"},"transformer":{"name":"transformer","type":"option","char":"T","description":"Transformer module or path"}},"args":[{"name":"fileId","required":true}]}}}
{"version":"0.0.1-alpha.9","commands":{"components":{"id":"components","description":"Exports components from a Figma file\n","pluginName":"@figma-export/cli","pluginType":"core","aliases":[],"flags":{"page":{"name":"page","type":"option","char":"p","description":"Figma page names (defaults to 'all pages')"},"output":{"name":"output","type":"option","char":"o","description":"Output directory","default":"output"},"outputter":{"name":"outputter","type":"option","char":"O","description":"Outputter module or path"},"transformer":{"name":"transformer","type":"option","char":"T","description":"Transformer module or path"}},"args":[{"name":"fileId","required":true}]},"from-config":{"id":"from-config","description":"Exports from configuration file\n","pluginName":"@figma-export/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"config","required":true,"default":".figmaexportrc.js"}]}}}
{
"name": "@figma-export/cli",
"description": "Command line for @figma-export",
"version": "0.0.1-alpha.8",
"version": "0.0.1-alpha.9",
"author": "Marco Montalbano @marcomontalbano",

@@ -11,3 +11,3 @@ "bin": {

"dependencies": {
"@figma-export/core": "^0.0.1-alpha.8",
"@figma-export/core": "^0.0.1-alpha.9",
"@oclif/command": "~1.5.19",

@@ -52,3 +52,3 @@ "@oclif/config": "~1.13.3",

},
"gitHead": "358ac4e5fc372091f4eae2278bae64dea2834b94"
"gitHead": "c3ba405414c710f9fc08f3dff40619d07fa49279"
}

@@ -29,2 +29,3 @@

### `help`

@@ -36,2 +37,8 @@

### `from-config`
This command is well-explained into the project README. Look at [advanced](/README.md#advanced) section.
### `components`

@@ -112,27 +119,1 @@

| [`@figma-export/output-components-as-es6`](/packages/output-components-as-es6) | [![npm](https://img.shields.io/npm/v/@figma-export/output-components-as-es6.svg?maxAge=3600)](https://www.npmjs.com/package/@figma-export/output-components-as-es6) |
#### .figmaexportrc.js
You can create a file `.figmaexportrc.js` or use a different configuration file providing `-c` or `--config` option to `figma-export components` command.
```sh
npx figma-export components FILEID -c .figmaexportrc.prod.js -T TRANSFORMER
```
This file contains the `configs` object that you can use to provide special options to `transformers` and `outputters`.
```js
// .figmaexportrc.js
module.exports = {
configs: [
['@figma-export/transform-svg-with-svgo', {
plugins: [
{ removeViewBox: false },
{ removeDimensions: true }
]
}]
]
};
```

@@ -7,14 +7,22 @@ const { Command, flags: commandFlags } = require('@oclif/command');

const figma = require('@figma-export/core');
const figmaExport = require('@figma-export/core');
const utils = require('../utils');
const resolveNameOrPath = (nameOrPath) => {
const absolutePath = path.resolve(nameOrPath);
return {
name: nameOrPath,
path: fs.existsSync(absolutePath) ? absolutePath : nameOrPath,
};
return fs.existsSync(absolutePath) ? absolutePath : nameOrPath;
};
const requirePackages = (packages, baseOptions = {}) => {
return packages.map((pkg) => {
if (typeof pkg === 'function') {
return pkg;
}
const pkgNameOrPath = resolveNameOrPath(pkg);
// eslint-disable-next-line import/no-dynamic-require, global-require
return require(pkgNameOrPath)(baseOptions);
});
};
class ComponentsCommand extends Command {

@@ -31,3 +39,2 @@ async run() {

transformer = [],
config,
},

@@ -40,12 +47,7 @@ } = this.parse(ComponentsCommand);

figma.setToken(process.env.FIGMA_TOKEN);
utils.mkdirRecursive(output);
return figma.exportComponents(fileId, {
output,
configFile: config,
return figmaExport.components(fileId, {
token: process.env.FIGMA_TOKEN,
onlyFromPages: page,
transformers: transformer.map(resolveNameOrPath),
outputters: outputter.map(resolveNameOrPath),
transformers: requirePackages(transformer),
outputters: requirePackages(outputter, { output }),
log: (message) => { spinner.text = message; },

@@ -83,8 +85,2 @@ }).then(() => {

}),
config: commandFlags.string({
char: 'c',
description: 'Configuration file',
default: '.figmaexportrc.js',
multiple: false,
}),
outputter: commandFlags.string({

@@ -91,0 +87,0 @@ char: 'O',

const { expect, test } = require('@oclif/test');
const figma = require('@figma-export/core');
const figmaExport = require('@figma-export/core');
const utils = require('../utils');
describe('components', () => {
beforeEach(() => {
sinon.stub(figma, 'setToken');
sinon.stub(utils, 'mkdirRecursive');
});
afterEach(() => {

@@ -18,3 +11,3 @@ sinon.restore();

it('should stdout a proper message with a fileId and an outputter', () => {
sinon.stub(figma, 'exportComponents').returns(Promise.resolve());
sinon.stub(figmaExport, 'components').returns(Promise.resolve());

@@ -30,3 +23,3 @@ test

it('should throw an error with invalid fields (rejection)', () => {
sinon.stub(figma, 'exportComponents').returns(Promise.reject(new Error('Something went wrong')));
sinon.stub(figmaExport, 'components').returns(Promise.reject(new Error('Something went wrong')));

@@ -33,0 +26,0 @@ test

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc