Skip to content

Commit ea5737a

Browse files
committed
fix: skip icon build without .env
1 parent 3ceeabb commit ea5737a

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

packages/nimiq-icons/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Figma API credentials for icon generation
2+
# If these are not set, the icon build script will be skipped
3+
FIGMA_FILE_ID=your_figma_file_id_here
4+
FIGMA_API_TOKEN=your_figma_api_token_here

packages/nimiq-icons/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.figma-cache/
2+
.env

packages/nimiq-icons/scripts/index.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function getFigmaCredentials() {
3737
const token = env.FIGMA_API_TOKEN
3838

3939
if (!file || !token) {
40-
consola.error('Please provide FIGMA_FILE_ID and FIGMA_API_TOKEN environment variables.')
41-
exit(1)
40+
return null
4241
}
4342

4443
return { file, token }
@@ -61,7 +60,11 @@ function getDeterministicId(prefix: string, name: string): string {
6160
}
6261

6362
async function checkFigmaVariants() {
64-
const { file, token } = getFigmaCredentials()
63+
const credentials = getFigmaCredentials()
64+
if (!credentials)
65+
return
66+
67+
const { file, token } = credentials
6568

6669
const figma = await importFromFigma({
6770
file,
@@ -92,7 +95,11 @@ async function checkFigmaVariants() {
9295
}
9396

9497
async function getFigma(frameName: string) {
95-
const { file, token } = getFigmaCredentials()
98+
const credentials = getFigmaCredentials()
99+
if (!credentials)
100+
return null
101+
102+
const { file, token } = credentials
96103

97104
try {
98105
const cacheDir = `.figma-cache/${frameName}` // Separate cache directory for each variant
@@ -349,6 +356,13 @@ function setIconInfo(iconSet: IconSet, packageInfo: any): void {
349356
// ====== MAIN EXECUTION ======
350357

351358
async function main() {
359+
// Skip icon build if Figma credentials are not available
360+
const credentials = getFigmaCredentials()
361+
if (!credentials) {
362+
consola.info('Skipping Figma icon build: FIGMA_FILE_ID and FIGMA_API_TOKEN not found in environment')
363+
return
364+
}
365+
352366
await checkFigmaVariants()
353367
consola.start('Processing icon variants...')
354368

@@ -361,6 +375,12 @@ async function main() {
361375
const figma = await getFigma(variant)
362376
const variantName = sanitizeName(variant)
363377

378+
// Skip if no credentials available
379+
if (figma === null) {
380+
consola.info(`Skipping variant ${variantName}: no Figma credentials`)
381+
continue
382+
}
383+
364384
if (figma === 'not_modified') {
365385
// If using cached data, try to load from the cache directory
366386
const cacheDir = `.figma-cache/${variantName}`

0 commit comments

Comments
 (0)