diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 08bf3bcb890b1..77c0a921b1352 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ { "type": "shell", "label": "prepare turbo", - "command": "cargo build -p turbo" + "command": "cargo build --package turbo" } ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf5d662a49aa3..2cebca83df1cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,7 @@ Dependencies Building -- Building `turbo` CLI: `cargo build -p turbo` +- Building `turbo` CLI: `cargo build --package turbo` - Using `turbo` to build `turbo` CLI: `./turbow.js` ### TLS Implementation diff --git a/cli/package.json b/cli/package.json index 430365fa92d32..deff9108f9185 100644 --- a/cli/package.json +++ b/cli/package.json @@ -3,8 +3,8 @@ "private": true, "version": "0.0.0", "scripts": { - "clean": "cargo clean -p turbo", - "build": "cargo build -p turbo", - "build:release": "cargo build -p turbo --profile release-turborepo" + "clean": "cargo clean --package turbo", + "build": "cargo build --package turbo", + "build:release": "cargo build --package turbo --profile release-turborepo" } } diff --git a/crates/turborepo-lib/src/framework.rs b/crates/turborepo-lib/src/framework.rs index 6e3145c771ee4..385d651e54d40 100644 --- a/crates/turborepo-lib/src/framework.rs +++ b/crates/turborepo-lib/src/framework.rs @@ -37,7 +37,8 @@ impl Framework { static FRAMEWORKS: OnceLock> = OnceLock::new(); -const FRAMEWORKS_JSON: &str = include_str!("frameworks.json"); +const FRAMEWORKS_JSON: &str = + include_str!("../../../packages/turbo-types/src/json/frameworks.json"); fn get_frameworks() -> &'static Vec { FRAMEWORKS.get_or_init(|| { diff --git a/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx b/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx index 8b17d079ebc39..c994e55c3d888 100644 --- a/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx +++ b/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx @@ -6,7 +6,7 @@ description: Learn how to handle environments for your applications. import { Callout } from '#/components/callout'; import { Tabs, Tab } from '#/components/tabs'; import { Accordion, Accordions } from '#/components/accordion'; -import frameworks from '../../../crates/turborepo-lib/src/frameworks.json'; +import { metadata } from 'eslint-plugin-turbo'; Environment variable inputs are a vital part of your applications that you'll need to account for in your Turborepo configuration. @@ -67,7 +67,7 @@ Turborepo automatically adds prefix wildcards to your [`env`](/repo/docs/referen - {frameworks.map(({ name, envWildcards }) => ( + {metadata.frameworks.map(({ name, envWildcards }) => ( {name} {envWildcards.map((w) => {w}).join(', ')} diff --git a/packages/eslint-plugin-turbo/lib/index.ts b/packages/eslint-plugin-turbo/lib/index.ts index 02cf4ae77ec12..44bd9013f327b 100644 --- a/packages/eslint-plugin-turbo/lib/index.ts +++ b/packages/eslint-plugin-turbo/lib/index.ts @@ -1,7 +1,5 @@ import { RULES } from "./constants"; -// rules import noUndeclaredEnvVars from "./rules/no-undeclared-env-vars"; -// configs import recommended from "./configs/recommended"; const rules = { diff --git a/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts b/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts index ee55f961285b1..6f05384dacf78 100644 --- a/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts +++ b/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts @@ -3,6 +3,7 @@ import { existsSync, readFileSync } from "node:fs"; import type { Rule } from "eslint"; import type { Node, MemberExpression } from "estree"; import { logger } from "@turbo/utils"; +import { frameworks } from "@turbo/types"; import { RULES } from "../constants"; import { Project, getWorkspaceFromFilePath } from "../utils/calculate-inputs"; @@ -14,15 +15,6 @@ const debug = debugging /* noop */ }; -interface Framework { - slug: string; - envWildcards: Array; - dependencyMatch: { - strategy: "all" | "some"; - dependencies: Array; - }; -} - export interface RuleContextWithOptions extends Rule.RuleContext { options: Array<{ cwd?: string; @@ -126,12 +118,6 @@ const packageJsonDependencies = (filePath: string): Set => { .reduce((acc, dependency) => acc.add(dependency), new Set()); }; -const frameworksJsonString = readFileSync( - "../../../../crates/turborepo-lib/src/frameworks.json", - "utf-8" -); -const frameworks = JSON.parse(frameworksJsonString) as Array; - /** * Turborepo does some nice framework detection based on the dependencies in the package.json. This function ports that logic to this ESLint rule. * diff --git a/packages/eslint-plugin-turbo/package.json b/packages/eslint-plugin-turbo/package.json index a79142e98a9de..2ac6fa5e5ab91 100644 --- a/packages/eslint-plugin-turbo/package.json +++ b/packages/eslint-plugin-turbo/package.json @@ -19,6 +19,7 @@ }, "author": "Vercel", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist/**" ], diff --git a/packages/eslint-plugin-turbo/tsup.config.ts b/packages/eslint-plugin-turbo/tsup.config.ts index bbda8cb604ddc..12dc08af087d4 100644 --- a/packages/eslint-plugin-turbo/tsup.config.ts +++ b/packages/eslint-plugin-turbo/tsup.config.ts @@ -1,8 +1,9 @@ -import { defineConfig, Options } from "tsup"; +import { defineConfig, type Options } from "tsup"; export default defineConfig((options: Options) => ({ entry: ["lib/index.ts"], clean: true, minify: true, + dts: true, ...options, })); diff --git a/packages/turbo-benchmark/README.md b/packages/turbo-benchmark/README.md index 68946de6a3b46..2fe53013c516d 100644 --- a/packages/turbo-benchmark/README.md +++ b/packages/turbo-benchmark/README.md @@ -3,5 +3,5 @@ To run benchmarks for turborepo 1. Follow the [Building Turborepo](../CONTRIBUTING.md#building-turborepo) instructions to install dependencies -2. `cargo build -p turbo --profile release-turborepo` to build turbo +2. `cargo build --package turbo --profile release-turborepo` to build turbo 3. From this directory `pnpm run benchmark` diff --git a/packages/turbo-types/src/index.ts b/packages/turbo-types/src/index.ts index b6f907d11490b..99cef354039ec 100644 --- a/packages/turbo-types/src/index.ts +++ b/packages/turbo-types/src/index.ts @@ -1,3 +1,10 @@ +import type { Framework as FW } from "./types/frameworks"; +import frameworksJson from "./json/frameworks.json"; + +export const frameworks = frameworksJson as Array; +export type Framework = FW; +export type { FrameworkStrategy } from "./types/frameworks"; + export { type BaseSchema, type BaseSchema as BaseSchemaV2, diff --git a/crates/turborepo-lib/src/frameworks.json b/packages/turbo-types/src/json/frameworks.json similarity index 100% rename from crates/turborepo-lib/src/frameworks.json rename to packages/turbo-types/src/json/frameworks.json diff --git a/packages/turbo-types/src/types/frameworks.ts b/packages/turbo-types/src/types/frameworks.ts new file mode 100644 index 0000000000000..1f91e4f958474 --- /dev/null +++ b/packages/turbo-types/src/types/frameworks.ts @@ -0,0 +1,11 @@ +export type FrameworkStrategy = "all" | "some"; + +export interface Framework { + slug: string; + name: string; + envWildcards: Array; + dependencyMatch: { + strategy: FrameworkStrategy; + dependencies: Array; + }; +}