mirror of
https://github.com/dcarrillo/atalaya.git
synced 2026-07-20 23:54:44 +00:00
feat: migrate from npm to pnpm (#24)
* feat: migrate from npm to pnpm * Update README.md
This commit is contained in:
@@ -33,3 +33,4 @@ updates:
|
||||
ignore:
|
||||
- dependency-name: '*'
|
||||
update-types: ['version-update:semver-major']
|
||||
|
||||
|
||||
@@ -18,26 +18,31 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v6
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 11
|
||||
cache: true
|
||||
cache_dependency_path: pnpm-lock.yaml
|
||||
|
||||
- name: Set up Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run linters and type checking
|
||||
run: |
|
||||
npm run check
|
||||
npm run check:pages
|
||||
pnpm check
|
||||
pnpm check:pages
|
||||
|
||||
- name: Build status page
|
||||
run: npm run build:pages
|
||||
run: pnpm build:pages
|
||||
|
||||
- name: Run worker tests
|
||||
run: npm run test
|
||||
run: pnpm test
|
||||
|
||||
- name: Run status-page tests
|
||||
run: npm run test:pages
|
||||
run: pnpm test:pages
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Architecture
|
||||
|
||||
npm workspace: Cloudflare Worker (`src/`) + Astro 6 SSR app (`status-page/`).
|
||||
pnpm workspace: Cloudflare Worker (`src/`) + Astro 6 SSR app (`status-page/`).
|
||||
|
||||
- **Worker entrypoint**: `src/index.ts` — `fetch` + `scheduled` handlers, `RegionalChecker` Durable Object
|
||||
- **Astro entrypoint**: `status-page/src/pages/index.astro` — single-page SSR app
|
||||
@@ -16,36 +16,36 @@ npm workspace: Cloudflare Worker (`src/`) + Astro 6 SSR app (`status-page/`).
|
||||
### Root (Worker)
|
||||
|
||||
```bash
|
||||
npm run dev # wrangler dev
|
||||
npm run test # vitest (20 test files)
|
||||
npm run typecheck # tsc --noEmit
|
||||
npm run check # typecheck + lint + format:check
|
||||
npm run check:fix # auto-fix lint + format
|
||||
npm run deploy # build:pages + wrangler deploy
|
||||
npm run lint:strict # oxlint --deny warnings + eslint --max-warnings=0
|
||||
pnpm dev # wrangler dev
|
||||
pnpm test # vitest (20 test files)
|
||||
pnpm typecheck # tsc --noEmit
|
||||
pnpm check # typecheck + lint + format:check
|
||||
pnpm check:fix # auto-fix lint + format
|
||||
pnpm deploy # build:pages + wrangler deploy
|
||||
pnpm lint:strict # oxlint --deny warnings + eslint --max-warnings=0
|
||||
vitest run src/path/to.test.ts # single test (no npx needed)
|
||||
```
|
||||
|
||||
### Pages workspace
|
||||
|
||||
```bash
|
||||
npm run dev:pages # astro dev
|
||||
npm run build:pages # astro build → status-page/dist/
|
||||
npm run test:pages # vitest (3 test files)
|
||||
npm run check:pages # astro check + tsc --noEmit + eslint
|
||||
npm run lint:pages # eslint (astro plugin)
|
||||
pnpm dev:pages # astro dev
|
||||
pnpm build:pages # astro build → status-page/dist/
|
||||
pnpm test:pages # vitest (3 test files)
|
||||
pnpm check:pages # astro check + tsc --noEmit + eslint
|
||||
pnpm lint:pages # eslint (astro plugin)
|
||||
```
|
||||
|
||||
### Verification order
|
||||
|
||||
Before commit: `npm run check && npm run test && npm run build:pages && npm run check:pages`
|
||||
Before commit: `pnpm check && pnpm test && pnpm build:pages && pnpm check:pages`
|
||||
|
||||
## Gotchas
|
||||
|
||||
- **`.js` extensions in imports**: All worker imports use `.js` extensions (`import { foo } from './bar.js'`). Required for ESM resolution with `moduleResolution: "bundler"`.
|
||||
- **D1 requires bind parameters**: Use `WHERE 1=?` with `.bind(1)` for queries that would otherwise have no parameters.
|
||||
- **Database naming**: D1 columns are `snake_case`, TypeScript properties are `camelCase`. Map at query boundary.
|
||||
- **`--legacy-peer-deps`**: Needed when installing Pages dependencies (`@astrojs/check` declares `typescript@^5` but project uses TypeScript 6).
|
||||
- **`--legacy-peer-deps`**: Not needed with pnpm. If peer issues arise, configure `peerDependencyRules` in `pnpm-workspace.yaml`.
|
||||
- **Pages `dist/` and `.astro/`**: Build artifacts, gitignored.
|
||||
- **Astro SSR build artifact**: Worker dynamically imports `../status-page/dist/server/index.mjs` at runtime — uses `@ts-expect-error`.
|
||||
- **Astro 6 + @astrojs/cloudflare v13 workarounds**: `status-page/astro.config.mjs` includes `fixBuildRollupInput` plugin and `prerenderEnvironment: 'node'`.
|
||||
|
||||
@@ -69,7 +69,7 @@ __ ,--~' ~~----____
|
||||
|
||||
## Architecture
|
||||
|
||||
The project is an npm workspace with a single Cloudflare Worker that handles everything:
|
||||
The project is a pnpm workspace with a single Cloudflare Worker that handles everything:
|
||||
|
||||
```text
|
||||
atalaya/
|
||||
@@ -91,7 +91,7 @@ atalaya/
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
pnpm install
|
||||
```
|
||||
|
||||
2. Create the configuration file (`wrangler.toml`):
|
||||
@@ -122,7 +122,7 @@ atalaya/
|
||||
6. Deploy:
|
||||
|
||||
```bash
|
||||
npm run deploy
|
||||
pnpm deploy
|
||||
```
|
||||
|
||||
This builds the Astro site and deploys the Worker with static assets in a single step.
|
||||
@@ -379,7 +379,7 @@ An hourly cron job aggregates raw data and cleans up old records automatically.
|
||||
wrangler dev --test-scheduled
|
||||
|
||||
# Run status page locally
|
||||
npm run dev:pages
|
||||
pnpm dev:pages
|
||||
|
||||
# Trigger cron manually
|
||||
curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"
|
||||
@@ -389,17 +389,17 @@ curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"
|
||||
|
||||
```bash
|
||||
# First build the status page
|
||||
npm run build:pages
|
||||
pnpm build:pages
|
||||
|
||||
# Worker tests
|
||||
npm run test
|
||||
pnpm test
|
||||
|
||||
# Status page unit tests
|
||||
npm run test:pages
|
||||
pnpm test:pages
|
||||
|
||||
# Type checking and linting
|
||||
npm run check # worker (typecheck + lint + format)
|
||||
npm run check:pages # pages (astro check + tsc + lint)
|
||||
pnpm check # worker (typecheck + lint + format)
|
||||
pnpm check:pages # pages (astro check + tsc + lint)
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
Generated
-9830
File diff suppressed because it is too large
Load Diff
+10
-12
@@ -3,12 +3,9 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
"status-page"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "wrangler dev",
|
||||
"deploy": "npm run build --workspace=status-page && wrangler deploy",
|
||||
"deploy": "pnpm --filter=atalaya-prod-status-page run build && wrangler deploy",
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "oxlint && eslint",
|
||||
@@ -16,14 +13,14 @@
|
||||
"lint:strict": "oxlint --deny warnings && eslint --max-warnings=0",
|
||||
"format": "prettier --write \"src/**/*.ts\"",
|
||||
"format:check": "prettier --check \"src/**/*.ts\"",
|
||||
"check": "npm run typecheck && npm run lint && npm run format:check",
|
||||
"check:fix": "npm run lint:fix && npm run format",
|
||||
"dev:pages": "npm run dev --workspace=status-page",
|
||||
"build:pages": "npm run build --workspace=status-page",
|
||||
"check:pages": "npm run typecheck --workspace=status-page && npm run lint:pages && npm run format:pages:check",
|
||||
"lint:pages": "npm run lint --workspace=status-page",
|
||||
"lint:pages:fix": "npm run lint:fix --workspace=status-page",
|
||||
"test:pages": "npm run test --workspace=status-page",
|
||||
"check": "pnpm run typecheck && pnpm run lint && pnpm run format:check",
|
||||
"check:fix": "pnpm run lint:fix && pnpm run format",
|
||||
"dev:pages": "pnpm --filter=atalaya-prod-status-page run dev",
|
||||
"build:pages": "pnpm --filter=atalaya-prod-status-page run build",
|
||||
"check:pages": "pnpm --filter=atalaya-prod-status-page run typecheck && pnpm run lint:pages && pnpm run format:pages:check",
|
||||
"lint:pages": "pnpm --filter=atalaya-prod-status-page run lint",
|
||||
"lint:pages:fix": "pnpm --filter=atalaya-prod-status-page run lint:fix",
|
||||
"test:pages": "pnpm --filter=atalaya-prod-status-page run test",
|
||||
"format:pages": "prettier --write \"src/**/*.ts\" \"status-page/src/**/*.ts\"",
|
||||
"format:pages:check": "prettier --check \"src/**/*.ts\" \"status-page/src/**/*.ts\""
|
||||
},
|
||||
@@ -34,6 +31,7 @@
|
||||
"@typescript-eslint/parser": "^8.62.1",
|
||||
"eslint": "^10.6.0",
|
||||
"eslint-plugin-oxlint": "^1.72.0",
|
||||
"oxlint": "^1.72.0",
|
||||
"prettier": "^3.9.4",
|
||||
"typescript": "^6.0.0",
|
||||
"vitest": "^4.1.9",
|
||||
|
||||
Generated
+5790
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
packages:
|
||||
- 'status-page'
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
sharp: true
|
||||
workerd: true
|
||||
@@ -7,7 +7,7 @@
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"deploy": "echo 'Deploy from root: npm run deploy'",
|
||||
"deploy": "echo 'Deploy from root: pnpm run deploy'",
|
||||
"typecheck": "astro check && tsc --noEmit",
|
||||
"check": "astro check && tsc --noEmit && eslint",
|
||||
"test": "vitest run",
|
||||
@@ -18,6 +18,7 @@
|
||||
"@astrojs/check": "^0.9.9",
|
||||
"@astrojs/cloudflare": "^13.7.0",
|
||||
"astro": "^6.4.8",
|
||||
"cookie": "^1.0.0",
|
||||
"uplot": "^1.6.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user