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 4.0.0-alpha.0 to 4.0.0-alpha.1

dist/run.d.ts

20

dist/commands/components.d.ts

@@ -1,18 +0,4 @@

import { Command } from '@oclif/core';
export declare class ComponentsCommand extends Command {
static description: string;
static args: {
name: string;
required: boolean;
}[];
static flags: {
fileVersion: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
page: import("@oclif/core/lib/interfaces").OptionFlag<string[]>;
concurrency: import("@oclif/core/lib/interfaces").OptionFlag<number>;
output: import("@oclif/core/lib/interfaces").OptionFlag<string>;
outputter: import("@oclif/core/lib/interfaces").OptionFlag<string[]>;
transformer: import("@oclif/core/lib/interfaces").OptionFlag<string[]>;
};
run(): Promise<void>;
}
import { Ora } from 'ora';
import { Sade } from 'sade';
export declare const addComponents: (prog: Sade, spinner: Ora) => Sade;
//# sourceMappingURL=components.d.ts.map

@@ -21,88 +21,54 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComponentsCommand = void 0;
const core_1 = require("@oclif/core");
exports.addComponents = void 0;
const figmaExport = __importStar(require("@figma-export/core"));
const utils_1 = require("../utils");
const ora = require("ora");
const spinner = ora({});
class ComponentsCommand extends core_1.Command {
run() {
return __awaiter(this, void 0, void 0, function* () {
const { args: { fileId, }, flags: { fileVersion, page, output, concurrency, outputter = [], transformer = [], }, } = yield this.parse(ComponentsCommand);
spinner.info(`Exporting ${fileId} with [${transformer.join(', ')}] as [${outputter.join(', ')}]`);
spinner.start();
figmaExport.components({
fileId,
version: fileVersion,
concurrency,
token: process.env.FIGMA_TOKEN || '',
onlyFromPages: page,
transformers: (0, utils_1.requirePackages)(transformer),
outputters: (0, utils_1.requirePackages)(outputter, { output }),
log: (message) => { spinner.text = message; },
}).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.error(error);
});
});
}
}
exports.ComponentsCommand = ComponentsCommand;
ComponentsCommand.description = `export components from a Figma file
`;
ComponentsCommand.args = [
{
name: 'fileId',
required: true,
},
];
ComponentsCommand.flags = {
fileVersion: core_1.Flags.string({
required: false,
description: `
A specific version ID to get. Omitting this will get the current version of the file.
https://help.figma.com/hc/en-us/articles/360038006754-View-a-file-s-version-history`,
multiple: false,
}),
page: core_1.Flags.string({
char: 'p',
description: 'Figma page names (defaults to \'all pages\')',
multiple: true,
}),
concurrency: core_1.Flags.integer({
char: 'c',
description: 'Concurrency when fetching',
default: 30,
multiple: false,
}),
output: core_1.Flags.string({
char: 'o',
description: 'Output directory',
default: 'output',
multiple: false,
}),
outputter: core_1.Flags.string({
char: 'O',
description: 'Outputter module or path',
multiple: true,
}),
transformer: core_1.Flags.string({
char: 'T',
description: 'Transformer module or path',
multiple: true,
}),
};
const addComponents = (prog, spinner) => prog
.command('components <fileId>')
.describe('Export components from a Figma file.')
.option('-O, --outputter', 'Outputter module or path')
.option('-T, --transformer', 'Transformer module or path')
.option('-c, --concurrency', 'Concurrency when fetching', 30)
.option('-o, --output', 'Output directory', 'output')
.option('-p, --page', 'Figma page names (all pages when not specified)')
.option('--fileVersion', `A specific version ID to get. Omitting this will get the current version of the file.
https://help.figma.com/hc/en-us/articles/360038006754-View-a-file-s-version-history`)
.example('components fzYhvQpqwhZDUImRz431Qo -O @figma-export/output-components-as-svg')
.action((fileId, _a) => {
var { fileVersion, concurrency, output } = _a, opts = __rest(_a, ["fileVersion", "concurrency", "output"]);
const outputter = (0, utils_1.asArray)(opts.outputter);
const transformer = (0, utils_1.asArray)(opts.transformer);
const page = (0, utils_1.asArray)(opts.page);
spinner.info(`Exporting ${fileId} with [${transformer.join(', ')}] as [${outputter.join(', ')}]`);
spinner.start();
figmaExport.components({
fileId,
version: fileVersion,
concurrency,
token: process.env.FIGMA_TOKEN || '',
onlyFromPages: page,
transformers: (0, utils_1.requirePackages)(transformer),
outputters: (0, utils_1.requirePackages)(outputter, { output }),
// eslint-disable-next-line no-param-reassign
log: (message) => { spinner.text = message; },
}).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.error(error);
});
});
exports.addComponents = addComponents;
//# sourceMappingURL=components.js.map

@@ -1,15 +0,4 @@

import { Command } from '@oclif/core';
export declare class StylesCommand extends Command {
static description: string;
static args: {
name: string;
required: boolean;
}[];
static flags: {
fileVersion: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
output: import("@oclif/core/lib/interfaces").OptionFlag<string>;
outputter: import("@oclif/core/lib/interfaces").OptionFlag<string[]>;
};
run(): Promise<void>;
}
import { Ora } from 'ora';
import { Sade } from 'sade';
export declare const addStyles: (prog: Sade, spinner: Ora) => Sade;
//# sourceMappingURL=styles.d.ts.map

@@ -21,69 +21,46 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylesCommand = void 0;
const core_1 = require("@oclif/core");
exports.addStyles = void 0;
const figmaExport = __importStar(require("@figma-export/core"));
const utils_1 = require("../utils");
const ora = require("ora");
const spinner = ora({});
class StylesCommand extends core_1.Command {
run() {
return __awaiter(this, void 0, void 0, function* () {
const { args: { fileId, }, flags: { output, outputter = [], fileVersion, }, } = yield this.parse(StylesCommand);
spinner.info(`Exporting ${fileId} as [${outputter.join(', ')}]`);
spinner.start();
figmaExport.styles({
fileId,
version: fileVersion,
token: process.env.FIGMA_TOKEN || '',
outputters: (0, utils_1.requirePackages)(outputter, { output }),
log: (message) => { spinner.text = message; },
}).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.log(error);
});
});
}
}
exports.StylesCommand = StylesCommand;
StylesCommand.description = `export styles from a Figma file
`;
StylesCommand.args = [
{
name: 'fileId',
required: true,
},
];
StylesCommand.flags = {
fileVersion: core_1.Flags.string({
required: false,
description: `
A specific version ID to get. Omitting this will get the current version of the file.
https://help.figma.com/hc/en-us/articles/360038006754-View-a-file-s-version-history`,
multiple: false,
}),
output: core_1.Flags.string({
char: 'o',
description: 'Output directory',
default: 'output',
multiple: false,
}),
outputter: core_1.Flags.string({
char: 'O',
description: 'Outputter module or path',
multiple: true,
}),
};
const addStyles = (prog, spinner) => prog
.command('styles <fileId>')
.describe('Export styles from a Figma file.')
.option('-O, --outputter', 'Outputter module or path')
.option('-o, --output', 'Output directory', 'output')
.option('--fileVersion', `A specific version ID to get. Omitting this will get the current version of the file.
https://help.figma.com/hc/en-us/articles/360038006754-View-a-file-s-version-history`)
.example('styles fzYhvQpqwhZDUImRz431Qo -O @figma-export/output-styles-as-css')
.action((fileId, _a) => {
var { fileVersion, output } = _a, opts = __rest(_a, ["fileVersion", "output"]);
const outputter = (0, utils_1.asArray)(opts.outputter);
spinner.info(`Exporting ${fileId} as [${outputter.join(', ')}]`);
spinner.start();
figmaExport.styles({
fileId,
version: fileVersion,
token: process.env.FIGMA_TOKEN || '',
outputters: (0, utils_1.requirePackages)(outputter, { output }),
// eslint-disable-next-line no-param-reassign
log: (message) => { spinner.text = message; },
}).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.log(error);
});
});
exports.addStyles = addStyles;
//# sourceMappingURL=styles.js.map

@@ -1,11 +0,4 @@

import { Command } from '@oclif/core';
export declare class UseConfigCommand extends Command {
static description: string;
static args: {
name: string;
default: string;
required: boolean;
}[];
run(): Promise<void>;
}
import { Ora } from 'ora';
import { Sade } from 'sade';
export declare const addUseConfig: (prog: Sade, spinner: Ora) => Sade;
//# sourceMappingURL=use-config.d.ts.map

@@ -30,56 +30,50 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UseConfigCommand = void 0;
const core_1 = require("@oclif/core");
exports.addUseConfig = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const figmaExport = __importStar(require("@figma-export/core"));
const fs = require("fs");
const path = require("path");
const ora = require("ora");
const spinner = ora({});
class UseConfigCommand extends core_1.Command {
run() {
return __awaiter(this, void 0, void 0, function* () {
const { args: { config, }, } = yield this.parse(UseConfigCommand);
const configPath = path.resolve(config);
// eslint-disable-next-line import/no-dynamic-require, global-require
const { commands = [] } = fs.existsSync(configPath) ? require(configPath) : {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const runExport = (figmaExporter, options) => figmaExporter(Object.assign(Object.assign({ token: process.env.FIGMA_TOKEN || '', fileId: '' }, options), { log: (message) => { spinner.text = message; } })).then((any) => {
spinner.succeed().start();
return any;
});
const commandPromises = commands.map((command) => {
const [commandName, options] = command;
switch (commandName) {
case 'components':
return () => runExport(figmaExport.components, options);
case 'styles':
return () => runExport(figmaExport.styles, options);
default:
throw new Error(`Command ${commandName} is not found.`);
}
});
spinner.start();
commandPromises.reduce((actualPromise, nextPromise) => {
return actualPromise.then(nextPromise);
}, Promise.resolve()).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.error(error);
});
});
}
}
exports.UseConfigCommand = UseConfigCommand;
UseConfigCommand.description = `export using a configuration file
`;
UseConfigCommand.args = [
{
name: 'config',
default: '.figmaexportrc.js',
required: true,
},
];
const addUseConfig = (prog, spinner) => prog
.command('use-config [configFile]', undefined)
.describe('Export using a configuration file.')
.example('use-config')
.example('use-config ./figmaexportrc.production.js')
.action((configFile = '.figmaexportrc.js') => {
const configPath = path_1.default.resolve(configFile);
// eslint-disable-next-line import/no-dynamic-require, global-require
const { commands = [] } = (fs_1.default.existsSync(configPath) ? require(configPath) : {});
const baseCommandOptions = {
token: process.env.FIGMA_TOKEN || '',
// eslint-disable-next-line no-param-reassign
log: (message) => { spinner.text = message; },
};
const commandPromises = commands.map((command) => {
switch (command[0]) {
case 'components':
return () => __awaiter(void 0, void 0, void 0, function* () {
yield figmaExport.components(Object.assign(Object.assign({}, baseCommandOptions), command[1]));
spinner.succeed().start();
});
case 'styles':
return () => __awaiter(void 0, void 0, void 0, function* () {
yield figmaExport.styles(Object.assign(Object.assign({}, baseCommandOptions), command[1]));
spinner.succeed().start();
});
default:
throw new Error(`Command ${command[0]} is not found.`);
}
});
spinner.start();
commandPromises.reduce((actualPromise, nextPromise) => actualPromise.finally(nextPromise), Promise.resolve()).then(() => {
spinner.succeed('done');
}).catch((error) => {
spinner.fail();
// eslint-disable-next-line no-console
console.error(error);
});
});
exports.addUseConfig = addUseConfig;
//# sourceMappingURL=use-config.js.map

@@ -1,2 +0,3 @@

export declare const requirePackages: <T extends Function>(packages: (string | T)[], baseOptions?: {}) => T[];
export declare const requirePackages: <T extends Function>(packages: string[], baseOptions?: {}) => T[];
export declare function asArray<T>(entry: T | T[] | undefined): T[];
//# sourceMappingURL=utils.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.requirePackages = void 0;
const fs = require("fs");
const path = require("path");
exports.asArray = exports.requirePackages = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const resolveNameOrPath = (nameOrPath) => {
const absolutePath = path.resolve(nameOrPath);
return fs.existsSync(absolutePath) ? absolutePath : nameOrPath;
const absolutePath = path_1.default.resolve(nameOrPath);
return fs_1.default.existsSync(absolutePath) ? absolutePath : nameOrPath;
};

@@ -13,5 +16,2 @@ // eslint-disable-next-line @typescript-eslint/ban-types

return packages.map((pkg) => {
if (typeof pkg === 'function') {
return pkg;
}
const pkgNameOrPath = resolveNameOrPath(pkg);

@@ -23,2 +23,6 @@ // eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires

exports.requirePackages = requirePackages;
function asArray(entry) {
return entry ? [].concat(entry) : [];
}
exports.asArray = asArray;
//# sourceMappingURL=utils.js.map
{
"name": "@figma-export/cli",
"description": "Command line for @figma-export",
"version": "4.0.0-alpha.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"version": "4.0.0-alpha.1",
"author": "Marco Montalbano",

@@ -13,13 +11,8 @@ "bin": {

"dependencies": {
"@figma-export/core": "^4.0.0-alpha.0",
"@figma-export/types": "^4.0.0-alpha.0",
"@oclif/core": "~1.0.10",
"@oclif/plugin-help": "~3.2.17",
"ora": "~5.4.1"
"@figma-export/core": "^4.0.0-alpha.1",
"@figma-export/types": "^4.0.0-alpha.1",
"@types/sade": "~1.7.4",
"ora": "~5.4.1",
"sade": "~1.7.4"
},
"devDependencies": {
"@oclif/dev-cli": "~1.26.9",
"@oclif/test": "~2.0.3",
"globby": "~11.0.4"
},
"engines": {

@@ -30,5 +23,3 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"

"/bin",
"/dist",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
"/dist"
],

@@ -44,13 +35,5 @@ "homepage": "https://github.com/marcomontalbano/figma-export",

"cli",
"figma cli",
"oclif"
"figma cli"
],
"license": "MIT",
"oclif": {
"commands": "./dist/commands",
"bin": "figma-export",
"plugins": [
"@oclif/plugin-help"
]
},
"repository": {

@@ -61,8 +44,3 @@ "type": "git",

},
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"prepack": "oclif-dev manifest && oclif-dev readme",
"version": "oclif-dev readme && git add README.md"
},
"gitHead": "69e5443cdb4a4f8ad9bf482d0a7dcca1bb261d96"
"gitHead": "086711cbbf9ef49e4d49dc143b01902cb0909afc"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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