Skip to content

Commit

Permalink
Replace request with fetch in ci-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ljowen committed Mar 12, 2025
1 parent 2266006 commit 5f2dcc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Remove unused `arraysAreEqual`, `autoUpdate`, `flattenNested`, `freezeInDebug`, `isPromise`, `loadJsonp`, `OrUndefined`, and `superGet` files from lib/Core.
- Update to react-virtual 2.10.4.
- Update types/file-saver to 2.0.7.
- Remove `request` dependency from CI scripts
- [The next improvement]

#### 8.8.1 - 2025-02-27
Expand Down
39 changes: 13 additions & 26 deletions buildprocess/ci-cleanup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
const childProcess = require("child_process");
const fs = require("fs");
const request = require("request");

function requestPromise(options) {
return new Promise((resolve, reject) => {
request(options, (error, response, body) => {
if (error) {
reject(error);
} else {
resolve(response);
}
});
});
}

function getAllBranches(repo) {
const baseUrl = "https://api.github.com/repos/" + repo + "/branches";
Expand All @@ -24,24 +11,24 @@ function getAllBranches(repo) {
++page;

let url = baseUrl + "?page=" + page;
return requestPromise({
url: url,
return fetch(url, {
headers: {
"User-Agent": "TerriaJS CI",
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`
}
}).then((pageResponse) => {
const pageOfBranches = JSON.parse(pageResponse.body);
result.push(
...pageOfBranches.filter(
(branch) => branch.name.indexOf("greenkeeper/") !== 0
)
);
})
.then((response) => response.json())
.then((pageOfBranches) => {
result.push(
...pageOfBranches.filter(
(branch) => branch.name.indexOf("greenkeeper/") !== 0
)
);

if (pageOfBranches.length > 0) {
return getNextPage();
}
});
if (pageOfBranches.length > 0) {
return getNextPage();
}
});
}

return getNextPage().then(() => result);
Expand Down
1 change: 0 additions & 1 deletion buildprocess/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gh api /repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} -f state=pending -f co
# Install some tools we need from npm
npm install -g https://github.com/terriajs/sync-dependencies
npm install -g yarn@^1.19.0
yarn add -W [email protected]

# Clone and build TerriaMap, using this version of TerriaJS
TERRIAJS_COMMIT_HASH=$(git rev-parse HEAD)
Expand Down

0 comments on commit 5f2dcc2

Please sign in to comment.