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

fix(remix-dev): Update create-remix to use the new examples repository #4208

Merged
merged 6 commits into from
Sep 26, 2022
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
6 changes: 6 additions & 0 deletions .changeset/curvy-zoos-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/dev": patch
"create-remix": patch
---

Fix create-remix to use the new examples repository when using `--template example/folder-name`
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/create-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("the create command", () => {
}

// this also tests sub directories
it("works for examples in the remix repo", async () => {
it("works for examples in the examples repo", async () => {
let projectDir = await getProjectDir("example");
await run([
"create",
Expand Down
Binary file not shown.
14 changes: 12 additions & 2 deletions packages/remix-dev/__tests__/github-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,34 @@ let sendTarball: ResponseResolver = async (req, res, ctx) => {
invariant(typeof repo === "string", "repo must be a string");

let pathToTarball: string;
if (owner === "remix-run" && repo === "remix") {
if (owner === "remix-run" && repo === "examples") {
pathToTarball = nodePath.join(__dirname, "fixtures/examples-main.tar.gz");
} else if (owner === "remix-run" && repo === "remix") {
pathToTarball = nodePath.join(__dirname, "fixtures/remix-repo.tar.gz");
} else if (owner === "fake-remix-tester" && repo === "nested-dir") {
pathToTarball = nodePath.join(__dirname, "fixtures/nested-dir-repo.tar.gz");
} else {
pathToTarball = nodePath.join(__dirname, "fixtures/stack.tar.gz");
}

let fileBuffer = await fsp.readFile(pathToTarball);

return res(
ctx.body(fileBuffer),
ctx.set("Content-Type", "application/x-gzip")
);
};

let githubHandlers: Array<RequestHandler> = [
rest.head(
`https://github.com/remix-run/remix/tree/main/:type/:name`,
async (req, res, ctx) => {
async (_req, res, ctx) => {
return res(ctx.status(200));
}
),
rest.head(
`https://github.com/remix-run/examples/tree/main/:type/:name`,
async (_req, res, ctx) => {
return res(ctx.status(200));
}
),
Expand Down
21 changes: 11 additions & 10 deletions packages/remix-dev/cli/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,14 @@ export async function createApp({
if (debug) {
console.log(
colors.warning(
` 🔍 Using the ${name} example template from the remix-run/remix repo`
` 🔍 Using the ${name} example template from the remix-run/examples repo`
)
);
}

await downloadAndExtractRepoTarball(
projectDir,
getRepoInfo(
`https://github.com/remix-run/remix/tree/main/examples/${name}`
),
getRepoInfo(`https://github.com/remix-run/examples/tree/main/${name}`),
options
);
break;
Expand Down Expand Up @@ -708,12 +706,15 @@ export async function validateTemplate(
case "example":
case "template": {
let spinner = ora("Validating the template…").start();
let isExample = templateType === "example";
let name = input;
if (templateType === "example") {
if (isExample) {
name = name.split("/")[1];
}
let typeDir = templateType + "s";
let templateUrl = `https://github.com/remix-run/remix/tree/main/${typeDir}/${name}`;
let repoBaseUrl = isExample
? "https://github.com/remix-run/examples/tree/main"
: "https://github.com/remix-run/remix/tree/main/templates";
let templateUrl = `${repoBaseUrl}/${name}`;
let response;
try {
response = await fetch(templateUrl, { method: "HEAD" });
Expand All @@ -733,15 +734,15 @@ export async function validateTemplate(
throw Error(
"🚨 The template could not be verified. Please double check that " +
"the template is a valid project directory in " +
`https://github.com/remix-run/remix/tree/main/${typeDir} and ` +
`${repoBaseUrl} and ` +
"try again."
);
default:
throw Error(
"🚨 The template could not be verified. The server returned a " +
`response with a ${response.status} status. Please double ` +
"check that the template is a valid project directory in " +
`https://github.com/remix-run/remix/tree/main/${typeDir} and ` +
`${repoBaseUrl} and ` +
"try again."
);
}
Expand Down Expand Up @@ -803,7 +804,7 @@ export function detectTemplateType(template: string): TemplateType | null {
// ignore FS errors and move on
}

// 4. examples/<template> will use an example folder in the Remix repo
// 4. examples/<template> will use a folder in the Examples repo
if (/^examples?\/[\w-]+$/.test(template)) {
return "example";
}
Expand Down
14 changes: 0 additions & 14 deletions packages/remix-eslint-config/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ module.exports = {
"@typescript-eslint/no-unused-vars": OFF,
},
},
{
files: [
// All examples and docs, including code blocks in .md files
"examples/**/*.js?(x)",
"examples/**/*.ts?(x)",
],
rules: {
"import/order": OFF,
"no-unused-expressions": OFF,
"no-unused-labels": OFF,
"no-unused-vars": OFF,
"prefer-let/prefer-let": OFF,
},
},
{
files: ["packages/**/*.*"],
excludedFiles: "**/__tests__/**/*.*",
Expand Down