npm-update-package 3.0.21 → 4.0.0-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/dist/package.json +6 -6
- package/dist/src/bin/npm-update-package.js +14 -20
- package/dist/src/core/FailedResult.js +1 -2
- package/dist/src/core/OutdatedPackage.js +1 -2
- package/dist/src/core/OutdatedPackagesProcessor.js +3 -7
- package/dist/src/core/PackageUpdater.js +1 -5
- package/dist/src/core/SucceededResult.js +1 -2
- package/dist/src/file/canReadWrite.js +3 -10
- package/dist/src/file/readFile.js +3 -10
- package/dist/src/git/CommitMessageCreator.js +3 -7
- package/dist/src/git/Git.js +1 -5
- package/dist/src/git/GitConfigInitializer.js +1 -5
- package/dist/src/git/GitRepository.js +5 -12
- package/dist/src/git/GitTransaction.js +4 -8
- package/dist/src/git/createBranchName.js +1 -5
- package/dist/src/github/GitHub.js +4 -8
- package/dist/src/github/branch/finder/BranchFinder.js +1 -5
- package/dist/src/github/createGitHub.js +5 -9
- package/dist/src/github/createOctokit.js +7 -14
- package/dist/src/github/errors/NotFoundError.js +4 -8
- package/dist/src/github/label/creator/LabelCreator.js +7 -11
- package/dist/src/github/pull-request/closer/PullRequestCloser.js +1 -5
- package/dist/src/github/pull-request/closer/PullRequestsCloser.js +3 -7
- package/dist/src/github/pull-request/creator/AssigneesAdder.js +3 -7
- package/dist/src/github/pull-request/creator/GitHubUrlOptimizer.js +3 -7
- package/dist/src/github/pull-request/creator/LabelsAdder.js +1 -5
- package/dist/src/github/pull-request/creator/PackageDiffsSectionCreator.js +1 -5
- package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +15 -18
- package/dist/src/github/pull-request/creator/PullRequestCreator.js +5 -9
- package/dist/src/github/pull-request/creator/PullRequestTitleCreator.js +3 -7
- package/dist/src/github/pull-request/creator/ReleaseNotesSectionCreator.js +1 -5
- package/dist/src/github/pull-request/creator/ReviewersAdder.js +3 -7
- package/dist/src/github/pull-request/creator/createFooter.js +3 -10
- package/dist/src/github/pull-request/creator/createMetadataSection.js +5 -9
- package/dist/src/github/pull-request/creator/createNotesSection.js +1 -5
- package/dist/src/github/pull-request/creator/createOutdatedPackagesTable.js +1 -5
- package/dist/src/github/pull-request/finder/PullRequestFinder.js +5 -9
- package/dist/src/github/pull-request/finder/isPullRequestByNpmUpdatePackage.js +1 -5
- package/dist/src/github/pull-request/metadata/PullRequestMetadata.js +10 -13
- package/dist/src/github/pull-request/metadata/createPullRequestMetadata.js +3 -10
- package/dist/src/github/pull-request/metadata/extractPullRequestMetadata.js +3 -7
- package/dist/src/github/releases/Release.js +1 -2
- package/dist/src/github/releases/fetcher/ReleasesFetcher.js +9 -16
- package/dist/src/json/toJSON.js +1 -5
- package/dist/src/logger/LogLevel.js +3 -7
- package/dist/src/logger/logger.js +2 -5
- package/dist/src/main.js +73 -58
- package/dist/src/npm-check-updates/Dependency.js +3 -7
- package/dist/src/npm-check-updates/NpmCheckUpdates.js +32 -34
- package/dist/src/npm-check-updates/NpmCheckUpdatesResult.js +3 -6
- package/dist/src/npm-check-updates/createDepOptionValue.js +3 -7
- package/dist/src/npm-check-updates/toDependency.js +13 -17
- package/dist/src/options/CLIOption.js +1 -2
- package/dist/src/options/OptionType.js +3 -7
- package/dist/src/options/Options.js +46 -49
- package/dist/src/options/cliOptions.js +50 -53
- package/dist/src/options/createOptions.js +11 -18
- package/dist/src/options/initOptions.js +4 -8
- package/dist/src/options/parseBooleanOption.js +3 -7
- package/dist/src/options/parseNumberOption.js +3 -7
- package/dist/src/options/toCommanderOption.js +14 -18
- package/dist/src/outdated-package-processor/OutdatedPackageProcessor.js +1 -2
- package/dist/src/outdated-package-processor/OutdatedPackageProcessorCreator.js +11 -15
- package/dist/src/outdated-package-processor/OutdatedPullRequestStrategy.js +3 -7
- package/dist/src/outdated-package-processor/create/Create.js +17 -20
- package/dist/src/outdated-package-processor/recreate/Recreate.js +18 -21
- package/dist/src/outdated-package-processor/skip/Skip.js +20 -23
- package/dist/src/package-json/DependencyType.js +3 -7
- package/dist/src/package-json/PackageMetadata.js +15 -18
- package/dist/src/package-json/PackageMetadataDependencies.js +3 -6
- package/dist/src/package-json/PackageMetadataRepository.js +4 -7
- package/dist/src/package-json/extractRepository.js +3 -7
- package/dist/src/package-json/parsePackageJson.js +3 -7
- package/dist/src/package-json/readPackageJson.js +5 -9
- package/dist/src/package-manager/PackageManager.js +1 -2
- package/dist/src/package-manager/PackageManagerCreator.js +15 -19
- package/dist/src/package-manager/PackageManagerName.js +3 -7
- package/dist/src/package-manager/detectPackageManager.js +7 -11
- package/dist/src/package-manager/npm/Npm.js +3 -7
- package/dist/src/package-manager/npm/NpmVersions.js +3 -6
- package/dist/src/package-manager/yarn/Yarn.js +3 -7
- package/dist/src/package-manager/yarn/YarnVersions.js +5 -8
- package/dist/src/semver/SemVer.js +3 -7
- package/dist/src/semver/SemVerLevel.js +3 -7
- package/dist/src/semver/compareSemVers.js +5 -9
- package/dist/src/terminal/Terminal.js +3 -10
- package/dist/src/util/range.js +1 -5
- package/dist/src/util/sampleSize.js +3 -10
- package/dist/src/util/sleep.js +1 -5
- package/package.json +6 -6
- package/dist/src/core/index.js +0 -21
- package/dist/src/file/index.js +0 -18
- package/dist/src/git/index.js +0 -22
- package/dist/src/github/branch/finder/index.js +0 -17
- package/dist/src/github/branch/index.js +0 -17
- package/dist/src/github/errors/index.js +0 -17
- package/dist/src/github/index.js +0 -22
- package/dist/src/github/label/creator/index.js +0 -17
- package/dist/src/github/label/index.js +0 -17
- package/dist/src/github/pull-request/closer/index.js +0 -18
- package/dist/src/github/pull-request/creator/index.js +0 -25
- package/dist/src/github/pull-request/finder/index.js +0 -17
- package/dist/src/github/pull-request/index.js +0 -19
- package/dist/src/github/pull-request/metadata/index.js +0 -19
- package/dist/src/github/releases/fetcher/index.js +0 -17
- package/dist/src/github/releases/index.js +0 -18
- package/dist/src/json/index.js +0 -17
- package/dist/src/logger/index.js +0 -18
- package/dist/src/npm-check-updates/index.js +0 -17
- package/dist/src/options/index.js +0 -18
- package/dist/src/outdated-package-processor/create/index.js +0 -17
- package/dist/src/outdated-package-processor/index.js +0 -19
- package/dist/src/outdated-package-processor/recreate/index.js +0 -17
- package/dist/src/outdated-package-processor/skip/index.js +0 -17
- package/dist/src/package-json/index.js +0 -21
- package/dist/src/package-manager/index.js +0 -21
- package/dist/src/package-manager/npm/index.js +0 -17
- package/dist/src/package-manager/yarn/index.js +0 -17
- package/dist/src/semver/index.js +0 -19
- package/dist/src/terminal/index.js +0 -17
- package/dist/src/util/index.js +0 -19
package/dist/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-0",
|
|
4
4
|
"description": "CLI tool for creating pull requests to update npm packages",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "tsc --project tsconfig.build.json",
|
|
7
8
|
"clean": "rimraf dist",
|
|
8
|
-
"lint": "eslint '**/*.{js,ts}'",
|
|
9
|
-
"lint:fix": "eslint --fix '**/*.{js,ts}'",
|
|
9
|
+
"lint": "eslint '**/*.{js,mjs,cjs,ts,mts,cts}'",
|
|
10
10
|
"prebuild": "npm run clean",
|
|
11
11
|
"prepublishOnly": "npm-run-all lint test build",
|
|
12
12
|
"test": "jest"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"type-guards": "0.15.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@munierujp/eslint-config-typescript": "
|
|
35
|
+
"@munierujp/eslint-config-typescript": "43.0.0",
|
|
36
36
|
"@tsconfig/node18": "18.2.4",
|
|
37
37
|
"@types/mustache": "4.2.5",
|
|
38
38
|
"@types/node": "18.17.15",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"@types/parse-github-url": "1.0.3",
|
|
41
41
|
"@types/semver": "7.5.8",
|
|
42
42
|
"eslint": "8.57.0",
|
|
43
|
-
"eslint-plugin-jest": "28.
|
|
43
|
+
"eslint-plugin-jest": "28.3.0",
|
|
44
44
|
"jest": "29.7.0",
|
|
45
45
|
"npm-run-all": "4.1.5",
|
|
46
46
|
"rimraf": "5.0.5",
|
|
47
47
|
"ts-jest": "29.1.2",
|
|
48
|
-
"
|
|
48
|
+
"tsx": "4.9.3",
|
|
49
49
|
"typescript": "5.4.5",
|
|
50
50
|
"utility-types": "3.11.0"
|
|
51
51
|
},
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.then(() => {
|
|
16
|
-
logger_1.logger.info(`End ${package_json_1.default.name} v${package_json_1.default.version}`);
|
|
17
|
-
})
|
|
18
|
-
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
19
|
-
.catch((error) => {
|
|
20
|
-
logger_1.logger.fatal(error);
|
|
2
|
+
import pkg from '../../package.json';
|
|
3
|
+
import { logger } from '../logger/logger.js';
|
|
4
|
+
import { main } from '../main.js';
|
|
5
|
+
import { initOptions } from '../options/initOptions.js';
|
|
6
|
+
try {
|
|
7
|
+
const options = initOptions();
|
|
8
|
+
logger.level = options.logLevel;
|
|
9
|
+
logger.info(`Start ${pkg.name} v${pkg.version}`);
|
|
10
|
+
await main(options);
|
|
11
|
+
logger.info(`End ${pkg.name} v${pkg.version}`);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
logger.fatal(error);
|
|
21
15
|
throw error;
|
|
22
|
-
}
|
|
16
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.OutdatedPackagesProcessor = void 0;
|
|
4
|
-
const logger_1 = require("../logger");
|
|
5
|
-
class OutdatedPackagesProcessor {
|
|
1
|
+
import { logger } from '../logger/logger.js';
|
|
2
|
+
export class OutdatedPackagesProcessor {
|
|
6
3
|
outdatedPackageProcessor;
|
|
7
4
|
constructor(outdatedPackageProcessor) {
|
|
8
5
|
this.outdatedPackageProcessor = outdatedPackageProcessor;
|
|
@@ -10,11 +7,10 @@ class OutdatedPackagesProcessor {
|
|
|
10
7
|
async process(outdatedPackages) {
|
|
11
8
|
const results = [];
|
|
12
9
|
for (const outdatedPackage of outdatedPackages) {
|
|
13
|
-
|
|
10
|
+
logger.debug(`outdatedPackage=${JSON.stringify(outdatedPackage)}`);
|
|
14
11
|
const result = await this.outdatedPackageProcessor.process(outdatedPackage);
|
|
15
12
|
results.push(result);
|
|
16
13
|
}
|
|
17
14
|
return results;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.OutdatedPackagesProcessor = OutdatedPackagesProcessor;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageUpdater = void 0;
|
|
4
|
-
class PackageUpdater {
|
|
1
|
+
export class PackageUpdater {
|
|
5
2
|
packageManager;
|
|
6
3
|
ncu;
|
|
7
4
|
constructor({ packageManager, ncu }) {
|
|
@@ -16,4 +13,3 @@ class PackageUpdater {
|
|
|
16
13
|
await this.packageManager.install();
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.PackageUpdater = PackageUpdater;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.canReadWrite = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
1
|
+
import fs from 'node:fs';
|
|
8
2
|
// TODO: Add test
|
|
9
|
-
const canReadWrite = async (path) => {
|
|
3
|
+
export const canReadWrite = async (path) => {
|
|
10
4
|
try {
|
|
11
|
-
await
|
|
5
|
+
await fs.promises.access(path, fs.constants.R_OK | fs.constants.W_OK);
|
|
12
6
|
}
|
|
13
7
|
catch {
|
|
14
8
|
return false;
|
|
15
9
|
}
|
|
16
10
|
return true;
|
|
17
11
|
};
|
|
18
|
-
exports.canReadWrite = canReadWrite;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
export const readFile = async (path) => {
|
|
3
|
+
return await fs.promises.readFile(path, 'utf8');
|
|
4
4
|
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readFile = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const readFile = async (path) => {
|
|
9
|
-
return await node_fs_1.default.promises.readFile(path, 'utf8');
|
|
10
|
-
};
|
|
11
|
-
exports.readFile = readFile;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CommitMessageCreator = void 0;
|
|
4
|
-
const mustache_1 = require("mustache");
|
|
5
|
-
class CommitMessageCreator {
|
|
1
|
+
import mustache from 'mustache';
|
|
2
|
+
export class CommitMessageCreator {
|
|
6
3
|
template;
|
|
7
4
|
constructor(template) {
|
|
8
5
|
this.template = template;
|
|
@@ -13,7 +10,7 @@ class CommitMessageCreator {
|
|
|
13
10
|
const newVersion = outdatedPackage.newVersion.version;
|
|
14
11
|
const level = outdatedPackage.level;
|
|
15
12
|
const dependencyType = outdatedPackage.dependencyType;
|
|
16
|
-
return
|
|
13
|
+
return mustache.render(this.template, {
|
|
17
14
|
packageName,
|
|
18
15
|
currentVersion,
|
|
19
16
|
newVersion,
|
|
@@ -22,4 +19,3 @@ class CommitMessageCreator {
|
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.CommitMessageCreator = CommitMessageCreator;
|
package/dist/src/git/Git.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Git = void 0;
|
|
4
|
-
class Git {
|
|
1
|
+
export class Git {
|
|
5
2
|
terminal;
|
|
6
3
|
constructor(terminal) {
|
|
7
4
|
this.terminal = terminal;
|
|
@@ -35,4 +32,3 @@ class Git {
|
|
|
35
32
|
await this.terminal.run('git', 'checkout', branchName);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.Git = Git;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GitConfigInitializer = void 0;
|
|
4
|
-
class GitConfigInitializer {
|
|
1
|
+
export class GitConfigInitializer {
|
|
5
2
|
options;
|
|
6
3
|
git;
|
|
7
4
|
constructor({ options, git }) {
|
|
@@ -17,4 +14,3 @@ class GitConfigInitializer {
|
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.GitConfigInitializer = GitConfigInitializer;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GitRepository = void 0;
|
|
7
|
-
const node_url_1 = require("node:url");
|
|
8
|
-
const parse_github_url_1 = __importDefault(require("parse-github-url"));
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
import gh from 'parse-github-url';
|
|
9
3
|
const HOST_GITHUB = 'github.com';
|
|
10
|
-
class GitRepository {
|
|
4
|
+
export class GitRepository {
|
|
11
5
|
url;
|
|
12
6
|
owner;
|
|
13
7
|
name;
|
|
@@ -35,7 +29,7 @@ class GitRepository {
|
|
|
35
29
|
* - `git@<host>:<owner>/<repo>.git`
|
|
36
30
|
*/
|
|
37
31
|
static of(repository) {
|
|
38
|
-
const result = (
|
|
32
|
+
const result = gh(repository);
|
|
39
33
|
if (result === null) {
|
|
40
34
|
return undefined;
|
|
41
35
|
}
|
|
@@ -51,11 +45,10 @@ class GitRepository {
|
|
|
51
45
|
return undefined;
|
|
52
46
|
}
|
|
53
47
|
return new GitRepository({
|
|
54
|
-
url: new
|
|
48
|
+
url: new URL(`https://${host}/${owner}/${name}`),
|
|
55
49
|
owner,
|
|
56
50
|
name,
|
|
57
51
|
isGitHub: host === HOST_GITHUB
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
|
-
exports.GitRepository = GitRepository;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GitTransaction = void 0;
|
|
4
|
-
const logger_1 = require("../logger");
|
|
1
|
+
import { logger } from '../logger/logger.js';
|
|
5
2
|
// TODO: Add test
|
|
6
|
-
class GitTransaction {
|
|
3
|
+
export class GitTransaction {
|
|
7
4
|
git;
|
|
8
5
|
branchName;
|
|
9
6
|
files;
|
|
@@ -14,7 +11,7 @@ class GitTransaction {
|
|
|
14
11
|
}
|
|
15
12
|
async run(operation) {
|
|
16
13
|
await this.git.createBranch(this.branchName);
|
|
17
|
-
|
|
14
|
+
logger.info(`${this.branchName} branch has created.`);
|
|
18
15
|
try {
|
|
19
16
|
return await operation({
|
|
20
17
|
git: this.git,
|
|
@@ -30,7 +27,6 @@ class GitTransaction {
|
|
|
30
27
|
await this.git.restore(...this.files);
|
|
31
28
|
await this.git.switch('-');
|
|
32
29
|
await this.git.removeBranch(this.branchName);
|
|
33
|
-
|
|
30
|
+
logger.info(`${this.branchName} branch has removed.`);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
exports.GitTransaction = GitTransaction;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBranchName = void 0;
|
|
4
|
-
const createBranchName = (outdatedPackage) => {
|
|
1
|
+
export const createBranchName = (outdatedPackage) => {
|
|
5
2
|
const packageName = outdatedPackage.name;
|
|
6
3
|
const newVersion = outdatedPackage.newVersion.version;
|
|
7
4
|
return `npm-update-package/${packageName}/v${newVersion}`;
|
|
8
5
|
};
|
|
9
|
-
exports.createBranchName = createBranchName;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GitHub = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
class GitHub {
|
|
1
|
+
import { range } from '../util/range.js';
|
|
2
|
+
export class GitHub {
|
|
6
3
|
octokit;
|
|
7
4
|
constructor(octokit) {
|
|
8
5
|
this.octokit = octokit;
|
|
@@ -61,7 +58,7 @@ class GitHub {
|
|
|
61
58
|
}
|
|
62
59
|
async fetchBranches({ owner, repo }) {
|
|
63
60
|
const branches = [];
|
|
64
|
-
for (const page of
|
|
61
|
+
for (const page of range(1, 11)) {
|
|
65
62
|
const { data } = await this.octokit.repos.listBranches({
|
|
66
63
|
owner,
|
|
67
64
|
repo,
|
|
@@ -85,7 +82,7 @@ class GitHub {
|
|
|
85
82
|
}
|
|
86
83
|
async fetchPullRequests({ owner, repo }) {
|
|
87
84
|
const pullRequests = [];
|
|
88
|
-
for (const page of
|
|
85
|
+
for (const page of range(1, 11)) {
|
|
89
86
|
const { data } = await this.octokit.pulls.list({
|
|
90
87
|
owner,
|
|
91
88
|
repo,
|
|
@@ -117,4 +114,3 @@ class GitHub {
|
|
|
117
114
|
await this.octokit.pulls.requestReviewers(params);
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
|
-
exports.GitHub = GitHub;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BranchFinder = void 0;
|
|
4
|
-
class BranchFinder {
|
|
1
|
+
export class BranchFinder {
|
|
5
2
|
branches;
|
|
6
3
|
constructor(branches) {
|
|
7
4
|
this.branches = branches;
|
|
@@ -10,4 +7,3 @@ class BranchFinder {
|
|
|
10
7
|
return this.branches.find(({ name }) => name === branchName);
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
|
-
exports.BranchFinder = BranchFinder;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const GitHub_1 = require("./GitHub");
|
|
6
|
-
const createGitHub = ({ host, token }) => {
|
|
7
|
-
const octokit = (0, createOctokit_1.createOctokit)({
|
|
1
|
+
import { createOctokit } from './createOctokit.js';
|
|
2
|
+
import { GitHub } from './GitHub.js';
|
|
3
|
+
export const createGitHub = ({ host, token }) => {
|
|
4
|
+
const octokit = createOctokit({
|
|
8
5
|
host,
|
|
9
6
|
token
|
|
10
7
|
});
|
|
11
|
-
return new
|
|
8
|
+
return new GitHub(octokit);
|
|
12
9
|
};
|
|
13
|
-
exports.createGitHub = createGitHub;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createOctokit = void 0;
|
|
7
|
-
const rest_1 = require("@octokit/rest");
|
|
8
|
-
const package_json_1 = __importDefault(require("../../package.json"));
|
|
9
|
-
const createOctokit = ({ host, token }) => {
|
|
10
|
-
const userAgent = `${package_json_1.default.name}/${package_json_1.default.version}`;
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import pkg from '../../package.json';
|
|
3
|
+
export const createOctokit = ({ host, token }) => {
|
|
4
|
+
const userAgent = `${pkg.name}/${pkg.version}`;
|
|
11
5
|
if (token === undefined) {
|
|
12
|
-
return new
|
|
6
|
+
return new Octokit({
|
|
13
7
|
userAgent
|
|
14
8
|
});
|
|
15
9
|
}
|
|
16
10
|
const auth = `token ${token}`;
|
|
17
11
|
if (host === 'github.com') {
|
|
18
|
-
return new
|
|
12
|
+
return new Octokit({
|
|
19
13
|
auth,
|
|
20
14
|
userAgent
|
|
21
15
|
});
|
|
22
16
|
}
|
|
23
|
-
return new
|
|
17
|
+
return new Octokit({
|
|
24
18
|
auth,
|
|
25
19
|
userAgent,
|
|
26
20
|
baseUrl: `https://${host}/api/v3`
|
|
27
21
|
});
|
|
28
22
|
};
|
|
29
|
-
exports.createOctokit = createOctokit;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
6
|
-
const isNotFoundError = (value) => {
|
|
7
|
-
return value instanceof request_error_1.RequestError && value.status === http_status_codes_1.StatusCodes.NOT_FOUND;
|
|
1
|
+
import { RequestError } from '@octokit/request-error';
|
|
2
|
+
import { StatusCodes } from 'http-status-codes';
|
|
3
|
+
export const isNotFoundError = (value) => {
|
|
4
|
+
return value instanceof RequestError && value.status === StatusCodes.NOT_FOUND;
|
|
8
5
|
};
|
|
9
|
-
exports.isNotFoundError = isNotFoundError;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LabelCreator = void 0;
|
|
4
|
-
const logger_1 = require("../../../logger");
|
|
5
|
-
const errors_1 = require("../../errors");
|
|
1
|
+
import { logger } from '../../../logger/logger.js';
|
|
2
|
+
import { isNotFoundError } from '../../errors/NotFoundError.js';
|
|
6
3
|
// TODO: Split into multiple classes and functions
|
|
7
|
-
class LabelCreator {
|
|
4
|
+
export class LabelCreator {
|
|
8
5
|
github;
|
|
9
6
|
gitRepo;
|
|
10
7
|
constructor({ github, gitRepo }) {
|
|
@@ -14,7 +11,7 @@ class LabelCreator {
|
|
|
14
11
|
async create({ name, description, color }) {
|
|
15
12
|
const label = await this.fetchLabel(name);
|
|
16
13
|
if (label !== undefined) {
|
|
17
|
-
|
|
14
|
+
logger.info(`Skip creating ${name} label because it already exists.`);
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
17
|
await this.createLabel({
|
|
@@ -22,7 +19,7 @@ class LabelCreator {
|
|
|
22
19
|
description,
|
|
23
20
|
color
|
|
24
21
|
});
|
|
25
|
-
|
|
22
|
+
logger.info(`${name} label has created.`);
|
|
26
23
|
}
|
|
27
24
|
async createLabel({ name, description, color }) {
|
|
28
25
|
await this.github.createLabel({
|
|
@@ -42,8 +39,8 @@ class LabelCreator {
|
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
catch (error) {
|
|
45
|
-
if (
|
|
46
|
-
|
|
42
|
+
if (isNotFoundError(error)) {
|
|
43
|
+
logger.warn(error);
|
|
47
44
|
return undefined;
|
|
48
45
|
}
|
|
49
46
|
else {
|
|
@@ -52,4 +49,3 @@ class LabelCreator {
|
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
exports.LabelCreator = LabelCreator;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PullRequestCloser = void 0;
|
|
4
|
-
class PullRequestCloser {
|
|
1
|
+
export class PullRequestCloser {
|
|
5
2
|
github;
|
|
6
3
|
constructor(github) {
|
|
7
4
|
this.github = github;
|
|
@@ -21,4 +18,3 @@ class PullRequestCloser {
|
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.PullRequestCloser = PullRequestCloser;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PullRequestsCloser = void 0;
|
|
4
|
-
const logger_1 = require("../../../logger");
|
|
5
|
-
class PullRequestsCloser {
|
|
1
|
+
import { logger } from '../../../logger/logger.js';
|
|
2
|
+
export class PullRequestsCloser {
|
|
6
3
|
pullRequestCloser;
|
|
7
4
|
constructor(pullRequestCloser) {
|
|
8
5
|
this.pullRequestCloser = pullRequestCloser;
|
|
@@ -10,8 +7,7 @@ class PullRequestsCloser {
|
|
|
10
7
|
async close(pullRequests) {
|
|
11
8
|
await Promise.all(pullRequests.map(async (pullRequest) => {
|
|
12
9
|
await this.pullRequestCloser.close(pullRequest);
|
|
13
|
-
|
|
10
|
+
logger.info(`Pull request #${pullRequest.number} has closed. ${pullRequest.html_url}`);
|
|
14
11
|
}));
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.PullRequestsCloser = PullRequestsCloser;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AssigneesAdder = void 0;
|
|
4
|
-
const util_1 = require("../../../util");
|
|
5
|
-
class AssigneesAdder {
|
|
1
|
+
import { sampleSize } from '../../../util/sampleSize.js';
|
|
2
|
+
export class AssigneesAdder {
|
|
6
3
|
github;
|
|
7
4
|
gitRepo;
|
|
8
5
|
constructor({ github, gitRepo }) {
|
|
@@ -14,8 +11,7 @@ class AssigneesAdder {
|
|
|
14
11
|
owner: this.gitRepo.owner,
|
|
15
12
|
repo: this.gitRepo.name,
|
|
16
13
|
issueNumber,
|
|
17
|
-
assignees: size === undefined ? assignees :
|
|
14
|
+
assignees: size === undefined ? assignees : sampleSize(assignees, size)
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.AssigneesAdder = AssigneesAdder;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GitHubUrlOptimizer = void 0;
|
|
4
|
-
const node_url_1 = require("node:url");
|
|
5
|
-
class GitHubUrlOptimizer {
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
export class GitHubUrlOptimizer {
|
|
6
3
|
options;
|
|
7
4
|
constructor(options) {
|
|
8
5
|
this.options = options;
|
|
@@ -11,11 +8,10 @@ class GitHubUrlOptimizer {
|
|
|
11
8
|
* Convert URL to prevent linking to other repositories.
|
|
12
9
|
*/
|
|
13
10
|
optimize(url) {
|
|
14
|
-
const newUrl = url instanceof
|
|
11
|
+
const newUrl = url instanceof URL ? url : new URL(url);
|
|
15
12
|
if (newUrl.host === 'github.com') {
|
|
16
13
|
newUrl.host = this.options.prBodyGithubHost;
|
|
17
14
|
}
|
|
18
15
|
return newUrl;
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.GitHubUrlOptimizer = GitHubUrlOptimizer;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LabelsAdder = void 0;
|
|
4
1
|
const DEFAULT_LABELS = ['npm-update-package'];
|
|
5
|
-
class LabelsAdder {
|
|
2
|
+
export class LabelsAdder {
|
|
6
3
|
options;
|
|
7
4
|
github;
|
|
8
5
|
gitRepo;
|
|
@@ -21,4 +18,3 @@ class LabelsAdder {
|
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.LabelsAdder = LabelsAdder;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageDiffsSectionCreator = void 0;
|
|
4
|
-
class PackageDiffsSectionCreator {
|
|
1
|
+
export class PackageDiffsSectionCreator {
|
|
5
2
|
gitHubUrlOptimizer;
|
|
6
3
|
constructor(gitHubUrlOptimizer) {
|
|
7
4
|
this.gitHubUrlOptimizer = gitHubUrlOptimizer;
|
|
@@ -22,4 +19,3 @@ class PackageDiffsSectionCreator {
|
|
|
22
19
|
${links.join('\n')}`;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.PackageDiffsSectionCreator = PackageDiffsSectionCreator;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const createNotesSection_1 = require("./createNotesSection");
|
|
9
|
-
const createOutdatedPackagesTable_1 = require("./createOutdatedPackagesTable");
|
|
1
|
+
import { readFile } from '../../../file/readFile.js';
|
|
2
|
+
import { extractRepository } from '../../../package-json/extractRepository.js';
|
|
3
|
+
import { parsePackageJson } from '../../../package-json/parsePackageJson.js';
|
|
4
|
+
import { createFooter } from './createFooter.js';
|
|
5
|
+
import { createMetadataSection } from './createMetadataSection.js';
|
|
6
|
+
import { createNotesSection } from './createNotesSection.js';
|
|
7
|
+
import { createOutdatedPackagesTable } from './createOutdatedPackagesTable.js';
|
|
10
8
|
// TODO: Split into multiple classes and functions
|
|
11
|
-
class PullRequestBodyCreator {
|
|
9
|
+
export class PullRequestBodyCreator {
|
|
12
10
|
options;
|
|
13
11
|
releasesFetcher;
|
|
14
12
|
packageDiffsSectionCreator;
|
|
@@ -21,7 +19,7 @@ class PullRequestBodyCreator {
|
|
|
21
19
|
}
|
|
22
20
|
async create(outdatedPackage) {
|
|
23
21
|
const sections = [];
|
|
24
|
-
const outdatedPackagesTable =
|
|
22
|
+
const outdatedPackagesTable = createOutdatedPackagesTable(outdatedPackage);
|
|
25
23
|
sections.push(`This PR updates these packages:\n\n${outdatedPackagesTable}`);
|
|
26
24
|
const gitRepo = await this.extractRepository(outdatedPackage);
|
|
27
25
|
const diffSection = this.packageDiffsSectionCreator.create({
|
|
@@ -42,19 +40,18 @@ class PullRequestBodyCreator {
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
if (this.options.prBodyNotes !== undefined) {
|
|
45
|
-
const notesSection =
|
|
43
|
+
const notesSection = createNotesSection(this.options.prBodyNotes);
|
|
46
44
|
sections.push(notesSection);
|
|
47
45
|
}
|
|
48
|
-
const metadataSection =
|
|
46
|
+
const metadataSection = createMetadataSection(outdatedPackage);
|
|
49
47
|
sections.push(`---\n${metadataSection}`);
|
|
50
|
-
const footer =
|
|
48
|
+
const footer = createFooter();
|
|
51
49
|
sections.push(`---\n${footer}`);
|
|
52
50
|
return sections.join('\n\n');
|
|
53
51
|
}
|
|
54
52
|
async extractRepository(outdatedPackage) {
|
|
55
|
-
const packageJson = await
|
|
56
|
-
const pkg =
|
|
57
|
-
return
|
|
53
|
+
const packageJson = await readFile(`node_modules/${outdatedPackage.name}/package.json`);
|
|
54
|
+
const pkg = parsePackageJson(packageJson);
|
|
55
|
+
return extractRepository(pkg);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
exports.PullRequestBodyCreator = PullRequestBodyCreator;
|