From cc30a85d3d77b8c72a57abe1c67cc34ea071ce12 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Tue, 15 Feb 2022 22:18:20 +0100 Subject: [PATCH] chore: script to update contributors (#3001) * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors * chore: script to update contributors --- .github/workflows/contributors.yml | 49 ++++++ package.json | 3 + packages/auth/src/jwt-token.ts | 6 +- pnpm-lock.yaml | 239 ++++++++++++++++++++++++++++- scripts/contributors-update.ts | 40 +++++ 5 files changed, 334 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/contributors.yml create mode 100644 scripts/contributors-update.ts diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml new file mode 100644 index 000000000..aa9645ce0 --- /dev/null +++ b/.github/workflows/contributors.yml @@ -0,0 +1,49 @@ +--- +name: contributors + +on: + workflow_dispatch: + schedule: + # twice peer week + - cron: '0 0 * * 1,4' + # for now, scheduled, we can enable on push master but not make much sense now + # push: + # branches: + # - master +jobs: + prepare: + name: Run script + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: 17.x + - name: install pnpm + run: sudo npm i pnpm@6.24.1 -g + - name: set store + run: | + mkdir ~/.pnpm-store + pnpm config set store-dir ~/.pnpm-store + - name: setup pnpm config registry + run: pnpm config set registry https://registry.verdaccio.org + - name: install dependencies + run: pnpm install + - name: update contributors + run: pnpm run contributors + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: format + run: pnpm format + - name: Commit & Push changes + uses: actions-js/push@v1.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + message: "chore: update contributors list" + branch: master + author_email: verdaccio.npm@gmail.com + author_name: verdacciobot + empty: true diff --git a/package.json b/package.json index b7d9989a0..b983a9135 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "@babel/preset-typescript": "7.16.7", "@babel/register": "7.16.9", "@babel/runtime": "7.16.7", + "@dianmora/contributors": "1.1.0", "@changesets/changelog-github": "0.4.2", "@changesets/cli": "2.15.0", "@changesets/get-dependents-graph": "1.2.4", @@ -52,6 +53,7 @@ "@types/mime": "2.0.3", "@types/minimatch": "3.0.5", "@types/node": "16.11.21", + "@types/jsonwebtoken": "8.5.1", "@types/request": "2.48.8", "@types/semver": "7.3.9", "@types/supertest": "2.0.11", @@ -120,6 +122,7 @@ "benchmark:hyper": "verdaccio-benchmark hyper -r ./hyper-results.json", "benchmark:api": "verdaccio-benchmark api", "benchmark:submit": "pnpm ts-node ./scripts/submit-metrics.ts", + "contributors": "ts-node ./scripts/contributors-update.ts", "start:watch": "concurrently --kill-others \"pnpm _build:watch\" \"pnpm _start:server\" \"pnpm _debug:reload\"", "_build:watch": "pnpm run --parallel watch --filter ./packages", "_start:server": "node --inspect packages/verdaccio/debug/bootstrap.js --listen 8000", diff --git a/packages/auth/src/jwt-token.ts b/packages/auth/src/jwt-token.ts index 782d4de40..3ad1c194b 100644 --- a/packages/auth/src/jwt-token.ts +++ b/packages/auth/src/jwt-token.ts @@ -21,12 +21,14 @@ export async function signPayload( return jwt.sign( payload, secretOrPrivateKey, + // FIXME: upgrade to the latest library and types + // @ts-ignore { // 1 === 1ms (one millisecond) notBefore: '1', // Make sure the time will not rollback :) ...options, }, - (error, token) => { + (error, token: string) => { debug('error on sign jwt token'); return error ? reject(error) : resolve(token); } @@ -36,5 +38,5 @@ export async function signPayload( export function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser { debug('verify jwt token'); - return jwt.verify(token, secretOrPrivateKey); + return jwt.verify(token, secretOrPrivateKey) as RemoteUser; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8ecb8d4e..662b14e03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,12 +31,14 @@ importers: '@changesets/cli': 2.15.0 '@changesets/get-dependents-graph': 1.2.4 '@crowdin/cli': 3.7.7 + '@dianmora/contributors': 1.1.0 '@trivago/prettier-plugin-sort-imports': 3.2.0 '@types/async': 3.2.12 '@types/autocannon': 4.1.1 '@types/express': 4.17.13 '@types/http-errors': 1.8.2 '@types/jest': 27.4.0 + '@types/jsonwebtoken': 8.5.1 '@types/lodash': 4.14.178 '@types/mime': 2.0.3 '@types/minimatch': 3.0.5 @@ -121,12 +123,14 @@ importers: '@changesets/cli': 2.15.0 '@changesets/get-dependents-graph': 1.2.4 '@crowdin/cli': 3.7.7 + '@dianmora/contributors': 1.1.0 '@trivago/prettier-plugin-sort-imports': 3.2.0_prettier@2.5.1 '@types/async': 3.2.12 '@types/autocannon': 4.1.1 '@types/express': 4.17.13 '@types/http-errors': 1.8.2 '@types/jest': 27.4.0 + '@types/jsonwebtoken': 8.5.1 '@types/lodash': 4.14.178 '@types/mime': 2.0.3 '@types/minimatch': 3.0.5 @@ -5832,6 +5836,17 @@ packages: '@cspotcode/source-map-consumer': 0.8.0 dev: true + /@dianmora/contributors/1.1.0: + resolution: {integrity: sha512-1HQrfiNHWUEFMSur1twULb2WKURcDZw95Cl/RT9fRXT4gdReJHXlDKrTAy1KCPWL8cbcZ6B3/7ffy8dxeNUX6Q==} + dependencies: + '@octokit/auth-app': 3.6.1 + '@octokit/rest': 18.12.0 + debug: 4.3.1 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /@discoveryjs/json-ext/0.5.2: resolution: {integrity: sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg==} engines: {node: '>=10.0.0'} @@ -7818,6 +7833,184 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.11.0 + /@octokit/auth-app/3.6.1: + resolution: {integrity: sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA==} + dependencies: + '@octokit/auth-oauth-app': 4.3.0 + '@octokit/auth-oauth-user': 1.3.0 + '@octokit/request': 5.6.3 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + '@types/lru-cache': 5.1.1 + deprecation: 2.3.1 + lru-cache: 6.0.0 + universal-github-app-jwt: 1.1.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/auth-oauth-app/4.3.0: + resolution: {integrity: sha512-cETmhmOQRHCz6cLP7StThlJROff3A/ln67Q961GuIr9zvyFXZ4lIJy9RE6Uw5O7D8IXWPU3jhDnG47FTSGQr8Q==} + dependencies: + '@octokit/auth-oauth-device': 3.1.2 + '@octokit/auth-oauth-user': 1.3.0 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + '@types/btoa-lite': 1.0.0 + btoa-lite: 1.0.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/auth-oauth-device/3.1.2: + resolution: {integrity: sha512-w7Po4Ck6N2aAn2VQyKLuojruiyKROTBv4qs6IwE5rbwF7HhBXXp4A/NKmkpoFIZkiXQtM+N8QtkSck4ApYWdGg==} + dependencies: + '@octokit/oauth-methods': 1.2.6 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/auth-oauth-user/1.3.0: + resolution: {integrity: sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ==} + dependencies: + '@octokit/auth-oauth-device': 3.1.2 + '@octokit/oauth-methods': 1.2.6 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + btoa-lite: 1.0.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/auth-token/2.5.0: + resolution: {integrity: sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==} + dependencies: + '@octokit/types': 6.34.0 + dev: true + + /@octokit/core/3.5.1: + resolution: {integrity: sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==} + dependencies: + '@octokit/auth-token': 2.5.0 + '@octokit/graphql': 4.8.0 + '@octokit/request': 5.6.3 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + before-after-hook: 2.2.2 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/endpoint/6.0.12: + resolution: {integrity: sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==} + dependencies: + '@octokit/types': 6.34.0 + is-plain-object: 5.0.0 + universal-user-agent: 6.0.0 + dev: true + + /@octokit/graphql/4.8.0: + resolution: {integrity: sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==} + dependencies: + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/oauth-authorization-url/4.3.3: + resolution: {integrity: sha512-lhP/t0i8EwTmayHG4dqLXgU+uPVys4WD/qUNvC+HfB1S1dyqULm5Yx9uKc1x79aP66U1Cb4OZeW8QU/RA9A4XA==} + dev: true + + /@octokit/oauth-methods/1.2.6: + resolution: {integrity: sha512-nImHQoOtKnSNn05uk2o76om1tJWiAo4lOu2xMAHYsNr0fwopP+Dv+2MlGvaMMlFjoqVd3fF3X5ZDTKCsqgmUaQ==} + dependencies: + '@octokit/oauth-authorization-url': 4.3.3 + '@octokit/request': 5.6.3 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + btoa-lite: 1.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/openapi-types/11.2.0: + resolution: {integrity: sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==} + dev: true + + /@octokit/plugin-paginate-rest/2.17.0_@octokit+core@3.5.1: + resolution: {integrity: sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==} + peerDependencies: + '@octokit/core': '>=2' + dependencies: + '@octokit/core': 3.5.1 + '@octokit/types': 6.34.0 + dev: true + + /@octokit/plugin-request-log/1.0.4_@octokit+core@3.5.1: + resolution: {integrity: sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==} + peerDependencies: + '@octokit/core': '>=3' + dependencies: + '@octokit/core': 3.5.1 + dev: true + + /@octokit/plugin-rest-endpoint-methods/5.13.0_@octokit+core@3.5.1: + resolution: {integrity: sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==} + peerDependencies: + '@octokit/core': '>=3' + dependencies: + '@octokit/core': 3.5.1 + '@octokit/types': 6.34.0 + deprecation: 2.3.1 + dev: true + + /@octokit/request-error/2.1.0: + resolution: {integrity: sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==} + dependencies: + '@octokit/types': 6.34.0 + deprecation: 2.3.1 + once: 1.4.0 + dev: true + + /@octokit/request/5.6.3: + resolution: {integrity: sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==} + dependencies: + '@octokit/endpoint': 6.0.12 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + is-plain-object: 5.0.0 + node-fetch: 2.6.7 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/rest/18.12.0: + resolution: {integrity: sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q==} + dependencies: + '@octokit/core': 3.5.1 + '@octokit/plugin-paginate-rest': 2.17.0_@octokit+core@3.5.1 + '@octokit/plugin-request-log': 1.0.4_@octokit+core@3.5.1 + '@octokit/plugin-rest-endpoint-methods': 5.13.0_@octokit+core@3.5.1 + transitivePeerDependencies: + - encoding + dev: true + + /@octokit/types/6.34.0: + resolution: {integrity: sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw==} + dependencies: + '@octokit/openapi-types': 11.2.0 + dev: true + /@open-draft/until/1.0.3: resolution: {integrity: sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==} dev: true @@ -8344,6 +8537,10 @@ packages: '@types/node': 16.11.21 dev: true + /@types/btoa-lite/1.0.0: + resolution: {integrity: sha512-wJsiX1tosQ+J5+bY5LrSahHxr2wT+uME5UDwdN1kg4frt40euqA+wzECkmq4t5QbveHiJepfdThgQrPw6KiSlg==} + dev: true + /@types/caseless/0.12.2: resolution: {integrity: sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==} dev: true @@ -8502,6 +8699,18 @@ packages: resolution: {integrity: sha1-7ihweulOEdK4J7y+UnC86n8+ce4=} dev: false + /@types/jsonwebtoken/8.5.1: + resolution: {integrity: sha512-rNAPdomlIUX0i0cg2+I+Q1wOUr531zHBQ+cV/28PJ39bSPKjahatZZ2LMuhiguETkCgLVzfruw/ZvNMNkKoSzw==} + dependencies: + '@types/node': 16.11.21 + dev: true + + /@types/jsonwebtoken/8.5.8: + resolution: {integrity: sha512-zm6xBQpFDIDM6o9r6HSgDeIcLy82TKWctCXEPbJJcXb5AKmi5BNNdLXneixK4lplX3PqIVcwLBCGE/kAGnlD4A==} + dependencies: + '@types/node': 16.11.21 + dev: true + /@types/ldapjs/1.0.9: resolution: {integrity: sha512-3PvY7Drp1zoLbcGlothCAkoc5o6Jp9KvUPwHadlHyKp3yPvyeIh7w2zQc9UXMzgDRkoeGXUEODtbEs5XCh9ZyA==} dependencies: @@ -8527,6 +8736,10 @@ packages: loud-rejection: 2.2.0 dev: true + /@types/lru-cache/5.1.1: + resolution: {integrity: sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==} + dev: true + /@types/mdast/3.0.3: resolution: {integrity: sha512-SXPBMnFVQg1s00dlMCc/jCdvPqdE4mXaMMCeRlxLDmTAEoegHT53xKtkDnzDTOcmMHUfcjyf36/YYZ6SxRdnsw==} dependencies: @@ -10404,6 +10617,10 @@ packages: /bcryptjs/2.4.3: resolution: {integrity: sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=} + /before-after-hook/2.2.2: + resolution: {integrity: sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==} + dev: true + /better-path-resolve/1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} @@ -10595,6 +10812,10 @@ packages: node-int64: 0.4.0 dev: true + /btoa-lite/1.0.0: + resolution: {integrity: sha1-M3dm2hWAEhD92VbCLpxokaudAzc=} + dev: true + /buble-jsx-only/0.19.8: resolution: {integrity: sha512-7AW19pf7PrKFnGTEDzs6u9+JZqQwM1VnLS19OlqYDhXomtFFknnoQJAPHeg84RMFWAvOhYrG7harizJNwUKJsA==} hasBin: true @@ -12215,6 +12436,10 @@ packages: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} + /deprecation/2.3.1: + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} + dev: true + /dequal/2.0.2: resolution: {integrity: sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==} engines: {node: '>=6'} @@ -14243,6 +14468,7 @@ packages: resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} engines: {node: '>= 4.0'} os: [darwin] + deprecated: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. requiresBuild: true dependencies: bindings: 1.5.0 @@ -23160,7 +23386,7 @@ packages: '@tsconfig/node14': 1.0.0 '@tsconfig/node16': 1.0.2 '@types/node': 16.11.21 - acorn: 8.4.1 + acorn: 8.7.0 acorn-walk: 8.1.1 arg: 4.1.3 create-require: 1.1.1 @@ -23553,6 +23779,17 @@ packages: unist-util-visit-parents: 5.1.0 dev: true + /universal-github-app-jwt/1.1.0: + resolution: {integrity: sha512-3b+ocAjjz4JTyqaOT+NNBd5BtTuvJTxWElIoeHSVelUV9J3Jp7avmQTdLKCaoqi/5Ox2o/q+VK19TJ233rVXVQ==} + dependencies: + '@types/jsonwebtoken': 8.5.8 + jsonwebtoken: 8.5.1 + dev: true + + /universal-user-agent/6.0.0: + resolution: {integrity: sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==} + dev: true + /universalify/0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} diff --git a/scripts/contributors-update.ts b/scripts/contributors-update.ts new file mode 100644 index 000000000..959a46c39 --- /dev/null +++ b/scripts/contributors-update.ts @@ -0,0 +1,40 @@ +import fs from 'fs/promises'; +import path from 'path'; + +const token = process.env.TOKEN; +// TODO: migrate to ESM and import +const contributors = require('@dianmora/contributors'); +const excludebots = [ + 'verdacciobot', + 'dependabot-preview[bot]', + 'dependabot[bot]', + '64b2b6d12bfe4baae7dad3d01', + 'greenkeeper[bot]', + 'snyk-bot', + 'allcontributors[bot]', + 'renovate[bot]', + 'undefined', + 'renovate-bot', +]; + +(async () => { + try { + // Awesome script made by https://github.com/dianmorales + const result = await contributors({ + token: token, + organization: 'verdaccio', + excludebots, + allowFork: false, + allowPrivateRepo: false, + }); + const pathContributorsFile = path.join( + __dirname, + '../packages/tools/docusaurus-plugin-contributors/src/contributors.json' + ); + await fs.writeFile(pathContributorsFile, JSON.stringify(result, null, 4)); + } catch (err) { + // eslint-disable-next-line no-console + console.error('error on update', err); + process.exit(1); + } +})();