npm-update-package 0.9.1 → 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 +0 -14
- package/dist/app.js +1 -1
- package/dist/git/index.js +1 -3
- package/dist/main.js +0 -8
- package/dist/options/Options.js +9 -15
- package/dist/options/initOptions.js +0 -2
- package/dist/processors/OutdatedPackageProcessor.js +2 -3
- package/package.json +4 -3
- package/dist/git/Committer.js +0 -31
package/README.md
CHANGED
|
@@ -66,20 +66,6 @@ Commit message template
|
|
|
66
66
|
- required: false
|
|
67
67
|
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
|
68
68
|
|
|
69
|
-
### `--git-user-email`
|
|
70
|
-
|
|
71
|
-
User email of commit
|
|
72
|
-
|
|
73
|
-
- value: string
|
|
74
|
-
- required: false
|
|
75
|
-
|
|
76
|
-
### `--git-user-name`
|
|
77
|
-
|
|
78
|
-
User name of commit
|
|
79
|
-
|
|
80
|
-
- value: string
|
|
81
|
-
- required: false
|
|
82
|
-
|
|
83
69
|
### `--github-token`
|
|
84
70
|
|
|
85
71
|
GitHub token
|
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; } });
|
package/dist/main.js
CHANGED
|
@@ -43,13 +43,6 @@ 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
|
|
@@ -67,7 +60,6 @@ const main = async ({ options, logger }) => {
|
|
|
67
60
|
const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
|
|
68
61
|
const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
|
|
69
62
|
const outdatedPackageProcessor = new processors_1.OutdatedPackageProcessor({
|
|
70
|
-
committer,
|
|
71
63
|
git,
|
|
72
64
|
ncu,
|
|
73
65
|
packageManager,
|
package/dist/options/Options.js
CHANGED
|
@@ -4,19 +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
|
-
}),
|
|
17
|
-
(0, io_ts_1.partial)({
|
|
18
|
-
gitUserEmail: io_ts_1.string,
|
|
19
|
-
gitUserName: io_ts_1.string
|
|
20
|
-
})
|
|
21
|
-
]);
|
|
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
|
+
});
|
|
22
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([
|
|
@@ -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,13 +1,14 @@
|
|
|
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
|
},
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"eslint-plugin-import": "2.25.3",
|
|
42
43
|
"eslint-plugin-jest": "25.3.0",
|
|
43
44
|
"eslint-plugin-node": "11.1.0",
|
|
44
|
-
"eslint-plugin-promise": "5.
|
|
45
|
+
"eslint-plugin-promise": "5.2.0",
|
|
45
46
|
"eslint-plugin-tsdoc": "0.2.14",
|
|
46
47
|
"husky": "7.0.4",
|
|
47
48
|
"jest": "27.0.6",
|
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;
|