-
Notifications
You must be signed in to change notification settings - Fork 11
Rework for TS6 #39
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
base: main
Are you sure you want to change the base?
Rework for TS6 #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v7.0.0 | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6.4.0 | ||
| with: | ||
| node-version: 22.6.0 | ||
| - name: Install Dependencies | ||
| run: npm install --no-fund | ||
| - name: Typecheck | ||
| run: npm run test:types | ||
| - name: Lint | ||
| run: npm run lint | ||
| - name: Unit Test | ||
| run: npm run test:unit | ||
| - name: Build | ||
| run: npm run build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| node_modules | ||
| .DS_Store | ||
| dist | ||
| .env | ||
| public/*.js | ||
| public/*.js.map | ||
| /node_modules/ | ||
| /dist/ | ||
| /public/*.js* | ||
| /.env |
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop .npmrc. NPM prints a warning on engine mismatch. Strict engines |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"recommendations": ["biomejs.biome"]} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "editor.defaultFormatter": "biomejs.biome", | ||
| "editor.codeActionsOnSave": {"source.organizeImports.biome": "explicit"}, | ||
| "js/ts.tsdk.path": "node_modules/typescript/lib" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use installed TypeScript version. |
||
| } | ||
This file was deleted.
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Biome to flag floating promises and format. Unfortunately, most |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "$schema": "https://biomejs.dev/schemas/2.5.1/schema.json", | ||
| "css": {"formatter": {"enabled": true, "quoteStyle": "single"}}, | ||
| "files": {"includes": ["**", "!dist/", "!public/*.js*"]}, | ||
| "formatter": { | ||
| "bracketSpacing": false, | ||
| "enabled": true, | ||
| "indentStyle": "space" | ||
| }, | ||
| "html": {"formatter": {"enabled": true}}, | ||
| "javascript": { | ||
| "formatter": { | ||
| "arrowParentheses": "asNeeded", | ||
| "jsxQuoteStyle": "single", | ||
| "quoteStyle": "single", | ||
| "semicolons": "asNeeded" | ||
| } | ||
| }, | ||
| "linter": { | ||
| "domains": {"project": "all"}, | ||
| "rules": { | ||
| "correctness": { | ||
| // Biome resolves conditional exports without the browser condition, | ||
| // which reports false positives for `@devvit/web/client` named exports. | ||
| "noUnresolvedImports": "off" | ||
| }, | ||
| "nursery": { | ||
| "noFloatingPromises": "error", | ||
| "noMisusedPromises": "error", | ||
| "recommended": true | ||
| }, | ||
| "style": {"noInferrableTypes": "off"}, | ||
| "suspicious": {"noImplicitAnyLet": "off"} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems crazy to me but the recommend rule is to require explicit let local typing which is often overtyping in my opinion |
||
| } | ||
| }, | ||
| "vcs": {"enabled": true, "clientKind": "git", "useIgnoreFile": true} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,37 +2,30 @@ | |
| "$schema": "https://developers.reddit.com/schema/config-file.v1.json", | ||
| "name": "<% name %>", | ||
| "post": { | ||
| "dir": "public", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default |
||
| "entrypoints": { | ||
| "default": { | ||
| "inline": true, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default |
||
| "entry": "splash.html" | ||
| }, | ||
| "game": { | ||
| "entry": "game.html" | ||
| } | ||
| } | ||
| }, | ||
| "server": { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove redundant post and server defaults in devvit.json. |
||
| "dir": "dist/server", | ||
| "entry": "index.js" | ||
| }, | ||
| "server": {}, | ||
| "menu": { | ||
| "items": [ | ||
| { | ||
| "label": "Create a new post", | ||
| "description": "<% name %>", | ||
| "label": "[<% name %>] New Post", | ||
| "description": "Create a new <% name %> post.", | ||
| "location": "subreddit", | ||
| "forUserType": "moderator", | ||
| "endpoint": "/internal/menu/post-create" | ||
| "endpoint": "/internal/on/menu/new-post" | ||
| } | ||
| ] | ||
| }, | ||
| "triggers": { | ||
| "onAppInstall": "/internal/on-app-install" | ||
| "onAppInstall": "/internal/on/app/install" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tweak router paths to be more hierarchical. |
||
| }, | ||
| "scripts": { | ||
| "dev": "node --experimental-strip-types ./tools/build.ts --watch", | ||
| "build": "node --experimental-strip-types ./tools/build.ts --minify" | ||
| "dev": "npm run watch" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,23 +5,28 @@ | |
| "license": "BSD-3-Clause", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "node --experimental-strip-types ./tools/build.ts --minify", | ||
| "deploy": "npm run build && devvit upload", | ||
| "dev": "devvit playtest", | ||
| "login": "devvit login", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop login NPM script since tooling will log you in. |
||
| "launch": "npm run build && npm run deploy && devvit publish", | ||
| "type-check": "tsc --build" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.6.0" | ||
| }, | ||
| "dependencies": { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move both devvit and @devvit/web to devDependencies. The former |
||
| "@devvit/web": "0.13.0", | ||
| "devvit": "0.13.0" | ||
| "build": "npm run build:client -- --metafile=dist/client.meta.json --minify && npm run build:server -- --metafile=dist/server.meta.json --minify", | ||
| "build:client": "esbuild --bundle --log-level=warning --sourcemap=linked --target=es2023 --format=esm --outdir=public --platform=browser src/client/splash.ts src/client/game.ts", | ||
| "build:server": "esbuild --bundle --log-level=warning --sourcemap=linked --target=es2023 --format=cjs --outdir=dist/server --platform=node src/server/index.ts", | ||
|
Comment on lines
+8
to
+10
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inlined from tools/build.ts |
||
| "clean": "rm -rf dist/ public/*.js*", | ||
| "format": "npm run lint -- --fix", | ||
| "lint": "biome check --error-on-warnings", | ||
| "playtest": "devvit playtest", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename dev to playtest, invoke watch, and reserve dev for dev |
||
| "test": "npm run test:types && npm run lint && npm run test:unit && npm run build", | ||
| "test:types": "tsc --build", | ||
| "test:unit": "node --experimental-strip-types --no-warnings=ExperimentalWarning --test src/**/*.test.ts", | ||
| "publish": "npm run clean && npm run build && devvit publish", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename deploy NPM script to publish which matches NPM (and Devvit) |
||
| "watch": "sh -c 'trap \"kill 0\" exit; npm run build:client -- --watch=forever& npm run build:server -- --watch=forever& wait' --" | ||
| }, | ||
| "devDependencies": { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgrade all dependencies. |
||
| "@types/node": "22.20.0", | ||
| "typescript": "6.0.3", | ||
| "esbuild": "0.28.1" | ||
| "@biomejs/biome": "2.5.1", | ||
| "@devvit/web": "0.13.5", | ||
| "@types/node": "22.6.2", | ||
| "devvit": "0.13.5", | ||
| "esbuild": "0.28.1", | ||
| "typescript": "6.0.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.6" | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,37 @@ | ||
| <!DOCTYPE html> | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <link rel="stylesheet" type="text/css" href="game.css" /> | ||
| <meta charset="UTF-8" /> | ||
| <meta charset="utf-8"> | ||
| <meta | ||
| name="viewport" | ||
| content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width, height=device-height, user-scalable=0" | ||
| /> | ||
| <title>devvit</title> | ||
| content="width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no" | ||
| > | ||
| <title>Game</title> | ||
| <link rel="modulepreload" href="game.js"> | ||
| <style> | ||
| body { | ||
| margin: 0; | ||
| width: 100dvw; | ||
| height: 100dvh; | ||
| overflow: hidden; | ||
| display: grid; | ||
| place-items: center; | ||
| } | ||
| main { | ||
| display: grid; | ||
| gap: 1rem; | ||
| justify-items: center; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body class="app"> | ||
| <img class="snoo" src="/snoo.png" alt="Snoo" /> | ||
| <div class="content"> | ||
| <h1 class="title" id="title"></h1> | ||
| <p class="description"> | ||
| Edit <span class="code">src/client/game.ts</span> to get started. | ||
| </p> | ||
| </div> | ||
| <div class="counter-row"> | ||
| <button class="counter-button" id="decrement-button">-</button> | ||
| <span class="counter-value" id="counter-value">0</span> | ||
| <button class="counter-button" id="increment-button">+</button> | ||
| </div> | ||
| <footer class="footer"> | ||
| <div class="docs-link" tabindex="0" id="docs-link">Docs</div> | ||
| <span class="divider">|</span> | ||
| <div class="docs-link" tabindex="0" id="playtest-link">r/Devvit</div> | ||
| <span class="divider">|</span> | ||
| <div class="docs-link" tabindex="0" id="discord-link">Discord</div> | ||
| </footer> | ||
| <script type="module" src="game.js" defer></script> | ||
| <body> | ||
| <main> | ||
| <div class="counter"> | ||
| <button id="dec-btn" type="button">-</button> | ||
| <output id="counter">0</output> | ||
| <button id="inc-btn" type="button">+</button> | ||
| </div> | ||
| </main> | ||
| <script src="game.js" type="module"></script> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add CI workflow to template. I think this will really help a lot of
people catch mistakes when they happen. As a bonus, they'll catch
errors in the template too.