diff --git a/.github/workflows/example.yaml b/.github/workflows/example.yaml index 663a1c7..1a1a3cd 100644 --- a/.github/workflows/example.yaml +++ b/.github/workflows/example.yaml @@ -74,6 +74,8 @@ jobs: 'reponame=react-example' --data 'description=React app example ⚛️' + --data + 'paths=false' # Create archive to retain file permissions - name: Create archive run: > diff --git a/copier.yaml b/copier.yaml index 7a52940..e8c1d56 100644 --- a/copier.yaml +++ b/copier.yaml @@ -32,6 +32,16 @@ port: help: The port on which the app will listen default: 5173 +paths: + type: bool + help: Whether you can use paths in the URL + default: true + +keyprefix: + type: str + help: The prefix for various keys used in the app (e.g. for storage) + default: "{{ appname | lower | replace('_', '-') }}" + pages: type: str help: What you want to host on GitHub Pages diff --git a/src/.envrc.jinja b/src/.envrc.jinja index 89b0897..585f532 100644 --- a/src/.envrc.jinja +++ b/src/.envrc.jinja @@ -1,7 +1,7 @@ #!/usr/bin/env bash # reload when these files change -watch_file flake.lock ./*.nix package.json package-lock.json Taskfile.dist.yaml {taskfile,Taskfile}.{yaml,yml} +watch_file flake.lock ./*.nix # activate the default development shell in the current shell # --accept-flake-config will accept the nix configuration from the flake without prompting diff --git a/src/.eslintrc.cjs b/src/.eslintrc.cjs index a2a6796..4404c7a 100644 --- a/src/.eslintrc.cjs +++ b/src/.eslintrc.cjs @@ -1,11 +1,11 @@ module.exports = { env: { - // Set ES2022 environment - es2022: true, - // Support browser globals browser: true, + // Set ES2022 environment + es2022: true, + // Support node globals node: true, }, @@ -41,6 +41,12 @@ module.exports = { root: true, rules: { + // Allow anonymous default exports + "import/no-anonymous-default-export": "off", + + // Allow empty block statements + "no-empty": "off", + // Allow empty destructuring patterns "no-empty-pattern": "off", diff --git a/src/Taskfile.dist.yaml.jinja b/src/Taskfile.dist.yaml.jinja index 8347877..abbf7f0 100644 --- a/src/Taskfile.dist.yaml.jinja +++ b/src/Taskfile.dist.yaml.jinja @@ -199,8 +199,8 @@ tasks: desc: Build outputs internal: true sources: - - src/**/* - public/**/* + - src/**/* - flake.lock - "*.nix" - index.html diff --git a/src/src/Router.tsx b/src/src/Router.tsx.jinja similarity index 72% rename from src/src/Router.tsx rename to src/src/Router.tsx.jinja index a7b7a2f..c144bd2 100644 --- a/src/src/Router.tsx +++ b/src/src/Router.tsx.jinja @@ -1,7 +1,7 @@ -import { RouterProvider, createHashRouter } from "react-router-dom"; +import { RouterProvider, {{ 'createBrowserRouter' if pages else 'createHashRouter' }} } from "react-router-dom"; import { ErrorPage, IndexPage, NotFoundPage, Root } from "./pages"; -const router = createHashRouter( +const router = {{ 'createBrowserRouter' if pages else 'createHashRouter' }}( [ { path: "/", diff --git a/src/src/config/constants.ts b/src/src/config/constants.ts deleted file mode 100644 index 2eecae1..0000000 --- a/src/src/config/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const colorSchemeStorageKey = "ra-color-scheme"; -export const defaultColorScheme = "auto"; -export const stateStorageKey = "ra-state"; -export const stateSyncChannel = "ra-state"; diff --git a/src/src/config/constants.ts.jinja b/src/src/config/constants.ts.jinja new file mode 100644 index 0000000..050a30a --- /dev/null +++ b/src/src/config/constants.ts.jinja @@ -0,0 +1,3 @@ +export const colorSchemeStorageKey = "{{ keyprefix }}-color-scheme"; +export const defaultColorScheme = "auto"; +export const stateStorageKey = "{{ keyprefix }}-state"; diff --git a/src/src/contexts/Theme/ThemeProvider.tsx b/src/src/contexts/ThemeProvider/ThemeProvider.tsx similarity index 100% rename from src/src/contexts/Theme/ThemeProvider.tsx rename to src/src/contexts/ThemeProvider/ThemeProvider.tsx diff --git a/src/src/contexts/Theme/ThemeProvider.types.ts b/src/src/contexts/ThemeProvider/ThemeProvider.types.ts similarity index 100% rename from src/src/contexts/Theme/ThemeProvider.types.ts rename to src/src/contexts/ThemeProvider/ThemeProvider.types.ts diff --git a/src/src/contexts/Theme/index.ts b/src/src/contexts/ThemeProvider/index.ts similarity index 100% rename from src/src/contexts/Theme/index.ts rename to src/src/contexts/ThemeProvider/index.ts diff --git a/src/src/contexts/index.ts b/src/src/contexts/index.ts index d681d61..d380ec3 100644 --- a/src/src/contexts/index.ts +++ b/src/src/contexts/index.ts @@ -1 +1 @@ -export * from "./Theme"; +export * from "./ThemeProvider"; diff --git a/src/src/hooks/index.ts b/src/src/hooks/index.ts index 262a4a3..aa35c31 100644 --- a/src/src/hooks/index.ts +++ b/src/src/hooks/index.ts @@ -1 +1 @@ -export * from "./Toasts"; +export * from "./useToasts"; diff --git a/src/src/hooks/Toasts/index.ts b/src/src/hooks/useToasts/index.ts similarity index 100% rename from src/src/hooks/Toasts/index.ts rename to src/src/hooks/useToasts/index.ts diff --git a/src/src/hooks/Toasts/useToasts.tsx b/src/src/hooks/useToasts/useToasts.tsx similarity index 100% rename from src/src/hooks/Toasts/useToasts.tsx rename to src/src/hooks/useToasts/useToasts.tsx diff --git a/src/src/hooks/Toasts/useToasts.types.ts b/src/src/hooks/useToasts/useToasts.types.ts similarity index 100% rename from src/src/hooks/Toasts/useToasts.types.ts rename to src/src/hooks/useToasts/useToasts.types.ts diff --git a/src/src/main.tsx b/src/src/main.tsx index e2d4986..85e34fb 100644 --- a/src/src/main.tsx +++ b/src/src/main.tsx @@ -1,9 +1,9 @@ -import React from "react"; -import ReactDOM from "react-dom/client"; -import { App } from "./App.tsx"; +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import { App } from "./App"; -ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - +createRoot(document.getElementById("root") as HTMLElement).render( + - , + , ); diff --git a/src/src/store/index.ts b/src/src/store/index.ts index 52f2c5d..d9d332b 100644 --- a/src/src/store/index.ts +++ b/src/src/store/index.ts @@ -1,2 +1,2 @@ export * from "./store"; -export * from "./store.types"; +export * from "./types"; diff --git a/src/src/store/store.ts b/src/src/store/store.ts index 467c3b4..be2c078 100644 --- a/src/src/store/store.ts +++ b/src/src/store/store.ts @@ -3,7 +3,7 @@ import { StateCreator, create } from "zustand"; import { PersistOptions, persist } from "zustand/middleware"; import { immer } from "zustand/middleware/immer"; import { stateStorageKey } from "../config/constants"; -import { Store } from "./store.types"; +import { Store } from "./types"; type Initializer = StateCreator; diff --git a/src/src/store/store.types.ts b/src/src/store/types.ts similarity index 100% rename from src/src/store/store.types.ts rename to src/src/store/types.ts diff --git a/src/tsconfig.json b/src/tsconfig.json index 0a97997..2002fe7 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -7,11 +7,12 @@ "esModuleInterop": true, "incremental": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "lib": ["DOM", "DOM.Iterable", "ESNext"], "module": "esnext", "moduleResolution": "bundler", "noEmit": true, + "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "preserveWatchOutput": true, "removeComments": true, diff --git a/src/vite.config.mts.jinja b/src/vite.config.mts.jinja index efe257f..973aefd 100644 --- a/src/vite.config.mts.jinja +++ b/src/vite.config.mts.jinja @@ -1,6 +1,12 @@ import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; +const host = process.env.{{ envprefix }}__SERVER__HOST || "0.0.0.0"; +const port = + process.env.{{ envprefix }}__SERVER__PORT === undefined + ? {{ port }} + : parseInt(process.env.{{ envprefix }}__SERVER__PORT, 10); + // https://vitejs.dev/config/ export default defineConfig({ build: { @@ -8,10 +14,7 @@ export default defineConfig({ }, plugins: [react()], server: { - host: process.env.{{ envprefix }}__SERVER__HOST || "0.0.0.0", - port: - process.env.{{ envprefix }}__SERVER__PORT === undefined - ? {{ port }} - : parseInt(process.env.{{ envprefix }}__SERVER__PORT, 10), + host: host, + port: port, }, }); diff --git a/tests/test_docs.py b/tests/test_docs.py index 93d41f8..1f870fb 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -19,6 +19,8 @@ def data() -> dict[str, str]: "repourl": "https://github.com/foo/app-foo", "envprefix": "FOO", "port": "5173", + "paths": "true", + "keyprefix": "foo", "pages": "docs", "pagesurl": "https://foo.github.io/app-foo", "releases": "false", diff --git a/tests/test_lint.py b/tests/test_lint.py index fcdc6c6..c2113ad 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -19,6 +19,8 @@ def data() -> dict[str, str]: "repourl": "https://github.com/foo/app-foo", "envprefix": "FOO", "port": "5173", + "paths": "true", + "keyprefix": "foo", "pages": "app", "pagesurl": "https://foo.github.io/app-foo", "releases": "true",