4 Commits

6 changed files with 125 additions and 46 deletions

22
.vscode/launch.json vendored
View File

@@ -5,16 +5,30 @@
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"env": {
"JOB": "jobs/example.json5"
"GPGPASS": "${input:gpgpass}"
},
"program": "${workspaceFolder}/index.js"
"program": "${workspaceFolder}/bin/artix-metro.mjs",
"args": [
"--job",
"jobs/kde-01.json5"
],
"outFiles": [
"${workspaceFolder}/distribution/*"
]
}
]
],
"inputs": [
{
"id": "gpgpass",
"type": "promptString",
"description": "Enter your GPG password"
}
]
}

View File

@@ -57,6 +57,7 @@ _artix_metro_completion() {
COMPREPLY=()
;;
"-j"|"--job")
compopt -o filenames
COMPREPLY=( $(compgen -f -- "$cur") )
;;
"--workspace")

60
package-lock.json generated
View File

@@ -1,19 +1,19 @@
{
"name": "artix-metro",
"version": "3.1.0",
"version": "3.1.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "artix-metro",
"version": "3.1.0",
"version": "3.1.2",
"license": "MIT",
"dependencies": {
"artix-checkupdates": "1.0.1",
"artix-checkupdates": "1.0.2",
"cli-color": "2.0.4",
"glob": "11.0.1",
"json5": "2.2.3",
"ky": "1.7.4"
"ky": "1.7.5"
},
"bin": {
"artix-metro": "bin/artix-metro.mjs"
@@ -21,8 +21,8 @@
"devDependencies": {
"@sindresorhus/tsconfig": "7.0.0",
"@types/cli-color": "2.0.6",
"@types/node": "22.10.7",
"typescript": "5.7.3"
"@types/node": "22.13.10",
"typescript": "5.8.2"
}
},
"node_modules/@isaacs/cliui": {
@@ -63,9 +63,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "22.10.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
"version": "22.13.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz",
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -97,9 +97,9 @@
}
},
"node_modules/artix-checkupdates": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.1.tgz",
"integrity": "sha512-C0AxI3SfoUUekYg3ft/y4+tRjIe8uuDLvBQRSmkfNsRuBLNlEHaxhY/93JB6G4AGXp5RFLZYDnbgjakgbTLhkw==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.2.tgz",
"integrity": "sha512-VTLeMVysGeZ3QiLtEyWoVM8D57YyeYhYQoL3vcW9b0dZE+zhE4di80PYEFGeQzIBcCStcBFnI1uSBoAEHMVHAQ==",
"license": "MIT"
},
"node_modules/balanced-match": {
@@ -357,9 +357,9 @@
}
},
"node_modules/ky": {
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.4.tgz",
"integrity": "sha512-zYEr/gh7uLW2l4su11bmQ2M9xLgQLjyvx58UyNM/6nuqyWFHPX5ktMjvpev3F8QWdjSsHUpnWew4PBCswBNuMQ==",
"version": "1.7.5",
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.5.tgz",
"integrity": "sha512-HzhziW6sc5m0pwi5M196+7cEBtbt0lCYi67wNsiwMUmz833wloE0gbzJPWKs1gliFKQb34huItDQX97LyOdPdA==",
"license": "MIT",
"engines": {
"node": ">=18"
@@ -604,9 +604,9 @@
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
},
"node_modules/typescript": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
"version": "5.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -758,9 +758,9 @@
"dev": true
},
"@types/node": {
"version": "22.10.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
"version": "22.13.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz",
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==",
"dev": true,
"requires": {
"undici-types": "~6.20.0"
@@ -777,9 +777,9 @@
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="
},
"artix-checkupdates": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.1.tgz",
"integrity": "sha512-C0AxI3SfoUUekYg3ft/y4+tRjIe8uuDLvBQRSmkfNsRuBLNlEHaxhY/93JB6G4AGXp5RFLZYDnbgjakgbTLhkw=="
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.2.tgz",
"integrity": "sha512-VTLeMVysGeZ3QiLtEyWoVM8D57YyeYhYQoL3vcW9b0dZE+zhE4di80PYEFGeQzIBcCStcBFnI1uSBoAEHMVHAQ=="
},
"balanced-match": {
"version": "1.0.2",
@@ -982,9 +982,9 @@
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
},
"ky": {
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.4.tgz",
"integrity": "sha512-zYEr/gh7uLW2l4su11bmQ2M9xLgQLjyvx58UyNM/6nuqyWFHPX5ktMjvpev3F8QWdjSsHUpnWew4PBCswBNuMQ=="
"version": "1.7.5",
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.5.tgz",
"integrity": "sha512-HzhziW6sc5m0pwi5M196+7cEBtbt0lCYi67wNsiwMUmz833wloE0gbzJPWKs1gliFKQb34huItDQX97LyOdPdA=="
},
"lru-cache": {
"version": "11.0.2",
@@ -1147,9 +1147,9 @@
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
},
"typescript": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
"version": "5.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
"dev": true
},
"undici-types": {

View File

@@ -1,6 +1,6 @@
{
"name": "artix-metro",
"version": "3.1.0",
"version": "3.1.2",
"description": "Automate pushing packages to Artix",
"keywords": [
"artix",
@@ -31,16 +31,16 @@
},
"license": "MIT",
"dependencies": {
"artix-checkupdates": "1.0.1",
"artix-checkupdates": "1.0.2",
"cli-color": "2.0.4",
"ky": "1.7.4",
"ky": "1.7.5",
"json5": "2.2.3",
"glob": "11.0.1"
},
"devDependencies": {
"typescript": "5.7.3",
"typescript": "5.8.2",
"@sindresorhus/tsconfig": "7.0.0",
"@types/cli-color": "2.0.6",
"@types/node": "22.10.7"
"@types/node": "22.13.10"
}
}

View File

@@ -1,7 +1,7 @@
import ky from 'ky';
import { snooze } from './snooze.mjs';
type CiStatus = "pending" | "success" | "error" | "failure";
type CiStatus = "pending" | "success" | "error" | "failure" | "";
interface GiteaConfig {
protocol?: string;
@@ -16,7 +16,12 @@ interface Commit {
interface Status {
sha: string;
state: CiStatus
state: CiStatus;
}
interface Hook {
active: boolean;
id: number;
}
class Gitea {
@@ -95,7 +100,43 @@ class Gitea {
}
}
async getHooks(...args: string[]): Promise<Hook[]> {
try {
let headers: HeadersInit = {};
if (this._token) {
headers['Authorization'] = `token ${this._token}`
}
const resp = await ky.get(`${this.getUrlPrefix()}/repos/${args.join('/')}/hooks`, {
headers
});
return await resp.json();
}
catch (err) {
throw err;
}
}
async sendTestWebhook(...args: string[]): Promise<void> {
try {
let headers: HeadersInit = {};
if (this._token) {
headers['Authorization'] = `token ${this._token}`
}
const hook = (await this.getHooks(...args)).find(hook => hook.active === true);
if (!hook) {
throw new Error('No active webhook found');
}
await ky.post(`${this.getUrlPrefix()}/repos/${args.join('/')}/hooks/${hook.id}/tests`, {
headers
});
}
catch (err) {
throw err;
}
}
async waitForBuild(lastHash: string, ...args: string[]): Promise<void> {
let missingStatusCount = 0;
while (true) {
let status: Status | null;
try {
@@ -108,7 +149,15 @@ class Gitea {
await snooze(30000);
continue;
}
if (status.sha !== lastHash) {
if (!status.sha && !status.state) {
if (++missingStatusCount > 3) {
console.log('No build info detected. Sending test webhook...');
missingStatusCount = 0;
await this.sendTestWebhook(...args);
}
await snooze(30000);
}
else if (status.sha !== lastHash) {
if (status.state === 'success') {
break;
}

View File

@@ -58,10 +58,25 @@ class Pusher {
if (await isPasswordRequired()) {
console.log(clc.cyan('Refreshing signature...'));
this._createdSignfile ||= await runCommand('touch', [SIGNFILE]);
await runCommand('gpg', ['-a', '--passphrase', escapeCommandParam(this._config.gpgpass || ''), '--batch', '--pinentry-mode', 'loopback', '--detach-sign', SIGNFILE]);
await fsp.rm(`${SIGNFILE}.asc`);
if ('SSHKEYSIGN' in process.env)
{
await runCommand('ssh-keygen', [ '-Y', 'sign', '-f', path.resolve(process.env['SSHKEYSIGN'] as string), '-n', ' git', SIGNFILE]);
}
else
{
await runCommand('gpg', ['-a', '--passphrase', escapeCommandParam(this._config.gpgpass || ''), '--batch', '--pinentry-mode', 'loopback', '--detach-sign', SIGNFILE]);
}
if ('SSHKEYSIGN' in process.env)
{
await fsp.rm(`${SIGNFILE}.sig`)
}
else
{
await fsp.rm(`${SIGNFILE}.asc`)
}
}
}
}
increment(pkg: string): Promise<void> {
return new Promise(async (res, _) => {
@@ -133,7 +148,7 @@ class Pusher {
}
console.log(clc.yellowBright('Running artix-checkupdates'));
const actionable = job.increment ? job.packages : (await (!!job.source ? checkupdates.fetchMovable() : checkupdates.fetchUpgradable())).map(res => res.basename);
const actionable = job.increment ? job.packages : (await (!!job.source ? checkupdates.fetchLooseMovable() : checkupdates.fetchUpgradable())).map(res => res.basename);
// order is IMPORTANT. Must be BLOCKING.
for (let i = 0; i < (job.packages || []).length; i++) {