diff --git a/AGENTS.md b/AGENTS.md index 5a898701..1dff8651 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -206,7 +206,7 @@ pnpm run check # Type check **Welshman Development:** - Clone welshman to parent directory -- Use `./link_deps` script to link local welshman packages +- Use `./scripts/link-deps.mjs` to link local welshman packages - Avoid committing `pnpm.overrides` changes **Git Workflow:** diff --git a/Dockerfile b/Dockerfile index 021a8e27..79880306 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # docker run -p 3000:3000 flotilla # # Pass --build-arg VITE_BUILD_HASH=$(git rev-parse --short HEAD) to stamp the build. -# A .env in the build context is picked up by build.sh for branding config. +# A .env in the build context is picked up by scripts/build.sh for branding config. # https://pnpm.io/docker#example-3-build-on-cicd FROM node:24-slim AS builder diff --git a/README.md b/README.md index 29d5886f..ac843917 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ You can also optionally create an `.env.local` file and populate it with the fol - `VITE_POMADE_SIGNERS` - A comma-separated list of Pomade signer server URLs (3+ required to enable email signup) - `VITE_THUMBNAIL_URL` - URL of the image thumbnail service -These values **won't** be used for a built version. Instead, env variables should be provided to `build.sh` directly or to the built container. +These values **won't** be used for a built version. Instead, env variables should be provided to `scripts/build.sh` directly or to the built container. If you're deploying a custom version of flotilla, be sure to remove the `plausible.coracle.social` script from `app.html`. This sends analytics to a server hosted by the developer. diff --git a/package.json b/package.json index b94f2987..9a19ebb1 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "private": true, "scripts": { "dev": "vite dev", - "build": "./build.sh", + "build": "./scripts/build.sh", "build:server": "vite build --config vite.config.server.ts", "start": "node server.js", - "release:android": "./build.sh && cap build android --androidreleasetype APK --signing-type apksigner", + "release:android": "./scripts/build.sh && cap build android --androidreleasetype APK --signing-type apksigner", + "bump": "node scripts/bump-version.mjs", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check src e2e playwright.config.ts && eslint src e2e", @@ -28,6 +29,7 @@ "@types/node": "^25.9.1", "@types/ws": "^8.18.1", "autoprefixer": "^10.4.23", + "capacitor-set-version": "^2.2.0", "classnames": "^2.5.1", "eslint": "^9.39.2", "eslint-config-prettier": "^9.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 692fe91e..d7f1e9bd 100644 Binary files a/pnpm-lock.yaml and b/pnpm-lock.yaml differ diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f86777f4..4e47c019 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,4 @@ -# Allow link_deps to change stuff in the working tree +# Allow link-deps.mjs to change stuff in the working tree verifyDepsBeforeRun: warn allowBuilds: @@ -7,6 +7,7 @@ allowBuilds: esbuild: false sharp: true nostr-signer-capacitor-plugin@https://codeload.github.com/coracle-social/nostr-signer-capacitor-plugin/tar.gz/436adec9ed1e71569748cd56aa697f361e7a8d47: true + yarn: false minimumReleaseAgeExclude: - '@pomade/core' - '@welshman/app' diff --git a/build-in-production.sh b/scripts/build-in-production.sh similarity index 100% rename from build-in-production.sh rename to scripts/build-in-production.sh diff --git a/build.sh b/scripts/build.sh similarity index 100% rename from build.sh rename to scripts/build.sh diff --git a/scripts/bump-version.mjs b/scripts/bump-version.mjs new file mode 100755 index 00000000..4e958cd9 --- /dev/null +++ b/scripts/bump-version.mjs @@ -0,0 +1,50 @@ +#!/usr/bin/env node +// Bumps the version in package.json and syncs it to android and ios via +// capacitor-set-version. Android and iOS build numbers have diverged +// historically, so each platform keeps its own counter, incremented only when +// its marketing version actually changes (re-running with the same version is +// a no-op). +import {readFileSync, writeFileSync} from "node:fs" +import {setAndroidVersionAndBuild} from "capacitor-set-version/dist/common/utils-android.js" +import {setIOSVersionAndBuild} from "capacitor-set-version/dist/common/utils-ios.js" + +const arg = process.argv[2] || "patch" + +const pkg = JSON.parse(readFileSync("package.json", "utf-8")) + +let version +if (/^\d+\.\d+\.\d+$/.test(arg)) { + version = arg +} else { + const [major, minor, patch] = pkg.version.split(".").map(Number) + if (arg === "major") { + version = `${major + 1}.0.0` + } else if (arg === "minor") { + version = `${major}.${minor + 1}.0` + } else if (arg === "patch") { + version = `${major}.${minor}.${patch + 1}` + } else { + console.error(`Usage: pnpm bump [major|minor|patch|x.y.z] (got "${arg}")`) + process.exit(1) + } +} + +const gradle = readFileSync("android/app/build.gradle", "utf-8") +const pbxproj = readFileSync("ios/App/App.xcodeproj/project.pbxproj", "utf-8") + +const androidVersion = gradle.match(/versionName "(.+)"/)[1] +const androidBuild = Number(gradle.match(/versionCode (\d+)/)[1]) +const iosVersion = pbxproj.match(/MARKETING_VERSION = (.+);/)[1] +const iosBuild = Number(pbxproj.match(/CURRENT_PROJECT_VERSION = (\d+);/)[1]) + +pkg.version = version +writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n") + +const nextAndroidBuild = version === androidVersion ? androidBuild : androidBuild + 1 +const nextIosBuild = version === iosVersion ? iosBuild : iosBuild + 1 + +setAndroidVersionAndBuild(".", version, nextAndroidBuild) +setIOSVersionAndBuild(".", version, nextIosBuild) + +console.log(`android: ${version} (${nextAndroidBuild})`) +console.log(`ios: ${version} (${nextIosBuild})`) diff --git a/link_deps b/scripts/link-deps.mjs similarity index 100% rename from link_deps rename to scripts/link-deps.mjs diff --git a/vite.config.ts b/vite.config.ts index 81434ad6..cf592a0a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,7 +9,7 @@ config({path: ".env"}) export default defineConfig({ // @welshman/editor takes tiptap as peer dependencies, so an installed copy resolves them from - // here and there is one prosemirror. link_deps symlinks its source instead, and that directory + // here and there is one prosemirror. link-deps.mjs symlinks its source instead, and that directory // carries node_modules from welshman's own install — a second prosemirror, whose Plugin and // PluginKey classes tiptap refuses to mix with ours ("Adding different instances of a keyed // plugin"). Deduping resolves these to this project's copy wherever they are imported from, and