diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b5e3b0830..a5c9009f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,6 +49,9 @@ jobs: env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} + ADMIN_TOKENS_FILE_KEY: ${{ secrets.TOKENS__ADMIN_TOKENS_FILE_KEY }} + PRIMITIVE_TOKENS_FILE_KEY: ${{ secrets.TOKENS__PRIMITIVE_TOKENS_FILE_KEY }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/packages/tokens/.env b/packages/tokens/.env deleted file mode 100644 index bf835975a..000000000 --- a/packages/tokens/.env +++ /dev/null @@ -1 +0,0 @@ -API_KEY="figd_TIePoUZstLBPBG7bPGcaHqQGeDlV2cGepEFuoOSD" \ No newline at end of file diff --git a/packages/tokens/src/GenerateArtifacts.test.ts b/packages/tokens/src/GenerateArtifacts.test.ts index 0bfdd0d81..b074aabad 100644 --- a/packages/tokens/src/GenerateArtifacts.test.ts +++ b/packages/tokens/src/GenerateArtifacts.test.ts @@ -6,10 +6,6 @@ import { env } from './env.js'; import { HttpClientUsingFetch } from './common/infrastructure/http-client/HttpClientUsingFetch.js'; import { server } from '../tests/mocks/node.js'; import { HttpResponse, http } from 'msw'; -import { - ADMIN_TOKENS_FILE_KEY, - PRIMITIVE_TOKENS_FILE_KEY, -} from './constants.js'; fact( 'creates a Dictionary in form of a JSON file for the primitive Design Tokens', @@ -17,7 +13,7 @@ fact( // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -80,7 +76,7 @@ fact( }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -132,7 +128,7 @@ fact( const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); @@ -172,7 +168,7 @@ fact( // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -235,7 +231,7 @@ fact( }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -287,7 +283,7 @@ fact( const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); @@ -327,7 +323,7 @@ fact( // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -390,7 +386,7 @@ fact( }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -442,7 +438,7 @@ fact( const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); @@ -480,7 +476,7 @@ fact('creates a CSS file for the primitive Design Tokens', async () => { // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -543,7 +539,7 @@ fact('creates a CSS file for the primitive Design Tokens', async () => { }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -595,7 +591,7 @@ fact('creates a CSS file for the primitive Design Tokens', async () => { const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); @@ -622,7 +618,7 @@ fact('creates a CSS file for the admin light mode tokens', async () => { // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -685,7 +681,7 @@ fact('creates a CSS file for the admin light mode tokens', async () => { }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -737,7 +733,7 @@ fact('creates a CSS file for the admin light mode tokens', async () => { const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); @@ -763,7 +759,7 @@ fact('creates a CSS file for the admin dark mode tokens', async () => { // GIVEN server.use( http.get( - `https://api.figma.com/v1/files/${PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.PRIMITIVE_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -826,7 +822,7 @@ fact('creates a CSS file for the admin dark mode tokens', async () => { }, ), http.get( - `https://api.figma.com/v1/files/${ADMIN_TOKENS_FILE_KEY}/variables/local`, + `https://api.figma.com/v1/files/${env.ADMIN_TOKENS_FILE_KEY}/variables/local`, () => { return HttpResponse.json({ status: 200, @@ -878,7 +874,7 @@ fact('creates a CSS file for the admin dark mode tokens', async () => { const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), ); diff --git a/packages/tokens/src/GenerateArtifacts.ts b/packages/tokens/src/GenerateArtifacts.ts index e50b99a1d..d8a0b5fd0 100644 --- a/packages/tokens/src/GenerateArtifacts.ts +++ b/packages/tokens/src/GenerateArtifacts.ts @@ -2,10 +2,7 @@ import type { FileSystem } from './common/domain/file-system/FileSystem.js'; import { Dictionary } from './dictionary/domain/Dictionary.js'; import { CSSDeliverable } from './deliverable/domain/CSSDeliverable.js'; import { FigmaApi } from './figma/infrastructure/FigmaApi.js'; -import { - ADMIN_TOKENS_FILE_KEY, - PRIMITIVE_TOKENS_FILE_KEY, -} from './constants.js'; +import { env } from './env.js'; export class GenerateArtifacts { public constructor( @@ -15,8 +12,8 @@ export class GenerateArtifacts { public async execute() { const [primitiveTokenResponse, adminTokenResponse] = await Promise.all( - [PRIMITIVE_TOKENS_FILE_KEY, ADMIN_TOKENS_FILE_KEY].map((fileKey) => - this.figmaApi.getLocalVariablesOfFile(fileKey), + [env.PRIMITIVE_TOKENS_FILE_KEY, env.ADMIN_TOKENS_FILE_KEY].map( + (fileKey) => this.figmaApi.getLocalVariablesOfFile(fileKey), ), ); diff --git a/packages/tokens/src/constants.ts b/packages/tokens/src/constants.ts deleted file mode 100644 index d41447d71..000000000 --- a/packages/tokens/src/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const PRIMITIVE_TOKENS_FILE_KEY = 'hSDX8IwmRAPOTL4NWPwVCl'; -export const ADMIN_TOKENS_FILE_KEY = '8X90GCcpIa4GllKCHA7qFM'; diff --git a/packages/tokens/src/env.ts b/packages/tokens/src/env.ts index 42f5cec6a..feceef77b 100644 --- a/packages/tokens/src/env.ts +++ b/packages/tokens/src/env.ts @@ -4,7 +4,9 @@ import dotenv from 'dotenv'; dotenv.config(); const schema = z.object({ - API_KEY: z.string().min(1), + FIGMA_TOKEN: z.string().min(1), + ADMIN_TOKENS_FILE_KEY: z.string().min(1), + PRIMITIVE_TOKENS_FILE_KEY: z.string().min(1), }); export const env = schema.parse(process.env); diff --git a/packages/tokens/src/scripts/index.ts b/packages/tokens/src/scripts/index.ts index 49e27c2f1..bfb83fc9b 100644 --- a/packages/tokens/src/scripts/index.ts +++ b/packages/tokens/src/scripts/index.ts @@ -8,7 +8,7 @@ import ora from 'ora'; const fileSystem = new HardDiskFileSystem(); const figmaApi = new FigmaApi( { - apiKey: env.API_KEY, + apiKey: env.FIGMA_TOKEN, }, new HttpClientUsingFetch(), );