@reviewflow/app 0.0.0-stage → 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +21 -2
- package/bin/reviewflow-app.mjs +3 -0
- package/build/index-node.mjs +1455 -0
- package/client/_expo/static/css/global-2bd407ae6bd27d52659beb6c1e7e0a97.css +2 -0
- package/client/_expo/static/css/markdown-editor-c7d01b900dca5674c4231847027038b2.css +1 -0
- package/client/_expo/static/js/web/AppEntry-c2146d447d34648839f59c857db20e98.js +1243 -0
- package/client/_expo/static/js/web/__common-edea2c7718fddaf3a2043fadeabab584.js +84 -0
- package/client/_expo/static/js/web/__expo-metro-runtime-1f8f5d3ca6b7f58204d51e14506d73fb.js +5 -0
- package/client/_expo/static/js/web/abap-769adef5e34cab6671c956ab6d547154.js +1 -0
- package/client/_expo/static/js/web/actionscript-3-b7b82073a4fb91d60ccaa82985313f35.js +1 -0
- package/client/_expo/static/js/web/ada-56f02e5fb550dc451bd17dc7f9bdecfd.js +1 -0
- package/client/_expo/static/js/web/ahk-86707baa6d5a495fa7c3885de5786066.js +1 -0
- package/client/_expo/static/js/web/ahk2-06ba852a3ebd2e71a8d79e805ee7c234.js +1 -0
- package/client/_expo/static/js/web/andromeeda-8258b4411ce6088326ba17be957b1177.js +1 -0
- package/client/_expo/static/js/web/angular-ts-0cbb1ba3aaa05e95401c274a25d340b4.js +3 -0
- package/client/_expo/static/js/web/apache-baf649bc9ad0ea3f9a1f1a806458b9f8.js +1 -0
- package/client/_expo/static/js/web/apex-a9ddc0c307db86d37467a212195c1253.js +1 -0
- package/client/_expo/static/js/web/apl-9d0344bf46ae609aab04bb84df468890.js +1 -0
- package/client/_expo/static/js/web/applescript-cc4af6a5d3647ec21b64cc9ae69f3d7a.js +1 -0
- package/client/_expo/static/js/web/ara-ae4fc6817ded87f92914ef7b37223b62.js +1 -0
- package/client/_expo/static/js/web/asciidoc-3bb3161f3a50a1c7e2cecf470a59d34f.js +1 -0
- package/client/_expo/static/js/web/asm-2a1ff8cabc76a2419ed0213e9c387c2a.js +1 -0
- package/client/_expo/static/js/web/astro-1bc753a5feda558c20a06147e14e62e0.js +1 -0
- package/client/_expo/static/js/web/aurora-x-bdc0740469538665d8c5fd9d7a0133f4.js +1 -0
- package/client/_expo/static/js/web/awk-813723529c4acfb1bfba75a4f341ff65.js +1 -0
- package/client/_expo/static/js/web/ayu-dark-3b6569226dcc93ab6f4e53aff808726c.js +1 -0
- package/client/_expo/static/js/web/ayu-light-91ebd140e7460af0c0f2109b8b79c86a.js +1 -0
- package/client/_expo/static/js/web/ayu-mirage-c2762ebd55aa3e432d05907e607cdb07.js +1 -0
- package/client/_expo/static/js/web/ballerina-ab51ce783269a72a67132203c49ec44e.js +1 -0
- package/client/_expo/static/js/web/beancount-dbc34b83c0cc3c7ce946d4af66ba67a0.js +1 -0
- package/client/_expo/static/js/web/berry-5ba6c68a015f73824da320fa9e12a868.js +1 -0
- package/client/_expo/static/js/web/bicep-c8585f0cbd88acbcd952cce456edbba1.js +1 -0
- package/client/_expo/static/js/web/bird2-72901e2b80e29553aff5fdacd5416ed1.js +1 -0
- package/client/_expo/static/js/web/blade-eeaf31f47667bc2e0b323a69a17f6c16.js +1 -0
- package/client/_expo/static/js/web/bsl-90ed342c7724af4534bc56610e734c83.js +1 -0
- package/client/_expo/static/js/web/c3-7cc2608644ba1a1ef015f7978bb6fa5b.js +1 -0
- package/client/_expo/static/js/web/cadence-74b0a48f10040a5c060b2ef3fe223347.js +1 -0
- package/client/_expo/static/js/web/cairo-ef00974f0dd8dd29d22c736abf4df8ff.js +1 -0
- package/client/_expo/static/js/web/catppuccin-frappe-d702b9345480370d5731f5a5da57b291.js +1 -0
- package/client/_expo/static/js/web/catppuccin-latte-a38f2be62ab340702261b512b4395873.js +1 -0
- package/client/_expo/static/js/web/catppuccin-macchiato-c0bb95a9e7cc63b44708070523c0d380.js +1 -0
- package/client/_expo/static/js/web/catppuccin-mocha-7369531bc8204fd0102e08759ab6bc24.js +1 -0
- package/client/_expo/static/js/web/chapel-39b6a02ba101bc9b18b6527522110f1e.js +1 -0
- package/client/_expo/static/js/web/clarity-d902cf4c81f8171f9705bf053f3f6983.js +1 -0
- package/client/_expo/static/js/web/cobol-93092f11932545e9436668f9448a95b8.js +1 -0
- package/client/_expo/static/js/web/codeowners-4fa4ca3f295a76ee38123852fb5ab3bb.js +1 -0
- package/client/_expo/static/js/web/codeql-3f5ecab83d7a2b30a255fe0079ac9f0b.js +1 -0
- package/client/_expo/static/js/web/common-lisp-9f9faa5b185d2dfc7a8492a673bcfdd9.js +1 -0
- package/client/_expo/static/js/web/coq-3cf85537c4b51a70f8bca8a0b83e09b9.js +1 -0
- package/client/_expo/static/js/web/crystal-2816654ba69407f6307d34dbee6df4fa.js +1 -0
- package/client/_expo/static/js/web/cue-b17d112f30d57eef3e00cd46bb19566c.js +1 -0
- package/client/_expo/static/js/web/cypher-8a728ded3f5d491fff1162b45a84e35c.js +1 -0
- package/client/_expo/static/js/web/d-0cde7b0f83412978f4ee5d52a1dc749f.js +1 -0
- package/client/_expo/static/js/web/dark-plus-76cf5b97f2a662594240309145952d5a.js +1 -0
- package/client/_expo/static/js/web/dax-5edba9509a07fb9150b5ae75f4f60059.js +1 -0
- package/client/_expo/static/js/web/desktop-3e6e3aa72cefc4ec35336c9ec431ab79.js +1 -0
- package/client/_expo/static/js/web/diff-worker-cc5e2731673002d078861f6937705979.js +59 -0
- package/client/_expo/static/js/web/dotenv-c4a6862effea6ce5c9680a5252dd579e.js +1 -0
- package/client/_expo/static/js/web/dracula-89374b0b86a05a19bf875cada55b6d46.js +1 -0
- package/client/_expo/static/js/web/dracula-soft-421f709ee0ff39ac631d59e94b06b00f.js +1 -0
- package/client/_expo/static/js/web/dream-maker-aecf6a9eea27a713aa720bcce56b0e55.js +1 -0
- package/client/_expo/static/js/web/edge-110b22d0629352e10af9ae23ba5d369c.js +1 -0
- package/client/_expo/static/js/web/elm-4635c57528483168a23fd667c54eeb56.js +1 -0
- package/client/_expo/static/js/web/emacs-lisp-aa3d388cb507b40f658c5e9069e9beba.js +1 -0
- package/client/_expo/static/js/web/erb-6fe0d436c64af2f2acccd80764efc8a8.js +1 -0
- package/client/_expo/static/js/web/everforest-dark-63904431ab281916219e2a75c29f1e62.js +1 -0
- package/client/_expo/static/js/web/everforest-light-ed8aab439f424298c1968e7e2bb87856.js +1 -0
- package/client/_expo/static/js/web/fennel-1ad1e7fabe88c381972070f083767758.js +1 -0
- package/client/_expo/static/js/web/fish-35962daa272edd76cc7699504d54d4df.js +1 -0
- package/client/_expo/static/js/web/fluent-6ea67003e6a98f971349bb707a18a2d5.js +1 -0
- package/client/_expo/static/js/web/fortran-fixed-form-f03d92d7ca85272af90d31625d8f84b2.js +1 -0
- package/client/_expo/static/js/web/gdresource-5e08d9e92f133aa5c8d6ccfb71eee4d9.js +1 -0
- package/client/_expo/static/js/web/genie-2381adcf565c170334809784b9133fb1.js +1 -0
- package/client/_expo/static/js/web/gherkin-48a009a1d4c4bbab9860d3fe71ea0cdf.js +1 -0
- package/client/_expo/static/js/web/github-dark-8d8f9728ae76e3ba039ae042d810df42.js +1 -0
- package/client/_expo/static/js/web/github-dark-default-92096de2a0f8ae50d918d6a247498616.js +1 -0
- package/client/_expo/static/js/web/github-dark-dimmed-53cc25f8c227323feeec9f34a687a67c.js +1 -0
- package/client/_expo/static/js/web/github-dark-high-contrast-74f3438e581a5e4ffdafafc56dd712a5.js +1 -0
- package/client/_expo/static/js/web/github-light-5fe9b7c0a7a3026f8286372ee4b61bfb.js +1 -0
- package/client/_expo/static/js/web/github-light-default-db32089ee8cdc865f33610d9b796ab7c.js +1 -0
- package/client/_expo/static/js/web/github-light-high-contrast-076de49429a3ff821bda36e950163521.js +1 -0
- package/client/_expo/static/js/web/gleam-95d68a4f0bd24e7fbe076c950cb99c8f.js +1 -0
- package/client/_expo/static/js/web/glimmer-js-183f0542934f09a5490330b577515c72.js +1 -0
- package/client/_expo/static/js/web/glimmer-ts-6f98f398820b5766e7e77be62d76874f.js +1 -0
- package/client/_expo/static/js/web/gn-5f3cde72a90e0934c65c41bd748af712.js +1 -0
- package/client/_expo/static/js/web/gnuplot-869f41854f3e8c1a922beb4e75acd4d3.js +1 -0
- package/client/_expo/static/js/web/gruvbox-dark-hard-86fe86c4668b7b751191ff0c1ea90f7a.js +1 -0
- package/client/_expo/static/js/web/gruvbox-dark-medium-4f523956ee7b4cdaa29200227370986c.js +1 -0
- package/client/_expo/static/js/web/gruvbox-dark-soft-a79ad82c2438477acb083bc7b1ae5ffb.js +1 -0
- package/client/_expo/static/js/web/gruvbox-light-hard-24e2877be0afd465bf130bae9e76a33b.js +1 -0
- package/client/_expo/static/js/web/gruvbox-light-medium-f5ce9e15f21f6b6374f4c3b29fbdb9be.js +1 -0
- package/client/_expo/static/js/web/gruvbox-light-soft-1304c221207b3b6b4165cfc0dbe76000.js +1 -0
- package/client/_expo/static/js/web/hack-6ffcd55aa688203464d0134f62729dda.js +1 -0
- package/client/_expo/static/js/web/haskell-f27148e5a0837c4fee3868ce15451c04.js +1 -0
- package/client/_expo/static/js/web/hcl-e7812908454b576b10f0471683fa4936.js +1 -0
- package/client/_expo/static/js/web/hjson-f83493107932a6df91fec7c9490546e8.js +1 -0
- package/client/_expo/static/js/web/horizon-93f47699b0622e11aa46b48fbf2c6b67.js +1 -0
- package/client/_expo/static/js/web/horizon-bright-ca884eb660f5187b779e5a84a450877f.js +1 -0
- package/client/_expo/static/js/web/houston-2f73a40d5bed1dee8b3fe252c8fa8056.js +1 -0
- package/client/_expo/static/js/web/http-378dcd80daeb6baac607f67f0a9201a4.js +1 -0
- package/client/_expo/static/js/web/hurl-b21655b7368865e268a3014cb1e4b1b1.js +1 -0
- package/client/_expo/static/js/web/hxml-9cb8ed960b45bc43f7ac81ac76822762.js +1 -0
- package/client/_expo/static/js/web/hy-36f45b3b385511f8bfa6732436405a1c.js +1 -0
- package/client/_expo/static/js/web/imba-0a45ed774d4b8fafe740a84d6ce73d12.js +1 -0
- package/client/_expo/static/js/web/jinja-22511338ca611a1656cac3ba758c7c4a.js +2 -0
- package/client/_expo/static/js/web/jison-f371a06ba690d7c2c1f123c41a20072b.js +1 -0
- package/client/_expo/static/js/web/json5-f1d3d89f6d81a311a719e5804821617f.js +1 -0
- package/client/_expo/static/js/web/jsonl-33699f5027bcaf5f389d93766b0f9371.js +1 -0
- package/client/_expo/static/js/web/jsonnet-e80d1b7d1e12ca38651d2da3b5e6e291.js +1 -0
- package/client/_expo/static/js/web/jssm-387167bacd84c1438f0d90259972cb34.js +1 -0
- package/client/_expo/static/js/web/just-671df0888fd3cb1ab27585abc5a02348.js +1 -0
- package/client/_expo/static/js/web/kanagawa-dragon-af8e47a946c93f68169c833b186da9ad.js +1 -0
- package/client/_expo/static/js/web/kanagawa-lotus-02c311a5335df8170d003bc5632c8365.js +1 -0
- package/client/_expo/static/js/web/kanagawa-wave-76d4634fdade5ec886b4106fdb58d544.js +1 -0
- package/client/_expo/static/js/web/kdl-5494639040937970f1479e2e2f5c8618.js +1 -0
- package/client/_expo/static/js/web/kotlin-414157118aed30d1c79cc221dd1f9e89.js +1 -0
- package/client/_expo/static/js/web/kusto-8038426dd2b14d65bc39e2347969407b.js +1 -0
- package/client/_expo/static/js/web/laserwave-ab499c85292e494ef57f630f6aac5a05.js +1 -0
- package/client/_expo/static/js/web/lean-9f6efeb4b03224ccd752320fd9e2f49e.js +1 -0
- package/client/_expo/static/js/web/light-plus-5e7976265eb1dc30888856f5452d6eb7.js +1 -0
- package/client/_expo/static/js/web/liquid-b5e604a585bd46ed2142a2373835359b.js +1 -0
- package/client/_expo/static/js/web/llvm-382c32cd1ae793bd8e36621b4b5257a8.js +1 -0
- package/client/_expo/static/js/web/logo-b1754a7da7661ad6c0aa0e39a7f00d6e.js +1 -0
- package/client/_expo/static/js/web/luau-efc9907c8454fe09f7f120734c44d1bf.js +1 -0
- package/client/_expo/static/js/web/marko-4d442465d03b8a634f243030d8f01535.js +1 -0
- package/client/_expo/static/js/web/material-theme-b49fb267453c4c2ce2bfa96492dd1e21.js +1 -0
- package/client/_expo/static/js/web/material-theme-darker-1172b69b37d34097bac241cb36b7cc04.js +1 -0
- package/client/_expo/static/js/web/material-theme-lighter-49a34444f6b11fc2ffe3910899fede20.js +1 -0
- package/client/_expo/static/js/web/material-theme-ocean-36bf87771f8883d2d1a173ad7e2bb0dd.js +1 -0
- package/client/_expo/static/js/web/material-theme-palenight-e8df01f0e170ee67a3c91da1a1607c35.js +1 -0
- package/client/_expo/static/js/web/matlab-14575aa28e0f907b622d5cbfeb4674b7.js +1 -0
- package/client/_expo/static/js/web/mdc-70f6c698577151b032a7bf9521427a83.js +1 -0
- package/client/_expo/static/js/web/mdx-091ffb5fdbb044d6af1191897a8c7656.js +1 -0
- package/client/_expo/static/js/web/mermaid-455d0d76a93653051cb56cf15dd40d65.js +1 -0
- package/client/_expo/static/js/web/min-dark-9b48aee498ba4481c6d752393f2b8b99.js +1 -0
- package/client/_expo/static/js/web/min-light-b28ecca546bbfea749ab4d736d5326cf.js +1 -0
- package/client/_expo/static/js/web/mipsasm-5e39c87c3f20d5d346d0147d5b79bd61.js +1 -0
- package/client/_expo/static/js/web/mojo-023c3b96d5d806616efb04c26359998f.js +1 -0
- package/client/_expo/static/js/web/monokai-673abae396dcafc0225ae052a8bb200d.js +1 -0
- package/client/_expo/static/js/web/moonbit-bce17d24b4e5282657b595cfa15648cc.js +1 -0
- package/client/_expo/static/js/web/move-cca76082a912b158b1d642e5b5199c56.js +1 -0
- package/client/_expo/static/js/web/narrat-16747d11d4014b09973d308364d68550.js +1 -0
- package/client/_expo/static/js/web/nextflow-418e67bd0d2a1c15008db5fb8618d505.js +1 -0
- package/client/_expo/static/js/web/nginx-442af891ee03eddfcfae8f648b413870.js +1 -0
- package/client/_expo/static/js/web/night-owl-06b717d3f87dd89ead465c1a3daed461.js +1 -0
- package/client/_expo/static/js/web/night-owl-light-aa060b3526f6ead229ca7bfc5034eb40.js +1 -0
- package/client/_expo/static/js/web/nix-1cee76f90aad55886e805604dac62717.js +2 -0
- package/client/_expo/static/js/web/nord-5079aa1bd2ba9b4c12e3680274d6a8ff.js +1 -0
- package/client/_expo/static/js/web/nsis-00c4e352b0bd096093f1f97418fcf28f.js +1 -0
- package/client/_expo/static/js/web/nushell-ae3b259c7125dfc685150b60c99a6d38.js +1 -0
- package/client/_expo/static/js/web/objective-cpp-dc7eec9f5dd784483073424f07eca3fb.js +1 -0
- package/client/_expo/static/js/web/odin-59882d99ebaffaf049bc51886dd1664c.js +1 -0
- package/client/_expo/static/js/web/one-dark-pro-ec8d19c689af7067ed93aa7be9f6518c.js +1 -0
- package/client/_expo/static/js/web/one-light-a326bc947ee9b389d48e32f4ecaf20d7.js +1 -0
- package/client/_expo/static/js/web/openscad-1db5e83726ac425dc46422f977269fbb.js +1 -0
- package/client/_expo/static/js/web/org-e198afd889aa4d7a4c5af30f81ff2a9b.js +1 -0
- package/client/_expo/static/js/web/pascal-8ced528d3ab6a89a3631963f42c84928.js +1 -0
- package/client/_expo/static/js/web/pierre-dark-fac5b6729b71683c6d36dff29f193362.js +1 -0
- package/client/_expo/static/js/web/pierre-dark-protanopia-deuteranopia-4b0d2ca238867771bcdd17497a522330.js +1 -0
- package/client/_expo/static/js/web/pierre-dark-soft-a26d9ac93cb8cc9c813f90cc773f1aa3.js +1 -0
- package/client/_expo/static/js/web/pierre-dark-tritanopia-e07fb124d79bf06c774431c7d17115b4.js +1 -0
- package/client/_expo/static/js/web/pierre-dark-vibrant-704a64276fa06a11cc7a0b5dad389044.js +1 -0
- package/client/_expo/static/js/web/pierre-light-34894f98c43b9715de2a4ed374c2e230.js +1 -0
- package/client/_expo/static/js/web/pierre-light-protanopia-deuteranopia-a4f3a86a75e6371191b2d4fafeca87de.js +1 -0
- package/client/_expo/static/js/web/pierre-light-soft-cccd20680b781ef907854cae48865b6e.js +1 -0
- package/client/_expo/static/js/web/pierre-light-tritanopia-700508863d04ffdb9b4df487ed80895c.js +1 -0
- package/client/_expo/static/js/web/pierre-light-vibrant-283da5c2c906862630034a48abc24b7a.js +1 -0
- package/client/_expo/static/js/web/pkl-80cc7915560714a43cde8cfd889687b1.js +1 -0
- package/client/_expo/static/js/web/plastic-38a5bd1f3c57cfecb18c3736f4320498.js +1 -0
- package/client/_expo/static/js/web/plsql-5605d62aab704621bd54e427eb39f241.js +1 -0
- package/client/_expo/static/js/web/po-4eaea6020e0daa45dbd45c9cbd51844a.js +1 -0
- package/client/_expo/static/js/web/poimandres-62f704484859f6e27fc78d1457011626.js +1 -0
- package/client/_expo/static/js/web/polar-0c5e78385dbbfe3ca75b54cf54f0a908.js +1 -0
- package/client/_expo/static/js/web/powerquery-746318fcbf4cd1a7aefea9e104d4adb7.js +1 -0
- package/client/_expo/static/js/web/prisma-91a5ae340614d53bf3ac249c16579f2f.js +1 -0
- package/client/_expo/static/js/web/prolog-5e77a3c791e8be999f226d34d7e54038.js +1 -0
- package/client/_expo/static/js/web/proto-82cfc6f1aa9fdc36c7f61ea07c314434.js +1 -0
- package/client/_expo/static/js/web/pull-request-diff-viewer-bac010d11f01f993bebe2fec58ac854c.js +350 -0
- package/client/_expo/static/js/web/puppet-b478e548b158c225f1760bca64a86ee3.js +1 -0
- package/client/_expo/static/js/web/purescript-c11edff58ec320358c7527fb9b6ab7a7.js +1 -0
- package/client/_expo/static/js/web/qml-f589a9c6839eccf3deb07d9aa062bcb7.js +1 -0
- package/client/_expo/static/js/web/qmldir-966f507a3e2eb053344c58a6ec3033f6.js +1 -0
- package/client/_expo/static/js/web/qss-60f8431f5feabeea1cad4442e1ae2447.js +1 -0
- package/client/_expo/static/js/web/racket-30d4736f5b54c7997f04c002205d56f7.js +1 -0
- package/client/_expo/static/js/web/razor-c857aae4fd3930683512cb5354a5fdd9.js +1 -0
- package/client/_expo/static/js/web/rbs-7fb6115a963d0451cd2ebd99ef70ca46.js +1 -0
- package/client/_expo/static/js/web/red-8a92b1997a2b2986b625ac677d43c524.js +1 -0
- package/client/_expo/static/js/web/reg-d4ad14ff1b1730328cb36af6888f71e3.js +1 -0
- package/client/_expo/static/js/web/rel-26d6c58867c48a954e84130f9263a252.js +1 -0
- package/client/_expo/static/js/web/riscv-c2d2f8d6d0de789dbe6abee73b83a725.js +1 -0
- package/client/_expo/static/js/web/ron-b4e0a20ead5cb77418313ab8aa040e05.js +1 -0
- package/client/_expo/static/js/web/rose-pine-dawn-892d15882bad5f528b3bb9059681df56.js +1 -0
- package/client/_expo/static/js/web/rose-pine-f462113a6b561dc53603886c3204ce27.js +1 -0
- package/client/_expo/static/js/web/rose-pine-moon-62647938f3455a7525e8acaf1ffcc59f.js +1 -0
- package/client/_expo/static/js/web/rosmsg-75bbbf19c9b336505a9c8079ed07ae6c.js +1 -0
- package/client/_expo/static/js/web/rst-f3fd7fbb764b14ca3fee357f29327d62.js +1 -0
- package/client/_expo/static/js/web/sas-9203a3f1d1c1f66f509d33d1c13a3d6a.js +1 -0
- package/client/_expo/static/js/web/sass-a6560343ea9861b57126090be08b210a.js +1 -0
- package/client/_expo/static/js/web/scheme-5cd092a32f627b1e6305becf61895c80.js +1 -0
- package/client/_expo/static/js/web/shaderlab-0026275171b288e7cf52656da1658aa6.js +1 -0
- package/client/_expo/static/js/web/shellsession-39a1b543dc344f6be8aa93e432cb65ed.js +1 -0
- package/client/_expo/static/js/web/slack-dark-35d9b5d88ee7904714f81050e02ebe42.js +1 -0
- package/client/_expo/static/js/web/slack-ochin-54a43794047d31260224af78f87f14b1.js +1 -0
- package/client/_expo/static/js/web/smalltalk-aa11d3f66d469dcb3b63a900040d9958.js +1 -0
- package/client/_expo/static/js/web/smithy-d44cb989cc60c86581b3b2d8e46cc88e.js +1 -0
- package/client/_expo/static/js/web/snazzy-light-f9a546ae9548ae72ab7154d375680883.js +1 -0
- package/client/_expo/static/js/web/solarized-dark-14d7b4d7d8d4a90accb3a5d0d9c5408c.js +1 -0
- package/client/_expo/static/js/web/solarized-light-0207b4dee5cb7a84f6c6bffd2c501b83.js +1 -0
- package/client/_expo/static/js/web/solidity-507f91395412ae84052eba9f9c0e2ad4.js +1 -0
- package/client/_expo/static/js/web/soy-361d9d108f535f8b5fbb3725063854b3.js +1 -0
- package/client/_expo/static/js/web/sparql-faf8934698d27b442c98549dbd6ea89f.js +1 -0
- package/client/_expo/static/js/web/splunk-a350d7d4407a4c713a021d4a959fe90f.js +1 -0
- package/client/_expo/static/js/web/ssh-config-2a8d995da684a7ab0a81bca3aaed3568.js +1 -0
- package/client/_expo/static/js/web/stata-eb269e0d1bf893c3753558fb815450a5.js +1 -0
- package/client/_expo/static/js/web/surrealql-c1e466ba490ce683ddb83e5d10515b20.js +1 -0
- package/client/_expo/static/js/web/svelte-0c532a4224f9ca040e2a51ced74a419a.js +1 -0
- package/client/_expo/static/js/web/synthwave-84-aa1f05a883fc69d5c75a71403ab18d75.js +1 -0
- package/client/_expo/static/js/web/systemd-6567da5597d94a8372030f6b49ce7fe2.js +1 -0
- package/client/_expo/static/js/web/talonscript-8ebe80f6d02a7d00590342515dd6fead.js +1 -0
- package/client/_expo/static/js/web/tasl-b50e20457ab7533427874c33b13e8ccc.js +1 -0
- package/client/_expo/static/js/web/tcl-878a99f7dc14a475103f200766cb5478.js +1 -0
- package/client/_expo/static/js/web/templ-12a83656cd0d1a922eab321d179db612.js +1 -0
- package/client/_expo/static/js/web/terraform-c670de87bdeba9f335ff7e94aac99044.js +1 -0
- package/client/_expo/static/js/web/tokyo-night-a7d30c2372c3318449f1b60f605c437f.js +1 -0
- package/client/_expo/static/js/web/toml-3ac514f4d9edf38b023e469fd298e7e8.js +1 -0
- package/client/_expo/static/js/web/ts-tags-331c9d1410f19ce7813877818861020d.js +6 -0
- package/client/_expo/static/js/web/tsv-c1e08a3902330dd31cb08b8695fe1912.js +1 -0
- package/client/_expo/static/js/web/typespec-74b1083d1b2cd47f048086a0fbf1ac8a.js +1 -0
- package/client/_expo/static/js/web/typst-5e6b9cd8887ac15e5300853aa72dbaf7.js +1 -0
- package/client/_expo/static/js/web/v-6cea322409be7ff269aec4cf3cc76066.js +1 -0
- package/client/_expo/static/js/web/vala-2b08d82af850a28f36caf7ca9f664b52.js +1 -0
- package/client/_expo/static/js/web/vesper-0fd33af0a5dbe874cba6f0721b9cec78.js +1 -0
- package/client/_expo/static/js/web/vhdl-5297dce8056f2b679408bcc5ce45a010.js +1 -0
- package/client/_expo/static/js/web/viml-16f5a8516fe0c29ff2f71f5a09096432.js +1 -0
- package/client/_expo/static/js/web/vitesse-black-c80c1a0802c9950709c3a7e9f17db839.js +1 -0
- package/client/_expo/static/js/web/vitesse-dark-ff9e01a7e621f18dafd62e381f9b5e82.js +1 -0
- package/client/_expo/static/js/web/vitesse-light-76bf678edbb2970576a045d09146dddf.js +1 -0
- package/client/_expo/static/js/web/vue-6eaa6fadcd52a8f423fd2df66aa7206a.js +5 -0
- package/client/_expo/static/js/web/vue-html-d9f05710e3ae1dd5986edd7b9e56442c.js +1 -0
- package/client/_expo/static/js/web/vue-vine-46586e45ec94acf1850b5ab85bfa6dfc.js +1 -0
- package/client/_expo/static/js/web/vyper-3b318e2a779fc2260d2ffbb2d89d005d.js +1 -0
- package/client/_expo/static/js/web/wasm-4dbcd0e26afde57dd6c8f95ac22eb479.js +2 -0
- package/client/_expo/static/js/web/wasm-B9ZqxnKj-2becd88758f5fc2a4baf4892deedd634.js +1 -0
- package/client/_expo/static/js/web/wasm-d5f8ac003a6340b522f5ca4abc79e306.js +1 -0
- package/client/_expo/static/js/web/wenyan-87c368e58eab106ea71d9c6a29f1c48e.js +1 -0
- package/client/_expo/static/js/web/wgsl-44c6445a73c51023d7bac7780ca289a7.js +1 -0
- package/client/_expo/static/js/web/wikitext-bccf76de5d350b06d9566eac73ef9ec2.js +1 -0
- package/client/_expo/static/js/web/wit-e300715b0e55ff0ce8b0fe5e0dd6d57d.js +1 -0
- package/client/_expo/static/js/web/wolfram-0e2bbc827b4d4e765d45abcb59029c71.js +1 -0
- package/client/_expo/static/js/web/zenscript-92cdd71e9894e84aef837ccde3926e39.js +1 -0
- package/client/assets/__node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png +0 -0
- package/client/assets/__node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png +0 -0
- package/client/favicon.ico +0 -0
- package/client/index.html +39 -0
- package/client/metadata.json +1 -0
- package/package.json +70 -3
|
@@ -0,0 +1,1455 @@
|
|
|
1
|
+
import { env } from 'node:process';
|
|
2
|
+
import { execFile, spawn, spawnSync } from 'node:child_process';
|
|
3
|
+
import { existsSync, readFileSync, statSync, mkdirSync, chmodSync, writeFileSync, renameSync } from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { join, isAbsolute, dirname, normalize, sep, extname } from 'node:path';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
import { Agent, request } from 'node:https';
|
|
8
|
+
import { createGunzip } from 'node:zlib';
|
|
9
|
+
import { createGitHubTransport, parsePullRequestEdit, fetchPullRequestRevisions, fetchPullRequestCandidates, fetchPullRequestPart, applyPullRequestEdit, createReviewflowFollower, withAccountBoard, applyStreamEvent, createReviewflowClient, readReviewflowStream, readAccountBoards, assembleBoard, isDiffWhitespace, isPullRequestPart } from '@reviewflow/sdk';
|
|
10
|
+
import { createBindingsCache, readReadingOrder, readFileAtSha, readPullRequestDiff, readImpacts } from '@reviewflow/sdk/git';
|
|
11
|
+
import { randomBytes, createCipheriv, createDecipheriv } from 'node:crypto';
|
|
12
|
+
import { createServer } from 'node:http';
|
|
13
|
+
import { readEditableFile, saveEditableFile } from '@reviewflow/sdk/files';
|
|
14
|
+
import { readFile } from 'node:fs/promises';
|
|
15
|
+
|
|
16
|
+
const execFileAsync = promisify(execFile);
|
|
17
|
+
const configHome = () => {
|
|
18
|
+
const override = env.REVIEWFLOW_APP_HOME;
|
|
19
|
+
return override === void 0 || override === "" ? join(homedir(), ".reviewflow-app") : override;
|
|
20
|
+
};
|
|
21
|
+
const configPathOf = (home = configHome()) => join(home, "config.json");
|
|
22
|
+
const readConfigRepos = (configPath) => {
|
|
23
|
+
if (!existsSync(configPath)) return {};
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`${configPath} is not valid json: ${error instanceof Error ? error.message : String(error)}`,
|
|
30
|
+
{ cause: error }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const repos = typeof parsed === "object" && parsed !== null ? parsed.repos : void 0;
|
|
34
|
+
if (repos === void 0) return {};
|
|
35
|
+
if (typeof repos !== "object" || repos === null || Array.isArray(repos)) {
|
|
36
|
+
throw new TypeError(`${configPath}: "repos" must be an object`);
|
|
37
|
+
}
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const [ownerRepo, path] of Object.entries(repos)) {
|
|
40
|
+
if (typeof path !== "string") {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`${configPath}: repos["${ownerRepo}"] must be a path`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
result[ownerRepo] = path;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
const ownerRepoOfRemote = (url) => {
|
|
50
|
+
const match = /^(?:[\w+.-]+:\/\/)?(?:[^@/]+@)?(?:www\.)?github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(
|
|
51
|
+
url.trim()
|
|
52
|
+
);
|
|
53
|
+
return match === null ? null : `${match[1]}/${match[2]}`;
|
|
54
|
+
};
|
|
55
|
+
const readOriginUrl = async (path) => {
|
|
56
|
+
try {
|
|
57
|
+
const { stdout } = await execFileAsync(
|
|
58
|
+
"git",
|
|
59
|
+
["-C", path, "config", "--get", "remote.origin.url"],
|
|
60
|
+
{ timeout: 1e4 }
|
|
61
|
+
);
|
|
62
|
+
return stdout.trim() || null;
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const checkCheckout = async (ownerRepo, path) => {
|
|
68
|
+
let isDirectory = false;
|
|
69
|
+
try {
|
|
70
|
+
isDirectory = statSync(path).isDirectory();
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
if (!isDirectory) return `${path} does not exist or is not a directory`;
|
|
74
|
+
const url = await readOriginUrl(path);
|
|
75
|
+
if (url === null) {
|
|
76
|
+
return `${path} has no remote.origin.url (is it a git checkout?)`;
|
|
77
|
+
}
|
|
78
|
+
const named = ownerRepoOfRemote(url);
|
|
79
|
+
if (named === null || named.toLowerCase() !== ownerRepo.toLowerCase()) {
|
|
80
|
+
return `remote.origin.url of ${path} is ${url}, which does not name ${ownerRepo}`;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
const findPath = (repos, ownerRepo) => {
|
|
85
|
+
const wanted = ownerRepo.toLowerCase();
|
|
86
|
+
const key = Object.keys(repos).find((name) => name.toLowerCase() === wanted);
|
|
87
|
+
return key === void 0 ? null : repos[key] ?? null;
|
|
88
|
+
};
|
|
89
|
+
const resolveCheckout = async (configPath, ownerRepo) => {
|
|
90
|
+
const path = findPath(readConfigRepos(configPath), ownerRepo);
|
|
91
|
+
if (path === null) {
|
|
92
|
+
return {
|
|
93
|
+
refused: {
|
|
94
|
+
reason: "notConfigured",
|
|
95
|
+
ownerRepo,
|
|
96
|
+
configPath,
|
|
97
|
+
detail: `no checkout is configured for ${ownerRepo}`
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const problem = await checkCheckout(ownerRepo, path);
|
|
102
|
+
if (problem !== null) {
|
|
103
|
+
return {
|
|
104
|
+
refused: {
|
|
105
|
+
reason: "invalidPath",
|
|
106
|
+
ownerRepo,
|
|
107
|
+
configPath,
|
|
108
|
+
detail: problem
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return { checkout: path };
|
|
113
|
+
};
|
|
114
|
+
const describeRepoAttachment = async (configPath, ownerRepo) => {
|
|
115
|
+
let resolved;
|
|
116
|
+
try {
|
|
117
|
+
resolved = await resolveCheckout(configPath, ownerRepo);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
ownerRepo,
|
|
121
|
+
status: "notConfigured",
|
|
122
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if ("refused" in resolved) {
|
|
126
|
+
return {
|
|
127
|
+
ownerRepo,
|
|
128
|
+
status: resolved.refused.reason,
|
|
129
|
+
detail: resolved.refused.detail
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return { ownerRepo, status: "attached", detail: resolved.checkout };
|
|
133
|
+
};
|
|
134
|
+
const ownerRepoPattern = /^[^/\s]+\/[^/\s]+$/;
|
|
135
|
+
const validateConfigSource = async (source) => {
|
|
136
|
+
let parsed;
|
|
137
|
+
try {
|
|
138
|
+
parsed = JSON.parse(source);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
error: `not valid json: ${error instanceof Error ? error.message : String(error)}`
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
145
|
+
return { error: 'the file must be a json object: { "repos": { ... } }' };
|
|
146
|
+
}
|
|
147
|
+
const object = parsed;
|
|
148
|
+
const unknownKey = Object.keys(object).find((key) => key !== "repos");
|
|
149
|
+
if (unknownKey !== void 0) {
|
|
150
|
+
return {
|
|
151
|
+
error: `unknown key "${unknownKey}": the only key is "repos"`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const repos = object.repos;
|
|
155
|
+
if (typeof repos !== "object" || repos === null || Array.isArray(repos)) {
|
|
156
|
+
return {
|
|
157
|
+
error: '"repos" must be an object of "owner/repo": "/absolute/path/to/checkout"'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const entries = Object.entries(repos);
|
|
161
|
+
for (const [ownerRepo, path] of entries) {
|
|
162
|
+
if (!ownerRepoPattern.test(ownerRepo)) {
|
|
163
|
+
return {
|
|
164
|
+
error: `repos key "${ownerRepo}" must be owner/repo`
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (typeof path !== "string" || path.trim() === "") {
|
|
168
|
+
return {
|
|
169
|
+
error: `repos["${ownerRepo}"] must be the absolute path of a checkout, as a non-empty string`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (!isAbsolute(path)) {
|
|
173
|
+
return {
|
|
174
|
+
error: `repos["${ownerRepo}"] must be an absolute path, got "${path}"`
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const problems = await Promise.all(
|
|
179
|
+
entries.map(async ([ownerRepo, path]) => {
|
|
180
|
+
const reason = await checkCheckout(ownerRepo, path);
|
|
181
|
+
return reason === null ? null : `${ownerRepo}: ${reason}`;
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
return {
|
|
185
|
+
warnings: problems.filter((problem) => problem !== null)
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
const credentialsPath = (home = configHome()) => join(home, "credentials.json");
|
|
189
|
+
|
|
190
|
+
const timeoutMs$1 = 3e4;
|
|
191
|
+
const apiHost = "api.github.com";
|
|
192
|
+
const ghMissingCode = "ERR_GH_MISSING";
|
|
193
|
+
const fallbackDirectories = ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin"];
|
|
194
|
+
let resolvedGhPath = null;
|
|
195
|
+
const resolveGh = () => {
|
|
196
|
+
if (resolvedGhPath !== null) return resolvedGhPath;
|
|
197
|
+
const override = env.REVIEWFLOW_APP_GH_PATH;
|
|
198
|
+
const candidates = override === void 0 || override === "" ? [
|
|
199
|
+
...env.PATH?.split(":").filter(Boolean) ?? [],
|
|
200
|
+
...fallbackDirectories
|
|
201
|
+
].map((directory) => join(directory, "gh")) : [override];
|
|
202
|
+
for (const candidate of candidates) {
|
|
203
|
+
if (existsSync(candidate)) {
|
|
204
|
+
resolvedGhPath = candidate;
|
|
205
|
+
return candidate;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
throw Object.assign(
|
|
209
|
+
new Error(
|
|
210
|
+
"gh was not found: install the GitHub CLI, or point REVIEWFLOW_APP_GH_PATH at it"
|
|
211
|
+
),
|
|
212
|
+
{ code: ghMissingCode }
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
const firstLine = (text) => text.split("\n", 1)[0]?.trim() ?? "";
|
|
216
|
+
const spawnGh = (args) => new Promise((resolve, reject) => {
|
|
217
|
+
const child = spawn(resolveGh(), args, {
|
|
218
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
219
|
+
});
|
|
220
|
+
let stdout = "";
|
|
221
|
+
let stderr = "";
|
|
222
|
+
const timer = setTimeout(() => {
|
|
223
|
+
child.kill("SIGKILL");
|
|
224
|
+
}, timeoutMs$1);
|
|
225
|
+
child.stdout.setEncoding("utf8");
|
|
226
|
+
child.stderr.setEncoding("utf8");
|
|
227
|
+
child.stdout.on("data", (chunk) => {
|
|
228
|
+
stdout += chunk;
|
|
229
|
+
});
|
|
230
|
+
child.stderr.on("data", (chunk) => {
|
|
231
|
+
stderr += chunk;
|
|
232
|
+
});
|
|
233
|
+
child.on("error", (error) => {
|
|
234
|
+
clearTimeout(timer);
|
|
235
|
+
reject(error);
|
|
236
|
+
});
|
|
237
|
+
child.on("close", (code) => {
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
resolve({ stdout, stderr, code });
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
const readGhToken = async () => {
|
|
243
|
+
const { stdout, stderr, code } = await spawnGh([
|
|
244
|
+
"auth",
|
|
245
|
+
"token",
|
|
246
|
+
"--hostname",
|
|
247
|
+
"github.com"
|
|
248
|
+
]);
|
|
249
|
+
const token = stdout.trim();
|
|
250
|
+
if (code !== 0 || token === "") {
|
|
251
|
+
const detail = firstLine(stderr);
|
|
252
|
+
throw new Error(
|
|
253
|
+
`gh has no GitHub token${detail === "" ? "" : `: ${detail}`}`
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return token;
|
|
257
|
+
};
|
|
258
|
+
const agent = new Agent({ keepAlive: true });
|
|
259
|
+
const sendWithToken = ({ method, path, accept, body }, token) => new Promise((resolve, reject) => {
|
|
260
|
+
const outgoing = request(
|
|
261
|
+
{
|
|
262
|
+
host: apiHost,
|
|
263
|
+
path: `/${path}`,
|
|
264
|
+
method,
|
|
265
|
+
agent,
|
|
266
|
+
signal: AbortSignal.timeout(timeoutMs$1),
|
|
267
|
+
headers: {
|
|
268
|
+
authorization: `bearer ${token}`,
|
|
269
|
+
accept,
|
|
270
|
+
"accept-encoding": "gzip",
|
|
271
|
+
"user-agent": "reviewflow-app",
|
|
272
|
+
"x-github-api-version": "2022-11-28",
|
|
273
|
+
...body === void 0 ? {} : {
|
|
274
|
+
"content-type": "application/json",
|
|
275
|
+
"content-length": Buffer.byteLength(body)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
(incoming) => {
|
|
280
|
+
const stream = incoming.headers["content-encoding"] === "gzip" ? incoming.pipe(createGunzip()) : incoming;
|
|
281
|
+
let text = "";
|
|
282
|
+
stream.setEncoding("utf8");
|
|
283
|
+
stream.on("data", (chunk) => {
|
|
284
|
+
text += chunk;
|
|
285
|
+
});
|
|
286
|
+
stream.on("error", reject);
|
|
287
|
+
stream.on("end", () => {
|
|
288
|
+
resolve({ status: incoming.statusCode ?? 0, body: text });
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
outgoing.on("error", reject);
|
|
293
|
+
outgoing.end(body);
|
|
294
|
+
});
|
|
295
|
+
const unauthorized = 401;
|
|
296
|
+
const createAuthenticatedSend = ({
|
|
297
|
+
readToken,
|
|
298
|
+
sendRaw
|
|
299
|
+
}) => {
|
|
300
|
+
let tokenPromise = null;
|
|
301
|
+
const token = () => {
|
|
302
|
+
tokenPromise ??= readToken().catch((error) => {
|
|
303
|
+
tokenPromise = null;
|
|
304
|
+
throw error;
|
|
305
|
+
});
|
|
306
|
+
return tokenPromise;
|
|
307
|
+
};
|
|
308
|
+
return async (httpRequest) => {
|
|
309
|
+
const answer = await sendRaw(httpRequest, await token());
|
|
310
|
+
if (answer.status !== unauthorized) return answer;
|
|
311
|
+
tokenPromise = null;
|
|
312
|
+
return sendRaw(httpRequest, await token());
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
const createGhTransport = () => createGitHubTransport(
|
|
316
|
+
createAuthenticatedSend({ readToken: readGhToken, sendRaw: sendWithToken })
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
const log = (level, message, fields = {}) => {
|
|
320
|
+
console.log(
|
|
321
|
+
JSON.stringify({
|
|
322
|
+
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
323
|
+
level,
|
|
324
|
+
message,
|
|
325
|
+
...fields
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
330
|
+
|
|
331
|
+
const bindingsCache = createBindingsCache();
|
|
332
|
+
const operations = {
|
|
333
|
+
fetchPullRequestPart,
|
|
334
|
+
fetchPullRequestCandidates,
|
|
335
|
+
fetchPullRequestRevisions,
|
|
336
|
+
parsePullRequestEdit,
|
|
337
|
+
editPullRequest: (transport, request) => applyPullRequestEdit(transport, request, {
|
|
338
|
+
logger: {
|
|
339
|
+
warn: (message, context) => {
|
|
340
|
+
log("warn", message, {
|
|
341
|
+
context: { ...context, error: errorMessage(context.error) }
|
|
342
|
+
});
|
|
343
|
+
},
|
|
344
|
+
error: (message, context) => {
|
|
345
|
+
log("error", message, {
|
|
346
|
+
context: { ...context, error: errorMessage(context.error) }
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}),
|
|
351
|
+
readPullRequestDiff,
|
|
352
|
+
readFileAtSha,
|
|
353
|
+
readReadingOrder,
|
|
354
|
+
readImpacts: (request) => readImpacts({ ...request, cache: bindingsCache })
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const heartbeatMs = 25e3;
|
|
358
|
+
const formatEvent = (event, data) => `event: ${event}
|
|
359
|
+
data: ${JSON.stringify(data)}
|
|
360
|
+
|
|
361
|
+
`;
|
|
362
|
+
const heartbeatFrame = ": heartbeat\n\n";
|
|
363
|
+
const createEventHub = ({
|
|
364
|
+
onCountChanged
|
|
365
|
+
}) => {
|
|
366
|
+
const writers = /* @__PURE__ */ new Set();
|
|
367
|
+
const send = (target, chunk) => {
|
|
368
|
+
try {
|
|
369
|
+
target.write(chunk);
|
|
370
|
+
} catch {
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
return {
|
|
374
|
+
subscribe: (write, initial = []) => {
|
|
375
|
+
const target = { write };
|
|
376
|
+
writers.add(target);
|
|
377
|
+
for (const frame of initial) send(target, frame);
|
|
378
|
+
const timer = setInterval(() => {
|
|
379
|
+
send(target, heartbeatFrame);
|
|
380
|
+
}, heartbeatMs);
|
|
381
|
+
onCountChanged(writers.size);
|
|
382
|
+
let closed = false;
|
|
383
|
+
return () => {
|
|
384
|
+
if (closed) return;
|
|
385
|
+
closed = true;
|
|
386
|
+
clearInterval(timer);
|
|
387
|
+
writers.delete(target);
|
|
388
|
+
onCountChanged(writers.size);
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
broadcast: (event, data) => {
|
|
392
|
+
const frame = formatEvent(event, data);
|
|
393
|
+
for (const target of writers) send(target, frame);
|
|
394
|
+
},
|
|
395
|
+
count: () => writers.size
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const credentialsVersion = 1;
|
|
400
|
+
const credentialKeyBytes = 32;
|
|
401
|
+
const cipherName = "aes-256-gcm";
|
|
402
|
+
const ivBytes = 12;
|
|
403
|
+
const empty = () => ({ version: credentialsVersion });
|
|
404
|
+
const credentialsUnreadableCode = "ERR_CREDENTIALS_UNREADABLE";
|
|
405
|
+
const unreadable = (message) => Object.assign(new Error(message), { code: credentialsUnreadableCode });
|
|
406
|
+
const parseObject = (path, contents) => {
|
|
407
|
+
const document = (() => {
|
|
408
|
+
try {
|
|
409
|
+
return JSON.parse(contents);
|
|
410
|
+
} catch {
|
|
411
|
+
throw unreadable(`${path} is not valid json \u2014 fix or remove it by hand`);
|
|
412
|
+
}
|
|
413
|
+
})();
|
|
414
|
+
if (typeof document !== "object" || document === null || Array.isArray(document)) {
|
|
415
|
+
throw unreadable(`${path} does not hold a json object`);
|
|
416
|
+
}
|
|
417
|
+
return document;
|
|
418
|
+
};
|
|
419
|
+
const toStoredCredentials = (document) => {
|
|
420
|
+
const { version, ...rest } = document;
|
|
421
|
+
return {
|
|
422
|
+
...rest,
|
|
423
|
+
version: typeof version === "number" ? version : credentialsVersion
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
const isEncrypted = (document) => document.encrypted === cipherName;
|
|
427
|
+
const encrypt = (credentials, key) => {
|
|
428
|
+
const iv = randomBytes(ivBytes);
|
|
429
|
+
const cipher = createCipheriv(cipherName, key, iv);
|
|
430
|
+
const data = Buffer.concat([
|
|
431
|
+
cipher.update(JSON.stringify(credentials), "utf8"),
|
|
432
|
+
cipher.final()
|
|
433
|
+
]);
|
|
434
|
+
return {
|
|
435
|
+
encrypted: cipherName,
|
|
436
|
+
iv: iv.toString("base64"),
|
|
437
|
+
tag: cipher.getAuthTag().toString("base64"),
|
|
438
|
+
data: data.toString("base64")
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
const decrypt = (path, document, key) => {
|
|
442
|
+
try {
|
|
443
|
+
const decipher = createDecipheriv(
|
|
444
|
+
cipherName,
|
|
445
|
+
key,
|
|
446
|
+
Buffer.from(document.iv, "base64")
|
|
447
|
+
);
|
|
448
|
+
decipher.setAuthTag(Buffer.from(document.tag, "base64"));
|
|
449
|
+
return Buffer.concat([
|
|
450
|
+
decipher.update(Buffer.from(document.data, "base64")),
|
|
451
|
+
decipher.final()
|
|
452
|
+
]).toString("utf8");
|
|
453
|
+
} catch {
|
|
454
|
+
throw unreadable(
|
|
455
|
+
`${path} does not decrypt with the key in the keychain \u2014 restore the matching key or remove the file by hand`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
const readContents = (path) => {
|
|
460
|
+
try {
|
|
461
|
+
return readFileSync(path, "utf8");
|
|
462
|
+
} catch (error) {
|
|
463
|
+
if (error.code === "ENOENT") return null;
|
|
464
|
+
throw error;
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
const writeDocument = (path, document) => {
|
|
468
|
+
const directory = dirname(path);
|
|
469
|
+
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
470
|
+
chmodSync(directory, 448);
|
|
471
|
+
const temporary = join(directory, `.credentials.${String(process.pid)}.tmp`);
|
|
472
|
+
writeFileSync(temporary, `${JSON.stringify(document, null, 2)}
|
|
473
|
+
`, {
|
|
474
|
+
mode: 384
|
|
475
|
+
});
|
|
476
|
+
chmodSync(temporary, 384);
|
|
477
|
+
renameSync(temporary, path);
|
|
478
|
+
};
|
|
479
|
+
const keyFor = (path, key) => {
|
|
480
|
+
const existing = key.read();
|
|
481
|
+
if (existing) return existing;
|
|
482
|
+
const contents = readContents(path);
|
|
483
|
+
if (contents !== null && isEncrypted(parseObject(path, contents))) {
|
|
484
|
+
throw unreadable(
|
|
485
|
+
`${path} is encrypted but its key is not in the keychain \u2014 restore the key or remove the file by hand`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
return key.create();
|
|
489
|
+
};
|
|
490
|
+
const createFileCredentialStore = (key, path = credentialsPath()) => ({
|
|
491
|
+
read: () => {
|
|
492
|
+
const contents = readContents(path);
|
|
493
|
+
if (contents === null) return empty();
|
|
494
|
+
const document = parseObject(path, contents);
|
|
495
|
+
if (!isEncrypted(document)) {
|
|
496
|
+
const credentials = toStoredCredentials(document);
|
|
497
|
+
try {
|
|
498
|
+
writeDocument(path, encrypt(credentials, keyFor(path, key)));
|
|
499
|
+
} catch (error) {
|
|
500
|
+
log("warn", "could not encrypt the credentials file", {
|
|
501
|
+
path,
|
|
502
|
+
error: errorMessage(error)
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
return credentials;
|
|
506
|
+
}
|
|
507
|
+
return toStoredCredentials(
|
|
508
|
+
parseObject(path, decrypt(path, document, keyFor(path, key)))
|
|
509
|
+
);
|
|
510
|
+
},
|
|
511
|
+
write: (next) => {
|
|
512
|
+
writeDocument(path, encrypt(next, keyFor(path, key)));
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
const securityPath = "/usr/bin/security";
|
|
517
|
+
const itemNotFoundStatus = 44;
|
|
518
|
+
const timeoutMs = 1e4;
|
|
519
|
+
const service = "com.christophehurpeau.reviewflow-app.credentials-key";
|
|
520
|
+
const runSecurity = (args, input) => {
|
|
521
|
+
const result = spawnSync(securityPath, args, {
|
|
522
|
+
encoding: "utf8",
|
|
523
|
+
input,
|
|
524
|
+
timeout: timeoutMs
|
|
525
|
+
});
|
|
526
|
+
if (result.error) throw result.error;
|
|
527
|
+
return result;
|
|
528
|
+
};
|
|
529
|
+
const findSecret = (account) => {
|
|
530
|
+
const { status, stdout, stderr } = runSecurity([
|
|
531
|
+
"find-generic-password",
|
|
532
|
+
"-s",
|
|
533
|
+
service,
|
|
534
|
+
"-a",
|
|
535
|
+
account,
|
|
536
|
+
"-w"
|
|
537
|
+
]);
|
|
538
|
+
if (status === itemNotFoundStatus) return null;
|
|
539
|
+
if (status !== 0) {
|
|
540
|
+
throw new Error(
|
|
541
|
+
`the keychain refused to read the credentials key: ${stderr.trim()}`
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return stdout.trim();
|
|
545
|
+
};
|
|
546
|
+
const addSecret = (account, secret) => {
|
|
547
|
+
if (/["\\\n]/.test(account)) {
|
|
548
|
+
throw new Error(
|
|
549
|
+
`cannot store a credentials key for ${account}: it holds a quote, a backslash or a newline`
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
runSecurity(
|
|
553
|
+
["-i"],
|
|
554
|
+
`add-generic-password -U -s "${service}" -a "${account}" -w ${secret}
|
|
555
|
+
`
|
|
556
|
+
);
|
|
557
|
+
if (findSecret(account) !== secret) {
|
|
558
|
+
throw new Error("the keychain did not store the credentials key");
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
const createKeychainCredentialKey = (account = configHome()) => {
|
|
562
|
+
let cached = null;
|
|
563
|
+
return {
|
|
564
|
+
read: () => {
|
|
565
|
+
if (cached) return cached;
|
|
566
|
+
const secret = findSecret(account);
|
|
567
|
+
if (secret === null) return null;
|
|
568
|
+
const key = Buffer.from(secret, "base64");
|
|
569
|
+
if (key.length !== credentialKeyBytes) {
|
|
570
|
+
throw new Error(
|
|
571
|
+
`the keychain item ${service} for ${account} does not hold a ${String(credentialKeyBytes)}-byte key`
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
cached = key;
|
|
575
|
+
return key;
|
|
576
|
+
},
|
|
577
|
+
create: () => {
|
|
578
|
+
const key = randomBytes(credentialKeyBytes);
|
|
579
|
+
addSecret(account, key.toString("base64"));
|
|
580
|
+
cached = key;
|
|
581
|
+
return key;
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
let instance = null;
|
|
587
|
+
const defaultCredentialStore = () => {
|
|
588
|
+
instance ??= createFileCredentialStore(createKeychainCredentialKey());
|
|
589
|
+
return instance;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const storeFor = (store) => store ?? defaultCredentialStore();
|
|
593
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
594
|
+
const readReviewflowConnection = (store) => {
|
|
595
|
+
const stored = storeFor(store).read().reviewflow;
|
|
596
|
+
if (!isRecord(stored) || typeof stored.url !== "string" || typeof stored.token !== "string" || stored.url === "" || stored.token === "") {
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
599
|
+
return {
|
|
600
|
+
url: stored.url.replace(/\/+$/u, ""),
|
|
601
|
+
token: stored.token,
|
|
602
|
+
login: typeof stored.login === "string" ? stored.login : null,
|
|
603
|
+
accounts: Array.isArray(stored.accounts) ? stored.accounts.filter((a) => typeof a === "string") : [],
|
|
604
|
+
lastVerifiedAt: typeof stored.lastVerifiedAt === "string" ? stored.lastVerifiedAt : null
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
const writeReviewflowConnection = (next, store) => {
|
|
608
|
+
const target = storeFor(store);
|
|
609
|
+
const { reviewflow: _previous, ...document } = target.read();
|
|
610
|
+
target.write(next === null ? document : { ...document, reviewflow: next });
|
|
611
|
+
};
|
|
612
|
+
const loopbackHostnames$1 = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
613
|
+
const normaliseReviewflowUrl = (url) => {
|
|
614
|
+
const parsed = (() => {
|
|
615
|
+
try {
|
|
616
|
+
return new URL(url.trim());
|
|
617
|
+
} catch {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
})();
|
|
621
|
+
if (parsed === null || parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
622
|
+
throw new Error(
|
|
623
|
+
"the reviewflow url is the server's address, e.g. https://reviewflow.example.com"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
if (parsed.protocol === "http:" && !loopbackHostnames$1.has(parsed.hostname)) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
`the reviewflow url must be https: the token would travel in clear text to ${parsed.hostname}`
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
return parsed.origin;
|
|
632
|
+
};
|
|
633
|
+
const withoutToken = (message, token) => token === "" ? message : message.split(token).join("[token]");
|
|
634
|
+
|
|
635
|
+
const tokenRefusedCode = "ERR_REVIEWFLOW_TOKEN_REFUSED";
|
|
636
|
+
const refused = (message) => Object.assign(new Error(message), { code: tokenRefusedCode });
|
|
637
|
+
const createReviewflowService = ({
|
|
638
|
+
store,
|
|
639
|
+
createClient = createReviewflowClient,
|
|
640
|
+
openStream = ({ url, token }, signal) => readReviewflowStream({
|
|
641
|
+
url,
|
|
642
|
+
token,
|
|
643
|
+
signal,
|
|
644
|
+
logger: {
|
|
645
|
+
warn: (message, { error }) => {
|
|
646
|
+
log("warn", message, { error: errorMessage(error) });
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}),
|
|
650
|
+
now = () => /* @__PURE__ */ new Date()
|
|
651
|
+
} = {}) => {
|
|
652
|
+
let snapshot = {};
|
|
653
|
+
let streamError = null;
|
|
654
|
+
let generation = 0;
|
|
655
|
+
let boardRead = null;
|
|
656
|
+
const connection = () => {
|
|
657
|
+
try {
|
|
658
|
+
return { stored: readReviewflowConnection(store), error: null };
|
|
659
|
+
} catch (error) {
|
|
660
|
+
return { stored: null, error: errorMessage(error) };
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
const status = () => {
|
|
664
|
+
const { stored, error } = connection();
|
|
665
|
+
return {
|
|
666
|
+
configured: stored !== null,
|
|
667
|
+
url: stored?.url ?? null,
|
|
668
|
+
login: stored?.login ?? null,
|
|
669
|
+
accounts: stored?.accounts ?? [],
|
|
670
|
+
// oxlint-disable-next-line eslint/no-use-before-define
|
|
671
|
+
stream: stored === null ? "off" : follower.state(),
|
|
672
|
+
error: error ?? streamError
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
const boardResponse = () => {
|
|
676
|
+
const { stored } = connection();
|
|
677
|
+
return assembleBoard(snapshot, stored?.login ?? null, stored?.accounts);
|
|
678
|
+
};
|
|
679
|
+
const hub = createEventHub({
|
|
680
|
+
onCountChanged: (count) => {
|
|
681
|
+
follower.setWatched(count > 0);
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
const emitStatus = () => {
|
|
685
|
+
hub.broadcast("reviewflowStatus", status());
|
|
686
|
+
};
|
|
687
|
+
const emitBoard = () => {
|
|
688
|
+
hub.broadcast("board", boardResponse());
|
|
689
|
+
};
|
|
690
|
+
const follower = createReviewflowFollower({
|
|
691
|
+
connect: () => {
|
|
692
|
+
const { stored } = connection();
|
|
693
|
+
if (stored === null) return null;
|
|
694
|
+
const { url, token } = stored;
|
|
695
|
+
return {
|
|
696
|
+
client: createClient({ url, token }),
|
|
697
|
+
events: (signal) => openStream({ url, token }, signal)
|
|
698
|
+
};
|
|
699
|
+
},
|
|
700
|
+
accounts: () => connection().stored?.accounts ?? [],
|
|
701
|
+
onPr: (pr) => {
|
|
702
|
+
const applied = applyStreamEvent(snapshot, { type: "pr", pr });
|
|
703
|
+
snapshot = applied.snapshot;
|
|
704
|
+
if (applied.changed) emitBoard();
|
|
705
|
+
},
|
|
706
|
+
onPrRemoved: (id) => {
|
|
707
|
+
const applied = applyStreamEvent(snapshot, { type: "prRemoved", id });
|
|
708
|
+
snapshot = applied.snapshot;
|
|
709
|
+
if (applied.changed) emitBoard();
|
|
710
|
+
},
|
|
711
|
+
onAccountBoard: (account, groups) => {
|
|
712
|
+
snapshot = withAccountBoard(snapshot, account, {
|
|
713
|
+
groups,
|
|
714
|
+
fetchedAt: now().toISOString()
|
|
715
|
+
});
|
|
716
|
+
emitBoard();
|
|
717
|
+
},
|
|
718
|
+
onBoardError: (account, message) => {
|
|
719
|
+
log("warn", "reviewflow board read failed", { account, error: message });
|
|
720
|
+
},
|
|
721
|
+
onPullRequestChanged: (change) => {
|
|
722
|
+
hub.broadcast("pullRequestChanged", change);
|
|
723
|
+
},
|
|
724
|
+
onStateChanged: (_state, error) => {
|
|
725
|
+
streamError = error;
|
|
726
|
+
emitStatus();
|
|
727
|
+
},
|
|
728
|
+
onLog: ({ level, message, error, fields }) => {
|
|
729
|
+
log(
|
|
730
|
+
level,
|
|
731
|
+
message,
|
|
732
|
+
error === void 0 ? fields : { ...fields, error: errorMessage(error) }
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
const readBoards = async (readGeneration) => {
|
|
737
|
+
const { stored } = connection();
|
|
738
|
+
if (stored === null) return;
|
|
739
|
+
const client = createClient({ url: stored.url, token: stored.token });
|
|
740
|
+
const read = await readAccountBoards(client, stored.accounts);
|
|
741
|
+
if (readGeneration !== generation) return;
|
|
742
|
+
const fetchedAt = now().toISOString();
|
|
743
|
+
for (const { account, groups } of read.boards) {
|
|
744
|
+
snapshot = withAccountBoard(snapshot, account, { groups, fetchedAt });
|
|
745
|
+
}
|
|
746
|
+
if (read.boards.length === 0 && read.errors.length > 0) {
|
|
747
|
+
throw new Error(
|
|
748
|
+
withoutToken(
|
|
749
|
+
read.errors.map((e) => `${e.account}: ${e.message}`).join("; "),
|
|
750
|
+
stored.token
|
|
751
|
+
)
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
if (read.boards.length > 0) emitBoard();
|
|
755
|
+
};
|
|
756
|
+
return {
|
|
757
|
+
status,
|
|
758
|
+
setToken: async ({ url, token }) => {
|
|
759
|
+
const origin = (() => {
|
|
760
|
+
try {
|
|
761
|
+
return normaliseReviewflowUrl(url);
|
|
762
|
+
} catch (error) {
|
|
763
|
+
throw refused(errorMessage(error));
|
|
764
|
+
}
|
|
765
|
+
})();
|
|
766
|
+
const trimmed = token.trim();
|
|
767
|
+
const me = await createClient({ url: origin, token: trimmed }).me().catch((error) => {
|
|
768
|
+
throw refused(
|
|
769
|
+
`reviewflow refused the token: ${withoutToken(errorMessage(error), trimmed)}`
|
|
770
|
+
);
|
|
771
|
+
});
|
|
772
|
+
generation++;
|
|
773
|
+
writeReviewflowConnection(
|
|
774
|
+
{
|
|
775
|
+
url: origin,
|
|
776
|
+
token: trimmed,
|
|
777
|
+
login: me.login,
|
|
778
|
+
accounts: me.accounts.map((account) => account.login),
|
|
779
|
+
lastVerifiedAt: now().toISOString()
|
|
780
|
+
},
|
|
781
|
+
store
|
|
782
|
+
);
|
|
783
|
+
snapshot = {};
|
|
784
|
+
streamError = null;
|
|
785
|
+
follower.restart();
|
|
786
|
+
emitStatus();
|
|
787
|
+
emitBoard();
|
|
788
|
+
return status();
|
|
789
|
+
},
|
|
790
|
+
clearToken: () => {
|
|
791
|
+
generation++;
|
|
792
|
+
writeReviewflowConnection(null, store);
|
|
793
|
+
snapshot = {};
|
|
794
|
+
streamError = null;
|
|
795
|
+
follower.restart();
|
|
796
|
+
emitStatus();
|
|
797
|
+
emitBoard();
|
|
798
|
+
return status();
|
|
799
|
+
},
|
|
800
|
+
board: async (refresh) => {
|
|
801
|
+
const { stored } = connection();
|
|
802
|
+
const empty = stored !== null && !stored.accounts.some((account) => snapshot[account] !== void 0);
|
|
803
|
+
if (stored !== null && (refresh || empty)) {
|
|
804
|
+
if (boardRead?.generation !== generation) {
|
|
805
|
+
const read = {
|
|
806
|
+
generation,
|
|
807
|
+
done: readBoards(generation).finally(() => {
|
|
808
|
+
if (boardRead === read) boardRead = null;
|
|
809
|
+
})
|
|
810
|
+
};
|
|
811
|
+
boardRead = read;
|
|
812
|
+
}
|
|
813
|
+
await boardRead.done;
|
|
814
|
+
}
|
|
815
|
+
return boardResponse();
|
|
816
|
+
},
|
|
817
|
+
pr: async ({ ownerRepo, number }) => {
|
|
818
|
+
const { stored } = connection();
|
|
819
|
+
if (stored === null) return { pr: null };
|
|
820
|
+
const client = createClient({ url: stored.url, token: stored.token });
|
|
821
|
+
try {
|
|
822
|
+
return { pr: await client.pr(ownerRepo, number) };
|
|
823
|
+
} catch (error) {
|
|
824
|
+
throw new Error(withoutToken(errorMessage(error), stored.token), {
|
|
825
|
+
cause: error
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
subscribe: (write) => hub.subscribe(write, [formatEvent("reviewflowStatus", status())]),
|
|
830
|
+
close: () => {
|
|
831
|
+
follower.close();
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
const bodyTooLargeCode = "ERR_BODY_TOO_LARGE";
|
|
837
|
+
const readBody = async (request, maxBytes = 1024 * 1024) => {
|
|
838
|
+
const chunks = [];
|
|
839
|
+
let size = 0;
|
|
840
|
+
for await (const chunk of request) {
|
|
841
|
+
const buffer = chunk;
|
|
842
|
+
size += buffer.length;
|
|
843
|
+
if (size > maxBytes) {
|
|
844
|
+
request.destroy();
|
|
845
|
+
throw Object.assign(new Error(`body exceeds ${String(maxBytes)} bytes`), {
|
|
846
|
+
code: bodyTooLargeCode
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
chunks.push(buffer);
|
|
850
|
+
}
|
|
851
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
const webappDevPort = 8085;
|
|
855
|
+
const loopbackHostnames = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]", "::1"]);
|
|
856
|
+
const devOrigins = /* @__PURE__ */ new Set([
|
|
857
|
+
`http://127.0.0.1:${String(webappDevPort)}`,
|
|
858
|
+
`http://localhost:${String(webappDevPort)}`
|
|
859
|
+
]);
|
|
860
|
+
const hostnameOf = (host) => {
|
|
861
|
+
const lowered = host.toLowerCase();
|
|
862
|
+
if (lowered.startsWith("[")) {
|
|
863
|
+
const end = lowered.indexOf("]");
|
|
864
|
+
return end === -1 ? lowered : lowered.slice(0, end + 1);
|
|
865
|
+
}
|
|
866
|
+
if (lowered.split(":").length > 2) return lowered;
|
|
867
|
+
const colon = lowered.indexOf(":");
|
|
868
|
+
return colon === -1 ? lowered : lowered.slice(0, colon);
|
|
869
|
+
};
|
|
870
|
+
const crossSiteFetches = /* @__PURE__ */ new Set(["cross-site", "same-site"]);
|
|
871
|
+
const judgeRequest = ({
|
|
872
|
+
host,
|
|
873
|
+
origin,
|
|
874
|
+
secFetchSite,
|
|
875
|
+
api,
|
|
876
|
+
allowDevOrigins
|
|
877
|
+
}) => {
|
|
878
|
+
if (host !== void 0 && !loopbackHostnames.has(hostnameOf(host))) {
|
|
879
|
+
return { allowed: false, reason: `host ${host} is not loopback` };
|
|
880
|
+
}
|
|
881
|
+
if (origin === void 0) {
|
|
882
|
+
if (api && secFetchSite !== void 0 && crossSiteFetches.has(secFetchSite)) {
|
|
883
|
+
return { allowed: false, reason: `a ${secFetchSite} request` };
|
|
884
|
+
}
|
|
885
|
+
return { allowed: true, corsOrigin: null };
|
|
886
|
+
}
|
|
887
|
+
if (host !== void 0 && origin === `http://${host}` || allowDevOrigins && devOrigins.has(origin)) {
|
|
888
|
+
return { allowed: true, corsOrigin: origin };
|
|
889
|
+
}
|
|
890
|
+
return { allowed: false, reason: `origin ${origin} is not allowed` };
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const apiRoutes = {
|
|
894
|
+
configFile: "/api/config/file",
|
|
895
|
+
configRepo: "/api/config/repo",
|
|
896
|
+
prDetail: "/api/prs/detail",
|
|
897
|
+
prCandidates: "/api/prs/candidates",
|
|
898
|
+
prRevisions: "/api/prs/revisions",
|
|
899
|
+
prEdit: "/api/prs/edit",
|
|
900
|
+
prDiff: "/api/prs/diff",
|
|
901
|
+
prFile: "/api/prs/file",
|
|
902
|
+
prReadingOrder: "/api/prs/reading-order",
|
|
903
|
+
prImpacts: "/api/prs/impacts",
|
|
904
|
+
reviewflowStatus: "/api/reviewflow/status",
|
|
905
|
+
reviewflowToken: "/api/reviewflow/token",
|
|
906
|
+
reviewflowBoard: "/api/reviewflow/board",
|
|
907
|
+
reviewflowPr: "/api/reviewflow/pr",
|
|
908
|
+
events: "/api/events"
|
|
909
|
+
};
|
|
910
|
+
const ok = (body) => ({ status: 200, body });
|
|
911
|
+
const bad = (error) => ({ status: 400, body: { error } });
|
|
912
|
+
const notAllowed = () => ({
|
|
913
|
+
status: 405,
|
|
914
|
+
body: { error: "method not allowed" }
|
|
915
|
+
});
|
|
916
|
+
const pullRequestRefOf = (ownerRepo, number) => {
|
|
917
|
+
if (typeof ownerRepo !== "string" || !/^[^/\s]+\/[^/\s]+$/.test(ownerRepo)) {
|
|
918
|
+
return "repo must be owner/repo";
|
|
919
|
+
}
|
|
920
|
+
if (typeof number !== "number" || !Number.isInteger(number) || number < 1) {
|
|
921
|
+
return "number must be a pull request number";
|
|
922
|
+
}
|
|
923
|
+
return { ownerRepo, number };
|
|
924
|
+
};
|
|
925
|
+
const isSha = (value) => /^[\da-f]{40}$/i.test(value);
|
|
926
|
+
const readRef = (request) => {
|
|
927
|
+
const ref = pullRequestRefOf(
|
|
928
|
+
request.query.get("repo"),
|
|
929
|
+
Number(request.query.get("number") ?? "")
|
|
930
|
+
);
|
|
931
|
+
return typeof ref === "string" ? bad(ref) : { ref };
|
|
932
|
+
};
|
|
933
|
+
const isAnswer = (value) => "status" in value;
|
|
934
|
+
const handleConfigFile = async ({ configPath }, request) => {
|
|
935
|
+
if (request.method === "GET") {
|
|
936
|
+
return ok({ path: configPath, ...readEditableFile(configPath) });
|
|
937
|
+
}
|
|
938
|
+
if (request.method !== "PUT") return notAllowed();
|
|
939
|
+
const payload = await request.readJson();
|
|
940
|
+
if (typeof payload?.source !== "string") {
|
|
941
|
+
return bad("source must be a string");
|
|
942
|
+
}
|
|
943
|
+
if (typeof payload.expectedSource !== "string") {
|
|
944
|
+
return bad("expectedSource must be the text the editor opened on");
|
|
945
|
+
}
|
|
946
|
+
const result = await saveEditableFile({
|
|
947
|
+
path: configPath,
|
|
948
|
+
source: payload.source,
|
|
949
|
+
expectedSource: payload.expectedSource,
|
|
950
|
+
validate: validateConfigSource
|
|
951
|
+
});
|
|
952
|
+
if (result.status === "invalid") return bad(result.error);
|
|
953
|
+
if (result.status === "conflict") {
|
|
954
|
+
return { status: 409, body: { conflict: { source: result.source } } };
|
|
955
|
+
}
|
|
956
|
+
return ok({
|
|
957
|
+
path: configPath,
|
|
958
|
+
source: result.source,
|
|
959
|
+
exists: true,
|
|
960
|
+
warnings: result.warnings
|
|
961
|
+
});
|
|
962
|
+
};
|
|
963
|
+
const handleConfigRepo = async ({ configPath }, request) => {
|
|
964
|
+
if (request.method !== "GET") return notAllowed();
|
|
965
|
+
const repo = request.query.get("repo") ?? "";
|
|
966
|
+
if (!/^[^/\s]+\/[^/\s]+$/.test(repo)) return bad("repo must be owner/repo");
|
|
967
|
+
return ok(await describeRepoAttachment(configPath, repo));
|
|
968
|
+
};
|
|
969
|
+
const handlePrDetail = async ({ transport, operations }, request) => {
|
|
970
|
+
if (request.method !== "GET") return notAllowed();
|
|
971
|
+
const read = readRef(request);
|
|
972
|
+
if (isAnswer(read)) return read;
|
|
973
|
+
const part = request.query.get("part");
|
|
974
|
+
if (!isPullRequestPart(part)) return bad(`unknown part ${String(part)}`);
|
|
975
|
+
return ok(await operations.fetchPullRequestPart(transport, read.ref, part));
|
|
976
|
+
};
|
|
977
|
+
const handlePrCandidates = async ({ transport, operations }, request) => {
|
|
978
|
+
if (request.method !== "GET") return notAllowed();
|
|
979
|
+
const read = readRef(request);
|
|
980
|
+
if (isAnswer(read)) return read;
|
|
981
|
+
return ok(await operations.fetchPullRequestCandidates(transport, read.ref));
|
|
982
|
+
};
|
|
983
|
+
const handlePrRevisions = async ({ transport, operations }, request) => {
|
|
984
|
+
if (request.method !== "GET") return notAllowed();
|
|
985
|
+
const read = readRef(request);
|
|
986
|
+
if (isAnswer(read)) return read;
|
|
987
|
+
const subjectId = request.query.get("subject") ?? "";
|
|
988
|
+
if (subjectId === "") return bad("subject must be a node id");
|
|
989
|
+
return ok(await operations.fetchPullRequestRevisions(transport, subjectId));
|
|
990
|
+
};
|
|
991
|
+
const handlePrEdit = async ({ transport, operations }, request) => {
|
|
992
|
+
if (request.method !== "POST") return notAllowed();
|
|
993
|
+
const payload = await request.readJson();
|
|
994
|
+
const ref = pullRequestRefOf(payload?.ownerRepo, payload?.number);
|
|
995
|
+
if (typeof ref === "string") return bad(ref);
|
|
996
|
+
const edit = operations.parsePullRequestEdit(payload?.edit);
|
|
997
|
+
if (typeof edit === "string") return bad(edit);
|
|
998
|
+
const followUpError = await operations.editPullRequest(transport, {
|
|
999
|
+
...ref,
|
|
1000
|
+
edit
|
|
1001
|
+
});
|
|
1002
|
+
const body = { edited: edit.kind, followUpError };
|
|
1003
|
+
return ok(body);
|
|
1004
|
+
};
|
|
1005
|
+
async function* streamLines(run) {
|
|
1006
|
+
const pending = [];
|
|
1007
|
+
const state = {
|
|
1008
|
+
finished: false,
|
|
1009
|
+
wake: null
|
|
1010
|
+
};
|
|
1011
|
+
const notify = () => {
|
|
1012
|
+
state.wake?.();
|
|
1013
|
+
state.wake = null;
|
|
1014
|
+
};
|
|
1015
|
+
const task = run((step) => {
|
|
1016
|
+
pending.push({ step });
|
|
1017
|
+
notify();
|
|
1018
|
+
}).then(
|
|
1019
|
+
(last) => {
|
|
1020
|
+
pending.push(last);
|
|
1021
|
+
},
|
|
1022
|
+
(error) => {
|
|
1023
|
+
pending.push({ error: errorMessage(error) });
|
|
1024
|
+
}
|
|
1025
|
+
).finally(() => {
|
|
1026
|
+
state.finished = true;
|
|
1027
|
+
notify();
|
|
1028
|
+
});
|
|
1029
|
+
for (; ; ) {
|
|
1030
|
+
while (pending.length > 0) yield pending.shift();
|
|
1031
|
+
if (state.finished) break;
|
|
1032
|
+
await new Promise((resolve) => {
|
|
1033
|
+
state.wake = resolve;
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
await task;
|
|
1037
|
+
}
|
|
1038
|
+
const handlePrDiff = async ({ transport, operations, configPath }, request) => {
|
|
1039
|
+
if (request.method !== "GET") return notAllowed();
|
|
1040
|
+
const read = readRef(request);
|
|
1041
|
+
if (isAnswer(read)) return read;
|
|
1042
|
+
const { ref } = read;
|
|
1043
|
+
const whitespace = request.query.get("whitespace") ?? "show";
|
|
1044
|
+
if (!isDiffWhitespace(whitespace)) {
|
|
1045
|
+
return bad("whitespace must be hide or show");
|
|
1046
|
+
}
|
|
1047
|
+
const head = request.query.get("head") ?? "";
|
|
1048
|
+
const base = request.query.get("base") ?? "";
|
|
1049
|
+
if (!isSha(head) || !isSha(base)) {
|
|
1050
|
+
return bad("head and base must be commit shas");
|
|
1051
|
+
}
|
|
1052
|
+
const resolved = await resolveCheckout(configPath, ref.ownerRepo);
|
|
1053
|
+
if ("refused" in resolved) {
|
|
1054
|
+
return request.query.get("stream") === "1" ? {
|
|
1055
|
+
status: 200,
|
|
1056
|
+
body: null,
|
|
1057
|
+
lines: streamLines(() => Promise.resolve(resolved))
|
|
1058
|
+
} : ok(resolved);
|
|
1059
|
+
}
|
|
1060
|
+
const readDiff = (onStep) => operations.readPullRequestDiff({
|
|
1061
|
+
checkout: resolved.checkout,
|
|
1062
|
+
transport,
|
|
1063
|
+
ref,
|
|
1064
|
+
head,
|
|
1065
|
+
base,
|
|
1066
|
+
whitespace,
|
|
1067
|
+
...onStep === void 0 ? {} : { onStep },
|
|
1068
|
+
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
1069
|
+
});
|
|
1070
|
+
if (request.query.get("stream") === "1") {
|
|
1071
|
+
return {
|
|
1072
|
+
status: 200,
|
|
1073
|
+
body: null,
|
|
1074
|
+
lines: streamLines(async (onStep) => ({
|
|
1075
|
+
result: await readDiff(onStep)
|
|
1076
|
+
}))
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
return ok(await readDiff());
|
|
1080
|
+
};
|
|
1081
|
+
const handlePrFile = async ({ operations, configPath }, request) => {
|
|
1082
|
+
if (request.method !== "GET") return notAllowed();
|
|
1083
|
+
const read = readRef(request);
|
|
1084
|
+
if (isAnswer(read)) return read;
|
|
1085
|
+
const sha = request.query.get("sha") ?? "";
|
|
1086
|
+
const path = request.query.get("path") ?? "";
|
|
1087
|
+
if (!isSha(sha)) return bad("sha must be a commit sha");
|
|
1088
|
+
if (path === "") return bad("path is required");
|
|
1089
|
+
const resolved = await resolveCheckout(configPath, read.ref.ownerRepo);
|
|
1090
|
+
if ("refused" in resolved) return bad(resolved.refused.detail);
|
|
1091
|
+
const body = {
|
|
1092
|
+
contents: await operations.readFileAtSha(resolved.checkout, sha, path)
|
|
1093
|
+
};
|
|
1094
|
+
return ok(body);
|
|
1095
|
+
};
|
|
1096
|
+
const handlePrReadingOrder = async ({ operations, configPath }, request) => {
|
|
1097
|
+
if (request.method !== "GET") return notAllowed();
|
|
1098
|
+
const read = readRef(request);
|
|
1099
|
+
if (isAnswer(read)) return read;
|
|
1100
|
+
const head = request.query.get("head") ?? "";
|
|
1101
|
+
const base = request.query.get("base") ?? "";
|
|
1102
|
+
if (!isSha(head) || !isSha(base)) {
|
|
1103
|
+
return bad("head and base must be commit shas");
|
|
1104
|
+
}
|
|
1105
|
+
const resolved = await resolveCheckout(configPath, read.ref.ownerRepo);
|
|
1106
|
+
if ("refused" in resolved) return ok(resolved);
|
|
1107
|
+
return ok(
|
|
1108
|
+
await operations.readReadingOrder({
|
|
1109
|
+
checkout: resolved.checkout,
|
|
1110
|
+
head,
|
|
1111
|
+
base
|
|
1112
|
+
})
|
|
1113
|
+
);
|
|
1114
|
+
};
|
|
1115
|
+
const handlePrImpacts = async ({ operations, configPath }, request) => {
|
|
1116
|
+
if (request.method !== "GET") return notAllowed();
|
|
1117
|
+
const read = readRef(request);
|
|
1118
|
+
if (isAnswer(read)) return read;
|
|
1119
|
+
const head = request.query.get("head") ?? "";
|
|
1120
|
+
const base = request.query.get("base") ?? "";
|
|
1121
|
+
if (!isSha(head) || !isSha(base)) {
|
|
1122
|
+
return bad("head and base must be commit shas");
|
|
1123
|
+
}
|
|
1124
|
+
const resolved = await resolveCheckout(configPath, read.ref.ownerRepo);
|
|
1125
|
+
if ("refused" in resolved) return ok(resolved);
|
|
1126
|
+
return ok(
|
|
1127
|
+
await operations.readImpacts({
|
|
1128
|
+
checkout: resolved.checkout,
|
|
1129
|
+
head,
|
|
1130
|
+
base
|
|
1131
|
+
})
|
|
1132
|
+
);
|
|
1133
|
+
};
|
|
1134
|
+
const handleReviewflowStatus = ({ reviewflow }, request) => Promise.resolve(
|
|
1135
|
+
request.method === "GET" ? ok(reviewflow.status()) : notAllowed()
|
|
1136
|
+
);
|
|
1137
|
+
const credentialsFailure = (error) => error.code === credentialsUnreadableCode ? { status: 409, body: { error: errorMessage(error) } } : null;
|
|
1138
|
+
const handleReviewflowToken = async ({ reviewflow }, request) => {
|
|
1139
|
+
try {
|
|
1140
|
+
if (request.method === "DELETE") return ok(reviewflow.clearToken());
|
|
1141
|
+
if (request.method !== "PUT") return notAllowed();
|
|
1142
|
+
const payload = await request.readJson();
|
|
1143
|
+
if (typeof payload?.url !== "string" || payload.url.trim() === "") {
|
|
1144
|
+
return bad("url is required");
|
|
1145
|
+
}
|
|
1146
|
+
if (typeof payload.token !== "string" || payload.token.trim() === "") {
|
|
1147
|
+
return bad("token must be a non-empty string");
|
|
1148
|
+
}
|
|
1149
|
+
return ok(
|
|
1150
|
+
await reviewflow.setToken({ url: payload.url, token: payload.token })
|
|
1151
|
+
);
|
|
1152
|
+
} catch (error) {
|
|
1153
|
+
if (error.code === tokenRefusedCode) {
|
|
1154
|
+
return bad(errorMessage(error));
|
|
1155
|
+
}
|
|
1156
|
+
const failure = credentialsFailure(error);
|
|
1157
|
+
if (failure !== null) return failure;
|
|
1158
|
+
throw error;
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const handleReviewflowBoard = async ({ reviewflow }, request) => {
|
|
1162
|
+
if (request.method !== "GET") return notAllowed();
|
|
1163
|
+
try {
|
|
1164
|
+
return ok(await reviewflow.board(request.query.get("refresh") === "1"));
|
|
1165
|
+
} catch (error) {
|
|
1166
|
+
return credentialsFailure(error) ?? {
|
|
1167
|
+
status: 502,
|
|
1168
|
+
body: { error: errorMessage(error) }
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
const handleReviewflowPr = async ({ reviewflow }, request) => {
|
|
1173
|
+
if (request.method !== "GET") return notAllowed();
|
|
1174
|
+
const read = readRef(request);
|
|
1175
|
+
if (isAnswer(read)) return read;
|
|
1176
|
+
try {
|
|
1177
|
+
return ok(await reviewflow.pr(read.ref));
|
|
1178
|
+
} catch (error) {
|
|
1179
|
+
return credentialsFailure(error) ?? {
|
|
1180
|
+
status: 502,
|
|
1181
|
+
body: { error: errorMessage(error) }
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
const handleEvents = ({ reviewflow }, request) => Promise.resolve(
|
|
1186
|
+
request.method === "GET" ? { status: 200, body: null, events: reviewflow.subscribe } : notAllowed()
|
|
1187
|
+
);
|
|
1188
|
+
const handlers = {
|
|
1189
|
+
[apiRoutes.configFile]: handleConfigFile,
|
|
1190
|
+
[apiRoutes.configRepo]: handleConfigRepo,
|
|
1191
|
+
[apiRoutes.prDetail]: handlePrDetail,
|
|
1192
|
+
[apiRoutes.prCandidates]: handlePrCandidates,
|
|
1193
|
+
[apiRoutes.prRevisions]: handlePrRevisions,
|
|
1194
|
+
[apiRoutes.prEdit]: handlePrEdit,
|
|
1195
|
+
[apiRoutes.prDiff]: handlePrDiff,
|
|
1196
|
+
[apiRoutes.prFile]: handlePrFile,
|
|
1197
|
+
[apiRoutes.prReadingOrder]: handlePrReadingOrder,
|
|
1198
|
+
[apiRoutes.prImpacts]: handlePrImpacts,
|
|
1199
|
+
[apiRoutes.reviewflowStatus]: handleReviewflowStatus,
|
|
1200
|
+
[apiRoutes.reviewflowToken]: handleReviewflowToken,
|
|
1201
|
+
[apiRoutes.reviewflowBoard]: handleReviewflowBoard,
|
|
1202
|
+
[apiRoutes.reviewflowPr]: handleReviewflowPr,
|
|
1203
|
+
[apiRoutes.events]: handleEvents
|
|
1204
|
+
};
|
|
1205
|
+
const routeApiRequest = (deps, request) => {
|
|
1206
|
+
if (!Object.hasOwn(handlers, request.pathname)) return null;
|
|
1207
|
+
return handlers[request.pathname](deps, request);
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
const packagedDistDirectory = join(import.meta.dirname, "..", "client");
|
|
1211
|
+
const workspaceDistDirectory = join(
|
|
1212
|
+
import.meta.dirname,
|
|
1213
|
+
"..",
|
|
1214
|
+
"..",
|
|
1215
|
+
"app-expo",
|
|
1216
|
+
"dist"
|
|
1217
|
+
);
|
|
1218
|
+
const defaultDistDirectory = existsSync(
|
|
1219
|
+
join(packagedDistDirectory, "index.html")
|
|
1220
|
+
) ? packagedDistDirectory : workspaceDistDirectory;
|
|
1221
|
+
const noAppMessage = "reviewflow app: no exported expo app found.\nRun it in dev with: pnpm --filter @reviewflow/app-expo run start\nor export it (pnpm --filter @reviewflow/app-expo run build) so packages/app-expo/dist exists.\n";
|
|
1222
|
+
const contentTypes = {
|
|
1223
|
+
".html": "text/html; charset=utf-8",
|
|
1224
|
+
".js": "text/javascript; charset=utf-8",
|
|
1225
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
1226
|
+
".css": "text/css; charset=utf-8",
|
|
1227
|
+
".json": "application/json; charset=utf-8",
|
|
1228
|
+
".map": "application/json; charset=utf-8",
|
|
1229
|
+
".svg": "image/svg+xml",
|
|
1230
|
+
".png": "image/png",
|
|
1231
|
+
".jpg": "image/jpeg",
|
|
1232
|
+
".jpeg": "image/jpeg",
|
|
1233
|
+
".gif": "image/gif",
|
|
1234
|
+
".ico": "image/x-icon",
|
|
1235
|
+
".webp": "image/webp",
|
|
1236
|
+
".woff": "font/woff",
|
|
1237
|
+
".woff2": "font/woff2",
|
|
1238
|
+
".ttf": "font/ttf",
|
|
1239
|
+
".txt": "text/plain; charset=utf-8",
|
|
1240
|
+
".wasm": "application/wasm"
|
|
1241
|
+
};
|
|
1242
|
+
const isFile = (path) => {
|
|
1243
|
+
try {
|
|
1244
|
+
return statSync(path).isFile();
|
|
1245
|
+
} catch {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
const notFound = () => ({
|
|
1250
|
+
status: 404,
|
|
1251
|
+
contentType: "text/plain; charset=utf-8",
|
|
1252
|
+
body: "not found\n"
|
|
1253
|
+
});
|
|
1254
|
+
const serveStatic = async (distDirectory, pathname) => {
|
|
1255
|
+
if (!existsSync(join(distDirectory, "index.html"))) {
|
|
1256
|
+
return {
|
|
1257
|
+
status: 200,
|
|
1258
|
+
contentType: "text/plain; charset=utf-8",
|
|
1259
|
+
body: noAppMessage
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
let decoded;
|
|
1263
|
+
try {
|
|
1264
|
+
decoded = decodeURIComponent(pathname);
|
|
1265
|
+
} catch {
|
|
1266
|
+
return notFound();
|
|
1267
|
+
}
|
|
1268
|
+
const target = normalize(join(distDirectory, decoded));
|
|
1269
|
+
if (target !== distDirectory && !target.startsWith(distDirectory + sep)) {
|
|
1270
|
+
return notFound();
|
|
1271
|
+
}
|
|
1272
|
+
let file = target;
|
|
1273
|
+
if (!isFile(target)) {
|
|
1274
|
+
if (extname(decoded) !== "") return notFound();
|
|
1275
|
+
file = join(distDirectory, "index.html");
|
|
1276
|
+
}
|
|
1277
|
+
return {
|
|
1278
|
+
status: 200,
|
|
1279
|
+
contentType: contentTypes[extname(file).toLowerCase()] ?? "application/octet-stream",
|
|
1280
|
+
body: await readFile(file)
|
|
1281
|
+
};
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
const preflightMaxAgeSeconds = 600;
|
|
1285
|
+
const writeJson = (response, status, body) => {
|
|
1286
|
+
response.writeHead(status, {
|
|
1287
|
+
"content-type": "application/json; charset=utf-8"
|
|
1288
|
+
});
|
|
1289
|
+
response.end(JSON.stringify(body));
|
|
1290
|
+
};
|
|
1291
|
+
const handleRequest = async (options, request, response) => {
|
|
1292
|
+
const method = request.method ?? "GET";
|
|
1293
|
+
const url = new URL(request.url ?? "/", "http://localhost");
|
|
1294
|
+
const secFetchSite = request.headers["sec-fetch-site"];
|
|
1295
|
+
const verdict = judgeRequest({
|
|
1296
|
+
host: request.headers.host,
|
|
1297
|
+
origin: request.headers.origin,
|
|
1298
|
+
secFetchSite: typeof secFetchSite === "string" ? secFetchSite : void 0,
|
|
1299
|
+
api: url.pathname.startsWith("/api/"),
|
|
1300
|
+
allowDevOrigins: options.allowDevOrigins === true
|
|
1301
|
+
});
|
|
1302
|
+
if (!verdict.allowed) {
|
|
1303
|
+
log("warn", "request refused", {
|
|
1304
|
+
method,
|
|
1305
|
+
path: url.pathname,
|
|
1306
|
+
reason: verdict.reason
|
|
1307
|
+
});
|
|
1308
|
+
writeJson(response, 403, { error: verdict.reason });
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
if (verdict.corsOrigin !== null) {
|
|
1312
|
+
response.setHeader("access-control-allow-origin", verdict.corsOrigin);
|
|
1313
|
+
response.setHeader("vary", "origin");
|
|
1314
|
+
}
|
|
1315
|
+
if (method === "OPTIONS") {
|
|
1316
|
+
response.writeHead(204, {
|
|
1317
|
+
"access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
1318
|
+
"access-control-allow-headers": "content-type",
|
|
1319
|
+
"access-control-max-age": String(preflightMaxAgeSeconds)
|
|
1320
|
+
});
|
|
1321
|
+
response.end();
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
const clientGone = new AbortController();
|
|
1325
|
+
response.on("close", () => {
|
|
1326
|
+
if (!response.writableFinished) clientGone.abort();
|
|
1327
|
+
});
|
|
1328
|
+
try {
|
|
1329
|
+
const routed = routeApiRequest(options, {
|
|
1330
|
+
method,
|
|
1331
|
+
pathname: url.pathname,
|
|
1332
|
+
query: url.searchParams,
|
|
1333
|
+
signal: clientGone.signal,
|
|
1334
|
+
readJson: async () => {
|
|
1335
|
+
try {
|
|
1336
|
+
return JSON.parse(await readBody(request));
|
|
1337
|
+
} catch (error) {
|
|
1338
|
+
if (error.code === bodyTooLargeCode) {
|
|
1339
|
+
throw error;
|
|
1340
|
+
}
|
|
1341
|
+
throw new Error("body is not json", { cause: error });
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
if (routed !== null) {
|
|
1346
|
+
const answer2 = await routed;
|
|
1347
|
+
if (answer2.events !== void 0) {
|
|
1348
|
+
response.writeHead(answer2.status, {
|
|
1349
|
+
"content-type": "text/event-stream; charset=utf-8",
|
|
1350
|
+
"cache-control": "no-store",
|
|
1351
|
+
"x-accel-buffering": "no"
|
|
1352
|
+
});
|
|
1353
|
+
response.write(": open\n\n");
|
|
1354
|
+
const unsubscribe = answer2.events((chunk) => response.write(chunk));
|
|
1355
|
+
response.on("close", unsubscribe);
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
if (answer2.lines !== void 0) {
|
|
1359
|
+
response.writeHead(answer2.status, {
|
|
1360
|
+
"content-type": "application/x-ndjson; charset=utf-8",
|
|
1361
|
+
"cache-control": "no-store",
|
|
1362
|
+
"x-accel-buffering": "no"
|
|
1363
|
+
});
|
|
1364
|
+
for await (const line of answer2.lines) {
|
|
1365
|
+
if (clientGone.signal.aborted) continue;
|
|
1366
|
+
response.write(`${JSON.stringify(line)}
|
|
1367
|
+
`);
|
|
1368
|
+
}
|
|
1369
|
+
response.end();
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
writeJson(response, answer2.status, answer2.body);
|
|
1373
|
+
if (answer2.status >= 400) {
|
|
1374
|
+
log("warn", "request failed", {
|
|
1375
|
+
method,
|
|
1376
|
+
path: url.pathname,
|
|
1377
|
+
status: answer2.status,
|
|
1378
|
+
error: answer2.body.error
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
if (url.pathname.startsWith("/api/")) {
|
|
1384
|
+
writeJson(response, 404, { error: "not found" });
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
1388
|
+
writeJson(response, 405, { error: "method not allowed" });
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
const answer = await serveStatic(options.distDirectory, url.pathname);
|
|
1392
|
+
response.writeHead(answer.status, { "content-type": answer.contentType });
|
|
1393
|
+
response.end(method === "HEAD" ? void 0 : answer.body);
|
|
1394
|
+
} catch (error) {
|
|
1395
|
+
const tooLarge = error.code === bodyTooLargeCode;
|
|
1396
|
+
let status = 500;
|
|
1397
|
+
if (tooLarge) status = 413;
|
|
1398
|
+
else if (errorMessage(error) === "body is not json") status = 400;
|
|
1399
|
+
log("error", "request failed", {
|
|
1400
|
+
method,
|
|
1401
|
+
path: url.pathname,
|
|
1402
|
+
status,
|
|
1403
|
+
error: errorMessage(error)
|
|
1404
|
+
});
|
|
1405
|
+
if (!response.headersSent) {
|
|
1406
|
+
writeJson(response, status, { error: errorMessage(error) });
|
|
1407
|
+
} else {
|
|
1408
|
+
response.end();
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
const createAppServer = (options) => createServer((request, response) => {
|
|
1413
|
+
handleRequest(options, request, response).catch((error) => {
|
|
1414
|
+
log("error", "request crashed", { error: errorMessage(error) });
|
|
1415
|
+
response.destroy();
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
const defaultPort = 7450;
|
|
1420
|
+
const host = "127.0.0.1";
|
|
1421
|
+
if (process.platform !== "darwin") {
|
|
1422
|
+
throw new Error(
|
|
1423
|
+
`the reviewflow app currently runs on macOS only, not on ${process.platform}. Please open an issue if you want to run it on another platform.`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
const readPort = () => {
|
|
1427
|
+
const raw = env.REVIEWFLOW_APP_PORT;
|
|
1428
|
+
if (raw === void 0 || raw === "") return defaultPort;
|
|
1429
|
+
const port2 = Number(raw);
|
|
1430
|
+
if (!Number.isInteger(port2) || port2 < 1 || port2 > 65535) {
|
|
1431
|
+
throw new Error(`REVIEWFLOW_APP_PORT is not a port: ${raw}`);
|
|
1432
|
+
}
|
|
1433
|
+
return port2;
|
|
1434
|
+
};
|
|
1435
|
+
const port = readPort();
|
|
1436
|
+
const configPath = configPathOf();
|
|
1437
|
+
const server = createAppServer({
|
|
1438
|
+
transport: createGhTransport(),
|
|
1439
|
+
operations,
|
|
1440
|
+
configPath,
|
|
1441
|
+
reviewflow: createReviewflowService(),
|
|
1442
|
+
distDirectory: defaultDistDirectory,
|
|
1443
|
+
allowDevOrigins: env.REVIEWFLOW_APP_DEV === "1"
|
|
1444
|
+
});
|
|
1445
|
+
server.on("error", (error) => {
|
|
1446
|
+
log("error", "server failed", { error: error.message });
|
|
1447
|
+
process.exitCode = 1;
|
|
1448
|
+
});
|
|
1449
|
+
server.listen(port, host, () => {
|
|
1450
|
+
log("info", "reviewflow app server listening", {
|
|
1451
|
+
url: `http://${host}:${String(port)}`,
|
|
1452
|
+
configPath
|
|
1453
|
+
});
|
|
1454
|
+
});
|
|
1455
|
+
//# sourceMappingURL=index-node.mjs.map
|