diff --git a/.changeset/large-foxes-reply.md b/.changeset/large-foxes-reply.md new file mode 100644 index 000000000..54274e08e --- /dev/null +++ b/.changeset/large-foxes-reply.md @@ -0,0 +1,5 @@ +--- +"@tokens-studio/figma-plugin": patch +--- + +Fix Tokens Studio sync missing theme metadata diff --git a/packages/tokens-studio-for-figma/package.json b/packages/tokens-studio-for-figma/package.json index 51b747647..facaede1b 100644 --- a/packages/tokens-studio-for-figma/package.json +++ b/packages/tokens-studio-for-figma/package.json @@ -62,7 +62,7 @@ "@supabase/supabase-js": "^2.0.5", "@supernovaio/supernova-sdk": "^1.9.3", "@tokens-studio/graph-engine": "^0.17.5", - "@tokens-studio/sdk": "^2.0.0-alpha.0", + "@tokens-studio/sdk": "^1.4.2", "@tokens-studio/tokens": "0.2.5", "@tokens-studio/types": "0.5.1", "@tokens-studio/ui": "0.9.0", diff --git a/packages/tokens-studio-for-figma/src/app/store/models/reducers/__tests__/tokensStudio.test.ts b/packages/tokens-studio-for-figma/src/app/store/models/reducers/__tests__/tokensStudio.test.ts index 25c9c11bd..25cf2165d 100644 --- a/packages/tokens-studio-for-figma/src/app/store/models/reducers/__tests__/tokensStudio.test.ts +++ b/packages/tokens-studio-for-figma/src/app/store/models/reducers/__tests__/tokensStudio.test.ts @@ -6,12 +6,20 @@ import { TokenSetStatus } from '@/constants/TokenSetStatus'; import { models } from '../../index'; import { TokenTypes } from '@/constants/TokenTypes'; import { - CREATE_THEME_GROUP_MUTATION, CREATE_TOKEN_SET_MUTATION, DELETE_THEME_GROUP_MUTATION, DELETE_TOKEN_SET_MUTATION, UPDATE_THEME_GROUP_MUTATION, UPDATE_TOKEN_SET_MUTATION, UPDATE_TOKEN_SET_ORDER_MUTATION, + CREATE_THEME_GROUP_MUTATION, + CREATE_TOKEN_SET_MUTATION, + DELETE_THEME_GROUP_MUTATION, + DELETE_TOKEN_SET_MUTATION, + UPDATE_THEME_GROUP_MUTATION, + UPDATE_TOKEN_SET_MUTATION, + UPDATE_TOKEN_SET_ORDER_MUTATION, } from '@/storage/tokensStudio/graphql'; import { DeleteTokenPayload, UpdateTokenPayload } from '@/types/payloads'; import * as notifiers from '@/plugin/notifiers'; import { middlewares } from '@/app/store/middlewares'; +const DEFAULT_BRANCH = 'main'; + type Store = RematchStore>; const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn()); @@ -149,7 +157,9 @@ const initialRawTokensDTCG = { }; function delay(ms = 0) { - return new Promise((resolve) => { setTimeout(resolve, ms); }); + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); } const mockQuery = jest.fn(); @@ -247,12 +257,14 @@ describe('Tokens Studio sync', () => { parent: 'global', name: 'newBoxShadow', description: 'newBoxShadow description', - value: [{ - color: '#e63d3d', - type: 'innerShadow', - x: '2px', - y: '2px', - }], + value: [ + { + color: '#e63d3d', + type: 'innerShadow', + x: '2px', + y: '2px', + }, + ], type: TokenTypes.BOX_SHADOW, }, { @@ -447,7 +459,7 @@ describe('Tokens Studio sync', () => { project: 'projectId', organization: 'orgId', path: 'global', - branch: 'master', + branch: DEFAULT_BRANCH, }, }); @@ -521,15 +533,17 @@ describe('Tokens Studio sync', () => { variables: { project: 'projectId', organization: 'orgId', - branch: 'master', + branch: DEFAULT_BRANCH, input: { name: themeData.group, - options: [{ - name: themeData.name, - selectedTokenSets: themeData.selectedTokenSets, - figmaStyleReferences: {}, - figmaVariableReferences: undefined, - }], + options: [ + { + name: themeData.name, + selectedTokenSets: themeData.selectedTokenSets, + figmaStyleReferences: {}, + figmaVariableReferences: undefined, + }, + ], }, }, }); @@ -619,12 +633,14 @@ describe('Tokens Studio sync', () => { organization: 'orgId', input: { name: updatedThemeData.group, - options: [{ - name: updatedThemeData.name, - selectedTokenSets: updatedThemeData.selectedTokenSets, - figmaStyleReferences: {}, - figmaVariableReferences: undefined, - }], + options: [ + { + name: updatedThemeData.name, + selectedTokenSets: updatedThemeData.selectedTokenSets, + figmaStyleReferences: {}, + figmaVariableReferences: undefined, + }, + ], }, }, }); @@ -657,14 +673,16 @@ describe('Tokens Studio sync', () => { variables: { project: 'projectId', organization: 'orgId', - branch: 'master', + branch: DEFAULT_BRANCH, input: { name: updatedThemeData.group, - options: [{ - name: updatedThemeData.name, - selectedTokenSets: updatedThemeData.selectedTokenSets, - figmaStyleReferences: {}, - }], + options: [ + { + name: updatedThemeData.name, + selectedTokenSets: updatedThemeData.selectedTokenSets, + figmaStyleReferences: {}, + }, + ], }, }, }); @@ -676,7 +694,7 @@ describe('Tokens Studio sync', () => { variables: { project: 'projectId', organization: 'orgId', - branch: 'master', + branch: DEFAULT_BRANCH, themeGroupName: existingTheme.group, }, }); @@ -698,7 +716,7 @@ describe('Tokens Studio sync', () => { variables: { project: 'projectId', organization: 'orgId', - branch: 'master', + branch: DEFAULT_BRANCH, themeGroupName: existingTheme.group, }, }); @@ -722,14 +740,17 @@ describe('Tokens Studio sync', () => { ...storeInitialState.redux.initialState, tokenState: { ...storeInitialState.redux.initialState.tokenState, - themes: [existingTheme, { - id: 'themeId2', - name: 'themeName2', - group: 'themeGroup', - selectedTokenSets: { options: TokenSetStatus.ENABLED }, - figmaVariableReferences: undefined, - figmaStyleReferences: undefined, - }], + themes: [ + existingTheme, + { + id: 'themeId2', + name: 'themeName2', + group: 'themeGroup', + selectedTokenSets: { options: TokenSetStatus.ENABLED }, + figmaVariableReferences: undefined, + figmaStyleReferences: undefined, + }, + ], }, }, }, diff --git a/packages/tokens-studio-for-figma/src/storage/TokensStudioTokenStorage.ts b/packages/tokens-studio-for-figma/src/storage/TokensStudioTokenStorage.ts index 659760bca..0e3e2ebb6 100644 --- a/packages/tokens-studio-for-figma/src/storage/TokensStudioTokenStorage.ts +++ b/packages/tokens-studio-for-figma/src/storage/TokensStudioTokenStorage.ts @@ -1,6 +1,4 @@ -import { - ThemeGroup, TokenSetType, TokensSet, create, -} from '@tokens-studio/sdk'; +import { ThemeGroup, TokenSetType, TokensSet, create } from '@tokens-studio/sdk'; import * as Sentry from '@sentry/react'; import { AnyTokenSet } from '@/types/tokens'; import { notifyToUI } from '@/plugin/notifiers'; @@ -26,11 +24,14 @@ import { track } from '@/utils/analytics'; import { ThemeObjectsList } from '@/types'; import { TokensStudioAction } from '@/app/store/providers/tokens-studio'; -const makeClient = (secret: string) => create({ - host: process.env.TOKENS_STUDIO_API_HOST || 'localhost:4200', - secure: process.env.NODE_ENV !== 'development', - auth: `Bearer ${secret}`, -}); +const DEFAULT_BRANCH = 'main'; + +const makeClient = (secret: string) => + create({ + host: process.env.TOKENS_STUDIO_API_HOST || 'localhost:4200', + secure: process.env.NODE_ENV !== 'development', + auth: `Bearer ${secret}`, + }); export type TokensStudioSaveOptions = { commitMessage?: string; @@ -52,7 +53,7 @@ async function getProjectData(id: string, orgId: string, client: any): Promise

=3.1.1 <6" -react@^18.2.0: +react@^18, react@^18.2.0: version "18.3.1" resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891" integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==