Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8574ca8ecb | |||
| dd6940a77f |
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Cory Sanin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -31,6 +31,8 @@ outputs:
|
||||
description: whether a deletion is required or not
|
||||
destination:
|
||||
description: destination repo
|
||||
deps:
|
||||
description: which repos to enable while building
|
||||
|
||||
runs:
|
||||
using: 'node16'
|
||||
|
||||
18
dist/index.js
vendored
18
dist/index.js
vendored
@@ -41396,6 +41396,7 @@ async function parse(previous, current) {
|
||||
build: false,
|
||||
move: [],
|
||||
delete: [],
|
||||
deps: getDepRepo(actions.addRepo),
|
||||
actions,
|
||||
};
|
||||
// can't delete if there's nothing to delete/no previous success
|
||||
@@ -41422,9 +41423,6 @@ function parseRepoContents(repoContents, repository) {
|
||||
};
|
||||
});
|
||||
}
|
||||
function getDropped(oldPackages, newPackages) {
|
||||
return oldPackages.filter(p => newPackages.filter(np => np.package === p.package).length === 0);
|
||||
}
|
||||
function isDelete(actions) {
|
||||
return !!(actions.removeRepo && actions.addRepo === null);
|
||||
}
|
||||
@@ -41434,6 +41432,19 @@ function isAdd(actions) {
|
||||
function isMove(actions) {
|
||||
return !!(actions.removeRepo && actions.addRepo);
|
||||
}
|
||||
function getDepRepo(destination) {
|
||||
const split = (destination || '').split('-');
|
||||
switch (split[split.length - 1]) {
|
||||
case 'testing':
|
||||
case 'gremlins':
|
||||
return 'testing';
|
||||
case 'staging':
|
||||
case 'goblins':
|
||||
return 'staging';
|
||||
default:
|
||||
return 'stable';
|
||||
}
|
||||
}
|
||||
async function tryRead(location) {
|
||||
try {
|
||||
const contents = isUrl(location) ? await (await distribution.get(location)).text() : await promises_namespaceObject.readFile(location, { encoding: 'utf-8' });
|
||||
@@ -41518,6 +41529,7 @@ async function doParse() {
|
||||
core.setOutput('move', diff.move.length > 0);
|
||||
core.setOutput('delete', diff.delete.length > 0);
|
||||
core.setOutput('destination', diff.actions.addRepo);
|
||||
core.setOutput('deps', diff.deps);
|
||||
}
|
||||
//# sourceMappingURL=router.js.map
|
||||
;// CONCATENATED MODULE: ./lib/src/index.js
|
||||
|
||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pkgbase-yaml-parser",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pkgbase-yaml-parser",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pkgbase-yaml-parser",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "compare Artix `pkgbase.yaml` files",
|
||||
"keywords": [
|
||||
"artix",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { type PathLike } from 'fs';
|
||||
import fsp from 'fs/promises';
|
||||
import { URL } from 'url';
|
||||
import ky from 'ky';
|
||||
import * as YAML from 'yaml';
|
||||
|
||||
export type DependencyRepo = 'stable' | 'testing' | 'staging';
|
||||
|
||||
export interface PackageInfo {
|
||||
package: string;
|
||||
repository: string;
|
||||
@@ -25,6 +26,7 @@ export interface Result {
|
||||
build: boolean;
|
||||
move: PackageInfo[];
|
||||
delete: PackageInfo[];
|
||||
deps: DependencyRepo;
|
||||
actions: Actions;
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ export async function parse(previous: string, current: string): Promise<Result>
|
||||
build: false,
|
||||
move: [],
|
||||
delete: [],
|
||||
deps: getDepRepo(actions.addRepo),
|
||||
actions,
|
||||
};
|
||||
|
||||
@@ -91,10 +94,6 @@ function parseRepoContents(repoContents: RepoContents, repository: string): Pack
|
||||
});
|
||||
}
|
||||
|
||||
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 {
|
||||
return !!(actions.removeRepo && actions.addRepo === null);
|
||||
}
|
||||
@@ -107,6 +106,20 @@ function isMove(actions: Actions): boolean {
|
||||
return !!(actions.removeRepo && actions.addRepo);
|
||||
}
|
||||
|
||||
export function getDepRepo(destination: string): DependencyRepo {
|
||||
const split = (destination || '').split('-');
|
||||
switch(split[split.length - 1]) {
|
||||
case 'testing':
|
||||
case 'gremlins':
|
||||
return 'testing';
|
||||
case 'staging':
|
||||
case 'goblins':
|
||||
return 'staging';
|
||||
default:
|
||||
return 'stable';
|
||||
}
|
||||
}
|
||||
|
||||
export async function tryRead(location: string): Promise<PkgBase | null> {
|
||||
try {
|
||||
const contents = isUrl(location) ? await (await ky.get(location)).text() : await fsp.readFile(location, { encoding: 'utf-8' });
|
||||
|
||||
@@ -78,4 +78,5 @@ async function doParse() {
|
||||
core.setOutput('move', diff.move.length > 0);
|
||||
core.setOutput('delete', diff.delete.length > 0);
|
||||
core.setOutput('destination', diff.actions.addRepo);
|
||||
core.setOutput('deps', diff.deps);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parse, type Result } from '../src/pkgbase.js';
|
||||
import { parse, getDepRepo, type Result } from '../src/pkgbase.js';
|
||||
|
||||
describe('pkgbase parser', () => {
|
||||
it('can detect an add operation', async () => {
|
||||
@@ -8,6 +8,7 @@ describe('pkgbase parser', () => {
|
||||
build: true,
|
||||
move: [],
|
||||
delete: [],
|
||||
deps: 'staging',
|
||||
actions: {
|
||||
addRepo: 'system-goblins',
|
||||
removeRepo: null,
|
||||
@@ -27,6 +28,7 @@ describe('pkgbase parser', () => {
|
||||
build: true,
|
||||
move: [],
|
||||
delete: [],
|
||||
deps: 'stable',
|
||||
actions: {
|
||||
addRepo: 'world',
|
||||
removeRepo: null,
|
||||
@@ -65,6 +67,7 @@ describe('pkgbase parser', () => {
|
||||
"version": "2.14.14-3",
|
||||
}
|
||||
],
|
||||
deps: 'stable',
|
||||
actions: {
|
||||
addRepo: 'world',
|
||||
removeRepo: null,
|
||||
@@ -96,6 +99,7 @@ describe('pkgbase parser', () => {
|
||||
"repository": "world",
|
||||
"version": "1:7.9.1-1",
|
||||
}],
|
||||
deps: 'stable',
|
||||
actions: {
|
||||
addRepo: 'world',
|
||||
removeRepo: 'world-gremlins',
|
||||
@@ -147,6 +151,7 @@ describe('pkgbase parser', () => {
|
||||
"version": "2.14.14-3",
|
||||
}
|
||||
],
|
||||
deps: 'stable',
|
||||
actions: {
|
||||
addRepo: 'world',
|
||||
removeRepo: 'world-gremlins',
|
||||
@@ -158,7 +163,7 @@ describe('pkgbase parser', () => {
|
||||
}
|
||||
};
|
||||
const rDir = 'move-with-dropped';
|
||||
await expect(parse(`https://git.sanin.dev/packages_test/pkgbase-yaml-parser/raw/branch/master/test/resources/${rDir}/pkgbase.old.yaml`, path.join('test', 'resources', rDir, 'pkgbase.new.yaml'))).resolves.toEqual(expected);
|
||||
await expect(parse(`https://git.sanin.dev/packages_infra/pkgbase-yaml-parser/raw/branch/master/test/resources/${rDir}/pkgbase.old.yaml`, path.join('test', 'resources', rDir, 'pkgbase.new.yaml'))).resolves.toEqual(expected);
|
||||
});
|
||||
|
||||
it('can detect a delete operation', async () => {
|
||||
@@ -185,6 +190,7 @@ describe('pkgbase parser', () => {
|
||||
version: "3.13.0-2",
|
||||
}
|
||||
],
|
||||
deps: 'stable',
|
||||
actions: {
|
||||
addRepo: null,
|
||||
removeRepo: 'world',
|
||||
@@ -198,4 +204,10 @@ describe('pkgbase parser', () => {
|
||||
const rDir = 'remove';
|
||||
await expect(parse(path.join('test', 'resources', rDir, 'pkgbase.old.yaml'), path.join('test', 'resources', rDir, 'pkgbase.new.yaml'))).resolves.toEqual(expected);
|
||||
});
|
||||
|
||||
it('can handle Arch repos', async () => {
|
||||
expect(getDepRepo('core')).to.be.equal('stable');
|
||||
expect(getDepRepo('core-testing')).to.be.equal('testing');
|
||||
expect(getDepRepo('extra-staging')).to.be.equal('staging');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user