Compare commits
1 Commits
4c2441b9e5
...
v0.2.7
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d21b8958b |
7
package-lock.json
generated
7
package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"country-code-lookup": "0.1.3",
|
"country-code-lookup": "0.1.3",
|
||||||
|
"email-addresses": "5.0.0",
|
||||||
"extract-tld": "1.1.2"
|
"extract-tld": "1.1.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -36,6 +37,12 @@
|
|||||||
"integrity": "sha512-gLu+AQKHUnkSQNTxShKgi/4tYd0vEEait3JMrLNZgYlmIZ9DJLkHUjzXE9qcs7dy3xY/kUx2/nOxZ0Z3D9JE+A==",
|
"integrity": "sha512-gLu+AQKHUnkSQNTxShKgi/4tYd0vEEait3JMrLNZgYlmIZ9DJLkHUjzXE9qcs7dy3xY/kUx2/nOxZ0Z3D9JE+A==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/email-addresses": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-4OIPYlA6JXqtVn8zpHpGiI7vE6EQOAg16aGnDMIAlZVinnoZ8208tW1hAbjWydgN/4PLTT9q+O1K6AH/vALJGw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/extract-tld": {
|
"node_modules/extract-tld": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/extract-tld/-/extract-tld-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/extract-tld/-/extract-tld-1.1.2.tgz",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"country-code-lookup": "0.1.3",
|
"country-code-lookup": "0.1.3",
|
||||||
|
"email-addresses": "5.0.0",
|
||||||
"extract-tld": "1.1.2"
|
"extract-tld": "1.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
12
src/index.ts
12
src/index.ts
@@ -1,6 +1,7 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fsp from 'fs/promises';
|
import fsp from 'fs/promises';
|
||||||
import parseUrl from 'extract-tld';
|
import parseUrl from 'extract-tld';
|
||||||
|
import addrs from "email-addresses";
|
||||||
import { resolveCountry } from './resolveCountry.js';
|
import { resolveCountry } from './resolveCountry.js';
|
||||||
import MirrorsByRegion from './mirrorsByRegion.js';
|
import MirrorsByRegion from './mirrorsByRegion.js';
|
||||||
import type { PathLike } from 'fs';
|
import type { PathLike } from 'fs';
|
||||||
@@ -219,6 +220,13 @@ async function generateMirrorMd(): Promise<string> {
|
|||||||
function findFirstWithChild<T, K extends keyof T>(profiles: T[], key: K): T[K] | undefined {
|
function findFirstWithChild<T, K extends keyof T>(profiles: T[], key: K): T[K] | undefined {
|
||||||
return profiles.find(p => !!p[key])?.[key];
|
return profiles.find(p => !!p[key])?.[key];
|
||||||
}
|
}
|
||||||
|
function printEmail(email: string | undefined) {
|
||||||
|
if (!email) {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
const addr = addrs.parseOneAddress(email)?.['address'];
|
||||||
|
return `[${email.replaceAll('<', '<').replaceAll('>', '>')}](mailto:${addr})`;
|
||||||
|
}
|
||||||
const lines: string[] = await tryReadHeader();
|
const lines: string[] = await tryReadHeader();
|
||||||
lines.push('# Mirrors\n\nContact or other information for the mirrors of our repositories and ISOs.\n');
|
lines.push('# Mirrors\n\nContact or other information for the mirrors of our repositories and ISOs.\n');
|
||||||
for (let mirrorName in mirrorProfilesByMirrorName) {
|
for (let mirrorName in mirrorProfilesByMirrorName) {
|
||||||
@@ -242,8 +250,8 @@ async function generateMirrorMd(): Promise<string> {
|
|||||||
// 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') || findFirstWithChild(profiles, 'country'));
|
pushTableRowIfTruthy(lines, 'Location', findFirstWithChild(activeProfiles, 'country') || findFirstWithChild(profiles, 'country'));
|
||||||
pushTableRowIfTruthy(lines, 'Contact Details', findFirstWithChild(activeProfiles, 'admin_email') || findFirstWithChild(profiles, 'admin_email'));
|
pushTableRowIfTruthy(lines, 'Contact Details', printEmail(findFirstWithChild(activeProfiles, 'admin_email') || findFirstWithChild(profiles, 'admin_email')));
|
||||||
pushTableRowIfTruthy(lines, 'Altenate Contact Details', findFirstWithChild(activeProfiles, 'alternate_email') || findFirstWithChild(profiles, 'alternate_email'));
|
pushTableRowIfTruthy(lines, 'Altenate Contact Details', printEmail(findFirstWithChild(activeProfiles, 'alternate_email') || findFirstWithChild(profiles, 'alternate_email')));
|
||||||
lines.push('');
|
lines.push('');
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user