mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-12 14:14:55 +00:00
Merge pull request #50998 from is-a-dev/updating-reserved-subdomains-dibster
chore: adding additional domains to reserved
This commit is contained in:
4 files changed
+114
-6
No files matched your search
+3
-1
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "npx ava tests/*.test.js"
|
||||
"test": "npx ava tests/*.test.js",
|
||||
"check:reserved-order": "node util/check-reserved-order.cjs",
|
||||
"add:reserved": "node util/add-reserved-subdomain.cjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^8.0.1",
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const { readFileSync, writeFileSync } = require("node:fs");
|
||||
const { join } = require("node:path");
|
||||
const readline = require("node:readline");
|
||||
|
||||
const filePath = join(__dirname, "reserved.json");
|
||||
const prompt = "What subdomain would you want to add to the reserved.json list: ";
|
||||
|
||||
const interface = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
interface.question(prompt, (input) => {
|
||||
const subdomain = input.trim();
|
||||
|
||||
if (!subdomain) {
|
||||
console.error("Subdomain cannot be empty.");
|
||||
interface.close();
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (subdomain !== subdomain.toLowerCase() || /\s/.test(subdomain)) {
|
||||
console.error("Subdomain must be lowercase and cannot contain whitespace.");
|
||||
interface.close();
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
const fileContents = readFileSync(filePath, "utf8");
|
||||
const reserved = JSON.parse(fileContents);
|
||||
|
||||
if (reserved.includes(subdomain)) {
|
||||
console.error(`"${subdomain}" is already in reserved.json.`);
|
||||
interface.close();
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
const insertionIndex = reserved.findIndex(
|
||||
(entry) => entry > subdomain,
|
||||
);
|
||||
const index = insertionIndex === -1 ? reserved.length : insertionIndex;
|
||||
reserved.splice(index, 0, subdomain);
|
||||
|
||||
const newline = fileContents.includes("\r\n") ? "\r\n" : "\n";
|
||||
const output = `${JSON.stringify(reserved, null, 4)}${newline}`;
|
||||
writeFileSync(filePath, output);
|
||||
|
||||
const lineNumber = index + 2;
|
||||
const precedingEntry = index > 0 ? reserved[index - 1] : "[";
|
||||
const followingEntry = index < reserved.length - 1 ? reserved[index + 1] : "]";
|
||||
console.log(
|
||||
`Added "${subdomain}" on line ${lineNumber}, after "${precedingEntry}" and before "${followingEntry}".`,
|
||||
);
|
||||
interface.close();
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
const { readFileSync } = require("node:fs");
|
||||
const { join } = require("node:path");
|
||||
|
||||
const filePath = join(__dirname, "reserved.json");
|
||||
const fileContents = readFileSync(filePath, "utf8");
|
||||
const reserved = JSON.parse(fileContents);
|
||||
|
||||
for (let index = 1; index < reserved.length; index += 1) {
|
||||
if (reserved[index - 1] > reserved[index]) {
|
||||
let precedingIndex = index - 1;
|
||||
|
||||
while (
|
||||
precedingIndex >= 0 &&
|
||||
reserved[precedingIndex] > reserved[index]
|
||||
) {
|
||||
precedingIndex -= 1;
|
||||
}
|
||||
|
||||
const precedingLine = precedingIndex + 2;
|
||||
|
||||
console.error(
|
||||
`reserved.json is not in alphabetical order: line ${index + 2} ("${reserved[index]}") should go after line ${precedingLine} ("${precedingIndex >= 0 ? reserved[precedingIndex] : "["}") and before line ${index + 1} ("${reserved[index - 1]}").`,
|
||||
);
|
||||
process.exitCode = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.exitCode !== 1) {
|
||||
console.log("reserved.json is in alphabetical order.");
|
||||
}
|
||||
+23
-5
@@ -17,6 +17,8 @@
|
||||
"blog",
|
||||
"bot",
|
||||
"cdn",
|
||||
"cert",
|
||||
"certs",
|
||||
"chat",
|
||||
"checkout",
|
||||
"cname",
|
||||
@@ -38,6 +40,7 @@
|
||||
"example",
|
||||
"file",
|
||||
"files",
|
||||
"ftp",
|
||||
"get",
|
||||
"git",
|
||||
"github",
|
||||
@@ -51,6 +54,7 @@
|
||||
"http",
|
||||
"https",
|
||||
"iad",
|
||||
"imap",
|
||||
"info",
|
||||
"int",
|
||||
"internal",
|
||||
@@ -58,18 +62,21 @@
|
||||
"is-a-dev",
|
||||
"isa",
|
||||
"isadev",
|
||||
"legal",
|
||||
"link",
|
||||
"links",
|
||||
"log",
|
||||
"login",
|
||||
"logs",
|
||||
"m",
|
||||
"mail",
|
||||
"mailbox",
|
||||
"maintainer",
|
||||
"maintainers",
|
||||
"manage",
|
||||
"metrics",
|
||||
"mc",
|
||||
"media",
|
||||
"metrics",
|
||||
"mobile",
|
||||
"net",
|
||||
"network",
|
||||
@@ -84,24 +91,27 @@
|
||||
"ns8",
|
||||
"ns9",
|
||||
"oauth",
|
||||
"open",
|
||||
"org",
|
||||
"organisation",
|
||||
"organisations",
|
||||
"organization",
|
||||
"organizations",
|
||||
"open",
|
||||
"panel",
|
||||
"pay",
|
||||
"payment",
|
||||
"payments",
|
||||
"pop",
|
||||
"pop3",
|
||||
"portal",
|
||||
"preview",
|
||||
"public",
|
||||
"privacy",
|
||||
"private",
|
||||
"prod",
|
||||
"production",
|
||||
"proxied",
|
||||
"proxy",
|
||||
"public",
|
||||
"rdap",
|
||||
"redirect",
|
||||
"register",
|
||||
@@ -109,28 +119,36 @@
|
||||
"registry",
|
||||
"reserved",
|
||||
"root",
|
||||
"rsync",
|
||||
"secure",
|
||||
"security",
|
||||
"server",
|
||||
"servers",
|
||||
"service",
|
||||
"services",
|
||||
"sftp",
|
||||
"shop",
|
||||
"smtp",
|
||||
"srv",
|
||||
"ssl",
|
||||
"sso",
|
||||
"staff",
|
||||
"staging",
|
||||
"static",
|
||||
"stats",
|
||||
"status",
|
||||
"server",
|
||||
"srv",
|
||||
"store",
|
||||
"subdomain",
|
||||
"subdomains",
|
||||
"support",
|
||||
"sys",
|
||||
"syslog",
|
||||
"syslogs",
|
||||
"system",
|
||||
"team",
|
||||
"test",
|
||||
"testing",
|
||||
"tls",
|
||||
"tools",
|
||||
"uptime",
|
||||
"url",
|
||||
|
||||
Reference in new issue
Block a user