Skip to content

Commit 98b6d26

Browse files
authored
feat(ui): update all plugin to wanted version button (#1456)
1 parent f42632b commit 98b6d26

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed

packages/@vue/cli-ui/locales/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@
267267
"project-plugins": {
268268
"title": "Project plugins",
269269
"button": "Add plugin",
270-
"heading": "Installed plugins"
270+
"heading": "Installed plugins",
271+
"update-all": "Update all plugins"
271272
},
272273
"project-plugins-add": {
273274
"title": "Add a plugin",

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

+31-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ async function initPrompts (id, context) {
359359
await prompts.start()
360360
}
361361

362-
function update (id, context) {
362+
function update (id, context, notify = true) {
363363
return progress.wrap('plugin-update', context, async setProgress => {
364364
setProgress({
365365
status: 'plugin-update',
@@ -370,15 +370,44 @@ function update (id, context) {
370370
const { current, wanted } = await getVersion(plugin, context)
371371
await updatePackage(cwd.get(), getCommand(), null, id)
372372
resetPluginApi(context)
373+
373374
logs.add({
374375
message: `Plugin ${id} updated from ${current} to ${wanted}`,
375376
type: 'info'
376377
}, context)
378+
379+
if (notify) {
380+
notifier.notify({
381+
title: `Plugin updated`,
382+
message: `Plugin ${id} was successfully updated`,
383+
icon: path.resolve(__dirname, '../../assets/done.png')
384+
})
385+
}
386+
377387
currentPluginId = null
378388
return findOne(id)
379389
})
380390
}
381391

392+
async function updateAll (context) {
393+
const plugins = await list(cwd.get(), context)
394+
let updatedPlugins = []
395+
for (const plugin of plugins) {
396+
const version = await getVersion(plugin, context)
397+
if (version.current !== version.wanted) {
398+
updatedPlugins.push(await update(plugin.id, context, false))
399+
}
400+
}
401+
402+
notifier.notify({
403+
title: `Plugins updated`,
404+
message: `${updatedPlugins.length} plugin(s) were successfully updated`,
405+
icon: path.resolve(__dirname, '../../assets/done.png')
406+
})
407+
408+
return updatedPlugins
409+
}
410+
382411
function getApi () {
383412
return pluginApi
384413
}
@@ -433,6 +462,7 @@ module.exports = {
433462
install,
434463
uninstall,
435464
update,
465+
updateAll,
436466
runInvoke,
437467
resetPluginApi,
438468
getApi,

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extend type Mutation {
1717
pluginFinishInstall: PluginInstallation
1818
pluginUpdate (id: ID!): Plugin
1919
pluginActionCall (id: ID!, params: JSON): PluginActionResult
20+
pluginsUpdate: [Plugin]
2021
}
2122
2223
extend type Subscription {
@@ -80,7 +81,8 @@ exports.resolvers = {
8081
pluginInvoke: (root, { id }, context) => plugins.runInvoke(id, context),
8182
pluginFinishInstall: (root, args, context) => plugins.finishInstall(context),
8283
pluginUpdate: (root, { id }, context) => plugins.update(id, context),
83-
pluginActionCall: (root, args, context) => plugins.callAction(args, context)
84+
pluginActionCall: (root, args, context) => plugins.callAction(args, context),
85+
pluginsUpdate: (root, args, context) => plugins.updateAll(context)
8486
},
8587

8688
Subscription: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#import "./versionFragment.gql"
2+
3+
mutation pluginsUpdate {
4+
pluginsUpdate {
5+
id
6+
version {
7+
...version
8+
}
9+
}
10+
}

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

+24
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
:to="{ name: 'project-plugins-add' }"
1313
data-testid="add-plugin"
1414
/>
15+
16+
<VueDropdown>
17+
<VueButton
18+
slot="trigger"
19+
icon-left="more_vert"
20+
class="icon-button flat round"
21+
/>
22+
23+
<VueDropdownButton
24+
icon-left="file_download"
25+
:label="$t('views.project-plugins.update-all')"
26+
@click="updateAll()"
27+
/>
28+
</VueDropdown>
1529
</template>
1630

1731
<ApolloQuery
@@ -43,13 +57,23 @@
4357
</template>
4458

4559
<script>
60+
import PLUGINS_UPDATE from '../graphql/pluginsUpdate.gql'
61+
4662
export default {
4763
name: 'ProjectPlugins',
4864
4965
metaInfo () {
5066
return {
5167
title: this.$t('views.project-plugins.title')
5268
}
69+
},
70+
71+
methods: {
72+
updateAll () {
73+
return this.$apollo.mutate({
74+
mutation: PLUGINS_UPDATE
75+
})
76+
}
5377
}
5478
}
5579
</script>

0 commit comments

Comments
 (0)