npm-update-package 0.55.0 → 0.58.0
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/README.md +72 -4
- package/dist/package.json +9 -7
- package/dist/src/bin.js +5 -8
- package/dist/src/core/Create.js +62 -0
- package/dist/src/core/OutdatedPackageProcessor.js +0 -74
- package/dist/src/core/OutdatedPackageProcessorCreator.js +48 -0
- package/dist/src/core/OutdatedPackagesProcessor.js +3 -3
- package/dist/src/core/OutdatedPullRequestStrategy.js +11 -0
- package/dist/src/core/Recreate.js +67 -0
- package/dist/src/core/Skip.js +72 -0
- package/dist/src/core/index.js +2 -0
- package/dist/src/git/GitTransaction.js +33 -0
- package/dist/src/git/index.js +1 -0
- package/dist/src/github/GitHub.js +6 -3
- package/dist/src/github/label/creator/LabelCreator.js +5 -5
- package/dist/src/github/pull-request/closer/PullRequestsCloser.js +3 -3
- package/dist/src/github/pull-request/creator/AssigneesAdder.js +23 -0
- package/dist/src/github/pull-request/creator/PullRequestCreator.js +16 -17
- package/dist/src/github/pull-request/creator/ReviewersAdder.js +23 -0
- package/dist/src/github/pull-request/creator/index.js +2 -0
- package/dist/src/logger/index.js +1 -2
- package/dist/src/logger/logger.js +5 -0
- package/dist/src/main.js +36 -40
- package/dist/src/ncu/Ncu.js +4 -4
- package/dist/src/options/Options.js +9 -1
- package/dist/src/options/cliOptions.js +25 -0
- package/dist/src/package-manager/PackageManagerCreator.js +10 -10
- package/dist/src/package-manager/index.js +2 -2
- package/dist/src/package-manager/{Npm.js → npm/Npm.js} +0 -0
- package/dist/src/package-manager/{NpmVersions.js → npm/NpmVersions.js} +0 -0
- package/dist/src/{number → package-manager/npm}/index.js +1 -1
- package/dist/src/package-manager/{Yarn.js → yarn/Yarn.js} +0 -0
- package/dist/src/package-manager/{YarnVersions.js → yarn/YarnVersions.js} +0 -0
- package/dist/src/package-manager/yarn/index.js +17 -0
- package/package.json +9 -7
- package/dist/src/logger/Logger.js +0 -2
- package/dist/src/logger/createLogger.js +0 -10
- package/dist/src/number/range.js +0 -10
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LabelCreator = void 0;
|
|
4
|
+
const logger_1 = require("../../../logger");
|
|
4
5
|
const errors_1 = require("../../errors");
|
|
5
6
|
// TODO: Split into multiple classes and functions
|
|
6
7
|
class LabelCreator {
|
|
7
|
-
constructor({ github, gitRepo
|
|
8
|
+
constructor({ github, gitRepo }) {
|
|
8
9
|
this.github = github;
|
|
9
10
|
this.gitRepo = gitRepo;
|
|
10
|
-
this.logger = logger;
|
|
11
11
|
}
|
|
12
12
|
async create({ name, description, color }) {
|
|
13
13
|
const label = await this.fetchLabel(name);
|
|
14
14
|
if (label !== undefined) {
|
|
15
|
-
|
|
15
|
+
logger_1.logger.info(`Skip creating ${name} label because it already exists.`);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
await this.createLabel({
|
|
@@ -20,7 +20,7 @@ class LabelCreator {
|
|
|
20
20
|
description,
|
|
21
21
|
color
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
logger_1.logger.info(`${name} label has created.`);
|
|
24
24
|
}
|
|
25
25
|
async createLabel({ name, description, color }) {
|
|
26
26
|
await this.github.createLabel({
|
|
@@ -41,7 +41,7 @@ class LabelCreator {
|
|
|
41
41
|
}
|
|
42
42
|
catch (e) {
|
|
43
43
|
if ((0, errors_1.isNotFoundError)(e)) {
|
|
44
|
-
|
|
44
|
+
logger_1.logger.warn(e);
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestsCloser = void 0;
|
|
4
|
+
const logger_1 = require("../../../logger");
|
|
4
5
|
class PullRequestsCloser {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(pullRequestCloser) {
|
|
6
7
|
this.pullRequestCloser = pullRequestCloser;
|
|
7
|
-
this.logger = logger;
|
|
8
8
|
}
|
|
9
9
|
async close(pullRequests) {
|
|
10
10
|
await Promise.all(pullRequests.map(async (pullRequest) => {
|
|
11
11
|
await this.pullRequestCloser.close(pullRequest);
|
|
12
|
-
|
|
12
|
+
logger_1.logger.info(`Pull request #${pullRequest.number} has closed. ${pullRequest.html_url}`);
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AssigneesAdder = void 0;
|
|
7
|
+
const shuffle_1 = __importDefault(require("lodash/shuffle"));
|
|
8
|
+
// TODO: Add test
|
|
9
|
+
class AssigneesAdder {
|
|
10
|
+
constructor({ github, gitRepo }) {
|
|
11
|
+
this.github = github;
|
|
12
|
+
this.gitRepo = gitRepo;
|
|
13
|
+
}
|
|
14
|
+
async add({ issueNumber, assignees, sampleSize }) {
|
|
15
|
+
await this.github.addAssignees({
|
|
16
|
+
owner: this.gitRepo.owner,
|
|
17
|
+
repo: this.gitRepo.name,
|
|
18
|
+
issueNumber,
|
|
19
|
+
assignees: sampleSize !== undefined ? (0, shuffle_1.default)(assignees).slice(0, sampleSize) : assignees
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.AssigneesAdder = AssigneesAdder;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
|
+
const logger_1 = require("../../../logger");
|
|
4
5
|
class PullRequestCreator {
|
|
5
|
-
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator,
|
|
6
|
+
constructor({ options, github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, assigneesAdder, reviewersAdder }) {
|
|
7
|
+
this.options = options;
|
|
6
8
|
this.github = github;
|
|
7
9
|
this.gitRepo = gitRepo;
|
|
8
10
|
this.githubRepo = githubRepo;
|
|
9
11
|
this.pullRequestTitleCreator = pullRequestTitleCreator;
|
|
10
12
|
this.pullRequestBodyCreator = pullRequestBodyCreator;
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.assignees = assignees;
|
|
13
|
+
this.assigneesAdder = assigneesAdder;
|
|
14
|
+
this.reviewersAdder = reviewersAdder;
|
|
14
15
|
}
|
|
15
16
|
async create({ outdatedPackage, branchName }) {
|
|
16
17
|
const title = this.pullRequestTitleCreator.create(outdatedPackage);
|
|
17
|
-
|
|
18
|
+
logger_1.logger.debug(`title=${title}`);
|
|
18
19
|
const body = await this.pullRequestBodyCreator.create(outdatedPackage);
|
|
19
|
-
|
|
20
|
+
logger_1.logger.debug(`body=${body}`);
|
|
20
21
|
const pullRequest = await this.github.createPullRequest({
|
|
21
22
|
owner: this.gitRepo.owner,
|
|
22
23
|
repo: this.gitRepo.name,
|
|
@@ -25,27 +26,25 @@ class PullRequestCreator {
|
|
|
25
26
|
title,
|
|
26
27
|
body
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
+
logger_1.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
|
|
29
30
|
await this.github.addLabels({
|
|
30
31
|
owner: this.gitRepo.owner,
|
|
31
32
|
repo: this.gitRepo.name,
|
|
32
33
|
issueNumber: pullRequest.number,
|
|
33
34
|
labels: ['npm-update-package']
|
|
34
35
|
});
|
|
35
|
-
if (this.assignees !== undefined) {
|
|
36
|
-
await this.
|
|
37
|
-
owner: this.gitRepo.owner,
|
|
38
|
-
repo: this.gitRepo.name,
|
|
36
|
+
if (this.options.assignees !== undefined) {
|
|
37
|
+
await this.assigneesAdder.add({
|
|
39
38
|
issueNumber: pullRequest.number,
|
|
40
|
-
assignees: this.assignees
|
|
39
|
+
assignees: this.options.assignees,
|
|
40
|
+
sampleSize: this.options.assigneesSampleSize
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
if (this.reviewers !== undefined) {
|
|
44
|
-
await this.
|
|
45
|
-
owner: this.gitRepo.owner,
|
|
46
|
-
repo: this.gitRepo.name,
|
|
43
|
+
if (this.options.reviewers !== undefined) {
|
|
44
|
+
await this.reviewersAdder.add({
|
|
47
45
|
pullNumber: pullRequest.number,
|
|
48
|
-
reviewers: this.reviewers
|
|
46
|
+
reviewers: this.options.reviewers,
|
|
47
|
+
sampleSize: this.options.reviewersSampleSize
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
return pullRequest;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReviewersAdder = void 0;
|
|
7
|
+
const shuffle_1 = __importDefault(require("lodash/shuffle"));
|
|
8
|
+
// TODO: Add test
|
|
9
|
+
class ReviewersAdder {
|
|
10
|
+
constructor({ github, gitRepo }) {
|
|
11
|
+
this.github = github;
|
|
12
|
+
this.gitRepo = gitRepo;
|
|
13
|
+
}
|
|
14
|
+
async add({ pullNumber, reviewers, sampleSize }) {
|
|
15
|
+
await this.github.requestReviewers({
|
|
16
|
+
owner: this.gitRepo.owner,
|
|
17
|
+
repo: this.gitRepo.name,
|
|
18
|
+
pullNumber,
|
|
19
|
+
reviewers: sampleSize !== undefined ? (0, shuffle_1.default)(reviewers).slice(0, sampleSize) : reviewers
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ReviewersAdder = ReviewersAdder;
|
|
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AssigneesAdder"), exports);
|
|
17
18
|
__exportStar(require("./GitHubUrlOptimizer"), exports);
|
|
18
19
|
__exportStar(require("./PackageDiffsSectionCreator"), exports);
|
|
19
20
|
__exportStar(require("./PullRequestBodyCreator"), exports);
|
|
20
21
|
__exportStar(require("./PullRequestCreator"), exports);
|
|
21
22
|
__exportStar(require("./PullRequestTitleCreator"), exports);
|
|
22
23
|
__exportStar(require("./ReleaseNotesSectionCreator"), exports);
|
|
24
|
+
__exportStar(require("./ReviewersAdder"), exports);
|
package/dist/src/logger/index.js
CHANGED
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./Logger"), exports);
|
|
17
|
+
__exportStar(require("./logger"), exports);
|
|
19
18
|
__exportStar(require("./LogLevel"), exports);
|
package/dist/src/main.js
CHANGED
|
@@ -5,31 +5,29 @@ const Either_1 = require("fp-ts/lib/Either");
|
|
|
5
5
|
const core_1 = require("./core");
|
|
6
6
|
const git_1 = require("./git");
|
|
7
7
|
const github_1 = require("./github");
|
|
8
|
+
const logger_1 = require("./logger");
|
|
8
9
|
const ncu_1 = require("./ncu");
|
|
9
10
|
const package_manager_1 = require("./package-manager");
|
|
10
11
|
const terminal_1 = require("./terminal");
|
|
11
12
|
// TODO: Add test
|
|
12
|
-
const main = async (
|
|
13
|
-
logger.debug(`options=${JSON.stringify({
|
|
13
|
+
const main = async (options) => {
|
|
14
|
+
logger_1.logger.debug(`options=${JSON.stringify({
|
|
14
15
|
...options,
|
|
15
16
|
githubToken: options.githubToken !== '' ? '***' : ''
|
|
16
17
|
})}`);
|
|
17
|
-
const ncu = new ncu_1.Ncu(
|
|
18
|
-
options,
|
|
19
|
-
logger
|
|
20
|
-
});
|
|
18
|
+
const ncu = new ncu_1.Ncu(options);
|
|
21
19
|
const outdatedPackages = await ncu.check();
|
|
22
|
-
logger.debug(`outdatedPackages=${JSON.stringify(outdatedPackages)}`);
|
|
20
|
+
logger_1.logger.debug(`outdatedPackages=${JSON.stringify(outdatedPackages)}`);
|
|
23
21
|
if (outdatedPackages.length === 0) {
|
|
24
|
-
logger.info('All packages are up-to-date.');
|
|
22
|
+
logger_1.logger.info('All packages are up-to-date.');
|
|
25
23
|
return;
|
|
26
24
|
}
|
|
27
|
-
logger.info(`There are ${outdatedPackages.length} outdated packages.`);
|
|
25
|
+
logger_1.logger.info(`There are ${outdatedPackages.length} outdated packages.`);
|
|
28
26
|
const terminal = new terminal_1.Terminal();
|
|
29
27
|
const git = new git_1.Git(terminal);
|
|
30
28
|
const remoteUrl = await git.getRemoteUrl();
|
|
31
29
|
const gitRepo = git_1.GitRepository.of(remoteUrl);
|
|
32
|
-
logger.debug(`gitRepo=${JSON.stringify(gitRepo)}`);
|
|
30
|
+
logger_1.logger.debug(`gitRepo=${JSON.stringify(gitRepo)}`);
|
|
33
31
|
if (gitRepo === undefined) {
|
|
34
32
|
throw new Error(`Failed to parse remote url. URL=${remoteUrl}`);
|
|
35
33
|
}
|
|
@@ -41,21 +39,20 @@ const main = async ({ options, logger }) => {
|
|
|
41
39
|
owner: gitRepo.owner,
|
|
42
40
|
repo: gitRepo.name
|
|
43
41
|
});
|
|
44
|
-
logger.debug(`githubRepo=${JSON.stringify(githubRepo)}`);
|
|
42
|
+
logger_1.logger.debug(`githubRepo=${JSON.stringify(githubRepo)}`);
|
|
45
43
|
const branches = await github.fetchBranches({
|
|
46
44
|
owner: gitRepo.owner,
|
|
47
45
|
repo: gitRepo.name
|
|
48
46
|
});
|
|
49
|
-
logger.debug(`branches=${JSON.stringify(branches)}`);
|
|
47
|
+
logger_1.logger.debug(`branches=${JSON.stringify(branches)}`);
|
|
50
48
|
const pullRequests = await github.fetchPullRequests({
|
|
51
49
|
owner: gitRepo.owner,
|
|
52
50
|
repo: gitRepo.name
|
|
53
51
|
});
|
|
54
|
-
logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
52
|
+
logger_1.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
55
53
|
const labelCreator = new github_1.LabelCreator({
|
|
56
54
|
github,
|
|
57
|
-
gitRepo
|
|
58
|
-
logger
|
|
55
|
+
gitRepo
|
|
59
56
|
});
|
|
60
57
|
await labelCreator.create({
|
|
61
58
|
name: 'npm-update-package',
|
|
@@ -63,10 +60,7 @@ const main = async ({ options, logger }) => {
|
|
|
63
60
|
color: 'A00F21'
|
|
64
61
|
});
|
|
65
62
|
const branchFinder = new github_1.BranchFinder(branches);
|
|
66
|
-
const packageManagerCreator = new package_manager_1.PackageManagerCreator(
|
|
67
|
-
options,
|
|
68
|
-
logger
|
|
69
|
-
});
|
|
63
|
+
const packageManagerCreator = new package_manager_1.PackageManagerCreator(options);
|
|
70
64
|
const packageManager = await packageManagerCreator.create(terminal);
|
|
71
65
|
const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.prTitle);
|
|
72
66
|
const releasesFetcher = new github_1.ReleasesFetcher({
|
|
@@ -82,33 +76,38 @@ const main = async ({ options, logger }) => {
|
|
|
82
76
|
packageDiffsSectionCreator,
|
|
83
77
|
releaseNotesSectionCreator
|
|
84
78
|
});
|
|
79
|
+
const assigneesAdder = new github_1.AssigneesAdder({
|
|
80
|
+
github,
|
|
81
|
+
gitRepo
|
|
82
|
+
});
|
|
83
|
+
const reviewersAdder = new github_1.ReviewersAdder({
|
|
84
|
+
github,
|
|
85
|
+
gitRepo
|
|
86
|
+
});
|
|
85
87
|
const pullRequestCreator = new github_1.PullRequestCreator({
|
|
88
|
+
options,
|
|
86
89
|
github,
|
|
87
90
|
gitRepo,
|
|
88
91
|
githubRepo,
|
|
89
92
|
pullRequestTitleCreator,
|
|
90
93
|
pullRequestBodyCreator,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
assignees: options.assignees
|
|
94
|
+
assigneesAdder,
|
|
95
|
+
reviewersAdder
|
|
94
96
|
});
|
|
95
97
|
const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
|
|
96
98
|
const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
|
|
97
99
|
const pullRequestCloser = new github_1.PullRequestCloser(github);
|
|
98
|
-
const pullRequestsCloser = new github_1.PullRequestsCloser(
|
|
99
|
-
pullRequestCloser,
|
|
100
|
-
logger
|
|
101
|
-
});
|
|
100
|
+
const pullRequestsCloser = new github_1.PullRequestsCloser(pullRequestCloser);
|
|
102
101
|
const packageUpdater = new core_1.PackageUpdater({
|
|
103
102
|
packageManager,
|
|
104
103
|
ncu
|
|
105
104
|
});
|
|
106
|
-
const
|
|
105
|
+
const outdatedPackageProcessorCreator = new core_1.OutdatedPackageProcessorCreator(options);
|
|
106
|
+
const outdatedPackageProcessor = outdatedPackageProcessorCreator.create({
|
|
107
107
|
git,
|
|
108
108
|
packageManager,
|
|
109
109
|
pullRequestCreator,
|
|
110
110
|
branchFinder,
|
|
111
|
-
logger,
|
|
112
111
|
commitMessageCreator,
|
|
113
112
|
pullRequestFinder,
|
|
114
113
|
pullRequestsCloser,
|
|
@@ -119,33 +118,30 @@ const main = async ({ options, logger }) => {
|
|
|
119
118
|
git
|
|
120
119
|
});
|
|
121
120
|
await gitConfigInitializer.initialize();
|
|
122
|
-
const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor(
|
|
123
|
-
outdatedPackageProcessor,
|
|
124
|
-
logger
|
|
125
|
-
});
|
|
121
|
+
const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor(outdatedPackageProcessor);
|
|
126
122
|
const results = await outdatedPackagesProcessor.process(outdatedPackages);
|
|
127
|
-
logger.debug(`results=${JSON.stringify(results)}`);
|
|
123
|
+
logger_1.logger.debug(`results=${JSON.stringify(results)}`);
|
|
128
124
|
const succeededResults = results.filter(Either_1.isRight).map(({ right }) => right);
|
|
129
|
-
logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
|
|
125
|
+
logger_1.logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
|
|
130
126
|
const createdPackages = succeededResults
|
|
131
127
|
.filter(({ created }) => created)
|
|
132
128
|
.map(({ outdatedPackage }) => outdatedPackage);
|
|
133
|
-
logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
|
|
129
|
+
logger_1.logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
|
|
134
130
|
const skippedPackages = succeededResults
|
|
135
131
|
.filter(({ skipped }) => skipped)
|
|
136
132
|
.map(({ outdatedPackage }) => outdatedPackage);
|
|
137
|
-
logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
|
|
133
|
+
logger_1.logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
|
|
138
134
|
const failedResults = results.filter(Either_1.isLeft).map(({ left }) => left);
|
|
139
|
-
logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
|
|
135
|
+
logger_1.logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
|
|
140
136
|
const failedPackages = failedResults.map(({ outdatedPackage }) => outdatedPackage);
|
|
141
|
-
logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
|
|
137
|
+
logger_1.logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
|
|
142
138
|
// TODO: Show as table
|
|
143
|
-
logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
|
|
139
|
+
logger_1.logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
|
|
144
140
|
- ${createdPackages.length} packages: created (${createdPackages.map(({ name }) => name).join(',')})
|
|
145
141
|
- ${skippedPackages.length} packages: skipped: (${skippedPackages.map(({ name }) => name).join(',')})
|
|
146
142
|
- ${failedPackages.length} packages: failed: (${failedPackages.map(({ name }) => name).join(',')})`);
|
|
147
143
|
if (options.ignorePackages !== undefined) {
|
|
148
|
-
logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
|
|
144
|
+
logger_1.logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
|
|
149
145
|
}
|
|
150
146
|
};
|
|
151
147
|
exports.main = main;
|
package/dist/src/ncu/Ncu.js
CHANGED
|
@@ -4,14 +4,14 @@ exports.Ncu = void 0;
|
|
|
4
4
|
const npm_check_updates_1 = require("npm-check-updates");
|
|
5
5
|
const type_guards_1 = require("type-guards");
|
|
6
6
|
const file_1 = require("../file");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
7
8
|
const package_json_1 = require("../package-json");
|
|
8
9
|
const semver_1 = require("../semver");
|
|
9
10
|
const NcuResult_1 = require("./NcuResult");
|
|
10
11
|
// TODO: Add test
|
|
11
12
|
class Ncu {
|
|
12
|
-
constructor(
|
|
13
|
+
constructor(options) {
|
|
13
14
|
this.options = options;
|
|
14
|
-
this.logger = logger;
|
|
15
15
|
}
|
|
16
16
|
async check() {
|
|
17
17
|
return await this.run({
|
|
@@ -32,9 +32,9 @@ class Ncu {
|
|
|
32
32
|
// Read package.json before running ncu
|
|
33
33
|
const json = await (0, file_1.readFile)('./package.json');
|
|
34
34
|
const pkg = (0, package_json_1.parsePackageJson)(json);
|
|
35
|
-
|
|
35
|
+
logger_1.logger.debug(`pkg=${JSON.stringify(pkg)}`);
|
|
36
36
|
const result = await (0, npm_check_updates_1.run)(options);
|
|
37
|
-
|
|
37
|
+
logger_1.logger.debug(`result=${JSON.stringify(result)}`);
|
|
38
38
|
if (!(0, NcuResult_1.isNcuResult)(result)) {
|
|
39
39
|
throw new Error('Failed to running ncu.');
|
|
40
40
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isOptions = void 0;
|
|
4
4
|
const io_ts_1 = require("io-ts");
|
|
5
|
+
const core_1 = require("../core");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const package_manager_1 = require("../package-manager");
|
|
7
8
|
const Options = (0, io_ts_1.intersection)([
|
|
@@ -19,11 +20,17 @@ const Options = (0, io_ts_1.intersection)([
|
|
|
19
20
|
(0, io_ts_1.literal)(logger_1.LogLevel.Debug),
|
|
20
21
|
(0, io_ts_1.literal)(logger_1.LogLevel.Trace)
|
|
21
22
|
]),
|
|
23
|
+
outdatedPrStrategy: (0, io_ts_1.union)([
|
|
24
|
+
(0, io_ts_1.literal)(core_1.OutdatedPullRequestStrategy.Create),
|
|
25
|
+
(0, io_ts_1.literal)(core_1.OutdatedPullRequestStrategy.Recreate),
|
|
26
|
+
(0, io_ts_1.literal)(core_1.OutdatedPullRequestStrategy.Skip)
|
|
27
|
+
]),
|
|
22
28
|
prBodyGithubHost: io_ts_1.string,
|
|
23
29
|
prTitle: io_ts_1.string
|
|
24
30
|
}),
|
|
25
31
|
(0, io_ts_1.partial)({
|
|
26
32
|
assignees: (0, io_ts_1.array)(io_ts_1.string),
|
|
33
|
+
assigneesSampleSize: io_ts_1.number,
|
|
27
34
|
gitUserEmail: io_ts_1.string,
|
|
28
35
|
gitUserName: io_ts_1.string,
|
|
29
36
|
ignorePackages: (0, io_ts_1.array)(io_ts_1.string),
|
|
@@ -32,7 +39,8 @@ const Options = (0, io_ts_1.intersection)([
|
|
|
32
39
|
(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)
|
|
33
40
|
]),
|
|
34
41
|
prBodyNotes: io_ts_1.string,
|
|
35
|
-
reviewers: (0, io_ts_1.array)(io_ts_1.string)
|
|
42
|
+
reviewers: (0, io_ts_1.array)(io_ts_1.string),
|
|
43
|
+
reviewersSampleSize: io_ts_1.number
|
|
36
44
|
})
|
|
37
45
|
]);
|
|
38
46
|
exports.isOptions = Options.is;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cliOptions = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
4
5
|
const logger_1 = require("../logger");
|
|
5
6
|
const package_manager_1 = require("../package-manager");
|
|
6
7
|
const OptionType_1 = require("./OptionType");
|
|
@@ -11,6 +12,12 @@ exports.cliOptions = [
|
|
|
11
12
|
type: OptionType_1.OptionType.StringArray,
|
|
12
13
|
required: false
|
|
13
14
|
},
|
|
15
|
+
{
|
|
16
|
+
name: 'assignees-sample-size',
|
|
17
|
+
description: 'How many members to be assigned to assignees',
|
|
18
|
+
type: OptionType_1.OptionType.Number,
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
14
21
|
{
|
|
15
22
|
name: 'commit-message',
|
|
16
23
|
description: 'Commit message template',
|
|
@@ -72,6 +79,18 @@ exports.cliOptions = [
|
|
|
72
79
|
],
|
|
73
80
|
default: logger_1.LogLevel.Info
|
|
74
81
|
},
|
|
82
|
+
{
|
|
83
|
+
name: 'outdated-pr-strategy',
|
|
84
|
+
description: 'What to do when outdated pull requests exist',
|
|
85
|
+
type: OptionType_1.OptionType.String,
|
|
86
|
+
required: false,
|
|
87
|
+
choices: [
|
|
88
|
+
core_1.OutdatedPullRequestStrategy.Create,
|
|
89
|
+
core_1.OutdatedPullRequestStrategy.Recreate,
|
|
90
|
+
core_1.OutdatedPullRequestStrategy.Skip
|
|
91
|
+
],
|
|
92
|
+
default: core_1.OutdatedPullRequestStrategy.Recreate
|
|
93
|
+
},
|
|
75
94
|
{
|
|
76
95
|
name: 'package-manager',
|
|
77
96
|
description: 'Package manager of your project',
|
|
@@ -107,5 +126,11 @@ exports.cliOptions = [
|
|
|
107
126
|
description: 'User names to request reviews',
|
|
108
127
|
type: OptionType_1.OptionType.StringArray,
|
|
109
128
|
required: false
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'reviewers-sample-size',
|
|
132
|
+
description: 'How many members to be assigned to reviewers',
|
|
133
|
+
type: OptionType_1.OptionType.Number,
|
|
134
|
+
required: false
|
|
110
135
|
}
|
|
111
136
|
];
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PackageManagerCreator = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
4
5
|
const detectPackageManager_1 = require("./detectPackageManager");
|
|
5
|
-
const
|
|
6
|
+
const npm_1 = require("./npm");
|
|
6
7
|
const PackageManagerName_1 = require("./PackageManagerName");
|
|
7
|
-
const
|
|
8
|
+
const yarn_1 = require("./yarn");
|
|
8
9
|
class PackageManagerCreator {
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(options) {
|
|
10
11
|
this.options = options;
|
|
11
|
-
this.logger = logger;
|
|
12
12
|
}
|
|
13
13
|
async create(terminal) {
|
|
14
14
|
const packageManagerName = await this.getPackageManagerName();
|
|
15
|
-
|
|
15
|
+
logger_1.logger.trace(`packageManagerName=${packageManagerName}`);
|
|
16
16
|
switch (packageManagerName) {
|
|
17
17
|
case PackageManagerName_1.PackageManagerName.Npm:
|
|
18
|
-
|
|
19
|
-
return new
|
|
18
|
+
logger_1.logger.info('Use npm as package manager');
|
|
19
|
+
return new npm_1.Npm(terminal);
|
|
20
20
|
case PackageManagerName_1.PackageManagerName.Yarn:
|
|
21
|
-
|
|
22
|
-
return new
|
|
21
|
+
logger_1.logger.info('Use Yarn as package manager');
|
|
22
|
+
return new yarn_1.Yarn(terminal);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
async getPackageManagerName() {
|
|
26
26
|
if (this.options.packageManager !== undefined) {
|
|
27
27
|
return this.options.packageManager;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
logger_1.logger.info('Try to detect package manager from lock file.');
|
|
30
30
|
return await (0, detectPackageManager_1.detectPackageManager)();
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./npm"), exports);
|
|
18
18
|
__exportStar(require("./PackageManager"), exports);
|
|
19
19
|
__exportStar(require("./PackageManagerCreator"), exports);
|
|
20
20
|
__exportStar(require("./PackageManagerName"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./yarn"), exports);
|
|
File without changes
|
|
File without changes
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./Npm"), exports);
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Yarn"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "CLI tool for creating pull requests to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
"fp-ts": "2.11.9",
|
|
21
21
|
"http-status-codes": "2.2.0",
|
|
22
22
|
"io-ts": "2.2.16",
|
|
23
|
+
"lodash": "4.14.2",
|
|
23
24
|
"log4js": "6.4.4",
|
|
24
25
|
"mustache": "4.1.0",
|
|
25
26
|
"node-fetch": "2.6.7",
|
|
26
|
-
"npm-check-updates": "12.5.
|
|
27
|
+
"npm-check-updates": "12.5.8",
|
|
27
28
|
"parse-github-url": "1.0.2",
|
|
28
|
-
"semver": "7.3.
|
|
29
|
+
"semver": "7.3.6",
|
|
29
30
|
"sleep-promise": "9.1.0",
|
|
30
31
|
"type-guards": "0.15.0"
|
|
31
32
|
},
|
|
@@ -33,19 +34,20 @@
|
|
|
33
34
|
"@jest/types": "27.4.2",
|
|
34
35
|
"@tsconfig/node12": "1.0.9",
|
|
35
36
|
"@types/jest": "27.4.1",
|
|
37
|
+
"@types/lodash": "4.14.181",
|
|
36
38
|
"@types/mustache": "4.1.2",
|
|
37
39
|
"@types/node": "12.20.47",
|
|
38
40
|
"@types/node-fetch": "2.6.1",
|
|
39
41
|
"@types/parse-github-url": "1.0.0",
|
|
40
42
|
"@types/semver": "7.3.9",
|
|
41
43
|
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
42
|
-
"eslint": "8.
|
|
44
|
+
"eslint": "8.13.0",
|
|
43
45
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
44
|
-
"eslint-plugin-import": "2.
|
|
45
|
-
"eslint-plugin-jest": "26.1.
|
|
46
|
+
"eslint-plugin-import": "2.26.0",
|
|
47
|
+
"eslint-plugin-jest": "26.1.4",
|
|
46
48
|
"eslint-plugin-node": "11.1.0",
|
|
47
49
|
"eslint-plugin-promise": "6.0.0",
|
|
48
|
-
"eslint-plugin-tsdoc": "0.2.
|
|
50
|
+
"eslint-plugin-tsdoc": "0.2.16",
|
|
49
51
|
"husky": "7.0.4",
|
|
50
52
|
"jest": "27.4.7",
|
|
51
53
|
"lint-staged": "12.3.7",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLogger = void 0;
|
|
4
|
-
const log4js_1 = require("log4js");
|
|
5
|
-
const createLogger = (logLevel) => {
|
|
6
|
-
const logger = (0, log4js_1.getLogger)();
|
|
7
|
-
logger.level = logLevel;
|
|
8
|
-
return logger;
|
|
9
|
-
};
|
|
10
|
-
exports.createLogger = createLogger;
|