Skip to content

Commit

Permalink
Pnpm updates cleanups etc (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfr authored Nov 22, 2024
1 parent d688b66 commit 1fe53a0
Show file tree
Hide file tree
Showing 16 changed files with 979 additions and 892 deletions.
2 changes: 1 addition & 1 deletion .env.sample → .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Add your env variables here
DEPLOYMENT_ENV="staging"
APP_DEPLOYMENT_ENV="staging"
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Add your env variables here
DEPLOYMENT_ENV="staging"
APP_DEPLOYMENT_ENV="staging"
53 changes: 19 additions & 34 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,37 @@ jobs:
name: ⬣ Biome lint
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
- name: Run Biome
run: biome ci .
- uses: actions/checkout@v4
- uses: biomejs/setup-biome@v2
- run: biome ci . --reporter=github

typecheck:
needs: lint
name: 🔎 Type check
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: 🔎 Type check
run: npm run typecheck
node-version-file: "package.json"
cache: "pnpm"
- run: pnpm install --prefer-offline --frozen-lockfile
- run: pnpm run typecheck

vitest:
needs: typecheck
name: ⚡ Unit Tests
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
useLockFile: false
- name: Install dotenv cli
run: npm install -g dotenv-cli
- name: ⚡ Run vitest
run: npm run test:cov
node-version-file: "package.json"
cache: "pnpm"
- run: pnpm install --prefer-offline --frozen-lockfile
- run: pnpm run test:cov
- name: "Report Coverage"
# Only works if you set `reportOnFailure: true` in your vite config as specified above
if: always()
Expand Down
95 changes: 91 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,94 @@
node_modules
/.cache
/build
.env
public/build
build
dist
out
coverage
.history
.react-router
.react-router

# Other Coverage tools
*.lcov

# macOS
.DS_*

# Cache Directories and files
.cache
.yarn*
.env*
!.env.example
.swp*
.turbo
.npm
.stylelintcache
*.tsbuildinfo
.node_repl_history

# Lock files from other package managers
package-lock.json
yarn.lock

# General tempory files and directories
t?mp
.t?mp
*.t?mp

# Docusaurus cache and generated files
.docusaurus

# Output of 'npm pack'
*.tgz
*.tar
*.tar.gz
*.tar.bz2
*.tbz
*.zip

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
vite.config.ts.*

# Playwright various test reports
test-results
playwright-report
blob-report


# Editors
.idea/workspace.xml
.idea/usage.statistics.xml
.idea/shelf


# Make it harder to accidentally commit files in the root
/*.json
/*.yaml
/*.yml
/*.toml
/*.ts
/*.tsx
/*.js
/*.jsx
/*.sh

# Dont commit sqlite database files
*.db
*.sqlite
*.sqlite3
*.db-journal
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enable-pre-post-scripts=true
side-effects-cache=false
save-exact=true
audit=false
fund=false
progress=false
3 changes: 2 additions & 1 deletion app/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from "zod"

const envSchema = z.object({
NODE_ENV: z.enum(["development", "production", "test"]),
DEPLOYMENT_ENV: z.enum(["staging", "production"]),
APP_DEPLOYMENT_ENV: z.enum(["staging", "production"]),
})

type APP_ENV = z.infer<typeof envSchema>
Expand All @@ -13,6 +13,7 @@ let env: APP_ENV
* @returns Initialized env vars
*/
export const initEnv = () => {
// biome-ignore lint/nursery/noProcessEnv: This should be the only place to use process.env directly
const envData = envSchema.safeParse(process.env)

if (!envData.success) {
Expand Down
6 changes: 4 additions & 2 deletions app/library/icon/icons/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// This file is generated by icon spritesheet generator

export const iconNames = ["ShoppingCart"] as const
export const iconNames = [
"ShoppingCart",
] as const

export type IconName = (typeof iconNames)[number]
export type IconName = typeof iconNames[number]
5 changes: 3 additions & 2 deletions app/routes/resource.locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { z } from "zod"
import { resources } from "~/localization/resource"
import type { Route } from "./+types/resource.locales"

export async function loader({ request }: Route.LoaderArgs) {
export async function loader({ request, context }: Route.LoaderArgs) {
const { env } = context
const url = new URL(request.url)

const lng = z
Expand All @@ -24,7 +25,7 @@ export async function loader({ request }: Route.LoaderArgs) {
const headers = new Headers()

// On production, we want to add cache headers to the response
if (process.env.APP_DEPLOYMENT_ENV === "production") {
if (env.APP_DEPLOYMENT_ENV === "production") {
headers.set(
"Cache-Control",
cacheHeader({
Expand Down
5 changes: 3 additions & 2 deletions app/routes/robots[.]txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { generateRobotsTxt } from "@forge42/seo-tools/robots"
import { createDomain } from "~/utils/http"
import type { Route } from "./+types/robots[.]txt"

export async function loader({ request }: Route.LoaderArgs) {
const isProductionDeployment = process.env.DEPLOYMENT_ENV === "production"
export async function loader({ request, context }: Route.LoaderArgs) {
const { env } = context
const isProductionDeployment = env.APP_DEPLOYMENT_ENV === "production"
const domain = createDomain(request)
const robotsTxt = generateRobotsTxt([
{
Expand Down
9 changes: 5 additions & 4 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignore": ["app/library/icon/**/*"]
},
"vcs": {
"enabled": true,
"clientKind": "git",
Expand All @@ -8,9 +11,6 @@
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"lineEnding": "lf",
"lineWidth": 120
},
"organizeImports": {
Expand Down Expand Up @@ -47,7 +47,8 @@
"recommended": true
},
"nursery": {
"recommended": true
"recommended": true,
"noProcessEnv": "error"
}
}
},
Expand Down
5 changes: 2 additions & 3 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": ["scripts/*.{ts,js}", "app/routes.ts"],
"entry": ["scripts/*.{ts,js}", "app/routes.ts","vite.config.ts"],
"remix": true,
"project": ["**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "vite.config.ts"],
"ignore": ["app/library/icon/icons/types.ts"],
"ignoreDependencies": ["virtual:react-router", "lefthook"]
"ignore": ["app/library/icon/icons/types.ts"]
}
8 changes: 4 additions & 4 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ pre-commit:
parallel: true
commands:
check:
run: npm run check -- --staged --fix --no-errors-on-unmatched
run: pnpm run check --fix --no-errors-on-unmatched
stage_fixed: true
typecheck:
run: npm run typecheck
run: pnpm run typecheck
test:
run: npm run test
run: pnpm run test
unused-code:
run: npm run check:unused
run: pnpm run check:unused
Loading

0 comments on commit 1fe53a0

Please sign in to comment.