From c5aadb9c76d5b163a5a80eb25cc7eae48aa8d4aa Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Fri, 20 Dec 2024 16:21:44 -0500 Subject: [PATCH] fix: add env variabls to turbo --- clis/generator-cli/src/cli.ts | 1 + clis/vercel-scripts/src/cli.ts | 2 + eslint.config.mjs | 2 + package.json | 1 + .../bundle/src/server/xfernhost/node.ts | 1 + packages/fern-docs/bundle/turbo.json | 3 +- .../components/src/FontAwesomeIcon.tsx | 3 +- .../search-utils/src/SearchConfig.ts | 5 +- packages/fern-docs/ui/turbo.json | 17 ++++++ packages/healthchecks/src/cli.ts | 1 + packages/healthchecks/src/getDocsURLs.ts | 2 + packages/scripts/src/cli.ts | 1 + pnpm-lock.yaml | 31 ++++++++++- servers/fdr/src/__test__/mock.ts | 1 + servers/fern-bot/turbo.json | 30 +++++++++++ turbo.json | 53 ++++++++++++++++++- 16 files changed, 146 insertions(+), 8 deletions(-) create mode 100644 packages/fern-docs/ui/turbo.json create mode 100644 servers/fern-bot/turbo.json diff --git a/clis/generator-cli/src/cli.ts b/clis/generator-cli/src/cli.ts index 969b5711fd..a63f9f2180 100644 --- a/clis/generator-cli/src/cli.ts +++ b/clis/generator-cli/src/cli.ts @@ -16,6 +16,7 @@ import { ReadmeParser } from "./readme/ReadmeParser"; import { ReferenceGenerator } from "./reference/ReferenceGenerator"; void yargs(hideBin(process.argv)) + // eslint-disable-next-line turbo/no-undeclared-env-vars .scriptName(process.env.CLI_NAME ?? "generator-cli") .strict() .command( diff --git a/clis/vercel-scripts/src/cli.ts b/clis/vercel-scripts/src/cli.ts index 23a409b220..9b3335a6da 100644 --- a/clis/vercel-scripts/src/cli.ts +++ b/clis/vercel-scripts/src/cli.ts @@ -18,12 +18,14 @@ void yargs(hideBin(process.argv)) type: "string", description: "The Vercel API token", demandOption: true, + // eslint-disable-next-line turbo/no-undeclared-env-vars default: process.env.VERCEL_TOKEN ?? getVercelTokenFromGlobalConfig(), }) .options("teamId", { type: "string", description: "The Vercel team ID", demandOption: false, + // eslint-disable-next-line turbo/no-undeclared-env-vars default: process.env.VERCEL_ORG_ID ?? "team_6FKOM5nw037hv8g2mTk3gaH7", }) .options("teamName", { diff --git a/eslint.config.mjs b/eslint.config.mjs index 84c8416df6..0225cdc842 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ export default tseslint.config( "**/.next", "**/storybook-static", "**/out", + "**/lib", "**/node_modules", "fern/**", ], @@ -38,6 +39,7 @@ export default tseslint.config( ...compat.config({ extends: [ + "turbo", "prettier", "next/core-web-vitals", "next/typescript", diff --git a/package.json b/package.json index 86e6751fe1..27c8f3ef20 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "eslint": "^9", "eslint-config-next": "15.1.2", "eslint-config-prettier": "^9.1.0", + "eslint-config-turbo": "^2.3.3", "eslint-plugin-deprecation": "^3.0.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-react": "^7.37.2", diff --git a/packages/fern-docs/bundle/src/server/xfernhost/node.ts b/packages/fern-docs/bundle/src/server/xfernhost/node.ts index 6d0235c2ff..49ae5e6f0e 100644 --- a/packages/fern-docs/bundle/src/server/xfernhost/node.ts +++ b/packages/fern-docs/bundle/src/server/xfernhost/node.ts @@ -36,6 +36,7 @@ export function getDocsDomainNode(req: NextApiRequest): string { // attempts to construct the host from environment variables, when the req object is not available export function getHostNodeStatic(): string | undefined { if (process.env.NODE_ENV === "development") { + // eslint-disable-next-line turbo/no-undeclared-env-vars return `${process.env.HOST || "localhost"}:${process.env.PORT || 3000}`; } diff --git a/packages/fern-docs/bundle/turbo.json b/packages/fern-docs/bundle/turbo.json index 3ac121c0c4..5bff8627e3 100644 --- a/packages/fern-docs/bundle/turbo.json +++ b/packages/fern-docs/bundle/turbo.json @@ -4,8 +4,7 @@ "tasks": { "docs:build": { "outputs": [".next/**", "!.next/cache/**"], - "inputs": ["$TURBO_DEFAULT$", ".env*"], - "dependsOn": ["^build", "^compile"] + "inputs": ["$TURBO_DEFAULT$", ".env*"] }, "docs:dev": { "dependsOn": ["^build", "^compile"] diff --git a/packages/fern-docs/components/src/FontAwesomeIcon.tsx b/packages/fern-docs/components/src/FontAwesomeIcon.tsx index 438565724a..128d9c4e18 100644 --- a/packages/fern-docs/components/src/FontAwesomeIcon.tsx +++ b/packages/fern-docs/components/src/FontAwesomeIcon.tsx @@ -60,7 +60,8 @@ function getIconUrl(icon: string | undefined): string { function getCdnHost() { return ( (typeof process !== "undefined" - ? process.env.NEXT_PUBLIC_FONTAWESOME_CDN_HOST + ? // eslint-disable-next-line turbo/no-undeclared-env-vars + process.env.NEXT_PUBLIC_FONTAWESOME_CDN_HOST : undefined) ?? "https://icons.ferndocs.com" ); } diff --git a/packages/fern-docs/search-utils/src/SearchConfig.ts b/packages/fern-docs/search-utils/src/SearchConfig.ts index b120a13676..36ba000dbe 100644 --- a/packages/fern-docs/search-utils/src/SearchConfig.ts +++ b/packages/fern-docs/search-utils/src/SearchConfig.ts @@ -64,12 +64,13 @@ async function getAlgoliaSearchConfig( return undefined; } - const algoliaAppId = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID; + const algoliaAppId = process.env.ALGOLIA_APP_ID; + // eslint-disable-next-line turbo/no-undeclared-env-vars const algoliaSearchIndex = process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX; assertNonNullish( algoliaAppId, - "Missing environment variable: NEXT_PUBLIC_ALGOLIA_APP_ID" + "Missing environment variable: ALGOLIA_APP_ID" ); assertNonNullish( algoliaSearchIndex, diff --git a/packages/fern-docs/ui/turbo.json b/packages/fern-docs/ui/turbo.json new file mode 100644 index 0000000000..e6c1c7d13e --- /dev/null +++ b/packages/fern-docs/ui/turbo.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "tasks": { + "compile": { + "env": [ + "NODE_ENV", + "ESBUILD_BINARY_PATH", + "FERN_TOKEN", + "NEXT_DEPLOYMENT_ID", + "NEXT_PUBLIC_FDR_ORIGIN", + "NEXT_PUBLIC_VERCEL_ENV" + ], + "inputs": ["$TURBO_DEFAULT$"] + } + } +} diff --git a/packages/healthchecks/src/cli.ts b/packages/healthchecks/src/cli.ts index 671012cfd2..2f3c48ae03 100644 --- a/packages/healthchecks/src/cli.ts +++ b/packages/healthchecks/src/cli.ts @@ -5,6 +5,7 @@ import { printResults } from "./printResults"; import { RuleResult, runRules } from "./rules/runRules"; void yargs(hideBin(process.argv)) + // eslint-disable-next-line turbo/no-undeclared-env-vars .scriptName(process.env.CLI_NAME ?? "fern-healthchecks") .strict() .command( diff --git a/packages/healthchecks/src/getDocsURLs.ts b/packages/healthchecks/src/getDocsURLs.ts index 3dda5ed1df..da7aac996d 100644 --- a/packages/healthchecks/src/getDocsURLs.ts +++ b/packages/healthchecks/src/getDocsURLs.ts @@ -1,3 +1,5 @@ +/* eslint-disable turbo/no-undeclared-env-vars */ + import { VercelClient } from "@fern-fern/vercel"; import { Domain } from "@fern-fern/vercel/api/resources/v9"; diff --git a/packages/scripts/src/cli.ts b/packages/scripts/src/cli.ts index 7b1289cbff..a6d593dfc2 100644 --- a/packages/scripts/src/cli.ts +++ b/packages/scripts/src/cli.ts @@ -1,3 +1,4 @@ +/* eslint-disable turbo/no-undeclared-env-vars */ import { noop } from "ts-essentials"; import { hideBin } from "yargs/helpers"; import yargs from "yargs/yargs"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 201db6f317..bfaa8a67fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: eslint-config-prettier: specifier: ^9.1.0 version: 9.1.0(eslint@9.17.0(jiti@1.21.7)) + eslint-config-turbo: + specifier: ^2.3.3 + version: 2.3.3(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-deprecation: specifier: ^3.0.0 version: 3.0.0(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) @@ -6734,7 +6737,7 @@ packages: resolution: {integrity: sha512-GWrNeElMYHO8FVETjW205u2s9IXFs46fmVKY8T1dHgksCm3JV8w4k14gM2eaZbOUOH/tGcOuz5YbqJl8iKkA8w==} engines: {node: '>=18.0.0'} peerDependencies: - next: ^13.5.0 || ^14.0.0 || ^15.0.0 + next: npm:@fern-api/next@14.2.9-fork.2 react: 18.3.1 react-dom: 18.3.1 storybook: ^8.4.4 @@ -9638,6 +9641,10 @@ packages: resolution: {integrity: sha512-SErOMvge0ZUyWd5B0NXMQlDkN+8r+HhVUsxgOO7IoPDOdDRD2JjExpN6y3KnFR66jsJMwSn1pqIivhU5rcJiNg==} engines: {node: '>=12'} + dotenv@16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + dotenv@16.4.5: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} @@ -9870,6 +9877,11 @@ packages: peerDependencies: eslint: 9.17.0 + eslint-config-turbo@2.3.3: + resolution: {integrity: sha512-cM9wSBYowQIrjx2MPCzFE6jTnG4vpTPJKZ/O+Ps3CqrmGK/wtNOsY6WHGMwLtKY/nNbgRahAJH6jGVF6k2coOg==} + peerDependencies: + eslint: 9.17.0 + eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} @@ -9953,6 +9965,11 @@ packages: peerDependencies: tailwindcss: 3.4.17 + eslint-plugin-turbo@2.3.3: + resolution: {integrity: sha512-j8UEA0Z+NNCsjZep9G5u5soDQHcXq/x4amrwulk6eHF1U91H2qAjp5I4jQcvJewmccCJbVp734PkHHTRnosjpg==} + peerDependencies: + eslint: 9.17.0 + eslint-plugin-vitest@0.5.4: resolution: {integrity: sha512-um+odCkccAHU53WdKAw39MY61+1x990uXjSPguUCq3VcEHdqJrOb8OTMrbYlY6f9jAKx7x98kLVlIe3RJeJqoQ==} engines: {node: ^18.0.0 || >= 20.0.0} @@ -25444,6 +25461,8 @@ snapshots: dotenv-expand@8.0.3: {} + dotenv@16.0.3: {} + dotenv@16.4.5: {} draco3d@1.5.7: {} @@ -25826,6 +25845,11 @@ snapshots: dependencies: eslint: 9.17.0(jiti@1.21.7) + eslint-config-turbo@2.3.3(eslint@9.17.0(jiti@1.21.7)): + dependencies: + eslint: 9.17.0(jiti@1.21.7) + eslint-plugin-turbo: 2.3.3(eslint@9.17.0(jiti@1.21.7)) + eslint-import-resolver-node@0.3.9: dependencies: debug: 3.2.7 @@ -25962,6 +25986,11 @@ snapshots: postcss: 8.4.31 tailwindcss: 3.4.17(ts-node@10.9.2(@swc/core@1.5.7)(@types/node@18.19.33)(typescript@5.7.2)) + eslint-plugin-turbo@2.3.3(eslint@9.17.0(jiti@1.21.7)): + dependencies: + dotenv: 16.0.3 + eslint: 9.17.0(jiti@1.21.7) + eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@8.18.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2)(vitest@2.1.4(@edge-runtime/vm@5.0.0)(@types/node@18.19.33)(jsdom@24.0.0)(less@4.2.0)(sass@1.77.0)(stylus@0.62.0)(terser@5.31.0)): dependencies: '@typescript-eslint/utils': 7.17.0(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) diff --git a/servers/fdr/src/__test__/mock.ts b/servers/fdr/src/__test__/mock.ts index b56f61140f..866e685d3a 100644 --- a/servers/fdr/src/__test__/mock.ts +++ b/servers/fdr/src/__test__/mock.ts @@ -164,6 +164,7 @@ export const baseMockFdrConfig: FdrConfig = { algoliaSearchV2Domains: [], slackToken: "", logLevel: "debug", + // eslint-disable-next-line turbo/no-undeclared-env-vars docsCacheEndpoint: process.env.DOCS_CACHE_ENDPOINT || "", enableCustomerNotifications: false, applicationEnvironment: "mock", diff --git a/servers/fern-bot/turbo.json b/servers/fern-bot/turbo.json new file mode 100644 index 0000000000..a5b19dd176 --- /dev/null +++ b/servers/fern-bot/turbo.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "tasks": { + "compile": { + "env": [ + "CUSTOMER_ALERTS_SLACK_CHANNEL", + "CUSTOMER_PULLS_SLACK_CHANNEL", + "DEFAULT_FDR_ORIGIN", + "DEFAULT_VENUS_ORIGIN", + "ENVIRONMENT", + "FERNIE_SLACK_APP_TOKEN", + "GITHUB_APP_CLIENT_ID", + "GITHUB_APP_CLIENT_SECRET", + "GITHUB_APP_ID", + "GITHUB_APP_LOGIN_ID", + "GITHUB_APP_LOGIN_NAME", + "GITHUB_APP_PRIVATE_KEY", + "GITHUB_APP_WEBHOOK_SECRET", + "HOME", + "NPM_CONFIG_CACHE", + "NPM_CONFIG_PREFIX", + "PINECONE_API_KEY", + "REPO_DATA_S3_BUCKET", + "REPO_DATA_S3_KEY", + "REPO_TO_RUN_ON" + ] + } + } +} diff --git a/turbo.json b/turbo.json index eb6a37ada0..a8ba663708 100644 --- a/turbo.json +++ b/turbo.json @@ -10,7 +10,8 @@ }, "compile": { "outputs": ["dist/**"], - "dependsOn": ["^compile"] + "dependsOn": ["^compile"], + "env": ["NODE_ENV", "VERCEL_ENV"] }, "check-types": { "dependsOn": ["^compile"] @@ -40,7 +41,55 @@ }, "docs:dev": { "persistent": true, - "dependsOn": ["^build", "^compile"] + "dependsOn": ["^build", "^compile"], + "inputs": [ + "$TURBO_DEFAULT$", + ".env.production.local", + ".env.local", + ".env.production", + ".env" + ] + }, + "docs:build": { + "dependsOn": ["^build", "^compile", "^docs:build"], + "env": [ + "ALGOLIA_API_KEY", + "ALGOLIA_APP_ID", + "ALGOLIA_SEARCH_API_KEY", + "ALGOLIA_WRITE_API_KEY", + "ANTHROPIC_API_KEY", + "ANALYZE", + "AWS_ACCESS_KEY_ID", + "AWS_S3_ENDPOINT", + "AWS_REGION", + "AWS_S3_BUCKET_NAME", + "AWS_SECRET_ACCESS_KEY", + "COHERE_API_KEY", + "EDGE_CONFIG", + "ENABLE_ROOT_PATH_BUILD_CACHE", + "ENABLE_SOURCE_MAPS", + "FERN_TOKEN", + "JWT_SECRET_KEY", + "KV_REST_API_READ_ONLY_TOKEN", + "KV_REST_API_TOKEN", + "KV_REST_API_URL", + "KV_URL", + "NODE_ENV", + "OPENAI_API_KEY", + "QSTASH_CURRENT_SIGNING_KEY", + "QSTASH_NEXT_SIGNING_KEY", + "QSTASH_TOKEN", + "QSTASH_URL", + "TRAILING_SLASH", + "TURBOPUFFER_API_KEY", + "VERCEL", + "VERCEL_AUTOMATION_BYPASS_SECRET", + "VERCEL_DEPLOYMENT_ID", + "VERCEL_ENV", + "VERCEL_URL", + "WORKOS_API_KEY", + "WORKOS_CLIENT_ID" + ] } }, "globalDependencies": ["eslint.config.mjs", ".prettierrc.json"]