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