### FigX Import Flow Explanation Example Source: https://github.com/tonykolomeytsev/figx/blob/master/README.md An example output illustrating the import flow for a 'Sun' icon, showing the export from Figma, transformation to Compose code, and final file writing. ```text //app/src/main/java/com/example/figxdemo/ui/icons:Sun ├── 📤 Export SVG from remote @icons/MhjeA23R15tAR3PO2JamCv │ ┆ node: Environment / Sun ├── ✨ Transform SVG to Compose │ ┆ package: com.example.figxdemo.ui.icons ╰── 💾 Write to file ┆ output: Sun.kt ``` -------------------------------- ### FigX Resource Definition Example Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.5-labels.md Illustrates how to define resources within FigX using TOML format in .fig.toml files. This example shows resource definitions at the root level and within a nested package. ```toml [svg] ic_crab = "Icons/Crab" [svg] ic_star = "Icons/Star" ``` -------------------------------- ### FigX CLI Commands for Asset Management Source: https://context7.com/tonykolomeytsev/figx/llms.txt Example commands for interacting with FigX to import, query, and explain design assets within the project. ```bash $ figx import //... $ figx query -o tree //... $ figx explain //app/src/main/java/com/example/app/ui/icons:Sun ``` -------------------------------- ### Build Figx from Source (Bash) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/1-installation.md Builds the Figx tool from source using Cargo. This command ensures a release build with locked dependencies. It requires the Cargo build tool to be installed. ```bash cargo install --release --locked --path app ``` -------------------------------- ### Install Figx with Homebrew on macOS (Bash) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/1-installation.md Installs Figx on macOS using Homebrew. This involves tapping the custom repository and then installing the package. Homebrew must be installed on the system. ```bash brew tap tonykolomeytsev/figx brew install figx ``` -------------------------------- ### Label Pattern Matching Examples in FigX Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.5-labels.md Demonstrates various ways to use label patterns with the 'figx import' command to select specific resources or groups of resources within the FigX workspace. These patterns are inspired by Bazel's target pattern syntax. ```text figx import //... figx import //:all figx import //foo/bar:ic_star figx import //foo/... ``` -------------------------------- ### Extending TOML Profiles Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/1-profiles.md Illustrates how to create a custom profile by extending an existing one. This example shows inheriting settings from the 'webp' profile and overriding specific properties like quality and output directory. ```toml [profiles.custom-webp] extends = "webp" quality = 90 output_dir = "src/webp_assets" ``` -------------------------------- ### FigX Asset Import Command (Bash) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.2.1-minimal-example.md Executes the FigX import process using the CLI. This command reads the configurations from `.figtree.toml` and `.fig.toml` files and initiates the fetching and local saving of specified Figma assets. ```bash figx import //... ``` -------------------------------- ### Workspace Configuration Example (.figtree.toml) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Defines workspace-level settings for FigX, including the declaration of remotes and profiles. This TOML file marks the root of the FigX workspace and provides shared configuration applicable to all packages within the monorepo. ```toml # .figtree.toml - Workspace root configuration ``` -------------------------------- ### FigX Project Configuration (.figtree.toml) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.2.1-minimal-example.md Configures the global settings for FigX, including the Figma file key, container node IDs, and the access token required to interact with the Figma API. This TOML file defines the source of assets and authentication credentials. ```toml [remotes.figma] file_key = "MhjeA23R15tAR3PO2JamCv" # From the URL container_node_ids = ["30788-66292"] # The container node ID where icons live access_token = "..." # Your Figma access token ``` -------------------------------- ### Figma Token Setup UI and API Interaction (JavaScript) Source: https://github.com/tonykolomeytsev/figx/blob/master/crates/command/auth/res/index.html JavaScript functions to manage the display of steps in the Figma token setup process and to securely save the user's Personal Access Token via a POST request. It handles user input validation, API communication, and provides feedback on success or failure. ```javascript function showStep(stepNumber) { // Hide all steps document.querySelectorAll('.step').forEach(step => { step.classList.remove('active'); }); // Show the selected step document.getElementById(`step${stepNumber}`).classList.add('active'); } function saveToken() { const token = document.getElementById('tokenInput').value.trim(); const messageElement = document.getElementById('message'); const saveButton = document.getElementById('saveButton'); if (!token) { messageElement.textContent = "Please enter a token"; messageElement.style.color = "red"; return; } // Show loading state saveButton.disabled = true; saveButton.textContent = "Saving..."; fetch('./save_token', { method: 'POST', headers: { 'Content-Type': 'text/plain', 'X-Figma-Token': token, }, body: "", }) .then(response => { if (response.ok) { showStep(3); } else { messageElement.textContent = `Error saving token: ${response.statusText}`; messageElement.style.color = "red"; } }) .catch(error => { messageElement.textContent = "Network error: " + error.message; messageElement.style.color = "red"; }) .finally(() => { saveButton.disabled = false; saveButton.textContent = "Save Token"; }); } ``` -------------------------------- ### FigX Package Configuration (.fig.toml) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.2.1-minimal-example.md Defines specific asset import configurations for a package within FigX. This example sets up an SVG profile to import a vector image named 'Environment / Puzzle' from Figma and save it as 'puzzle.svg'. ```toml [svg] puzzle = "Environment / Puzzle" ``` -------------------------------- ### Create Custom FigX Profiles by Extending (TOML) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.3-profiles.md Example TOML configuration for creating custom FigX profiles by extending built-in profiles. This allows for inheriting settings from a base profile and applying specific modifications like scale and output directory. ```toml [profiles.illustrations] extends = "png" scale = 2.0 output_dir = "res/illustrations" ``` -------------------------------- ### Run FigX Import in Android Project Example Source: https://github.com/tonykolomeytsev/figx/blob/master/README.md This command imports icons and illustrations for an Android project using FigX. It supports generating Compose ImageVectors and WEBP format illustrations for various screen densities. A Figma personal access token is required. ```bash cd examples/android-project export FIGMA_PERSONAL_TOKEN="" figx import //... ``` -------------------------------- ### Run FigX Import in Multiple SVG Icons Example Source: https://github.com/tonykolomeytsev/figx/blob/master/README.md This command imports SVG icons using the FigX tool. It requires a Figma personal access token to be set as an environment variable. The output is typically a set of SVG files ready for use. ```bash cd examples/multiple-svg-icons export FIGMA_PERSONAL_TOKEN="" figx import //... ``` -------------------------------- ### Configure Built-in FigX Profiles (TOML) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.3-profiles.md Example TOML configurations for defining built-in image export profiles in FigX. These profiles specify parameters like scale, quality, and output directory for different image formats and use cases. ```toml [profiles.webp] # The scale at which the image will be exported scale = 2.0 # The target quality of the image when converting to WEBP (range: 0 to 100) quality = 85 # The directory where the downloaded WEBP images will be saved output_dir = "res/img" [profiles.android-drawable-xml] # The scale at which the image will be exported scale = 1.0 # Android project res dir android_res_dir = "src/main/res" ``` -------------------------------- ### Authenticate FigX Access Token via Command Line Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.2-remotes.md Initiates the FigX authentication process through the command line interface. This command guides the user through a web interface to securely store their Figma access token in the system's keychain. ```bash figx auth ``` -------------------------------- ### FigX GitHub Actions CI/CD Workflow Source: https://context7.com/tonykolomeytsev/figx/llms.txt A GitHub Actions workflow file to automate the import of Figma assets using FigX. It includes steps for installing FigX, caching metadata, performing the import, and creating a pull request for updates. Requires a Figma personal access token as a secret. ```yaml # .github/workflows/import-assets.yml name: Import Figma Assets on: schedule: - cron: '0 0 * * 1' # Weekly on Monday workflow_dispatch: jobs: import-assets: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install FigX run: | wget https://github.com/tonykolomeytsev/figx/releases/latest/download/figx-linux-x64.tar.gz tar -xzf figx-linux-x64.tar.gz sudo mv figx /usr/local/bin/ - name: Cache FigX metadata uses: actions/cache@v4 with: path: ~/.cache/figx key: figx-cache-${{ hashFiles('**/.figtree.toml', '**/.fig.toml') }} - name: Import assets env: FIGMA_PERSONAL_TOKEN: ${{ secrets.FIGMA_PERSONAL_TOKEN }} run: | figx import //... -vv - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: commit-message: "chore: update Figma assets" title: "Update design assets from Figma" body: "Automated import of latest Figma assets" branch: figx-assets-update # Docker-based approach $ docker run -v $(pwd):/workspace -e FIGMA_PERSONAL_TOKEN ghcr.io/tonykolomeytsev/figx:latest import //... ``` -------------------------------- ### Explain Figx Resource Import Flow Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Explains the step-by-step import process for specified Figx resources. This command provides details on how resources are exported, transformed, and written to files, including different variants and their configurations. ```bash figx explain //app:ill_travel //.../ui/icons:Sun ``` -------------------------------- ### List All Figx Resources Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Lists all Figx resources within the project without performing any import operations. This command is useful for inventorying available assets. ```bash figx query //... ``` -------------------------------- ### Explain Resource Import Flow (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Visualizes the transformation pipeline for specific resources, detailing each stage from Figma export to final output. This helps in debugging profile configurations and understanding resource processing. Supports explaining single or multiple resources. ```bash # Explain single resource figx explain //app/ui/icons:Sun # Example output: # //app/src/main/java/com/example/figxdemo/ui/icons:Sun # ├── 📤 Export SVG from remote @icons/MhjeA23R15tAR3PO2JamCv # │ ┆ node: Environment / Sun # ├── ✨ Transform SVG to Compose # │ ┆ package: com.example.figxdemo.ui.icons # ╰── 💾 Write to file # ┆ output: Sun.kt # Explain multiple resources figx explain //app/ui/icons:... ``` -------------------------------- ### Explain FigX Import Flow Source: https://github.com/tonykolomeytsev/figx/blob/master/README.md This command explains the step-by-step process for importing specific resources, detailing where assets are exported from, transformed, and written to the project. ```bash figx explain //.../ui/icons:Sun ``` -------------------------------- ### Import All Figx Resources Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Imports all available Figx resources from the project. This command is a general-purpose import for all types of assets managed by Figx. ```bash figx import //... ``` -------------------------------- ### Define PNG Resource in Fig-file Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.4-fig-files.md This example shows how to define a PNG resource named 'ic_nemo' in a .fig.toml file. It specifies that the resource should use the 'png' profile and be pulled from the Figma node named 'XEM'. The output filename will be 'ic_nemo.png' with default profile settings. ```toml [png] ic_nemo = "XEM" ``` -------------------------------- ### Figma File Key Extraction from URL Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.2.1-minimal-example.md Extracts the unique file key from a Figma file URL. This key is essential for FigX to identify the source Figma file for asset retrieval. The file key is the alphanumeric string found in the URL after '/design/'. ```text https://www.figma.com/design/MhjeA23R15tAR3PO2JamCv/coolicons-... ^^^^^^^^^^^^^^^^^^^^^^ <- This is the file_key ``` -------------------------------- ### Import Specific Drawable Resources Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Imports only WEBP drawable resources from a specified package (e.g., `//app`). It can accept package-specific wildcards like `//app:all` or `//app:*`. Note that `//app:*` may require shell globbing to be disabled or the pattern to be quoted in zsh. ```bash figx import //app:all ``` -------------------------------- ### List All Figx Packages Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Lists all Figx packages available in the project. The `-o package` flag filters the output to show only package information. ```bash figx query -o package //... ``` -------------------------------- ### Configure Android Drawable Profile in Figtree TOML Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/1.7-android-drawable-profile.md This TOML configuration block defines the settings for the Android drawable profile. It specifies the Figma remote to use, the root directory for Android resources, and the naming pattern for dark theme variants. Ensure the 'remote' ID corresponds to a configured remote in your Figtree setup. ```toml [profiles.android-drawable] # ID from the [remotes] section. # Uses the default remote if unspecified, but can reference any configured remote remote = "some_remote_id" # Root Android resources directory # (parent of drawable-* folders) android_res_dir = "src/main/res" # Dark theme configuration # Naming pattern for dark theme variants # {base} is replaced with base asset name # Leave unspecified to disable dark theme support night = "{base} / Dark" ``` -------------------------------- ### Figma Container Node ID Extraction from URL Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.2.1-minimal-example.md Extracts the container node ID from a Figma selection URL. This ID specifies the exact location within the Figma file where assets are organized, allowing FigX to target specific frames or component groups. The node ID is typically found at the end of the URL after '?node-id='. ```text https://www.figma.com/design/.../...?node-id=30788-66292 ^^^^^^^^^^^ <- node id of our container ``` -------------------------------- ### WebP Profile Configuration for Conversion Source: https://context7.com/tonykolomeytsev/figx/llms.txt Configures the 'webp' profile to download PNGs from Figma and convert them to WebP format, setting the output directory, quality, and scale. ```toml [profiles.webp] remote = "design" output_dir = "assets/webp" quality = 90 scale = 2.0 ``` -------------------------------- ### Basic TOML Profile Configuration Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/1-profiles.md Demonstrates the fundamental structure for configuring a profile in the `.figtree.toml` file. It shows how to reference remote configurations for a profile. ```toml [profiles.{profile_name}] remote = "default" ``` -------------------------------- ### Explain Resource Import Flow Source: https://context7.com/tonykolomeytsev/figx/llms.txt Visualizes the transformation pipeline for specific resources, showing each stage from Figma export through transformations to the final output. This is helpful for debugging profile configurations. ```APIDOC ## GET /figx/explain ### Description Visualizes the transformation pipeline for specific resources, showing each stage from Figma export through transformations to final output. Helpful for debugging profile configurations and understanding how resources are processed. ### Method GET ### Endpoint /figx/explain ### Parameters #### Path Parameters - **target** (string) - Required - The specific resource to explain using its label (e.g., `//app/ui/icons:Sun`). Accepts multiple targets with `...`. ### Request Example ```bash figx explain //app/ui/icons:Sun figx explain //app/ui/icons:... ``` ### Response #### Success Response (200) - **explanation** (string) - A textual representation of the resource's import flow, detailing each transformation step. #### Response Example ``` //app/src/main/java/com/example/figxdemo/ui/icons:Sun ├── 📤 Export SVG from remote @icons/MhjeA23R15tAR3PO2JamCv │ ┆ node: Environment / Sun ├── ✨ Transform SVG to Compose │ ┆ package: com.example.figxdemo.ui.icons ╰── 💾 Write to file ┆ output: Sun.kt ``` ``` -------------------------------- ### Query Resources in Workspace Source: https://context7.com/tonykolomeytsev/figx/llms.txt Lists and searches for resources, packages, or profiles defined in your workspace without triggering imports. This command is useful for validation, CI checks, and understanding project structure. ```APIDOC ## GET /figx/query ### Description Lists and searches for resources, packages, or profiles defined in your workspace without triggering imports. Useful for validation, CI checks, and understanding project structure. ### Method GET ### Endpoint /figx/query ### Parameters #### Query Parameters - **o** (string) - Optional - Specifies the output format (e.g., `package`, `profile`, `tree`). #### Path Parameters - **targets** (string) - Required - Specifies the scope for querying using label patterns (e.g., `//...`, `//app/ui/icons:...`). ### Request Example ```bash figx query //... figx query -o package //... figx query -o tree //... ``` ### Response #### Success Response (200) - **results** (array) - A list of queried items based on the specified targets and output format. #### Response Example ```json { "results": [ "//app/ui/icons:Sun", "//app/ui/icons:Moon" ] } ``` ``` -------------------------------- ### Running FigX Icon Import Command Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/3.1.4-android-compose-2.md Executes the FigX import process for all modules containing a `.fig.toml` configuration file. The `//...` pattern ensures recursive discovery and import of icon assets. ```bash figx import //... ``` -------------------------------- ### Query Resources in Workspace (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Lists and searches for resources, packages, or profiles within the FigX workspace without initiating imports. This command is useful for validation, CI checks, and understanding project structure. Supports various output formats including tree views and filtering by profile type. ```bash # List all resources figx query //... # List all packages figx query -o package //... # List by profile type figx query -o profile //... # Query specific package figx query //app/ui/icons:... # Tree view output figx query -o tree //... ``` -------------------------------- ### PNG Profile Configuration for Raster Export Source: https://context7.com/tonykolomeytsev/figx/llms.txt Sets up the 'png' profile to download PNG raster images from Figma, specifying the output directory and a scale factor for the export. ```toml [profiles.png] remote = "design" output_dir = "assets/png" scale = 2.0 ``` -------------------------------- ### Android-Webp Profile Configuration in .figtree.toml Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/1.6-android-webp-profile.md This TOML configuration block defines the settings for the 'android-webp' profile in Figx. It specifies the Figma remote, Android resource directory, WEBP quality, supported densities, and dark theme naming patterns. The 'legacy_loader' option allows switching between the default SVG-to-PNG-to-WEBP process and the legacy PNG-to-WEBP process. ```toml [profiles.android-webp] # ID from the [remotes] section. # Uses the default remote if unspecified, but can reference any configured remote remote = "some_remote_id" # Root Android resources directory # (parent of drawable-* folders) android_res_dir = "src/main/res" # Output quality for WEBP conversion (0-100) # Defaults to 100 (lossless) - recommended value quality = 100 # Density configurations scales = ["mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"] # Dark theme configuration # Naming pattern for dark theme variants # {base} is replaced with base asset name # Leave unspecified to disable dark theme support night = "{base} / Dark" # If true, the legacy resource loading method will be used. # The new approach downloads the SVG source and renders the raster image locally. # In most cases, this significantly speeds up the import process. # This may not suit all use cases, so the feature can be disabled. legacy_loader = false ``` -------------------------------- ### Android WebP Profile for Drawable Resources Source: https://context7.com/tonykolomeytsev/figx/llms.txt Configures the 'android-illustrations' profile to download and convert assets to WebP format, organized for Android's drawable resource structure. It supports density variations and night mode. ```toml [profiles.android-illustrations] extends = "android-webp" remote = "illustrations" android_res_dir = "src/main/res" quality = 100 densities = ["mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"] # Dark theme variant naming pattern night = "{base} (Dark)" # Use legacy PNG-based loader instead of SVG rendering legacy_loader = false ``` -------------------------------- ### Import Jetpack Compose Icons Source: https://github.com/tonykolomeytsev/figx/blob/master/examples/android-project/README.md Imports Jetpack Compose icons from a specified package path. This is useful for integrating icon assets directly into Android Jetpack Compose UI. ```bash figx import //.../ui/icons:all ``` -------------------------------- ### FigX CLI Commands for Asset Import Source: https://context7.com/tonykolomeytsev/figx/llms.txt Demonstrates FigX command-line interface usage for importing assets from Figma. These commands are used for various project structures, including monorepos and simple icon libraries. They require environment variables for authentication. ```bash # Import all modules $ figx import //... # Import specific module $ figx import //feature-profile:... # Import $ export FIGMA_PERSONAL_TOKEN="figd_..." $ figx import //... -vv ``` -------------------------------- ### PNG Profile Configuration for .figtree.toml Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/1.1-png-profile.md This snippet shows the complete configuration for the PNG profile in a `.figtree.toml` file. It specifies remote settings, export scales, output directories, variant definitions (including output names and Figma node names), and a flag for legacy loading. ```toml [profiles.png] # ID from the [remotes] section. # Uses the default remote if unspecified, but can reference any configured remote remote = "some_remote_id" # Export scale for the image from Figma (default: 1.0) scale = 1.0 # Target directory for downloaded assets. # Defaults to empty (root package directory where .fig.toml resides) output_dir = "some_dir" # Specifies which variants to use. Only the listed keys will be processed. # Can be overridden in .fig.toml for each resource variants.use = ["L", "M", "S"] # Available variants # output_name - filename for the exported file # figma_name - node name in Figma to look for variants.L = { output_name = "{base}L", figma_name = "{base}_24" } variants.M = { output_name = "{base}M", figma_name = "{base}_20" } variants.S = { output_name = "{base}S", figma_name = "{base}_16" } variants.XS = { output_name = "{base}XS", figma_name = "{base}_12" } # If true, the legacy resource loading method will be used. # The new approach downloads the SVG source and renders the raster image locally. # In most cases, this significantly speeds up the import process. # This may not suit all use cases, so the feature can be disabled. legacy_loader = false ``` -------------------------------- ### Project Structure: Android App with Figma Assets Source: https://context7.com/tonykolomeytsev/figx/llms.txt This outlines the directory structure for an Android application utilizing FigX to manage Figma assets. It includes configuration files and the organization for Compose icons and WebP illustrations. ```text android-app/ ├── .figtree.toml └── app/ ├── .fig.toml └── src/main/ ├── java/com/example/app/ui/ │ └── icons/ │ ├── .fig.toml │ ├── Sun.kt │ ├── Moon.kt │ └── Star.kt └── res/ ├── drawable-hdpi/ ├── drawable-xhdpi/ ├── drawable-xxhdpi/ ├── drawable-night-hdpi/ └── ... ``` -------------------------------- ### Configure Asset Profiles (SVG, Icons, Illustrations, Custom SVG Variants) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Sets up various profiles for processing design assets: 'svg' for direct SVG output, 'icons' for Compose compatibility, 'illustrations' for Android WebP, and 'custom-svg-variants' for generating different sizes of SVGs. ```toml # Configure profiles for different asset types [profiles.svg] output_dir = "img" [profiles.icons] extends = "compose" remote = "icons" color_mappings = [ { from = "*", to = "Color.Black" }, ] extension_target = "com.example.app.ui.Icons" kotlin_explicit_api = true [profiles.illustrations] extends = "android-webp" remote = "illustrations" densities = ["hdpi", "xhdpi", "xxhdpi", "xxxhdpi"] night = "{base} (Dark)" quality = 100 android_res_dir = "src/main/res" [profiles.custom-svg-variants] extends = "svg" variants.use = ["L", "M", "S"] variants.L = { output_name = "{base}_24", figma_name = "{base}_24" } variants.M = { output_name = "{base}_20", figma_name = "{base}_20" } variants.S = { output_name = "{base}_16", figma_name = "{base}_16" } ``` -------------------------------- ### Manage Authentication Tokens (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Handles secure storage and management of Figma personal access tokens. Supports adding tokens interactively via system keychain on macOS/Windows, deleting tokens, and using environment variables for token authentication across all platforms. ```bash # Add token to keychain (interactive prompt) figx auth # Remove token from keychain figx auth --delete # Use environment variable (all platforms) export FIGMA_PERSONAL_TOKEN="figd_your_token_here" figx import //... ``` -------------------------------- ### Workspace Information (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Displays brief information about the workspace or package configuration. This includes details such as configured remotes, active profiles, and resource counts. Supports showing information at the workspace or package level. ```bash # Show workspace info figx info workspace # Show package info figx info package ``` -------------------------------- ### Configure FigX Access Token with Priority Lookup (TOML) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/user_guide/2.1.2-remotes.md Sets up a priority list for fetching the FigX access token. It first attempts to read from the 'FIGMA_PERSONAL_TOKEN' environment variable and falls back to the secure keychain if the environment variable is not found. ```toml access_token = [ { env = "FIGMA_PERSONAL_TOKEN" }, { keychain = true }, ] ``` -------------------------------- ### Import Resources from Figma (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Imports design assets from configured Figma remotes into the workspace. It resolves label patterns, fetches metadata, downloads assets, applies transformations, and writes output files. Supports workspace-wide or specific package/resource imports, with options for forced refetching, parallelism control, and verbose output. ```bash # Import all resources in the workspace figx import //... # Import specific package resources figx import //app/ui/icons:... # Import specific resource figx import //app/ui/icons:Sun # Import with forced refetch (ignore cache) figx import //... --refetch # Run with parallelism control figx import //... -j 4 # Verbose output for debugging figx import //... -vv ``` -------------------------------- ### Scan Remotes for Metadata (CLI) Source: https://context7.com/tonykolomeytsev/figx/llms.txt Generates an indexed metadata file from selected Figma remotes, which can be used for offline analysis or documentation generation. Supports scanning specific remotes by name or scanning all remotes in the workspace. ```bash # Scan specific remotes figx scan icons illustrations # Scan all remotes figx scan $(figx query -o package //... | awk '{print $1}') ``` -------------------------------- ### Import Resources from Figma Source: https://context7.com/tonykolomeytsev/figx/llms.txt Imports design assets from configured Figma remotes into your workspace. It resolves label patterns, fetches metadata, downloads assets, applies transformations, and writes output files. Supports various import scopes and options like forced refetching and parallelism. ```APIDOC ## POST /figx/import ### Description Imports design assets from configured Figma remotes into your workspace. The import command resolves label patterns, fetches metadata from Figma's API, downloads assets, applies profile transformations, and writes output files to their designated locations. ### Method POST ### Endpoint /figx/import ### Parameters #### Query Parameters - **refetch** (boolean) - Optional - Forces a refetch of assets, ignoring the cache. - **j** (integer) - Optional - Controls the parallelism level for imports. - **vv** (boolean) - Optional - Enables verbose output for debugging. #### Path Parameters - **targets** (string) - Required - Specifies the resources or packages to import using label patterns (e.g., `//...`, `//app/ui/icons:...`, `//app/ui/icons:Sun`). ### Request Example ```bash figx import //... figx import //app/ui/icons:Sun --refetch -j 4 ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the import operation. - **message** (string) - Provides details about the import process. #### Response Example ```json { "status": "success", "message": "Successfully imported 15 resources." } ``` ``` -------------------------------- ### Manage Authentication Tokens Source: https://context7.com/tonykolomeytsev/figx/llms.txt Stores and manages Figma personal access tokens securely in the system keychain (macOS/Windows). On Linux, tokens are typically provided via environment variables. ```APIDOC ## POST /figx/auth ### Description Manages Figma authentication tokens. This command securely stores tokens in the system keychain or allows for deletion. Alternatively, tokens can be provided via environment variables. ### Method POST ### Endpoint /figx/auth ### Parameters #### Query Parameters - **delete** (boolean) - Optional - If set to true, removes the stored token from the keychain. ### Request Example ```bash # Add token (interactive prompt) figx auth # Remove token figx auth --delete # Use environment variable export FIGMA_PERSONAL_TOKEN="figd_your_token_here" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the authentication token management operation. - **message** (string) - Provides details about the action taken (e.g., token added, token removed). #### Response Example ```json { "status": "success", "message": "Figma token successfully added to keychain." } ``` ``` -------------------------------- ### FigX Configuration: Remotes and Profiles for Android Source: https://context7.com/tonykolomeytsev/figx/llms.txt Configuration file for FigX, defining remote Figma file connections and profiles for generating Android-specific assets like Compose ImageVectors and WebP drawables. ```toml # .figtree.toml [remotes.icons] file_key = "FILE_KEY" container_node_ids = ["NODE_ID"] default = true access_token.keychain = true [remotes.illustrations] file_key = "FILE_KEY" container_node_ids = ["NODE_ID"] access_token.keychain = true [profiles.icons] extends = "compose" remote = "icons" color_mappings = [{ from = "*", to = "Color.Black" }] extension_target = "com.example.app.ui.theme.AppIcons" [profiles.illustrations] extends = "android-webp" remote = "illustrations" densities = ["hdpi", "xhdpi", "xxhdpi", "xxxhdpi"] night = "{base} (Dark)" android_res_dir = "src/main/res" ``` -------------------------------- ### Figx Remote Configuration Syntax (TOML) Source: https://github.com/tonykolomeytsev/figx/blob/master/docs/src/reference/2-remotes.md This snippet illustrates the TOML syntax for configuring remotes in Figx. It shows how to define a remote's name, set it as default, specify the Figma file key and container node IDs, and configure the access token, including the option to use environment variables. ```toml [remotes.{remote_name}] default = true|false file_key = "figma_file_identifier" container_node_ids = ["node_id_1", "node_id_2"] access_token = { env = "FIGMA_PERSONAL_TOKEN" } ``` -------------------------------- ### Workspace Information Source: https://context7.com/tonykolomeytsev/figx/llms.txt Displays brief information about the workspace or package configuration, including details on remotes, profiles, and resource counts. ```APIDOC ## GET /figx/info ### Description Displays brief information about the workspace or package configuration, including details on remotes, profiles, and resource counts. Useful for quick overviews and validation. ### Method GET ### Endpoint /figx/info ### Parameters #### Query Parameters - **scope** (string) - Required - Specifies the scope of information to retrieve. Accepted values are `workspace` or `package`. ### Request Example ```bash figx info workspace figx info package ``` ### Response #### Success Response (200) - **info** (object) - An object containing workspace or package configuration details. #### Response Example ```json { "info": { "remotes": 5, "profiles": 3, "resources": 150 } } ``` ``` -------------------------------- ### PDF Profile Configuration for Export Source: https://context7.com/tonykolomeytsev/figx/llms.txt Defines the 'pdf' profile for exporting design assets directly as PDF documents from Figma, specifying the remote source and output directory. ```toml [profiles.pdf] remote = "design" output_dir = "assets/pdf" ```