npm-update-package 0.7.0 → 0.10.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 +86 -20
- package/dist/app.js +1 -1
- package/dist/git/index.js +1 -3
- package/dist/github/PullRequestBodyCreator.js +29 -0
- package/dist/github/PullRequestCreator.js +3 -3
- package/dist/github/RemoteBranchExistenceChecker.js +0 -1
- package/dist/github/index.js +3 -1
- package/dist/main.js +2 -8
- package/dist/options/Options.js +9 -14
- package/dist/options/initOptions.js +8 -2
- package/dist/processors/OutdatedPackageProcessor.js +2 -3
- package/package.json +14 -9
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -23
- package/.github/FUNDING.yml +0 -2
- package/.github/renovate.json +0 -15
- package/.github/workflows/eslint.yml +0 -14
- package/.github/workflows/test.yml +0 -19
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/dist/git/Committer.js +0 -31
- package/dist/github/createPullRequestBody.js +0 -19
- package/jest.config.ts +0 -11
- package/lint-staged.config.js +0 -4
- package/npm-update-package.code-workspace +0 -8
- package/src/app.ts +0 -5
- package/src/bin.ts +0 -20
- package/src/git/BranchNameCreator.test.ts +0 -17
- package/src/git/BranchNameCreator.ts +0 -19
- package/src/git/CommitMessageCreator.test.ts +0 -17
- package/src/git/CommitMessageCreator.ts +0 -19
- package/src/git/Committer.ts +0 -49
- package/src/git/Git.ts +0 -55
- package/src/git/GitRepository.test.ts +0 -61
- package/src/git/GitRepository.ts +0 -57
- package/src/git/index.ts +0 -5
- package/src/github/Branch.ts +0 -4
- package/src/github/GitHub.ts +0 -27
- package/src/github/PullRequest.ts +0 -3
- package/src/github/PullRequestCreator.ts +0 -61
- package/src/github/PullRequestTitleCreator.test.ts +0 -17
- package/src/github/PullRequestTitleCreator.ts +0 -19
- package/src/github/RemoteBranchExistenceChecker.ts +0 -15
- package/src/github/Repository.ts +0 -3
- package/src/github/createGitHub.ts +0 -18
- package/src/github/createOctokit.ts +0 -28
- package/src/github/createPullRequestBody.test.ts +0 -64
- package/src/github/createPullRequestBody.ts +0 -17
- package/src/github/index.ts +0 -8
- package/src/logger/LogLevel.ts +0 -8
- package/src/logger/Logger.ts +0 -1
- package/src/logger/createLogger.ts +0 -10
- package/src/logger/index.ts +0 -6
- package/src/main.ts +0 -125
- package/src/ncu/Ncu.ts +0 -43
- package/src/ncu/NcuOutdatedPackages.ts +0 -6
- package/src/ncu/NcuOutdatedPackagesConverter.ts +0 -25
- package/src/ncu/OutdatedPackage.ts +0 -9
- package/src/ncu/PackageVersion.test.ts +0 -25
- package/src/ncu/PackageVersion.ts +0 -40
- package/src/ncu/UpdateType.ts +0 -9
- package/src/ncu/index.ts +0 -7
- package/src/ncu/isNcuOutdatedPackages.ts +0 -6
- package/src/ncu/toUpdateType.test.ts +0 -21
- package/src/ncu/toUpdateType.ts +0 -18
- package/src/options/Options.ts +0 -29
- package/src/options/index.ts +0 -2
- package/src/options/initOptions.ts +0 -45
- package/src/package-json/Package.ts +0 -24
- package/src/package-json/PackageDependencies.ts +0 -10
- package/src/package-json/PackageJsonParser.ts +0 -19
- package/src/package-json/PackageJsonReader.ts +0 -27
- package/src/package-json/index.ts +0 -3
- package/src/package-manager/Npm.ts +0 -19
- package/src/package-manager/PackageManager.ts +0 -4
- package/src/package-manager/PackageManagerName.ts +0 -8
- package/src/package-manager/Yarn.ts +0 -19
- package/src/package-manager/createPackageManager.ts +0 -21
- package/src/package-manager/index.ts +0 -8
- package/src/processors/OutdatedPackageProcessor.ts +0 -109
- package/src/processors/OutdatedPackagesProcessor.ts +0 -32
- package/src/processors/Result.ts +0 -7
- package/src/processors/index.ts +0 -2
- package/src/terminal/Terminal.ts +0 -30
- package/src/terminal/index.ts +0 -1
- package/src/terminal/isExecaReturnValue.ts +0 -30
- package/tsconfig.base.json +0 -3
- package/tsconfig.build.json +0 -13
- package/tsconfig.json +0 -9
package/README.md
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
CLI tool for creating pull request to update npm packages
|
|
7
7
|
|
|
8
|
+
## Caution
|
|
9
|
+
|
|
10
|
+
This package is currently under development, so the major version is 0 yet.
|
|
11
|
+
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
10
14
|
If you are using npm:
|
|
@@ -33,36 +37,98 @@ npm-update-package --github-token $GITHUB_TOKEN
|
|
|
33
37
|
|
|
34
38
|
## Options
|
|
35
39
|
|
|
36
|
-
You can customize behavior via command-line options.
|
|
37
|
-
|
|
38
|
-
|Option|Description|Required|Value|Default|
|
|
39
|
-
|---|---|---|---|---|
|
|
40
|
-
|`--branch-name`|Branch name template|-|string|`npm-update-package/{{{packageName}}}/v{{newVersion}}`|
|
|
41
|
-
|`--commit-message`|Commit message template|-|string|`chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`|
|
|
42
|
-
|`--git-user-email`|User email of commit|-|string|-|
|
|
43
|
-
|`--git-user-name`|User name of commit|-|string|-|
|
|
44
|
-
|`--github-token`|GitHub token|✓|string|-|
|
|
45
|
-
|`--log-level`|Log level to show|-|`info`, `debug`|`info`|
|
|
46
|
-
|`--package-manager`|Package manager of your project|-|`npm`, `yarn`|`npm`|
|
|
47
|
-
|`--pull-request-title`|Pull request title template|-|string|`chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`|
|
|
40
|
+
You can customize behavior via command-line options.
|
|
41
|
+
Template strings such as `--branch-name` can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
|
|
48
42
|
|
|
49
|
-
###
|
|
43
|
+
### `--branch-name`
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
These variables are available:
|
|
45
|
+
Branch name template
|
|
53
46
|
|
|
54
|
-
-
|
|
55
|
-
|
|
47
|
+
- value: template string
|
|
48
|
+
- embeddable variables:
|
|
56
49
|
- `currentVersion`
|
|
57
50
|
- `newVersion`
|
|
58
|
-
- `updateType`
|
|
59
|
-
- `--commit-message`
|
|
60
51
|
- `packageName`
|
|
52
|
+
- `updateType`
|
|
53
|
+
- required: false
|
|
54
|
+
- default: `npm-update-package/{{{packageName}}}/v{{newVersion}}`
|
|
55
|
+
|
|
56
|
+
### `--commit-message`
|
|
57
|
+
|
|
58
|
+
Commit message template
|
|
59
|
+
|
|
60
|
+
- value: template string
|
|
61
|
+
- embeddable variables:
|
|
61
62
|
- `currentVersion`
|
|
62
63
|
- `newVersion`
|
|
64
|
+
- `packageName`
|
|
63
65
|
- `updateType`
|
|
64
|
-
-
|
|
66
|
+
- required: false
|
|
67
|
+
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
|
68
|
+
|
|
69
|
+
### `--github-token`
|
|
70
|
+
|
|
71
|
+
GitHub token
|
|
72
|
+
|
|
73
|
+
- value: string
|
|
74
|
+
- required: true
|
|
75
|
+
|
|
76
|
+
### `--log-level`
|
|
77
|
+
|
|
78
|
+
Log level to show
|
|
79
|
+
|
|
80
|
+
- value: string
|
|
81
|
+
- `info`
|
|
82
|
+
- `debug`
|
|
83
|
+
- required: false
|
|
84
|
+
- default: `info`
|
|
85
|
+
|
|
86
|
+
### `--package-manager`
|
|
87
|
+
|
|
88
|
+
Package manager of your project
|
|
89
|
+
|
|
90
|
+
- value: string
|
|
91
|
+
- `npm`
|
|
92
|
+
- `yarn`
|
|
93
|
+
- required: false
|
|
94
|
+
- default: `npm`
|
|
95
|
+
|
|
96
|
+
### `--pull-request-body`
|
|
97
|
+
|
|
98
|
+
Pull request body template
|
|
99
|
+
|
|
100
|
+
- value: template string
|
|
101
|
+
- embeddable variables:
|
|
102
|
+
- `appName`
|
|
103
|
+
- `appVersion`
|
|
104
|
+
- `appWeb`
|
|
105
|
+
- `currentVersion`
|
|
106
|
+
- `newVersion`
|
|
65
107
|
- `packageName`
|
|
108
|
+
- `updateType`
|
|
109
|
+
- required: false
|
|
110
|
+
- default:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
This PR updates these packages:
|
|
114
|
+
|
|
115
|
+
|package|type|current version|new version|
|
|
116
|
+
|---|---|---|---|
|
|
117
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### `--pull-request-title`
|
|
124
|
+
|
|
125
|
+
Pull request title template
|
|
126
|
+
|
|
127
|
+
- value: template string
|
|
128
|
+
- embeddable variables:
|
|
66
129
|
- `currentVersion`
|
|
67
130
|
- `newVersion`
|
|
131
|
+
- `packageName`
|
|
68
132
|
- `updateType`
|
|
133
|
+
- required: false
|
|
134
|
+
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
package/dist/app.js
CHANGED
package/dist/git/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Git = exports.
|
|
3
|
+
exports.Git = exports.CommitMessageCreator = exports.BranchNameCreator = void 0;
|
|
4
4
|
var BranchNameCreator_1 = require("./BranchNameCreator");
|
|
5
5
|
Object.defineProperty(exports, "BranchNameCreator", { enumerable: true, get: function () { return BranchNameCreator_1.BranchNameCreator; } });
|
|
6
6
|
var CommitMessageCreator_1 = require("./CommitMessageCreator");
|
|
7
7
|
Object.defineProperty(exports, "CommitMessageCreator", { enumerable: true, get: function () { return CommitMessageCreator_1.CommitMessageCreator; } });
|
|
8
|
-
var Committer_1 = require("./Committer");
|
|
9
|
-
Object.defineProperty(exports, "Committer", { enumerable: true, get: function () { return Committer_1.Committer; } });
|
|
10
8
|
var Git_1 = require("./Git");
|
|
11
9
|
Object.defineProperty(exports, "Git", { enumerable: true, get: function () { return Git_1.Git; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestBodyCreator = void 0;
|
|
4
|
+
const mustache_1 = require("mustache");
|
|
5
|
+
const app_1 = require("../app");
|
|
6
|
+
class PullRequestBodyCreator {
|
|
7
|
+
constructor(template) {
|
|
8
|
+
this.template = template;
|
|
9
|
+
}
|
|
10
|
+
create(outdatedPackage) {
|
|
11
|
+
const appName = app_1.app.name;
|
|
12
|
+
const appVersion = app_1.app.version;
|
|
13
|
+
const appWeb = app_1.app.web;
|
|
14
|
+
const currentVersion = outdatedPackage.currentVersion.version;
|
|
15
|
+
const newVersion = outdatedPackage.newVersion.version;
|
|
16
|
+
const packageName = outdatedPackage.name;
|
|
17
|
+
const updateType = outdatedPackage.type;
|
|
18
|
+
return (0, mustache_1.render)(this.template, {
|
|
19
|
+
appName,
|
|
20
|
+
appVersion,
|
|
21
|
+
appWeb,
|
|
22
|
+
currentVersion,
|
|
23
|
+
newVersion,
|
|
24
|
+
packageName,
|
|
25
|
+
updateType
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.PullRequestBodyCreator = PullRequestBodyCreator;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
|
-
const createPullRequestBody_1 = require("./createPullRequestBody");
|
|
5
4
|
// TODO: add test
|
|
6
5
|
class PullRequestCreator {
|
|
7
|
-
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger }) {
|
|
6
|
+
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger }) {
|
|
8
7
|
this.github = github;
|
|
9
8
|
this.gitRepo = gitRepo;
|
|
10
9
|
this.githubRepo = githubRepo;
|
|
11
10
|
this.pullRequestTitleCreator = pullRequestTitleCreator;
|
|
11
|
+
this.pullRequestBodyCreator = pullRequestBodyCreator;
|
|
12
12
|
this.logger = logger;
|
|
13
13
|
}
|
|
14
14
|
async create({ outdatedPackage, branchName }) {
|
|
15
15
|
const title = this.pullRequestTitleCreator.create(outdatedPackage);
|
|
16
16
|
this.logger.debug(`title=${title}`);
|
|
17
|
-
const body =
|
|
17
|
+
const body = this.pullRequestBodyCreator.create(outdatedPackage);
|
|
18
18
|
this.logger.debug(`body=${body}`);
|
|
19
19
|
const createdPullRequest = await this.github.createPullRequest({
|
|
20
20
|
owner: this.gitRepo.owner,
|
package/dist/github/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteBranchExistenceChecker = exports.PullRequestTitleCreator = exports.PullRequestCreator = exports.GitHub = exports.createGitHub = void 0;
|
|
3
|
+
exports.RemoteBranchExistenceChecker = exports.PullRequestTitleCreator = exports.PullRequestCreator = exports.PullRequestBodyCreator = exports.GitHub = exports.createGitHub = void 0;
|
|
4
4
|
var createGitHub_1 = require("./createGitHub");
|
|
5
5
|
Object.defineProperty(exports, "createGitHub", { enumerable: true, get: function () { return createGitHub_1.createGitHub; } });
|
|
6
6
|
var GitHub_1 = require("./GitHub");
|
|
7
7
|
Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () { return GitHub_1.GitHub; } });
|
|
8
|
+
var PullRequestBodyCreator_1 = require("./PullRequestBodyCreator");
|
|
9
|
+
Object.defineProperty(exports, "PullRequestBodyCreator", { enumerable: true, get: function () { return PullRequestBodyCreator_1.PullRequestBodyCreator; } });
|
|
8
10
|
var PullRequestCreator_1 = require("./PullRequestCreator");
|
|
9
11
|
Object.defineProperty(exports, "PullRequestCreator", { enumerable: true, get: function () { return PullRequestCreator_1.PullRequestCreator; } });
|
|
10
12
|
var PullRequestTitleCreator_1 = require("./PullRequestTitleCreator");
|
package/dist/main.js
CHANGED
|
@@ -43,29 +43,23 @@ const main = async ({ options, logger }) => {
|
|
|
43
43
|
});
|
|
44
44
|
logger.debug(`remoteBranches=${JSON.stringify(remoteBranches)}`);
|
|
45
45
|
const remoteBranchExistenceChecker = github_1.RemoteBranchExistenceChecker.of(remoteBranches);
|
|
46
|
-
const committer = new git_1.Committer({
|
|
47
|
-
git,
|
|
48
|
-
user: {
|
|
49
|
-
name: options.gitUserName,
|
|
50
|
-
email: options.gitUserEmail
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
46
|
const packageManager = (0, package_manager_1.createPackageManager)({
|
|
54
47
|
terminal,
|
|
55
48
|
packageManager: options.packageManager
|
|
56
49
|
});
|
|
57
50
|
const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.pullRequestTitle);
|
|
51
|
+
const pullRequestBodyCreator = new github_1.PullRequestBodyCreator(options.pullRequestBody);
|
|
58
52
|
const pullRequestCreator = new github_1.PullRequestCreator({
|
|
59
53
|
github,
|
|
60
54
|
gitRepo,
|
|
61
55
|
githubRepo,
|
|
62
56
|
pullRequestTitleCreator,
|
|
57
|
+
pullRequestBodyCreator,
|
|
63
58
|
logger
|
|
64
59
|
});
|
|
65
60
|
const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
|
|
66
61
|
const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
|
|
67
62
|
const outdatedPackageProcessor = new processors_1.OutdatedPackageProcessor({
|
|
68
|
-
committer,
|
|
69
63
|
git,
|
|
70
64
|
ncu,
|
|
71
65
|
packageManager,
|
package/dist/options/Options.js
CHANGED
|
@@ -4,18 +4,13 @@ exports.isOptions = void 0;
|
|
|
4
4
|
const io_ts_1 = require("io-ts");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const package_manager_1 = require("../package-manager");
|
|
7
|
-
const Options = (0, io_ts_1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(0, io_ts_1.partial)({
|
|
17
|
-
gitUserEmail: io_ts_1.string,
|
|
18
|
-
gitUserName: io_ts_1.string
|
|
19
|
-
})
|
|
20
|
-
]);
|
|
7
|
+
const Options = (0, io_ts_1.type)({
|
|
8
|
+
branchName: io_ts_1.string,
|
|
9
|
+
commitMessage: io_ts_1.string,
|
|
10
|
+
githubToken: io_ts_1.string,
|
|
11
|
+
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
|
|
12
|
+
packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm), (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)]),
|
|
13
|
+
pullRequestBody: io_ts_1.string,
|
|
14
|
+
pullRequestTitle: io_ts_1.string
|
|
15
|
+
});
|
|
21
16
|
exports.isOptions = Options.is;
|
|
@@ -12,8 +12,6 @@ const initOptions = () => {
|
|
|
12
12
|
.version(app_1.app.version)
|
|
13
13
|
.option('--branch-name <value>', 'Branch name template', 'npm-update-package/{{{packageName}}}/v{{newVersion}}')
|
|
14
14
|
.option('--commit-message <value>', 'Commit message template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}')
|
|
15
|
-
.option('--git-user-email <value>', 'User email of commit')
|
|
16
|
-
.option('--git-user-name <value>', 'User name of commit')
|
|
17
15
|
.requiredOption('--github-token <value>', 'GitHub token')
|
|
18
16
|
.addOption(new commander_1.Option('--log-level <value>', 'Log level to show')
|
|
19
17
|
.choices([
|
|
@@ -27,6 +25,14 @@ const initOptions = () => {
|
|
|
27
25
|
package_manager_1.PackageManagerName.Yarn
|
|
28
26
|
])
|
|
29
27
|
.default(package_manager_1.PackageManagerName.Npm))
|
|
28
|
+
.option('--pull-request-body <value>', 'Pull request body template', `This PR updates these packages:
|
|
29
|
+
|
|
30
|
+
|package|type|current version|new version|
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
|
|
30
36
|
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}');
|
|
31
37
|
commander_1.program.parse(process.argv);
|
|
32
38
|
const options = commander_1.program.opts();
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OutdatedPackageProcessor = void 0;
|
|
4
4
|
// TODO: add test
|
|
5
5
|
class OutdatedPackageProcessor {
|
|
6
|
-
constructor({
|
|
7
|
-
this.committer = committer;
|
|
6
|
+
constructor({ git, ncu, packageManager, pullRequestCreator, remoteBranchExistenceChecker, logger, branchNameCreator, commitMessageCreator }) {
|
|
8
7
|
this.git = git;
|
|
9
8
|
this.ncu = ncu;
|
|
10
9
|
this.packageManager = packageManager;
|
|
@@ -38,7 +37,7 @@ class OutdatedPackageProcessor {
|
|
|
38
37
|
await this.git.add(...this.packageManager.packageFiles);
|
|
39
38
|
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
40
39
|
this.logger.debug(`message=${message}`);
|
|
41
|
-
await this.
|
|
40
|
+
await this.git.commit(message);
|
|
42
41
|
await this.git.push(branchName);
|
|
43
42
|
await this.pullRequestCreator.create({
|
|
44
43
|
outdatedPackage,
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "CLI tool for creating pull request to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
7
7
|
"clean": "rimraf dist",
|
|
8
8
|
"lint": "eslint '**/*.{js,ts}'",
|
|
9
|
+
"prebuild": "npm run clean",
|
|
9
10
|
"prepare": "husky install",
|
|
10
|
-
"prepublish": "npm-run-all
|
|
11
|
+
"prepublish": "npm-run-all lint test build",
|
|
11
12
|
"start": "ts-node src/bin.ts",
|
|
12
13
|
"test": "jest --passWithNoTests"
|
|
13
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
14
18
|
"bin": "dist/bin.js",
|
|
15
19
|
"dependencies": {
|
|
16
20
|
"@octokit/rest": "18.12.0",
|
|
@@ -32,13 +36,13 @@
|
|
|
32
36
|
"@types/node": "12.20.15",
|
|
33
37
|
"@types/parse-github-url": "1.0.0",
|
|
34
38
|
"@types/semver": "7.3.9",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "5.5.0",
|
|
36
40
|
"eslint": "8.3.0",
|
|
37
41
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
38
42
|
"eslint-plugin-import": "2.25.3",
|
|
39
43
|
"eslint-plugin-jest": "25.3.0",
|
|
40
44
|
"eslint-plugin-node": "11.1.0",
|
|
41
|
-
"eslint-plugin-promise": "5.
|
|
45
|
+
"eslint-plugin-promise": "5.2.0",
|
|
42
46
|
"eslint-plugin-tsdoc": "0.2.14",
|
|
43
47
|
"husky": "7.0.4",
|
|
44
48
|
"jest": "27.0.6",
|
|
@@ -50,12 +54,13 @@
|
|
|
50
54
|
"typescript": "4.4.4",
|
|
51
55
|
"utility-types": "3.10.0"
|
|
52
56
|
},
|
|
53
|
-
"homepage": "https://github.com/npm-update-package/npm-update-package",
|
|
54
|
-
"bugs": {
|
|
55
|
-
"url": "https://github.com/npm-update-package/npm-update-package/issues"
|
|
56
|
-
},
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
59
59
|
"url": "https://github.com/npm-update-package/npm-update-package.git"
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/npm-update-package/npm-update-package/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/npm-update-package/npm-update-package",
|
|
65
|
+
"license": "MIT"
|
|
61
66
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
'standard-with-typescript',
|
|
4
|
-
'plugin:jest/recommended'
|
|
5
|
-
],
|
|
6
|
-
plugins: [
|
|
7
|
-
'eslint-plugin-tsdoc'
|
|
8
|
-
],
|
|
9
|
-
parserOptions: {
|
|
10
|
-
project: './tsconfig.json'
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
'import/order': ['error', {
|
|
14
|
-
alphabetize: {
|
|
15
|
-
order: 'asc',
|
|
16
|
-
caseInsensitive: true
|
|
17
|
-
}
|
|
18
|
-
}],
|
|
19
|
-
'no-console': 'error',
|
|
20
|
-
'sort-imports': 'off',
|
|
21
|
-
'tsdoc/syntax': 'warn'
|
|
22
|
-
}
|
|
23
|
-
}
|
package/.github/FUNDING.yml
DELETED
package/.github/renovate.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
name: eslint
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
branches: [ master ]
|
|
5
|
-
jobs:
|
|
6
|
-
eslint:
|
|
7
|
-
name: runner / eslint
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- uses: actions/checkout@v2
|
|
11
|
-
- name: eslint
|
|
12
|
-
uses: reviewdog/action-eslint@v1
|
|
13
|
-
with:
|
|
14
|
-
reporter: github-pr-check
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: test
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
branches: [ master ]
|
|
5
|
-
jobs:
|
|
6
|
-
test:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
strategy:
|
|
9
|
-
matrix:
|
|
10
|
-
node-version: [12.20.2]
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v2
|
|
13
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
14
|
-
uses: actions/setup-node@v2
|
|
15
|
-
with:
|
|
16
|
-
node-version: ${{ matrix.node-version }}
|
|
17
|
-
- run: npm ci
|
|
18
|
-
- run: npm run build --if-present
|
|
19
|
-
- run: npm test
|
package/.husky/pre-commit
DELETED
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
12.20.2
|
package/dist/git/Committer.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Committer = void 0;
|
|
4
|
-
// TODO: add test
|
|
5
|
-
class Committer {
|
|
6
|
-
constructor({ git, user }) {
|
|
7
|
-
this.git = git;
|
|
8
|
-
this.user = user;
|
|
9
|
-
}
|
|
10
|
-
async commit(message) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
let name;
|
|
13
|
-
if (((_a = this.user) === null || _a === void 0 ? void 0 : _a.name) !== undefined) {
|
|
14
|
-
name = await this.git.getConfig('user.name');
|
|
15
|
-
await this.git.setConfig('user.name', this.user.name);
|
|
16
|
-
}
|
|
17
|
-
let email;
|
|
18
|
-
if (((_b = this.user) === null || _b === void 0 ? void 0 : _b.email) !== undefined) {
|
|
19
|
-
email = await this.git.getConfig('user.email');
|
|
20
|
-
await this.git.setConfig('user.email', this.user.email);
|
|
21
|
-
}
|
|
22
|
-
await this.git.commit(message);
|
|
23
|
-
if (name !== undefined) {
|
|
24
|
-
await this.git.setConfig('user.name', name);
|
|
25
|
-
}
|
|
26
|
-
if (email !== undefined) {
|
|
27
|
-
await this.git.setConfig('user.email', email);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Committer = Committer;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPullRequestBody = void 0;
|
|
4
|
-
const app_1 = require("../app");
|
|
5
|
-
const createPullRequestBody = (outdatedPackage) => {
|
|
6
|
-
const packageName = outdatedPackage.name;
|
|
7
|
-
const currentVersion = outdatedPackage.currentVersion.version;
|
|
8
|
-
const newVersion = outdatedPackage.newVersion.version;
|
|
9
|
-
const updateType = outdatedPackage.type;
|
|
10
|
-
return `This PR updates these packages:
|
|
11
|
-
|
|
12
|
-
|package|type|current version|new version|
|
|
13
|
-
|---|---|---|---|
|
|
14
|
-
|[${packageName}](https://www.npmjs.com/package/${packageName})|${updateType}|\`${currentVersion}\`|\`${newVersion}\`|
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
This PR has been generated by [${app_1.app.name}](${app_1.app.web})`;
|
|
18
|
-
};
|
|
19
|
-
exports.createPullRequestBody = createPullRequestBody;
|
package/jest.config.ts
DELETED
package/lint-staged.config.js
DELETED
package/src/app.ts
DELETED
package/src/bin.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { app } from './app'
|
|
4
|
-
import { createLogger } from './logger'
|
|
5
|
-
import { main } from './main'
|
|
6
|
-
import { initOptions } from './options'
|
|
7
|
-
|
|
8
|
-
const options = initOptions()
|
|
9
|
-
const logger = createLogger(options.logLevel)
|
|
10
|
-
logger.info(`Start ${app.name} v${app.version}`)
|
|
11
|
-
|
|
12
|
-
main({
|
|
13
|
-
options,
|
|
14
|
-
logger
|
|
15
|
-
})
|
|
16
|
-
.then(() => logger.info(`End ${app.name} v${app.version}`))
|
|
17
|
-
.catch((e: unknown) => {
|
|
18
|
-
// TODO: improve error handling
|
|
19
|
-
logger.fatal('Unexpected error has occurred.', e)
|
|
20
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageVersion } from '../ncu'
|
|
2
|
-
import { BranchNameCreator } from './BranchNameCreator'
|
|
3
|
-
|
|
4
|
-
describe('BranchNameCreator', () => {
|
|
5
|
-
describe('create', () => {
|
|
6
|
-
it('returns branch name', () => {
|
|
7
|
-
const branchNameCreator = new BranchNameCreator('npm-update-package/{{{packageName}}}/{{updateType}}/{{currentVersion}}/{{newVersion}}')
|
|
8
|
-
const actual = branchNameCreator.create({
|
|
9
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
10
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
11
|
-
newVersion: PackageVersion.of('1.2.3'),
|
|
12
|
-
type: 'major'
|
|
13
|
-
})
|
|
14
|
-
expect(actual).toBe('npm-update-package/@typescript-eslint/eslint-plugin/major/1.0.0/1.2.3')
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { render } from 'mustache'
|
|
2
|
-
import type { OutdatedPackage } from '../ncu'
|
|
3
|
-
|
|
4
|
-
export class BranchNameCreator {
|
|
5
|
-
constructor (private readonly template: string) {}
|
|
6
|
-
|
|
7
|
-
create (outdatedPackage: OutdatedPackage): string {
|
|
8
|
-
const packageName = outdatedPackage.name
|
|
9
|
-
const currentVersion = outdatedPackage.currentVersion.version
|
|
10
|
-
const newVersion = outdatedPackage.newVersion.version
|
|
11
|
-
const updateType = outdatedPackage.type
|
|
12
|
-
return render(this.template, {
|
|
13
|
-
packageName,
|
|
14
|
-
currentVersion,
|
|
15
|
-
newVersion,
|
|
16
|
-
updateType
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageVersion } from '../ncu'
|
|
2
|
-
import { CommitMessageCreator } from './CommitMessageCreator'
|
|
3
|
-
|
|
4
|
-
describe('CommitMessageCreator', () => {
|
|
5
|
-
describe('create', () => {
|
|
6
|
-
it('returns commit message', () => {
|
|
7
|
-
const commitMessageCreator = new CommitMessageCreator('chore(deps): {{updateType}} update {{{packageName}}} from {{currentVersion}} to v{{newVersion}}')
|
|
8
|
-
const actual = commitMessageCreator.create({
|
|
9
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
10
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
11
|
-
newVersion: PackageVersion.of('2.0.0'),
|
|
12
|
-
type: 'major'
|
|
13
|
-
})
|
|
14
|
-
expect(actual).toBe('chore(deps): major update @typescript-eslint/eslint-plugin from 1.0.0 to v2.0.0')
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
})
|