Skip to content

Implement cross-platform improvements#106

Open
alesiahil wants to merge 1 commit intov5from
codex/update-icons-from-figma
Open

Implement cross-platform improvements#106
alesiahil wants to merge 1 commit intov5from
codex/update-icons-from-figma

Conversation

@alesiahil
Copy link
Copy Markdown

@alesiahil alesiahil commented Jul 25, 2025

Summary

  • generate TS references before pre-commit typecheck
  • clean build output with rimraf
  • document how to export icons from Figma
  • fix lerna.json typo in release docs
  • add portable figma:export-env script

Testing

  • npm test
  • npm run auto:lint

https://chatgpt.com/codex/tasks/task_e_68822756d3e8832fb50ac8d28ed0ff10

Summary by CodeRabbit

  • New Features
    • Added a new script to automate exporting Figma icons using environment variables for improved workflow.
  • Documentation
    • Updated README with detailed instructions for exporting icons from Figma and fixed a minor typo.
  • Chores
    • Enhanced pre-commit hook with an additional step for TypeScript references.
    • Simplified TypeScript cleanup script and added rimraf as a dev dependency.
    • Updated icon export script to use the new automation approach.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 25, 2025

Walkthrough

The changes introduce a new Node.js script for exporting Figma icons, update related npm scripts, and revise documentation with instructions for updating icons. The pre-commit hook is enhanced by adding a new step, and the cleanup script for TypeScript artifacts is simplified using the rimraf package, which is now added as a dev dependency.

Changes

File(s) Change Summary
.husky/pre-commit Added npm run auto:ts:references between linting and type checking steps in pre-commit hook.
README.md Added "Updating icons" section and fixed a minor typo.
package.json Simplified ts:clean script to use rimraf; added rimraf as dev dependency.
packages/default-icons/figma-export-env.js Added new Node.js script to automate Figma icon export, token retrieval, and formatting.
packages/default-icons/package.json Changed "figma:export-env" script to invoke the new Node.js script instead of inline shell.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant PreCommit as Pre-commit Hook
    participant Lint as lint-staged
    participant TSRef as auto:ts:references
    participant TSCheck as auto:typecheck

    Dev->>PreCommit: git commit
    PreCommit->>Lint: npm run lint-staged
    Lint-->>PreCommit: done
    PreCommit->>TSRef: npm run auto:ts:references
    TSRef-->>PreCommit: done
    PreCommit->>TSCheck: npm run auto:typecheck
    TSCheck-->>PreCommit: done
Loading
sequenceDiagram
    participant Dev as Developer
    participant Script as figma-export-env.js
    participant Env as .env.local
    participant Figma as Figma API
    participant FS as File System
    participant Prettier as Prettier

    Dev->>Script: npm run figma:export-env
    Script->>Env: Read FIGMA_TOKEN
    alt Token found
        Script->>FS: Remove src/figma-icons
        Script->>Figma: Export icons using token
        Figma-->>Script: Icons exported
        Script->>Prettier: Format src/figma-icons
    else Token missing
        Script-->>Dev: Log error and exit
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-25T08_48_39_229Z-debug-0.log

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/update-icons-from-figma

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 25, 2025

😭 Deploy PR Preview d33f322 failed. Build logs

🤖 By surge-preview

@alesiahil alesiahil self-assigned this Jul 25, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a583b0 and d33f322.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • .husky/pre-commit (1 hunks)
  • README.md (2 hunks)
  • package.json (2 hunks)
  • packages/default-icons/figma-export-env.js (1 hunks)
  • packages/default-icons/package.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~21-~21: Use correct spacing
Context: ... running local dev server ### Updating icons Icons used across packages are sourced f...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~23-~23: There might be a mistake here.
Context: ...ourced from Figma. To export the latest icons: 1. Navigate to packages/default-icons. 2...

(QB_NEW_EN_OTHER)


[grammar] ~27-~27: Use correct spacing
Context: ...npm run figma:export-env if you saved the token in a .env.local file). After exporti...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~28-~28: Use correct spacing
Context: ...ou saved the token in a .env.local file). After exporting icons, run `npm run buil...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~30-~30: Use correct spacing
Context: ...n npm run build to regenerate package bundles. ## Setup ### Package management To add de...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~117-~117: There might be a mistake here.
Context: ...ent major version 2. Change the version num from vN to vN+1 in lerna.json and...

(QB_NEW_EN_OTHER)


[grammar] ~117-~117: Use articles correctly
Context: ...nge the version num from vN to vN+1 in lerna.json and `.github/workflows/dep...

(QB_NEW_EN_OTHER_ERROR_IDS_11)


[grammar] ~117-~117: There might be a mistake here.
Context: ...sonand.github/workflows/deploy.ymlfiles 3. Push the branch 4. Runnpm run release`...

(QB_NEW_EN_OTHER)

🔇 Additional comments (7)
package.json (2)

27-27: Excellent cross-platform improvement using rimraf.

The replacement of the complex find command with rimraf improves cross-platform compatibility and readability. The change from & to && ensures proper sequential execution, only running the TypeScript clean command if the directory removal succeeds.


121-122: Proper dependency addition for the rimraf usage.

The rimraf dev dependency is correctly added to support the updated ts:clean script. The version ^5.0.5 appears to be a recent stable version.

.husky/pre-commit (1)

4-4: Logical improvement to the pre-commit workflow.

Adding auto:ts:references between linting and type checking ensures TypeScript project references are current before type checking runs. This prevents potential false positive type errors due to stale references in a monorepo setup.

packages/default-icons/figma-export-env.js (1)

1-28: Excellent refactoring from shell commands to Node.js script.

This script successfully consolidates the Figma export logic into a maintainable, cross-platform Node.js solution. The token handling is secure, and the overall structure is clean and logical.

packages/default-icons/package.json (1)

17-17: Clean simplification by delegating to the dedicated script.

The replacement of the complex inline shell command with a simple Node.js script call improves maintainability and cross-platform compatibility. This aligns perfectly with the new figma-export-env.js script.

README.md (2)

21-30: Excellent documentation addition for icon management.

The new "Updating icons" section provides clear, step-by-step instructions for exporting icons from Figma. The documentation is well-structured and includes appropriate cross-references to detailed setup instructions.


117-117: Good catch on the typo fix.

Correcting "leran.json" to "lerna.json" improves the accuracy of the documentation.

Comment on lines +5 to +14
function getToken() {
if (process.env.FIGMA_TOKEN) return process.env.FIGMA_TOKEN;
const envPath = path.resolve('.env.local');
if (existsSync(envPath)) {
const content = readFileSync(envPath, 'utf8');
const match = content.match(/^FIGMA_TOKEN=(.*)$/m);
if (match) return match[1].trim();
}
return null;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Improve regex pattern for environment variable parsing.

The current regex pattern /^FIGMA_TOKEN=(.*)$/m could be more robust. It doesn't handle quoted values or potential whitespace around the equals sign.

Consider this more robust pattern:

-    const match = content.match(/^FIGMA_TOKEN=(.*)$/m);
+    const match = content.match(/^FIGMA_TOKEN\s*=\s*(.*)$/m);

Or even better, handle quoted values:

-    const match = content.match(/^FIGMA_TOKEN=(.*)$/m);
-    if (match) return match[1].trim();
+    const match = content.match(/^FIGMA_TOKEN\s*=\s*(.*)$/m);
+    if (match) {
+      const value = match[1].trim();
+      return value.replace(/^["']|["']$/g, ''); // Remove surrounding quotes
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getToken() {
if (process.env.FIGMA_TOKEN) return process.env.FIGMA_TOKEN;
const envPath = path.resolve('.env.local');
if (existsSync(envPath)) {
const content = readFileSync(envPath, 'utf8');
const match = content.match(/^FIGMA_TOKEN=(.*)$/m);
if (match) return match[1].trim();
}
return null;
}
function getToken() {
if (process.env.FIGMA_TOKEN) return process.env.FIGMA_TOKEN;
const envPath = path.resolve('.env.local');
if (existsSync(envPath)) {
const content = readFileSync(envPath, 'utf8');
- const match = content.match(/^FIGMA_TOKEN=(.*)$/m);
- if (match) return match[1].trim();
+ const match = content.match(/^FIGMA_TOKEN\s*=\s*(.*)$/m);
+ if (match) {
+ const value = match[1].trim();
+ return value.replace(/^["']|["']$/g, ''); // Remove surrounding quotes
+ }
}
return null;
}
🤖 Prompt for AI Agents
In packages/default-icons/figma-export-env.js around lines 5 to 14, the regex
used to parse the FIGMA_TOKEN from the .env.local file is too simplistic and
does not handle cases with quotes or whitespace around the equals sign. Update
the regex pattern to allow optional whitespace around the equals sign and to
correctly capture values enclosed in single or double quotes, trimming any
surrounding whitespace or quotes from the captured token before returning it.

Comment on lines +22 to +27
rmSync('src/figma-icons', { recursive: true, force: true });
execSync('figma-export use-config .figmaexportrc.cjs', {
stdio: 'inherit',
env: { ...process.env, FIGMA_TOKEN: token },
});
execSync('prettier --write src/figma-icons/*', { stdio: 'inherit' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider adding error handling for external commands.

While the script handles missing tokens well, it doesn't handle potential failures of the figma-export or prettier commands. Consider wrapping the execSync calls in try-catch blocks for better error reporting.

-execSync('figma-export use-config .figmaexportrc.cjs', {
-  stdio: 'inherit',
-  env: { ...process.env, FIGMA_TOKEN: token },
-});
-execSync('prettier --write src/figma-icons/*', { stdio: 'inherit' });
+try {
+  execSync('figma-export use-config .figmaexportrc.cjs', {
+    stdio: 'inherit',
+    env: { ...process.env, FIGMA_TOKEN: token },
+  });
+  execSync('prettier --write src/figma-icons/*', { stdio: 'inherit' });
+} catch (error) {
+  console.error('Export failed:', error.message);
+  process.exit(1);
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rmSync('src/figma-icons', { recursive: true, force: true });
execSync('figma-export use-config .figmaexportrc.cjs', {
stdio: 'inherit',
env: { ...process.env, FIGMA_TOKEN: token },
});
execSync('prettier --write src/figma-icons/*', { stdio: 'inherit' });
rmSync('src/figma-icons', { recursive: true, force: true });
try {
execSync('figma-export use-config .figmaexportrc.cjs', {
stdio: 'inherit',
env: { ...process.env, FIGMA_TOKEN: token },
});
execSync('prettier --write src/figma-icons/*', { stdio: 'inherit' });
} catch (error) {
console.error('Export failed:', error.message);
process.exit(1);
}
🤖 Prompt for AI Agents
In packages/default-icons/figma-export-env.js around lines 22 to 27, the
execSync calls for running external commands lack error handling. Wrap each
execSync call in a try-catch block to catch any exceptions thrown during
execution, and log or handle the errors appropriately to improve error reporting
and prevent silent failures.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant