Skip to content

Commit 4a5d9dd

Browse files
authored
feat(create-turbo): fix official examples (#9837)
### Description Fixes some logic that was introduced #9708 that allows classifying official examples. ### Testing Instructions <!-- Give a quick description of steps to test your changes. -->
1 parent ebc4075 commit 4a5d9dd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/create-turbo/src/transforms/official-starter.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { isDefaultExample } from "../utils/isDefaultExample";
55
import type { TransformInput, TransformResult, MetaJson } from "./types";
66
import { TransformError } from "./errors";
77

8+
const REPO_NAMES = ["turbo", "turborepo"];
9+
810
const meta = {
911
name: "official-starter",
1012
};
@@ -18,10 +20,10 @@ export async function transform(args: TransformInput): TransformResult {
1820
const { prompts, example, opts } = args;
1921

2022
const defaultExample = isDefaultExample(example.name);
21-
const isThisRepo =
22-
example.repo &&
23-
(example.repo.name === "turborepo" || example.repo.name === "turbo");
24-
const isOfficialStarter = example.repo?.username === "vercel" && isThisRepo;
23+
const isOfficialStarter =
24+
!example.repo ||
25+
(example.repo.username === "vercel" &&
26+
REPO_NAMES.includes(example.repo.name));
2527

2628
if (!isOfficialStarter) {
2729
return { result: "not-applicable", ...meta };
@@ -43,7 +45,7 @@ export async function transform(args: TransformInput): TransformResult {
4345
}
4446

4547
if (hasPackageJson) {
46-
let packageJsonContent;
48+
let packageJsonContent: PackageJson | undefined;
4749
try {
4850
packageJsonContent = fs.readJsonSync(rootPackageJsonPath) as
4951
| PackageJson

packages/turbo-utils/src/createProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function createProject({
4747
if (isDefaultExample) {
4848
repoInfo = {
4949
username: "vercel",
50-
name: "turbo",
50+
name: "turborepo",
5151
branch: "main",
5252
filePath: "examples/basic",
5353
};

packages/turbo-utils/src/examples.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function existsInRepo(nameOrUrl: string): Promise<boolean> {
9191
return isUrlOk(url.href);
9292
} catch {
9393
return isUrlOk(
94-
`https://api.github.com/repos/vercel/turbo/contents/examples/${encodeURIComponent(
94+
`https://api.github.com/repos/vercel/turborepo/contents/examples/${encodeURIComponent(
9595
nameOrUrl
9696
)}`
9797
);

0 commit comments

Comments
 (0)