figma-cli 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/CLAUDE.md +1 -1
- data/README.md +2 -2
- data/lib/figma/cli/command.rb +7 -4
- data/lib/figma/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 264bb31de4b3d3036daa7a20f03576254ebcf3384cc6ed468b319ae9fea96580
|
|
4
|
+
data.tar.gz: 6d7ebe134047f9a8a913d1a3aa6f3ee5e22d7004dfeae5ed6c5cbbc121955fb2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad2372c9cdc0eedafffcb8b420d16ce2812dc44efa59d6b35bc9d4d9d09e296e2b0e99fd194d7a29bb856f553adf402bde2f9bd1e69a2bba739968012069398f
|
|
7
|
+
data.tar.gz: 2edf0ee22d7ec970aee8886e185397e037153827be46b0ed32a272bbfbc2c3d65e0996687accb72ead38f3de4f11a28a613e354bef20adf8e536802a13192400
|
data/CLAUDE.md
CHANGED
|
@@ -44,7 +44,7 @@ lib/figma/cli/
|
|
|
44
44
|
- `--node-id` scopes spacing extraction to a subtree
|
|
45
45
|
|
|
46
46
|
### Writer (`Figma::Cli::Writer`)
|
|
47
|
-
- `Writer.write(data, output_dir:
|
|
47
|
+
- `Writer.write(data, output_dir:)` → array of 5 written file paths
|
|
48
48
|
- Writes `metadata.yml` (flat), `colors.yml`, `typography.yml`, `effects.yml`, `spacing.yml` (wrapped arrays)
|
|
49
49
|
- YAML output: no `---` header, `line_width: -1`, empty categories → `colors: []`
|
|
50
50
|
- Creates output directory if missing, overwrites silently (idempotent)
|
data/README.md
CHANGED
|
@@ -42,10 +42,10 @@ figma-cli version
|
|
|
42
42
|
|
|
43
43
|
## Output
|
|
44
44
|
|
|
45
|
-
Writes 5 YAML files to
|
|
45
|
+
Writes 5 YAML files to a temp directory by default (`/tmp/figma-cli/<file-key>/`). Files are cleaned up automatically on reboot. Use `-o` to write to a persistent location instead.
|
|
46
46
|
|
|
47
47
|
```
|
|
48
|
-
|
|
48
|
+
/tmp/figma-cli/<file-key>/
|
|
49
49
|
metadata.yml
|
|
50
50
|
colors.yml
|
|
51
51
|
typography.yml
|
data/lib/figma/cli/command.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "thor"
|
|
4
4
|
require "yaml"
|
|
5
|
+
require "tmpdir"
|
|
5
6
|
|
|
6
7
|
module Figma
|
|
7
8
|
module Cli
|
|
@@ -13,25 +14,27 @@ module Figma
|
|
|
13
14
|
|
|
14
15
|
desc "extract URL", "Extract design tokens from a Figma file"
|
|
15
16
|
option :node_id, type: :string, desc: "Figma node ID to scope extraction"
|
|
16
|
-
option :output, aliases: "-o", type: :string,
|
|
17
|
+
option :output, aliases: "-o", type: :string, desc: "Output directory (default: temp directory)"
|
|
17
18
|
def extract(url) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
18
19
|
client = Client.new
|
|
19
20
|
parser = Parser.new(client: client)
|
|
20
21
|
|
|
21
22
|
# Check cache: skip if local version matches remote
|
|
22
23
|
version_info = parser.file_version(url)
|
|
23
|
-
|
|
24
|
+
output_dir = options[:output] || File.join(Dir.tmpdir, "figma-cli", version_info[:file_key])
|
|
25
|
+
metadata_path = File.join(output_dir, "metadata.yml")
|
|
24
26
|
if File.exist?(metadata_path)
|
|
25
27
|
local = YAML.safe_load_file(metadata_path)
|
|
26
28
|
if local && local["version"] == version_info[:version]
|
|
27
29
|
warn "Up to date (version #{version_info[:version]}), skipping."
|
|
30
|
+
warn "Files at #{output_dir}/"
|
|
28
31
|
return
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
data = parser.extract(url, node_id: options[:node_id])
|
|
33
|
-
paths = Writer.write(data, output_dir:
|
|
34
|
-
warn "Wrote #{paths.size} files to #{
|
|
36
|
+
paths = Writer.write(data, output_dir: output_dir)
|
|
37
|
+
warn "Wrote #{paths.size} files to #{output_dir}/"
|
|
35
38
|
paths.each { |p| warn " #{p}" }
|
|
36
39
|
rescue Error => e
|
|
37
40
|
warn "Error: #{e.message}"
|
data/lib/figma/cli/version.rb
CHANGED