Skip to content

Commit 1d9f865

Browse files
authored
Cleaned up code (#32)
1 parent a965650 commit 1d9f865

24 files changed

+52
-27
lines changed

.github/workflows/example.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
'reponame=react-example'
7575
--data
7676
'description=React app example ⚛️'
77+
--data
78+
'paths=false'
7779
# Create archive to retain file permissions
7880
- name: Create archive
7981
run: >

copier.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ port:
3232
help: The port on which the app will listen
3333
default: 5173
3434

35+
paths:
36+
type: bool
37+
help: Whether you can use paths in the URL
38+
default: true
39+
40+
keyprefix:
41+
type: str
42+
help: The prefix for various keys used in the app (e.g. for storage)
43+
default: "{{ appname | lower | replace('_', '-') }}"
44+
3545
pages:
3646
type: str
3747
help: What you want to host on GitHub Pages

src/.envrc.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# reload when these files change
4-
watch_file flake.lock ./*.nix package.json package-lock.json Taskfile.dist.yaml {taskfile,Taskfile}.{yaml,yml}
4+
watch_file flake.lock ./*.nix
55

66
# activate the default development shell in the current shell
77
# --accept-flake-config will accept the nix configuration from the flake without prompting

src/.eslintrc.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22
env: {
3-
// Set ES2022 environment
4-
es2022: true,
5-
63
// Support browser globals
74
browser: true,
85

6+
// Set ES2022 environment
7+
es2022: true,
8+
99
// Support node globals
1010
node: true,
1111
},
@@ -41,6 +41,12 @@ module.exports = {
4141
root: true,
4242

4343
rules: {
44+
// Allow anonymous default exports
45+
"import/no-anonymous-default-export": "off",
46+
47+
// Allow empty block statements
48+
"no-empty": "off",
49+
4450
// Allow empty destructuring patterns
4551
"no-empty-pattern": "off",
4652

src/Taskfile.dist.yaml.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ tasks:
199199
desc: Build outputs
200200
internal: true
201201
sources:
202-
- src/**/*
203202
- public/**/*
203+
- src/**/*
204204
- flake.lock
205205
- "*.nix"
206206
- index.html

src/src/Router.tsx renamed to src/src/Router.tsx.jinja

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { RouterProvider, createHashRouter } from "react-router-dom";
1+
import { RouterProvider, {{ 'createBrowserRouter' if pages else 'createHashRouter' }} } from "react-router-dom";
22
import { ErrorPage, IndexPage, NotFoundPage, Root } from "./pages";
33

4-
const router = createHashRouter(
4+
const router = {{ 'createBrowserRouter' if pages else 'createHashRouter' }}(
55
[
66
{
77
path: "/",

src/src/config/constants.ts

-4
This file was deleted.

src/src/config/constants.ts.jinja

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const colorSchemeStorageKey = "{{ keyprefix }}-color-scheme";
2+
export const defaultColorScheme = "auto";
3+
export const stateStorageKey = "{{ keyprefix }}-state";

src/src/contexts/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./Theme";
1+
export * from "./ThemeProvider";

src/src/hooks/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./Toasts";
1+
export * from "./useToasts";
File renamed without changes.

src/src/main.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom/client";
3-
import { App } from "./App.tsx";
1+
import { StrictMode } from "react";
2+
import { createRoot } from "react-dom/client";
3+
import { App } from "./App";
44

5-
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
6-
<React.StrictMode>
5+
createRoot(document.getElementById("root") as HTMLElement).render(
6+
<StrictMode>
77
<App />
8-
</React.StrictMode>,
8+
</StrictMode>,
99
);

src/src/store/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from "./store";
2-
export * from "./store.types";
2+
export * from "./types";

src/src/store/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StateCreator, create } from "zustand";
33
import { PersistOptions, persist } from "zustand/middleware";
44
import { immer } from "zustand/middleware/immer";
55
import { stateStorageKey } from "../config/constants";
6-
import { Store } from "./store.types";
6+
import { Store } from "./types";
77

88
type Initializer = StateCreator<Store, [["zustand/immer", never]]>;
99

File renamed without changes.

src/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"esModuleInterop": true,
88
"incremental": true,
99
"isolatedModules": true,
10-
"jsx": "react-jsx",
10+
"jsx": "preserve",
1111
"lib": ["DOM", "DOM.Iterable", "ESNext"],
1212
"module": "esnext",
1313
"moduleResolution": "bundler",
1414
"noEmit": true,
15+
"noUncheckedIndexedAccess": true,
1516
"noUnusedLocals": true,
1617
"preserveWatchOutput": true,
1718
"removeComments": true,

src/vite.config.mts.jinja

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import react from "@vitejs/plugin-react";
22
import { defineConfig } from "vite";
33

4+
const host = process.env.{{ envprefix }}__SERVER__HOST || "0.0.0.0";
5+
const port =
6+
process.env.{{ envprefix }}__SERVER__PORT === undefined
7+
? {{ port }}
8+
: parseInt(process.env.{{ envprefix }}__SERVER__PORT, 10);
9+
410
// https://vitejs.dev/config/
511
export default defineConfig({
612
build: {
713
outDir: "build/",
814
},
915
plugins: [react()],
1016
server: {
11-
host: process.env.{{ envprefix }}__SERVER__HOST || "0.0.0.0",
12-
port:
13-
process.env.{{ envprefix }}__SERVER__PORT === undefined
14-
? {{ port }}
15-
: parseInt(process.env.{{ envprefix }}__SERVER__PORT, 10),
17+
host: host,
18+
port: port,
1619
},
1720
});

tests/test_docs.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def data() -> dict[str, str]:
1919
"repourl": "https://github.com/foo/app-foo",
2020
"envprefix": "FOO",
2121
"port": "5173",
22+
"paths": "true",
23+
"keyprefix": "foo",
2224
"pages": "docs",
2325
"pagesurl": "https://foo.github.io/app-foo",
2426
"releases": "false",

tests/test_lint.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def data() -> dict[str, str]:
1919
"repourl": "https://github.com/foo/app-foo",
2020
"envprefix": "FOO",
2121
"port": "5173",
22+
"paths": "true",
23+
"keyprefix": "foo",
2224
"pages": "app",
2325
"pagesurl": "https://foo.github.io/app-foo",
2426
"releases": "true",

0 commit comments

Comments
 (0)