diff --git a/.github/pr-badge.yml b/.github/pr-badge.yml new file mode 100644 index 0000000..7400516 --- /dev/null +++ b/.github/pr-badge.yml @@ -0,0 +1,17 @@ +- icon: visualstudio + label: 'GitHub.dev' + message: 'PR-$prNumber' + color: 'blue' + url: 'https://github.dev/$owner/$repo/pull/$prNumber' + +- icon: github + label: 'GitHub codespaces' + message: 'PR-$prNumber' + color: 'black' + url: 'https://codespaces.new/$owner/$repo/pull/$prNumber' + +- icon: git + label: 'GitPod.io' + message: 'PR-$prNumber' + color: 'orange' + url: 'https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber' diff --git a/ReadMe.md b/ReadMe.md index d82d4ee..b80c854 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -11,14 +11,14 @@ ## Technology stack -- Language: [TypeScript v5][9] -- Component engine: [PReact v10][10] -- State management: [MobX v6][11] -- Component suite: [React Bootstrap v2][12] -- HTTP Client: [KoAJAX v1][13] -- PWA framework: [Workbox v7][14] -- Package bundler: [Parcel v2][15] -- CI / CD: GitHub [Actions][16] + [Pages][17] +- Language: [TypeScript v5][2] +- Component engine: [PReact v10][9] +- State management: [MobX v6][3] +- Component suite: [React Bootstrap v2][10] +- HTTP Client: [KoAJAX v1][11] +- PWA framework: [Workbox v7][12] +- Package bundler: [Parcel v2][13] +- CI / CD: GitHub [Actions][14] + [Pages][15] ## Extra components @@ -31,13 +31,22 @@ ## Best practice -1. Install **[Settings][19] GitHub app** in your account or organization -2. Click the **[Use this template][20] button** on the top of this GitHub repository's home page, then create your own repository in the app-installed namespace above +1. Install GitHub apps in your organization or account: + + 1. [Probot settings][16]: set up Issue labels & Pull Request rules + 2. [PR badge][17]: set up Online [VS Code][18] editor entries in Pull Request description + +2. Click the **[Use this template][19] button** on the top of this GitHub repository's home page, then create your own repository in the app-installed namespace above + 3. Click the **[Open in GitHub codespaces][7] button** on the top of ReadMe file, then an **online VS Code development environment** will be started immediately -4. Set [Vercel variables][21] as [Repository secrets][22], then every commit will get an independent **Preview URL** -5. Recommend to add a [Notification step in GitHub actions][23] for your Team IM app -6. Remind the PMs & users of your product to submit **Feature/Enhancement** requests or **Bug** reports with [Issue forms][24] instead of IM messages or Mobile Phone calls -7. Collect all these issues into [Project kanbans][25], then create **Pull requests** & add `closes #issue_number` into its description for automation + +4. Set [Vercel variables][20] as [Repository secrets][21], then every commit will get an independent **Preview URL** + +5. Recommend to add a [Notification step in GitHub actions][22] for your Team IM app + +6. Remind the PMs & users of your product to submit **Feature/Enhancement** requests or **Bug** reports with [Issue forms][23] instead of IM messages or Mobile Phone calls + +7. Collect all these issues into [Project kanbans][24], then create **Pull requests** & add `closes #issue_number` into its description for automation ## Development @@ -63,20 +72,19 @@ pnpm build [6]: https://github.com/idea2app/React-MobX-Bootstrap-ts/actions/workflows/main.yml [7]: https://codespaces.new/idea2app/React-MobX-Bootstrap-ts [8]: https://gitpod.io/?autostart=true#https://github.com/idea2app/React-MobX-Bootstrap-ts -[9]: https://www.typescriptlang.org/ -[10]: https://preactjs.com/ -[11]: https://mobx.js.org/ -[12]: https://react-bootstrap.github.io/ -[13]: https://github.com/EasyWebApp/KoAJAX -[14]: https://developers.google.com/web/tools/workbox -[15]: https://parceljs.org/ -[16]: https://github.com/features/actions -[17]: https://pages.github.com/ -[18]: https://github.com/idea2app/React-Bootstrap-editor -[19]: https://github.com/apps/settings -[20]: https://github.com/new?template_name=React-MobX-Bootstrap-ts&template_owner=idea2app -[21]: https://github.com/idea2app/Next-Bootstrap-ts/blob/80967ed49045af9dbcf4d3695a2c39d53a6f71f1/.github/workflows/pull-request.yml#L9-L11 -[22]: https://github.com/idea2app/React-MobX-Bootstrap-ts/settings/secrets/actions -[23]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/bb4675a56bf1d6b207231313da5ed0af7cf0ebd6/.github/workflows/pull-request.yml#L32-L56 -[24]: https://github.com/idea2app/React-MobX-Bootstrap-ts/issues/new/choose -[25]: https://github.com/idea2app/React-MobX-Bootstrap-ts/projects +[9]: https://preactjs.com/ +[10]: https://react-bootstrap.github.io/ +[11]: https://github.com/EasyWebApp/KoAJAX +[12]: https://developers.google.com/web/tools/workbox +[13]: https://parceljs.org/ +[14]: https://github.com/features/actions +[15]: https://pages.github.com/ +[16]: https://github.com/apps/settings +[17]: https://pullrequestbadge.com/ +[18]: https://code.visualstudio.com/ +[19]: https://github.com/new?template_name=React-MobX-Bootstrap-ts&template_owner=idea2app +[20]: https://github.com/idea2app/React-MobX-Bootstrap-ts/blob/8e796c6e7dc485fe4a68b59fcbffb9d224236bf4/.github/workflows/main.yml#L10-L12 +[21]: https://github.com/idea2app/React-MobX-Bootstrap-ts/settings/secrets/actions +[22]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/bb4675a56bf1d6b207231313da5ed0af7cf0ebd6/.github/workflows/pull-request.yml#L32-L56 +[23]: https://github.com/idea2app/React-MobX-Bootstrap-ts/issues/new/choose +[24]: https://github.com/idea2app/React-MobX-Bootstrap-ts/projects diff --git a/package.json b/package.json index 833f824..af4199d 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,13 @@ "echarts-jsx": "^1.2.0", "editorjs-html": "^3.4.3", "idea-react": "^2.0.0-rc.2", - "koajax": "^1.1.0", + "koajax": "^1.1.2", "lodash": "^4.17.21", "mobx": "^6.12.3", + "mobx-github": "^0.3.1", "mobx-i18n": "^0.5.0", "mobx-react": "^9.1.1", - "mobx-restful": "^1.0.0-rc.5", + "mobx-restful": "^1.0.0-rc.6", "mobx-restful-table": "^2.0.0-rc.1", "preact": "^10.22.0", "react-bootstrap": "^2.10.2", @@ -33,21 +34,20 @@ "web-utility": "^4.4.0" }, "devDependencies": { - "@babel/runtime": "^7.24.6", - "@octokit/openapi-types": "^22.2.0", + "@babel/runtime": "^7.24.7", "@parcel/config-default": "~2.12.0", "@parcel/packager-raw-url": "~2.12.0", "@parcel/transformer-less": "~2.12.0", "@parcel/transformer-typescript-tsc": "~2.12.0", "@parcel/transformer-webmanifest": "~2.12.0", "@types/lodash": "^4.17.4", - "@types/node": "^18.19.33", + "@types/node": "^18.19.34", "buffer": "^6.0.3", "husky": "^9.0.11", "lint-staged": "^15.2.5", "parcel": "~2.12.0", "parcel-transformer-mdx": "^0.3.2", - "prettier": "^3.2.5", + "prettier": "^3.3.1", "prismjs": "^1.29.0", "process": "^0.11.10", "typescript": "~5.4.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 128f994..3f7bb67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,14 +48,17 @@ importers: specifier: ^2.0.0-rc.2 version: 2.0.0-rc.2(@types/react@18.2.74)(typescript@5.4.5) koajax: - specifier: ^1.1.0 - version: 1.1.0(typescript@5.4.5) + specifier: ^1.1.2 + version: 1.1.2(typescript@5.4.5) lodash: specifier: ^4.17.21 version: 4.17.21 mobx: specifier: ^6.12.3 version: 6.12.3 + mobx-github: + specifier: 0.3.0-rc.1 + version: 0.3.0-rc.1(typescript@5.4.5) mobx-i18n: specifier: ^0.5.0 version: 0.5.0(mobx@6.12.3) @@ -63,11 +66,11 @@ importers: specifier: ^9.1.1 version: 9.1.1(mobx@6.12.3) mobx-restful: - specifier: ^1.0.0-rc.5 - version: 1.0.0-rc.5(mobx@6.12.3)(typescript@5.4.5) + specifier: ^1.0.0-rc.6 + version: 1.0.0-rc.6(mobx@6.12.3)(typescript@5.4.5) mobx-restful-table: specifier: ^2.0.0-rc.1 - version: 2.0.0-rc.1(@types/react@18.2.74)(mobx-i18n@0.5.0(mobx@6.12.3))(mobx-react@9.1.1(mobx@6.12.3))(mobx-restful@1.0.0-rc.5(mobx@6.12.3)(typescript@5.4.5))(mobx@6.12.3)(typescript@5.4.5) + version: 2.0.0-rc.1(@types/react@18.2.74)(mobx-i18n@0.5.0(mobx@6.12.3))(mobx-react@9.1.1(mobx@6.12.3))(mobx-restful@1.0.0-rc.6(mobx@6.12.3)(typescript@5.4.5))(mobx@6.12.3)(typescript@5.4.5) preact: specifier: ^10.22.0 version: 10.22.0 @@ -91,8 +94,8 @@ importers: version: 4.4.0(typescript@5.4.5) devDependencies: '@babel/runtime': - specifier: ^7.24.6 - version: 7.24.6 + specifier: ^7.24.7 + version: 7.24.7 '@octokit/openapi-types': specifier: ^22.2.0 version: 22.2.0 @@ -115,8 +118,8 @@ importers: specifier: ^4.17.4 version: 4.17.4 '@types/node': - specifier: ^18.19.33 - version: 18.19.33 + specifier: ^18.19.34 + version: 18.19.34 buffer: specifier: ^6.0.3 version: 6.0.3 @@ -133,8 +136,8 @@ importers: specifier: ^0.3.2 version: 0.3.2(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) prettier: - specifier: ^3.2.5 - version: 3.2.5 + specifier: ^3.3.1 + version: 3.3.1 prismjs: specifier: ^1.29.0 version: 1.29.0 @@ -720,8 +723,8 @@ packages: '@babel/regjsgen@0.8.0': resolution: {integrity: sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==} - '@babel/runtime@7.24.6': - resolution: {integrity: sha512-Ja18XcETdEl5mzzACGd+DKgaGJzPTCow7EglgwTmHdwokzDFYh/MHua6lU6DV/hjF2IaOJ4oX2nqnjG7RElKOw==} + '@babel/runtime@7.24.7': + resolution: {integrity: sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==} engines: {node: '>=6.9.0'} '@babel/template@7.24.0': @@ -1458,8 +1461,8 @@ packages: '@types/node-fetch@2.6.11': resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==} - '@types/node@18.19.33': - resolution: {integrity: sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==} + '@types/node@18.19.34': + resolution: {integrity: sha512-eXF4pfBNV5DAMKGbI02NnDtWrQ40hAN558/2vvS4gMpMIxaf6JmD7YjnZbq0Q9TDSSkKBamime8ewRoomHdt4g==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -2770,8 +2773,14 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} - koajax@1.1.0: - resolution: {integrity: sha512-5BzwkuLlZGC1Ro3NgJRMysXc/FtnHJiCMpLOTgDBHl+4v1xtBWTHvMm4SL2mwf2wszJ5OUWQ6m5I3M63rIqzKQ==} + koajax@0.9.6: + resolution: {integrity: sha512-Cv5HH7igfN7HEGLwRzu4TEzXLTm3QSpbR48Gif9dhPPBNKZ8ELS1bbh3Dik1s83vpKnnjC+DcFU8ql+LwNg3tQ==} + deprecated: Don't use versions with old API & bugs + peerDependencies: + jsdom: '>=21' + + koajax@1.1.2: + resolution: {integrity: sha512-TGWJhGpojfSYdqGIKK8CWwMhUY1LYDyvodt6LywHVYEH6qq38/3DgW+FKTCV88O59G0J4W2XFbBTF8nvZ/J/nw==} peerDependencies: jsdom: '>=21' @@ -3203,6 +3212,9 @@ packages: engines: {node: '>=10'} hasBin: true + mobx-github@0.3.0-rc.1: + resolution: {integrity: sha512-KQeW3Y0ActHJjsO1uKveca3KjpIeP0qRpk96v5PjaipwGAY3sRmh1pOJr11LWvyE2CY8UcZ72zS4SSZc88qC2w==} + mobx-i18n@0.5.0: resolution: {integrity: sha512-ZflCX7iqosU/ZhfGV3uaQGcptK1w1pHBEn4PWc1b+IZtLOcc4agaLQNj5OIIbTQNLNNxNdA5k1+Ze9aqStsHzA==} peerDependencies: @@ -3249,8 +3261,14 @@ packages: mobx-restful: ^0.7.0-rc.0 react: '>=16.8' - mobx-restful@1.0.0-rc.5: - resolution: {integrity: sha512-7NpXLHqMXyQpIAsFb0bXM+fURhrxfO+tD5SGFElyCKvF95QoeMmhXI258SvAF9Q/5lwE2+NbI5TGEHDKqo8lAg==} + mobx-restful@0.7.0-rc.0: + resolution: {integrity: sha512-fM2ymsA+u8N0sCK8d1sb26Zja9G4PxKMWuRzFJzVzvKX0ba1pViRCeC4qiH8ITzhAw/vIySNeGZ8iObxAZN5ww==} + deprecated: Don't use versions with old API & bugs + peerDependencies: + mobx: '>=6.11' + + mobx-restful@1.0.0-rc.6: + resolution: {integrity: sha512-vAe4jORvueaFFupTQbjF98S8JHh5n7lPHon3hCz+c0Ncc5ZIOWSm24GlfLsoUXxoikqM51mo/nbZbNDDJqod3w==} peerDependencies: mobx: '>=6.11' @@ -3489,8 +3507,8 @@ packages: resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} engines: {node: '>=4'} - prettier@3.2.5: - resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + prettier@3.3.1: + resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} engines: {node: '>=14'} hasBin: true @@ -5082,7 +5100,7 @@ snapshots: '@babel/regjsgen@0.8.0': {} - '@babel/runtime@7.24.6': + '@babel/runtime@7.24.7': dependencies: regenerator-runtime: 0.14.1 @@ -5137,7 +5155,7 @@ snapshots: '@editorjs/link@2.6.2': dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@codexteam/icons': 0.0.4 '@editorjs/list@1.9.0': @@ -5952,7 +5970,7 @@ snapshots: '@remark-embedder/core@3.0.2': dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@types/hast': 2.3.10 '@types/mdast': 3.0.15 hast-util-from-parse5: 7.1.2 @@ -5962,7 +5980,7 @@ snapshots: '@remark-embedder/transformer-oembed@3.0.0(@remark-embedder/core@3.0.2)': dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@remark-embedder/core': 3.0.2 '@types/make-fetch-happen': 10.0.4 make-fetch-happen: 10.2.1 @@ -5978,7 +5996,7 @@ snapshots: '@restart/ui@1.6.8': dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@popperjs/core': 2.11.8 '@react-aria/ssr': 3.9.2 '@restart/hooks': 0.4.16 @@ -6139,7 +6157,7 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 18.19.33 + '@types/node': 18.19.34 '@types/lodash@4.17.4': {} @@ -6165,10 +6183,10 @@ snapshots: '@types/node-fetch@2.6.11': dependencies: - '@types/node': 18.19.33 + '@types/node': 18.19.34 form-data: 4.0.0 - '@types/node@18.19.33': + '@types/node@18.19.34': dependencies: undici-types: 5.26.5 @@ -6189,13 +6207,13 @@ snapshots: '@types/responselike@1.0.3': dependencies: - '@types/node': 18.19.33 + '@types/node': 18.19.34 '@types/retry@0.12.5': {} '@types/ssri@7.1.5': dependencies: - '@types/node': 18.19.33 + '@types/node': 18.19.34 '@types/trusted-types@2.0.7': {} @@ -6703,7 +6721,7 @@ snapshots: dom-helpers@5.2.1: dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 csstype: 3.1.3 dom-renderer@2.1.4(typescript@5.4.5): @@ -7216,7 +7234,7 @@ snapshots: history@5.3.0: dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 hosted-git-info@2.8.9: {} @@ -7579,7 +7597,16 @@ snapshots: kind-of@6.0.3: {} - koajax@1.1.0(typescript@5.4.5): + koajax@0.9.6(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + iterable-observer: 1.0.1 + regenerator-runtime: 0.14.1 + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - typescript + + koajax@1.1.2(typescript@5.4.5): dependencies: '@swc/helpers': 0.5.11 iterable-observer: 1.0.1 @@ -8324,6 +8351,20 @@ snapshots: mkdirp@1.0.4: {} + mobx-github@0.3.0-rc.1(typescript@5.4.5): + dependencies: + '@octokit/openapi-types': 22.2.0 + '@swc/helpers': 0.5.11 + '@types/lodash': 4.17.4 + koajax: 1.1.2(typescript@5.4.5) + lodash: 4.17.21 + mobx: 6.12.3 + mobx-restful: 0.7.0-rc.0(mobx@6.12.3)(typescript@5.4.5) + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - jsdom + - typescript + mobx-i18n@0.5.0(mobx@6.12.3): dependencies: '@swc/helpers': 0.5.8 @@ -8346,7 +8387,7 @@ snapshots: mobx: 6.12.3 mobx-react-lite: 4.0.7(mobx@6.12.3) - mobx-restful-table@2.0.0-rc.1(@types/react@18.2.74)(mobx-i18n@0.5.0(mobx@6.12.3))(mobx-react@9.1.1(mobx@6.12.3))(mobx-restful@1.0.0-rc.5(mobx@6.12.3)(typescript@5.4.5))(mobx@6.12.3)(typescript@5.4.5): + mobx-restful-table@2.0.0-rc.1(@types/react@18.2.74)(mobx-i18n@0.5.0(mobx@6.12.3))(mobx-react@9.1.1(mobx@6.12.3))(mobx-restful@1.0.0-rc.6(mobx@6.12.3)(typescript@5.4.5))(mobx@6.12.3)(typescript@5.4.5): dependencies: '@swc/helpers': 0.5.8 classnames: 2.5.1 @@ -8355,7 +8396,7 @@ snapshots: mobx-i18n: 0.5.0(mobx@6.12.3) mobx-react: 9.1.1(mobx@6.12.3) mobx-react-helper: 0.3.1(mobx@6.12.3) - mobx-restful: 1.0.0-rc.5(mobx@6.12.3)(typescript@5.4.5) + mobx-restful: 1.0.0-rc.6(mobx@6.12.3)(typescript@5.4.5) react-bootstrap: 2.10.2(@types/react@18.2.74) regenerator-runtime: 0.14.1 web-utility: 4.4.0(typescript@5.4.5) @@ -8364,11 +8405,22 @@ snapshots: - react-dom - typescript - mobx-restful@1.0.0-rc.5(mobx@6.12.3)(typescript@5.4.5): + mobx-restful@0.7.0-rc.0(mobx@6.12.3)(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + koajax: 0.9.6(typescript@5.4.5) + mobx: 6.12.3 + regenerator-runtime: 0.14.1 + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - jsdom + - typescript + + mobx-restful@1.0.0-rc.6(mobx@6.12.3)(typescript@5.4.5): dependencies: '@swc/helpers': 0.5.11 idb-keyval: 6.2.1 - koajax: 1.1.0(typescript@5.4.5) + koajax: 1.1.2(typescript@5.4.5) mobx: 6.12.3 native-file-system-adapter: 3.0.1 regenerator-runtime: 0.14.1 @@ -8645,7 +8697,7 @@ snapshots: prepend-http@2.0.0: {} - prettier@3.2.5: {} + prettier@3.3.1: {} pretty-bytes@5.6.0: {} @@ -8719,7 +8771,7 @@ snapshots: react-bootstrap@2.10.2(@types/react@18.2.74): dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@restart/hooks': 0.4.16 '@restart/ui': 1.6.8 '@types/react-transition-group': 4.4.10 @@ -8779,7 +8831,7 @@ snapshots: react-transition-group@4.4.5: dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -8830,7 +8882,7 @@ snapshots: regenerator-transform@0.15.2: dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 regexp.prototype.flags@1.5.2: dependencies: @@ -9333,7 +9385,7 @@ snapshots: uncontrollable@7.2.1: dependencies: - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@types/react': 18.2.74 invariant: 2.2.4 react-lifecycles-compat: 3.0.4 @@ -9596,7 +9648,7 @@ snapshots: '@apideck/better-ajv-errors': 0.3.6(ajv@8.12.0) '@babel/core': 7.24.4 '@babel/preset-env': 7.24.4(@babel/core@7.24.4) - '@babel/runtime': 7.24.6 + '@babel/runtime': 7.24.7 '@rollup/plugin-babel': 5.3.1(@babel/core@7.24.4)(rollup@2.79.1) '@rollup/plugin-node-resolve': 15.2.3(rollup@2.79.1) '@rollup/plugin-replace': 2.4.2(rollup@2.79.1) diff --git a/src/component/Git/Card.tsx b/src/component/Git/Card.tsx index 7a4c703..801bbfe 100644 --- a/src/component/Git/Card.tsx +++ b/src/component/Git/Card.tsx @@ -1,9 +1,9 @@ import { text2color } from 'idea-react'; +import { GitRepository } from 'mobx-github'; import { observer } from 'mobx-react'; import { FC } from 'react'; import { Badge, Button, Card, Col, Row } from 'react-bootstrap'; -import { GitRepository } from '../../model/Repository'; import { i18n } from '../../model/Translation'; import { GitLogo } from './Logo'; diff --git a/src/model/Project.ts b/src/model/Project.ts index d6560ae..0a5c460 100644 --- a/src/model/Project.ts +++ b/src/model/Project.ts @@ -1,11 +1,11 @@ -import { components } from '@octokit/openapi-types'; import { observable } from 'mobx'; +import { GitRepository } from 'mobx-github'; -import { service } from './service'; +import { repositoryStore } from './service'; -export type Project = components['schemas']['minimal-repository'] & { +export interface Project extends GitRepository { logo?: string; -}; +} export class ProjectModel { @observable @@ -13,11 +13,12 @@ export class ProjectModel { clearList() { this.list = []; + repositoryStore.clear(); } async getList(...names: string[]) { for (const name of names) { - const { body } = await service.get(`repos/${name}`); + const body = await repositoryStore.getOne(name); const logo = await ProjectModel.getLogo( body.owner.login, diff --git a/src/model/Repository.ts b/src/model/Repository.ts deleted file mode 100644 index 016a665..0000000 --- a/src/model/Repository.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { averageOf, buildURLData } from 'web-utility'; -import { memoize } from 'lodash'; -import { ListModel, toggle } from 'mobx-restful'; -import { components } from '@octokit/openapi-types'; - -import { service } from './service'; - -type Repository = components['schemas']['minimal-repository']; - -export interface GitRepository extends Repository { - languages?: string[]; -} -export type Organization = components['schemas']['organization-full']; - -const getGitLanguages = memoize(async (URI: string) => { - const { body: languageCount } = await service.get>( - `repos/${URI}/languages` - ); - - const languageAverage = averageOf(...Object.values(languageCount!)); - - const languageList = Object.entries(languageCount!) - .filter(([_, score]) => score >= languageAverage) - .sort(([_, a], [__, b]) => b - a); - - return languageList.map(([name]) => name); -}); - -export class RepositoryModel extends ListModel { - client = service; - baseURI = 'orgs/idea2app/repos'; - indexKey = 'full_name' as const; - - @toggle('downloading') - async getOne(URI: string) { - const { body } = await this.client.get(`repos/${URI}`); - - return (this.currentOne = { - ...body!, - languages: await getGitLanguages(URI) - }); - } - - async loadPage(page: number, per_page: number) { - const { body: list } = await this.client.get( - `${this.baseURI}?${buildURLData({ - type: 'public', - sort: 'pushed', - page, - per_page - })}` - ); - const pageData = await Promise.all( - list!.map(async ({ full_name, ...item }) => ({ - ...item, - full_name, - languages: await getGitLanguages(full_name) - })) - ); - const [_, organization] = this.baseURI.split('/'); - - const { body } = await this.client.get( - `orgs/${organization}` - ); - return { pageData, totalCount: body!.public_repos }; - } -} - -export default new RepositoryModel(); diff --git a/src/model/service.ts b/src/model/service.ts index 4fe5425..c8638f1 100644 --- a/src/model/service.ts +++ b/src/model/service.ts @@ -1,12 +1,9 @@ -import { HTTPClient } from 'koajax'; +import { RepositoryModel, githubClient } from 'mobx-github'; import { Downloader } from 'mobx-restful'; const GithubToken = process.env.GITHUB_TOKEN; -export const service = new HTTPClient({ - baseURI: 'https://api.github.com/', - responseType: 'json' -}).use(({ request }, next) => { +githubClient.use(({ request }, next) => { if (GithubToken) request.headers = { ...request.headers, @@ -15,4 +12,5 @@ export const service = new HTTPClient({ return next(); }); +export const repositoryStore = new RepositoryModel('idea2app'); export const downloader = new Downloader(); diff --git a/src/page/Home.tsx b/src/page/Home.tsx index 29cb8a8..a6917c6 100644 --- a/src/page/Home.tsx +++ b/src/page/Home.tsx @@ -36,7 +36,7 @@ class HomePage extends Component< homepage, html_url }: Project) => ( - + @@ -78,7 +78,9 @@ class HomePage extends Component< {t('welcome')} {guest}! )} - {list.map(this.renderProject)} + + {list.map(this.renderProject)} + ); } diff --git a/src/page/Pagination.tsx b/src/page/Pagination.tsx index 6775963..84cf3f0 100644 --- a/src/page/Pagination.tsx +++ b/src/page/Pagination.tsx @@ -1,11 +1,12 @@ +import { text2color } from 'idea-react'; import { computed } from 'mobx'; +import { GitRepository } from 'mobx-github'; import { observer } from 'mobx-react'; import { Column, RestTable } from 'mobx-restful-table'; import { Component } from 'react'; -import { Container, Badge } from 'react-bootstrap'; -import { text2color } from 'idea-react'; +import { Badge, Container } from 'react-bootstrap'; -import repositoryStore, { GitRepository } from '../model/Repository'; +import { repositoryStore } from '../model/service'; import { i18n } from '../model/Translation'; @observer diff --git a/src/page/ScrollList.tsx b/src/page/ScrollList.tsx index ee46d88..7896b25 100644 --- a/src/page/ScrollList.tsx +++ b/src/page/ScrollList.tsx @@ -4,7 +4,7 @@ import { FC } from 'react'; import { Col, Container, Row } from 'react-bootstrap'; import { GitCard } from '../component/Git/Card'; -import repositoryStore from '../model/Repository'; +import { repositoryStore } from '../model/service'; import { i18n } from '../model/Translation'; export const ScrollListPage: FC = observer(() => (