diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..ba43332 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,36 @@ +name: "Setup" +description: "Install Node.js and pnpm and set up caching" +inputs: + node-version: + description: "Version of Node.js to use" + required: false + default: "22" + pnpm-version: + description: "Version of pnpm to install" + required: false + default: "9.1.0" + env: + description: "Build Environment" + required: false + default: "production" +runs: + using: "composite" + steps: + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + version: ${{ inputs.pnpm-version }} + run_install: true + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'pnpm' + + # Build the SDK + - name: Project build + shell: bash + run: pnpm build:clean + env: + NODE_ENV: ${{ inputs.node_env }} diff --git a/.github/workflows/bundle-size_compare.yml b/.github/workflows/bundle-size_compare.yml new file mode 100644 index 0000000..0b9e42d --- /dev/null +++ b/.github/workflows/bundle-size_compare.yml @@ -0,0 +1,78 @@ +name: 'Bundle Sizes' + +on: + pull_request: + pull_request_target: + +jobs: + # Build and upload stats for `head` + build: + name: 'Upload ${{ matrix.target }} stats for ${{ github.event.pull_request.head.ref }}' + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + target: [browser, node] # Runs for both browser and node bundles + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup pnpm + uses: ./.github/actions/setup + + - name: Upload stats.json + uses: actions/upload-artifact@v4 + with: + name: head-stats-${{ matrix.target }} + path: .stats/bundle.${{ matrix.target }}.json + + # Build base stats for comparison + build-base: + name: 'Upload ${{ matrix.target }} stats for ${{ github.base_ref }}' + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + target: [browser, node] + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: Setup pnpm + uses: ./.github/actions/setup + + - name: Upload stats.json + uses: actions/upload-artifact@v4 + with: + name: base-stats-${{ matrix.target }} + path: .stats/bundle.${{ matrix.target }}.json + + # Compare base and head stats.json files + compare: + name: 'Bundle sizes comparison for ${{ matrix.target }}' + runs-on: ubuntu-latest + needs: [build, build-base] + permissions: + pull-requests: write + strategy: + matrix: + target: [browser, node] + steps: + - uses: actions/download-artifact@v4 + with: + name: head-stats-${{ matrix.target }} + + - uses: actions/download-artifact@v4 + with: + name: base-stats-${{ matrix.target }} + + - uses: twk3/rollup-size-compare-action@v1.0.0 + with: + title: ${{ matrix.target }} + github-token: ${{ secrets.GITHUB_TOKEN }} + current-stats-json-path: ./head-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json + base-stats-json-path: ./base-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 8c221b9..bf96b50 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -14,17 +14,14 @@ jobs: commitlint: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - uses: pnpm/action-setup@v4 - name: Install pnpm + - name: Checkout + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup + name: Setup with: - version: 9.1.0 - run_install: true + node-version: ${{ matrix.node }} + - name: Validate PR commits with commitlint if: github.event_name == 'pull_request' run: pnpx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/.github/workflows/issues_dailyCron.yml b/.github/workflows/issues_daily-cron.yml similarity index 80% rename from .github/workflows/issues_dailyCron.yml rename to .github/workflows/issues_daily-cron.yml index d230cbb..2467a53 100644 --- a/.github/workflows/issues_dailyCron.yml +++ b/.github/workflows/issues_daily-cron.yml @@ -12,7 +12,7 @@ jobs: cron-tasks: runs-on: ubuntu-latest steps: - - name: check for inactive issues that can't be reproduced + - name: Check for inactive issues that can't be reproduced uses: actions-cool/issues-helper@v3 with: actions: 'close-issues' @@ -25,6 +25,6 @@ jobs: As we have not received any new or updated information to reproduce this issue in the last 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we will consider reopening it. - If anyone else has updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues. + If anyone else has updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. Thank you and have a great day! diff --git a/.github/workflows/issues_handleLabel.yml b/.github/workflows/issues_handleLabel.yml index a4af438..bba1c54 100644 --- a/.github/workflows/issues_handleLabel.yml +++ b/.github/workflows/issues_handleLabel.yml @@ -50,7 +50,7 @@ jobs: Hello @${{ github.event.issue.user.login }}, - We ask that you please follow the [issue template](https://raw.githubusercontent.com/strapi/strapi/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md). + We ask that you please follow the [issue template](https://github.com/strapi/sdk-js/issues/new/choose). A proper issue submission let's us better understand the origin of your bug and therefore help you. We will reopen your issue when we receive the issue following the template guidelines and properly fill out the template. You can see the template guidelines for bug reports [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue). Please update the issue with the template and we can reopen this report. @@ -83,8 +83,6 @@ jobs: - questions should be directed to [our forum](https://forum.strapi.io) or our [Discord](https://discord.strapi.io) - feature requests should be directed to our [feedback and feature request database](https://feedback.strapi.io) - Please see the following contributing guidelines for asking a question [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue). - Thank you. - name: 'Close: redirect question to community' if: "${{ github.event.label.name == 'flag: question' }}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index b3db83c..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: 'Tests' - -on: - push: - branches: - - main - pull_request: - -permissions: - contents: read # to fetch code (actions/checkout) - actions: read - -jobs: - cache-and-install: - runs-on: ubuntu-latest - - strategy: - matrix: - node: [20, 22] - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - version: 9.1.0 - run_install: true - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - - build: - name: 'build (node: ${{ matrix.node }})' - needs: [cache-and-install] - runs-on: ubuntu-latest - strategy: - matrix: - node: [20, 22] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - version: 9.1.0 - run_install: true - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: 'pnpm' - - - name: Project build - shell: bash - run: pnpm run build:clean - - unit_back: - name: 'unit_back (node: ${{ matrix.node }})' - needs: [cache-and-install, build] - runs-on: ubuntu-latest - strategy: - matrix: - node: [20, 22] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - version: 9.1.0 - run_install: true - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: 'pnpm' - - - name: Run tests - run: pnpm run test diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..6a9429b --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,30 @@ +name: 'Unit Tests' + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read # to fetch code (actions/checkout) + actions: read + +jobs: + unit_tests: + name: 'Unit Tests (node: ${{ matrix.node }})' + runs-on: ubuntu-latest + strategy: + matrix: + node: [20, 22] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup + name: Setup + with: + node-version: ${{ matrix.node }} + + - name: Run tests + run: pnpm run test diff --git a/.gitignore b/.gitignore index c894534..cc6a825 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ nbproject .coverage .node_history +.stats dist lcov.info lib-cov diff --git a/package.json b/package.json index ea852e5..45e5c17 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "prettier": "3.3.3", "rimraf": "6.0.1", "rollup": "4.27.3", + "rollup-plugin-visualizer": "5.12.0", "ts-jest": "29.2.5", "typescript": "5.6.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 059393c..9a850a9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: rollup: specifier: 4.27.3 version: 4.27.3 + rollup-plugin-visualizer: + specifier: 5.12.0 + version: 5.12.0(rollup@4.27.3) ts-jest: specifier: 29.2.5 version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@22.10.2))(typescript@5.6.3) @@ -1231,6 +1234,10 @@ packages: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} + define-lazy-prop@2.0.0: + resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} + engines: {node: '>=8'} + define-properties@1.2.1: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} @@ -1874,6 +1881,11 @@ packages: resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} engines: {node: '>= 0.4'} + is-docker@2.2.1: + resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} + engines: {node: '>=8'} + hasBin: true + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -1984,6 +1996,10 @@ packages: resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} engines: {node: '>= 0.4'} + is-wsl@2.2.0: + resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} + engines: {node: '>=8'} + isarray@2.0.5: resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} @@ -2451,6 +2467,10 @@ packages: resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} engines: {node: '>=18'} + open@8.4.2: + resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} + engines: {node: '>=12'} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -2679,6 +2699,16 @@ packages: engines: {node: 20 || >=22} hasBin: true + rollup-plugin-visualizer@5.12.0: + resolution: {integrity: sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ==} + engines: {node: '>=14'} + hasBin: true + peerDependencies: + rollup: 2.x || 3.x || 4.x + peerDependenciesMeta: + rollup: + optional: true + rollup@4.27.3: resolution: {integrity: sha512-SLsCOnlmGt9VoZ9Ek8yBK8tAdmPHeppkw+Xa7yDlCEhDTvwYei03JlWo1fdc7YTfLZ4tD8riJCUyAgTbszk1fQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -2777,6 +2807,10 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + source-map@0.7.4: + resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} + engines: {node: '>= 8'} + split2@4.2.0: resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} engines: {node: '>= 10.x'} @@ -4510,6 +4544,8 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 + define-lazy-prop@2.0.0: {} + define-properties@1.2.1: dependencies: define-data-property: 1.1.4 @@ -5374,6 +5410,8 @@ snapshots: call-bound: 1.0.3 has-tostringtag: 1.0.2 + is-docker@2.2.1: {} + is-extglob@2.1.1: {} is-finalizationregistry@1.1.1: @@ -5466,6 +5504,10 @@ snapshots: call-bound: 1.0.3 get-intrinsic: 1.2.6 + is-wsl@2.2.0: + dependencies: + is-docker: 2.2.1 + isarray@2.0.5: {} isexe@2.0.0: {} @@ -6113,6 +6155,12 @@ snapshots: dependencies: mimic-function: 5.0.1 + open@8.4.2: + dependencies: + define-lazy-prop: 2.0.0 + is-docker: 2.2.1 + is-wsl: 2.2.0 + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -6313,6 +6361,15 @@ snapshots: glob: 11.0.0 package-json-from-dist: 1.0.1 + rollup-plugin-visualizer@5.12.0(rollup@4.27.3): + dependencies: + open: 8.4.2 + picomatch: 2.3.1 + source-map: 0.7.4 + yargs: 17.7.2 + optionalDependencies: + rollup: 4.27.3 + rollup@4.27.3: dependencies: '@types/estree': 1.0.6 @@ -6447,6 +6504,8 @@ snapshots: source-map@0.6.1: {} + source-map@0.7.4: {} + split2@4.2.0: {} sprintf-js@1.0.3: {} diff --git a/rollup.config.mjs b/rollup.config.mjs index fd755f1..d35297e 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -3,6 +3,7 @@ import nodeResolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import replace from '@rollup/plugin-replace'; import terser from '@rollup/plugin-terser'; +import { visualizer } from 'rollup-plugin-visualizer'; const isProduction = process.env.NODE_ENV === 'production'; @@ -65,6 +66,8 @@ const node_build = { }), // Only minify in production isProduction && terser(), + // Analysis and visualization artifacts + visualizer({ filename: '.stats/bundle.node.json', template: 'raw-data' }), ], }; @@ -120,7 +123,10 @@ const browser_build = { 'process.browser': true, preventAssignment: true, }), + // Minify the code terser(), + // Analysis and visualization artifacts + visualizer({ filename: '.stats/bundle.browser.json', template: 'raw-data' }), ], };