npm-update-package 0.46.4 → 0.46.7
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 +4 -4
- package/dist/src/git/GitRepository.js +32 -11
- package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +1 -1
- package/dist/src/main.js +3 -0
- package/dist/src/package-json/extractRepository.js +4 -11
- package/package.json +4 -4
- package/dist/src/package-json/parseRepositoryString.js +0 -20
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.7",
|
|
4
4
|
"description": "CLI tool for creating pull requests to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"badges": "jest-coverage-badges output docs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"prepare": "husky install",
|
|
13
13
|
"prepublish": "npm-run-all lint test build",
|
|
14
14
|
"start": "ts-node src/bin.ts",
|
|
15
|
-
"test": "jest
|
|
15
|
+
"test": "jest"
|
|
16
16
|
},
|
|
17
17
|
"bin": "dist/src/bin.js",
|
|
18
18
|
"dependencies": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"log4js": "6.4.3",
|
|
27
27
|
"mustache": "4.1.0",
|
|
28
28
|
"node-fetch": "2.6.7",
|
|
29
|
-
"npm-check-updates": "12.5.
|
|
29
|
+
"npm-check-updates": "12.5.4",
|
|
30
30
|
"parse-github-url": "1.0.2",
|
|
31
31
|
"semver": "7.3.5",
|
|
32
32
|
"sleep-promise": "9.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"husky": "7.0.4",
|
|
54
54
|
"jest": "27.4.7",
|
|
55
55
|
"jest-coverage-badges": "1.1.2",
|
|
56
|
-
"lint-staged": "12.3.
|
|
56
|
+
"lint-staged": "12.3.7",
|
|
57
57
|
"npm-run-all": "4.1.5",
|
|
58
58
|
"rimraf": "3.0.2",
|
|
59
59
|
"ts-jest": "27.1.3",
|
|
@@ -6,27 +6,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GitRepository = void 0;
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const parse_github_url_1 = __importDefault(require("parse-github-url"));
|
|
9
|
+
const HOST_GITHUB = 'github.com';
|
|
9
10
|
class GitRepository {
|
|
10
|
-
constructor({ url, owner, name }) {
|
|
11
|
+
constructor({ url, owner, name, isGitHub }) {
|
|
11
12
|
this.url = url;
|
|
12
13
|
this.owner = owner;
|
|
13
14
|
this.name = name;
|
|
15
|
+
this.isGitHub = isGitHub;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Parses a repository string.
|
|
19
|
+
* @example Valid strings
|
|
20
|
+
* - `<owner>/<repo>`
|
|
21
|
+
* - `github:<owner>/<repo>`
|
|
22
|
+
* - `https://<host>/<owner>/<repo>`
|
|
23
|
+
* - `https://<host>/<owner>/<repo>.git`
|
|
24
|
+
* - `git://<host>/<owner>/<repo>`
|
|
25
|
+
* - `git://<host>/<owner>/<repo>.git`
|
|
26
|
+
* - `git+https://<host>/<owner>/<repo>`
|
|
27
|
+
* - `git+https://<host>/<owner>/<repo>.git`
|
|
28
|
+
* - `git+ssh://<host>/<owner>/<repo>`
|
|
29
|
+
* - `git+ssh://<host>/<owner>/<repo>.git`
|
|
30
|
+
* - `git@<host>:<owner>/<repo>`
|
|
31
|
+
* - `git@<host>:<owner>/<repo>.git`
|
|
32
|
+
*/
|
|
15
33
|
static of(repository) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error(`Failed to parse repository. repository=${repository}`);
|
|
34
|
+
const result = (0, parse_github_url_1.default)(repository);
|
|
35
|
+
if (result === null) {
|
|
36
|
+
return undefined;
|
|
20
37
|
}
|
|
21
|
-
const {
|
|
22
|
-
if (
|
|
23
|
-
|
|
38
|
+
const { owner, name } = result;
|
|
39
|
+
if (owner === null || name === null) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const host = result.protocol === 'github:' ? HOST_GITHUB : result.host;
|
|
43
|
+
if (host === null || !host.includes('.')) {
|
|
44
|
+
return undefined;
|
|
24
45
|
}
|
|
25
|
-
const protocol = (_a = parsed.protocol) !== null && _a !== void 0 ? _a : 'https:';
|
|
26
46
|
return new GitRepository({
|
|
27
|
-
url: new url_1.URL(
|
|
47
|
+
url: new url_1.URL(`https://${host}/${owner}/${name}`),
|
|
28
48
|
owner,
|
|
29
|
-
name
|
|
49
|
+
name,
|
|
50
|
+
isGitHub: host === HOST_GITHUB
|
|
30
51
|
});
|
|
31
52
|
}
|
|
32
53
|
}
|
|
@@ -20,7 +20,7 @@ class PullRequestBodyCreator {
|
|
|
20
20
|
const outdatedPackagesTable = this.createOutdatedPackagesTable(outdatedPackage);
|
|
21
21
|
sections.push(`This PR updates these packages:\n\n${outdatedPackagesTable}`);
|
|
22
22
|
const gitRepo = await this.extractRepository(outdatedPackage);
|
|
23
|
-
if (gitRepo
|
|
23
|
+
if ((gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
|
|
24
24
|
const releaseNotesSection = await this.createReleaseNotesSection({
|
|
25
25
|
outdatedPackage,
|
|
26
26
|
gitRepo
|
package/dist/src/main.js
CHANGED
|
@@ -30,6 +30,9 @@ const main = async ({ options, logger }) => {
|
|
|
30
30
|
const remoteUrl = await git.getRemoteUrl();
|
|
31
31
|
const gitRepo = git_1.GitRepository.of(remoteUrl);
|
|
32
32
|
logger.debug(`gitRepo=${JSON.stringify(gitRepo)}`);
|
|
33
|
+
if (gitRepo === undefined) {
|
|
34
|
+
throw new Error(`Failed to parse remote url. URL=${remoteUrl}`);
|
|
35
|
+
}
|
|
33
36
|
const github = (0, github_1.createGitHub)({
|
|
34
37
|
host: gitRepo.url.host,
|
|
35
38
|
token: options.githubToken
|
|
@@ -2,19 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractRepository = void 0;
|
|
4
4
|
const git_1 = require("../git");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const extractRepository = (pkg) => {
|
|
6
|
+
const { repository } = pkg;
|
|
7
7
|
if (repository === undefined) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!isGitHub) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return git_1.GitRepository.of(`${owner}/${repo}`);
|
|
16
|
-
}
|
|
17
|
-
const { url } = repository;
|
|
18
|
-
return git_1.GitRepository.of(url.replace(/^git\+/, ''));
|
|
10
|
+
const repositoryString = typeof repository === 'string' ? repository : repository.url;
|
|
11
|
+
return git_1.GitRepository.of(repositoryString);
|
|
19
12
|
};
|
|
20
13
|
exports.extractRepository = extractRepository;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.7",
|
|
4
4
|
"description": "CLI tool for creating pull requests to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"badges": "jest-coverage-badges output docs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"prepare": "husky install",
|
|
13
13
|
"prepublish": "npm-run-all lint test build",
|
|
14
14
|
"start": "ts-node src/bin.ts",
|
|
15
|
-
"test": "jest
|
|
15
|
+
"test": "jest"
|
|
16
16
|
},
|
|
17
17
|
"bin": "dist/src/bin.js",
|
|
18
18
|
"dependencies": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"log4js": "6.4.3",
|
|
27
27
|
"mustache": "4.1.0",
|
|
28
28
|
"node-fetch": "2.6.7",
|
|
29
|
-
"npm-check-updates": "12.5.
|
|
29
|
+
"npm-check-updates": "12.5.4",
|
|
30
30
|
"parse-github-url": "1.0.2",
|
|
31
31
|
"semver": "7.3.5",
|
|
32
32
|
"sleep-promise": "9.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"husky": "7.0.4",
|
|
54
54
|
"jest": "27.4.7",
|
|
55
55
|
"jest-coverage-badges": "1.1.2",
|
|
56
|
-
"lint-staged": "12.3.
|
|
56
|
+
"lint-staged": "12.3.7",
|
|
57
57
|
"npm-run-all": "4.1.5",
|
|
58
58
|
"rimraf": "3.0.2",
|
|
59
59
|
"ts-jest": "27.1.3",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRepositoryString = void 0;
|
|
4
|
-
const parseRepositoryString = (repository) => {
|
|
5
|
-
const matched = repository.match(/^((.+):)?(.+)\/(.+)/);
|
|
6
|
-
if (matched === null) {
|
|
7
|
-
throw new Error(`Failed to parse repository. repository=${repository}`);
|
|
8
|
-
}
|
|
9
|
-
const [, , type, owner, repo] = matched;
|
|
10
|
-
/* istanbul ignore if: I can't write a test to reach here. */
|
|
11
|
-
if (owner === undefined || repo === undefined) {
|
|
12
|
-
throw new Error(`Failed to parse repository. repository=${repository}`);
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
owner,
|
|
16
|
-
repo,
|
|
17
|
-
isGitHub: type === undefined || type === 'github'
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exports.parseRepositoryString = parseRepositoryString;
|