Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Migrate to remix v2 route convention (#1367)

Bogdan Chadkin0095f47fbcab
diff --git a/apps/builder/app/routes/index.tsx b/apps/builder/app/routes/_index.tsx
similarity index 100%
rename from apps/builder/app/routes/index.tsx
rename to apps/builder/app/routes/_index.tsx
diff --git a/apps/builder/app/routes/auth/dev.tsx b/apps/builder/app/routes/auth.dev.tsx
similarity index 100%
rename from apps/builder/app/routes/auth/dev.tsx
rename to apps/builder/app/routes/auth.dev.tsx
diff --git a/apps/builder/app/routes/auth/github/callback.tsx b/apps/builder/app/routes/auth.github.callback.tsx
similarity index 100%
rename from apps/builder/app/routes/auth/github/callback.tsx
rename to apps/builder/app/routes/auth.github.callback.tsx
diff --git a/apps/builder/app/routes/auth/github.tsx b/apps/builder/app/routes/auth.github.tsx
similarity index 100%
rename from apps/builder/app/routes/auth/github.tsx
rename to apps/builder/app/routes/auth.github.tsx
diff --git a/apps/builder/app/routes/auth/google/callback.tsx b/apps/builder/app/routes/auth.google.callback.tsx
similarity index 100%
rename from apps/builder/app/routes/auth/google/callback.tsx
rename to apps/builder/app/routes/auth.google.callback.tsx
diff --git a/apps/builder/app/routes/auth/google.tsx b/apps/builder/app/routes/auth.google.tsx
similarity index 100%
rename from apps/builder/app/routes/auth/google.tsx
rename to apps/builder/app/routes/auth.google.tsx
diff --git a/apps/builder/app/routes/builder/$projectId.tsx b/apps/builder/app/routes/builder.$projectId.tsx
similarity index 100%
rename from apps/builder/app/routes/builder/$projectId.tsx
rename to apps/builder/app/routes/builder.$projectId.tsx
index 2c6a10800b..642ddb8b7f 100644
--- a/apps/builder/app/routes/builder/$projectId.tsx
+++ b/apps/builder/app/routes/builder.$projectId.tsx
@@ -4,12 +4,12 @@ import type { LoaderArgs } from "@remix-run/node";
import { loadBuildByProjectId } from "@webstudio-is/project-build/server";
import { db } from "@webstudio-is/project/server";
import { authorizeProject } from "@webstudio-is/trpc-interface/server";
+import { loadByProject } from "@webstudio-is/asset-uploader/server";
import { createContext } from "~/shared/context.server";
import { ErrorMessage } from "~/shared/error";
import { sentryException } from "~/shared/sentry";
import { getBuildOrigin } from "~/shared/router-utils";
import { type BuilderProps, Builder, links } from "~/builder";
-import { loadByProject } from "@webstudio-is/asset-uploader/server";
export { links };
diff --git a/apps/builder/app/routes/dashboard/index.tsx b/apps/builder/app/routes/dashboard._index.tsx
similarity index 99%
rename from apps/builder/app/routes/dashboard/index.tsx
rename to apps/builder/app/routes/dashboard._index.tsx
index 4411dae675..b47e4eb487 100644
--- a/apps/builder/app/routes/dashboard/index.tsx
+++ b/apps/builder/app/routes/dashboard._index.tsx
@@ -1,14 +1,15 @@
+import type { ComponentProps } from "react";
import { useLoaderData, useRouteError } from "@remix-run/react";
import type { LoaderArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
+import { dashboardProjectRouter } from "@webstudio-is/dashboard/server";
import { Dashboard } from "~/dashboard";
import { findAuthenticatedUser } from "~/services/auth.server";
import { loginPath } from "~/shared/router-utils";
-import type { ComponentProps } from "react";
import { sentryException } from "~/shared/sentry";
import { ErrorMessage } from "~/shared/error";
-import { dashboardProjectRouter } from "@webstudio-is/dashboard/server";
import { createContext } from "~/shared/context.server";
+
export { links } from "~/dashboard";
export const loader = async ({
diff --git a/apps/builder/app/routes/dashboard/projects.$method.ts b/apps/builder/app/routes/dashboard.projects.$method.ts
similarity index 100%
rename from apps/builder/app/routes/dashboard/projects.$method.ts
rename to apps/builder/app/routes/dashboard.projects.$method.ts
diff --git a/apps/builder/app/routes/login/index.tsx b/apps/builder/app/routes/login._index.tsx
similarity index 100%
rename from apps/builder/app/routes/login/index.tsx
rename to apps/builder/app/routes/login._index.tsx
index e5578062a1..a8de799daf 100644
--- a/apps/builder/app/routes/login/index.tsx
+++ b/apps/builder/app/routes/login._index.tsx
@@ -1,17 +1,17 @@
+import type { ComponentProps } from "react";
import {
type LoaderArgs,
type TypedResponse,
redirect,
json,
} from "@remix-run/node";
+import { useLoaderData } from "@remix-run/react";
import { findAuthenticatedUser } from "~/services/auth.server";
import env from "~/env/env.server";
import { Login, links } from "~/auth";
import { useLoginErrorMessage } from "~/shared/session";
import { dashboardPath } from "~/shared/router-utils";
import { returnToCookie } from "~/services/cookie.server";
-import { useLoaderData } from "@remix-run/react";
-import type { ComponentProps } from "react";
export { links };
diff --git a/apps/builder/app/routes/rest/assets.$projectId.tsx b/apps/builder/app/routes/rest.assets.$projectId.tsx
similarity index 100%
rename from apps/builder/app/routes/rest/assets.$projectId.tsx
rename to apps/builder/app/routes/rest.assets.$projectId.tsx
index 02916ab909..5a1475258b 100644
--- a/apps/builder/app/routes/rest/assets.$projectId.tsx
+++ b/apps/builder/app/routes/rest.assets.$projectId.tsx
@@ -1,3 +1,4 @@
+import { useEffect } from "react";
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import { useActionData } from "@remix-run/react";
import type { Asset } from "@webstudio-is/asset-uploader";
@@ -6,7 +7,6 @@ import {
loadByProject,
} from "@webstudio-is/asset-uploader/server";
import { toast } from "@webstudio-is/design-system";
-import { useEffect } from "react";
import type { ActionData } from "~/builder/shared/assets";
import { sentryException } from "~/shared/sentry";
import { createContext } from "~/shared/context.server";
diff --git a/apps/builder/app/routes/rest/authorization-token.$method.ts b/apps/builder/app/routes/rest.authorization-token.$method.ts
similarity index 100%
rename from apps/builder/app/routes/rest/authorization-token.$method.ts
rename to apps/builder/app/routes/rest.authorization-token.$method.ts
diff --git a/apps/builder/app/routes/rest/patch.ts b/apps/builder/app/routes/rest.patch.ts
similarity index 100%
rename from apps/builder/app/routes/rest/patch.ts
rename to apps/builder/app/routes/rest.patch.ts
diff --git a/apps/builder/app/routes/rest/project.$projectId.tsx b/apps/builder/app/routes/rest.project.$projectId.tsx
similarity index 100%
rename from apps/builder/app/routes/rest/project.$projectId.tsx
rename to apps/builder/app/routes/rest.project.$projectId.tsx
diff --git a/apps/builder/app/routes/rest/project/clone.$domain.ts b/apps/builder/app/routes/rest.project.clone.$domain.ts
similarity index 100%
rename from apps/builder/app/routes/rest/project/clone.$domain.ts
rename to apps/builder/app/routes/rest.project.clone.$domain.ts
index dc38bb7212..5c6b50e1df 100644
--- a/apps/builder/app/routes/rest/project/clone.$domain.ts
+++ b/apps/builder/app/routes/rest.project.clone.$domain.ts
@@ -1,9 +1,9 @@
import { redirect, type LoaderArgs } from "@remix-run/node";
import { db as projectDb } from "@webstudio-is/project/server";
import type { Project } from "@webstudio-is/project";
+import type { AppContext } from "@webstudio-is/trpc-interface/server";
import { findAuthenticatedUser } from "~/services/auth.server";
import { builderPath, loginPath } from "~/shared/router-utils";
-import type { AppContext } from "@webstudio-is/trpc-interface/server";
import { createContext } from "~/shared/context.server";
const ensureProject = async (
diff --git a/apps/builder/app/routes/rest/publish.ts b/apps/builder/app/routes/rest.publish.ts
similarity index 100%
rename from apps/builder/app/routes/rest/publish.ts
rename to apps/builder/app/routes/rest.publish.ts
diff --git a/apps/builder/app/routes/rest/theme.$setting.ts b/apps/builder/app/routes/rest.theme.$setting.ts
similarity index 100%
rename from apps/builder/app/routes/rest/theme.$setting.ts
rename to apps/builder/app/routes/rest.theme.$setting.ts
diff --git a/apps/builder/app/routes/s/css.ts b/apps/builder/app/routes/s.css.ts
similarity index 100%
rename from apps/builder/app/routes/s/css.ts
rename to apps/builder/app/routes/s.css.ts
index f20353066a..147fb911ee 100644
--- a/apps/builder/app/routes/s/css.ts
+++ b/apps/builder/app/routes/s.css.ts
@@ -1,12 +1,12 @@
import { type ActionArgs, json } from "@remix-run/node";
import { generateCssText } from "@webstudio-is/react-sdk";
import { db } from "@webstudio-is/project/server";
+import { createCssEngine } from "@webstudio-is/css-engine";
import env from "~/env/env.public.server";
import { getBuildParams } from "~/shared/router-utils";
import { sentryException } from "~/shared/sentry";
import { createContext } from "~/shared/context.server";
import { loadCanvasData } from "~/shared/db";
-import { createCssEngine } from "@webstudio-is/css-engine";
import { helperStyles } from "~/canvas/shared/styles";
export const loader = async ({ request }: ActionArgs) => {
diff --git a/apps/builder/remix.config.js b/apps/builder/remix.config.js
index 9b0a0a1017..c256712498 100644
--- a/apps/builder/remix.config.js
+++ b/apps/builder/remix.config.js
@@ -35,5 +35,6 @@ module.exports = {
future: {
v2_errorBoundary: true,
+ v2_routeConvention: true,
},
};
diff --git a/packages/eslint-config-custom/index.js b/packages/eslint-config-custom/index.js
index 7ef259e684..8c27b88e94 100644
--- a/packages/eslint-config-custom/index.js
+++ b/packages/eslint-config-custom/index.js
@@ -32,14 +32,7 @@ module.exports = {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"func-style": ["error", "expression", { allowArrowFunctions: true }],
- "unicorn/filename-case": [
- "error",
- {
- case: "kebabCase",
- // Remix routes need to contain $variable in the file name
- ignore: ["\\$"],
- },
- ],
+ "unicorn/filename-case": ["error", { case: "kebabCase" }],
curly: 2,
eqeqeq: ["error", "always", { null: "ignore" }],
camelcase: [2, { properties: "never" }],
@@ -57,4 +50,12 @@ module.exports = {
},
],
},
+ overrides: [
+ {
+ files: ["**/app/routes/**/*.{ts,tsx}"],
+ rules: {
+ "unicorn/filename-case": "off",
+ },
+ },
+ ],
};