Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

Overview

This PR adds support for importing tokens from ZIP files, allowing users to upload compressed archives containing multiple JSON token files as an alternative to selecting individual files or folders.

Changes

UI Enhancement

  • Added a new "Choose ZIP" button to the import dialog alongside existing "Choose file" and "Choose folder" options
  • Updated help text to clarify that ZIP archives are now supported
  • Added analytics tracking for ZIP import events

Storage Layer

  • Implemented readZipFile() method in FileTokenStorage to handle ZIP extraction using the existing JSZip dependency
  • Enhanced the read() method to detect ZIP files by extension and route them to the appropriate handler
  • ZIP files are processed similarly to multi-file folder imports:
    • All .json files are extracted from the archive
    • Each file is validated against existing schemas
    • Special files ($themes.json, $metadata.json) are properly recognized and handled
    • Token set files are parsed and structured correctly

Testing

  • Added comprehensive unit test covering ZIP file extraction and parsing
  • Tests validate multi-file ZIP structures containing tokens, themes, and metadata
  • All existing tests continue to pass with no regressions

Usage Example

Users can now create a ZIP file containing their token files:

tokens.zip
├── colors.json
├── spacing.json
├── typography.json
├── $themes.json
└── $metadata.json

Then import it by clicking "Choose ZIP" in the import dialog. The plugin will extract and import all JSON files just like a folder import.

Benefits

  • Easier sharing: Complete token sets can be shared as a single compressed file
  • No Pro required: Unlike folder imports, ZIP imports work for all users
  • Cross-platform: Consistent behavior across all operating systems
  • Compressed: Smaller file size with ZIP compression
  • Flexible: Supports subdirectories within ZIP archives

Technical Notes

  • Uses existing JSZip dependency (no new dependencies added)
  • Type-safe implementation with TypeScript type guards
  • Follows existing multi-file import patterns for consistency
  • Proper error handling for invalid ZIP files
  • Minimal, surgical changes to codebase (172 lines added across 4 files)

Fixes the issue requested in the problem statement.

Original prompt

in addition to upload a file or folder allow using a zip


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 0e33a39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI and others added 2 commits October 13, 2025 19:29
Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for uploading zip files Add ZIP file upload support for token imports Oct 13, 2025
Copilot AI requested a review from six7 October 13, 2025 19:35
Copilot finished work on behalf of six7 October 13, 2025 19:35
@github-actions
Copy link
Contributor

Commit SHA:ab469b1fcbf594664e0c1e90fdbef847297d2626

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: copilot/add-zip-upload-support 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 65.07 (0.04) 57 (0.05) 61.87 (0.03) 65.4 (0.03)
🟢 packages/tokens-studio-for-figma/src/storage/FileTokenStorage.ts 59.3 (20.84) 46.03 (20.39) 52.94 (14.48) 59.75 (19.75)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants