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 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
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.app = void 0;
4
4
  exports.app = {
5
5
  name: 'npm-update-package',
6
- version: '0.11.1',
6
+ version: '0.14.0',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
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', 'switch', '-c', branchName);
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', 'restore', '--worktree', '--staged', ...files);
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', 'switch', branchName);
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(options)}`);
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 isNcuOutdatedPackages_1 = require("./isNcuOutdatedPackages");
6
- const NcuOutdatedPackagesConverter_1 = require("./NcuOutdatedPackagesConverter");
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, isNcuOutdatedPackages_1.isNcuOutdatedPackages)(result)) {
34
- throw new Error('result is not NcuOutdatedPackages');
33
+ if (!(0, NcuResult_1.isNcuResult)(result)) {
34
+ throw new Error('result is not NcuResult');
35
35
  }
36
- const ncuOutdatedPackagesConverter = new NcuOutdatedPackagesConverter_1.NcuOutdatedPackagesConverter(currentDependencies);
37
- return ncuOutdatedPackagesConverter.toOutdatedPackages(result);
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.NcuOutdatedPackagesConverter = void 0;
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 NcuOutdatedPackagesConverter {
7
+ class NcuResultConverter {
8
8
  constructor(currentDependencies) {
9
9
  this.currentDependencies = currentDependencies;
10
10
  }
11
- toOutdatedPackages(outdatedPackages) {
12
- return Object.entries(outdatedPackages)
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.NcuOutdatedPackagesConverter = NcuOutdatedPackagesConverter;
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.packageFiles = [
9
- 'package.json',
10
- 'package-lock.json'
11
- ];
8
+ this.packageFile = 'package.json';
9
+ this.lockFile = 'package-lock.json';
12
10
  }
13
11
  /**
14
- * @see https://docs.npmjs.com/cli/v8/commands/npm-install
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.packageFiles = [
9
- 'package.json',
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(...this.packageManager.packageFiles);
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(...this.packageManager.packageFiles);
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.11.1",
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.2",
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.5.0",
40
- "eslint": "8.3.0",
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.0.7",
52
+ "ts-jest": "27.1.1",
53
53
  "ts-node": "10.4.0",
54
- "typescript": "4.4.4",
54
+ "typescript": "4.5.3",
55
55
  "utility-types": "3.10.0"
56
56
  },
57
57
  "repository": {
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;