npm-update-package 0.57.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 +28 -0
- package/dist/package.json +4 -4
- 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/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/main.js +2 -1
- package/dist/src/options/Options.js +6 -0
- package/dist/src/options/cliOptions.js +13 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ CLI tool for creating pull requests to update npm packages
|
|
|
26
26
|
- [githubToken](#githubtoken)
|
|
27
27
|
- [ignorePackages](#ignorepackages)
|
|
28
28
|
- [logLevel](#loglevel)
|
|
29
|
+
- [outdatedPrStrategy](#outdatedprstrategy)
|
|
29
30
|
- [packageManager](#packagemanager)
|
|
30
31
|
- [prBodyGithubHost](#prbodygithubhost)
|
|
31
32
|
- [prBodyNotes](#prbodynotes)
|
|
@@ -266,6 +267,33 @@ npx npm-update-package \
|
|
|
266
267
|
--log-level debug
|
|
267
268
|
```
|
|
268
269
|
|
|
270
|
+
### outdatedPrStrategy
|
|
271
|
+
|
|
272
|
+
What to do when outdated pull requests exist.
|
|
273
|
+
|
|
274
|
+
|Name|Value|
|
|
275
|
+
|---|---|
|
|
276
|
+
|cli|`--outdated-pr-strategy`|
|
|
277
|
+
|type|string|
|
|
278
|
+
|required|false|
|
|
279
|
+
|default|`recreate`|
|
|
280
|
+
|
|
281
|
+
Allowed values:
|
|
282
|
+
|
|
283
|
+
|Value|Description|
|
|
284
|
+
|---|---|
|
|
285
|
+
|`create`|Create new pull request.|
|
|
286
|
+
|`recreate`|Close old pull requests and create new pull request.|
|
|
287
|
+
|`skip`|Skip creating pull request.|
|
|
288
|
+
|
|
289
|
+
Example:
|
|
290
|
+
|
|
291
|
+
```sh
|
|
292
|
+
npx npm-update-package \
|
|
293
|
+
--github-token $GITHUB_TOKEN \
|
|
294
|
+
--outdated-pr-strategy create
|
|
295
|
+
```
|
|
296
|
+
|
|
269
297
|
### packageManager
|
|
270
298
|
|
|
271
299
|
Package manager of your project.
|
package/dist/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",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@types/parse-github-url": "1.0.0",
|
|
42
42
|
"@types/semver": "7.3.9",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
44
|
-
"eslint": "8.
|
|
44
|
+
"eslint": "8.13.0",
|
|
45
45
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
46
46
|
"eslint-plugin-import": "2.26.0",
|
|
47
|
-
"eslint-plugin-jest": "26.1.
|
|
47
|
+
"eslint-plugin-jest": "26.1.4",
|
|
48
48
|
"eslint-plugin-node": "11.1.0",
|
|
49
49
|
"eslint-plugin-promise": "6.0.0",
|
|
50
|
-
"eslint-plugin-tsdoc": "0.2.
|
|
50
|
+
"eslint-plugin-tsdoc": "0.2.16",
|
|
51
51
|
"husky": "7.0.4",
|
|
52
52
|
"jest": "27.4.7",
|
|
53
53
|
"lint-staged": "12.3.7",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Create = void 0;
|
|
4
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
5
|
+
const git_1 = require("../git");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
// TODO: Add test
|
|
8
|
+
class Create {
|
|
9
|
+
constructor({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, packageUpdater }) {
|
|
10
|
+
this.git = git;
|
|
11
|
+
this.packageManager = packageManager;
|
|
12
|
+
this.pullRequestCreator = pullRequestCreator;
|
|
13
|
+
this.branchFinder = branchFinder;
|
|
14
|
+
this.commitMessageCreator = commitMessageCreator;
|
|
15
|
+
this.packageUpdater = packageUpdater;
|
|
16
|
+
}
|
|
17
|
+
async process(outdatedPackage) {
|
|
18
|
+
const branchName = (0, git_1.createBranchName)(outdatedPackage);
|
|
19
|
+
logger_1.logger.trace(`branchName=${branchName}`);
|
|
20
|
+
if (this.branchFinder.findByName(branchName) !== undefined) {
|
|
21
|
+
logger_1.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
|
|
22
|
+
return (0, Either_1.right)({
|
|
23
|
+
outdatedPackage,
|
|
24
|
+
skipped: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const transaction = new git_1.GitTransaction({
|
|
28
|
+
git: this.git,
|
|
29
|
+
branchName,
|
|
30
|
+
files: [this.packageManager.packageFile, this.packageManager.lockFile]
|
|
31
|
+
});
|
|
32
|
+
return await transaction.run(async ({ git, branchName }) => {
|
|
33
|
+
try {
|
|
34
|
+
await this.packageUpdater.update(outdatedPackage);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
logger_1.logger.error(error);
|
|
38
|
+
return (0, Either_1.left)({
|
|
39
|
+
outdatedPackage,
|
|
40
|
+
error
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
logger_1.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
44
|
+
await git.add(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
45
|
+
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
46
|
+
logger_1.logger.trace(`message=${message}`);
|
|
47
|
+
await git.commit(message);
|
|
48
|
+
await git.push(branchName);
|
|
49
|
+
const pullRequest = await this.pullRequestCreator.create({
|
|
50
|
+
outdatedPackage,
|
|
51
|
+
branchName
|
|
52
|
+
});
|
|
53
|
+
logger_1.logger.trace(`pullRequest=${JSON.stringify(pullRequest)}`);
|
|
54
|
+
logger_1.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
|
|
55
|
+
return (0, Either_1.right)({
|
|
56
|
+
outdatedPackage,
|
|
57
|
+
created: true
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Create = Create;
|
|
@@ -1,76 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutdatedPackageProcessor = void 0;
|
|
4
|
-
const Either_1 = require("fp-ts/lib/Either");
|
|
5
|
-
const git_1 = require("../git");
|
|
6
|
-
const logger_1 = require("../logger");
|
|
7
|
-
// TODO: Add test
|
|
8
|
-
// TODO: Split into multiple classes and functions
|
|
9
|
-
class OutdatedPackageProcessor {
|
|
10
|
-
constructor({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, pullRequestFinder, pullRequestsCloser, packageUpdater }) {
|
|
11
|
-
this.git = git;
|
|
12
|
-
this.packageManager = packageManager;
|
|
13
|
-
this.pullRequestCreator = pullRequestCreator;
|
|
14
|
-
this.branchFinder = branchFinder;
|
|
15
|
-
this.commitMessageCreator = commitMessageCreator;
|
|
16
|
-
this.pullRequestFinder = pullRequestFinder;
|
|
17
|
-
this.pullRequestsCloser = pullRequestsCloser;
|
|
18
|
-
this.packageUpdater = packageUpdater;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Don't run in parallel because it includes file operations.
|
|
22
|
-
*/
|
|
23
|
-
async process(outdatedPackage) {
|
|
24
|
-
const branchName = (0, git_1.createBranchName)(outdatedPackage);
|
|
25
|
-
logger_1.logger.debug(`branchName=${branchName}`);
|
|
26
|
-
if (this.branchFinder.findByName(branchName) !== undefined) {
|
|
27
|
-
logger_1.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
|
|
28
|
-
return (0, Either_1.right)({
|
|
29
|
-
outdatedPackage,
|
|
30
|
-
skipped: true
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
await this.git.createBranch(branchName);
|
|
34
|
-
logger_1.logger.info(`${branchName} branch has created.`);
|
|
35
|
-
try {
|
|
36
|
-
try {
|
|
37
|
-
await this.packageUpdater.update(outdatedPackage);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
logger_1.logger.error(error);
|
|
41
|
-
return (0, Either_1.left)({
|
|
42
|
-
outdatedPackage,
|
|
43
|
-
error
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
logger_1.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
47
|
-
await this.git.add(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
48
|
-
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
49
|
-
logger_1.logger.debug(`message=${message}`);
|
|
50
|
-
await this.git.commit(message);
|
|
51
|
-
await this.git.push(branchName);
|
|
52
|
-
const pullRequest = await this.pullRequestCreator.create({
|
|
53
|
-
outdatedPackage,
|
|
54
|
-
branchName
|
|
55
|
-
});
|
|
56
|
-
logger_1.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
|
|
57
|
-
await this.closeOldPullRequests(outdatedPackage);
|
|
58
|
-
return (0, Either_1.right)({
|
|
59
|
-
outdatedPackage,
|
|
60
|
-
created: true
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
await this.git.restore(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
65
|
-
await this.git.switch('-');
|
|
66
|
-
await this.git.removeBranch(branchName);
|
|
67
|
-
logger_1.logger.info(`${branchName} branch has removed.`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async closeOldPullRequests(outdatedPackage) {
|
|
71
|
-
const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
|
|
72
|
-
logger_1.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
73
|
-
await this.pullRequestsCloser.close(pullRequests);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.OutdatedPackageProcessor = OutdatedPackageProcessor;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutdatedPackageProcessorCreator = void 0;
|
|
4
|
+
const Create_1 = require("./Create");
|
|
5
|
+
const OutdatedPullRequestStrategy_1 = require("./OutdatedPullRequestStrategy");
|
|
6
|
+
const Recreate_1 = require("./Recreate");
|
|
7
|
+
const Skip_1 = require("./Skip");
|
|
8
|
+
// TODO: Add test
|
|
9
|
+
class OutdatedPackageProcessorCreator {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
create({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, pullRequestFinder, pullRequestsCloser, packageUpdater }) {
|
|
14
|
+
switch (this.options.outdatedPrStrategy) {
|
|
15
|
+
case OutdatedPullRequestStrategy_1.OutdatedPullRequestStrategy.Create:
|
|
16
|
+
return new Create_1.Create({
|
|
17
|
+
git,
|
|
18
|
+
packageManager,
|
|
19
|
+
pullRequestCreator,
|
|
20
|
+
branchFinder,
|
|
21
|
+
commitMessageCreator,
|
|
22
|
+
packageUpdater
|
|
23
|
+
});
|
|
24
|
+
case OutdatedPullRequestStrategy_1.OutdatedPullRequestStrategy.Recreate:
|
|
25
|
+
return new Recreate_1.Recreate({
|
|
26
|
+
git,
|
|
27
|
+
packageManager,
|
|
28
|
+
pullRequestCreator,
|
|
29
|
+
branchFinder,
|
|
30
|
+
commitMessageCreator,
|
|
31
|
+
pullRequestFinder,
|
|
32
|
+
pullRequestsCloser,
|
|
33
|
+
packageUpdater
|
|
34
|
+
});
|
|
35
|
+
case OutdatedPullRequestStrategy_1.OutdatedPullRequestStrategy.Skip:
|
|
36
|
+
return new Skip_1.Skip({
|
|
37
|
+
git,
|
|
38
|
+
packageManager,
|
|
39
|
+
pullRequestCreator,
|
|
40
|
+
branchFinder,
|
|
41
|
+
commitMessageCreator,
|
|
42
|
+
pullRequestFinder,
|
|
43
|
+
packageUpdater
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.OutdatedPackageProcessorCreator = OutdatedPackageProcessorCreator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOutdatedPullRequestStrategy = exports.OutdatedPullRequestStrategy = void 0;
|
|
4
|
+
exports.OutdatedPullRequestStrategy = {
|
|
5
|
+
Create: 'create',
|
|
6
|
+
Recreate: 'recreate',
|
|
7
|
+
Skip: 'skip'
|
|
8
|
+
};
|
|
9
|
+
const outdatedPullRequestStrategies = Object.values(exports.OutdatedPullRequestStrategy);
|
|
10
|
+
const isOutdatedPullRequestStrategy = (value) => outdatedPullRequestStrategies.includes(value);
|
|
11
|
+
exports.isOutdatedPullRequestStrategy = isOutdatedPullRequestStrategy;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Recreate = void 0;
|
|
4
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
5
|
+
const git_1 = require("../git");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
// TODO: Add test
|
|
8
|
+
class Recreate {
|
|
9
|
+
constructor({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, packageUpdater, pullRequestFinder, pullRequestsCloser }) {
|
|
10
|
+
this.git = git;
|
|
11
|
+
this.packageManager = packageManager;
|
|
12
|
+
this.pullRequestCreator = pullRequestCreator;
|
|
13
|
+
this.branchFinder = branchFinder;
|
|
14
|
+
this.commitMessageCreator = commitMessageCreator;
|
|
15
|
+
this.packageUpdater = packageUpdater;
|
|
16
|
+
this.pullRequestFinder = pullRequestFinder;
|
|
17
|
+
this.pullRequestsCloser = pullRequestsCloser;
|
|
18
|
+
}
|
|
19
|
+
async process(outdatedPackage) {
|
|
20
|
+
const branchName = (0, git_1.createBranchName)(outdatedPackage);
|
|
21
|
+
logger_1.logger.trace(`branchName=${branchName}`);
|
|
22
|
+
if (this.branchFinder.findByName(branchName) !== undefined) {
|
|
23
|
+
logger_1.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
|
|
24
|
+
return (0, Either_1.right)({
|
|
25
|
+
outdatedPackage,
|
|
26
|
+
skipped: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const transaction = new git_1.GitTransaction({
|
|
30
|
+
git: this.git,
|
|
31
|
+
branchName,
|
|
32
|
+
files: [this.packageManager.packageFile, this.packageManager.lockFile]
|
|
33
|
+
});
|
|
34
|
+
return await transaction.run(async ({ git, branchName }) => {
|
|
35
|
+
try {
|
|
36
|
+
await this.packageUpdater.update(outdatedPackage);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger_1.logger.error(error);
|
|
40
|
+
return (0, Either_1.left)({
|
|
41
|
+
outdatedPackage,
|
|
42
|
+
error
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
logger_1.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
46
|
+
await git.add(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
47
|
+
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
48
|
+
logger_1.logger.trace(`message=${message}`);
|
|
49
|
+
await git.commit(message);
|
|
50
|
+
await git.push(branchName);
|
|
51
|
+
const pullRequest = await this.pullRequestCreator.create({
|
|
52
|
+
outdatedPackage,
|
|
53
|
+
branchName
|
|
54
|
+
});
|
|
55
|
+
logger_1.logger.trace(`pullRequest=${JSON.stringify(pullRequest)}`);
|
|
56
|
+
logger_1.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
|
|
57
|
+
const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
|
|
58
|
+
logger_1.logger.trace(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
59
|
+
await this.pullRequestsCloser.close(pullRequests);
|
|
60
|
+
return (0, Either_1.right)({
|
|
61
|
+
outdatedPackage,
|
|
62
|
+
created: true
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Recreate = Recreate;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Skip = void 0;
|
|
4
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
5
|
+
const git_1 = require("../git");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
// TODO: Add test
|
|
8
|
+
class Skip {
|
|
9
|
+
constructor({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, packageUpdater, pullRequestFinder }) {
|
|
10
|
+
this.git = git;
|
|
11
|
+
this.packageManager = packageManager;
|
|
12
|
+
this.pullRequestCreator = pullRequestCreator;
|
|
13
|
+
this.branchFinder = branchFinder;
|
|
14
|
+
this.commitMessageCreator = commitMessageCreator;
|
|
15
|
+
this.packageUpdater = packageUpdater;
|
|
16
|
+
this.pullRequestFinder = pullRequestFinder;
|
|
17
|
+
}
|
|
18
|
+
async process(outdatedPackage) {
|
|
19
|
+
const branchName = (0, git_1.createBranchName)(outdatedPackage);
|
|
20
|
+
logger_1.logger.trace(`branchName=${branchName}`);
|
|
21
|
+
if (this.branchFinder.findByName(branchName) !== undefined) {
|
|
22
|
+
logger_1.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
|
|
23
|
+
return (0, Either_1.right)({
|
|
24
|
+
outdatedPackage,
|
|
25
|
+
skipped: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
|
|
29
|
+
logger_1.logger.trace(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
30
|
+
if (pullRequests.length > 0) {
|
|
31
|
+
logger_1.logger.info(`Skip ${outdatedPackage.name} because outdated pull requests exist.`);
|
|
32
|
+
return (0, Either_1.right)({
|
|
33
|
+
outdatedPackage,
|
|
34
|
+
skipped: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const transaction = new git_1.GitTransaction({
|
|
38
|
+
git: this.git,
|
|
39
|
+
branchName,
|
|
40
|
+
files: [this.packageManager.packageFile, this.packageManager.lockFile]
|
|
41
|
+
});
|
|
42
|
+
return await transaction.run(async ({ git, branchName }) => {
|
|
43
|
+
try {
|
|
44
|
+
await this.packageUpdater.update(outdatedPackage);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger_1.logger.error(error);
|
|
48
|
+
return (0, Either_1.left)({
|
|
49
|
+
outdatedPackage,
|
|
50
|
+
error
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
logger_1.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
54
|
+
await git.add(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
55
|
+
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
56
|
+
logger_1.logger.trace(`message=${message}`);
|
|
57
|
+
await git.commit(message);
|
|
58
|
+
await git.push(branchName);
|
|
59
|
+
const pullRequest = await this.pullRequestCreator.create({
|
|
60
|
+
outdatedPackage,
|
|
61
|
+
branchName
|
|
62
|
+
});
|
|
63
|
+
logger_1.logger.trace(`pullRequest=${JSON.stringify(pullRequest)}`);
|
|
64
|
+
logger_1.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
|
|
65
|
+
return (0, Either_1.right)({
|
|
66
|
+
outdatedPackage,
|
|
67
|
+
created: true
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Skip = Skip;
|
package/dist/src/core/index.js
CHANGED
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./FailedResult"), exports);
|
|
18
18
|
__exportStar(require("./OutdatedPackage"), exports);
|
|
19
19
|
__exportStar(require("./OutdatedPackageProcessor"), exports);
|
|
20
|
+
__exportStar(require("./OutdatedPackageProcessorCreator"), exports);
|
|
20
21
|
__exportStar(require("./OutdatedPackagesProcessor"), exports);
|
|
22
|
+
__exportStar(require("./OutdatedPullRequestStrategy"), exports);
|
|
21
23
|
__exportStar(require("./PackageUpdater"), exports);
|
|
22
24
|
__exportStar(require("./SucceededResult"), exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitTransaction = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
|
+
// TODO: Add test
|
|
6
|
+
class GitTransaction {
|
|
7
|
+
constructor({ git, branchName, files }) {
|
|
8
|
+
this.git = git;
|
|
9
|
+
this.branchName = branchName;
|
|
10
|
+
this.files = files;
|
|
11
|
+
}
|
|
12
|
+
async run(operation) {
|
|
13
|
+
await this.git.createBranch(this.branchName);
|
|
14
|
+
logger_1.logger.info(`${this.branchName} branch has created.`);
|
|
15
|
+
try {
|
|
16
|
+
return await operation({
|
|
17
|
+
git: this.git,
|
|
18
|
+
branchName: this.branchName,
|
|
19
|
+
files: this.files
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
await this.rollback();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async rollback() {
|
|
27
|
+
await this.git.restore(...this.files);
|
|
28
|
+
await this.git.switch('-');
|
|
29
|
+
await this.git.removeBranch(this.branchName);
|
|
30
|
+
logger_1.logger.info(`${this.branchName} branch has removed.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GitTransaction = GitTransaction;
|
package/dist/src/git/index.js
CHANGED
package/dist/src/main.js
CHANGED
|
@@ -102,7 +102,8 @@ const main = async (options) => {
|
|
|
102
102
|
packageManager,
|
|
103
103
|
ncu
|
|
104
104
|
});
|
|
105
|
-
const
|
|
105
|
+
const outdatedPackageProcessorCreator = new core_1.OutdatedPackageProcessorCreator(options);
|
|
106
|
+
const outdatedPackageProcessor = outdatedPackageProcessorCreator.create({
|
|
106
107
|
git,
|
|
107
108
|
packageManager,
|
|
108
109
|
pullRequestCreator,
|
|
@@ -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,6 +20,11 @@ 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
|
}),
|
|
@@ -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");
|
|
@@ -78,6 +79,18 @@ exports.cliOptions = [
|
|
|
78
79
|
],
|
|
79
80
|
default: logger_1.LogLevel.Info
|
|
80
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
|
+
},
|
|
81
94
|
{
|
|
82
95
|
name: 'package-manager',
|
|
83
96
|
description: 'Package manager of your project',
|
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",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@types/parse-github-url": "1.0.0",
|
|
42
42
|
"@types/semver": "7.3.9",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
44
|
-
"eslint": "8.
|
|
44
|
+
"eslint": "8.13.0",
|
|
45
45
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
46
46
|
"eslint-plugin-import": "2.26.0",
|
|
47
|
-
"eslint-plugin-jest": "26.1.
|
|
47
|
+
"eslint-plugin-jest": "26.1.4",
|
|
48
48
|
"eslint-plugin-node": "11.1.0",
|
|
49
49
|
"eslint-plugin-promise": "6.0.0",
|
|
50
|
-
"eslint-plugin-tsdoc": "0.2.
|
|
50
|
+
"eslint-plugin-tsdoc": "0.2.16",
|
|
51
51
|
"husky": "7.0.4",
|
|
52
52
|
"jest": "27.4.7",
|
|
53
53
|
"lint-staged": "12.3.7",
|