figma-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- figma_cli-0.1.0/.github/workflows/ci.yml +30 -0
- figma_cli-0.1.0/.github/workflows/release.yml +49 -0
- figma_cli-0.1.0/.gitignore +8 -0
- figma_cli-0.1.0/LICENSE +21 -0
- figma_cli-0.1.0/PKG-INFO +82 -0
- figma_cli-0.1.0/README.md +57 -0
- figma_cli-0.1.0/pyproject.toml +50 -0
- figma_cli-0.1.0/src/figma_cli/__init__.py +3 -0
- figma_cli-0.1.0/src/figma_cli/cli.py +28 -0
- figma_cli-0.1.0/tests/__init__.py +0 -0
- figma_cli-0.1.0/tests/test_cli.py +82 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v5
|
|
20
|
+
- uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- name: Install
|
|
24
|
+
run: python -m pip install -e ".[dev]"
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: ruff check .
|
|
27
|
+
- name: Format
|
|
28
|
+
run: ruff format --check .
|
|
29
|
+
- name: Test
|
|
30
|
+
run: pytest tests/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v5
|
|
15
|
+
- uses: actions/setup-python@v6
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
- name: Install build tools
|
|
19
|
+
run: python -m pip install build "twine>=6.1.0"
|
|
20
|
+
- name: Verify tag matches __version__
|
|
21
|
+
run: |
|
|
22
|
+
version=$(python -c "import re, pathlib; print(re.search(r'^__version__ = \"([^\"]+)\"', pathlib.Path('src/figma_cli/__init__.py').read_text(), re.M).group(1))")
|
|
23
|
+
if [ "${GITHUB_REF_NAME#v}" != "$version" ]; then
|
|
24
|
+
echo "::error::tag $GITHUB_REF_NAME does not match __version__ $version"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
- name: Build
|
|
28
|
+
run: python -m build
|
|
29
|
+
- name: Check
|
|
30
|
+
run: twine check --strict dist/*
|
|
31
|
+
- uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: dist
|
|
34
|
+
path: dist/
|
|
35
|
+
|
|
36
|
+
publish:
|
|
37
|
+
needs: build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
environment:
|
|
40
|
+
name: pypi
|
|
41
|
+
url: https://pypi.org/p/figma-cli
|
|
42
|
+
permissions:
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist/
|
|
49
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
figma_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 imperfect-co
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
figma_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: figma-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Headless Figma CLI for AI coding agents and automated design inspection.
|
|
5
|
+
Project-URL: Homepage, https://github.com/imperfect-co/figma-cli
|
|
6
|
+
Project-URL: Issues, https://github.com/imperfect-co/figma-cli/issues
|
|
7
|
+
Author: imperfect-co
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
23
|
+
Requires-Dist: twine>=6.1.0; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# figma-cli
|
|
27
|
+
|
|
28
|
+
Headless Figma CLI for AI coding agents and automated design inspection.
|
|
29
|
+
|
|
30
|
+
Requires Python 3.11 or newer. Licensed under MIT.
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
The package installs two console scripts that run the same entrypoint:
|
|
35
|
+
|
|
36
|
+
- `figma-cli`
|
|
37
|
+
- `figma` (short alias)
|
|
38
|
+
|
|
39
|
+
Each reports its own name in `--help` and `--version`:
|
|
40
|
+
|
|
41
|
+
```console
|
|
42
|
+
$ figma-cli --version
|
|
43
|
+
figma-cli 0.1.0
|
|
44
|
+
$ figma --version
|
|
45
|
+
figma 0.1.0
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The npm package `silships/figma-cli` also installs a `figma-cli` executable. If both are installed, whichever directory comes first on `PATH` wins. Run `command -v figma-cli` to check which one you get, or use the `figma` alias.
|
|
49
|
+
|
|
50
|
+
## Run without installing
|
|
51
|
+
|
|
52
|
+
Before the first PyPI release, run straight from the repository with [uv](https://docs.astral.sh/uv/):
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
uvx --from git+https://github.com/imperfect-co/figma-cli figma-cli --help
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
From a local checkout:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
uvx --from . figma-cli --version
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
python -m venv .venv && . .venv/bin/activate
|
|
68
|
+
pip install -e ".[dev]"
|
|
69
|
+
ruff check .
|
|
70
|
+
ruff format --check .
|
|
71
|
+
pytest tests/
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The tests are hermetic: no network access and no Figma token are needed.
|
|
75
|
+
|
|
76
|
+
## Release
|
|
77
|
+
|
|
78
|
+
Bump `__version__` in `src/figma_cli/__init__.py`, merge, then push a matching tag (`v0.1.0` for `0.1.0`). The release workflow refuses a tag that does not match `__version__`, builds the sdist and wheel, runs `twine check`, and publishes to PyPI through trusted publishing (OIDC, the `pypi` environment).
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# figma-cli
|
|
2
|
+
|
|
3
|
+
Headless Figma CLI for AI coding agents and automated design inspection.
|
|
4
|
+
|
|
5
|
+
Requires Python 3.11 or newer. Licensed under MIT.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
The package installs two console scripts that run the same entrypoint:
|
|
10
|
+
|
|
11
|
+
- `figma-cli`
|
|
12
|
+
- `figma` (short alias)
|
|
13
|
+
|
|
14
|
+
Each reports its own name in `--help` and `--version`:
|
|
15
|
+
|
|
16
|
+
```console
|
|
17
|
+
$ figma-cli --version
|
|
18
|
+
figma-cli 0.1.0
|
|
19
|
+
$ figma --version
|
|
20
|
+
figma 0.1.0
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The npm package `silships/figma-cli` also installs a `figma-cli` executable. If both are installed, whichever directory comes first on `PATH` wins. Run `command -v figma-cli` to check which one you get, or use the `figma` alias.
|
|
24
|
+
|
|
25
|
+
## Run without installing
|
|
26
|
+
|
|
27
|
+
Before the first PyPI release, run straight from the repository with [uv](https://docs.astral.sh/uv/):
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
uvx --from git+https://github.com/imperfect-co/figma-cli figma-cli --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
From a local checkout:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
uvx --from . figma-cli --version
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Development
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
python -m venv .venv && . .venv/bin/activate
|
|
43
|
+
pip install -e ".[dev]"
|
|
44
|
+
ruff check .
|
|
45
|
+
ruff format --check .
|
|
46
|
+
pytest tests/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The tests are hermetic: no network access and no Figma token are needed.
|
|
50
|
+
|
|
51
|
+
## Release
|
|
52
|
+
|
|
53
|
+
Bump `__version__` in `src/figma_cli/__init__.py`, merge, then push a matching tag (`v0.1.0` for `0.1.0`). The release workflow refuses a tag that does not match `__version__`, builds the sdist and wheel, runs `twine check`, and publishes to PyPI through trusted publishing (OIDC, the `pypi` environment).
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "figma-cli"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Headless Figma CLI for AI coding agents and automated design inspection."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
authors = [{ name = "imperfect-co" }]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
]
|
|
24
|
+
dependencies = []
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest", "ruff", "build", "twine>=6.1.0"]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
figma-cli = "figma_cli.cli:main"
|
|
31
|
+
figma = "figma_cli.cli:main"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/imperfect-co/figma-cli"
|
|
35
|
+
Issues = "https://github.com/imperfect-co/figma-cli/issues"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.version]
|
|
38
|
+
path = "src/figma_cli/__init__.py"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/figma_cli"]
|
|
42
|
+
|
|
43
|
+
[tool.ruff]
|
|
44
|
+
target-version = "py311"
|
|
45
|
+
|
|
46
|
+
[tool.ruff.lint]
|
|
47
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Console entrypoint shared by the ``figma-cli`` and ``figma`` commands."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from collections.abc import Sequence
|
|
5
|
+
|
|
6
|
+
from figma_cli import __version__
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
10
|
+
# prog is left unset so it follows sys.argv[0]: each alias reports its own name.
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
description=(
|
|
13
|
+
"Headless Figma CLI for AI coding agents and automated design inspection."
|
|
14
|
+
),
|
|
15
|
+
)
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
"--version", action="version", version=f"%(prog)s {__version__}"
|
|
18
|
+
)
|
|
19
|
+
return parser
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
23
|
+
build_parser().parse_args(argv)
|
|
24
|
+
return 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
raise SystemExit(main())
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Hermetic tests for the CLI entrypoint: no network, no installed scripts required."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tomllib
|
|
7
|
+
from importlib import import_module
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from figma_cli import __version__
|
|
13
|
+
from figma_cli.cli import main
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
16
|
+
ALIASES = ("figma-cli", "figma")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _scripts() -> dict[str, str]:
|
|
20
|
+
with (ROOT / "pyproject.toml").open("rb") as fh:
|
|
21
|
+
return tomllib.load(fh)["project"]["scripts"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _resolve(target: str):
|
|
25
|
+
module, _, attr = target.partition(":")
|
|
26
|
+
return getattr(import_module(module), attr)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_version_flag(capsys):
|
|
30
|
+
with pytest.raises(SystemExit) as exc:
|
|
31
|
+
main(["--version"])
|
|
32
|
+
assert exc.value.code == 0
|
|
33
|
+
assert __version__ in capsys.readouterr().out
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_help_flag(capsys):
|
|
37
|
+
with pytest.raises(SystemExit) as exc:
|
|
38
|
+
main(["--help"])
|
|
39
|
+
assert exc.value.code == 0
|
|
40
|
+
out = capsys.readouterr().out
|
|
41
|
+
assert "usage:" in out
|
|
42
|
+
assert "--version" in out
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_no_args_exits_zero():
|
|
46
|
+
assert main([]) == 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_unknown_flag_exits_two(capsys):
|
|
50
|
+
with pytest.raises(SystemExit) as exc:
|
|
51
|
+
main(["--no-such-flag"])
|
|
52
|
+
assert exc.value.code == 2
|
|
53
|
+
assert "unrecognized arguments" in capsys.readouterr().err
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_both_aliases_declared():
|
|
57
|
+
assert {name: _scripts().get(name) for name in ALIASES} == {
|
|
58
|
+
name: "figma_cli.cli:main" for name in ALIASES
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
63
|
+
def test_alias_reports_its_own_name(alias, monkeypatch, capsys):
|
|
64
|
+
monkeypatch.setattr(sys, "argv", [alias, "--version"])
|
|
65
|
+
with pytest.raises(SystemExit) as exc:
|
|
66
|
+
_resolve(_scripts()[alias])()
|
|
67
|
+
assert exc.value.code == 0
|
|
68
|
+
assert capsys.readouterr().out.strip() == f"{alias} {__version__}"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.parametrize("flag", ["--version", "--help"])
|
|
72
|
+
def test_module_execution(flag):
|
|
73
|
+
env = {**os.environ, "PYTHONPATH": str(ROOT / "src")}
|
|
74
|
+
result = subprocess.run(
|
|
75
|
+
[sys.executable, "-m", "figma_cli.cli", flag],
|
|
76
|
+
capture_output=True,
|
|
77
|
+
text=True,
|
|
78
|
+
env=env,
|
|
79
|
+
check=False,
|
|
80
|
+
)
|
|
81
|
+
assert result.returncode == 0, result.stderr
|
|
82
|
+
assert (__version__ if flag == "--version" else "usage:") in result.stdout
|