npm-update-package 0.7.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -20
- package/dist/app.js +1 -1
- package/dist/git/index.js +1 -3
- package/dist/github/PullRequestBodyCreator.js +29 -0
- package/dist/github/PullRequestCreator.js +3 -3
- package/dist/github/RemoteBranchExistenceChecker.js +0 -1
- package/dist/github/index.js +3 -1
- package/dist/main.js +2 -8
- package/dist/options/Options.js +9 -14
- package/dist/options/initOptions.js +8 -2
- package/dist/processors/OutdatedPackageProcessor.js +2 -3
- package/package.json +14 -9
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -23
- package/.github/FUNDING.yml +0 -2
- package/.github/renovate.json +0 -15
- package/.github/workflows/eslint.yml +0 -14
- package/.github/workflows/test.yml +0 -19
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/dist/git/Committer.js +0 -31
- package/dist/github/createPullRequestBody.js +0 -19
- package/jest.config.ts +0 -11
- package/lint-staged.config.js +0 -4
- package/npm-update-package.code-workspace +0 -8
- package/src/app.ts +0 -5
- package/src/bin.ts +0 -20
- package/src/git/BranchNameCreator.test.ts +0 -17
- package/src/git/BranchNameCreator.ts +0 -19
- package/src/git/CommitMessageCreator.test.ts +0 -17
- package/src/git/CommitMessageCreator.ts +0 -19
- package/src/git/Committer.ts +0 -49
- package/src/git/Git.ts +0 -55
- package/src/git/GitRepository.test.ts +0 -61
- package/src/git/GitRepository.ts +0 -57
- package/src/git/index.ts +0 -5
- package/src/github/Branch.ts +0 -4
- package/src/github/GitHub.ts +0 -27
- package/src/github/PullRequest.ts +0 -3
- package/src/github/PullRequestCreator.ts +0 -61
- package/src/github/PullRequestTitleCreator.test.ts +0 -17
- package/src/github/PullRequestTitleCreator.ts +0 -19
- package/src/github/RemoteBranchExistenceChecker.ts +0 -15
- package/src/github/Repository.ts +0 -3
- package/src/github/createGitHub.ts +0 -18
- package/src/github/createOctokit.ts +0 -28
- package/src/github/createPullRequestBody.test.ts +0 -64
- package/src/github/createPullRequestBody.ts +0 -17
- package/src/github/index.ts +0 -8
- package/src/logger/LogLevel.ts +0 -8
- package/src/logger/Logger.ts +0 -1
- package/src/logger/createLogger.ts +0 -10
- package/src/logger/index.ts +0 -6
- package/src/main.ts +0 -125
- package/src/ncu/Ncu.ts +0 -43
- package/src/ncu/NcuOutdatedPackages.ts +0 -6
- package/src/ncu/NcuOutdatedPackagesConverter.ts +0 -25
- package/src/ncu/OutdatedPackage.ts +0 -9
- package/src/ncu/PackageVersion.test.ts +0 -25
- package/src/ncu/PackageVersion.ts +0 -40
- package/src/ncu/UpdateType.ts +0 -9
- package/src/ncu/index.ts +0 -7
- package/src/ncu/isNcuOutdatedPackages.ts +0 -6
- package/src/ncu/toUpdateType.test.ts +0 -21
- package/src/ncu/toUpdateType.ts +0 -18
- package/src/options/Options.ts +0 -29
- package/src/options/index.ts +0 -2
- package/src/options/initOptions.ts +0 -45
- package/src/package-json/Package.ts +0 -24
- package/src/package-json/PackageDependencies.ts +0 -10
- package/src/package-json/PackageJsonParser.ts +0 -19
- package/src/package-json/PackageJsonReader.ts +0 -27
- package/src/package-json/index.ts +0 -3
- package/src/package-manager/Npm.ts +0 -19
- package/src/package-manager/PackageManager.ts +0 -4
- package/src/package-manager/PackageManagerName.ts +0 -8
- package/src/package-manager/Yarn.ts +0 -19
- package/src/package-manager/createPackageManager.ts +0 -21
- package/src/package-manager/index.ts +0 -8
- package/src/processors/OutdatedPackageProcessor.ts +0 -109
- package/src/processors/OutdatedPackagesProcessor.ts +0 -32
- package/src/processors/Result.ts +0 -7
- package/src/processors/index.ts +0 -2
- package/src/terminal/Terminal.ts +0 -30
- package/src/terminal/index.ts +0 -1
- package/src/terminal/isExecaReturnValue.ts +0 -30
- package/tsconfig.base.json +0 -3
- package/tsconfig.build.json +0 -13
- package/tsconfig.json +0 -9
|
@@ -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
|
-
}
|
package/src/git/Committer.ts
DELETED
|
@@ -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
|
-
}
|
package/src/git/Git.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Terminal } from '../terminal'
|
|
2
|
-
import { GitRepository } from './GitRepository'
|
|
3
|
-
|
|
4
|
-
// TODO: add test
|
|
5
|
-
export class Git {
|
|
6
|
-
constructor (private readonly terminal: Terminal) {}
|
|
7
|
-
|
|
8
|
-
async add (...files: string[]): Promise<void> {
|
|
9
|
-
await this.terminal.run('git', 'add', ...files)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async checkout (branchName: string): Promise<void> {
|
|
13
|
-
await this.terminal.run('git', 'checkout', branchName)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async commit (message: string): Promise<void> {
|
|
17
|
-
await this.terminal.run('git', 'commit', '--message', message)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async createBranch (branchName: string): Promise<void> {
|
|
21
|
-
await this.terminal.run('git', 'checkout', '-b', branchName)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async getConfig (key: string): Promise<string> {
|
|
25
|
-
const { stdout } = await this.terminal.run('git', 'config', key)
|
|
26
|
-
return stdout.trim()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async getCurrentBranch (): Promise<string> {
|
|
30
|
-
const { stdout } = await this.terminal.run('git', 'rev-parse', '--abbrev-ref', 'HEAD')
|
|
31
|
-
return stdout.trim()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async getRemoteUrl (): Promise<string> {
|
|
35
|
-
const { stdout } = await this.terminal.run('git', 'remote', 'get-url', '--push', 'origin')
|
|
36
|
-
return stdout.trim()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async getRepository (): Promise<GitRepository> {
|
|
40
|
-
const url = await this.getRemoteUrl()
|
|
41
|
-
return GitRepository.of(url)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async push (branchName: string): Promise<void> {
|
|
45
|
-
await this.terminal.run('git', 'push', 'origin', branchName)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async removeBranch (branchName: string): Promise<void> {
|
|
49
|
-
await this.terminal.run('git', 'branch', '-D', branchName)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async setConfig (key: string, value: string): Promise<void> {
|
|
53
|
-
await this.terminal.run('git', 'config', key, value)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { GitRepository } from './GitRepository'
|
|
2
|
-
|
|
3
|
-
describe('GitRepository', () => {
|
|
4
|
-
describe('of', () => {
|
|
5
|
-
describe('if URL is HTTPS', () => {
|
|
6
|
-
describe('if URL is github.com', () => {
|
|
7
|
-
const url = 'https://github.com/npm-update-package/npm-update-package.git'
|
|
8
|
-
|
|
9
|
-
it('returns new GitRepository instance', () => {
|
|
10
|
-
const repo = GitRepository.of(url)
|
|
11
|
-
expect(repo.host).toBe('github.com')
|
|
12
|
-
expect(repo.owner).toBe('npm-update-package')
|
|
13
|
-
expect(repo.name).toBe('npm-update-package')
|
|
14
|
-
expect(repo.apiEndPoint).toBe('https://api.github.com')
|
|
15
|
-
expect(repo.isGitHubDotCom).toBe(true)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('if URL is not github.com', () => {
|
|
20
|
-
const url = 'https://git.example.com/npm-update-package/npm-update-package.git'
|
|
21
|
-
|
|
22
|
-
it('returns new GitRepository instance', () => {
|
|
23
|
-
const repo = GitRepository.of(url)
|
|
24
|
-
expect(repo.host).toBe('git.example.com')
|
|
25
|
-
expect(repo.owner).toBe('npm-update-package')
|
|
26
|
-
expect(repo.name).toBe('npm-update-package')
|
|
27
|
-
expect(repo.apiEndPoint).toBe('https://git.example.com/api/v3')
|
|
28
|
-
expect(repo.isGitHubDotCom).toBe(false)
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
describe('if URL is SSH', () => {
|
|
34
|
-
describe('if URL is github.com', () => {
|
|
35
|
-
const url = 'git@github.com:npm-update-package/npm-update-package.git'
|
|
36
|
-
|
|
37
|
-
it('returns new GitRepository instance', () => {
|
|
38
|
-
const repo = GitRepository.of(url)
|
|
39
|
-
expect(repo.host).toBe('github.com')
|
|
40
|
-
expect(repo.owner).toBe('npm-update-package')
|
|
41
|
-
expect(repo.name).toBe('npm-update-package')
|
|
42
|
-
expect(repo.apiEndPoint).toBe('https://api.github.com')
|
|
43
|
-
expect(repo.isGitHubDotCom).toBe(true)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe('if URL is not github.com', () => {
|
|
48
|
-
const url = 'git@git.example.com:npm-update-package/npm-update-package.git'
|
|
49
|
-
|
|
50
|
-
it('returns new GitRepository instance', () => {
|
|
51
|
-
const repo = GitRepository.of(url)
|
|
52
|
-
expect(repo.host).toBe('git.example.com')
|
|
53
|
-
expect(repo.owner).toBe('npm-update-package')
|
|
54
|
-
expect(repo.name).toBe('npm-update-package')
|
|
55
|
-
expect(repo.apiEndPoint).toBe('https://git.example.com/api/v3')
|
|
56
|
-
expect(repo.isGitHubDotCom).toBe(false)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
})
|
package/src/git/GitRepository.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import parse from 'parse-github-url'
|
|
2
|
-
|
|
3
|
-
export class GitRepository {
|
|
4
|
-
readonly host: string
|
|
5
|
-
readonly owner: string
|
|
6
|
-
readonly name: string
|
|
7
|
-
|
|
8
|
-
private constructor ({
|
|
9
|
-
host,
|
|
10
|
-
owner,
|
|
11
|
-
name
|
|
12
|
-
}: {
|
|
13
|
-
host: string
|
|
14
|
-
owner: string
|
|
15
|
-
name: string
|
|
16
|
-
}) {
|
|
17
|
-
this.host = host
|
|
18
|
-
this.owner = owner
|
|
19
|
-
this.name = name
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static of (url: string): GitRepository {
|
|
23
|
-
const parsed = parse(url)
|
|
24
|
-
|
|
25
|
-
if (parsed === null) {
|
|
26
|
-
throw new Error(`Failed to parse url. url=${url}`)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
host,
|
|
31
|
-
owner,
|
|
32
|
-
name
|
|
33
|
-
} = parsed
|
|
34
|
-
|
|
35
|
-
if (host === null || owner === null || name === null) {
|
|
36
|
-
throw new Error(`Failed to parse url. url=${url}`)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return new GitRepository({
|
|
40
|
-
host,
|
|
41
|
-
owner,
|
|
42
|
-
name
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get apiEndPoint (): string {
|
|
47
|
-
if (this.isGitHubDotCom) {
|
|
48
|
-
return 'https://api.github.com'
|
|
49
|
-
} else {
|
|
50
|
-
return `https://${this.host}/api/v3`
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get isGitHubDotCom (): boolean {
|
|
55
|
-
return this.host === 'github.com'
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/git/index.ts
DELETED
package/src/github/Branch.ts
DELETED
package/src/github/GitHub.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Octokit,
|
|
3
|
-
RestEndpointMethodTypes
|
|
4
|
-
} from '@octokit/rest'
|
|
5
|
-
import type { Branch } from './Branch'
|
|
6
|
-
import type { PullRequest } from './PullRequest'
|
|
7
|
-
import type { Repository } from './Repository'
|
|
8
|
-
|
|
9
|
-
// TODO: add test
|
|
10
|
-
export class GitHub {
|
|
11
|
-
constructor (private readonly octokit: Octokit) {}
|
|
12
|
-
|
|
13
|
-
async createPullRequest (params: RestEndpointMethodTypes['pulls']['create']['parameters']): Promise<PullRequest> {
|
|
14
|
-
const { data } = await this.octokit.pulls.create(params)
|
|
15
|
-
return data
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async fetchBranches (params: RestEndpointMethodTypes['repos']['listBranches']['parameters']): Promise<Branch[]> {
|
|
19
|
-
const { data } = await this.octokit.repos.listBranches(params)
|
|
20
|
-
return data
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async fetchRepository (params: RestEndpointMethodTypes['repos']['get']['parameters']): Promise<Repository> {
|
|
24
|
-
const { data } = await this.octokit.repos.get(params)
|
|
25
|
-
return data
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { GitRepository } from '../git'
|
|
2
|
-
import type { Logger } from '../logger'
|
|
3
|
-
import type { OutdatedPackage } from '../ncu'
|
|
4
|
-
import { createPullRequestBody } from './createPullRequestBody'
|
|
5
|
-
import type { GitHub } from './GitHub'
|
|
6
|
-
import type { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
7
|
-
import type { Repository as GitHubRepository } from './Repository'
|
|
8
|
-
|
|
9
|
-
// TODO: add test
|
|
10
|
-
export class PullRequestCreator {
|
|
11
|
-
private readonly github: GitHub
|
|
12
|
-
private readonly gitRepo: GitRepository
|
|
13
|
-
private readonly githubRepo: GitHubRepository
|
|
14
|
-
private readonly pullRequestTitleCreator: PullRequestTitleCreator
|
|
15
|
-
private readonly logger: Logger
|
|
16
|
-
|
|
17
|
-
constructor ({
|
|
18
|
-
github,
|
|
19
|
-
gitRepo,
|
|
20
|
-
githubRepo,
|
|
21
|
-
pullRequestTitleCreator,
|
|
22
|
-
logger
|
|
23
|
-
}: {
|
|
24
|
-
github: GitHub
|
|
25
|
-
gitRepo: GitRepository
|
|
26
|
-
githubRepo: GitHubRepository
|
|
27
|
-
pullRequestTitleCreator: PullRequestTitleCreator
|
|
28
|
-
logger: Logger
|
|
29
|
-
}) {
|
|
30
|
-
this.github = github
|
|
31
|
-
this.gitRepo = gitRepo
|
|
32
|
-
this.githubRepo = githubRepo
|
|
33
|
-
this.pullRequestTitleCreator = pullRequestTitleCreator
|
|
34
|
-
this.logger = logger
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async create ({
|
|
38
|
-
outdatedPackage,
|
|
39
|
-
branchName
|
|
40
|
-
}: {
|
|
41
|
-
outdatedPackage: OutdatedPackage
|
|
42
|
-
branchName: string
|
|
43
|
-
}): Promise<void> {
|
|
44
|
-
const title = this.pullRequestTitleCreator.create(outdatedPackage)
|
|
45
|
-
this.logger.debug(`title=${title}`)
|
|
46
|
-
|
|
47
|
-
const body = createPullRequestBody(outdatedPackage)
|
|
48
|
-
this.logger.debug(`body=${body}`)
|
|
49
|
-
|
|
50
|
-
const createdPullRequest = await this.github.createPullRequest({
|
|
51
|
-
owner: this.gitRepo.owner,
|
|
52
|
-
repo: this.gitRepo.name,
|
|
53
|
-
base: this.githubRepo.default_branch,
|
|
54
|
-
head: branchName,
|
|
55
|
-
title,
|
|
56
|
-
body
|
|
57
|
-
})
|
|
58
|
-
this.logger.debug(`createdPullRequest=${JSON.stringify(createdPullRequest)}`)
|
|
59
|
-
this.logger.info(`Pull request for ${outdatedPackage.name} has created. ${createdPullRequest.html_url}`)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageVersion } from '../ncu'
|
|
2
|
-
import { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
3
|
-
|
|
4
|
-
describe('PullRequestTitleCreator', () => {
|
|
5
|
-
describe('create', () => {
|
|
6
|
-
it('returns commit message', () => {
|
|
7
|
-
const pullRequestTitleCreator = new PullRequestTitleCreator('chore(deps): {{updateType}} update {{{packageName}}} from {{currentVersion}} to v{{newVersion}}')
|
|
8
|
-
const actual = pullRequestTitleCreator.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 PullRequestTitleCreator {
|
|
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,15 +0,0 @@
|
|
|
1
|
-
import type { Branch } from './Branch'
|
|
2
|
-
|
|
3
|
-
// TODO: add test
|
|
4
|
-
export class RemoteBranchExistenceChecker {
|
|
5
|
-
constructor (private readonly remoteBranchNames: string[]) {}
|
|
6
|
-
|
|
7
|
-
static of (remoteBranches: Branch[]): RemoteBranchExistenceChecker {
|
|
8
|
-
const remoteBranchNames = remoteBranches.map(({ name }) => name)
|
|
9
|
-
return new RemoteBranchExistenceChecker(remoteBranchNames)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
check (branchName: string): boolean {
|
|
13
|
-
return this.remoteBranchNames.includes(branchName)
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/github/Repository.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { GitRepository } from '../git'
|
|
2
|
-
import { createOctokit } from './createOctokit'
|
|
3
|
-
import { GitHub } from './GitHub'
|
|
4
|
-
|
|
5
|
-
// TODO: add test
|
|
6
|
-
export const createGitHub = ({
|
|
7
|
-
repository,
|
|
8
|
-
token
|
|
9
|
-
}: {
|
|
10
|
-
repository: GitRepository
|
|
11
|
-
token: string
|
|
12
|
-
}): GitHub => {
|
|
13
|
-
const octokit = createOctokit({
|
|
14
|
-
repository,
|
|
15
|
-
token
|
|
16
|
-
})
|
|
17
|
-
return new GitHub(octokit)
|
|
18
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Octokit } from '@octokit/rest'
|
|
2
|
-
import { app } from '../app'
|
|
3
|
-
import type { GitRepository } from '../git'
|
|
4
|
-
|
|
5
|
-
// TODO: add test
|
|
6
|
-
export const createOctokit = ({
|
|
7
|
-
repository,
|
|
8
|
-
token
|
|
9
|
-
}: {
|
|
10
|
-
repository: GitRepository
|
|
11
|
-
token: string
|
|
12
|
-
}): Octokit => {
|
|
13
|
-
const auth = `token ${token}`
|
|
14
|
-
const userAgent = `${app.name}/${app.version}`
|
|
15
|
-
|
|
16
|
-
if (repository.isGitHubDotCom) {
|
|
17
|
-
return new Octokit({
|
|
18
|
-
auth,
|
|
19
|
-
userAgent
|
|
20
|
-
})
|
|
21
|
-
} else {
|
|
22
|
-
return new Octokit({
|
|
23
|
-
auth,
|
|
24
|
-
userAgent,
|
|
25
|
-
baseUrl: repository.apiEndPoint
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PackageVersion,
|
|
3
|
-
UpdateType
|
|
4
|
-
} from '../ncu'
|
|
5
|
-
import { createPullRequestBody } from './createPullRequestBody'
|
|
6
|
-
|
|
7
|
-
describe('createPullRequestBody', () => {
|
|
8
|
-
describe('if update type is patch', () => {
|
|
9
|
-
it('returns pull request body', () => {
|
|
10
|
-
const actual = createPullRequestBody({
|
|
11
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
12
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
13
|
-
newVersion: PackageVersion.of('1.0.1'),
|
|
14
|
-
type: UpdateType.Patch
|
|
15
|
-
})
|
|
16
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
17
|
-
|
|
18
|
-
|package|type|current version|new version|
|
|
19
|
-
|---|---|---|---|
|
|
20
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|patch|\`1.0.0\`|\`1.0.1\`|
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
describe('if update type is minor', () => {
|
|
28
|
-
it('returns pull request body', () => {
|
|
29
|
-
const actual = createPullRequestBody({
|
|
30
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
31
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
32
|
-
newVersion: PackageVersion.of('1.1.0'),
|
|
33
|
-
type: UpdateType.Minor
|
|
34
|
-
})
|
|
35
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
36
|
-
|
|
37
|
-
|package|type|current version|new version|
|
|
38
|
-
|---|---|---|---|
|
|
39
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|minor|\`1.0.0\`|\`1.1.0\`|
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
describe('if update type is major', () => {
|
|
47
|
-
it('returns pull request body', () => {
|
|
48
|
-
const actual = createPullRequestBody({
|
|
49
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
50
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
51
|
-
newVersion: PackageVersion.of('2.0.0'),
|
|
52
|
-
type: UpdateType.Major
|
|
53
|
-
})
|
|
54
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
55
|
-
|
|
56
|
-
|package|type|current version|new version|
|
|
57
|
-
|---|---|---|---|
|
|
58
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|major|\`1.0.0\`|\`2.0.0\`|
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { app } from '../app'
|
|
2
|
-
import type { OutdatedPackage } from '../ncu'
|
|
3
|
-
|
|
4
|
-
export const createPullRequestBody = (outdatedPackage: OutdatedPackage): string => {
|
|
5
|
-
const packageName = outdatedPackage.name
|
|
6
|
-
const currentVersion = outdatedPackage.currentVersion.version
|
|
7
|
-
const newVersion = outdatedPackage.newVersion.version
|
|
8
|
-
const updateType = outdatedPackage.type
|
|
9
|
-
return `This PR updates these packages:
|
|
10
|
-
|
|
11
|
-
|package|type|current version|new version|
|
|
12
|
-
|---|---|---|---|
|
|
13
|
-
|[${packageName}](https://www.npmjs.com/package/${packageName})|${updateType}|\`${currentVersion}\`|\`${newVersion}\`|
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
This PR has been generated by [${app.name}](${app.web})`
|
|
17
|
-
}
|
package/src/github/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type { Branch } from './Branch'
|
|
2
|
-
export { createGitHub } from './createGitHub'
|
|
3
|
-
export { GitHub } from './GitHub'
|
|
4
|
-
export type { PullRequest } from './PullRequest'
|
|
5
|
-
export { PullRequestCreator } from './PullRequestCreator'
|
|
6
|
-
export { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
7
|
-
export { RemoteBranchExistenceChecker } from './RemoteBranchExistenceChecker'
|
|
8
|
-
export type { Repository } from './Repository'
|
package/src/logger/LogLevel.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const LogLevel = {
|
|
2
|
-
Info: 'info',
|
|
3
|
-
Debug: 'debug'
|
|
4
|
-
} as const
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
6
|
-
export type LogLevel = typeof LogLevel[keyof typeof LogLevel]
|
|
7
|
-
const logLevels = Object.values(LogLevel)
|
|
8
|
-
export const isLogLevel = (value: any): value is LogLevel => logLevels.includes(value)
|
package/src/logger/Logger.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { Logger } from 'log4js'
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getLogger } from 'log4js'
|
|
2
|
-
import type { Logger } from './Logger'
|
|
3
|
-
import type { LogLevel } from './LogLevel'
|
|
4
|
-
|
|
5
|
-
// TODO: add test
|
|
6
|
-
export const createLogger = (logLevel: LogLevel): Logger => {
|
|
7
|
-
const logger = getLogger()
|
|
8
|
-
logger.level = logLevel
|
|
9
|
-
return logger
|
|
10
|
-
}
|