Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up code #32

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down
10 changes: 10 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/.envrc.jinja
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -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,
},
Expand Down Expand Up @@ -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",

Expand Down
2 changes: 1 addition & 1 deletion src/Taskfile.dist.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ tasks:
desc: Build outputs
internal: true
sources:
- src/**/*
- public/**/*
- src/**/*
- flake.lock
- "*.nix"
- index.html
Expand Down
4 changes: 2 additions & 2 deletions src/src/Router.tsx → src/src/Router.tsx.jinja
Original file line number Diff line number Diff line change
@@ -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: "/",
Expand Down
4 changes: 0 additions & 4 deletions src/src/config/constants.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/src/config/constants.ts.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const colorSchemeStorageKey = "{{ keyprefix }}-color-scheme";
export const defaultColorScheme = "auto";
export const stateStorageKey = "{{ keyprefix }}-state";
2 changes: 1 addition & 1 deletion src/src/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./Theme";
export * from "./ThemeProvider";
2 changes: 1 addition & 1 deletion src/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./Toasts";
export * from "./useToasts";
File renamed without changes.
12 changes: 6 additions & 6 deletions src/src/main.tsx
Original file line number Diff line number Diff line change
@@ -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(
<React.StrictMode>
createRoot(document.getElementById("root") as HTMLElement).render(
<StrictMode>
<App />
</React.StrictMode>,
</StrictMode>,
);
2 changes: 1 addition & 1 deletion src/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./store";
export * from "./store.types";
export * from "./types";
2 changes: 1 addition & 1 deletion src/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Store, [["zustand/immer", never]]>;

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions src/vite.config.mts.jinja
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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: {
outDir: "build/",
},
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,
},
});
2 changes: 2 additions & 0 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down