npm-update-package 4.0.10 → 4.0.12

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "postbuild": "cp package.json dist/package.json",
11
11
  "prebuild": "npm run clean",
12
12
  "prepublishOnly": "npm-run-all lint test build",
13
- "test": "glob -c 'tsx --test' 'src/**/*.test.ts'"
13
+ "test": "glob -c 'node --test --import tsx/esm' 'src/**/*.test.ts'"
14
14
  },
15
15
  "bin": "dist/src/bin/npm-update-package.js",
16
16
  "engines": {
@@ -23,24 +23,28 @@
23
23
  "fp-ts": "2.16.6",
24
24
  "http-status-codes": "2.3.0",
25
25
  "io-ts": "2.2.21",
26
+ "jsdom": "21.1.2",
26
27
  "lodash": "4.17.21",
27
28
  "log4js": "6.9.1",
28
29
  "mustache": "4.2.0",
29
30
  "npm-check-updates": "16.3.11",
30
31
  "parse-github-url": "1.0.2",
32
+ "safe-marked": "16.0.0",
31
33
  "semver": "7.5.4",
32
34
  "type-guards": "0.15.0"
33
35
  },
34
36
  "devDependencies": {
35
37
  "@munierujp/eslint-config-typescript": "46.0.1",
36
38
  "@tsconfig/node20": "20.1.4",
39
+ "@types/jsdom": "21.1.6",
37
40
  "@types/lodash": "4.17.4",
38
41
  "@types/mustache": "4.2.5",
39
- "@types/node": "20.12.12",
42
+ "@types/node": "20.12.13",
40
43
  "@types/parse-github-url": "1.0.3",
41
44
  "@types/semver": "7.5.8",
42
45
  "eslint": "8.57.0",
43
46
  "eslint-config-lodash": "4.0.3",
47
+ "eslint-plugin-regexp": "2.6.0",
44
48
  "glob": "10.3.15",
45
49
  "nock": "14.0.0-beta.6",
46
50
  "npm-run-all2": "6.2.0",
@@ -1,17 +1,16 @@
1
+ import { parseHTML } from '../../../html/parseHTML.js';
2
+ import { parseMarkdown } from '../../../markdown/parseMarkdown.js';
1
3
  import { isPullRequestMetadata } from './PullRequestMetadata.js';
2
4
  export const extractPullRequestMetadata = (pullRequestBody) => {
3
- const matched = pullRequestBody.match(/<div id="npm-update-package-metadata">\s*```json\s*([\S\s]+?)\s*```\s*<\/div>/);
4
- if (matched === null) {
5
- return undefined;
6
- }
7
- const json = matched[1];
8
- /* istanbul ignore if: I can't write a test to reach here. */
5
+ const html = parseMarkdown(pullRequestBody);
6
+ const document = parseHTML(html);
7
+ const jsonElement = document.querySelector('#npm-update-package-metadata code');
8
+ const json = jsonElement?.textContent ?? undefined;
9
9
  if (json === undefined) {
10
10
  return undefined;
11
11
  }
12
12
  const metadata = JSON.parse(json);
13
- if (!isPullRequestMetadata(metadata)) {
14
- return undefined;
13
+ if (isPullRequestMetadata(metadata)) {
14
+ return metadata;
15
15
  }
16
- return metadata;
17
16
  };
@@ -0,0 +1,5 @@
1
+ import { JSDOM } from 'jsdom';
2
+ export const parseHTML = (html) => {
3
+ const { window } = new JSDOM(html);
4
+ return window.document;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { createMarkdown } from 'safe-marked';
2
+ export const parseMarkdown = createMarkdown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "postbuild": "cp package.json dist/package.json",
11
11
  "prebuild": "npm run clean",
12
12
  "prepublishOnly": "npm-run-all lint test build",
13
- "test": "glob -c 'tsx --test' 'src/**/*.test.ts'"
13
+ "test": "glob -c 'node --test --import tsx/esm' 'src/**/*.test.ts'"
14
14
  },
15
15
  "bin": "dist/src/bin/npm-update-package.js",
16
16
  "engines": {
@@ -23,24 +23,28 @@
23
23
  "fp-ts": "2.16.6",
24
24
  "http-status-codes": "2.3.0",
25
25
  "io-ts": "2.2.21",
26
+ "jsdom": "21.1.2",
26
27
  "lodash": "4.17.21",
27
28
  "log4js": "6.9.1",
28
29
  "mustache": "4.2.0",
29
30
  "npm-check-updates": "16.3.11",
30
31
  "parse-github-url": "1.0.2",
32
+ "safe-marked": "16.0.0",
31
33
  "semver": "7.5.4",
32
34
  "type-guards": "0.15.0"
33
35
  },
34
36
  "devDependencies": {
35
37
  "@munierujp/eslint-config-typescript": "46.0.1",
36
38
  "@tsconfig/node20": "20.1.4",
39
+ "@types/jsdom": "21.1.6",
37
40
  "@types/lodash": "4.17.4",
38
41
  "@types/mustache": "4.2.5",
39
- "@types/node": "20.12.12",
42
+ "@types/node": "20.12.13",
40
43
  "@types/parse-github-url": "1.0.3",
41
44
  "@types/semver": "7.5.8",
42
45
  "eslint": "8.57.0",
43
46
  "eslint-config-lodash": "4.0.3",
47
+ "eslint-plugin-regexp": "2.6.0",
44
48
  "glob": "10.3.15",
45
49
  "nock": "14.0.0-beta.6",
46
50
  "npm-run-all2": "6.2.0",