diff --git a/cypress/support/mockEnv.js b/cypress/support/mockEnv.js index 116d4ba3e..44cab5369 100644 --- a/cypress/support/mockEnv.js +++ b/cypress/support/mockEnv.js @@ -31,7 +31,7 @@ const MockEnv = () => { } }).as('getContent'); - cy.intercept('GET', 'http://localhost:5000/six7/repos/122/figma-tokens/branches', [ + cy.intercept('GET', 'http://localhost:5000/six7six7/repos/122/figma-tokens/branches?per_page=30', [ { name: 'main', }, diff --git a/package.json b/package.json index 2ef3a2ccf..71bf031d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tokens-studio-for-figma", "version": "1.0.0", - "plugin_version": "1.35.3", + "plugin_version": "1.35.4", "description": "Tokens Studio for Figma", "license": "MIT", "scripts": { diff --git a/script/release.sh b/script/release.sh index ae6b53b53..64967087e 100755 --- a/script/release.sh +++ b/script/release.sh @@ -1,4 +1,4 @@ -VERSION=figma-tokens@1.35.3 +VERSION=figma-tokens@1.35.4 sentry-cli releases -p figma-tokens files "$VERSION" upload-sourcemaps --ext ts --ext tsx --ext map --ext js --ignore-file .sentryignore . sentry-cli releases set-commits "$VERSION" --auto sentry-cli releases finalize "$VERSION" \ No newline at end of file diff --git a/src/app/components/ErrorMessage.tsx b/src/app/components/ErrorMessage.tsx index f13c827d8..2397ff9bf 100644 --- a/src/app/components/ErrorMessage.tsx +++ b/src/app/components/ErrorMessage.tsx @@ -1,7 +1,7 @@ import { styled } from '@/stitches.config'; export const ErrorMessage = styled('div', { - backgroundColor: '$dangerBg', + backgroundColor: '$bgDanger', color: '$dangerFg', borderRadius: '$default', padding: '$4', diff --git a/src/app/components/SyncSettings.tsx b/src/app/components/SyncSettings.tsx index df4b34c22..6a63696e4 100644 --- a/src/app/components/SyncSettings.tsx +++ b/src/app/components/SyncSettings.tsx @@ -178,7 +178,7 @@ const SyncSettings = () => { { providers.map((provider) => ( - {getProviderIcon(provider.type)} + {getProviderIcon(provider.type)} {provider.text} )) diff --git a/src/storage/GithubTokenStorage.ts b/src/storage/GithubTokenStorage.ts index ac94d24d5..d0c4e091a 100644 --- a/src/storage/GithubTokenStorage.ts +++ b/src/storage/GithubTokenStorage.ts @@ -66,10 +66,11 @@ export class GithubTokenStorage extends GitTokenStorage { } public async listBranches() { - return this.octokitClient.repos.listBranches({ + return this.octokitClient.paginate(this.octokitClient.repos.listBranches, { owner: this.owner, repo: this.repository, headers: octokitClientDefaultHeaders, + per_page: 30, // Set to desired page size (max 100) }); } @@ -78,7 +79,7 @@ export class GithubTokenStorage extends GitTokenStorage { // however when pulling from the root directory we can not do this, but we can take the SHA from the branch if (path === '') { const branches = await this.listBranches(); - const branch = branches.data.find((entry) => entry.name === this.branch); + const branch = branches?.find((entry) => entry.name === this.branch); if (!branch) throw new Error(`Branch not found, ${this.branch}`); return branch.commit.sha; } @@ -110,7 +111,7 @@ export class GithubTokenStorage extends GitTokenStorage { public async fetchBranches() { const branches = await this.listBranches(); - return branches.data.map((branch) => branch.name); + return branches?.map((branch) => branch.name); } public async createBranch(branch: string, source?: string) { diff --git a/src/storage/__tests__/GithubTokenStorage.test.ts b/src/storage/__tests__/GithubTokenStorage.test.ts index b39d17c37..88b0396ec 100644 --- a/src/storage/__tests__/GithubTokenStorage.test.ts +++ b/src/storage/__tests__/GithubTokenStorage.test.ts @@ -10,7 +10,7 @@ import { mockGetContent, mockGetRef, mockGetTree, - mockListBranches, + mockPaginate, } from '../../../tests/__mocks__/octokitRestMock'; import { ErrorMessages } from '@/constants/ErrorMessages'; @@ -1260,10 +1260,8 @@ describe('GithubTokenStorage', () => { }); it('should return false if there are no branches', async () => { - mockListBranches.mockImplementationOnce(() => ( - Promise.resolve({ - data: [], - }) + mockPaginate.mockImplementationOnce(() => ( + Promise.resolve([]) )); expect(await storageProvider.write([], { @@ -1272,15 +1270,13 @@ describe('GithubTokenStorage', () => { }); it('should be able to get the tree sha for a given path', async () => { - mockListBranches.mockImplementationOnce(() => ( - Promise.resolve({ - data: [ - { - name: 'main', - commit: { sha: 'root-sha' }, - }, - ], - }) + mockPaginate.mockImplementationOnce(() => ( + Promise.resolve([ + { + name: 'main', + commit: { sha: 'root-sha' }, + }, + ]) )); expect(await storageProvider.getTreeShaForDirectory('')).toEqual('root-sha'); diff --git a/tests/__mocks__/octokitRestMock.d.ts b/tests/__mocks__/octokitRestMock.d.ts index 674a10adf..c7f73d48b 100644 --- a/tests/__mocks__/octokitRestMock.d.ts +++ b/tests/__mocks__/octokitRestMock.d.ts @@ -7,3 +7,4 @@ export const mockGetContent: jest.Mock; export const mockCreateOrUpdateFiles: jest.Mock; export const mockCreateTree: jest.Mock; export const mockGetTree: jest.Mock; +export const mockPaginate: jest.Mock; diff --git a/tests/__mocks__/octokitRestMock.js b/tests/__mocks__/octokitRestMock.js index c2b7dcaaa..b663b42a4 100644 --- a/tests/__mocks__/octokitRestMock.js +++ b/tests/__mocks__/octokitRestMock.js @@ -14,6 +14,10 @@ export const mockGetContent = jest.fn(); export const mockCreateOrUpdateFiles = jest.fn(); export const mockCreateTree = jest.fn(); export const mockGetTree = jest.fn(); +export const mockPaginate = jest.fn(() => Promise.resolve([ + { name: 'main' }, + { name: 'development' }, +])); jest.mock('@octokit/rest', () => ({ Octokit: { @@ -40,6 +44,7 @@ jest.mock('@octokit/rest', () => ({ listBranches: mockListBranches, createOrUpdateFiles: mockCreateOrUpdateFiles, }, + paginate: mockPaginate })) )), },