Skip to content

Commit

Permalink
Merge branch 'dev' into logan/rem-1118-include-publicpath-in-server-m…
Browse files Browse the repository at this point in the history
…anifest
  • Loading branch information
mcansh committed Jul 5, 2022
2 parents ffe875e + ac9b14a commit 6f3ef54
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 21 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
- evanwinter
- exegeteio
- F3n67u
- federicoestevez
- fergusmeiklejohn
- fgiuliani
- fishel-feng
Expand Down
2 changes: 1 addition & 1 deletion integration/esm-only-warning-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test.beforeAll(async () => {
},
});

let chunks = [];
let chunks: Buffer[] = [];
buildOutput = await new Promise<string>((resolve, reject) => {
buildStdio.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
buildStdio.on("error", (err) => reject(err));
Expand Down
21 changes: 13 additions & 8 deletions integration/helpers/playwright-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ export class PlaywrightFixture {
* @param waitForHydration Will wait for the network to be idle, so
* everything should be loaded and ready to go
*/
async goto(href: string, waitForHydration?: true) {
return this.page.goto(this.app.serverUrl + href, {
async goto(href: string, waitForHydration?: true): Promise<Response> {
let response = await this.page.goto(this.app.serverUrl + href, {
waitUntil: waitForHydration ? "networkidle" : undefined,
});
if (response == null)
throw new Error(
"Unexpected null response, possible about:blank request or same-URL redirect"
);
return response;
}

/**
Expand All @@ -42,7 +47,7 @@ export class PlaywrightFixture {
throw new Error(`Could not find link for ${selector}`);
}
if (options.wait) {
await doAndWait(this.page, () => el.click());
await doAndWait(this.page, () => el!.click());
} else {
await el.click();
}
Expand Down Expand Up @@ -94,7 +99,7 @@ export class PlaywrightFixture {
}
}
if (options.wait) {
await doAndWait(this.page, () => el.click());
await doAndWait(this.page, () => el!.click());
} else {
await el.click();
}
Expand All @@ -108,7 +113,7 @@ export class PlaywrightFixture {
if (!el) {
throw new Error(`Can't find element for: ${selector}`);
}
await doAndWait(this.page, () => el.click());
await doAndWait(this.page, () => el!.click());
}

/**
Expand Down Expand Up @@ -167,7 +172,7 @@ export class PlaywrightFixture {
*
* @param selector CSS Selector for the element's HTML you want
*/
async getElement(selector?: string) {
async getElement(selector: string) {
return getElement(await getHtml(this.page), selector);
}

Expand Down Expand Up @@ -260,7 +265,7 @@ async function doAndWait(
page.on("requestfinished", onRequestDone);
page.on("requestfailed", onRequestDone);

let timeoutId: NodeJS.Timer;
let timeoutId: NodeJS.Timer | undefined;
if (DEBUG) {
timeoutId = setInterval(() => {
console.log(`${requestCounter} requests pending:`);
Expand All @@ -283,7 +288,7 @@ async function doAndWait(
page.removeListener("requestfinished", onRequestDone);
page.removeListener("requestfailed", onRequestDone);

if (DEBUG) {
if (DEBUG && timeoutId) {
clearTimeout(timeoutId);
}

Expand Down
2 changes: 1 addition & 1 deletion integration/prefetch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import type { RemixLinkProps } from "../build/node_modules/@remix-run/react/components";
import type { RemixLinkProps } from "../build/node_modules/@remix-run/react/dist/components";
import { PlaywrightFixture } from "./helpers/playwright-fixture";

// Generate the test app using the given prefetch mode
Expand Down
10 changes: 9 additions & 1 deletion integration/tsconfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test";
import fse from "fs-extra";
import path from "path";
import JSON5 from "json5";
import type { TsConfigJson } from "type-fest";

import { createFixture, json } from "./helpers/create-fixture";

Expand All @@ -11,8 +12,15 @@ async function getTsConfig(projectDir: string) {
return JSON5.parse(config);
}

// Omit non JSON-serializable things we don't need
type SerializableTsConfigJson = Omit<
TsConfigJson,
"compilerOptions" | "references" | "typeAcquisition" | "watchOptions"
> & {
compilerOptions: Omit<TsConfigJson.CompilerOptions, "plugins">;
};
// this is the default tsconfig.json that is shipped with `create-remix` templates
const DEFAULT_CONFIG = {
const DEFAULT_CONFIG: SerializableTsConfigJson = {
include: ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
compilerOptions: {
allowJs: true,
Expand Down
23 changes: 23 additions & 0 deletions integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"exclude": ["helpers/*-template"],
"compilerOptions": {
"lib": ["ES2019"],
"target": "ES2019",
"module": "CommonJS",
"skipLibCheck": true,

"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"strict": true,
"resolveJsonModule": true,

"noEmit": true,

"rootDir": "."
},
"references": [
{ "path": "../packages/remix-express" },
{ "path": "../packages/remix-react" },
{ "path": "../packages/remix-server-runtime" }
]
}
2 changes: 2 additions & 0 deletions packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ describe("remix CLI", () => {
\`dev\` Options:
--debug Attach Node.js inspector
--port, -p Choose the port from which to run your app
\`init\` Options:
--no-delete Skip deleting the \`remix.init\` script
\`routes\` Options:
--json Print the routes as JSON
\`migrate\` Options:
Expand Down
24 changes: 24 additions & 0 deletions packages/remix-dev/__tests__/create-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,30 @@ describe("the create command", () => {
expect(fse.existsSync(path.join(projectDir, "remix.init"))).toBeFalsy();
});

it("It keeps the `remix.init` script when using the `--no-delete` flag", async () => {
let projectDir = await getProjectDir("remix-init-manual");
await run([
"create",
projectDir,
"--template",
path.join(__dirname, "fixtures", "successful-remix-init.tar.gz"),
"--no-install",
"--typescript",
]);
expect(output.trim()).toBe(
getOptOutOfInstallMessage() +
"\n\n" +
getSuccessMessage(path.join("<TEMP_DIR>", "remix-init-manual"))
);

output = "";
process.chdir(projectDir);
await run(["init", "--no-delete"]);

expect(output).toBe("");
expect(fse.existsSync(path.join(projectDir, "remix.init"))).toBeTruthy();
});

it("throws an error when invalid remix.init script when automatically ran", async () => {
let projectDir = await getProjectDir("invalid-remix-init-manual");
await expect(
Expand Down
12 changes: 10 additions & 2 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ export async function create({
spinner.clear();
}

export async function init(projectDir: string) {
type InitFlags = {
deleteScript?: boolean;
};
export async function init(
projectDir: string,
{ deleteScript = true }: InitFlags = {}
) {
let initScriptDir = path.join(projectDir, "remix.init");
let initScript = path.resolve(initScriptDir, "index.js");

Expand All @@ -79,7 +85,9 @@ export async function init(projectDir: string) {
try {
await initFn({ isTypeScript, packageManager, rootDirectory: projectDir });

await fse.remove(initScriptDir);
if (deleteScript) {
await fse.remove(initScriptDir);
}
} catch (error) {
if (error instanceof Error) {
error.message = `${colors.error("🚨 Oops, remix.init failed")}\n\n${
Expand Down
12 changes: 10 additions & 2 deletions packages/remix-dev/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ ${colors.logoBlue("R")} ${colors.logoGreen("E")} ${colors.logoYellow(
\`dev\` Options:
--debug Attach Node.js inspector
--port, -p Choose the port from which to run your app
\`init\` Options:
--no-delete Skip deleting the \`remix.init\` script
\`routes\` Options:
--json Print the routes as JSON
\`migrate\` Options:
Expand Down Expand Up @@ -151,6 +153,7 @@ export async function run(argv: string[] = process.argv.slice(2)) {
let args = arg(
{
"--debug": Boolean,
"--no-delete": Boolean,
"--dry": Boolean,
"--force": Boolean,
"--help": Boolean,
Expand Down Expand Up @@ -192,6 +195,9 @@ export async function run(argv: string[] = process.argv.slice(2)) {
return;
}

if (args["--no-delete"]) {
flags.delete = false;
}
if (args["--no-install"]) {
flags.install = false;
}
Expand Down Expand Up @@ -408,7 +414,7 @@ export async function run(argv: string[] = process.argv.slice(2)) {
if (hasInitScript) {
if (installDeps) {
console.log("💿 Running remix.init script");
await commands.init(projectDir);
await commands.init(projectDir, { deleteScript: true });
} else {
console.log();
console.log(
Expand Down Expand Up @@ -442,7 +448,9 @@ export async function run(argv: string[] = process.argv.slice(2)) {
break;
}
case "init":
await commands.init(input[1] || process.env.REMIX_ROOT || process.cwd());
await commands.init(input[1] || process.env.REMIX_ROOT || process.cwd(), {
deleteScript: flags.delete,
});
break;
case "routes":
await commands.routes(input[1], flags.json ? "json" : "jsx");
Expand Down
3 changes: 2 additions & 1 deletion packages/remix-express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"declaration": true,
"emitDeclarationOnly": true,
"rootDir": ".",
"outDir": "../../build/node_modules/@remix-run/express/dist"
"outDir": "../../build/node_modules/@remix-run/express/dist",
"composite": true
}
}
2 changes: 1 addition & 1 deletion packages/remix-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@netlify/functions": "^1.0.0"
},
"peerDependencies": {
"@netlify/functions": "^0.10.0 || ^1.0.0"
"@netlify/functions": "^0.10.0 || ^0.11.0 || ^1.0.0"
},
"engines": {
"node": ">=14"
Expand Down
3 changes: 2 additions & 1 deletion packages/remix-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"declaration": true,
"emitDeclarationOnly": true,
"rootDir": ".",
"outDir": "../../build/node_modules/@remix-run/react/dist"
"outDir": "../../build/node_modules/@remix-run/react/dist",
"composite": true
}
}
1 change: 1 addition & 0 deletions packages/remix-server-runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"emitDeclarationOnly": true,
"rootDir": ".",
"outDir": "../../build/node_modules/@remix-run/server-runtime/dist",
"composite": true,

// Avoid naming conflicts between lib.dom.d.ts and globals.ts
"skipLibCheck": true
Expand Down
2 changes: 1 addition & 1 deletion scripts/playground/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function createNewProject(name = `playground-${Date.now()}`) {
let hasInit = fse.existsSync(path.join(projectDir, "remix.init"));
if (hasInit) {
console.log("🎬 Running Remix Init...");
execSync(`node ./node_modules/@remix-run/dev/cli init`, {
execSync(`node ./node_modules/@remix-run/dev/dist/cli init`, {
stdio: "inherit",
cwd: projectDir,
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/playground/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"scripts": {
"build": "run-s build:*",
"build:css": "npm run generate:css -- --minify",
"build:remix": "node ./node_modules/@remix-run/dev/cli build",
"build:remix": "node ./node_modules/@remix-run/dev/dist/cli build",
"dev": "run-p dev:*",
"dev:server": "cross-env NODE_ENV=development node --inspect --require ./node_modules/dotenv/config ./server.js",
"dev:remix": "cross-env NODE_ENV=development node ./node_modules/@remix-run/dev/cli watch",
"dev:remix": "cross-env NODE_ENV=development node ./node_modules/@remix-run/dev/dist/cli watch",
"dev:css": "cross-env NODE_ENV=development npm run generate:css -- --watch",
"generate:css": "tailwindcss -o ./app/styles/tailwind.css",
"setup": "prisma migrate dev",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"files": [],
"exclude": ["node_modules", "build"],
"references": [
{ "path": "integration" },
{ "path": "packages/create-remix" },
{ "path": "packages/remix" },
{ "path": "packages/remix-architect" },
Expand Down

0 comments on commit 6f3ef54

Please sign in to comment.