6 Commits

Author SHA1 Message Date
fca8e679c5 increment mirrorUrlCounter before referencing 2025-07-31 21:52:01 -05:00
9de4542b56 country defaults to undefined 2025-07-31 21:50:34 -05:00
567c888c08 Actually update mirror info 2025-07-31 20:14:45 -05:00
0d8308e06a "better than nothing" 2025-07-31 02:06:05 -05:00
1fcc4d46da Show inactive URLs in markdown 2025-07-31 02:01:48 -05:00
f60aeceb5f fix anchor links 2025-07-31 01:46:26 -05:00
3 changed files with 17 additions and 14 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "artix-mlg", "name": "artix-mlg",
"version": "0.2.4", "version": "0.2.6",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "artix-mlg", "name": "artix-mlg",
"version": "0.2.4", "version": "0.2.6",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"country-code-lookup": "0.1.3", "country-code-lookup": "0.1.3",

View File

@@ -1,6 +1,6 @@
{ {
"name": "artix-mlg", "name": "artix-mlg",
"version": "0.2.4", "version": "0.2.6",
"description": "mirrorlist generator for Artix Linux", "description": "mirrorlist generator for Artix Linux",
"keywords": [ "keywords": [
"artix", "artix",

View File

@@ -118,9 +118,9 @@ function getMirror(name: string): Mirror {
function updateMirror(m: Mirror, profile: MirrorProfile, url: UrlComponents) { function updateMirror(m: Mirror, profile: MirrorProfile, url: UrlComponents) {
m.fields.tier = Math.max(m.fields.tier, profile.tier); m.fields.tier = Math.max(m.fields.tier, profile.tier);
m.fields.admin_email ||= profile.admin_email || ''; m.fields.admin_email = profile.admin_email || m.fields.admin_email;
m.fields.alternate_email ||= profile.alternate_email || ''; m.fields.alternate_email = profile.alternate_email || m.fields.alternate_email;
m.fields.notes ||= profile.notes || ''; m.fields.notes = profile.notes || m.fields.notes;
m.fields.active ||= profile.active; m.fields.active ||= profile.active;
m.fields.public &&= profile.public; m.fields.public &&= profile.public;
m.fields.isos ||= !!profile.stable_isos || !!profile.weekly_isos; m.fields.isos ||= !!profile.stable_isos || !!profile.weekly_isos;
@@ -135,13 +135,13 @@ function processMirrorProfile(m: MirrorProfile) {
const mirror: Mirror = getMirror(m.force_mirror_name || url.name); const mirror: Mirror = getMirror(m.force_mirror_name || url.name);
updateMirror(mirror, m, url); updateMirror(mirror, m, url);
const mirrorUrl: MirrorUrl = { const mirrorUrl: MirrorUrl = {
pk: mirrorUrlCounter++, pk: ++mirrorUrlCounter,
model: 'mirrors.MirrorUrl', model: 'mirrors.MirrorUrl',
fields: { fields: {
url: url.partial, url: url.partial,
protocol: protocolId[url.protocol], protocol: protocolId[url.protocol],
mirror: mirror.pk, mirror: mirror.pk,
country: resolveCountry(m.country)?.iso2 || null, country: resolveCountry(m.country)?.iso2 || undefined,
// populate ip fields with `mirrorresolv` // populate ip fields with `mirrorresolv`
has_ipv4: false, has_ipv4: false,
has_ipv6: false, has_ipv6: false,
@@ -160,7 +160,7 @@ function pushMirrorProfile(name: string, m: MirrorProfile) {
function updateUpstream(m: MirrorProfile) { function updateUpstream(m: MirrorProfile) {
const url: UrlComponents = processUrl(m.url); const url: UrlComponents = processUrl(m.url);
const mirror: Mirror = mirrors[m.force_mirror_name || url.name]; const mirror: Mirror = mirrors[m.force_mirror_name || url.name];
mirror.fields.upstream ||= m.upstream && mirrors[m.upstream]?.pk; mirror.fields.upstream = (m.upstream && mirrors[m.upstream]?.pk) || mirror.fields.upstream;
} }
function composeMirrorFixture(): FixtureObject[] { function composeMirrorFixture(): FixtureObject[] {
@@ -214,13 +214,16 @@ function generateMirrorMd(): string {
for (let mirrorName in mirrorProfilesByMirrorName) { for (let mirrorName in mirrorProfilesByMirrorName) {
const profiles: MirrorProfile[] = mirrorProfilesByMirrorName[mirrorName]; const profiles: MirrorProfile[] = mirrorProfilesByMirrorName[mirrorName];
const activeProfiles: MirrorProfile[] = profiles.filter(p => p.active); const activeProfiles: MirrorProfile[] = profiles.filter(p => p.active);
const urls: string[] = activeProfiles.map(p => p.url).map(u => u.split('$repo')[0]); const urls: string[] = profiles.map(p => {
const url = p.url.split('$repo')[0];
return p.active ? url: `${url} (inactive)`;
});
const upstream = findFirstWithChild(activeProfiles, 'upstream'); const upstream = findFirstWithChild(activeProfiles, 'upstream');
lines.push(`### ${mirrorName}`); lines.push(`### ${mirrorName}`);
lines.push(`| Mirror | ${mirrorName} |`); lines.push(`| Mirror | ${mirrorName} |`);
lines.push('| ------ | ------------- |'); lines.push('| ------ | ------------- |');
if (upstream) { if (upstream) {
lines.push(`| Sync Source | [${upstream}](#${upstream}) |`); lines.push(`| Sync Source | [${upstream}](#${upstream.replaceAll('.', '')}) |`);
} }
lines.push(`| URLs | ${urls.join('<br>')} |`); lines.push(`| URLs | ${urls.join('<br>')} |`);
pushTableRowIfTruthy(lines, 'Provides Stable ISO', findFirstWithChild(activeProfiles, 'stable_isos')); pushTableRowIfTruthy(lines, 'Provides Stable ISO', findFirstWithChild(activeProfiles, 'stable_isos'));
@@ -228,9 +231,9 @@ function generateMirrorMd(): string {
// pushTableRowIfTruthy(lines, 'Bandwidth', findFirstWithChild(activeProfiles, 'bandwidth')); // pushTableRowIfTruthy(lines, 'Bandwidth', findFirstWithChild(activeProfiles, 'bandwidth'));
// pushTableRowIfTruthy(lines, 'Frequency', findFirstWithChild(activeProfiles, 'frequency')); // pushTableRowIfTruthy(lines, 'Frequency', findFirstWithChild(activeProfiles, 'frequency'));
// pushTableRowIfTruthy(lines, 'Hosted by', findFirstWithChild(activeProfiles, 'org')); // pushTableRowIfTruthy(lines, 'Hosted by', findFirstWithChild(activeProfiles, 'org'));
pushTableRowIfTruthy(lines, 'Location', findFirstWithChild(activeProfiles, 'country')); pushTableRowIfTruthy(lines, 'Location', findFirstWithChild(activeProfiles, 'country') || findFirstWithChild(profiles, 'country'));
pushTableRowIfTruthy(lines, 'Contact Details', findFirstWithChild(activeProfiles, 'admin_email')); pushTableRowIfTruthy(lines, 'Contact Details', findFirstWithChild(activeProfiles, 'admin_email') || findFirstWithChild(profiles, 'admin_email'));
pushTableRowIfTruthy(lines, 'Altenate Contact Details', findFirstWithChild(activeProfiles, 'alternate_email')); pushTableRowIfTruthy(lines, 'Altenate Contact Details', findFirstWithChild(activeProfiles, 'alternate_email') || findFirstWithChild(profiles, 'alternate_email'));
lines.push(''); lines.push('');
} }
return lines.join('\n'); return lines.join('\n');