webring 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.2](https://github.com/shepherdjerred/webring/compare/v1.1.1...v1.1.2) (2024-07-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update npm ([bfaf883](https://github.com/shepherdjerred/webring/commit/bfaf88347ae769e00e93e514774b2c760694f902))
14
+
8
15
  ## [1.1.1](https://github.com/shepherdjerred/webring/compare/v1.1.0...v1.1.1) (2024-07-07)
9
16
 
10
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhG,wBAAsB,QAAQ,CAAC,MAAM,EAAE,aAAa;;;;;;;;;KAEnD;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAsC5F"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhG,wBAAsB,QAAQ,CAAC,MAAM,EAAE,aAAa;;;;;;;;;KAEnD;AAED,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA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,OAAO,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,GAAG,KAAK,CAAW,EAAE,CAAC,CAAC;QAC9D,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -3,47 +3,49 @@ import { run } from "./index.js";
3
3
  import { tmpdir } from "os";
4
4
  import { mkdtemp } from "fs/promises";
5
5
  import { join } from "path";
6
- // TODO: intercept network requests
6
+ import express from "express";
7
+ const app = express();
8
+ app.use(express.static("src/testdata"));
9
+ const port = Math.floor(Math.random() * 10000) + 3000;
10
+ app.listen(port, () => {
11
+ console.log(`Test server listening at http://localhost:${port.toString()}`);
12
+ });
13
+ function createUrl(path) {
14
+ return `http://localhost:${port.toString()}/${path}`;
15
+ }
16
+ function createSources(count) {
17
+ return Array.from({ length: count }, (_, i) => ({
18
+ title: `rss ${i.toString()}`,
19
+ url: createUrl(`rss-${i.toString()}.xml`),
20
+ }));
21
+ }
7
22
  test("it should fetch an RSS feed without caching", { timeout: 30000 }, async () => {
8
23
  const config = {
9
- sources: [
10
- {
11
- title: "Jerred Shepherd",
12
- url: "https://sjer.red/rss.xml",
13
- },
14
- ],
24
+ sources: createSources(19),
15
25
  number: 1,
16
26
  truncate: 300,
17
27
  };
18
28
  const result = await run(config);
19
- expect(result).toMatchSnapshot();
29
+ let string = JSON.stringify(result);
30
+ // replace the port number with a fixed value
31
+ string = string.replaceAll(port.toString(), "PORT");
32
+ expect(string).toMatchSnapshot();
20
33
  });
21
34
  test("it should fetch several RSS feeds", { timeout: 30000 }, async () => {
22
35
  const config = {
23
- sources: [
24
- {
25
- url: "https://drewdevault.com/blog/index.xml",
26
- title: "Drew DeVault",
27
- },
28
- {
29
- url: "https://danluu.com/atom.xml",
30
- title: "Dan Luu",
31
- },
32
- ],
36
+ sources: createSources(19),
33
37
  number: 3,
34
38
  truncate: 300,
35
39
  };
36
40
  const result = await run(config);
37
- expect(result).toMatchSnapshot();
41
+ let string = JSON.stringify(result);
42
+ // replace the port number with a fixed value
43
+ string = string.replaceAll(port.toString(), "PORT");
44
+ expect(string).toMatchSnapshot();
38
45
  });
39
46
  test("it should fetch an RSS feed with caching", { timeout: 30000 }, async () => {
40
47
  const config = {
41
- sources: [
42
- {
43
- title: "Jerred Shepherd",
44
- url: "https://sjer.red/rss.xml",
45
- },
46
- ],
48
+ sources: createSources(19),
47
49
  number: 1,
48
50
  truncate: 300,
49
51
  cache: {
@@ -52,7 +54,10 @@ test("it should fetch an RSS feed with caching", { timeout: 30000 }, async () =>
52
54
  },
53
55
  };
54
56
  const result = await run(config);
55
- expect(result).toMatchSnapshot();
57
+ let string = JSON.stringify(result);
58
+ // replace the port number with a fixed value
59
+ string = string.replaceAll(port.toString(), "PORT");
60
+ expect(string).toMatchSnapshot();
56
61
  });
57
62
  // https://sdorra.dev/posts/2024-02-12-vitest-tmpdir
58
63
  async function createTempDir() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,6CAA6C,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,IAAI,EAAE;IACjF,MAAM,MAAM,GAAkB;QAC5B,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,iBAAiB;gBACxB,GAAG,EAAE,0BAA0B;aAChC;SACF;QACD,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,GAAG;KACd,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,CAAC,C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AAM,aAAa,EAAE,aAAa;YACjD,sBAAsB,EAAE,CAAC;SAC1B;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,6CAA6C;IAC7C,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC;AAEH,oDAAoD;AACpD,KAAK,UAAU,aAAa;IAC1B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "url": "https://github.com/shepherdjerred/webring/issues"
17
17
  },
18
18
  "type": "module",
19
- "version": "1.1.1",
19
+ "version": "1.1.2",
20
20
  "scripts": {
21
21
  "prepare": "husky",
22
22
  "lint": "eslint src",
@@ -28,7 +28,7 @@
28
28
  "main": "dist/index.js",
29
29
  "types": "dist/index.d.ts",
30
30
  "dependencies": {
31
- "remeda": "^2.0.1",
31
+ "remeda": "^2.5.0",
32
32
  "rss-parser": "^3.13.0",
33
33
  "sanitize-html": "^2.13.0",
34
34
  "truncate-html": "^1.1.1",
@@ -37,22 +37,24 @@
37
37
  "devDependencies": {
38
38
  "@commitlint/cli": "^19.3.0",
39
39
  "@commitlint/config-conventional": "^19.2.2",
40
- "@eslint/js": "^9.4.0",
40
+ "@eslint/js": "^9.7.0",
41
41
  "@tsconfig/node20": "^20.1.4",
42
42
  "@tsconfig/strictest": "^2.0.5",
43
- "@types/node": "^20.14.0",
43
+ "@types/express": "^4.17.21",
44
+ "@types/node": "^20.14.10",
44
45
  "@types/sanitize-html": "^2.11.0",
45
- "@typescript-eslint/eslint-plugin": "^7.11.0",
46
- "@typescript-eslint/parser": "^7.11.0",
46
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
47
+ "@typescript-eslint/parser": "^7.16.0",
47
48
  "eslint": "^8.57.0",
49
+ "express": "^4.19.2",
48
50
  "husky": "^9.0.11",
49
- "lint-staged": "^15.2.5",
50
- "prettier": "^3.3.0",
51
- "typedoc": "^0.26.3",
51
+ "lint-staged": "^15.2.7",
52
+ "prettier": "^3.3.3",
53
+ "typedoc": "^0.26.4",
52
54
  "typedoc-plugin-zod": "^1.2.0",
53
- "typescript": "^5.4.5",
54
- "typescript-eslint": "^7.11.0",
55
- "vitest": "^1.6.0"
55
+ "typescript": "^5.5.3",
56
+ "typescript-eslint": "^7.16.0",
57
+ "vitest": "^2.0.2"
56
58
  },
57
59
  "lint-staged": {
58
60
  "*.{ts,tsx}": "eslint --cache --fix",
@@ -1,56 +1,7 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
- exports[`it should fetch an RSS feed with caching 1`] = `
4
- [
5
- {
6
- "date": 2024-07-01T00:00:00.000Z,
7
- "preview": "TIL: Using Twoslash with Shiki and Astro",
8
- "source": {
9
- "title": "Jerred Shepherd",
10
- "url": "https://sjer.red/rss.xml",
11
- },
12
- "title": "TIL: Using Twoslash with Shiki and Astro",
13
- "url": "https://sjer.red/blog/til/2024-07-01/",
14
- },
15
- ]
16
- `;
3
+ exports[`it should fetch an RSS feed with caching 1`] = `"[{"title":"Creating an already-completed asynchronous activity in C++/WinRT, part 4","url":"https://devblogs.microsoft.com/oldnewthing/20240712-00/?p=109967","date":"2024-07-12T14:00:00.000Z","source":{"url":"http://localhost:PORT/rss-10.xml","title":"rss 10"},"preview":"Failing is easy. Failing correctly is hard. The post Creating an already-completed asynchronous activity in C++/WinRT, part 4 appeared first on The Old New Thing."}]"`;
17
4
 
18
- exports[`it should fetch an RSS feed without caching 1`] = `
19
- [
20
- {
21
- "date": 2024-07-01T00:00:00.000Z,
22
- "preview": "TIL: Using Twoslash with Shiki and Astro",
23
- "source": {
24
- "title": "Jerred Shepherd",
25
- "url": "https://sjer.red/rss.xml",
26
- },
27
- "title": "TIL: Using Twoslash with Shiki and Astro",
28
- "url": "https://sjer.red/blog/til/2024-07-01/",
29
- },
30
- ]
31
- `;
5
+ exports[`it should fetch an RSS feed without caching 1`] = `"[{"title":"Creating an already-completed asynchronous activity in C++/WinRT, part 4","url":"https://devblogs.microsoft.com/oldnewthing/20240712-00/?p=109967","date":"2024-07-12T14:00:00.000Z","source":{"title":"rss 10","url":"http://localhost:PORT/rss-10.xml"},"preview":"Failing is easy. Failing correctly is hard. The post Creating an already-completed asynchronous activity in C++/WinRT, part 4 appeared first on The Old New Thing."}]"`;
32
6
 
33
- exports[`it should fetch several RSS feeds 1`] = `
34
- [
35
- {
36
- "date": 2024-06-16T00:00:00.000Z,
37
- "preview": "There've been regular viral stories about ML/AI bias with LLMs and generative AI for the past couple years. One thing I find interesting about discussions of bias is how different the reaction is in the LLM and generative AI case when compared to "classical" bugs in cases where there's a clear bug. ...",
38
- "source": {
39
- "title": "Dan Luu",
40
- "url": "https://danluu.com/atom.xml",
41
- },
42
- "title": "A discussion of discussions on AI bias",
43
- "url": "https://danluu.com/ai-bias/",
44
- },
45
- {
46
- "date": 2024-05-24T00:00:00.000Z,
47
- "preview": "I needed a bit of a break from “real work” recently, so I started a new programming project that was low-stakes and purely recreational. On April 21st, I set out to see how much of a Unix-like operating system for x86_64 targets that I could put together in about a month. The result is Bunnix. Not i...",
48
- "source": {
49
- "title": "Drew DeVault",
50
- "url": "https://drewdevault.com/blog/index.xml",
51
- },
52
- "title": "Writing a Unix clone in about a month",
53
- "url": "https://drewdevault.com/2024/05/24/2024-05-24-Bunnix.html",
54
- },
55
- ]
56
- `;
7
+ exports[`it should fetch several RSS feeds 1`] = `"[{"title":"Creating an already-completed asynchronous activity in C++/WinRT, part 4","url":"https://devblogs.microsoft.com/oldnewthing/20240712-00/?p=109967","date":"2024-07-12T14:00:00.000Z","source":{"title":"rss 10","url":"http://localhost:PORT/rss-10.xml"},"preview":"Failing is easy. Failing correctly is hard. The post Creating an already-completed asynchronous activity in C++/WinRT, part 4 appeared first on The Old New Thing."},{"title":"Garlic and gravel","url":"https://www.henrikkarlsson.xyz/p/garlic-and-gravel","date":"2024-07-12T11:34:25.000Z","source":{"title":"rss 16","url":"http://localhost:PORT/rss-16.xml"},"preview":"fragments"},{"title":"My Glorious Ascension To Thought Leadership","url":"https://ludic.mataroa.blog/blog/my-glorious-ascension-to-thought-leadership/","date":"2024-07-11T00:00:00.000Z","source":{"title":"rss 5","url":"http://localhost:PORT/rss-5.xml"},"preview":"I. This Escalated Quickly I mentioned one post ago that this blog has done approximately 2M+ lifetime views, with over a million of them being in the past two weeks in response to the now-infamous rant about AI, then I went out of my way to not write the most maximally viral thing possible for perso..."}]"`;
package/src/fetch.ts CHANGED
@@ -14,6 +14,7 @@ export async function fetchAll(config: Configuration) {
14
14
 
15
15
  export async function fetch(source: Source, length: number): Promise<ResultEntry | undefined> {
16
16
  const parser = new Parser();
17
+
17
18
  try {
18
19
  const feed = await parser.parseURL(source.url);
19
20
 
package/src/index.test.ts CHANGED
@@ -4,52 +4,58 @@ import { run } from "./index.js";
4
4
  import { tmpdir } from "os";
5
5
  import { mkdtemp } from "fs/promises";
6
6
  import { join } from "path";
7
+ import express from "express";
8
+
9
+ const app = express();
10
+ app.use(express.static("src/testdata"));
11
+
12
+ const port = Math.floor(Math.random() * 10000) + 3000;
13
+ app.listen(port, () => {
14
+ console.log(`Test server listening at http://localhost:${port.toString()}`);
15
+ });
16
+
17
+ function createUrl(path: string): string {
18
+ return `http://localhost:${port.toString()}/${path}`;
19
+ }
20
+
21
+ function createSources(count: number): Configuration["sources"] {
22
+ return Array.from({ length: count }, (_, i) => ({
23
+ title: `rss ${i.toString()}`,
24
+ url: createUrl(`rss-${i.toString()}.xml`),
25
+ }));
26
+ }
7
27
 
8
- // TODO: intercept network requests
9
28
  test("it should fetch an RSS feed without caching", { timeout: 30000 }, async () => {
10
29
  const config: Configuration = {
11
- sources: [
12
- {
13
- title: "Jerred Shepherd",
14
- url: "https://sjer.red/rss.xml",
15
- },
16
- ],
30
+ sources: createSources(19),
17
31
  number: 1,
18
32
  truncate: 300,
19
33
  };
20
34
 
21
35
  const result = await run(config);
22
- expect(result).toMatchSnapshot();
36
+ let string = JSON.stringify(result);
37
+ // replace the port number with a fixed value
38
+ string = string.replaceAll(port.toString(), "PORT");
39
+ expect(string).toMatchSnapshot();
23
40
  });
24
41
 
25
42
  test("it should fetch several RSS feeds", { timeout: 30000 }, async () => {
26
43
  const config: Configuration = {
27
- sources: [
28
- {
29
- url: "https://drewdevault.com/blog/index.xml",
30
- title: "Drew DeVault",
31
- },
32
- {
33
- url: "https://danluu.com/atom.xml",
34
- title: "Dan Luu",
35
- },
36
- ],
44
+ sources: createSources(19),
37
45
  number: 3,
38
46
  truncate: 300,
39
47
  };
40
48
 
41
49
  const result = await run(config);
42
- expect(result).toMatchSnapshot();
50
+ let string = JSON.stringify(result);
51
+ // replace the port number with a fixed value
52
+ string = string.replaceAll(port.toString(), "PORT");
53
+ expect(string).toMatchSnapshot();
43
54
  });
44
55
 
45
56
  test("it should fetch an RSS feed with caching", { timeout: 30000 }, async () => {
46
57
  const config: Configuration = {
47
- sources: [
48
- {
49
- title: "Jerred Shepherd",
50
- url: "https://sjer.red/rss.xml",
51
- },
52
- ],
58
+ sources: createSources(19),
53
59
  number: 1,
54
60
  truncate: 300,
55
61
  cache: {
@@ -59,7 +65,10 @@ test("it should fetch an RSS feed with caching", { timeout: 30000 }, async () =>
59
65
  };
60
66
 
61
67
  const result = await run(config);
62
- expect(result).toMatchSnapshot();
68
+ let string = JSON.stringify(result);
69
+ // replace the port number with a fixed value
70
+ string = string.replaceAll(port.toString(), "PORT");
71
+ expect(string).toMatchSnapshot();
63
72
  });
64
73
 
65
74
  // https://sdorra.dev/posts/2024-02-12-vitest-tmpdir