npm-update-package 0.8.0 → 0.11.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.
Files changed (90) hide show
  1. package/README.md +13 -18
  2. package/dist/app.js +1 -1
  3. package/dist/bin.js +6 -4
  4. package/dist/git/Git.js +7 -4
  5. package/dist/git/index.js +1 -3
  6. package/dist/github/RemoteBranchExistenceChecker.js +0 -1
  7. package/dist/logger/LogLevel.js +3 -2
  8. package/dist/main.js +14 -11
  9. package/dist/options/Options.js +9 -15
  10. package/dist/options/initOptions.js +1 -2
  11. package/dist/processors/{Result.js → FailedResult.js} +0 -0
  12. package/dist/processors/OutdatedPackageProcessor.js +39 -25
  13. package/dist/processors/SucceededResult.js +2 -0
  14. package/package.json +14 -9
  15. package/.eslintignore +0 -3
  16. package/.eslintrc.js +0 -23
  17. package/.github/FUNDING.yml +0 -2
  18. package/.github/renovate.json +0 -15
  19. package/.github/workflows/eslint.yml +0 -14
  20. package/.github/workflows/test.yml +0 -19
  21. package/.husky/pre-commit +0 -4
  22. package/.nvmrc +0 -1
  23. package/dist/git/Committer.js +0 -31
  24. package/jest.config.ts +0 -11
  25. package/lint-staged.config.js +0 -4
  26. package/npm-update-package.code-workspace +0 -8
  27. package/src/app.ts +0 -5
  28. package/src/bin.ts +0 -20
  29. package/src/git/BranchNameCreator.test.ts +0 -17
  30. package/src/git/BranchNameCreator.ts +0 -19
  31. package/src/git/CommitMessageCreator.test.ts +0 -17
  32. package/src/git/CommitMessageCreator.ts +0 -19
  33. package/src/git/Committer.ts +0 -49
  34. package/src/git/Git.ts +0 -55
  35. package/src/git/GitRepository.test.ts +0 -61
  36. package/src/git/GitRepository.ts +0 -57
  37. package/src/git/index.ts +0 -5
  38. package/src/github/Branch.ts +0 -4
  39. package/src/github/GitHub.ts +0 -27
  40. package/src/github/PullRequest.ts +0 -3
  41. package/src/github/PullRequestBodyCreator.test.ts +0 -32
  42. package/src/github/PullRequestBodyCreator.ts +0 -26
  43. package/src/github/PullRequestCreator.ts +0 -65
  44. package/src/github/PullRequestTitleCreator.test.ts +0 -17
  45. package/src/github/PullRequestTitleCreator.ts +0 -19
  46. package/src/github/RemoteBranchExistenceChecker.ts +0 -15
  47. package/src/github/Repository.ts +0 -3
  48. package/src/github/createGitHub.ts +0 -18
  49. package/src/github/createOctokit.ts +0 -28
  50. package/src/github/index.ts +0 -9
  51. package/src/logger/LogLevel.ts +0 -8
  52. package/src/logger/Logger.ts +0 -1
  53. package/src/logger/createLogger.ts +0 -10
  54. package/src/logger/index.ts +0 -6
  55. package/src/main.ts +0 -128
  56. package/src/ncu/Ncu.ts +0 -43
  57. package/src/ncu/NcuOutdatedPackages.ts +0 -6
  58. package/src/ncu/NcuOutdatedPackagesConverter.ts +0 -25
  59. package/src/ncu/OutdatedPackage.ts +0 -9
  60. package/src/ncu/PackageVersion.test.ts +0 -25
  61. package/src/ncu/PackageVersion.ts +0 -40
  62. package/src/ncu/UpdateType.ts +0 -9
  63. package/src/ncu/index.ts +0 -7
  64. package/src/ncu/isNcuOutdatedPackages.ts +0 -6
  65. package/src/ncu/toUpdateType.test.ts +0 -21
  66. package/src/ncu/toUpdateType.ts +0 -18
  67. package/src/options/Options.ts +0 -30
  68. package/src/options/index.ts +0 -2
  69. package/src/options/initOptions.ts +0 -53
  70. package/src/package-json/Package.ts +0 -24
  71. package/src/package-json/PackageDependencies.ts +0 -10
  72. package/src/package-json/PackageJsonParser.ts +0 -19
  73. package/src/package-json/PackageJsonReader.ts +0 -27
  74. package/src/package-json/index.ts +0 -3
  75. package/src/package-manager/Npm.ts +0 -19
  76. package/src/package-manager/PackageManager.ts +0 -4
  77. package/src/package-manager/PackageManagerName.ts +0 -8
  78. package/src/package-manager/Yarn.ts +0 -19
  79. package/src/package-manager/createPackageManager.ts +0 -21
  80. package/src/package-manager/index.ts +0 -8
  81. package/src/processors/OutdatedPackageProcessor.ts +0 -109
  82. package/src/processors/OutdatedPackagesProcessor.ts +0 -32
  83. package/src/processors/Result.ts +0 -7
  84. package/src/processors/index.ts +0 -2
  85. package/src/terminal/Terminal.ts +0 -30
  86. package/src/terminal/index.ts +0 -1
  87. package/src/terminal/isExecaReturnValue.ts +0 -30
  88. package/tsconfig.base.json +0 -3
  89. package/tsconfig.build.json +0 -13
  90. package/tsconfig.json +0 -9
package/README.md CHANGED
@@ -5,6 +5,14 @@
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
+
12
+ ## Requirements
13
+
14
+ - Git v2.23.0 or higher
15
+
8
16
  ## Installation
9
17
 
10
18
  If you are using npm:
@@ -41,7 +49,7 @@ Template strings such as `--branch-name` can embed variables like `{{packageName
41
49
  Branch name template
42
50
 
43
51
  - value: template string
44
- - embeddable variables:
52
+ - variables:
45
53
  - `currentVersion`
46
54
  - `newVersion`
47
55
  - `packageName`
@@ -54,7 +62,7 @@ Branch name template
54
62
  Commit message template
55
63
 
56
64
  - value: template string
57
- - embeddable variables:
65
+ - variables:
58
66
  - `currentVersion`
59
67
  - `newVersion`
60
68
  - `packageName`
@@ -62,20 +70,6 @@ Commit message template
62
70
  - required: false
63
71
  - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
64
72
 
65
- ### `--git-user-email`
66
-
67
- User email of commit
68
-
69
- - value: string
70
- - required: false
71
-
72
- ### `--git-user-name`
73
-
74
- User name of commit
75
-
76
- - value: string
77
- - required: false
78
-
79
73
  ### `--github-token`
80
74
 
81
75
  GitHub token
@@ -88,6 +82,7 @@ GitHub token
88
82
  Log level to show
89
83
 
90
84
  - value: string
85
+ - `error`
91
86
  - `info`
92
87
  - `debug`
93
88
  - required: false
@@ -108,7 +103,7 @@ Package manager of your project
108
103
  Pull request body template
109
104
 
110
105
  - value: template string
111
- - embeddable variables:
106
+ - variables:
112
107
  - `appName`
113
108
  - `appVersion`
114
109
  - `appWeb`
@@ -135,7 +130,7 @@ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
135
130
  Pull request title template
136
131
 
137
132
  - value: template string
138
- - embeddable variables:
133
+ - variables:
139
134
  - `currentVersion`
140
135
  - `newVersion`
141
136
  - `packageName`
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.8.0',
6
+ version: '0.11.0',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
package/dist/bin.js CHANGED
@@ -12,8 +12,10 @@ logger.info(`Start ${app_1.app.name} v${app_1.app.version}`);
12
12
  options,
13
13
  logger
14
14
  })
15
- .then(() => logger.info(`End ${app_1.app.name} v${app_1.app.version}`))
16
- .catch((e) => {
17
- // TODO: improve error handling
18
- logger.fatal('Unexpected error has occurred.', e);
15
+ .then(() => {
16
+ logger.info(`End ${app_1.app.name} v${app_1.app.version}`);
17
+ })
18
+ .catch((error) => {
19
+ logger.fatal(error);
20
+ throw error;
19
21
  });
package/dist/git/Git.js CHANGED
@@ -10,14 +10,11 @@ class Git {
10
10
  async add(...files) {
11
11
  await this.terminal.run('git', 'add', ...files);
12
12
  }
13
- async checkout(branchName) {
14
- await this.terminal.run('git', 'checkout', branchName);
15
- }
16
13
  async commit(message) {
17
14
  await this.terminal.run('git', 'commit', '--message', message);
18
15
  }
19
16
  async createBranch(branchName) {
20
- await this.terminal.run('git', 'checkout', '-b', branchName);
17
+ await this.terminal.run('git', 'switch', '-c', branchName);
21
18
  }
22
19
  async getConfig(key) {
23
20
  const { stdout } = await this.terminal.run('git', 'config', key);
@@ -41,8 +38,14 @@ class Git {
41
38
  async removeBranch(branchName) {
42
39
  await this.terminal.run('git', 'branch', '-D', branchName);
43
40
  }
41
+ async restore(...files) {
42
+ await this.terminal.run('git', 'restore', '--worktree', '--staged', ...files);
43
+ }
44
44
  async setConfig(key, value) {
45
45
  await this.terminal.run('git', 'config', key, value);
46
46
  }
47
+ async switch(branchName) {
48
+ await this.terminal.run('git', 'switch', branchName);
49
+ }
47
50
  }
48
51
  exports.Git = Git;
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.Committer = exports.CommitMessageCreator = exports.BranchNameCreator = void 0;
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; } });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoteBranchExistenceChecker = void 0;
4
- // TODO: add test
5
4
  class RemoteBranchExistenceChecker {
6
5
  constructor(remoteBranchNames) {
7
6
  this.remoteBranchNames = remoteBranchNames;
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLogLevel = exports.LogLevel = void 0;
4
4
  exports.LogLevel = {
5
- Info: 'info',
6
- Debug: 'debug'
5
+ Debug: 'debug',
6
+ Error: 'error',
7
+ Info: 'info'
7
8
  };
8
9
  const logLevels = Object.values(exports.LogLevel);
9
10
  const isLogLevel = (value) => logLevels.includes(value);
package/dist/main.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
+ const Either_1 = require("fp-ts/lib/Either");
4
5
  const git_1 = require("./git");
5
6
  const github_1 = require("./github");
6
7
  const ncu_1 = require("./ncu");
@@ -43,13 +44,6 @@ const main = async ({ options, logger }) => {
43
44
  });
44
45
  logger.debug(`remoteBranches=${JSON.stringify(remoteBranches)}`);
45
46
  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
47
  const packageManager = (0, package_manager_1.createPackageManager)({
54
48
  terminal,
55
49
  packageManager: options.packageManager
@@ -67,7 +61,6 @@ const main = async ({ options, logger }) => {
67
61
  const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
68
62
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
69
63
  const outdatedPackageProcessor = new processors_1.OutdatedPackageProcessor({
70
- committer,
71
64
  git,
72
65
  ncu,
73
66
  packageManager,
@@ -83,14 +76,24 @@ const main = async ({ options, logger }) => {
83
76
  });
84
77
  const results = await outdatedPackagesProcessor.process(outdatedPackages);
85
78
  logger.debug(`results=${JSON.stringify(results)}`);
86
- const updatedPackages = results
79
+ const succeededResults = results.filter(Either_1.isRight).map(({ right }) => right);
80
+ logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
81
+ const updatedPackages = succeededResults
87
82
  .filter(({ updated }) => updated)
88
83
  .map(({ outdatedPackage }) => outdatedPackage);
89
84
  logger.debug(`updatedPackages=${JSON.stringify(updatedPackages)}`);
90
- const skippedPackages = results
85
+ const skippedPackages = succeededResults
91
86
  .filter(({ skipped }) => skipped)
92
87
  .map(({ outdatedPackage }) => outdatedPackage);
93
88
  logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
94
- logger.info(`${updatedPackages.length} packages has updated. ${skippedPackages.length} packages has skipped.`);
89
+ const failedResults = results.filter(Either_1.isLeft).map(({ left }) => left);
90
+ logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
91
+ const failedPackages = failedResults.map(({ outdatedPackage }) => outdatedPackage);
92
+ logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
93
+ // TODO: show as table
94
+ logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
95
+ - ${updatedPackages.length} packages has updated: ${updatedPackages.map(({ name }) => name).join(',')}
96
+ - ${skippedPackages.length} packages has skipped: ${skippedPackages.map(({ name }) => name).join(',')}
97
+ - ${failedPackages.length} packages has failed: ${failedPackages.map(({ name }) => name).join(',')}`);
95
98
  };
96
99
  exports.main = main;
@@ -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.intersection)([
8
- (0, io_ts_1.type)({
9
- branchName: io_ts_1.string,
10
- commitMessage: io_ts_1.string,
11
- githubToken: io_ts_1.string,
12
- logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
13
- 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)]),
14
- pullRequestBody: io_ts_1.string,
15
- pullRequestTitle: io_ts_1.string
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.Error), (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,11 +12,10 @@ 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([
18
+ logger_1.LogLevel.Error,
20
19
  logger_1.LogLevel.Info,
21
20
  logger_1.LogLevel.Debug
22
21
  ])
File without changes
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutdatedPackageProcessor = void 0;
4
+ const Either_1 = require("fp-ts/lib/Either");
4
5
  // TODO: add test
5
6
  class OutdatedPackageProcessor {
6
- constructor({ committer, git, ncu, packageManager, pullRequestCreator, remoteBranchExistenceChecker, logger, branchNameCreator, commitMessageCreator }) {
7
- this.committer = committer;
7
+ constructor({ git, ncu, packageManager, pullRequestCreator, remoteBranchExistenceChecker, logger, branchNameCreator, commitMessageCreator }) {
8
8
  this.git = git;
9
9
  this.ncu = ncu;
10
10
  this.packageManager = packageManager;
@@ -22,35 +22,49 @@ class OutdatedPackageProcessor {
22
22
  this.logger.debug(`branchName=${branchName}`);
23
23
  if (this.remoteBranchExistenceChecker.check(branchName)) {
24
24
  this.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
25
- return {
25
+ return (0, Either_1.right)({
26
26
  outdatedPackage,
27
27
  skipped: true
28
- };
28
+ });
29
29
  }
30
30
  await this.git.createBranch(branchName);
31
31
  this.logger.info(`${branchName} branch has created.`);
32
- const updatedPackages = await this.ncu.update(outdatedPackage);
33
- if (updatedPackages.length !== 1) {
34
- throw new Error(`Failed to update ${outdatedPackage.name}.`);
32
+ try {
33
+ try {
34
+ const updatedPackages = await this.ncu.update(outdatedPackage);
35
+ if (updatedPackages.length !== 1) {
36
+ throw new Error(`Failed to update ${outdatedPackage.name}.`);
37
+ }
38
+ await this.packageManager.install();
39
+ }
40
+ catch (error) {
41
+ this.logger.error(error);
42
+ return (0, Either_1.left)({
43
+ outdatedPackage,
44
+ error
45
+ });
46
+ }
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);
49
+ const message = this.commitMessageCreator.create(outdatedPackage);
50
+ this.logger.debug(`message=${message}`);
51
+ await this.git.commit(message);
52
+ await this.git.push(branchName);
53
+ await this.pullRequestCreator.create({
54
+ outdatedPackage,
55
+ branchName
56
+ });
57
+ return (0, Either_1.right)({
58
+ outdatedPackage,
59
+ updated: true
60
+ });
61
+ }
62
+ finally {
63
+ await this.git.restore(...this.packageManager.packageFiles);
64
+ await this.git.switch('-');
65
+ await this.git.removeBranch(branchName);
66
+ this.logger.info(`${branchName} branch has removed.`);
35
67
  }
36
- await this.packageManager.install();
37
- this.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
38
- await this.git.add(...this.packageManager.packageFiles);
39
- const message = this.commitMessageCreator.create(outdatedPackage);
40
- this.logger.debug(`message=${message}`);
41
- await this.committer.commit(message);
42
- await this.git.push(branchName);
43
- await this.pullRequestCreator.create({
44
- outdatedPackage,
45
- branchName
46
- });
47
- await this.git.checkout('-');
48
- await this.git.removeBranch(branchName);
49
- this.logger.info(`${branchName} branch has removed.`);
50
- return {
51
- outdatedPackage,
52
- updated: true
53
- };
54
68
  }
55
69
  }
56
70
  exports.OutdatedPackageProcessor = OutdatedPackageProcessor;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.8.0",
3
+ "version": "0.11.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 clean lint test build",
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.4.0",
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.1.1",
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
@@ -1,3 +0,0 @@
1
- /coverage
2
- /dist
3
- /node_modules
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
- }
@@ -1,2 +0,0 @@
1
- github: munierujp
2
- custom: ["https://www.paypal.me/munieru"]
@@ -1,15 +0,0 @@
1
- {
2
- "extends": [
3
- "config:base"
4
- ],
5
- "packageRules": [
6
- {
7
- "matchPackageNames": ["@types/node"],
8
- "allowedVersions": "<13"
9
- },
10
- {
11
- "matchPackageNames": ["node"],
12
- "allowedVersions": "<13"
13
- }
14
- ]
15
- }
@@ -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
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- npx lint-staged
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 12.20.2
@@ -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;
package/jest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { Config } from '@jest/types'
2
-
3
- const config: Config.InitialOptions = {
4
- preset: 'ts-jest',
5
- collectCoverage: true,
6
- collectCoverageFrom: [
7
- 'src/**/*.ts'
8
- ]
9
- }
10
-
11
- export default config
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- '*.js': 'eslint',
3
- '*.ts': 'eslint'
4
- }
@@ -1,8 +0,0 @@
1
- {
2
- "folders": [
3
- {
4
- "path": "."
5
- }
6
- ],
7
- "settings": {}
8
- }
package/src/app.ts DELETED
@@ -1,5 +0,0 @@
1
- export const app = {
2
- name: 'npm-update-package',
3
- version: '0.8.0',
4
- web: 'https://github.com/npm-update-package/npm-update-package'
5
- } as const
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
- }