diff --git a/.github/composite/build-image/action.yml b/.github/composite/build-image/action.yml index 7f9dcac80..292eee1bd 100644 --- a/.github/composite/build-image/action.yml +++ b/.github/composite/build-image/action.yml @@ -56,8 +56,4 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/build-image - env: - DOCKER_UPLOAD: ${{ inputs.DOCKER_UPLOAD }} - TAG_PREFIX: ${{ inputs.TAG_PREFIX }} - SERVER_PROFILES: ${{ inputs.SERVER_PROFILES }} + run: bun run .github/scripts/build-image --tag-prefix=${{ inputs.TAG_PREFIX }} --docker-upload=${{ inputs.DOCKER_UPLOAD }} --server-profiles=${{ inputs.SERVER_PROFILES }} diff --git a/.github/composite/build-image/internal/standup-bot/action.yml b/.github/composite/build-image/internal/standup-bot/action.yml index 5fcda9b8f..45ef58317 100644 --- a/.github/composite/build-image/internal/standup-bot/action.yml +++ b/.github/composite/build-image/internal/standup-bot/action.yml @@ -33,6 +33,4 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/build-image/internal/standup-bot - env: - DOCKER_UPLOAD: ${{ inputs.DOCKER_UPLOAD }} + run: bun run .github/scripts/build-image/internal/standup-bot --docker-upload=${{ inputs.DOCKER_UPLOAD }} diff --git a/.github/composite/notion-checks/action.yml b/.github/composite/notion-checks/action.yml index 8161f5a78..8aba73546 100644 --- a/.github/composite/notion-checks/action.yml +++ b/.github/composite/notion-checks/action.yml @@ -33,7 +33,4 @@ runs: - name: Run script id: run_script shell: bash - run: bun .github/scripts/notion - env: - PR_ID: ${{ inputs.PR_ID }} - GET_GHA_OUTPUT: ${{ inputs.GET_GHA_OUTPUT }} + run: bun .github/scripts/notion --prId=${{ inputs.PR_ID }} --getGhaOutput=${{ inputs.GET_GHA_OUTPUT }} --githubOutput=${{ inputs.GITHUB_OUTPUT }} diff --git a/.github/composite/redeploy/action.yml b/.github/composite/redeploy/action.yml index 10aed6873..2fcedc0bc 100644 --- a/.github/composite/redeploy/action.yml +++ b/.github/composite/redeploy/action.yml @@ -52,10 +52,8 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/redeploy + run: bun run .github/scripts/redeploy --environment=${{ inputs.ENVIRONMENT }} --sha=${{ inputs.SHA }} env: DOCKER_UPLOAD: ${{ inputs.DOCKER_UPLOAD }} TAG_PREFIX: ${{ inputs.TAG_PREFIX }} SERVER_PROFILES: ${{ inputs.SERVER_PROFILES }} - ENVIRONMENT: ${{ inputs.ENVIRONMENT }} - SHA: ${{ inputs.SHA }} diff --git a/.github/composite/test/backend-test/action.yml b/.github/composite/test/backend-test/action.yml index fc247a30e..cc55161cc 100644 --- a/.github/composite/test/backend-test/action.yml +++ b/.github/composite/test/backend-test/action.yml @@ -49,6 +49,4 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/test/run-backend-tests - env: - UPLOAD_TEST_COV: ${{ inputs.UPLOAD_TEST_COV }} + run: bun run .github/scripts/test/run-backend-tests --should-upload-coverage=${{ inputs.UPLOAD_TEST_COV }} diff --git a/.github/composite/test/frontend-test/action.yml b/.github/composite/test/frontend-test/action.yml index a075911de..7a164ce7f 100644 --- a/.github/composite/test/frontend-test/action.yml +++ b/.github/composite/test/frontend-test/action.yml @@ -49,6 +49,4 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/test/run-frontend-tests - env: - UPLOAD_TEST_COV: ${{ inputs.UPLOAD_TEST_COV }} + run: bun run .github/scripts/test/run-frontend-tests --should-upload-coverage=${{ inputs.UPLOAD_TEST_COV }} diff --git a/.github/composite/validate-db/action.yml b/.github/composite/validate-db/action.yml index 3d9bb60fc..275d3c465 100644 --- a/.github/composite/validate-db/action.yml +++ b/.github/composite/validate-db/action.yml @@ -41,7 +41,4 @@ runs: - name: Run script shell: bash - run: bun .github/scripts/validate-db - env: - ENVIRONMENT: ${{ inputs.ENVIRONMENT }} - SHA: ${{ inputs.SHA }} + run: bun run .github/scripts/validate-db --environment=${{ inputs.ENVIRONMENT }} --sha=${{ inputs.SHA }} diff --git a/.github/scripts/auto-approval/index.ts b/.github/scripts/auto-approval/index.ts index 32ce0e905..2211ae054 100644 --- a/.github/scripts/auto-approval/index.ts +++ b/.github/scripts/auto-approval/index.ts @@ -1,37 +1,42 @@ import type { RestEndpointMethodTypes } from "@octokit/rest"; import { Octokit, RequestError } from "octokit"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; const AUTHORIZED_USER = "tahminator"; -const githubToken = (() => { - const v = process.env.GH_TOKEN; - if (!v) { - throw new Error("GH_TOKEN is required"); - } - return v; -})(); +const { + githubToken, + repo: rawRepo, + prId, +} = await yargs(hideBin(process.argv)) + .option("githubToken", { + type: "string", + describe: "GitHub token", + default: "", + }) + .option("repo", { + type: "string", + describe: "Repository in owner/repo form", + default: "", + }) + .option("prId", { + type: "number", + describe: "Pull request number", + default: 1, + }) + .strict() + .parse(); const [owner, repo] = (() => { - const v = process.env.GITHUB_REPOSITORY; + const v = rawRepo; if (!v) { throw new Error("GITHUB_REPOSITORY is required"); } return v.split("/") as [string, string]; })(); -const prId = (() => { - const v = process.env.PR_ID; - if (!v) { - throw new Error("PR_ID is required"); - } - const n = Number(v); - if (Number.isNaN(n)) { - throw new Error("PR_ID must be a number"); - } - return n; -})(); - async function main() { const client = new Octokit({ auth: githubToken, diff --git a/.github/scripts/build-image/index.ts b/.github/scripts/build-image/index.ts index 22e7ea5e6..699bed6cc 100644 --- a/.github/scripts/build-image/index.ts +++ b/.github/scripts/build-image/index.ts @@ -2,12 +2,28 @@ import { $ } from "bun"; import { getEnvVariables } from "load-secrets/env/load"; import { backend } from "utils/run-backend-instance"; import { db } from "utils/run-local-db"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; process.env.TZ = "America/New_York"; -const tagPrefix = process.env.TAG_PREFIX || ""; -const shouldDockerUpload = Boolean(process.env.DOCKER_UPLOAD) || false; -const serverProfiles = process.env.SERVER_PROFILES || "prod"; +const { tagPrefix, shouldDockerUpload, serverProfiles } = await yargs( + hideBin(process.argv), +) + .option("tagPrefix", { + type: "string", + default: "", + }) + .option("dockerUpload", { + type: "boolean", + default: false, + }) + .option("serverProfiles", { + type: "string", + default: "prod", + }) + .strict() + .parse(); async function main() { try { diff --git a/.github/scripts/build-image/internal/standup-bot.ts b/.github/scripts/build-image/internal/standup-bot.ts index 09a909d6a..b398ddcff 100644 --- a/.github/scripts/build-image/internal/standup-bot.ts +++ b/.github/scripts/build-image/internal/standup-bot.ts @@ -1,9 +1,17 @@ import { $ } from "bun"; import { getEnvVariables } from "load-secrets/env/load"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; process.env.TZ = "America/New_York"; -const shouldDockerUpload = Boolean(process.env.DOCKER_UPLOAD) || false; +const { shouldDockerUpload } = await yargs(hideBin(process.argv)) + .option("dockerUpload", { + type: "boolean", + default: false, + }) + .strict() + .parse(); async function main() { const ciEnv = await getEnvVariables(["ci"]); diff --git a/.github/scripts/bun.lock b/.github/scripts/bun.lock index 31cc77bdc..ee747abf3 100644 --- a/.github/scripts/bun.lock +++ b/.github/scripts/bun.lock @@ -9,9 +9,11 @@ "@digitalocean/dots": "^1.7.0", "@notionhq/client": "^5.7.0", "@octokit/rest": "^22.0.1", + "@types/yargs": "^17.0.35", "bun": "^1.3.6", "coolify": "https://github.com/tahminator/Coolify-TypeScript-SDK#8e19e18635ea2b095a9c39c574d22eefd938441f", "octokit": "^5.0.5", + "yargs": "^18.0.0", }, "devDependencies": { "@eslint/js": "^9.39.2", @@ -227,6 +229,10 @@ "@types/tunnel": ["@types/tunnel@0.0.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA=="], + "@types/yargs": ["@types/yargs@17.0.35", "", { "dependencies": { "@types/yargs-parser": "*" } }, "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg=="], + + "@types/yargs-parser": ["@types/yargs-parser@21.0.3", "", {}, "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ=="], + "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.53.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.53.0", "@typescript-eslint/type-utils": "8.53.0", "@typescript-eslint/utils": "8.53.0", "@typescript-eslint/visitor-keys": "8.53.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.53.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-eEXsVvLPu8Z4PkFibtuFJLJOTAV/nPdgtSjkGoPpddpFk3/ym2oy97jynY6ic2m6+nc5M8SE1e9v/mHKsulcJg=="], "@typescript-eslint/parser": ["@typescript-eslint/parser@8.53.0", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.53.0", "@typescript-eslint/types": "8.53.0", "@typescript-eslint/typescript-estree": "8.53.0", "@typescript-eslint/visitor-keys": "8.53.0", "debug": "^4.4.3" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg=="], @@ -309,6 +315,8 @@ "chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="], + "cliui": ["cliui@9.0.1", "", { "dependencies": { "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w=="], + "color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="], "color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="], @@ -345,7 +353,7 @@ "eastasianwidth": ["eastasianwidth@0.2.0", "", {}, "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="], - "emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], + "emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="], "es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="], @@ -355,6 +363,8 @@ "es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="], + "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], + "escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="], "eslint": ["eslint@9.39.2", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.1", "@eslint/config-helpers": "^0.4.2", "@eslint/core": "^0.17.0", "@eslint/eslintrc": "^3.3.1", "@eslint/js": "9.39.2", "@eslint/plugin-kit": "^0.4.1", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.4.0", "eslint-visitor-keys": "^4.2.1", "espree": "^10.4.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw=="], @@ -411,6 +421,10 @@ "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], + "get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="], + + "get-east-asian-width": ["get-east-asian-width@1.4.0", "", {}, "sha512-QZjmEOC+IT1uk6Rx0sX22V6uHWVwbdbxf1faPqJ1QhLdGgsRGCZoyaQBm/piRdJy/D2um6hM1UP7ZEeQ4EkP+Q=="], + "get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="], "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], @@ -565,7 +579,7 @@ "streamx": ["streamx@2.23.0", "", { "dependencies": { "events-universal": "^1.0.0", "fast-fifo": "^1.3.2", "text-decoder": "^1.1.0" } }, "sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg=="], - "string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="], + "string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="], "string-width-cjs": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="], @@ -631,7 +645,7 @@ "word-wrap": ["word-wrap@1.2.5", "", {}, "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA=="], - "wrap-ansi": ["wrap-ansi@8.1.0", "", { "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } }, "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ=="], + "wrap-ansi": ["wrap-ansi@9.0.2", "", { "dependencies": { "ansi-styles": "^6.2.1", "string-width": "^7.0.0", "strip-ansi": "^7.1.0" } }, "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww=="], "wrap-ansi-cjs": ["wrap-ansi@7.0.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="], @@ -641,6 +655,12 @@ "xmlbuilder": ["xmlbuilder@11.0.1", "", {}, "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="], + "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], + + "yargs": ["yargs@18.0.0", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^7.2.0", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg=="], + + "yargs-parser": ["yargs-parser@22.0.0", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="], + "yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="], "zip-stream": ["zip-stream@6.0.1", "", { "dependencies": { "archiver-utils": "^5.0.0", "compress-commons": "^6.0.2", "readable-stream": "^4.0.0" } }, "sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA=="], @@ -663,6 +683,10 @@ "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], + "@isaacs/cliui/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="], + + "@isaacs/cliui/wrap-ansi": ["wrap-ansi@8.1.0", "", { "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } }, "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ=="], + "@octokit/app/@octokit/core": ["@octokit/core@7.0.6", "", { "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.3", "@octokit/request": "^10.0.6", "@octokit/request-error": "^7.0.2", "@octokit/types": "^16.0.0", "before-after-hook": "^4.0.0", "universal-user-agent": "^7.0.0" } }, "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q=="], "@octokit/auth-app/@octokit/request": ["@octokit/request@10.0.7", "", { "dependencies": { "@octokit/endpoint": "^11.0.2", "@octokit/request-error": "^7.0.2", "@octokit/types": "^16.0.0", "fast-content-type-parse": "^3.0.0", "universal-user-agent": "^7.0.2" } }, "sha512-v93h0i1yu4idj8qFPZwjehoJx4j3Ntn+JhXsdJrG9pYaX6j/XRz2RmasMUHtNgQD39nrv/VwTWSqK0RNXR8upA=="], @@ -753,6 +777,10 @@ "@actions/github/@octokit/plugin-rest-endpoint-methods/@octokit/types": ["@octokit/types@12.6.0", "", { "dependencies": { "@octokit/openapi-types": "^20.0.0" } }, "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw=="], + "@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], + + "@isaacs/cliui/wrap-ansi/ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="], + "@octokit/app/@octokit/core/@octokit/auth-token": ["@octokit/auth-token@6.0.0", "", {}, "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w=="], "@octokit/app/@octokit/core/@octokit/graphql": ["@octokit/graphql@9.0.3", "", { "dependencies": { "@octokit/request": "^10.0.6", "@octokit/types": "^16.0.0", "universal-user-agent": "^7.0.0" } }, "sha512-grAEuupr/C1rALFnXTv6ZQhFuL1D8G5y8CN04RgrO4FIPMrtm+mcZzFG7dcBm+nq+1ppNixu+Jd78aeJOYxlGA=="], diff --git a/.github/scripts/copy-prod-db/index.ts b/.github/scripts/copy-prod-db/index.ts index 6798a8f0f..ca0a34646 100644 --- a/.github/scripts/copy-prod-db/index.ts +++ b/.github/scripts/copy-prod-db/index.ts @@ -1,33 +1,30 @@ import { $ } from "bun"; import { updateCommitStatus } from "utils/update-commit-status"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; import { getEnvVariables } from "../load-secrets/env/load"; const AUTHORIZED_USER = "tahminator"; -const username = (() => { - const v = process.env.GITHUB_ACTOR; - if (!v) { - throw new Error("GITHUB_ACTOR is required"); - } - return v; -})(); - -const sha = (() => { - const v = process.env.SHA; - if (!v) { - throw new Error("SHA is required"); - } - return v; -})(); - -const runUrl = (() => { - const v = process.env.RUN_URL; - if (!v) { - throw new Error("RUN_URL is required"); - } - return v; -})(); +const { runUrl, username, sha } = await yargs(hideBin(process.argv)) + .options("runUrl", { + type: "string", + describe: "Run url for action", + default: "", + }) + .options("username", { + type: "string", + describe: "Username of person who triggered action", + default: "", + }) + .options("sha", { + type: "string", + describe: "Commit SHA", + default: "", + }) + .strict() + .parse(); async function main() { try { diff --git a/.github/scripts/help-message/index.ts b/.github/scripts/help-message/index.ts index bf7953143..d2c0abf46 100644 --- a/.github/scripts/help-message/index.ts +++ b/.github/scripts/help-message/index.ts @@ -1,16 +1,15 @@ import { sendMessage } from "utils/send-message"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; -const prId = (() => { - const v = process.env.PR_ID; - if (!v) { - throw new Error("PR_ID is required"); - } - const n = Number(v); - if (Number.isNaN(n)) { - throw new Error("PR_ID must be a number"); - } - return n; -})(); +const { prId } = await yargs(hideBin(process.argv)) + .options("prId", { + type: "number", + describe: "Pull request number", + default: 1, + }) + .strict() + .parse(); export async function main() { await sendMessage( diff --git a/.github/scripts/load-secrets/index.ts b/.github/scripts/load-secrets/index.ts index 45b5b4f52..74e44b951 100644 --- a/.github/scripts/load-secrets/index.ts +++ b/.github/scripts/load-secrets/index.ts @@ -1,7 +1,6 @@ import { getEnvVariables } from "load-secrets/env/load"; - -// UNLOAD_ENVIRONMENTS="prod,staging,dev" -const unloadEnvironments = process.env.UNLOAD_ENVIRONMENTS || ""; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; const excludedVars = [ "PATH", @@ -15,20 +14,33 @@ const excludedVars = [ "JAVA_HOME", ]; +const { envs, githubEnv } = await yargs(hideBin(process.argv)) + .option("envs", { + type: "string", + describe: "Env names (ex: prod,staging,dev)", + demandOption: true, + }) + .option("githubEnv", { + type: "string", + describe: "Path to GITHUB_ENV", + default: process.env.GITHUB_ENV, + }) + .strict() + .parse(); + /** * @deprecated this is no longer a supported flow. */ async function main() { - const envs = unloadEnvironments + const formattedEnvs = envs .split(",") .map((e) => e.trim()) .filter(Boolean); - const loaded = await getEnvVariables(envs, { + const loaded = await getEnvVariables(formattedEnvs, { mask_PLZ_DO_NOT_TURN_OFF_UNLESS_YOU_KNOW_WHAT_UR_DOING: false, }); - const githubEnv = process.env.GITHUB_ENV; if (!githubEnv) { console.log("Warning: GITHUB_ENV not set, skipping variable export"); return; diff --git a/.github/scripts/notion/index.ts b/.github/scripts/notion/index.ts index d8fc2558d..edf873095 100644 --- a/.github/scripts/notion/index.ts +++ b/.github/scripts/notion/index.ts @@ -4,26 +4,36 @@ import { checkNotionPrAndGetTask } from "notion/pr"; import { getNotionClient } from "notion/sdk"; import { _updateNotionTaskWithPrLink } from "notion/task"; import { updatePrDescriptionWithTicket } from "utils/update-pr-description"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; export * from "./pr"; -const prId = (() => { - const v = process.env.PR_ID; - if (!v) { - throw new Error("PR_ID is required"); - } - const n = Number(v); - if (isNaN(n)) { - throw new Error("PR_ID is not a number"); - } - return n; -})(); - -const getGhaOutput = process.env.GET_GHA_OUTPUT === "true"; -const githubOutputFile = process.env.GITHUB_OUTPUT; +const { + prId, + getGhaOutput, + githubOutput: githubOutputFile, +} = await yargs(hideBin(process.argv)) + .option("prId", { + type: "number", + describe: "Pull request number", + default: 1, + }) + .option("getGhaOutput", { + type: "boolean", + describe: "Enable GitHub Actions output", + default: false, + }) + .option("githubOutput", { + type: "string", + describe: "Path to GITHUB_OUTPUT", + default: "", + }) + .strict() + .parse(); async function main() { - console.log(`GET_GHA_OUTPUT=${process.env.GET_GHA_OUTPUT}`); + console.log(`GET_GHA_OUTPUT=${getGhaOutput}`); const { notionDbId, notionSecret } = parseCiEnv( await getEnvVariables(["ci"]), diff --git a/.github/scripts/package.json b/.github/scripts/package.json index 402be6bcd..754517503 100644 --- a/.github/scripts/package.json +++ b/.github/scripts/package.json @@ -21,9 +21,11 @@ "@digitalocean/dots": "^1.7.0", "@notionhq/client": "^5.7.0", "@octokit/rest": "^22.0.1", + "@types/yargs": "^17.0.35", "bun": "^1.3.6", "coolify": "https://github.com/tahminator/Coolify-TypeScript-SDK#8e19e18635ea2b095a9c39c574d22eefd938441f", - "octokit": "^5.0.5" + "octokit": "^5.0.5", + "yargs": "^18.0.0" }, "devDependencies": { "typescript": "^5.9.0", diff --git a/.github/scripts/redeploy/index.ts b/.github/scripts/redeploy/index.ts index a50f65cf7..9a7c27fe1 100644 --- a/.github/scripts/redeploy/index.ts +++ b/.github/scripts/redeploy/index.ts @@ -3,9 +3,25 @@ import type { Environment } from "types"; import { getEnvVariables } from "load-secrets/env/load"; import { _migrateDb } from "redeploy/db"; import { _migrateDo } from "redeploy/do"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; + +const { environment: rawEnvironment, sha } = await yargs(hideBin(process.argv)) + .option("environment", { + type: "string", + describe: "Deployment environment (staging or production)", + default: "staging", + }) + .option("sha", { + type: "string", + describe: "Commit SHA (required for staging)", + default: "", + }) + .strict() + .parse(); const environment: Environment = (() => { - const v = process.env.ENVIRONMENT; + const v = rawEnvironment; if (!v) { throw new Error("Environment is required"); } @@ -19,16 +35,6 @@ const environment: Environment = (() => { return v; })(); -const sha = (() => { - const v = process.env.SHA; - if (environment === "staging" && !v) { - throw new Error( - "SHA must be available in ENV if script is being run in staging environment.", - ); - } - return v; -})(); - async function main() { // should already be called // await $`git-crypt unlock`; diff --git a/.github/scripts/test/run-backend-tests.ts b/.github/scripts/test/run-backend-tests.ts index a9126bc8d..fc8438e38 100644 --- a/.github/scripts/test/run-backend-tests.ts +++ b/.github/scripts/test/run-backend-tests.ts @@ -4,8 +4,16 @@ import { backend } from "utils/run-backend-instance"; import { frontend } from "utils/run-frontend-instance"; import { db } from "utils/run-local-db"; import { uploadBackendTests } from "utils/upload"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; -const shouldUploadCoverage = process.env.UPLOAD_TEST_COV === "true"; +const { shouldUploadCoverage } = await yargs(hideBin(process.argv)) + .option("shouldUploadCoverage", { + type: "boolean", + default: false, + }) + .strict() + .parse(); async function main() { try { diff --git a/.github/scripts/test/run-frontend-tests.ts b/.github/scripts/test/run-frontend-tests.ts index 1a8461c9b..9f7c427ca 100644 --- a/.github/scripts/test/run-frontend-tests.ts +++ b/.github/scripts/test/run-frontend-tests.ts @@ -3,8 +3,16 @@ import { getEnvVariables } from "load-secrets/env/load"; import { backend } from "utils/run-backend-instance"; import { db } from "utils/run-local-db"; import { uploadFrontendTests } from "utils/upload"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; -const shouldUploadCoverage = process.env.UPLOAD_TEST_COV === "true"; +const { shouldUploadCoverage } = await yargs(hideBin(process.argv)) + .option("shouldUploadCoverage", { + type: "boolean", + default: false, + }) + .strict() + .parse(); async function main() { try { diff --git a/.github/scripts/validate-db/index.ts b/.github/scripts/validate-db/index.ts index 2c3874f6e..a40c66ec3 100644 --- a/.github/scripts/validate-db/index.ts +++ b/.github/scripts/validate-db/index.ts @@ -2,9 +2,25 @@ import type { Environment } from "types"; import { $ } from "bun"; import { getEnvVariables } from "load-secrets/env/load"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; + +const { environment: rawEnvironment, sha } = await yargs(hideBin(process.argv)) + .option("environment", { + type: "string", + describe: "Deployment environment (staging or production)", + default: "Staging", + }) + .option("sha", { + type: "string", + describe: "Commit SHA (required for staging)", + default: "", + }) + .strict() + .parse(); const environment: Environment = (() => { - const v = process.env.ENVIRONMENT; + const v = rawEnvironment; if (!v) { throw new Error("Environment is required"); } @@ -18,16 +34,6 @@ const environment: Environment = (() => { return v; })(); -const sha = (() => { - const v = process.env.SHA; - if (environment === "staging" && !v) { - throw new Error( - "SHA must be available in ENV if script is being run in staging environment.", - ); - } - return v; -})(); - export async function main() { // make sure you checkout the repo first. diff --git a/.github/workflows/auto-approval.yml b/.github/workflows/auto-approval.yml index bfe46b358..71c1c5e8e 100644 --- a/.github/workflows/auto-approval.yml +++ b/.github/workflows/auto-approval.yml @@ -30,6 +30,4 @@ jobs: - name: Run script shell: bash - run: bun .github/scripts/auto-approval - env: - PR_ID: ${{ github.event.pull_request.number }} + run: bun run .github/scripts/auto-approval --prId ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --githubToken ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/copy-db.yml b/.github/workflows/copy-db.yml index 43de5beea..9375ffc58 100644 --- a/.github/workflows/copy-db.yml +++ b/.github/workflows/copy-db.yml @@ -67,9 +67,6 @@ jobs: cache: "maven" - name: Copy Production Database to Staging - run: bun .github/scripts/copy-prod-db/index.ts + run: bun run .github/scripts/copy-prod-db/index.ts --run-url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --github-actor=${{ github.event.client_payload.github.actor || github.actor }} --sha=${{ needs.getPRHead.outputs.sha }} env: PR_ID: ${{ github.event.client_payload.slash_command.args.named.prId || github.event.inputs.prId }} - GITHUB_ACTOR: ${{ github.event.client_payload.github.actor || github.actor }} - SHA: ${{ needs.getPRHead.outputs.sha }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index 9cb5ae233..0a48a7f58 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -25,6 +25,4 @@ jobs: - name: Run script shell: bash - run: bun .github/scripts/help-message - env: - PR_ID: ${{ github.event.pull_request.number }} + run: bun run .github/scripts/help-message --pr-id=${{ github.event.pull_request.number }}