Skip to content

Commit

Permalink
chore: get this mostly working...
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Feb 1, 2023
1 parent d4b327c commit a43f796
Show file tree
Hide file tree
Showing 59 changed files with 9,059 additions and 986 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ yarn.lock
pnpm-lock.yaml
pnpm-lock.yml

!./yarn.lock
!/yarn.lock
!yarn-pnp/yarn.lock
92 changes: 36 additions & 56 deletions __scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import os from "node:os";

import { execa } from "execa";
import { detect, getCommand } from "@antfu/ni";
import PackageJson from "@npmcli/package-json";
import fse from "fs-extra";
import PQueue from "p-queue";
import PackageJson from "@npmcli/package-json";

console.log({ concurrency: os.cpus().length });

const queue = new PQueue({ concurrency: os.cpus().length });
const queue = new PQueue({ concurrency: os.cpus().length, autoStart: false });

const TO_IGNORE = [".git", ".github", "__scripts", "yarn.lock", "package.json"];

Expand Down Expand Up @@ -40,9 +40,7 @@ if (process.env.CI) {
.filter((entry) => entry.isDirectory())
.filter((entry) => !TO_IGNORE.includes(entry.name))
.map((entry) => entry.name)
.filter((entry) => {
return fse.existsSync(path.join(entry, "package.json"));
});
.filter((entry) => fse.existsSync(path.join(entry, "package.json")));
}

const list = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
Expand All @@ -53,43 +51,47 @@ for (const example of examples) {
queue.add(async () => {
const pkgJson = await PackageJson.load(example);

const remixDeps = Object.keys(pkgJson.content.dependencies).filter((d) => {
return d.startsWith("@remix-run/");
});

const remixDevDeps = Object.keys(pkgJson.content.devDependencies).filter(
(d) => {
return d.startsWith("@remix-run/");
}
);

// TODO: figure out why this is blowing up
pkgJson.update({
dependencies: {
...pkgJson.content.dependencies,
...Object.fromEntries(remixDeps.map((d) => [d, `latest`])),
},
devDependencies: {
...pkgJson.content.devDependencies,
...Object.fromEntries(remixDevDeps.map((d) => [d, `latest`])),
"@vanilla-extract/css": "1.9.2",
},
});

await pkgJson.save();

/** @type {import('execa').Options} */
const options = { cwd: example };
const options = { cwd: example, reject: false };

// detect package manager
const detected = await detect({ cwd: example });

const install = await getCommand(detected, "install", ["--silent"]);
const hasSetup = !!pkgJson.content.scripts?.__setup;

if (hasSetup) {
const setup = await getCommand(detected, "run", ["__setup"]);
const setupArgs = setup.split(" ").slice(1);
console.log("🔧 Running setup script for", example);
const setupResult = await execa(detected, setupArgs, options);
if (setupResult.exitCode) {
console.error(setupResult.stderr);
throw new Error(`Error running setup script for ${example}`);
}
}

const install = await getCommand(detected, "install", [
"--silent",
"--legacy-peer-deps",
]);
// this is silly, but is needed in order for execa to work
const installArgs = install.split(" ").slice(1, -1);
console.log(`📥 Installing ${example} with ${install}`);
console.log(`📥 Installing ${example} with "${install}"`);
const installResult = await execa(detected, installArgs, options);

if (installResult.exitCode) {
console.error(`Error installing ${example}`);
console.error(installResult.stderr);
return;
throw new Error(`Error installing ${example}`);
}

const hasPrisma = fse.existsSync(
Expand All @@ -105,56 +107,34 @@ for (const example of examples) {
);

if (prismaGenerate.exitCode) {
console.error(`Error generating prisma types for ${example}`);
console.error(prismaGenerate.stderr);
return;
throw new Error(`Error generating prisma types for ${example}`);
}
}

const build = await getCommand(detected, "run", ["build"]);
const buildArgs = build.split(" ").slice(1);
console.log(`📦 Building ${example} with ${build}`);
console.log(`📦 Building ${example} with "${build}"`);
const buildResult = await execa(detected, buildArgs, options);

if (buildResult.exitCode) {
console.error(`Error building ${example}`);
console.error(buildResult.stderr);
return;
throw new Error(`Error building ${example}`);
}

const typecheck = await getCommand(detected, "run", ["typecheck"]);
const typecheckArgs = typecheck.split(" ").slice(1);
console.log(`🕵️ Typechecking ${example} with ${typecheck}`);
console.log(`🕵️ Typechecking ${example} with "${typecheck}"`);
const typecheckResult = await execa(detected, typecheckArgs, options);

if (typecheckResult.exitCode) {
console.error(`Error typechecking ${example}`);
console.error(typecheckResult.stderr);
return;
throw new Error(`Error typechecking ${example}`);
}

pkgJson.update({
dependencies: {
...pkgJson.content.dependencies,
...Object.fromEntries(remixDeps.map((d) => [d, `*`])),
},
devDependencies: {
...pkgJson.content.devDependencies,
...Object.fromEntries(remixDevDeps.map((d) => [d, `*`])),
},
});

await pkgJson.save();
});
}

try {
queue.start();
} catch (error) {
console.error(error);
process.exit(1);
}

// const rejected = promises.filter((s) => s.status === "rejected");
// rejected.forEach((s) => console.error(s.reason));
// process.exit(rejected.length > 0 ? 1 : 0);
queue.start();
queue.on("error", (error) => {
console.error("🚨", error);
});
2 changes: 1 addition & 1 deletion _official-blog-tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@remix-run/node": "*",
"@remix-run/react": "*",
"@remix-run/serve": "*",
"marked": "^4.0.15",
"isbot": "^3.6.5",
"marked": "^4.0.15",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tiny-invariant": "^1.2.0"
Expand Down
2 changes: 2 additions & 0 deletions _official-blog-tutorial/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"exclude": ["./cypress"],
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"types": ["vitest/globals"],
"isolatedModules": true,
Expand Down
3 changes: 2 additions & 1 deletion _official-jokes/app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function validatePassword(password: unknown) {
}
}

function validateUrl(url: string) {
function validateUrl(url: FormDataEntryValue) {
if (typeof url !== "string") return;
const urls = ["/jokes", "/", "https://remix.run"];
if (urls.includes(url)) {
return url;
Expand Down
1 change: 1 addition & 0 deletions basic/app/routes/demos/params/$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const loader = async ({ params }: LoaderArgs) => {
// Sometimes your code just blows up and you never anticipated it. Remix will
// automatically catch it and send the UI to the error boundary.
if (params.id === "kaboom") {
// @ts-expect-error
lol();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";

export function ComplexComponent() {
const [count, setCount] = useState(() => {
const [count, setCount] = useState<number>(() => {
const stored = localStorage.getItem("count");
if (!stored) return 0;
return JSON.parse(stored);
Expand Down
2 changes: 1 addition & 1 deletion combobox-resource-route/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@remix-run/node": "*",
"@remix-run/react": "*",
"@remix-run/serve": "*",
"match-sorter": "^6.3.1",
"isbot": "^3.6.5",
"match-sorter": "^6.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion emotion/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
remixContext: any
) {
const cache = createEmotionCache();
const { extractCriticalToChunks } = createEmotionServer(cache);
Expand Down
2 changes: 1 addition & 1 deletion firebase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"typescript": "^4.8.4"
},
"engines": {
"node": "16"
"node": ">=16"
}
}
3 changes: 1 addition & 2 deletions graphql-api/app/routes/character/$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export const loader = async ({ params }: LoaderArgs) => {
* the Remix loader & route params.
*/
export default function Character() {
const loader = useLoaderData<typeof loader>();
const { data } = loader;
const { data } = useLoaderData<typeof loader>();

const character = data.character;

Expand Down
4 changes: 2 additions & 2 deletions graphql-api/app/routes/character/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export const loader = async () => {
* an array of errors coming back from the GraphQL API.
*/
export default function CharacterError() {
const loader = useLoaderData<typeof loader>();
const data = useLoaderData<typeof loader>();

return (
<main className="ui-main">
<h1>Ex: GraphQL Error</h1>
<Code data={loader} summary="Loader Data" />
<Code data={data} summary="Loader Data" />
<p>
Uh oh, we've intentionally triggered an error, expand the details above
to see what's going on.
Expand Down
2 changes: 1 addition & 1 deletion graphql-api/app/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Index() {
above to see what the Remix loader returned.
</p>
<hr style={{ margin: "40px auto" }} />
{characters.map((character) => {
{characters.map((character: any) => {
if (!character) return null;

const { image } = character;
Expand Down
5 changes: 4 additions & 1 deletion image-resize/app/components/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export interface ImageProps extends React.ComponentPropsWithRef<"img"> {
width?: number; // either width or height is required
height?: number;
fit?: keyof FitEnum; // contain is default
alt: string;
alt?: string;
}

const Image = forwardRef<HTMLImageElement, ImageProps>(
({ children, width, height, fit, src, alt = "", ...other }, forwardedRef) => {
const query = new URLSearchParams();
Expand All @@ -32,3 +33,5 @@ const Image = forwardRef<HTMLImageElement, ImageProps>(
);

Image.displayName = "Image";

export { Image };
3 changes: 2 additions & 1 deletion image-resize/app/routes/assets/resize/$.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { createReadStream, statSync } from "fs";
import path from "path";
import { PassThrough } from "stream";

import type { LoaderArgs, Params } from "@remix-run/node";
import type { LoaderArgs } from "@remix-run/node";
import type { Params } from "@remix-run/react";
import type { FitEnum } from "sharp";
import sharp from "sharp";

Expand Down
9 changes: 9 additions & 0 deletions infinite-scrolling/app/utils/backend.server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
interface Item {
id: string;
value: string;
}

declare global {
var __items: Item[];
}

const items = (global.__items =
global.__items ??
Array.from({ length: 50_000 }, (_, i) => ({
Expand Down
6 changes: 3 additions & 3 deletions leaflet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"@remix-run/node": "*",
"@remix-run/react": "*",
"@remix-run/serve": "*",
"leaflet": "^1.8.0",
"react-leaflet": "^4.0.2",
"isbot": "^3.6.5",
"leaflet": "^1.8.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-leaflet": "^4.0.2"
},
"devDependencies": {
"@remix-run/dev": "*",
Expand Down
2 changes: 2 additions & 0 deletions mantine/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const handleBotRequest = (

const { pipe, abort } = renderToPipeableStream(
injectStylesIntoStaticMarkup(
// @ts-expect-error
<RemixServer context={remixContext} url={request.url} />
),
{
Expand Down Expand Up @@ -83,6 +84,7 @@ const handleBrowserRequest = (

const { pipe, abort } = renderToPipeableStream(
injectStylesIntoStaticMarkup(
// @ts-expect-error
<RemixServer context={remixContext} url={request.url} />
),
{
Expand Down
2 changes: 1 addition & 1 deletion nprogress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@remix-run/node": "*",
"@remix-run/react": "*",
"@remix-run/serve": "*",
"nprogress": "^0.2.0",
"isbot": "^3.6.5",
"nprogress": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
5 changes: 5 additions & 0 deletions pm-app/app/routes/dashboard/projects/$projectId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,15 @@ export default function ProjectRoute() {
<Label>Members</Label>

<MemberSearch
// @ts-expect-error
users={selectableUsers}
// @ts-expect-error
selection={
membersFetcher.submission
? optimisticMembersExcludingSelf
: membersExcludingSelf
}
// @ts-expect-error
onSelectionChange={setOptimisticSelectedMembers}
>
<MemberSearchCombobox />
Expand Down Expand Up @@ -387,7 +390,9 @@ export default function ProjectRoute() {
<Label>Members</Label>

<MemberSearch
// @ts-expect-error
users={selectableUsers}
// @ts-expect-error
initialSelection={membersExcludingSelf}
>
<MemberSearchCombobox />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function TodoListRoute() {

const fetchers = useFetchers();
const taskFetcherMap = new Map<string, boolean>();
// @ts-expect-error
const allTodos: Todo[] = todoList.todos;
for (const fetcher of fetchers) {
if (fetcher.type === "actionSubmission") {
Expand Down
Loading

0 comments on commit a43f796

Please sign in to comment.