npm-update-package 0.6.1 → 0.9.1

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 (88) hide show
  1. package/README.md +102 -16
  2. package/dist/app.js +1 -1
  3. package/dist/github/PullRequestBodyCreator.js +29 -0
  4. package/dist/github/PullRequestCreator.js +5 -5
  5. package/dist/github/PullRequestTitleCreator.js +22 -0
  6. package/dist/github/RemoteBranchExistenceChecker.js +0 -1
  7. package/dist/github/index.js +5 -1
  8. package/dist/main.js +4 -0
  9. package/dist/options/Options.js +6 -2
  10. package/dist/options/initOptions.js +10 -1
  11. package/package.json +11 -7
  12. package/.eslintignore +0 -3
  13. package/.eslintrc.js +0 -23
  14. package/.github/FUNDING.yml +0 -2
  15. package/.github/renovate.json +0 -15
  16. package/.github/workflows/eslint.yml +0 -14
  17. package/.github/workflows/test.yml +0 -19
  18. package/.husky/pre-commit +0 -4
  19. package/.nvmrc +0 -1
  20. package/dist/github/createPullRequestBody.js +0 -19
  21. package/dist/github/createPullRequestTitle.js +0 -10
  22. package/jest.config.ts +0 -11
  23. package/lint-staged.config.js +0 -4
  24. package/npm-update-package.code-workspace +0 -8
  25. package/src/app.ts +0 -5
  26. package/src/bin.ts +0 -20
  27. package/src/git/BranchNameCreator.test.ts +0 -17
  28. package/src/git/BranchNameCreator.ts +0 -19
  29. package/src/git/CommitMessageCreator.test.ts +0 -17
  30. package/src/git/CommitMessageCreator.ts +0 -19
  31. package/src/git/Committer.ts +0 -49
  32. package/src/git/Git.ts +0 -55
  33. package/src/git/GitRepository.test.ts +0 -61
  34. package/src/git/GitRepository.ts +0 -57
  35. package/src/git/index.ts +0 -5
  36. package/src/github/Branch.ts +0 -4
  37. package/src/github/GitHub.ts +0 -27
  38. package/src/github/PullRequest.ts +0 -3
  39. package/src/github/PullRequestCreator.ts +0 -57
  40. package/src/github/RemoteBranchExistenceChecker.ts +0 -15
  41. package/src/github/Repository.ts +0 -3
  42. package/src/github/createGitHub.ts +0 -18
  43. package/src/github/createOctokit.ts +0 -28
  44. package/src/github/createPullRequestBody.test.ts +0 -64
  45. package/src/github/createPullRequestBody.ts +0 -17
  46. package/src/github/createPullRequestTitle.test.ts +0 -42
  47. package/src/github/createPullRequestTitle.ts +0 -8
  48. package/src/github/index.ts +0 -7
  49. package/src/logger/LogLevel.ts +0 -8
  50. package/src/logger/Logger.ts +0 -1
  51. package/src/logger/createLogger.ts +0 -10
  52. package/src/logger/index.ts +0 -6
  53. package/src/main.ts +0 -122
  54. package/src/ncu/Ncu.ts +0 -43
  55. package/src/ncu/NcuOutdatedPackages.ts +0 -6
  56. package/src/ncu/NcuOutdatedPackagesConverter.ts +0 -25
  57. package/src/ncu/OutdatedPackage.ts +0 -9
  58. package/src/ncu/PackageVersion.test.ts +0 -25
  59. package/src/ncu/PackageVersion.ts +0 -40
  60. package/src/ncu/UpdateType.ts +0 -9
  61. package/src/ncu/index.ts +0 -7
  62. package/src/ncu/isNcuOutdatedPackages.ts +0 -6
  63. package/src/ncu/toUpdateType.test.ts +0 -21
  64. package/src/ncu/toUpdateType.ts +0 -18
  65. package/src/options/Options.ts +0 -26
  66. package/src/options/index.ts +0 -2
  67. package/src/options/initOptions.ts +0 -44
  68. package/src/package-json/Package.ts +0 -24
  69. package/src/package-json/PackageDependencies.ts +0 -10
  70. package/src/package-json/PackageJsonParser.ts +0 -19
  71. package/src/package-json/PackageJsonReader.ts +0 -27
  72. package/src/package-json/index.ts +0 -3
  73. package/src/package-manager/Npm.ts +0 -19
  74. package/src/package-manager/PackageManager.ts +0 -4
  75. package/src/package-manager/PackageManagerName.ts +0 -8
  76. package/src/package-manager/Yarn.ts +0 -19
  77. package/src/package-manager/createPackageManager.ts +0 -21
  78. package/src/package-manager/index.ts +0 -8
  79. package/src/processors/OutdatedPackageProcessor.ts +0 -109
  80. package/src/processors/OutdatedPackagesProcessor.ts +0 -32
  81. package/src/processors/Result.ts +0 -7
  82. package/src/processors/index.ts +0 -2
  83. package/src/terminal/Terminal.ts +0 -30
  84. package/src/terminal/index.ts +0 -1
  85. package/src/terminal/isExecaReturnValue.ts +0 -30
  86. package/tsconfig.base.json +0 -3
  87. package/tsconfig.build.json +0 -13
  88. 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,30 +37,112 @@ 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`|
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).
47
42
 
48
- ### Templates
43
+ ### `--branch-name`
49
44
 
50
- npm-update-package is using [mustache](https://www.npmjs.com/package/mustache) for generating string from templates.
51
- These variables are available:
45
+ Branch name template
52
46
 
53
- - `--branch-name`
47
+ - value: template string
48
+ - embeddable variables:
49
+ - `currentVersion`
50
+ - `newVersion`
54
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:
55
62
  - `currentVersion`
56
63
  - `newVersion`
64
+ - `packageName`
57
65
  - `updateType`
58
- - `--commit-message`
66
+ - required: false
67
+ - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
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
+ ### `--github-token`
84
+
85
+ GitHub token
86
+
87
+ - value: string
88
+ - required: true
89
+
90
+ ### `--log-level`
91
+
92
+ Log level to show
93
+
94
+ - value: string
95
+ - `info`
96
+ - `debug`
97
+ - required: false
98
+ - default: `info`
99
+
100
+ ### `--package-manager`
101
+
102
+ Package manager of your project
103
+
104
+ - value: string
105
+ - `npm`
106
+ - `yarn`
107
+ - required: false
108
+ - default: `npm`
109
+
110
+ ### `--pull-request-body`
111
+
112
+ Pull request body template
113
+
114
+ - value: template string
115
+ - embeddable variables:
116
+ - `appName`
117
+ - `appVersion`
118
+ - `appWeb`
119
+ - `currentVersion`
120
+ - `newVersion`
59
121
  - `packageName`
122
+ - `updateType`
123
+ - required: false
124
+ - default:
125
+
126
+ ```
127
+ This PR updates these packages:
128
+
129
+ |package|type|current version|new version|
130
+ |---|---|---|---|
131
+ |[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
132
+
133
+ ---
134
+ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
135
+ ```
136
+
137
+ ### `--pull-request-title`
138
+
139
+ Pull request title template
140
+
141
+ - value: template string
142
+ - embeddable variables:
60
143
  - `currentVersion`
61
144
  - `newVersion`
145
+ - `packageName`
62
146
  - `updateType`
147
+ - required: false
148
+ - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
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.6.1',
6
+ version: '0.9.1',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -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
- const createPullRequestTitle_1 = require("./createPullRequestTitle");
6
4
  // TODO: add test
7
5
  class PullRequestCreator {
8
- constructor({ github, gitRepo, githubRepo, logger }) {
6
+ constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger }) {
9
7
  this.github = github;
10
8
  this.gitRepo = gitRepo;
11
9
  this.githubRepo = githubRepo;
10
+ this.pullRequestTitleCreator = pullRequestTitleCreator;
11
+ this.pullRequestBodyCreator = pullRequestBodyCreator;
12
12
  this.logger = logger;
13
13
  }
14
14
  async create({ outdatedPackage, branchName }) {
15
- const title = (0, createPullRequestTitle_1.createPullRequestTitle)(outdatedPackage);
15
+ const title = this.pullRequestTitleCreator.create(outdatedPackage);
16
16
  this.logger.debug(`title=${title}`);
17
- const body = (0, createPullRequestBody_1.createPullRequestBody)(outdatedPackage);
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,
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PullRequestTitleCreator = void 0;
4
+ const mustache_1 = require("mustache");
5
+ class PullRequestTitleCreator {
6
+ constructor(template) {
7
+ this.template = template;
8
+ }
9
+ create(outdatedPackage) {
10
+ const packageName = outdatedPackage.name;
11
+ const currentVersion = outdatedPackage.currentVersion.version;
12
+ const newVersion = outdatedPackage.newVersion.version;
13
+ const updateType = outdatedPackage.type;
14
+ return (0, mustache_1.render)(this.template, {
15
+ packageName,
16
+ currentVersion,
17
+ newVersion,
18
+ updateType
19
+ });
20
+ }
21
+ }
22
+ exports.PullRequestTitleCreator = PullRequestTitleCreator;
@@ -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;
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteBranchExistenceChecker = 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; } });
12
+ var PullRequestTitleCreator_1 = require("./PullRequestTitleCreator");
13
+ Object.defineProperty(exports, "PullRequestTitleCreator", { enumerable: true, get: function () { return PullRequestTitleCreator_1.PullRequestTitleCreator; } });
10
14
  var RemoteBranchExistenceChecker_1 = require("./RemoteBranchExistenceChecker");
11
15
  Object.defineProperty(exports, "RemoteBranchExistenceChecker", { enumerable: true, get: function () { return RemoteBranchExistenceChecker_1.RemoteBranchExistenceChecker; } });
package/dist/main.js CHANGED
@@ -54,10 +54,14 @@ const main = async ({ options, logger }) => {
54
54
  terminal,
55
55
  packageManager: options.packageManager
56
56
  });
57
+ const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.pullRequestTitle);
58
+ const pullRequestBodyCreator = new github_1.PullRequestBodyCreator(options.pullRequestBody);
57
59
  const pullRequestCreator = new github_1.PullRequestCreator({
58
60
  github,
59
61
  gitRepo,
60
62
  githubRepo,
63
+ pullRequestTitleCreator,
64
+ pullRequestBodyCreator,
61
65
  logger
62
66
  });
63
67
  const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
@@ -2,13 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isOptions = void 0;
4
4
  const io_ts_1 = require("io-ts");
5
+ const logger_1 = require("../logger");
6
+ const package_manager_1 = require("../package-manager");
5
7
  const Options = (0, io_ts_1.intersection)([
6
8
  (0, io_ts_1.type)({
7
9
  branchName: io_ts_1.string,
8
10
  commitMessage: io_ts_1.string,
9
11
  githubToken: io_ts_1.string,
10
- logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)('info'), (0, io_ts_1.literal)('debug')]),
11
- packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)('npm'), (0, io_ts_1.literal)('yarn')])
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
12
16
  }),
13
17
  (0, io_ts_1.partial)({
14
18
  gitUserEmail: io_ts_1.string,
@@ -26,7 +26,16 @@ const initOptions = () => {
26
26
  package_manager_1.PackageManagerName.Npm,
27
27
  package_manager_1.PackageManagerName.Yarn
28
28
  ])
29
- .default(package_manager_1.PackageManagerName.Npm));
29
+ .default(package_manager_1.PackageManagerName.Npm))
30
+ .option('--pull-request-body <value>', 'Pull request body template', `This PR updates these packages:
31
+
32
+ |package|type|current version|new version|
33
+ |---|---|---|---|
34
+ |[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
35
+
36
+ ---
37
+ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
38
+ .option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}');
30
39
  commander_1.program.parse(process.argv);
31
40
  const options = commander_1.program.opts();
32
41
  if (!(0, Options_1.isOptions)(options)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.6.1",
3
+ "version": "0.9.1",
4
4
  "description": "CLI tool for creating pull request to update npm packages",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.build.json",
@@ -11,6 +11,9 @@
11
11
  "start": "ts-node src/bin.ts",
12
12
  "test": "jest --passWithNoTests"
13
13
  },
14
+ "files": [
15
+ "dist"
16
+ ],
14
17
  "bin": "dist/bin.js",
15
18
  "dependencies": {
16
19
  "@octokit/rest": "18.12.0",
@@ -32,7 +35,7 @@
32
35
  "@types/node": "12.20.15",
33
36
  "@types/parse-github-url": "1.0.0",
34
37
  "@types/semver": "7.3.9",
35
- "@typescript-eslint/eslint-plugin": "5.4.0",
38
+ "@typescript-eslint/eslint-plugin": "5.5.0",
36
39
  "eslint": "8.3.0",
37
40
  "eslint-config-standard-with-typescript": "21.0.1",
38
41
  "eslint-plugin-import": "2.25.3",
@@ -50,12 +53,13 @@
50
53
  "typescript": "4.4.4",
51
54
  "utility-types": "3.10.0"
52
55
  },
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
56
  "repository": {
58
57
  "type": "git",
59
58
  "url": "https://github.com/npm-update-package/npm-update-package.git"
60
- }
59
+ },
60
+ "bugs": {
61
+ "url": "https://github.com/npm-update-package/npm-update-package/issues"
62
+ },
63
+ "homepage": "https://github.com/npm-update-package/npm-update-package",
64
+ "license": "MIT"
61
65
  }
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,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;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPullRequestTitle = void 0;
4
- const createPullRequestTitle = (outdatedPackage) => {
5
- const packageName = outdatedPackage.name;
6
- const newVersion = outdatedPackage.newVersion.version;
7
- const updateType = outdatedPackage.type;
8
- return `chore(deps): ${updateType} update ${packageName} to v${newVersion}`;
9
- };
10
- exports.createPullRequestTitle = createPullRequestTitle;
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.6.1',
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
- }
@@ -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
- })
@@ -1,19 +0,0 @@
1
- import { render } from 'mustache'
2
- import type { OutdatedPackage } from '../ncu'
3
-
4
- export class CommitMessageCreator {
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,49 +0,0 @@
1
- import type { Git } from './Git'
2
-
3
- export interface User {
4
- name?: string
5
- email?: string
6
- }
7
-
8
- // TODO: add test
9
- export class Committer {
10
- private readonly git: Git
11
- private readonly user: User | undefined
12
-
13
- constructor ({
14
- git,
15
- user
16
- }: {
17
- git: Git
18
- user?: User
19
- }) {
20
- this.git = git
21
- this.user = user
22
- }
23
-
24
- async commit (message: string): Promise<void> {
25
- let name: string | undefined
26
-
27
- if (this.user?.name !== undefined) {
28
- name = await this.git.getConfig('user.name')
29
- await this.git.setConfig('user.name', this.user.name)
30
- }
31
-
32
- let email: string | undefined
33
-
34
- if (this.user?.email !== undefined) {
35
- email = await this.git.getConfig('user.email')
36
- await this.git.setConfig('user.email', this.user.email)
37
- }
38
-
39
- await this.git.commit(message)
40
-
41
- if (name !== undefined) {
42
- await this.git.setConfig('user.name', name)
43
- }
44
-
45
- if (email !== undefined) {
46
- await this.git.setConfig('user.email', email)
47
- }
48
- }
49
- }