mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-29 00:09:47 -05:00
feat(ui): pwa open vue config/manifest suggestions
This commit is contained in:
@@ -22,7 +22,8 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"workbox-webpack-plugin": "^3.2.0"
|
||||
"workbox-webpack-plugin": "^3.2.0",
|
||||
"launch-editor": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"register-service-worker": "^1.0.0"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
module.exports = api => {
|
||||
const CONFIG = 'pwa'
|
||||
|
||||
// Config file
|
||||
api.describeConfig({
|
||||
id: 'pwa',
|
||||
id: CONFIG,
|
||||
name: 'PWA',
|
||||
description: 'pwa.config.pwa.description',
|
||||
link: 'https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa#configuration',
|
||||
@@ -110,4 +112,60 @@ module.exports = api => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const OPEN_VUE = 'vue-pwa-open-vue'
|
||||
const OPEN_MANIFEST = 'vue-pwa-open-manifest'
|
||||
|
||||
api.onViewOpen(({ view }) => {
|
||||
if (view.id !== 'vue-project-configurations') {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
api.onConfigRead(({ config }) => {
|
||||
if (config.id === CONFIG) {
|
||||
if (config.foundFiles.vue) {
|
||||
api.addSuggestion({
|
||||
id: OPEN_VUE,
|
||||
type: 'action',
|
||||
label: 'pwa.suggestions.open-vue.label',
|
||||
handler () {
|
||||
const file = config.foundFiles.vue.path
|
||||
console.log('open', file)
|
||||
const launch = require('launch-editor')
|
||||
launch(file)
|
||||
return {
|
||||
keep: true
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
api.removeSuggestion(OPEN_VUE)
|
||||
}
|
||||
if (config.foundFiles.manifest) {
|
||||
api.addSuggestion({
|
||||
id: OPEN_MANIFEST,
|
||||
type: 'action',
|
||||
label: 'pwa.suggestions.open-manifest.label',
|
||||
handler () {
|
||||
const file = config.foundFiles.manifest.path
|
||||
console.log('open', file)
|
||||
const launch = require('launch-editor')
|
||||
launch(file)
|
||||
return {
|
||||
keep: true
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
api.removeSuggestion(OPEN_MANIFEST)
|
||||
}
|
||||
} else {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
function removeSuggestions () {
|
||||
[OPEN_VUE, OPEN_MANIFEST].forEach(id => api.removeSuggestion(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,6 +497,14 @@
|
||||
"description": "Style for the web app status bar on iOS"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suggestions": {
|
||||
"open-vue": {
|
||||
"label": "Open vue config"
|
||||
},
|
||||
"open-manifest": {
|
||||
"label": "Open manifest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"cypress": {
|
||||
|
||||
Reference in New Issue
Block a user