Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/lib/PluginAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ class PluginAPI {
} catch (e) {
return fs.readFileSync(absolutePath, 'utf-8')
}
}
else {
} else {
return fs.readFileSync(absolutePath, 'utf-8')
}
}
Expand Down
31 changes: 28 additions & 3 deletions packages/@vue/cli-ui/apollo-server/connectors/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const {
getPluginLink,
resolveModule,
loadModule,
clearModule
clearModule,
execa
} = require('@vue/cli-shared-utils')
const {
progress: installProgress,
installPackage,
uninstallPackage,
updatePackage
} = require('@vue/cli/lib/util/installDeps')
const invoke = require('@vue/cli/lib/invoke')
const { getCommand } = require('../util/command')
const ipc = require('../util/ipc')
const { log } = require('../util/logger')
Expand Down Expand Up @@ -446,7 +446,32 @@ function runInvoke (id, context) {
currentPluginId = id
// Allow plugins that don't have a generator
if (resolveModule(`${id}/generator`, cwd.get())) {
await invoke(id, prompts.getAnswers(), cwd.get())
const child = execa('vue', [
'invoke',
id,
'--$inlineOptions',
JSON.stringify(prompts.getAnswers())
], {
cwd: cwd.get(),
stdio: ['inherit', 'pipe', 'inherit']
})

const onData = buffer => {
const text = buffer.toString().trim()
if (text) {
setProgress({
info: text
})
logs.add({
type: 'info',
message: text
}, context)
}
}

child.stdout.on('data', onData)

await child
}
// Run plugin api
runPluginApi(id, getApi(cwd.get()), context)
Expand Down
10 changes: 8 additions & 2 deletions packages/@vue/cli/lib/invoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ async function invoke (pluginName, options = {}, context = process.cwd()) {
// resolve options if no command line options (other than --registry) are passed,
// and the plugin contains a prompt module.
// eslint-disable-next-line prefer-const
let { registry, ...pluginOptions } = options
if (!Object.keys(pluginOptions).length) {
let { registry, $inlineOptions, ...pluginOptions } = options
if ($inlineOptions) {
try {
pluginOptions = JSON.parse($inlineOptions)
} catch (e) {
throw new Error(`Couldn't parse inline options JSON: ${e.message}`)
}
} else if (!Object.keys(pluginOptions).length) {
let pluginPrompts = loadModule(`${id}/prompts`, context)
if (pluginPrompts) {
if (typeof pluginPrompts === 'function') {
Expand Down