more verbose delete details, fix logic
All checks were successful
Distribution check / Generated files check (push) Successful in -2m2s
NPM Audit Check / Check NPM audit (push) Successful in -2m10s
Unit tests / Unit tests (latest) (push) Successful in -2m2s
Unit tests / Unit tests (lts/*) (push) Successful in -2m2s
Unit tests / Unit tests (lts/hydrogen) (push) Successful in -2m1s
All checks were successful
Distribution check / Generated files check (push) Successful in -2m2s
NPM Audit Check / Check NPM audit (push) Successful in -2m10s
Unit tests / Unit tests (latest) (push) Successful in -2m2s
Unit tests / Unit tests (lts/*) (push) Successful in -2m2s
Unit tests / Unit tests (lts/hydrogen) (push) Successful in -2m1s
This commit is contained in:
@@ -12,20 +12,30 @@ async function parse(previous, current) {
|
|||||||
};
|
};
|
||||||
if (isDelete(actions)) {
|
if (isDelete(actions)) {
|
||||||
const repo = prev.repos[actions.removeRepo];
|
const repo = prev.repos[actions.removeRepo];
|
||||||
result.delete.push(...repo.packages.map(p => `${actions.removeRepo}/${p.split(`-${repo.version}`)[0]}`));
|
result.delete.push(...parseRepoContents(repo, actions.removeRepo));
|
||||||
}
|
}
|
||||||
else if (result.move = isMove(actions)) {
|
else if (prev && (result.move = isMove(actions))) {
|
||||||
result.delete.push(...getDropped(prev.repos[actions.addRepo], curr.repos[actions.removeRepo]));
|
const moving = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo);
|
||||||
|
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving));
|
||||||
|
result.delete.push(...moving);
|
||||||
}
|
}
|
||||||
else if (result.build = isAdd(actions)) {
|
else if ((result.build = isAdd(actions)) && prev) {
|
||||||
result.delete.push(...getDropped(prev.repos[actions.addRepo], curr.repos[actions.addRepo]));
|
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo)));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
function getDropped(oldRepoContents, newRepoContents) {
|
function parseRepoContents(repoContents, repository) {
|
||||||
const oldPackages = oldRepoContents.packages.map(p => p.split(`-${oldRepoContents.version}`)[0]);
|
return repoContents.packages.map(p => {
|
||||||
const newPackages = newRepoContents.packages.map(p => p.split(`-${newRepoContents.version}`)[0]);
|
return {
|
||||||
return oldPackages.filter(p => newPackages.indexOf(p) === -1);
|
version: repoContents.version,
|
||||||
|
repository,
|
||||||
|
package: p.split(`-${repoContents.version}`)[0],
|
||||||
|
architecture: p.split(`${repoContents.version}-`)[1].split('.')[0]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getDropped(oldPackages, newPackages) {
|
||||||
|
return oldPackages.filter(p => newPackages.filter(np => np.package === p.package).length === 0);
|
||||||
}
|
}
|
||||||
function isDelete(actions) {
|
function isDelete(actions) {
|
||||||
return !!(actions.removeRepo && actions.addRepo === null);
|
return !!(actions.removeRepo && actions.addRepo === null);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -24,7 +24,14 @@ describe('pkgbase parser', () => {
|
|||||||
const expected = {
|
const expected = {
|
||||||
build: true,
|
build: true,
|
||||||
move: false,
|
move: false,
|
||||||
delete: ['pidgin'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "pidgin",
|
||||||
|
repository: "world",
|
||||||
|
version: "2.14.14-3",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: null,
|
removeRepo: null,
|
||||||
@@ -42,7 +49,12 @@ describe('pkgbase parser', () => {
|
|||||||
const expected = {
|
const expected = {
|
||||||
build: false,
|
build: false,
|
||||||
move: true,
|
move: true,
|
||||||
delete: ['opencascade'],
|
delete: [{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "opencascade",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "1:7.9.2-1",
|
||||||
|
}],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: 'world-gremlins',
|
removeRepo: 'world-gremlins',
|
||||||
@@ -60,7 +72,26 @@ describe('pkgbase parser', () => {
|
|||||||
const expected = {
|
const expected = {
|
||||||
build: false,
|
build: false,
|
||||||
move: true,
|
move: true,
|
||||||
delete: ['pidgin', 'libpurple', 'finch'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "pidgin",
|
||||||
|
repository: "world",
|
||||||
|
version: "2.14.14-3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "libpurple",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "2.14.14-4",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "finch",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "2.14.14-4",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: 'world-gremlins',
|
removeRepo: 'world-gremlins',
|
||||||
@@ -78,7 +109,26 @@ describe('pkgbase parser', () => {
|
|||||||
const expected = {
|
const expected = {
|
||||||
build: false,
|
build: false,
|
||||||
move: false,
|
move: false,
|
||||||
delete: ['world/python-nntplib', 'world/python-cgi', 'world/python-mailcap'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-nntplib",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-cgi",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-mailcap",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: null,
|
addRepo: null,
|
||||||
removeRepo: 'world',
|
removeRepo: 'world',
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -2,6 +2,13 @@ import { type PathLike } from 'fs';
|
|||||||
import fsp from 'fs/promises';
|
import fsp from 'fs/promises';
|
||||||
import * as YAML from 'yaml';
|
import * as YAML from 'yaml';
|
||||||
|
|
||||||
|
interface PackageInfo {
|
||||||
|
package: string;
|
||||||
|
repository: string;
|
||||||
|
version: string;
|
||||||
|
architecture: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface Actions {
|
interface Actions {
|
||||||
addRepo: string | null;
|
addRepo: string | null;
|
||||||
removeRepo: string | null;
|
removeRepo: string | null;
|
||||||
@@ -15,7 +22,7 @@ interface Actions {
|
|||||||
interface Result {
|
interface Result {
|
||||||
build: boolean;
|
build: boolean;
|
||||||
move: boolean;
|
move: boolean;
|
||||||
delete: string[];
|
delete: PackageInfo[];
|
||||||
actions: Actions;
|
actions: Actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,22 +64,33 @@ async function parse(previous: PathLike, current: PathLike): Promise<Result> {
|
|||||||
|
|
||||||
if (isDelete(actions)) {
|
if (isDelete(actions)) {
|
||||||
const repo: RepoContents = prev.repos[actions.removeRepo];
|
const repo: RepoContents = prev.repos[actions.removeRepo];
|
||||||
result.delete.push(...repo.packages.map(p => `${actions.removeRepo}/${p.split(`-${repo.version}`)[0]}`));
|
result.delete.push(...parseRepoContents(repo, actions.removeRepo));
|
||||||
}
|
}
|
||||||
else if (result.move = isMove(actions)) {
|
else if (prev && (result.move = isMove(actions))) {
|
||||||
result.delete.push(...getDropped(prev.repos[actions.addRepo], curr.repos[actions.removeRepo]));
|
const moving = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo);
|
||||||
|
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving));
|
||||||
|
result.delete.push(...moving);
|
||||||
}
|
}
|
||||||
else if (result.build = isAdd(actions)) {
|
else if ((result.build = isAdd(actions)) && prev) {
|
||||||
result.delete.push(...getDropped(prev.repos[actions.addRepo], curr.repos[actions.addRepo]));
|
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDropped(oldRepoContents: RepoContents, newRepoContents: RepoContents): string[] {
|
function parseRepoContents(repoContents: RepoContents, repository: string): PackageInfo[] {
|
||||||
const oldPackages = oldRepoContents.packages.map(p => p.split(`-${oldRepoContents.version}`)[0]);
|
return repoContents.packages.map(p => {
|
||||||
const newPackages = newRepoContents.packages.map(p => p.split(`-${newRepoContents.version}`)[0]);
|
return {
|
||||||
return oldPackages.filter(p => newPackages.indexOf(p) === -1);
|
version: repoContents.version,
|
||||||
|
repository,
|
||||||
|
package: p.split(`-${repoContents.version}`)[0],
|
||||||
|
architecture: p.split(`${repoContents.version}-`)[1].split('.')[0]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropped(oldPackages: PackageInfo[], newPackages: PackageInfo[]): PackageInfo[] {
|
||||||
|
return oldPackages.filter(p => newPackages.filter(np => np.package === p.package).length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDelete(actions: Actions): boolean {
|
function isDelete(actions: Actions): boolean {
|
||||||
@@ -98,4 +116,4 @@ async function tryRead(file: PathLike): Promise<PkgBase | null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { parse };
|
export { parse };
|
||||||
export type { Actions, Result, RepoContents, PkgBase };
|
export type { Actions, Result, RepoContents, PkgBase, PackageInfo };
|
||||||
|
|||||||
@@ -26,7 +26,14 @@ describe('pkgbase parser', () => {
|
|||||||
const expected: Result = {
|
const expected: Result = {
|
||||||
build: true,
|
build: true,
|
||||||
move: false,
|
move: false,
|
||||||
delete: ['pidgin'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "pidgin",
|
||||||
|
repository: "world",
|
||||||
|
version: "2.14.14-3",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: null,
|
removeRepo: null,
|
||||||
@@ -45,7 +52,12 @@ describe('pkgbase parser', () => {
|
|||||||
const expected: Result = {
|
const expected: Result = {
|
||||||
build: false,
|
build: false,
|
||||||
move: true,
|
move: true,
|
||||||
delete: ['opencascade'],
|
delete: [{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "opencascade",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "1:7.9.2-1",
|
||||||
|
}],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: 'world-gremlins',
|
removeRepo: 'world-gremlins',
|
||||||
@@ -64,7 +76,26 @@ describe('pkgbase parser', () => {
|
|||||||
const expected: Result = {
|
const expected: Result = {
|
||||||
build: false,
|
build: false,
|
||||||
move: true,
|
move: true,
|
||||||
delete: ['pidgin', 'libpurple', 'finch'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "pidgin",
|
||||||
|
repository: "world",
|
||||||
|
version: "2.14.14-3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "libpurple",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "2.14.14-4",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "x86_64",
|
||||||
|
package: "finch",
|
||||||
|
repository: "world-gremlins",
|
||||||
|
version: "2.14.14-4",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: 'world',
|
addRepo: 'world',
|
||||||
removeRepo: 'world-gremlins',
|
removeRepo: 'world-gremlins',
|
||||||
@@ -83,7 +114,26 @@ describe('pkgbase parser', () => {
|
|||||||
const expected: Result = {
|
const expected: Result = {
|
||||||
build: false,
|
build: false,
|
||||||
move: false,
|
move: false,
|
||||||
delete: ['world/python-nntplib', 'world/python-cgi', 'world/python-mailcap'],
|
delete: [
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-nntplib",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-cgi",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
architecture: "any",
|
||||||
|
package: "python-mailcap",
|
||||||
|
repository: "world",
|
||||||
|
version: "3.13.0-2",
|
||||||
|
}
|
||||||
|
],
|
||||||
actions: {
|
actions: {
|
||||||
addRepo: null,
|
addRepo: null,
|
||||||
removeRepo: 'world',
|
removeRepo: 'world',
|
||||||
|
|||||||
Reference in New Issue
Block a user