Skip to content

Commit

Permalink
log requesting package lists in pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaresincic committed Sep 7, 2022
1 parent 602dc1e commit e310c3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
11 changes: 5 additions & 6 deletions delete-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async function findAll(
cursor = null
) {
while (true) {
info("a new page grab");
let rsp = await graphql(token, query, {
...params,
after: cursor,
Expand All @@ -27,9 +28,13 @@ async function findAll(
}

async function findAllPackageVersions(token, package, owner, repo) {
info(
"Complete package versions data JSON: " + JSON.stringify(package.versions)
);
let versions = package.versions.edges.map((edge) => edge.node);
const pageInfo = package.versions.pageInfo;
if (pageInfo.hasNextPage) {
info("starts finding packages by pages");
await findAll(
token,
queries.packageVersions,
Expand Down Expand Up @@ -72,15 +77,11 @@ async function deletePackageVersions(
const toDelete = [];
for (const key in majorVersions) {
let vs = majorVersions[key];
info("All versions: ");
vs.map((v) => info("v: " + v.version));
vs = vs.reverse();
if (vs.length <= keepCnt) {
continue;
}
info("vs.length before slice: " + vs.length + " keepCnt: " + keepCnt);
vs = vs.slice(0, vs.length - keepCnt);
info("vs.length after slice: " + vs.length);
vs.forEach((v) => {
toDelete.push(v);
});
Expand Down Expand Up @@ -116,9 +117,7 @@ module.exports = async function (inputs) {
},
(rsp) => rsp.repository.packages
);
info("All packages list:");
packages = packages.filter((p) => {
info(p.name);
return !p.name.startsWith("deleted_");
});

Expand Down
11 changes: 5 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit e310c3b

Please sign in to comment.