diff --git a/package-lock.json b/package-lock.json index 8866adc..1fcfcf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "@types/semver": "^7.5.8", "@vercel/ncc": "^0.38.2", "mock-fs": "^5.4.1", + "msw": "^2.6.4", "prettier": "^3.3.3", "semver": "^7.6.3", "typescript": "^5.6.3", @@ -82,6 +83,34 @@ "node": ">=6.9.0" } }, + "node_modules/@bundled-es-modules/cookie": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.1.tgz", + "integrity": "sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==", + "dev": true, + "dependencies": { + "cookie": "^0.7.2" + } + }, + "node_modules/@bundled-es-modules/statuses": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz", + "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==", + "dev": true, + "dependencies": { + "statuses": "^2.0.1" + } + }, + "node_modules/@bundled-es-modules/tough-cookie": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz", + "integrity": "sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==", + "dev": true, + "dependencies": { + "@types/tough-cookie": "^4.0.5", + "tough-cookie": "^4.1.4" + } + }, "node_modules/@changesets/apply-release-plan": { "version": "7.0.5", "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.5.tgz", @@ -741,6 +770,75 @@ "node": ">=14" } }, + "node_modules/@inquirer/confirm": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-5.0.2.tgz", + "integrity": "sha512-KJLUHOaKnNCYzwVbryj3TNBxyZIrr56fR5N45v6K9IPrbT6B7DcudBMfylkV1A8PUdJE15mybkEQyp2/ZUpxUA==", + "dev": true, + "dependencies": { + "@inquirer/core": "^10.1.0", + "@inquirer/type": "^3.0.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + } + }, + "node_modules/@inquirer/core": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.1.0.tgz", + "integrity": "sha512-I+ETk2AL+yAVbvuKx5AJpQmoaWhpiTFOg/UJb7ZkMAK4blmtG8ATh5ct+T/8xNld0CZG/2UhtkdMwpgvld92XQ==", + "dev": true, + "dependencies": { + "@inquirer/figures": "^1.0.8", + "@inquirer/type": "^3.0.1", + "ansi-escapes": "^4.3.2", + "cli-width": "^4.1.0", + "mute-stream": "^2.0.0", + "signal-exit": "^4.1.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@inquirer/figures": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.8.tgz", + "integrity": "sha512-tKd+jsmhq21AP1LhexC0pPwsCxEhGgAkg28byjJAd+xhmIs8LUX8JbUc3vBf3PhLxWiB5EvyBE5X7JSPAqMAqg==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/type": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.1.tgz", + "integrity": "sha512-+ksJMIy92sOAiAccGpcKZUc3bYO07cADnscIxHBknEm3uNts3movSmBofc1908BNy5edKscxYeAdaX1NXkHS6A==", + "dev": true, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", @@ -813,6 +911,23 @@ "node": ">=6 <7 || >=8" } }, + "node_modules/@mswjs/interceptors": { + "version": "0.36.10", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.36.10.tgz", + "integrity": "sha512-GXrJgakgJW3DWKueebkvtYgGKkxA7s0u5B0P5syJM5rvQUnrpLPigvci8Hukl7yEM+sU06l+er2Fgvx/gmiRgg==", + "dev": true, + "dependencies": { + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/logger": "^0.3.0", + "@open-draft/until": "^2.0.0", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "strict-event-emitter": "^0.5.1" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -992,6 +1107,28 @@ "@octokit/openapi-types": "^22.2.0" } }, + "node_modules/@open-draft/deferred-promise": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", + "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", + "dev": true + }, + "node_modules/@open-draft/logger": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", + "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "dev": true, + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + } + }, + "node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", + "dev": true + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.24.4", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.4.tgz", @@ -1226,6 +1363,12 @@ "win32" ] }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", + "dev": true + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -1247,6 +1390,18 @@ "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, + "node_modules/@types/statuses": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", + "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==", + "dev": true + }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "dev": true + }, "node_modules/@vercel/ncc": { "version": "0.38.2", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.2.tgz", @@ -1371,6 +1526,33 @@ "node": ">=6" } }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-escapes/node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -1380,6 +1562,21 @@ "node": ">=8" } }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -1461,6 +1658,22 @@ "node": ">=12" } }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", @@ -1491,6 +1704,73 @@ "node": ">=8" } }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", @@ -1569,6 +1849,12 @@ "node": ">=10" } }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "node_modules/enquirer": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz", @@ -1620,6 +1906,15 @@ "@esbuild/win32-x64": "0.21.5" } }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -1749,6 +2044,15 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -1787,6 +2091,30 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, + "node_modules/graphql": { + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/headers-polyfill": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz", + "integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==", + "dev": true + }, "node_modules/human-id": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/human-id/-/human-id-1.0.2.tgz", @@ -1823,6 +2151,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -1835,6 +2172,12 @@ "node": ">=0.10.0" } }, + "node_modules/is-node-process": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", + "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", + "dev": true + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1982,6 +2325,59 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/msw": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/msw/-/msw-2.6.4.tgz", + "integrity": "sha512-Pm4LmWQeytDsNCR+A7gt39XAdtH6zQb6jnIKRig0FlvYOn8eksn3s1nXxUfz5KYUjbckof7Z4p2ewzgffPoCbg==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@bundled-es-modules/cookie": "^2.0.1", + "@bundled-es-modules/statuses": "^1.0.1", + "@bundled-es-modules/tough-cookie": "^0.1.6", + "@inquirer/confirm": "^5.0.0", + "@mswjs/interceptors": "^0.36.5", + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/until": "^2.1.0", + "@types/cookie": "^0.6.0", + "@types/statuses": "^2.0.4", + "chalk": "^4.1.2", + "graphql": "^16.8.1", + "headers-polyfill": "^4.0.2", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "path-to-regexp": "^6.3.0", + "strict-event-emitter": "^0.5.1", + "type-fest": "^4.26.1", + "yargs": "^17.7.2" + }, + "bin": { + "msw": "cli/index.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/mswjs" + }, + "peerDependencies": { + "typescript": ">= 4.8.x" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/mute-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz", + "integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==", + "dev": true, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, "node_modules/nanoid": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", @@ -2043,6 +2439,12 @@ "integrity": "sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==", "dev": true }, + "node_modules/outvariant": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", + "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", + "dev": true + }, "node_modules/p-filter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/p-filter/-/p-filter-2.1.0.tgz", @@ -2115,6 +2517,12 @@ "node": ">=8" } }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -2215,6 +2623,30 @@ "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", "dev": true }, + "node_modules/psl": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.10.0.tgz", + "integrity": "sha512-KSKHEbjAnpUuAUserOq0FxGXCUrzC3WniuSJhvdbs102rL55266ZcHBqLWOsG30spQMlPdpy7icATiAQehg/iA==", + "dev": true, + "dependencies": { + "punycode": "^2.3.1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -2256,6 +2688,21 @@ "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "dev": true }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, "node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", @@ -2426,12 +2873,41 @@ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", "dev": true }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, + "node_modules/strict-event-emitter": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", + "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", + "dev": true + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2453,6 +2929,18 @@ "node": ">=4" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/term-size": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", @@ -2528,6 +3016,30 @@ "node": ">=8.0" } }, + "node_modules/tough-cookie": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", + "dev": true, + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tough-cookie/node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -2542,6 +3054,18 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, + "node_modules/type-fest": { + "version": "4.26.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz", + "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typescript": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", @@ -2586,6 +3110,16 @@ "node": ">= 4.0.0" } }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "node_modules/vite": { "version": "5.4.10", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.10.tgz", @@ -2775,17 +3309,79 @@ "node": ">=8" } }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yoctocolors-cjs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz", + "integrity": "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/zod": { "version": "3.23.8", "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", diff --git a/package.json b/package.json index d54c148..7c876cd 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@types/semver": "^7.5.8", "@vercel/ncc": "^0.38.2", "mock-fs": "^5.4.1", + "msw": "^2.6.4", "prettier": "^3.3.3", "semver": "^7.6.3", "typescript": "^5.6.3", diff --git a/src/github.ts b/src/github.ts deleted file mode 100644 index a6332e9..0000000 --- a/src/github.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { summary } from "@actions/core"; -import { context, getOctokit } from "@actions/github"; -import { env } from "process"; -import { WranglerActionConfig } from "./wranglerAction"; - -type Octokit = ReturnType; - -export async function createGitHubDeployment({ - config, - octokit, - productionBranch, - environment, - deploymentId, - projectName, - deploymentUrl, -}: { - config: WranglerActionConfig; - octokit: Octokit; - productionBranch: string; - environment: string; - deploymentId: string | null; - projectName: string; - deploymentUrl?: string; -}) { - const githubBranch = env.GITHUB_HEAD_REF || env.GITHUB_REF_NAME; - const productionEnvironment = githubBranch === productionBranch; - - const deployment = await octokit.rest.repos.createDeployment({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: githubBranch || context.ref, - auto_merge: false, - description: "Cloudflare Pages", - required_contexts: [], - environment, - production_environment: productionEnvironment, - }); - - if (deployment.status === 201) { - await octokit.rest.repos.createDeploymentStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - deployment_id: deployment.data.id, - environment, - environment_url: deploymentUrl, - production_environment: productionEnvironment, - // don't have project_name or deployment_id I think - log_url: `https://dash.cloudflare.com/${config.CLOUDFLARE_ACCOUNT_ID}/pages/view/${projectName}/${deploymentId}`, - description: "Cloudflare Pages", - state: "success", - auto_inactive: false, - }); - } -} - -export async function createJobSummary({ - commitHash, - deploymentUrl, - aliasUrl, -}: { - commitHash: string; - deploymentUrl?: string; - aliasUrl?: string; -}) { - await summary - .addRaw( - ` -# Deploying with Cloudflare Pages - -| Name | Result | -| ----------------------- | - | -| **Last commit:** | ${commitHash} | -| **Preview URL**: | ${deploymentUrl} | -| **Branch Preview URL**: | ${aliasUrl} | - `, - ) - .write(); -} diff --git a/src/packageManagers.test.ts b/src/packageManagers.test.ts index 6a71fc5..52e3a46 100644 --- a/src/packageManagers.test.ts +++ b/src/packageManagers.test.ts @@ -3,7 +3,7 @@ import { getPackageManager } from "./packageManagers"; describe("getPackageManager", () => { test("should use provided value instead of inferring from lockfile", () => { - expect(getPackageManager("npm", { workingDirectory: "test/npm" })) + expect(getPackageManager("npm", { workingDirectory: "src/test/fixtures/npm" })) .toMatchInlineSnapshot(` { "exec": "npx", @@ -12,7 +12,7 @@ describe("getPackageManager", () => { } `); - expect(getPackageManager("yarn", { workingDirectory: "test/npm" })) + expect(getPackageManager("yarn", { workingDirectory: "src/test/fixtures/npm" })) .toMatchInlineSnapshot(` { "exec": "yarn", @@ -21,7 +21,7 @@ describe("getPackageManager", () => { } `); - expect(getPackageManager("pnpm", { workingDirectory: "test/npm" })) + expect(getPackageManager("pnpm", { workingDirectory: "src/test/fixtures/npm" })) .toMatchInlineSnapshot(` { "exec": "pnpm exec", @@ -30,7 +30,7 @@ describe("getPackageManager", () => { } `); - expect(getPackageManager("bun", { workingDirectory: "test/bun" })) + expect(getPackageManager("bun", { workingDirectory: "src/test/fixtures/bun" })) .toMatchInlineSnapshot(` { "exec": "bunx", @@ -41,7 +41,7 @@ describe("getPackageManager", () => { }); test("should use npm if no value provided and package-lock.json exists", () => { - expect(getPackageManager("", { workingDirectory: "test/npm" })) + expect(getPackageManager("", { workingDirectory: "src/test/fixtures/npm" })) .toMatchInlineSnapshot(` { "exec": "npx", @@ -52,7 +52,7 @@ describe("getPackageManager", () => { }); test("should use yarn if no value provided and yarn.lock exists", () => { - expect(getPackageManager("", { workingDirectory: "test/yarn" })) + expect(getPackageManager("", { workingDirectory: "src/test/fixtures/yarn" })) .toMatchInlineSnapshot(` { "exec": "yarn", @@ -63,7 +63,7 @@ describe("getPackageManager", () => { }); test("should use pnpm if no value provided and pnpm-lock.yaml exists", () => { - expect(getPackageManager("", { workingDirectory: "test/pnpm" })) + expect(getPackageManager("", { workingDirectory: "src/test/fixtures/pnpm" })) .toMatchInlineSnapshot(` { "exec": "pnpm exec", @@ -74,7 +74,7 @@ describe("getPackageManager", () => { }); test("should use bun if no value provided and bun.lockb exists", () => { - expect(getPackageManager("", { workingDirectory: "test/bun" })) + expect(getPackageManager("", { workingDirectory: "src/test/fixtures/bun" })) .toMatchInlineSnapshot(` { "exec": "bunx", @@ -85,7 +85,7 @@ describe("getPackageManager", () => { }); test("should use npm if no value provided and no lockfile is present", () => { - expect(getPackageManager("", { workingDirectory: "test/empty" })) + expect(getPackageManager("", { workingDirectory: "src/test/fixtures/empty" })) .toMatchInlineSnapshot(` { "exec": "npx", @@ -97,7 +97,7 @@ describe("getPackageManager", () => { test("should throw if an invalid value is provided", () => { expect(() => - getPackageManager("cargo", { workingDirectory: "test/npm" }), + getPackageManager("cargo", { workingDirectory: "src/test/fixtures/npm" }), ).toThrowError(); }); }); diff --git a/test/build-quiet/index.ts b/src/test/fixtures/build-quiet/index.ts similarity index 100% rename from test/build-quiet/index.ts rename to src/test/fixtures/build-quiet/index.ts diff --git a/test/build-quiet/package-lock.json b/src/test/fixtures/build-quiet/package-lock.json similarity index 100% rename from test/build-quiet/package-lock.json rename to src/test/fixtures/build-quiet/package-lock.json diff --git a/test/build-quiet/package.json b/src/test/fixtures/build-quiet/package.json similarity index 100% rename from test/build-quiet/package.json rename to src/test/fixtures/build-quiet/package.json diff --git a/test/build-quiet/wrangler.toml b/src/test/fixtures/build-quiet/wrangler.toml similarity index 100% rename from test/build-quiet/wrangler.toml rename to src/test/fixtures/build-quiet/wrangler.toml diff --git a/test/bun/bun.lockb b/src/test/fixtures/bun/bun.lockb similarity index 100% rename from test/bun/bun.lockb rename to src/test/fixtures/bun/bun.lockb diff --git a/test/bun/index.ts b/src/test/fixtures/bun/index.ts similarity index 100% rename from test/bun/index.ts rename to src/test/fixtures/bun/index.ts diff --git a/test/bun/package.json b/src/test/fixtures/bun/package.json similarity index 100% rename from test/bun/package.json rename to src/test/fixtures/bun/package.json diff --git a/test/bun/wrangler.toml b/src/test/fixtures/bun/wrangler.toml similarity index 100% rename from test/bun/wrangler.toml rename to src/test/fixtures/bun/wrangler.toml diff --git a/test/environment/index.ts b/src/test/fixtures/environment/index.ts similarity index 100% rename from test/environment/index.ts rename to src/test/fixtures/environment/index.ts diff --git a/test/environment/package-lock.json b/src/test/fixtures/environment/package-lock.json similarity index 100% rename from test/environment/package-lock.json rename to src/test/fixtures/environment/package-lock.json diff --git a/test/environment/package.json b/src/test/fixtures/environment/package.json similarity index 100% rename from test/environment/package.json rename to src/test/fixtures/environment/package.json diff --git a/test/environment/wrangler.toml b/src/test/fixtures/environment/wrangler.toml similarity index 100% rename from test/environment/wrangler.toml rename to src/test/fixtures/environment/wrangler.toml diff --git a/test/npm/index.ts b/src/test/fixtures/npm/index.ts similarity index 100% rename from test/npm/index.ts rename to src/test/fixtures/npm/index.ts diff --git a/test/npm/package-lock.json b/src/test/fixtures/npm/package-lock.json similarity index 100% rename from test/npm/package-lock.json rename to src/test/fixtures/npm/package-lock.json diff --git a/test/npm/package.json b/src/test/fixtures/npm/package.json similarity index 100% rename from test/npm/package.json rename to src/test/fixtures/npm/package.json diff --git a/test/npm/wrangler.toml b/src/test/fixtures/npm/wrangler.toml similarity index 100% rename from test/npm/wrangler.toml rename to src/test/fixtures/npm/wrangler.toml diff --git a/test/only-build/index.ts b/src/test/fixtures/only-build/index.ts similarity index 100% rename from test/only-build/index.ts rename to src/test/fixtures/only-build/index.ts diff --git a/test/only-build/package-lock.json b/src/test/fixtures/only-build/package-lock.json similarity index 100% rename from test/only-build/package-lock.json rename to src/test/fixtures/only-build/package-lock.json diff --git a/test/only-build/package.json b/src/test/fixtures/only-build/package.json similarity index 100% rename from test/only-build/package.json rename to src/test/fixtures/only-build/package.json diff --git a/test/only-build/wrangler.toml b/src/test/fixtures/only-build/wrangler.toml similarity index 100% rename from test/only-build/wrangler.toml rename to src/test/fixtures/only-build/wrangler.toml diff --git a/test/pnpm/index.ts b/src/test/fixtures/pnpm/index.ts similarity index 100% rename from test/pnpm/index.ts rename to src/test/fixtures/pnpm/index.ts diff --git a/test/pnpm/package.json b/src/test/fixtures/pnpm/package.json similarity index 100% rename from test/pnpm/package.json rename to src/test/fixtures/pnpm/package.json diff --git a/test/pnpm/pnpm-lock.yaml b/src/test/fixtures/pnpm/pnpm-lock.yaml similarity index 100% rename from test/pnpm/pnpm-lock.yaml rename to src/test/fixtures/pnpm/pnpm-lock.yaml diff --git a/test/pnpm/wrangler.toml b/src/test/fixtures/pnpm/wrangler.toml similarity index 100% rename from test/pnpm/wrangler.toml rename to src/test/fixtures/pnpm/wrangler.toml diff --git a/test/pre-installed-wrangler/index.ts b/src/test/fixtures/pre-installed-wrangler/index.ts similarity index 100% rename from test/pre-installed-wrangler/index.ts rename to src/test/fixtures/pre-installed-wrangler/index.ts diff --git a/test/pre-installed-wrangler/mock_packages/wrangler/index.js b/src/test/fixtures/pre-installed-wrangler/mock_packages/wrangler/index.js similarity index 100% rename from test/pre-installed-wrangler/mock_packages/wrangler/index.js rename to src/test/fixtures/pre-installed-wrangler/mock_packages/wrangler/index.js diff --git a/test/pre-installed-wrangler/mock_packages/wrangler/package.json b/src/test/fixtures/pre-installed-wrangler/mock_packages/wrangler/package.json similarity index 100% rename from test/pre-installed-wrangler/mock_packages/wrangler/package.json rename to src/test/fixtures/pre-installed-wrangler/mock_packages/wrangler/package.json diff --git a/test/pre-installed-wrangler/package-lock.json b/src/test/fixtures/pre-installed-wrangler/package-lock.json similarity index 100% rename from test/pre-installed-wrangler/package-lock.json rename to src/test/fixtures/pre-installed-wrangler/package-lock.json diff --git a/test/pre-installed-wrangler/package.json b/src/test/fixtures/pre-installed-wrangler/package.json similarity index 100% rename from test/pre-installed-wrangler/package.json rename to src/test/fixtures/pre-installed-wrangler/package.json diff --git a/test/secrets-default/index.ts b/src/test/fixtures/secrets-default/index.ts similarity index 100% rename from test/secrets-default/index.ts rename to src/test/fixtures/secrets-default/index.ts diff --git a/test/secrets-default/package-lock.json b/src/test/fixtures/secrets-default/package-lock.json similarity index 100% rename from test/secrets-default/package-lock.json rename to src/test/fixtures/secrets-default/package-lock.json diff --git a/test/secrets-default/package.json b/src/test/fixtures/secrets-default/package.json similarity index 100% rename from test/secrets-default/package.json rename to src/test/fixtures/secrets-default/package.json diff --git a/test/secrets-default/wrangler.toml b/src/test/fixtures/secrets-default/wrangler.toml similarity index 100% rename from test/secrets-default/wrangler.toml rename to src/test/fixtures/secrets-default/wrangler.toml diff --git a/test/secrets-v2/index.ts b/src/test/fixtures/secrets-v2/index.ts similarity index 100% rename from test/secrets-v2/index.ts rename to src/test/fixtures/secrets-v2/index.ts diff --git a/test/secrets-v2/package-lock.json b/src/test/fixtures/secrets-v2/package-lock.json similarity index 100% rename from test/secrets-v2/package-lock.json rename to src/test/fixtures/secrets-v2/package-lock.json diff --git a/test/secrets-v2/package.json b/src/test/fixtures/secrets-v2/package.json similarity index 100% rename from test/secrets-v2/package.json rename to src/test/fixtures/secrets-v2/package.json diff --git a/test/secrets-v2/wrangler.toml b/src/test/fixtures/secrets-v2/wrangler.toml similarity index 100% rename from test/secrets-v2/wrangler.toml rename to src/test/fixtures/secrets-v2/wrangler.toml diff --git a/test/specify-package-manager/index.ts b/src/test/fixtures/specify-package-manager/index.ts similarity index 100% rename from test/specify-package-manager/index.ts rename to src/test/fixtures/specify-package-manager/index.ts diff --git a/test/specify-package-manager/package.json b/src/test/fixtures/specify-package-manager/package.json similarity index 100% rename from test/specify-package-manager/package.json rename to src/test/fixtures/specify-package-manager/package.json diff --git a/test/specify-package-manager/wrangler.toml b/src/test/fixtures/specify-package-manager/wrangler.toml similarity index 100% rename from test/specify-package-manager/wrangler.toml rename to src/test/fixtures/specify-package-manager/wrangler.toml diff --git a/test/unspecified-package-manager/index.ts b/src/test/fixtures/unspecified-package-manager/index.ts similarity index 100% rename from test/unspecified-package-manager/index.ts rename to src/test/fixtures/unspecified-package-manager/index.ts diff --git a/test/unspecified-package-manager/package.json b/src/test/fixtures/unspecified-package-manager/package.json similarity index 100% rename from test/unspecified-package-manager/package.json rename to src/test/fixtures/unspecified-package-manager/package.json diff --git a/test/unspecified-package-manager/wrangler.toml b/src/test/fixtures/unspecified-package-manager/wrangler.toml similarity index 100% rename from test/unspecified-package-manager/wrangler.toml rename to src/test/fixtures/unspecified-package-manager/wrangler.toml diff --git a/test/yarn/index.ts b/src/test/fixtures/yarn/index.ts similarity index 100% rename from test/yarn/index.ts rename to src/test/fixtures/yarn/index.ts diff --git a/test/yarn/package.json b/src/test/fixtures/yarn/package.json similarity index 100% rename from test/yarn/package.json rename to src/test/fixtures/yarn/package.json diff --git a/test/yarn/wrangler.toml b/src/test/fixtures/yarn/wrangler.toml similarity index 100% rename from test/yarn/wrangler.toml rename to src/test/fixtures/yarn/wrangler.toml diff --git a/test/yarn/yarn.lock b/src/test/fixtures/yarn/yarn.lock similarity index 100% rename from test/yarn/yarn.lock rename to src/test/fixtures/yarn/yarn.lock diff --git a/src/test/mocks.ts b/src/test/mocks.ts new file mode 100644 index 0000000..bfa20e5 --- /dev/null +++ b/src/test/mocks.ts @@ -0,0 +1,24 @@ +import { http, HttpResponse } from "msw"; + +export function mockGithubDeployments({ + githubUser, + githubRepoName, +}: { + githubUser: string; + githubRepoName: string; +}) { + return { + handlers: [ + http.post( + `https://api.github.com/repos/${githubUser}/${githubRepoName}/deployments`, + async ({ request }) => { + if (request.headers.get("Authorization") === null) { + return HttpResponse.text("error: no auth token", { status: 400 }); + } + + return HttpResponse.json(null); + }, + ), + ], + }; +} diff --git a/src/test/test-utils.ts b/src/test/test-utils.ts new file mode 100644 index 0000000..4b18933 --- /dev/null +++ b/src/test/test-utils.ts @@ -0,0 +1,26 @@ +import { WranglerActionConfig } from "../wranglerAction"; + +export function getTestConfig({ + config = {}, +}: { + config?: Partial; +} = {}): WranglerActionConfig { + return Object.assign( + { + WRANGLER_VERSION: "3.81.0", + didUserProvideWranglerVersion: false, + secrets: [], + workingDirectory: "/src/test/fixtures", + CLOUDFLARE_API_TOKEN: "foo", + CLOUDFLARE_ACCOUNT_ID: "bar", + ENVIRONMENT: "dev", + VARS: [], + COMMANDS: [], + QUIET_MODE: false, + PACKAGE_MANAGER: "npm", + WRANGLER_OUTPUT_DIR: "/tmp/wranglerArtifacts", + GITHUB_TOKEN: "xxxxyy23213123132131", + } as const satisfies WranglerActionConfig, + config, + ); +} diff --git a/src/wranglerAction.test.ts b/src/wranglerAction.test.ts index b3d8c2a..e28f37c 100644 --- a/src/wranglerAction.test.ts +++ b/src/wranglerAction.test.ts @@ -2,6 +2,7 @@ import * as core from "@actions/core"; import * as exec from "@actions/exec"; import { describe, expect, it, vi } from "vitest"; import { installWrangler } from "./wranglerAction"; +import { getTestConfig } from "./test/test-utils"; describe("installWrangler", () => { const testPackageManager = { @@ -11,20 +12,7 @@ describe("installWrangler", () => { }; it("Errors on unsupported wrangler version", async () => { - const testConfig = { - WRANGLER_VERSION: "1", - didUserProvideWranglerVersion: false, - secrets: [], - workingDirectory: "/test", - CLOUDFLARE_API_TOKEN: "foo", - CLOUDFLARE_ACCOUNT_ID: "bar", - ENVIRONMENT: "dev", - VARS: [], - COMMANDS: [], - QUIET_MODE: false, - PACKAGE_MANAGER: "npm", - WRANGLER_OUTPUT_DIR: "/tmp/wranglerArtifacts", - }; + const testConfig = getTestConfig({ config: { WRANGLER_VERSION: "1" } }); await expect( installWrangler(testConfig, testPackageManager), ).rejects.toThrowError( @@ -33,29 +21,14 @@ describe("installWrangler", () => { }); it("Does nothing if no wrangler version is specified and wrangler is already installed", async () => { - const testConfig = { - WRANGLER_VERSION: "3.81.0", - didUserProvideWranglerVersion: false, - secrets: [], - workingDirectory: "/test", - CLOUDFLARE_API_TOKEN: "foo", - CLOUDFLARE_ACCOUNT_ID: "bar", - ENVIRONMENT: "dev", - VARS: [], - COMMANDS: [], - QUIET_MODE: false, - PACKAGE_MANAGER: "npm", - WRANGLER_OUTPUT_DIR: "/tmp/wranglerArtifacts", - }; - vi.spyOn(exec, "getExecOutput").mockImplementation( - async (commandLine: string, args?: string[]) => { - return { - exitCode: 0, - stderr: "", - stdout: ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`, - }; - }, - ); + const testConfig = getTestConfig(); + vi.spyOn(exec, "getExecOutput").mockImplementation(async () => { + return { + exitCode: 0, + stderr: "", + stdout: ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`, + }; + }); const infoSpy = vi.spyOn(core, "info"); await installWrangler(testConfig, testPackageManager); expect(infoSpy).toBeCalledWith( @@ -64,58 +37,38 @@ describe("installWrangler", () => { }); it("Does nothing if the wrangler version specified is the same as the one installed", async () => { - const testConfig = { - WRANGLER_VERSION: "3.48.0", - didUserProvideWranglerVersion: true, - secrets: [], - workingDirectory: "/test", - CLOUDFLARE_API_TOKEN: "foo", - CLOUDFLARE_ACCOUNT_ID: "bar", - ENVIRONMENT: "dev", - VARS: [], - COMMANDS: [], - QUIET_MODE: false, - PACKAGE_MANAGER: "npm", - WRANGLER_OUTPUT_DIR: "/tmp/wranglerArtifacts", - }; - vi.spyOn(exec, "getExecOutput").mockImplementation( - async (commandLine: string, args?: string[]) => { - return { - exitCode: 0, - stderr: "", - stdout: ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`, - }; + const testConfig = getTestConfig({ + config: { + WRANGLER_VERSION: "3.48.0", + didUserProvideWranglerVersion: true, }, - ); + }); + vi.spyOn(exec, "getExecOutput").mockImplementation(async () => { + return { + exitCode: 0, + stderr: "", + stdout: ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`, + }; + }); const infoSpy = vi.spyOn(core, "info"); await installWrangler(testConfig, testPackageManager); expect(infoSpy).toBeCalledWith("✅ Using Wrangler 3.48.0"); }); it("Should install wrangler if the version specified is not already available", async () => { - const testConfig = { - WRANGLER_VERSION: "3.48.0", - didUserProvideWranglerVersion: true, - secrets: [], - workingDirectory: "/test", - CLOUDFLARE_API_TOKEN: "foo", - CLOUDFLARE_ACCOUNT_ID: "bar", - ENVIRONMENT: "dev", - VARS: [], - COMMANDS: [], - QUIET_MODE: false, - PACKAGE_MANAGER: "npm", - WRANGLER_OUTPUT_DIR: "/tmp/wranglerArtifacts", - }; - vi.spyOn(exec, "getExecOutput").mockImplementation( - async (commandLine: string, args?: string[]) => { - return { - exitCode: 0, - stderr: "", - stdout: ` ⛅️ wrangler 3.20.0 (update available 3.53.1)`, - }; + const testConfig = getTestConfig({ + config: { + WRANGLER_VERSION: "3.48.0", + didUserProvideWranglerVersion: true, }, - ); - vi.spyOn(exec, "exec").mockImplementation(async (commandLine: string) => { + }); + vi.spyOn(exec, "getExecOutput").mockImplementation(async () => { + return { + exitCode: 0, + stderr: "", + stdout: ` ⛅️ wrangler 3.20.0 (update available 3.53.1)`, + }; + }); + vi.spyOn(exec, "exec").mockImplementation(async () => { return 0; }); const infoSpy = vi.spyOn(core, "info"); diff --git a/src/wranglerAction.ts b/src/wranglerAction.ts index 59624d3..23ec4ba 100644 --- a/src/wranglerAction.ts +++ b/src/wranglerAction.ts @@ -15,7 +15,7 @@ import { exec, execShell } from "./exec"; import { PackageManager } from "./packageManagers"; import { semverCompare } from "./utils"; import { getDetailedPagesDeployOutput } from "./wranglerArtifactManager"; -import { createGitHubDeployment, createJobSummary } from "./github"; +import { createGitHubDeployment, createJobSummary } from "./service/github"; import { getOctokit } from "@actions/github"; export type WranglerActionConfig = z.infer; @@ -404,8 +404,7 @@ async function wranglerCommands( // Check if this command is a workers deployment if (command.startsWith("deploy") || command.startsWith("publish")) { - const { deploymentUrl } = - extractDeploymentUrlsFromStdout(stdOut); + const { deploymentUrl } = extractDeploymentUrlsFromStdout(stdOut); setOutput("deployment-url", deploymentUrl); } // Check if this command is a pages deployment diff --git a/tsconfig.json b/tsconfig.json index 03e6f29..3a3cb80 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,6 @@ "lib": ["ESNext"], "types": ["node", "@cloudflare/workers-types"] }, - "exclude": ["node_modules", "**/*.test.ts"], + "exclude": ["node_modules"], "include": ["src"] }