npm-update-package 0.11.1 → 0.14.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 +1 -5
- package/dist/app.js +1 -1
- package/dist/git/Git.js +3 -3
- package/dist/main.js +4 -1
- package/dist/ncu/Ncu.js +6 -6
- package/dist/ncu/NcuResult.js +6 -0
- package/dist/ncu/{NcuOutdatedPackagesConverter.js → NcuResultConverter.js} +5 -5
- package/dist/package-manager/Npm.js +4 -6
- package/dist/package-manager/Yarn.js +2 -4
- package/dist/processors/OutdatedPackageProcessor.js +2 -2
- package/dist/terminal/Terminal.js +0 -15
- package/package.json +6 -6
- package/dist/ncu/NcuOutdatedPackages.js +0 -2
- package/dist/ncu/isNcuOutdatedPackages.js +0 -8
- package/dist/terminal/isExecaReturnValue.js +0 -24
package/README.md
CHANGED
|
@@ -9,10 +9,6 @@ CLI tool for creating pull request to update npm packages
|
|
|
9
9
|
|
|
10
10
|
This package is currently under development, so the major version is 0 yet.
|
|
11
11
|
|
|
12
|
-
## Requirements
|
|
13
|
-
|
|
14
|
-
- Git v2.23.0 or higher
|
|
15
|
-
|
|
16
12
|
## Usage
|
|
17
13
|
|
|
18
14
|
```sh
|
|
@@ -21,7 +17,7 @@ npx npm-update-package --github-token $GITHUB_TOKEN
|
|
|
21
17
|
|
|
22
18
|
## Examples
|
|
23
19
|
|
|
24
|
-
Example of running npm-update-package on GitHub Actions at 0:00 every day:
|
|
20
|
+
Example of running npm-update-package on GitHub Actions at 0:00 (UTC) every day:
|
|
25
21
|
|
|
26
22
|
```yaml
|
|
27
23
|
name: npm-update-package
|
package/dist/app.js
CHANGED
package/dist/git/Git.js
CHANGED
|
@@ -14,7 +14,7 @@ class Git {
|
|
|
14
14
|
await this.terminal.run('git', 'commit', '--message', message);
|
|
15
15
|
}
|
|
16
16
|
async createBranch(branchName) {
|
|
17
|
-
await this.terminal.run('git', '
|
|
17
|
+
await this.terminal.run('git', 'checkout', '-b', branchName);
|
|
18
18
|
}
|
|
19
19
|
async getConfig(key) {
|
|
20
20
|
const { stdout } = await this.terminal.run('git', 'config', key);
|
|
@@ -39,13 +39,13 @@ class Git {
|
|
|
39
39
|
await this.terminal.run('git', 'branch', '-D', branchName);
|
|
40
40
|
}
|
|
41
41
|
async restore(...files) {
|
|
42
|
-
await this.terminal.run('git', '
|
|
42
|
+
await this.terminal.run('git', 'checkout', ...files);
|
|
43
43
|
}
|
|
44
44
|
async setConfig(key, value) {
|
|
45
45
|
await this.terminal.run('git', 'config', key, value);
|
|
46
46
|
}
|
|
47
47
|
async switch(branchName) {
|
|
48
|
-
await this.terminal.run('git', '
|
|
48
|
+
await this.terminal.run('git', 'checkout', branchName);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
exports.Git = Git;
|
package/dist/main.js
CHANGED
|
@@ -11,7 +11,10 @@ const processors_1 = require("./processors");
|
|
|
11
11
|
const terminal_1 = require("./terminal");
|
|
12
12
|
// TODO: add test
|
|
13
13
|
const main = async ({ options, logger }) => {
|
|
14
|
-
logger.debug(`options=${JSON.stringify(
|
|
14
|
+
logger.debug(`options=${JSON.stringify({
|
|
15
|
+
...options,
|
|
16
|
+
githubToken: options.githubToken !== '' ? '***' : ''
|
|
17
|
+
})}`);
|
|
15
18
|
const packageJsonParser = new package_json_1.PackageJsonParser(logger);
|
|
16
19
|
const packageJsonReader = new package_json_1.PackageJsonReader({
|
|
17
20
|
packageJsonParser,
|
package/dist/ncu/Ncu.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Ncu = void 0;
|
|
4
4
|
const npm_check_updates_1 = require("npm-check-updates");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const NcuResult_1 = require("./NcuResult");
|
|
6
|
+
const NcuResultConverter_1 = require("./NcuResultConverter");
|
|
7
7
|
// TODO: add test
|
|
8
8
|
class Ncu {
|
|
9
9
|
constructor(packageJsonReader) {
|
|
@@ -30,11 +30,11 @@ class Ncu {
|
|
|
30
30
|
...pkg.optionalDependencies
|
|
31
31
|
};
|
|
32
32
|
const result = await (0, npm_check_updates_1.run)(options);
|
|
33
|
-
if (!(0,
|
|
34
|
-
throw new Error('result is not
|
|
33
|
+
if (!(0, NcuResult_1.isNcuResult)(result)) {
|
|
34
|
+
throw new Error('result is not NcuResult');
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
return
|
|
36
|
+
const ncuResultConverter = new NcuResultConverter_1.NcuResultConverter(currentDependencies);
|
|
37
|
+
return ncuResultConverter.toOutdatedPackages(result);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.Ncu = Ncu;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNcuResult = exports.NcuResult = void 0;
|
|
4
|
+
const io_ts_1 = require("io-ts");
|
|
5
|
+
exports.NcuResult = (0, io_ts_1.record)(io_ts_1.string, io_ts_1.string);
|
|
6
|
+
exports.isNcuResult = exports.NcuResult.is;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NcuResultConverter = void 0;
|
|
4
4
|
const PackageVersion_1 = require("./PackageVersion");
|
|
5
5
|
const toUpdateType_1 = require("./toUpdateType");
|
|
6
6
|
// TODO: add test
|
|
7
|
-
class
|
|
7
|
+
class NcuResultConverter {
|
|
8
8
|
constructor(currentDependencies) {
|
|
9
9
|
this.currentDependencies = currentDependencies;
|
|
10
10
|
}
|
|
11
|
-
toOutdatedPackages(
|
|
12
|
-
return Object.entries(
|
|
11
|
+
toOutdatedPackages(result) {
|
|
12
|
+
return Object.entries(result)
|
|
13
13
|
.map(([name, newVersion]) => ({
|
|
14
14
|
name,
|
|
15
15
|
currentVersion: PackageVersion_1.PackageVersion.of(this.currentDependencies[name]),
|
|
@@ -23,4 +23,4 @@ class NcuOutdatedPackagesConverter {
|
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
exports.
|
|
26
|
+
exports.NcuResultConverter = NcuResultConverter;
|
|
@@ -5,14 +5,12 @@ exports.Npm = void 0;
|
|
|
5
5
|
class Npm {
|
|
6
6
|
constructor(terminal) {
|
|
7
7
|
this.terminal = terminal;
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
'package-lock.json'
|
|
11
|
-
];
|
|
8
|
+
this.packageFile = 'package.json';
|
|
9
|
+
this.lockFile = 'package-lock.json';
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
* @see https://docs.npmjs.com/cli/v8/commands/npm-install
|
|
13
|
+
*/
|
|
16
14
|
async install() {
|
|
17
15
|
await this.terminal.run('npm', 'install');
|
|
18
16
|
}
|
|
@@ -5,10 +5,8 @@ exports.Yarn = void 0;
|
|
|
5
5
|
class Yarn {
|
|
6
6
|
constructor(terminal) {
|
|
7
7
|
this.terminal = terminal;
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
'yarn.lock'
|
|
11
|
-
];
|
|
8
|
+
this.packageFile = 'package.json';
|
|
9
|
+
this.lockFile = 'yarn.lock';
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* @see https://classic.yarnpkg.com/en/docs/cli/install
|
|
@@ -45,7 +45,7 @@ class OutdatedPackageProcessor {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
this.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
48
|
-
await this.git.add(
|
|
48
|
+
await this.git.add(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
49
49
|
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
50
50
|
this.logger.debug(`message=${message}`);
|
|
51
51
|
await this.git.commit(message);
|
|
@@ -60,7 +60,7 @@ class OutdatedPackageProcessor {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
finally {
|
|
63
|
-
await this.git.restore(
|
|
63
|
+
await this.git.restore(this.packageManager.packageFile, this.packageManager.lockFile);
|
|
64
64
|
await this.git.switch('-');
|
|
65
65
|
await this.git.removeBranch(branchName);
|
|
66
66
|
this.logger.info(`${branchName} branch has removed.`);
|
|
@@ -5,25 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Terminal = void 0;
|
|
7
7
|
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
const isExecaReturnValue_1 = require("./isExecaReturnValue");
|
|
9
8
|
// TODO: add test
|
|
10
9
|
class Terminal {
|
|
11
10
|
async run(command, ...args) {
|
|
12
11
|
return await (0, execa_1.default)(command, args);
|
|
13
12
|
}
|
|
14
|
-
async runWithErrorHandling(command, ...args) {
|
|
15
|
-
try {
|
|
16
|
-
return await this.run(command, ...args);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
const value = e instanceof Error ? JSON.parse(JSON.stringify(e)) : e;
|
|
20
|
-
if ((0, isExecaReturnValue_1.isExecaReturnValue)(value)) {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
13
|
}
|
|
29
14
|
exports.Terminal = Terminal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"io-ts": "2.2.16",
|
|
25
25
|
"log4js": "6.3.0",
|
|
26
26
|
"mustache": "4.1.0",
|
|
27
|
-
"npm-check-updates": "12.0.
|
|
27
|
+
"npm-check-updates": "12.0.3",
|
|
28
28
|
"parse-github-url": "1.0.2",
|
|
29
29
|
"semver": "7.3.5"
|
|
30
30
|
},
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@types/node": "12.20.15",
|
|
37
37
|
"@types/parse-github-url": "1.0.0",
|
|
38
38
|
"@types/semver": "7.3.9",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
40
|
-
"eslint": "8.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "5.6.0",
|
|
40
|
+
"eslint": "8.4.1",
|
|
41
41
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
42
42
|
"eslint-plugin-import": "2.25.3",
|
|
43
43
|
"eslint-plugin-jest": "25.3.0",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"lint-staged": "12.1.2",
|
|
50
50
|
"npm-run-all": "4.1.5",
|
|
51
51
|
"rimraf": "3.0.2",
|
|
52
|
-
"ts-jest": "27.
|
|
52
|
+
"ts-jest": "27.1.1",
|
|
53
53
|
"ts-node": "10.4.0",
|
|
54
|
-
"typescript": "4.
|
|
54
|
+
"typescript": "4.5.3",
|
|
55
55
|
"utility-types": "3.10.0"
|
|
56
56
|
},
|
|
57
57
|
"repository": {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNcuOutdatedPackages = void 0;
|
|
4
|
-
// TODO: add test
|
|
5
|
-
const isNcuOutdatedPackages = (value) => {
|
|
6
|
-
return typeof value === 'object' && value !== null && Object.values(value).every(value => typeof value === 'string');
|
|
7
|
-
};
|
|
8
|
-
exports.isNcuOutdatedPackages = isNcuOutdatedPackages;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isExecaReturnValue = void 0;
|
|
4
|
-
const io_ts_1 = require("io-ts");
|
|
5
|
-
const ExecaReturnValueType = (0, io_ts_1.intersection)([
|
|
6
|
-
(0, io_ts_1.type)({
|
|
7
|
-
command: io_ts_1.string,
|
|
8
|
-
escapedCommand: io_ts_1.string,
|
|
9
|
-
exitCode: io_ts_1.number,
|
|
10
|
-
failed: io_ts_1.boolean,
|
|
11
|
-
timedOut: io_ts_1.boolean,
|
|
12
|
-
killed: io_ts_1.boolean,
|
|
13
|
-
isCanceled: io_ts_1.boolean
|
|
14
|
-
}),
|
|
15
|
-
(0, io_ts_1.partial)({
|
|
16
|
-
signal: io_ts_1.string,
|
|
17
|
-
signalDescription: io_ts_1.string
|
|
18
|
-
})
|
|
19
|
-
]);
|
|
20
|
-
// TODO: add test
|
|
21
|
-
const isExecaReturnValue = (value) => {
|
|
22
|
-
return ExecaReturnValueType.is(value);
|
|
23
|
-
};
|
|
24
|
-
exports.isExecaReturnValue = isExecaReturnValue;
|