From 0064ad7db52c73a3bb1144671537f055a9b4e891 Mon Sep 17 00:00:00 2001 From: mimo Date: Wed, 4 Dec 2024 16:32:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=A8=E3=82=A4=E3=83=AA=E3=82=A2?= =?UTF-8?q?=E3=82=B9=E3=81=AE=E8=A7=A3=E6=B1=BA=E3=81=8C=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E6=99=82=E3=80=81token=E5=90=8D=E3=82=92?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/token-cli/src/figma/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/token-cli/src/figma/index.ts b/packages/token-cli/src/figma/index.ts index 7506e67ac..504a3f8ce 100644 --- a/packages/token-cli/src/figma/index.ts +++ b/packages/token-cli/src/figma/index.ts @@ -106,13 +106,16 @@ export const resolveValue = ( // if alias, look at it recursively. if (typeof value === 'object' && 'type' in value && 'id' in value) { const v = variableMap.get(value.id) - if (!v) throw new Error(`can't find variable ${value.id}`) + if (!v) + throw new Error( + `can't find variable alias "${variable.name}:${value.id}"` + ) const variableCollection = variableCollectionMap.get(v.variableCollectionId) if (!variableCollection) throw new Error( - `can't find variable collection ${v.variableCollectionId}` + `can't find variable collection "${variable.name}:${v.variableCollectionId}"` ) return `{${variableCollection.name}.${v.name}}` From 2021b228d40afc496916c33d6fbc10228cfef2ca Mon Sep 17 00:00:00 2001 From: mimo Date: Wed, 4 Dec 2024 19:05:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat(token-cli):=20=E5=8F=82=E7=85=A7?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84token=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=81=A8=E3=81=8D=E3=80=81warn=E3=82=92=E5=87=BA?= =?UTF-8?q?=E3=81=99=E3=81=8C=E3=81=9D=E3=81=AE=E3=81=BE=E3=81=BE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E7=B6=9A=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/token-cli/src/createToken.ts | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/token-cli/src/createToken.ts b/packages/token-cli/src/createToken.ts index 8f6879a48..e0dbc40d3 100644 --- a/packages/token-cli/src/createToken.ts +++ b/packages/token-cli/src/createToken.ts @@ -62,18 +62,36 @@ export const createToken = ( if (!v) throw new Error(`can't find variable: ${it}`) - return { - [v.name]: { - value: resolveValue( - variableCollectionMap, - variableMap, - v.resolvedType, - v, - modeId - ), - }, + try { + const value = resolveValue( + variableCollectionMap, + variableMap, + v.resolvedType, + v, + modeId + ) + return { + [v.name]: { + value, + }, + } + } catch (e) { + if (e instanceof Error) { + // eslint-disable-next-line no-console + console.warn(`[warn]: ${e.message}`) + } + return undefined } }) + .filter( + ( + it + ): it is { + [x: string]: { + value: string + } + } => it !== undefined + ) .reduce((prev, current) => ({ ...prev, ...current,