Skip to content

Commit 1a48c9f

Browse files
author
Guillaume Chau
committed
feat(ui): plugin invoke
1 parent 798445f commit 1a48c9f

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

packages/@vue/cli-plugin-eslint/lint.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function lint (args = {}, api) {
44
const cwd = api.resolve('.')
55
const { CLIEngine } = require('eslint')
66
const options = require('./eslintOptions')(api)
7-
const { log, done } = require('@vue/cli-shared-utils')
7+
const { log, done, exit } = require('@vue/cli-shared-utils')
88

99
const files = args._ && args._.length ? args._ : ['src', 'tests', '*.js']
1010
if (args['no-fix']) {
@@ -44,7 +44,7 @@ module.exports = function lint (args = {}, api) {
4444
}
4545
} else {
4646
console.log(formatter(report.results))
47-
process.exit(1)
47+
exit(1)
4848
}
4949
}
5050

packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
uninstallPackage
1515
} = require('@vue/cli/lib/util/installDeps')
1616
const { loadOptions } = require('@vue/cli/lib/options')
17+
const invoke = require('@vue/cli/lib/invoke')
1718

1819
const cwd = require('./cwd')
1920
const folders = require('./folders')
@@ -186,7 +187,7 @@ function uninstall (id, context) {
186187
})
187188
}
188189

189-
function invoke (id, context) {
190+
function runInvoke (id, context) {
190191
return progress.wrap(PROGRESS_ID, context, async setProgress => {
191192
setProgress({
192193
status: 'plugin-invoke',
@@ -195,7 +196,7 @@ function invoke (id, context) {
195196

196197
currentPluginId = id
197198

198-
// TODO
199+
await invoke(id, prompts.getAnswers(), cwd.get())
199200

200201
currentPluginId = null
201202

@@ -221,5 +222,5 @@ module.exports = {
221222
getInstallation,
222223
install,
223224
uninstall,
224-
invoke
225+
runInvoke
225226
}

packages/@vue/cli-ui/src/graphql-api/resolvers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = {
6464
projectCwdReset: (root, args, context) => projects.resetCwd(context),
6565
pluginInstall: (root, { id }, context) => plugins.install(id, context),
6666
pluginUninstall: (root, { id }, context) => plugins.uninstall(id, context),
67-
pluginInvoke: (root, { id }, context) => plugins.invoke(id, context)
67+
pluginInvoke: (root, { id }, context) => plugins.runInvoke(id, context)
6868
},
6969

7070
Subscription: {

packages/@vue/cli-ui/src/views/ProjectPluginsAdd.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
icon-left="close"
6161
label="Cancel"
6262
class="big"
63-
@click="cancel()"
63+
@click="close()"
6464
/>
6565

6666
<div class="algolia">
@@ -156,6 +156,7 @@ import Prompts from '../mixins/Prompts'
156156
import PLUGIN_INSTALLATION from '../graphql/pluginInstallation.gql'
157157
import PLUGIN_INSTALL from '../graphql/pluginInstall.gql'
158158
import PLUGIN_UNINSTALL from '../graphql/pluginUninstall.gql'
159+
import PLUGIN_INVOKE from '../graphql/pluginInvoke.gql'
159160
import PROMPT_ANSWER from '../graphql/promptAnswer.gql'
160161
161162
export default {
@@ -198,7 +199,7 @@ export default {
198199
},
199200
200201
methods: {
201-
cancel () {
202+
close () {
202203
this.$router.push({ name: 'project-home' })
203204
},
204205
@@ -238,7 +239,17 @@ export default {
238239
},
239240
240241
async invokePlugin () {
241-
// TODO
242+
try {
243+
await this.$apollo.mutate({
244+
mutation: PLUGIN_INVOKE,
245+
variables: {
246+
id: this.selectedId
247+
}
248+
})
249+
this.close()
250+
} catch(e) {
251+
console.error(e)
252+
}
242253
},
243254
}
244255
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ async function invoke (pluginName, options = {}, context = process.cwd()) {
135135
log()
136136
log(` Successfully invoked generator for plugin: ${chalk.cyan(id)}`)
137137
if (!process.env.VUE_CLI_TEST && hasGit()) {
138-
const { stdout } = await execa('git', ['ls-files', '--exclude-standard', '--modified', '--others'])
138+
const { stdout } = await execa('git', ['ls-files', '--exclude-standard', '--modified', '--others'], {
139+
cwd: context
140+
})
139141
if (stdout.trim()) {
140142
log(` The following files have been updated / added:\n`)
141143
log(chalk.red(stdout.split(/\r?\n/g).map(line => ` ${line}`).join('\n')))

packages/@vue/cli/lib/util/installDeps.js

-13
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,6 @@ function executeCommand (command, args, targetDir) {
154154

155155
progress.enabled = false
156156

157-
// const lines = []
158-
// let count = 0
159-
// const unhook = intercept(buffer => {
160-
// count++
161-
// lines.push(buffer)
162-
// const str = buffer === 'string' ? buffer : buffer.toString()
163-
// // Steps
164-
// const stepMatch = str.match(/\[\d+\/\d+]\s+(.*)/)
165-
// if (stepMatch) {
166-
// progress.log(stepMatch[1])
167-
// }
168-
// })
169-
170157
if (apiMode) {
171158
if (command === 'npm') {
172159
// TODO when this is supported

0 commit comments

Comments
 (0)