Skip to content

Commit 2a2f9df

Browse files
author
test
committed
feat(git): allow users to specify custom commit messages. also fixed some var name typos (#1086)
1 parent bcd92b1 commit 2a2f9df

File tree

12 files changed

+36
-19
lines changed

12 files changed

+36
-19
lines changed

packages/@vue/cli-test-utils/assertPromptModule.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = async function assertPromptModule (
1111
opts = {}
1212
) {
1313
// auto fill non-module prompts
14-
if (opts.plguinsOnly) {
14+
if (opts.pluginsOnly) {
1515
expectedPrompts.unshift(
1616
{
1717
message: 'Please pick a preset',
@@ -40,7 +40,7 @@ module.exports = async function assertPromptModule (
4040
const creator = new Creator('test', '/', [].concat(module))
4141
const preset = await creator.promptAndResolvePreset()
4242

43-
if (opts.plguinsOnly) {
43+
if (opts.pluginsOnly) {
4444
delete preset.useConfigFiles
4545
}
4646
expect(preset).toEqual(expectedOptions)

packages/@vue/cli/bin/vue.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ program
3939
.option('-p, --preset <presetName>', 'Skip prompts and use saved or remote preset')
4040
.option('-d, --default', 'Skip prompts and use default preset')
4141
.option('-i, --inlinePreset <json>', 'Skip prompts and use inline JSON string as preset')
42+
.option('-g, --initialCommit <message>', 'Skip prompt and provide initial commit message (when git is available)')
4243
.option('-m, --packageManager <command>', 'Use specified npm client when installing dependencies')
4344
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
4445
.option('-f, --force', 'Overwrite target directory if it exists')

packages/@vue/cli/lib/Creator.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ module.exports = class Creator {
7979

8080
// clone before mutating
8181
preset = cloneDeep(preset)
82+
83+
let initialCommit
84+
if (cliOptions.initialCommit) {
85+
initialCommit = cliOptions.initialCommit
86+
} else {
87+
// clear the console and ask for the initial commit message #1086
88+
await clearConsole(true)
89+
initialCommit = (await inquirer.prompt([{
90+
name: 'commitMessage',
91+
when: hasGit,
92+
type: 'input',
93+
message: 'Initial Git commit message:',
94+
default: 'init'
95+
}])).commitMessage
96+
}
97+
8298
// inject core service
8399
preset.plugins['@vue/cli-service'] = Object.assign({
84100
projectName: name
@@ -164,7 +180,7 @@ module.exports = class Creator {
164180
await run('git', ['config', 'user.name', 'test'])
165181
await run('git', ['config', 'user.email', '[email protected]'])
166182
}
167-
await run(`git commit -m init`)
183+
await run('git', ['commit', '-m', initialCommit])
168184
}
169185

170186
// log instructions

packages/@vue/cli/lib/promptModules/__tests__/babel.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test('should pass', async () => {
2323
moduleToTest,
2424
expectedPrompts,
2525
expectedOptions,
26-
{ plguinsOnly: true }
26+
{ pluginsOnly: true }
2727
)
2828
})
2929

@@ -49,6 +49,6 @@ test('should not include the plugin if ts is also present', async () => {
4949
[mockTSModule, moduleToTest],
5050
expectedPrompts,
5151
expectedOptions,
52-
{ plguinsOnly: true }
52+
{ pluginsOnly: true }
5353
)
5454
})

packages/@vue/cli/lib/promptModules/__tests__/cssPreprocessors.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ test('CSS pre-processor ', async () => {
2828
moduleToTest,
2929
expectedPrompts,
3030
expectedOptions,
31-
{ plguinsOnly: true }
31+
{ pluginsOnly: true }
3232
)
3333
})

packages/@vue/cli/lib/promptModules/__tests__/e2e.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('cypress', async () => {
2929
moduleToTest,
3030
expectedPrompts,
3131
expectedOptions,
32-
{ plguinsOnly: true }
32+
{ pluginsOnly: true }
3333
)
3434
})
3535

@@ -57,6 +57,6 @@ test('nightwatch', async () => {
5757
moduleToTest,
5858
expectedPrompts,
5959
expectedOptions,
60-
{ plguinsOnly: true }
60+
{ pluginsOnly: true }
6161
)
6262
})

packages/@vue/cli/lib/promptModules/__tests__/linter.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('base', async () => {
3737
moduleToTest,
3838
expectedPrompts,
3939
expectedOptions,
40-
{ plguinsOnly: true }
40+
{ pluginsOnly: true }
4141
)
4242
})
4343

@@ -69,7 +69,7 @@ test('airbnb', async () => {
6969
moduleToTest,
7070
expectedPrompts,
7171
expectedOptions,
72-
{ plguinsOnly: true }
72+
{ pluginsOnly: true }
7373
)
7474
})
7575

@@ -101,7 +101,7 @@ test('standard', async () => {
101101
moduleToTest,
102102
expectedPrompts,
103103
expectedOptions,
104-
{ plguinsOnly: true }
104+
{ pluginsOnly: true }
105105
)
106106
})
107107

@@ -133,6 +133,6 @@ test('prettier', async () => {
133133
moduleToTest,
134134
expectedPrompts,
135135
expectedOptions,
136-
{ plguinsOnly: true }
136+
{ pluginsOnly: true }
137137
)
138138
})

packages/@vue/cli/lib/promptModules/__tests__/pwa.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ test('pwa', async () => {
2424
moduleToTest,
2525
expectedPrompts,
2626
expectedOptions,
27-
{ plguinsOnly: true }
27+
{ pluginsOnly: true }
2828
)
2929
})

packages/@vue/cli/lib/promptModules/__tests__/router.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ test('router', async () => {
2323
moduleToTest,
2424
expectedPrompts,
2525
expectedOptions,
26-
{ plguinsOnly: true }
26+
{ pluginsOnly: true }
2727
)
2828
})

packages/@vue/cli/lib/promptModules/__tests__/typescript.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test('with TSLint', async () => {
4848
[moduleToTest, linterModule],
4949
expectedPrompts,
5050
expectedOptions,
51-
{ plguinsOnly: true }
51+
{ pluginsOnly: true }
5252
)
5353
})
5454

@@ -96,6 +96,6 @@ test('with ESLint', async () => {
9696
[moduleToTest, linterModule],
9797
expectedPrompts,
9898
expectedOptions,
99-
{ plguinsOnly: true }
99+
{ pluginsOnly: true }
100100
)
101101
})

packages/@vue/cli/lib/promptModules/__tests__/unit.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('mocha', async () => {
2929
moduleToTest,
3030
expectedPrompts,
3131
expectedOptions,
32-
{ plguinsOnly: true }
32+
{ pluginsOnly: true }
3333
)
3434
})
3535

@@ -57,6 +57,6 @@ test('jest', async () => {
5757
moduleToTest,
5858
expectedPrompts,
5959
expectedOptions,
60-
{ plguinsOnly: true }
60+
{ pluginsOnly: true }
6161
)
6262
})

packages/@vue/cli/lib/promptModules/__tests__/vuex.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ test('vuex', async () => {
2323
moduleToTest,
2424
expectedPrompts,
2525
expectedOptions,
26-
{ plguinsOnly: true }
26+
{ pluginsOnly: true }
2727
)
2828
})

0 commit comments

Comments
 (0)