Update prettier
This commit is contained in:
parent
4d99378a25
commit
32e7fa4fbd
|
@ -6342,9 +6342,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"version": "1.19.1",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.2.tgz",
|
||||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
"integrity": "sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"pretty-format": {
|
"pretty-format": {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "concurrently \"tsc --watch\" \"nodemon lib\"",
|
"start": "concurrently \"tsc --watch\" \"nodemon lib\"",
|
||||||
"test": "tsc && jest && prettier --check 'src/**'"
|
"test": "tsc && jest && prettier --check src"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"caddy-npm": "^2.0.0-beta.20",
|
"caddy-npm": "^2.0.0-beta.20",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"jest": "^25.2.4",
|
"jest": "^25.2.4",
|
||||||
"nodemailer": "^6.4.6",
|
"nodemailer": "^6.4.6",
|
||||||
"nodemon": "^2.0.2",
|
"nodemon": "^2.0.2",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^2.0.2",
|
||||||
"qs": "^6.9.3",
|
"qs": "^6.9.3",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,7 @@ import fs from "fs";
|
||||||
console.log("STARTED");
|
console.log("STARTED");
|
||||||
for (const feed of fs
|
for (const feed of fs
|
||||||
.readdirSync("static/feeds")
|
.readdirSync("static/feeds")
|
||||||
.filter(file => !file.startsWith("."))) {
|
.filter((file) => !file.startsWith("."))) {
|
||||||
try {
|
try {
|
||||||
const xml: any = xmlbuilder2.convert(
|
const xml: any = xmlbuilder2.convert(
|
||||||
fs.readFileSync(`static/feeds/${feed}`, "utf8"),
|
fs.readFileSync(`static/feeds/${feed}`, "utf8"),
|
||||||
|
|
|
@ -38,7 +38,7 @@ export const webServer = express()
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})().catch(error => {
|
})().catch((error) => {
|
||||||
console.error(
|
console.error(
|
||||||
`Error creating feed: ${JSON.stringify({ name, identifier }, null, 2)}`
|
`Error creating feed: ${JSON.stringify({ name, identifier }, null, 2)}`
|
||||||
);
|
);
|
||||||
|
@ -83,7 +83,7 @@ export const emailServer = new SMTPServer({
|
||||||
title: email.subject ?? "",
|
title: email.subject ?? "",
|
||||||
author: email.from?.text ?? "",
|
author: email.from?.text ?? "",
|
||||||
content:
|
content:
|
||||||
typeof email.html === "string" ? email.html : email.textAsHtml ?? ""
|
typeof email.html === "string" ? email.html : email.textAsHtml ?? "",
|
||||||
});
|
});
|
||||||
for (const { address } of session.envelope.rcptTo) {
|
for (const { address } of session.envelope.rcptTo) {
|
||||||
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
|
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
|
||||||
|
@ -102,7 +102,7 @@ export const emailServer = new SMTPServer({
|
||||||
await writeFileAtomic(path, renderXML(xml));
|
await writeFileAtomic(path, renderXML(xml));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
})().catch(error => {
|
})().catch((error) => {
|
||||||
console.error(
|
console.error(
|
||||||
`Error receiving email: ${JSON.stringify({ session, email }, null, 2)}`
|
`Error receiving email: ${JSON.stringify({ session, email }, null, 2)}`
|
||||||
);
|
);
|
||||||
|
@ -110,7 +110,7 @@ export const emailServer = new SMTPServer({
|
||||||
stream.resume();
|
stream.resume();
|
||||||
callback(new Error("Failed to receive message. Please try again."));
|
callback(new Error("Failed to receive message. Please try again."));
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}).listen(process.env.EMAIL_PORT ?? 2525);
|
}).listen(process.env.EMAIL_PORT ?? 2525);
|
||||||
|
|
||||||
function Layout({ children }: { children: React.ReactNode }) {
|
function Layout({ children }: { children: React.ReactNode }) {
|
||||||
|
@ -226,13 +226,13 @@ function Feed({ name, identifier }: { name: string; identifier: string }) {
|
||||||
{
|
{
|
||||||
"@rel": "self",
|
"@rel": "self",
|
||||||
"@type": "application/atom+xml",
|
"@type": "application/atom+xml",
|
||||||
"@href": feedURL(identifier)
|
"@href": feedURL(identifier),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@rel": "alternate",
|
"@rel": "alternate",
|
||||||
"@type": "text/html",
|
"@type": "text/html",
|
||||||
"@href": "https://www.kill-the-newsletter.com/"
|
"@href": "https://www.kill-the-newsletter.com/",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
id: urn(identifier),
|
id: urn(identifier),
|
||||||
title: name,
|
title: name,
|
||||||
|
@ -246,16 +246,16 @@ function Feed({ name, identifier }: { name: string; identifier: string }) {
|
||||||
author: "Kill the Newsletter!",
|
author: "Kill the Newsletter!",
|
||||||
content: ReactDOMServer.renderToStaticMarkup(
|
content: ReactDOMServer.renderToStaticMarkup(
|
||||||
<Created identifier={identifier}></Created>
|
<Created identifier={identifier}></Created>
|
||||||
)
|
),
|
||||||
})
|
}),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function Entry({
|
function Entry({
|
||||||
title,
|
title,
|
||||||
author,
|
author,
|
||||||
content
|
content,
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
author: string;
|
author: string;
|
||||||
|
@ -270,17 +270,17 @@ function Entry({
|
||||||
link: {
|
link: {
|
||||||
"@rel": "alternate",
|
"@rel": "alternate",
|
||||||
"@type": "text/html",
|
"@type": "text/html",
|
||||||
"@href": "https://www.kill-the-newsletter.com/entry"
|
"@href": "https://www.kill-the-newsletter.com/entry",
|
||||||
|
},
|
||||||
|
content: { "@type": "html", "#": content },
|
||||||
},
|
},
|
||||||
content: { "@type": "html", "#": content }
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createIdentifier(): string {
|
function createIdentifier(): string {
|
||||||
return cryptoRandomString({
|
return cryptoRandomString({
|
||||||
length: 20,
|
length: 20,
|
||||||
characters: "1234567890qwertyuiopasdfghjklzxcvbnm"
|
characters: "1234567890qwertyuiopasdfghjklzxcvbnm",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,13 +312,13 @@ function renderXML(xml: object): string {
|
||||||
return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, {
|
return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, {
|
||||||
format: "xml",
|
format: "xml",
|
||||||
noDoubleEncoding: true,
|
noDoubleEncoding: true,
|
||||||
prettyPrint: true
|
prettyPrint: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseXML(xml: string): any {
|
function parseXML(xml: string): any {
|
||||||
return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, {
|
return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, {
|
||||||
format: "object",
|
format: "object",
|
||||||
noDoubleEncoding: true
|
noDoubleEncoding: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
26
src/test.ts
26
src/test.ts
|
@ -18,7 +18,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
html: "<p>HTML content</p>"
|
html: "<p>HTML content</p>",
|
||||||
});
|
});
|
||||||
const after = await getFeed(identifier);
|
const after = await getFeed(identifier);
|
||||||
expect(after.match(/<updated>(.*)<\/updated>/)![1]).not.toMatch(
|
expect(after.match(/<updated>(.*)<\/updated>/)![1]).not.toMatch(
|
||||||
|
@ -32,7 +32,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
html: "<p>HTML content</p>"
|
html: "<p>HTML content</p>",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("publisher@example.com");
|
expect(feed).toMatch("publisher@example.com");
|
||||||
|
@ -46,7 +46,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
text: "TEXT content"
|
text: "TEXT content",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("TEXT content");
|
expect(feed).toMatch("TEXT content");
|
||||||
|
@ -58,7 +58,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
text: "TEXT content\n\nhttps://www.kill-the-newsletter.com\n\nMore text"
|
text: "TEXT content\n\nhttps://www.kill-the-newsletter.com\n\nMore text",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("TEXT content");
|
expect(feed).toMatch("TEXT content");
|
||||||
|
@ -71,7 +71,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
html: "<p>Invalid XML character (backspace): ‘\b’</p>"
|
html: "<p>Invalid XML character (backspace): ‘\b’</p>",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("Invalid XML character (backspace): ‘’");
|
expect(feed).toMatch("Invalid XML character (backspace): ‘’");
|
||||||
|
@ -83,7 +83,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
text: "Invalid XML character (backspace): ‘\b’"
|
text: "Invalid XML character (backspace): ‘\b’",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch(
|
expect(feed).toMatch(
|
||||||
|
@ -96,7 +96,7 @@ describe("receive email", () => {
|
||||||
await emailClient.sendMail({
|
await emailClient.sendMail({
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message"
|
subject: "New Message",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("New Message");
|
expect(feed).toMatch("New Message");
|
||||||
|
@ -107,7 +107,7 @@ describe("receive email", () => {
|
||||||
await emailClient.sendMail({
|
await emailClient.sendMail({
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
html: "<p>HTML content</p>"
|
html: "<p>HTML content</p>",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("HTML content");
|
expect(feed).toMatch("HTML content");
|
||||||
|
@ -120,7 +120,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
text: `REPETITION ${repetition} `.repeat(10_000)
|
text: `REPETITION ${repetition} `.repeat(10_000),
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("REPETITION 3");
|
expect(feed).toMatch("REPETITION 3");
|
||||||
|
@ -132,7 +132,7 @@ describe("receive email", () => {
|
||||||
from: "publisher@example.com",
|
from: "publisher@example.com",
|
||||||
to: "nonexistent@kill-the-newsletter.com",
|
to: "nonexistent@kill-the-newsletter.com",
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
html: "<p>HTML content</p>"
|
html: "<p>HTML content</p>",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ describe("receive email", () => {
|
||||||
await emailClient.sendMail({
|
await emailClient.sendMail({
|
||||||
to: `${identifier}@kill-the-newsletter.com`,
|
to: `${identifier}@kill-the-newsletter.com`,
|
||||||
subject: "New Message",
|
subject: "New Message",
|
||||||
html: "<p>HTML content</p>"
|
html: "<p>HTML content</p>",
|
||||||
});
|
});
|
||||||
const feed = await getFeed(identifier);
|
const feed = await getFeed(identifier);
|
||||||
expect(feed).toMatch("HTML content");
|
expect(feed).toMatch("HTML content");
|
||||||
|
@ -154,7 +154,7 @@ afterAll(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const webClient = axios.create({
|
const webClient = axios.create({
|
||||||
baseURL: `http://localhost:${(webServer.address() as AddressInfo).port}`
|
baseURL: `http://localhost:${(webServer.address() as AddressInfo).port}`,
|
||||||
});
|
});
|
||||||
const emailClient = nodemailer.createTransport(
|
const emailClient = nodemailer.createTransport(
|
||||||
`smtp://localhost:${(emailServer.address() as AddressInfo).port}`
|
`smtp://localhost:${(emailServer.address() as AddressInfo).port}`
|
||||||
|
@ -165,7 +165,7 @@ async function createFeed(): Promise<string> {
|
||||||
await webClient.post(
|
await webClient.post(
|
||||||
"/",
|
"/",
|
||||||
qs.stringify({
|
qs.stringify({
|
||||||
name: "My Feed"
|
name: "My Feed",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
).data.match(/(\w{20}).xml/)![1];
|
).data.match(/(\w{20}).xml/)![1];
|
||||||
|
|
Loading…
Reference in New Issue