@cmflow/cli 0.65.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.
- package/README.md +106 -0
- package/bin/checkfeatures.sh +5 -0
- package/bin/cm-changelog.js +17 -0
- package/bin/cm-clean.js +10 -0
- package/bin/cm-config.js +14 -0
- package/bin/cm-deploy.js +11 -0
- package/bin/cm-fetch.js +11 -0
- package/bin/cm-finish.js +13 -0
- package/bin/cm-publish-pages.js +11 -0
- package/bin/cm-publish.js +14 -0
- package/bin/cm-push.js +14 -0
- package/bin/cm-rebase.js +14 -0
- package/bin/cm-republish.js +11 -0
- package/bin/cm-start.js +20 -0
- package/bin/cm.js +20 -0
- package/bin/cmexpedit.sh +9 -0
- package/bin/cmpull.sh +7 -0
- package/bin/cmrelease.js +3 -0
- package/package.json +88 -0
- package/release.config.js +19 -0
- package/semantic.js +1 -0
- package/src/commands/changelog.js +47 -0
- package/src/commands/clean.js +30 -0
- package/src/commands/config.js +23 -0
- package/src/commands/deploy.js +39 -0
- package/src/commands/fetch.js +21 -0
- package/src/commands/finish.js +44 -0
- package/src/commands/index.js +10 -0
- package/src/commands/prompts/branches.js +38 -0
- package/src/commands/publish-pages.js +29 -0
- package/src/commands/push.js +26 -0
- package/src/commands/rebase.js +38 -0
- package/src/commands/release.js +36 -0
- package/src/commands/republish.js +24 -0
- package/src/commands/start.js +82 -0
- package/src/commands/tasks/push-branch.js +16 -0
- package/src/commands/tasks/rebase-all-branches.js +34 -0
- package/src/commands/tasks/refresh-repository.js +33 -0
- package/src/commands/tasks/run-test.js +23 -0
- package/src/commands/tasks/update-branch.js +40 -0
- package/src/commands/tasks/update-dependencies.js +37 -0
- package/src/commands/utils/check-install.js +31 -0
- package/src/common/cli/cli.js +107 -0
- package/src/common/cli/docker.js +63 -0
- package/src/common/cli/docker.test.js +128 -0
- package/src/common/cli/git.js +130 -0
- package/src/common/cli/git.test.js +205 -0
- package/src/common/cli/heroku.js +21 -0
- package/src/common/cli/heroku.test.js +56 -0
- package/src/common/cli/lerna.js +25 -0
- package/src/common/cli/lerna.test.js +48 -0
- package/src/common/cli/npm.js +33 -0
- package/src/common/cli/npm.test.js +47 -0
- package/src/common/cli/yarn.js +33 -0
- package/src/common/cli/yarn.test.js +48 -0
- package/src/common/configure-git-workspace.js +27 -0
- package/src/common/get-config.js +135 -0
- package/src/common/get-package-json.js +7 -0
- package/src/common/get-release-config.js +7 -0
- package/src/common/index.js +10 -0
- package/src/common/run-command.js +61 -0
- package/src/common/run-command.test.js +63 -0
- package/src/index.js +1 -0
- package/src/main.js +10 -0
- package/src/semantic-release/actions/analyze-commits.js +9 -0
- package/src/semantic-release/actions/fail.js +16 -0
- package/src/semantic-release/actions/generate-notes.js +11 -0
- package/src/semantic-release/actions/index.js +8 -0
- package/src/semantic-release/actions/prepare.js +101 -0
- package/src/semantic-release/actions/publish.js +17 -0
- package/src/semantic-release/actions/success.js +30 -0
- package/src/semantic-release/actions/verify-conditions.js +30 -0
- package/src/semantic-release/actions/verify-release.js +7 -0
- package/src/semantic-release/get-semantic-config.js +115 -0
- package/src/semantic-release/utils/calculate-snapshot-version.js +9 -0
- package/src/semantic-release/utils/calculate-snapshot-version.test.js +57 -0
- package/src/semantic-release/utils/display-package-info.js +11 -0
- package/src/semantic-release/utils/display-release-info.js +12 -0
- package/src/semantic-release/utils/docker-clean-tags.js +45 -0
- package/src/semantic-release/utils/docker-clean-tags.test.js +54 -0
- package/src/semantic-release/utils/docker-publish.js +36 -0
- package/src/semantic-release/utils/docker-publish.test.js +43 -0
- package/src/semantic-release/utils/ghpages-publish.js +16 -0
- package/src/semantic-release/utils/log-section.js +5 -0
- package/src/workflow/index.js +37 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import execa from 'execa'
|
|
3
|
+
import { docker } from './docker'
|
|
4
|
+
import { Cli } from './cli'
|
|
5
|
+
|
|
6
|
+
jest.mock('axios')
|
|
7
|
+
jest.mock('execa')
|
|
8
|
+
|
|
9
|
+
execa.mockReturnValue({})
|
|
10
|
+
|
|
11
|
+
execa.sync.mockImplementation((...args) => {
|
|
12
|
+
return {
|
|
13
|
+
stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('DockerCli', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
|
|
20
|
+
return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
describe('tag', () => {
|
|
24
|
+
it('should run tag cmd', () => {
|
|
25
|
+
const result = docker.tag('tag-arg', 'image')
|
|
26
|
+
|
|
27
|
+
expect(result).toEqual('CMD: docker tag tag-arg image')
|
|
28
|
+
expect(Cli.getRaw).toHaveBeenCalledWith('docker', ['tag', 'tag-arg', 'image'], {
|
|
29
|
+
cwd: process.cwd()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
describe('login', () => {
|
|
34
|
+
it('should run login cmd', () => {
|
|
35
|
+
const result = docker.login('login-arg')
|
|
36
|
+
|
|
37
|
+
expect(result.stdout).toEqual('CMD: docker login login-arg')
|
|
38
|
+
expect(execa.sync).toHaveBeenCalledWith('docker', ['login', 'login-arg'], {
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
stdio: 'inherit'
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
describe('push', () => {
|
|
45
|
+
it('should run push cmd', async () => {
|
|
46
|
+
await docker.push('push-arg')
|
|
47
|
+
|
|
48
|
+
expect(execa).toHaveBeenCalledWith('docker', ['push', 'push-arg'], {
|
|
49
|
+
cwd: process.cwd(),
|
|
50
|
+
stdio: 'inherit'
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
describe('getToken', () => {
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
axios.mockReturnValue({ data: { token: 'token' } })
|
|
57
|
+
})
|
|
58
|
+
it('should get token', async () => {
|
|
59
|
+
const token = await docker.getToken('username', 'password')
|
|
60
|
+
|
|
61
|
+
expect(axios).toHaveBeenCalledWith({
|
|
62
|
+
method: 'POST',
|
|
63
|
+
url: 'https://hub.docker.com/v2/users/login/',
|
|
64
|
+
headers: {
|
|
65
|
+
Accept: 'application/json',
|
|
66
|
+
'Content-Type': 'application/json'
|
|
67
|
+
},
|
|
68
|
+
data: {
|
|
69
|
+
password: 'password',
|
|
70
|
+
username: 'username'
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
expect(token).toEqual('token')
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
describe('getTags', () => {
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
axios.mockReturnValue({
|
|
79
|
+
data: {
|
|
80
|
+
results: [
|
|
81
|
+
{
|
|
82
|
+
name: 'branch-1',
|
|
83
|
+
last_updated: new Date('2020-06-01')
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
it('should get token', async () => {
|
|
90
|
+
const tags = await docker.getTags({
|
|
91
|
+
token: 'token',
|
|
92
|
+
repository: 'owner'
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
expect(tags).toEqual([
|
|
96
|
+
{
|
|
97
|
+
name: 'branch-1',
|
|
98
|
+
last_updated: new Date('2020-06-01')
|
|
99
|
+
}
|
|
100
|
+
])
|
|
101
|
+
expect(axios).toHaveBeenCalledWith({
|
|
102
|
+
method: 'GET',
|
|
103
|
+
url: 'https://hub.docker.com/v2/repositories/owner/tags/?page=1&page_size=500',
|
|
104
|
+
headers: {
|
|
105
|
+
Accept: 'application/json',
|
|
106
|
+
Authorization: 'JWT token'
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
describe('deleteTag', () => {
|
|
112
|
+
it('should run delete Tag', async () => {
|
|
113
|
+
await docker.deleteTag('my-tag', {
|
|
114
|
+
token: 'token',
|
|
115
|
+
repository: 'owner'
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
expect(axios).toHaveBeenCalledWith({
|
|
119
|
+
headers: {
|
|
120
|
+
Accept: 'application/json',
|
|
121
|
+
Authorization: 'JWT token'
|
|
122
|
+
},
|
|
123
|
+
method: 'DELETE',
|
|
124
|
+
url: 'https://hub.docker.com/v2/repositories/owner/tags/my-tag/'
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Cli } from './cli'
|
|
2
|
+
|
|
3
|
+
class GitCli extends Cli {
|
|
4
|
+
constructor () {
|
|
5
|
+
super('git')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
init (...args) {
|
|
9
|
+
return this.run('init', ...args)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
add (...args) {
|
|
13
|
+
return this.run('add', ...args)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
status (...args) {
|
|
17
|
+
return this.sync('status', ...args)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
branch (...args) {
|
|
21
|
+
return this.run('branch', ...args)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
clean (...args) {
|
|
25
|
+
return this.run('clean', ...args)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
config (...args) {
|
|
29
|
+
return this.run('config', ...args).get()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
checkout (...args) {
|
|
33
|
+
return this.run('checkout', ...args)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
commit (...args) {
|
|
37
|
+
return this.run('commit', ...args)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fetch (...args) {
|
|
41
|
+
return this.run('fetch', ...args)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
prune (...args) {
|
|
45
|
+
return this.run('prune', ...args)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
merge (...args) {
|
|
49
|
+
return this.sync('merge', ...args)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
reset (...args) {
|
|
53
|
+
return this.sync('reset', ...args)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
remote (...args) {
|
|
57
|
+
return this.run('remote', ...args)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
rebase (...args) {
|
|
61
|
+
return this.run('rebase', ...args)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getCommitTag (ref = 'HEAD') {
|
|
65
|
+
return this.get('rev-parse', '--short', ref)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getBranchName (ref = 'HEAD') {
|
|
69
|
+
return this.get('rev-parse', '--abbrev-ref', ref)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getLastCommitMsg () {
|
|
73
|
+
return this.get('log', '-1', '--pretty=%B')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
push (...args) {
|
|
77
|
+
return this.run('push', ...args)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
branchExists (branch, origin = 'origin') {
|
|
81
|
+
return (
|
|
82
|
+
this.branch('-a')
|
|
83
|
+
.getRaw()
|
|
84
|
+
.trim()
|
|
85
|
+
.includes(`remotes/${origin}/${branch}`)
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
checkBranchRemoteStatus (branch, origin = 'origin') {
|
|
90
|
+
return this.run('cherry', branch, `${origin}/${branch}`).get()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
branches (...args) {
|
|
94
|
+
return this.branch(...args)
|
|
95
|
+
.get()
|
|
96
|
+
.split('\n')
|
|
97
|
+
.map(branch => branch.trim().replace('* ', ''))
|
|
98
|
+
.filter(branch => !!branch)
|
|
99
|
+
.filter(branch => !String(branch).includes('/HEAD'))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
show (branch) {
|
|
103
|
+
return this.run('show', '--format="%ci|%cr|%an"', branch, '--')
|
|
104
|
+
.getRaw()
|
|
105
|
+
.split('\n')[0]
|
|
106
|
+
.trim()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
branchesInfos (...args) {
|
|
110
|
+
return this
|
|
111
|
+
.branches(...args)
|
|
112
|
+
.map(branch => {
|
|
113
|
+
try {
|
|
114
|
+
const [date, creation, author] = this.show(branch).split('|')
|
|
115
|
+
return {
|
|
116
|
+
branch,
|
|
117
|
+
date,
|
|
118
|
+
creation,
|
|
119
|
+
author
|
|
120
|
+
}
|
|
121
|
+
} catch (er) {
|
|
122
|
+
return undefined
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
.filter((b) => !!b)
|
|
126
|
+
.sort((info1, info2) => info1.date < info2.date)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const git = new GitCli()
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import execa from 'execa'
|
|
2
|
+
import { git } from './git'
|
|
3
|
+
import { Cli } from './cli'
|
|
4
|
+
|
|
5
|
+
jest.mock('execa')
|
|
6
|
+
|
|
7
|
+
execa.sync.mockImplementation((...args) => {
|
|
8
|
+
return {
|
|
9
|
+
stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
execa.mockReturnValue({})
|
|
14
|
+
|
|
15
|
+
describe('GitCli', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
|
|
18
|
+
return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
describe('init', () => {
|
|
22
|
+
it('should run init cmd', () => {
|
|
23
|
+
const result = git.init('init-arg').sync()
|
|
24
|
+
|
|
25
|
+
expect(result.stdout).toEqual('CMD: git init init-arg')
|
|
26
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['init', 'init-arg'], {
|
|
27
|
+
cwd: process.cwd(),
|
|
28
|
+
stdio: 'inherit'
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
describe('add', () => {
|
|
33
|
+
it('should run add cmd', () => {
|
|
34
|
+
const result = git.add('add-arg').sync()
|
|
35
|
+
|
|
36
|
+
expect(result.stdout).toEqual('CMD: git add add-arg')
|
|
37
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['add', 'add-arg'], {
|
|
38
|
+
cwd: process.cwd(),
|
|
39
|
+
stdio: 'inherit'
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
describe('branch', () => {
|
|
44
|
+
it('should run branch cmd', () => {
|
|
45
|
+
const result = git.branch('branch-arg').sync()
|
|
46
|
+
|
|
47
|
+
expect(result.stdout).toEqual('CMD: git branch branch-arg')
|
|
48
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['branch', 'branch-arg'], {
|
|
49
|
+
cwd: process.cwd(),
|
|
50
|
+
stdio: 'inherit'
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
describe('clean', () => {
|
|
55
|
+
it('should run branch cmd', () => {
|
|
56
|
+
const result = git.clean('clean-arg').sync()
|
|
57
|
+
|
|
58
|
+
expect(result.stdout).toEqual('CMD: git clean clean-arg')
|
|
59
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['clean', 'clean-arg'], {
|
|
60
|
+
cwd: process.cwd(),
|
|
61
|
+
stdio: 'inherit'
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
describe('config', () => {
|
|
66
|
+
it('should run config cmd', () => {
|
|
67
|
+
const result = git.config('config-arg')
|
|
68
|
+
|
|
69
|
+
expect(result).toEqual('CMD: git config config-arg')
|
|
70
|
+
expect(Cli.getRaw).toHaveBeenCalledWith('git', ['config', 'config-arg'], {
|
|
71
|
+
cwd: process.cwd()
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
describe('checkout', () => {
|
|
76
|
+
it('should run checkout cmd', () => {
|
|
77
|
+
const result = git.checkout('checkout-arg').sync()
|
|
78
|
+
|
|
79
|
+
expect(result.stdout).toEqual('CMD: git checkout checkout-arg')
|
|
80
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['checkout', 'checkout-arg'], {
|
|
81
|
+
cwd: process.cwd(),
|
|
82
|
+
stdio: 'inherit'
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
describe('commit', () => {
|
|
87
|
+
it('should run commit cmd', () => {
|
|
88
|
+
const result = git.commit('commit-arg').sync()
|
|
89
|
+
|
|
90
|
+
expect(result.stdout).toEqual('CMD: git commit commit-arg')
|
|
91
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['commit', 'commit-arg'], {
|
|
92
|
+
cwd: process.cwd(),
|
|
93
|
+
stdio: 'inherit'
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
describe('fetch', () => {
|
|
98
|
+
it('should run fetch cmd', () => {
|
|
99
|
+
const result = git.fetch('fetch-arg').sync()
|
|
100
|
+
|
|
101
|
+
expect(result.stdout).toEqual('CMD: git fetch fetch-arg')
|
|
102
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['fetch', 'fetch-arg'], {
|
|
103
|
+
cwd: process.cwd(),
|
|
104
|
+
stdio: 'inherit'
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
describe('prune', () => {
|
|
109
|
+
it('should run fetch cmd', () => {
|
|
110
|
+
const result = git.prune('prune-arg').sync()
|
|
111
|
+
|
|
112
|
+
expect(result.stdout).toEqual('CMD: git prune prune-arg')
|
|
113
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['prune', 'prune-arg'], {
|
|
114
|
+
cwd: process.cwd(),
|
|
115
|
+
stdio: 'inherit'
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
describe('merge', () => {
|
|
120
|
+
it('should run fetch cmd', () => {
|
|
121
|
+
const result = git.merge('merge-arg')
|
|
122
|
+
|
|
123
|
+
expect(result.stdout).toEqual('CMD: git merge merge-arg')
|
|
124
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['merge', 'merge-arg'], {
|
|
125
|
+
cwd: process.cwd(),
|
|
126
|
+
stdio: 'inherit'
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
describe('reset', () => {
|
|
131
|
+
it('should run reset cmd', () => {
|
|
132
|
+
const result = git.reset('reset-arg')
|
|
133
|
+
|
|
134
|
+
expect(result.stdout).toEqual('CMD: git reset reset-arg')
|
|
135
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['reset', 'reset-arg'], {
|
|
136
|
+
cwd: process.cwd(),
|
|
137
|
+
stdio: 'inherit'
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
describe('remote', () => {
|
|
142
|
+
it('should run remote cmd', () => {
|
|
143
|
+
const result = git.remote('remote-arg').sync()
|
|
144
|
+
|
|
145
|
+
expect(result.stdout).toEqual('CMD: git remote remote-arg')
|
|
146
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['remote', 'remote-arg'], {
|
|
147
|
+
cwd: process.cwd(),
|
|
148
|
+
stdio: 'inherit'
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
describe('rebase', () => {
|
|
153
|
+
it('should run rebase cmd', () => {
|
|
154
|
+
const result = git.rebase('rebase-arg').sync()
|
|
155
|
+
|
|
156
|
+
expect(result.stdout).toEqual('CMD: git rebase rebase-arg')
|
|
157
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['rebase', 'rebase-arg'], {
|
|
158
|
+
cwd: process.cwd(),
|
|
159
|
+
stdio: 'inherit'
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
describe('status', () => {
|
|
164
|
+
it('should run status cmd', () => {
|
|
165
|
+
const result = git.status('status-arg')
|
|
166
|
+
|
|
167
|
+
expect(result.stdout).toEqual('CMD: git status status-arg')
|
|
168
|
+
expect(execa.sync).toHaveBeenCalledWith('git', ['status', 'status-arg'], {
|
|
169
|
+
cwd: process.cwd(),
|
|
170
|
+
stdio: 'inherit'
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
describe('getCommitTag', () => {
|
|
175
|
+
it('should run revParse cmd', () => {
|
|
176
|
+
const result = git.getCommitTag('ref')
|
|
177
|
+
|
|
178
|
+
expect(result).toEqual('CMD: git rev-parse --short ref')
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
describe('getBranchName', () => {
|
|
182
|
+
it('should run revParse cmd', () => {
|
|
183
|
+
const result = git.getBranchName('ref')
|
|
184
|
+
|
|
185
|
+
expect(result).toEqual('CMD: git rev-parse --abbrev-ref ref')
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
describe('getLastCommitMsg', () => {
|
|
189
|
+
it('should run revParse cmd', () => {
|
|
190
|
+
const result = git.getLastCommitMsg()
|
|
191
|
+
|
|
192
|
+
expect(result).toEqual('CMD: git log -1 --pretty=%B')
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
describe('push', () => {
|
|
196
|
+
it('should run push cmd', async () => {
|
|
197
|
+
await git.push('push-arg')
|
|
198
|
+
|
|
199
|
+
expect(execa).toHaveBeenCalledWith('git', ['push', 'push-arg'], {
|
|
200
|
+
cwd: process.cwd(),
|
|
201
|
+
stdio: 'inherit'
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Cli } from './cli'
|
|
2
|
+
|
|
3
|
+
export class HerokuCli extends Cli {
|
|
4
|
+
constructor () {
|
|
5
|
+
super('heroku')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
containerLogin (...args) {
|
|
9
|
+
return this.run('container:login', ...args)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
containerPush (...args) {
|
|
13
|
+
return this.run('container:push', ...args)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
containerRelease (...args) {
|
|
17
|
+
return this.run('container:release', ...args)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const heroku = new HerokuCli()
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import execa from 'execa'
|
|
2
|
+
import { Cli } from './cli'
|
|
3
|
+
import { heroku } from './heroku'
|
|
4
|
+
|
|
5
|
+
jest.mock('execa')
|
|
6
|
+
|
|
7
|
+
execa.sync.mockImplementation((...args) => {
|
|
8
|
+
return {
|
|
9
|
+
stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
execa.mockReturnValue({})
|
|
14
|
+
|
|
15
|
+
describe('HerokuCli', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
|
|
18
|
+
return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
describe('containerLogin', () => {
|
|
22
|
+
it('should run cmd', () => {
|
|
23
|
+
const result = heroku.containerLogin('arg').sync()
|
|
24
|
+
|
|
25
|
+
expect(result.stdout).toEqual('CMD: heroku container:login arg')
|
|
26
|
+
expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:login', 'arg'], {
|
|
27
|
+
cwd: process.cwd(),
|
|
28
|
+
stdio: 'inherit'
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('containerPush', () => {
|
|
34
|
+
it('should run cmd', () => {
|
|
35
|
+
const result = heroku.containerPush('arg').sync()
|
|
36
|
+
|
|
37
|
+
expect(result.stdout).toEqual('CMD: heroku container:push arg')
|
|
38
|
+
expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:push', 'arg'], {
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
stdio: 'inherit'
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('containerRelease', () => {
|
|
46
|
+
it('should run cmd', () => {
|
|
47
|
+
const result = heroku.containerRelease('arg').sync()
|
|
48
|
+
|
|
49
|
+
expect(result.stdout).toEqual('CMD: heroku container:release arg')
|
|
50
|
+
expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:release', 'arg'], {
|
|
51
|
+
cwd: process.cwd(),
|
|
52
|
+
stdio: 'inherit'
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Cli } from './cli'
|
|
2
|
+
|
|
3
|
+
class LernaCli extends Cli {
|
|
4
|
+
constructor () {
|
|
5
|
+
super('lerna')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
newVersion (version) {
|
|
9
|
+
return this.version(version, '--exact', '--yes', '--no-git-tag-version', '--no-push')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
version (...args) {
|
|
13
|
+
return this.sync('version', ...args)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
run (...args) {
|
|
17
|
+
return super.run('run', ...args)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
install (...args) {
|
|
21
|
+
return super.run('install', ...args)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const lerna = new LernaCli()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import execa from 'execa'
|
|
2
|
+
import { lerna } from './lerna'
|
|
3
|
+
import { Cli } from './cli'
|
|
4
|
+
|
|
5
|
+
jest.mock('execa')
|
|
6
|
+
|
|
7
|
+
execa.sync.mockImplementation((...args) => {
|
|
8
|
+
return {
|
|
9
|
+
stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
execa.mockReturnValue({})
|
|
14
|
+
|
|
15
|
+
describe('LernaCli', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
|
|
18
|
+
return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
describe('newVersion', () => {
|
|
22
|
+
it('should run add cmd', () => {
|
|
23
|
+
const result = lerna.newVersion('1.0.0')
|
|
24
|
+
|
|
25
|
+
expect(result.stdout).toEqual('CMD: lerna version 1.0.0 --exact --yes --no-git-tag-version --no-push')
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
describe('run', () => {
|
|
29
|
+
it('should run "run" cmd', async () => {
|
|
30
|
+
await lerna.run('run-arg')
|
|
31
|
+
|
|
32
|
+
expect(execa).toHaveBeenCalledWith('lerna', ['run', 'run-arg'], {
|
|
33
|
+
cwd: process.cwd(),
|
|
34
|
+
stdio: 'inherit'
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
describe('install', () => {
|
|
39
|
+
it('should run "install" cmd', async () => {
|
|
40
|
+
await lerna.install('install-arg')
|
|
41
|
+
|
|
42
|
+
expect(execa).toHaveBeenCalledWith('lerna', ['install', 'install-arg'], {
|
|
43
|
+
cwd: process.cwd(),
|
|
44
|
+
stdio: 'inherit'
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Cli } from './cli'
|
|
2
|
+
|
|
3
|
+
class NpmCli extends Cli {
|
|
4
|
+
constructor () {
|
|
5
|
+
super('npm')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
newVersion (version) {
|
|
9
|
+
return this.version('--no-git-tag-version', version)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
version (...args) {
|
|
13
|
+
return this.sync('version', ...args)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
run (...args) {
|
|
17
|
+
return super.run('run', ...args)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
install (...args) {
|
|
21
|
+
return super.run('install', ...args)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reinstall dependencies without package-lock mutation
|
|
26
|
+
* @returns {Promise<unknown>}
|
|
27
|
+
*/
|
|
28
|
+
restore () {
|
|
29
|
+
return super.run('install', '--no-package-lock', '--no-production')
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const npm = new NpmCli()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import execa from 'execa'
|
|
2
|
+
import { npm } from './npm'
|
|
3
|
+
import { Cli } from './cli'
|
|
4
|
+
|
|
5
|
+
jest.mock('execa')
|
|
6
|
+
|
|
7
|
+
execa.sync.mockImplementation((...args) => {
|
|
8
|
+
return {
|
|
9
|
+
stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
execa.mockReturnValue({})
|
|
13
|
+
|
|
14
|
+
describe('NpmCli', () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
|
|
17
|
+
return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
describe('newVersion', () => {
|
|
21
|
+
it('should run newVersion cmd', () => {
|
|
22
|
+
const result = npm.newVersion('1.0.0')
|
|
23
|
+
|
|
24
|
+
expect(result.stdout).toEqual('CMD: npm version --no-git-tag-version 1.0.0')
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
describe('run', () => {
|
|
28
|
+
it('should run "run" cmd', async () => {
|
|
29
|
+
await npm.run('run-arg')
|
|
30
|
+
|
|
31
|
+
expect(execa).toHaveBeenCalledWith('npm', ['run', 'run-arg'], {
|
|
32
|
+
cwd: process.cwd(),
|
|
33
|
+
stdio: 'inherit'
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
describe('install', () => {
|
|
38
|
+
it('should run "install" cmd', async () => {
|
|
39
|
+
await npm.install('install-arg')
|
|
40
|
+
|
|
41
|
+
expect(execa).toHaveBeenCalledWith('npm', ['install', 'install-arg'], {
|
|
42
|
+
cwd: process.cwd(),
|
|
43
|
+
stdio: 'inherit'
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|