Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Estévez authored Jul 2, 2022
2 parents 065aed7 + 5aa1047 commit f147f7f
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 272 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/stacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
run: |
npx -y create-remix@${{ inputs.version }} ${{ matrix.stack.name }} --template ${{ matrix.stack.repo }} --typescript --no-install
- name: ⎔ Setup dependency caching
uses: actions/setup-node@v3
- name: 📥 Install deps
uses: bahmutov/npm-install@v1 # more fine grained control than actions/setup-node@v3 caching, i.e. package.json doesn't exist until after the create-remix step
with:
cache: npm
cache-dependency-path: ${{ matrix.stack.name }}/package.json
Expand Down Expand Up @@ -89,8 +89,8 @@ jobs:
- name: 📁 Unzip artifact
run: unzip ${{ matrix.stack.name }}.zip

- name: ⎔ Setup node and dependency caching
uses: actions/setup-node@v3
- name: 📥 Install deps
uses: bahmutov/npm-install@v1 # more fine grained control than actions/setup-node@v3 caching, i.e. package.json doesn't exist until after the unzip step
with:
node-version: 16
cache: npm
Expand Down Expand Up @@ -131,8 +131,8 @@ jobs:
- name: 📁 Unzip artifact
run: unzip ${{ matrix.stack.name }}.zip

- name: ⎔ Setup node and dependency caching
uses: actions/setup-node@v3
- name: 📥 Install deps
uses: bahmutov/npm-install@v1 # more fine grained control than actions/setup-node@v3 caching, i.e. package.json doesn't exist until after the unzip step
with:
node-version: 16
cache: npm
Expand Down Expand Up @@ -173,8 +173,8 @@ jobs:
- name: 📁 Unzip artifact
run: unzip ${{ matrix.stack.name }}.zip

- name: ⎔ Setup node and dependency caching
uses: actions/setup-node@v3
- name: 📥 Install deps
uses: bahmutov/npm-install@v1 # more fine grained control than actions/setup-node@v3 caching, i.e. package.json doesn't exist until after the unzip step
with:
node-version: 16
cache: npm
Expand Down Expand Up @@ -218,8 +218,8 @@ jobs:
- name: 📁 Unzip artifact
run: unzip ${{ matrix.stack.name }}.zip

- name: ⎔ Setup node and dependency caching
uses: actions/setup-node@v3
- name: 📥 Install deps
uses: bahmutov/npm-install@v1 # more fine grained control than actions/setup-node@v3 caching, i.e. package.json doesn't exist until after the unzip step
with:
node-version: 16
cache: npm
Expand Down
2 changes: 2 additions & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
- chenxsan
- chiangs
- christianhg
- christophertrudel
- christophgockel
- clarkmitchell
- cliffordfajardo
Expand Down Expand Up @@ -187,6 +188,7 @@
- JulesBlm
- juliaqiuxy
- justinnoel
- justsml
- juwiragiye
- jveldridge
- jvnm-dev
Expand Down
12 changes: 12 additions & 0 deletions docs/api/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ module.exports = {
};
```

### watchPaths

A function for defining custom directories to watch while running [remix dev][remix-dev], in addition to [`appDirectory`][app-directory].

```tsx
exports.watchPaths = async () => {
return ["/some/path/*"];
};
```

## File Name Conventions

There are a few conventions that Remix uses you should be aware of.
Expand Down Expand Up @@ -1458,3 +1468,5 @@ export default function Page() {
[http-equiv-tag]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-http-equiv
[error-boundaries]: https://reactjs.org/docs/error-boundaries.html
[use-matches]: ./remix#usematches
[remix-dev]: https://remix.run/docs/en/v1/other-api/dev#remix-dev
[app-directory]: #appDirectory
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
1 change: 1 addition & 0 deletions packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("readConfig", () => {
"serverMode": "production",
"serverModuleFormat": "cjs",
"serverPlatform": "node",
"watchPaths": Array [],
}
`
);
Expand Down
15 changes: 12 additions & 3 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 Expand Up @@ -291,7 +299,8 @@ export async function dev(
process.env.HOST ||
Object.values(os.networkInterfaces())
.flat()
.find((ip) => ip?.family === "IPv4" && !ip.internal)?.address;
.find((ip) => String(ip?.family).includes("4") && !ip?.internal)
?.address;

if (!address) {
console.log(`Remix App Server started at http://localhost:${port}`);
Expand Down
13 changes: 8 additions & 5 deletions packages/remix-dev/cli/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,13 @@ export async function validateTemplate(
method = "GET";
}
try {
response = await fetch(apiUrl, {
method,
headers: { Authorization: `token ${options?.githubToken}` },
});
let headers: Record<string, string> = {};
if (options?.githubToken) {
headers = {
Authorization: `token ${options.githubToken}`,
};
}
response = await fetch(apiUrl, { method, headers });
} catch (_) {
throw Error(
"🚨 There was a problem fetching the template. Please ensure you " +
Expand Down Expand Up @@ -674,7 +677,7 @@ export async function validateTemplate(
return;
case 401:
throw Error(
"🚨 The template could not be verified because you do are not " +
"🚨 The template could not be verified because you are not " +
"authorized to access that repository. Please double check the " +
"access rights of the repo or consider passing a `--token`"
);
Expand Down
Loading

0 comments on commit f147f7f

Please sign in to comment.