Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Release and Publish

on: [push]

permissions:
id-token: write
contents: write
packages: write

env:
BRANCH_TAG: "${{ github.ref_name == 'main' && 'latest' || github.ref_name }}"
BRANCH: ${{ github.ref_name }}
Expand All @@ -14,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 24
- name: Install dependencies
run: npm ci
- name: Run lint
Expand All @@ -37,7 +42,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 24

- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -72,22 +77,20 @@ jobs:
git config user.name "fundabot"
git commit -a -m "CI: bumps @fundwave/fetch-queue to $VERSION" -m "[skip ci]"

- name: Publish package to gitlab
env:
GITLAB_TOKEN: ${{secrets.GITLAB_TOKEN}}
- name: Build package
run: npm run build

Copilot AI Nov 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publish command relies on the .npmrc configured earlier, but there's no explicit '--registry' flag or scope verification. Since the package scope is '@fundwave', ensure the package.json includes '"name": "@fundwave/fetch-queue"' to match the registry configuration. Without proper scoping, the publish may fail or publish to the wrong registry.

Suggested change
- name: Verify package name scope
run: |
PKG_NAME=$(jq -r .name package.json)
if [ "$PKG_NAME" != "@fundwave/fetch-queue" ]; then
echo "Error: package.json name must be '@fundwave/fetch-queue', found '$PKG_NAME'"
exit 1
fi

Copilot uses AI. Check for mistakes.
- name: Publish package to github
run: |
echo @fundwave:registry=https://gitlab.com/api/v4/projects/24877554/packages/npm/ > ~/.npmrc
echo //gitlab.com/api/v4/projects/24877554/packages/npm/:_authToken=$GITLAB_TOKEN >> ~/.npmrc
echo "@fundwave:registry=https://npm.pkg.github.com" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
npm publish --tag $BRANCH_TAG

- name: Publish package to npm
if: ${{ github.ref_name == 'main'}}
# if: ${{ github.ref_name == 'main'}}
run: |
echo //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} > ~/.npmrc
echo registry=https://registry.npmjs.org/ >> ~/.npmrc
echo "@fundwave:registry=https://registry.npmjs.org/" >> ~/.npmrc
npm publish --tag $BRANCH_TAG --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPMJS_TOKEN}}

- name: Push changes
uses: ad-m/github-push-action@master
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fundwave/fetchq",
"version": "1.2.2",
"version": "1.2.4-github-package.1",
"description": "Queue for fetch requests",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
Expand All @@ -11,16 +11,16 @@
},
"scripts": {
"build:esm": "tsc --module NodeNext --outDir ./dist/esm",
"build": "tsc --module commonjs --outDir ./dist/cjs",
"prepare": "npm run build && npm run build:esm",
"build:cjs": "tsc --module commonjs --outDir ./dist/cjs",
"build": "npm run build:cjs && npm run build:esm",

Copilot AI Nov 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the 'prepare' script may cause issues for package consumers. The 'prepare' script automatically runs during 'npm install' and ensures the package is built before use. Without it, developers installing this package from git or using 'npm link' won't have built artifacts available. Consider keeping the 'prepare' script or documenting this breaking change.

Suggested change
"build": "npm run build:cjs && npm run build:esm",
"build": "npm run build:cjs && npm run build:esm",
"prepare": "npm run build",

Copilot uses AI. Check for mistakes.
"pretest": "jest --clearCache",
"test": "jest --detectOpenHandles",
"lint": "npx eslint src/index.ts",
"docs": "npx jsdoc-to-markdown ./src/index.ts --configure ./jsdoc2md.json > DOCUMENTATION.md"
},
"repository": {
"type": "git",
"url": "git+https://github.com/getfundwave/fetch-queue.git"
"url": "git+https://github.com/fundwave/fetch-queue.git"
},
"keywords": [
"js",
Expand All @@ -30,9 +30,9 @@
"author": "The Fundwave Authors",
"license": "MIT",
"bugs": {
"url": "https://github.com/getfundwave/fetch-queue/issues"
"url": "https://github.com/fundwave/fetch-queue/issues"
},
"homepage": "https://github.com/getfundwave/fetch-queue#readme",
"homepage": "https://github.com/fundwave/fetch-queue#readme",
"devDependencies": {
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
Expand Down
22 changes: 11 additions & 11 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FetchQueue } from "../src/index";
import { PreHook } from "../src/interfaces";

const urls = ["https://httpstat.us/500", "https://dummyjson.com/products/1", "https://dummyjson.com/products/2", "https://dummyjson.com/products/3"];
const urls = ["https://sandbox.fundwave.com/api/activity/healthchecks", "https://sandbox.fundwave.com/api/user/healthcheck", "https://sandbox.fundwave.com/api/activity/healthcheck", "https://sandbox.fundwave.com/services/api/instance/ssoconfig"];

async function wait(time: number = 1200) {
return new Promise((resolve) => {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("test case with start and pause queue", () => {
expect(fetchQueue.getActiveRequests()).toBe(0);
break;
case 2:
const regExp = /https:\/\/dummyjson\.com.*/g;
const regExp = /https:\/\/sandbox\.fundwave\.com\/api\/.*\/healthcheck$/g;
fetchQueue.emptyQueue(regExp);
expect(fetchQueue.getQueueLength()).toBe(0);
expect(fetchQueue.getActiveRequests()).toBe(0);
Expand Down Expand Up @@ -230,15 +230,15 @@ describe("test case with start and pause queue", () => {

const fetchQueue = new FetchQueue({
concurrent: 1,
pre: [{ pattern: new RegExp("https://dummyjson.com/products/\\d+"), hook }]
pre: [{ pattern: new RegExp("https://sandbox.fundwave.com/api/user/.*"), hook }]
});

fetchQueue.startQueue();

const fetch = fetchQueue.getFetchMethod();
await Promise.allSettled([
fetch("https://dummyjson.com/products/1"),
fetch("https://dummyjson.com/test"),
fetch("https://sandbox.fundwave.com/api/user/healthcheck"),
fetch("https://sandbox.fundwave.com/api/activity/healthcheck"),
]);

expect(hook).toHaveBeenCalledTimes(1);
Expand All @@ -253,19 +253,19 @@ describe("test case with start and pause queue", () => {

const fetchQueue = new FetchQueue({
concurrent: 1,
queuingPatterns: [ new RegExp("https://dummyjson.com/products/*") ],
queuingPatterns: [ new RegExp("https://sandbox.fundwave.com/api/user/.*") ],
pre: [
{ pattern: new RegExp("https://dummyjson.com/products/\\d+"), hook: notToBeCalled },
{ pattern: new RegExp("https://dummyjson.com/test"), hook: toBeCalled },
{ pattern: new RegExp("https://sandbox.fundwave.com/api/user/.*"), hook: notToBeCalled },
{ pattern: new RegExp("https://sandbox.fundwave.com/api/activity/healthcheck"), hook: toBeCalled },
]
});

fetchQueue.startQueue();
fetchQueue.pauseQueue();

const fetch = fetchQueue.getFetchMethod();
fetch("https://dummyjson.com/products/1"),
await fetch("https://dummyjson.com/test"),
fetch("https://sandbox.fundwave.com/api/user/healthcheck"),
await fetch("https://sandbox.fundwave.com/api/activity/healthcheck"),

expect(notToBeCalled).toHaveBeenCalledTimes(0);
expect(toBeCalled).toHaveBeenCalled();
Expand Down Expand Up @@ -298,7 +298,7 @@ describe("test case with start and pause queue", () => {

expect(responses.length).toBe(8);
responses.forEach((resp) => {
if (resp.ok) expect(resp.json()).resolves.not.toBeNull();
if (resp.ok) expect(resp.text()).resolves.not.toBeNull();
})
}, TEST_TIMEOUT);
});
Loading