npm-update-package 0.6.0 → 0.9.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 (87) hide show
  1. package/README.md +98 -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/index.js +5 -1
  7. package/dist/main.js +4 -0
  8. package/dist/options/Options.js +6 -2
  9. package/dist/options/initOptions.js +10 -1
  10. package/package.json +11 -7
  11. package/.eslintignore +0 -3
  12. package/.eslintrc.js +0 -23
  13. package/.github/FUNDING.yml +0 -2
  14. package/.github/renovate.json +0 -15
  15. package/.github/workflows/eslint.yml +0 -14
  16. package/.github/workflows/test.yml +0 -19
  17. package/.husky/pre-commit +0 -4
  18. package/.nvmrc +0 -1
  19. package/dist/github/createPullRequestBody.js +0 -19
  20. package/dist/github/createPullRequestTitle.js +0 -10
  21. package/jest.config.ts +0 -11
  22. package/lint-staged.config.js +0 -4
  23. package/npm-update-package.code-workspace +0 -8
  24. package/src/app.ts +0 -5
  25. package/src/bin.ts +0 -20
  26. package/src/git/BranchNameCreator.test.ts +0 -17
  27. package/src/git/BranchNameCreator.ts +0 -19
  28. package/src/git/CommitMessageCreator.test.ts +0 -17
  29. package/src/git/CommitMessageCreator.ts +0 -19
  30. package/src/git/Committer.ts +0 -49
  31. package/src/git/Git.ts +0 -55
  32. package/src/git/GitRepository.test.ts +0 -61
  33. package/src/git/GitRepository.ts +0 -57
  34. package/src/git/index.ts +0 -5
  35. package/src/github/Branch.ts +0 -4
  36. package/src/github/GitHub.ts +0 -27
  37. package/src/github/PullRequest.ts +0 -3
  38. package/src/github/PullRequestCreator.ts +0 -57
  39. package/src/github/RemoteBranchExistenceChecker.ts +0 -15
  40. package/src/github/Repository.ts +0 -3
  41. package/src/github/createGitHub.ts +0 -18
  42. package/src/github/createOctokit.ts +0 -28
  43. package/src/github/createPullRequestBody.test.ts +0 -64
  44. package/src/github/createPullRequestBody.ts +0 -17
  45. package/src/github/createPullRequestTitle.test.ts +0 -42
  46. package/src/github/createPullRequestTitle.ts +0 -8
  47. package/src/github/index.ts +0 -7
  48. package/src/logger/LogLevel.ts +0 -8
  49. package/src/logger/Logger.ts +0 -1
  50. package/src/logger/createLogger.ts +0 -10
  51. package/src/logger/index.ts +0 -6
  52. package/src/main.ts +0 -122
  53. package/src/ncu/Ncu.ts +0 -43
  54. package/src/ncu/NcuOutdatedPackages.ts +0 -6
  55. package/src/ncu/NcuOutdatedPackagesConverter.ts +0 -25
  56. package/src/ncu/OutdatedPackage.ts +0 -9
  57. package/src/ncu/PackageVersion.test.ts +0 -25
  58. package/src/ncu/PackageVersion.ts +0 -40
  59. package/src/ncu/UpdateType.ts +0 -9
  60. package/src/ncu/index.ts +0 -7
  61. package/src/ncu/isNcuOutdatedPackages.ts +0 -6
  62. package/src/ncu/toUpdateType.test.ts +0 -21
  63. package/src/ncu/toUpdateType.ts +0 -18
  64. package/src/options/Options.ts +0 -26
  65. package/src/options/index.ts +0 -2
  66. package/src/options/initOptions.ts +0 -44
  67. package/src/package-json/Package.ts +0 -24
  68. package/src/package-json/PackageDependencies.ts +0 -10
  69. package/src/package-json/PackageJsonParser.ts +0 -19
  70. package/src/package-json/PackageJsonReader.ts +0 -27
  71. package/src/package-json/index.ts +0 -3
  72. package/src/package-manager/Npm.ts +0 -19
  73. package/src/package-manager/PackageManager.ts +0 -4
  74. package/src/package-manager/PackageManagerName.ts +0 -8
  75. package/src/package-manager/Yarn.ts +0 -19
  76. package/src/package-manager/createPackageManager.ts +0 -21
  77. package/src/package-manager/index.ts +0 -8
  78. package/src/processors/OutdatedPackageProcessor.ts +0 -109
  79. package/src/processors/OutdatedPackagesProcessor.ts +0 -32
  80. package/src/processors/Result.ts +0 -7
  81. package/src/processors/index.ts +0 -2
  82. package/src/terminal/Terminal.ts +0 -30
  83. package/src/terminal/index.ts +0 -1
  84. package/src/terminal/isExecaReturnValue.ts +0 -30
  85. package/tsconfig.base.json +0 -3
  86. package/tsconfig.build.json +0 -13
  87. package/tsconfig.json +0 -9
package/README.md CHANGED
@@ -33,30 +33,112 @@ npm-update-package --github-token $GITHUB_TOKEN
33
33
 
34
34
  ## Options
35
35
 
36
- You can customize behavior via command-line options.
36
+ You can customize behavior via command-line options.
37
+ Template strings such as `--branch-name` can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
37
38
 
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`|
39
+ ### `--branch-name`
47
40
 
48
- ### Templates
41
+ Branch name template
49
42
 
50
- npm-update-package is using [mustache](https://www.npmjs.com/package/mustache) for generating string from templates.
51
- These variables are available:
52
-
53
- - `--branch-name`
43
+ - value: template string
44
+ - embeddable variables:
45
+ - `currentVersion`
46
+ - `newVersion`
54
47
  - `packageName`
48
+ - `updateType`
49
+ - required: false
50
+ - default: `npm-update-package/{{{packageName}}}/v{{newVersion}}`
51
+
52
+ ### `--commit-message`
53
+
54
+ Commit message template
55
+
56
+ - value: template string
57
+ - embeddable variables:
55
58
  - `currentVersion`
56
59
  - `newVersion`
60
+ - `packageName`
57
61
  - `updateType`
58
- - `--commit-message`
62
+ - required: false
63
+ - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
64
+
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
+ ### `--github-token`
80
+
81
+ GitHub token
82
+
83
+ - value: string
84
+ - required: true
85
+
86
+ ### `--log-level`
87
+
88
+ Log level to show
89
+
90
+ - value: string
91
+ - `info`
92
+ - `debug`
93
+ - required: false
94
+ - default: `info`
95
+
96
+ ### `--package-manager`
97
+
98
+ Package manager of your project
99
+
100
+ - value: string
101
+ - `npm`
102
+ - `yarn`
103
+ - required: false
104
+ - default: `npm`
105
+
106
+ ### `--pull-request-body`
107
+
108
+ Pull request body template
109
+
110
+ - value: template string
111
+ - embeddable variables:
112
+ - `appName`
113
+ - `appVersion`
114
+ - `appWeb`
115
+ - `currentVersion`
116
+ - `newVersion`
59
117
  - `packageName`
118
+ - `updateType`
119
+ - required: false
120
+ - default:
121
+
122
+ ```
123
+ This PR updates these packages:
124
+
125
+ |package|type|current version|new version|
126
+ |---|---|---|---|
127
+ |[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
128
+
129
+ ---
130
+ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
131
+ ```
132
+
133
+ ### `--pull-request-title`
134
+
135
+ Pull request title template
136
+
137
+ - value: template string
138
+ - embeddable variables:
60
139
  - `currentVersion`
61
140
  - `newVersion`
141
+ - `packageName`
62
142
  - `updateType`
143
+ - required: false
144
+ - 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.0',
6
+ version: '0.9.0',
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,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.0",
3
+ "version": "0.9.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",
@@ -8,9 +8,12 @@
8
8
  "lint": "eslint '**/*.{js,ts}'",
9
9
  "prepare": "husky install",
10
10
  "prepublish": "npm-run-all clean lint test build",
11
- "start": "ts-node src/start.ts",
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",
@@ -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.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
- }
@@ -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
- }