Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(examples): mark core supported examples #9707

Merged
merged 7 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter Turborepo.
This Turborepo starter is maintained by the Turborepo core team.

## Using this example

Expand Down
3 changes: 3 additions & 0 deletions examples/basic/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"maintainedByCoreTeam": true
}
2 changes: 2 additions & 0 deletions examples/design-system/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Turborepo Design System Starter

This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

This guide explains how to use a React design system starter powered by:

- 🏎 [Turborepo](https://turbo.build/repo) — High-performance build system for Monorepos
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchen-sink/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo kitchen sink starter

This is an official starter Turborepo with multiple meta-frameworks all working in harmony and sharing packages.
This Turborepo starter is maintained by the Turborepo core team.

This example also shows how to use [Workspace Configurations](https://turbo.build/repo/docs/core-concepts/monorepos/configuring-workspaces).

Expand Down
3 changes: 2 additions & 1 deletion examples/kitchen-sink/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"name": "Kitchen Sink",
"description": "Want to see a more in-depth example? Includes multiple frameworks, both frontend and backend.",
"template": "https://vercel.com/templates/remix/turborepo-kitchensink",
"featured": true
"featured": true,
"maintainedByCoreTeam": true
}
2 changes: 1 addition & 1 deletion examples/non-monorepo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo non-monorepo starter

This is an official starter Turborepo.
This Turborepo starter is maintained by the Turborepo core team.

## Using this example

Expand Down
3 changes: 2 additions & 1 deletion examples/non-monorepo/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Non-Monorepo",
"description": "Example of using Turborepo in a single project without workspaces"
"description": "Example of using Turborepo in a single project without workspaces",
"maintainedByCoreTeam": true
}
2 changes: 1 addition & 1 deletion examples/with-angular/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-berry/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter with berry (yarn v2+)

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-changesets/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo Design System starter with Changesets

This is an official React design system starter powered by Turborepo. Versioning and package publishing is handled by [Changesets](https://github.com/changesets/changesets) and fully automated with GitHub Actions.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo Docker starter

This is an official Docker starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-gatsby/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo Gatsby.js starter

This is an official starter turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-nestjs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-npm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-prisma/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-react-native-web/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo react-native starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-rollup/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter with Rollup

This is an official starter Turborepo, showing how Turborepo can be used with Rollup for bundling a `ui` package.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-shell-commands/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter with shell commands

This is an official starter Turborepo meant for debugging, learning, and exploring.
This Turborepo starter is maintained by the Turborepo core team. This template is great for issue reproductions and exploring building task graphs without frameworks.

## Using this example

Expand Down
3 changes: 3 additions & 0 deletions examples/with-shell-commands/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"maintainedByCoreTeam": true
}
2 changes: 1 addition & 1 deletion examples/with-svelte/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo Svelte starter

This is an official starter Turborepo.
This Turborepo starter is maintained by the Turborepo core team.

## Using this example

Expand Down
3 changes: 2 additions & 1 deletion examples/with-svelte/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"description": "Monorepo with multiple SvelteKit apps sharing a UI Library",
"featured": true,
"template": "https://vercel.com/templates/svelte/turborepo-sveltekit-starter",
"boost": true
"boost": true,
"maintainedByCoreTeam": true
}
2 changes: 1 addition & 1 deletion examples/with-tailwind/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo Tailwind CSS starter

This is an official starter Turborepo.
This Turborepo starter is maintained by the Turborepo core team.

## Using this example

Expand Down
3 changes: 2 additions & 1 deletion examples/with-tailwind/meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "Tailwind CSS",
"description": "Monorepo with multiple Next.js apps sharing a UI Library all using Tailwind CSS with a shared config",
"featured": true
"featured": true,
"maintainedByCoreTeam": true
}
2 changes: 1 addition & 1 deletion examples/with-typeorm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo with TypeORM

This is an official starter Turborepo configured with TypeORM to manage the service layer in a monorepo setup.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## What's inside?

Expand Down
2 changes: 1 addition & 1 deletion examples/with-vite/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `Turborepo` Vite starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-vue-nuxt/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo VueJS/NuxtJS starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
2 changes: 1 addition & 1 deletion examples/with-yarn/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turborepo starter

This is an official starter Turborepo.
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.

## Using this example

Expand Down
18 changes: 17 additions & 1 deletion packages/create-turbo/src/commands/create/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "node:path";
import { bold, red, cyan, green } from "picocolors";
import { bold, red, cyan, green, dim } from "picocolors";
import type { Project } from "@turbo/workspaces";
import {
getWorkspaceDetails,
Expand Down Expand Up @@ -76,6 +76,8 @@ export async function create(
opts.telemetry?.trackArgumentDirectory(Boolean(directory));
trackOptions(opts);

let isMaintainedByCoreTeam = false;

const { packageManager, skipInstall, skipTransforms } = opts;

const [online, availablePackageManagers] = await Promise.all([
Expand Down Expand Up @@ -159,6 +161,10 @@ export async function create(
`feat(create-turbo): apply ${transformResult.name} transform`
);
}

if (transformResult.metaJson?.maintainedByCoreTeam) {
isMaintainedByCoreTeam = true;
}
} catch (err) {
handleErrors(err, opts.telemetry);
}
Expand Down Expand Up @@ -256,6 +262,15 @@ export async function create(
);
}

if (!isMaintainedByCoreTeam) {
logger.log();
logger.log(
dim(
"Note: This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed."
)
);
}

// get the package manager details so we display the right commands to the user in log messages
const packageManagerMeta = getPackageManagerMeta(projectPackageManager);
if (packageManagerMeta && hasPackageJson) {
Expand Down Expand Up @@ -285,5 +300,6 @@ export async function create(
});
logger.log("- Run a command twice to hit cache");
}

opts.telemetry?.trackCommandStatus({ command: "create", status: "end" });
}
14 changes: 9 additions & 5 deletions packages/create-turbo/src/transforms/official-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path";
import { readJsonSync, writeJsonSync, rmSync, existsSync } from "fs-extra";
import type { PackageJson } from "@turbo/utils";
import { isDefaultExample } from "../utils/isDefaultExample";
import type { TransformInput, TransformResult } from "./types";
import type { TransformInput, TransformResult, MetaJson } from "./types";
import { TransformError } from "./errors";

const meta = {
Expand All @@ -18,9 +18,10 @@ export async function transform(args: TransformInput): TransformResult {
const { prompts, example, opts } = args;

const defaultExample = isDefaultExample(example.name);
const isOfficialStarter =
!example.repo ||
(example.repo.username === "vercel" && example.repo.name === "turbo");
const isThisRepo =
example.repo &&
(example.repo.name === "turborepo" || example.repo.name === "turbo");
const isOfficialStarter = example.repo?.username === "vercel" && isThisRepo;

if (!isOfficialStarter) {
return { result: "not-applicable", ...meta };
Expand All @@ -31,8 +32,11 @@ export async function transform(args: TransformInput): TransformResult {
const rootMetaJsonPath = path.join(prompts.root, "meta.json");
const hasPackageJson = existsSync(rootPackageJsonPath);

let metaJson: MetaJson | undefined;

// 1. remove meta file (used for generating the examples page on turbo.build)
try {
metaJson = readJsonSync(rootMetaJsonPath) as MetaJson;
rmSync(rootMetaJsonPath, { force: true });
} catch (_err) {
// do nothing
Expand Down Expand Up @@ -83,5 +87,5 @@ export async function transform(args: TransformInput): TransformResult {
}
}

return { result: "success", ...meta };
return { result: "success", metaJson, ...meta };
}
10 changes: 10 additions & 0 deletions packages/create-turbo/src/transforms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ export interface TransformInput {
opts: CreateCommandOptions;
}

export interface MetaJson {
maintainedByCoreTeam?: string;
name?: string;
description?: string;
featured?: boolean;
boost?: boolean;
template?: boolean;
}

export interface TransformResponse {
// errors should be thrown as instances of TransformError
result: "not-applicable" | "success";
name: string;
metaJson?: MetaJson;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this more generic and just call it data. This response type is re-used by every transform, but the metaJson is only applicable to one.

Copy link
Member

@tknickman tknickman Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah but you need typesafe access here later so we can leave this unless you want to make data generic 😄

}

export type TransformResult = Promise<TransformResponse>;
Loading