Skip to content

Commit

Permalink
Release 1.35.4 (#1860)
Browse files Browse the repository at this point in the history
- Fixes an issue where sometimes we wouldn't show all branches that are
available in GitHub in the branch selector
- Fixes an issue with error messages in Figma's light theme
- Fixes an issue with sync provider icons in Figma's light theme

---------

Co-authored-by: Hiroshi <hinatatadashi0823@gmail.com>
  • Loading branch information
six7 and swordEdge authored May 4, 2023
1 parent 1af8851 commit 731a78e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cypress/support/mockEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion script/release.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/app/components/ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from '@/stitches.config';

export const ErrorMessage = styled('div', {
backgroundColor: '$dangerBg',
backgroundColor: '$bgDanger',
color: '$dangerFg',
borderRadius: '$default',
padding: '$4',
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/SyncSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const SyncSettings = () => {
{
providers.map((provider) => (
<DropdownMenuItem key={provider.type} onSelect={handleProviderClick(provider.type)} css={{ display: 'flex', gap: '$3' }} data-testid={`add-${provider.text}-credential`}>
<Box css={{ color: '$fgDefault' }}>{getProviderIcon(provider.type)}</Box>
<Box css={{ color: '$contextMenuForeground' }}>{getProviderIcon(provider.type)}</Box>
{provider.text}
</DropdownMenuItem>
))
Expand Down
7 changes: 4 additions & 3 deletions src/storage/GithubTokenStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 10 additions & 14 deletions src/storage/__tests__/GithubTokenStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
mockGetContent,
mockGetRef,
mockGetTree,
mockListBranches,
mockPaginate,
} from '../../../tests/__mocks__/octokitRestMock';
import { ErrorMessages } from '@/constants/ErrorMessages';

Expand Down Expand Up @@ -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([], {
Expand All @@ -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');

Expand Down
1 change: 1 addition & 0 deletions tests/__mocks__/octokitRestMock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 5 additions & 0 deletions tests/__mocks__/octokitRestMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -40,6 +44,7 @@ jest.mock('@octokit/rest', () => ({
listBranches: mockListBranches,
createOrUpdateFiles: mockCreateOrUpdateFiles,
},
paginate: mockPaginate
}))
)),
},
Expand Down

0 comments on commit 731a78e

Please sign in to comment.