npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xinliang/figma

v1.0.4

Published

这个npm包旨在帮助开发者从Figma设计文件中下载图片。它支持通过Figma API下载特定类型节点的图片,并允许用户通过命令行参数、配置文件或`package.json`中的配置来指定下载选项。

Downloads

7

Readme

Figma 图片下载器

这个npm包旨在帮助开发者从Figma设计文件中下载图片。它支持通过Figma API下载特定类型节点的图片,并允许用户通过命令行参数、配置文件或package.json中的配置来指定下载选项。

功能特点

  • 支持多种节点类型的图片下载
  • 支持命令行参数、figma.config.js配置文件和package.json配置
  • 灵活的配置优先级,以适应不同的工作流程

安装

使用npm安装:

npm install @xinliang/figma -D

@xinliang/figma 将提供一个 figma 命令用来下载图片

使用方法

通过命令行

由于命令行中的特殊字符可能导致解析错误,建议将命令添加到package.jsonscripts字段中,如下所示:

  1. 在项目的package.json文件中,添加一个脚本命令:

"scripts": {
    "download-figma-images": "figma --url=\"https://www.figma.com/file/示例文件ID/示例页面名称?type=design&node-id=示例节点ID&mode=design\" -t \"你的Figma访问令牌\""
}

请将示例文件ID示例页面名称示例节点ID你的Figma访问令牌替换为实际的值。

  1. 通过运行以下命令来执行脚本:

使用npm:

npm run download-figma-images

可用选项

  • -u, --url <url>: Figma文件的URL(必需)
  • -t, --accessToken <accessToken>: Figma访问令牌(必需)
  • -p, --imageSavePath [imageSavePath]: 图片保存路径,默认为./figma/images
  • -n, --nodeTypes [nodeTypes]: 要下载的节点类型,多个类型用逗号分隔,默认为FRAME
  • -s, --scale [scale]: 图片缩放比例,介于0.01和4之间,默认为2
  • -f, --format [format]: 图片输出格式,可以是jpgpngsvgpdf,默认为png

配置文件

您可以在项目根目录下创建一个figma.config.js文件,以JavaScript对象的形式指定配置选项。例如:

    module.exports = {
        url: "Figma文件URL",
        accessToken: "Figma访问令牌",
        imageSavePath: "./path/to/save/images",
        nodeTypes: "FRAME,COMPONENT",
        scale: 1,
        format: "png"
    };

此外,您也可以在package.json中添加一个figma节点来指定配置:

// package.json
{
    "figma": {
        "url": "Figma文件URL",
        "accessToken": "Figma访问令牌",
        ...
    }
}