From 80e66a53e0b533591dcbb87bb9acb9e0c087c066 Mon Sep 17 00:00:00 2001 From: cocobo1 <122374431+C0C0B01@users.noreply.github.com> Date: Tue, 27 May 2025 21:12:30 +0300 Subject: [PATCH 1/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1dbb764..dc51c87 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Please do not donate if you are not able to, if you are able to please don't don pnpm build ``` 1. In the newly created `dist` directory, run a HTTP server. I recommend [http-server](https://www.npmjs.com/package/http-server). -1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/pupu.js`) in the new input box labelled `Pupu URL`. -1. Restart Discord. Upon reload, you should notice that your device will download Pupu's bundled code from your server, rather than GitHub. +1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/kettu.js`) in the new input box labelled `Kettu URL`. +1. Restart Discord. Upon reload, you should notice that your device will download Kettu's bundled code from your server, rather than GitHub. 1. Make your changes, rebuild, reload, go wild! Alternatively, you can directly *serve* the bundled code by running `pnpm serve`. `kettu.js` will be served on your local address under the port 4040. You will then insert `http://:4040/kettu.js` as a custom url and reload. Whenever you restart your mobile client, the script will rebuild the bundle as your client fetches it. From 5c246ff8ab50c8f11e500143a954f4f4fe72e2fa Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:25:50 -0500 Subject: [PATCH 2/7] Add GitHub Actions workflow for Node.js CI/CD --- .github/workflows/build.yaml | 89 ++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..e5999d7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,89 @@ +name: Node.js CI / CD + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + buildAndRelease: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: latest + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - run: | + pnpm build --release-branch=${{ github.ref_name }} --build-minify + + # - name: Create Release + # if: github.event_name == 'push' && github.ref == 'refs/heads/main' + # uses: actions/create-release@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # tag_name: v${{ github.run_number }} + # release_name: Release v${{ github.run_number }} + # draft: false + # prerelease: false + + - name: Push JS files to dist branch + run: | + # Configure git + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + + # Create a temporary directory for the dist branch + mkdir -p temp_dist + + # Copy only JS files from dist/ to temp directory + find dist -name "*.js" -exec cp {} temp_dist/ \; + + # Create and checkout dist branch + git checkout --orphan dist-temp + git rm -rf --cached . + + # Move the JS files to the root + cp -r temp_dist/* . + rm -rf temp_dist + + # Add, commit and push to dist branch + git add *.js + git commit -m "Update build $GITHUB_SHA" || exit 0 + git push -f origin HEAD:dist + + # Return to the original branch + git checkout -f ${GITHUB_REF#refs/heads/} From 45c28772ac00d19029af0db8c8436516ac9134b2 Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:31:13 -0500 Subject: [PATCH 3/7] Fix build workflow --- .github/workflows/build.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5999d7..fa36aab 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,8 +3,6 @@ name: Node.js CI / CD on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] jobs: buildAndRelease: From 4d6ec7c2d1bbeb52dae54d0bb51fddfbeb19f69f Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:40:38 -0500 Subject: [PATCH 4/7] Add CodeQL analysis workflow for volunerability analysis --- .github/workflows/codeql.yml | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..217386b --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,71 @@ +name: "CodeQL Advanced" + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '31 8 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + security-events: write + packages: read + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + language: [ 'javascript-typescript' ] + node-version: [20.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: latest + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: autobuilder + + - name: Build project + run: pnpm build --release-branch=${{ github.ref_name }} --build-minify + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 591624960fdd73a028a113d480f1ebfc1b836b14 Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:41:38 -0500 Subject: [PATCH 5/7] Update CodeQL workflow to use 'autobuild' mode --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 217386b..cb78cd7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -60,7 +60,7 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - build-mode: autobuilder + build-mode: autobuild - name: Build project run: pnpm build --release-branch=${{ github.ref_name }} --build-minify From 0470d3a9c0e25c9c20882d042b00b15e8b2720c5 Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:43:28 -0500 Subject: [PATCH 6/7] Update CodeQL workflow to use manual build mode with specified build command --- .github/workflows/codeql.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cb78cd7..0e701f6 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -60,10 +60,8 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - build-mode: autobuild - - - name: Build project - run: pnpm build --release-branch=${{ github.ref_name }} --build-minify + build-mode: manual + build-command: pnpm build --release-branch=${{ github.ref_name }} --build-minify - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 From cc0f43eea130aa2565583975b3749f39bff9da12 Mon Sep 17 00:00:00 2001 From: Jonathan Sydorowicz Date: Fri, 30 May 2025 12:44:43 -0500 Subject: [PATCH 7/7] Refactor CodeQL workflow to remove manual build mode and add explicit build step --- .github/workflows/codeql.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0e701f6..2134829 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -60,8 +60,10 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - build-mode: manual - build-command: pnpm build --release-branch=${{ github.ref_name }} --build-minify + build-mode: none + + - name: Build project + run: pnpm build --release-branch=${{ github.ref_name }} --build-minify - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3