Skip to content

Commit 0b33a66

Browse files
committed
chore: merge dev
2 parents 964e3c4 + 1195aee commit 0b33a66

File tree

10 files changed

+141
-13
lines changed

10 files changed

+141
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"request": "^2.83.0",
6161
"request-promise-native": "^1.0.5",
6262
"rimraf": "^2.6.2",
63-
"vuepress": "^0.10.0",
63+
"vuepress": "^0.10.1",
6464
"vuepress-theme-vue": "^1.0.3",
6565
"yorkie": "^1.0.2"
6666
},

packages/@vue/cli-plugin-eslint/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"babel-eslint": "^8.2.3",
2727
"eslint": "^4.19.1",
2828
"eslint-loader": "^2.0.0",
29-
"eslint-plugin-vue": "^4.5.0"
29+
"eslint-plugin-vue": "^4.5.0",
30+
"launch-editor": "^2.2.1"
3031
}
3132
}

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = api => {
2+
const CONFIG = 'eslintrc'
3+
24
// Config file
35
api.describeConfig({
4-
id: 'eslintrc',
6+
id: CONFIG,
57
name: 'ESLint configuration',
68
description: 'eslint.config.eslint.description',
79
link: 'https://github.com/vuejs/eslint-plugin-vue',
@@ -226,4 +228,37 @@ module.exports = api => {
226228
if (answers.noFix) args.push('--no-fix')
227229
}
228230
})
231+
232+
const OPEN_ESLINTRC = 'vue-eslint-open-eslintrc'
233+
234+
api.onViewOpen(({ view }) => {
235+
if (view.id !== 'vue-project-configurations') {
236+
removeSuggestions()
237+
}
238+
})
239+
240+
api.onConfigRead(({ config }) => {
241+
if (config.id === CONFIG) {
242+
api.addSuggestion({
243+
id: OPEN_ESLINTRC,
244+
type: 'action',
245+
label: 'eslint.suggestions.open-eslintrc.label',
246+
handler () {
247+
const file = config.foundFiles.eslint.path
248+
console.log('open', file)
249+
const launch = require('launch-editor')
250+
launch(file)
251+
return {
252+
keep: true
253+
}
254+
}
255+
})
256+
} else {
257+
removeSuggestions()
258+
}
259+
})
260+
261+
function removeSuggestions () {
262+
[OPEN_ESLINTRC].forEach(id => api.removeSuggestion(id))
263+
}
229264
}

packages/@vue/cli-plugin-pwa/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"access": "public"
2323
},
2424
"dependencies": {
25-
"workbox-webpack-plugin": "^3.2.0"
25+
"workbox-webpack-plugin": "^3.2.0",
26+
"launch-editor": "^2.2.1"
2627
},
2728
"devDependencies": {
2829
"register-service-worker": "^1.0.0"

packages/@vue/cli-plugin-pwa/ui.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = api => {
2+
const CONFIG = 'pwa'
3+
24
// Config file
35
api.describeConfig({
4-
id: 'pwa',
6+
id: CONFIG,
57
name: 'PWA',
68
description: 'pwa.config.pwa.description',
79
link: 'https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa#configuration',
@@ -110,4 +112,60 @@ module.exports = api => {
110112
}
111113
}
112114
})
115+
116+
const OPEN_VUE = 'vue-pwa-open-vue'
117+
const OPEN_MANIFEST = 'vue-pwa-open-manifest'
118+
119+
api.onViewOpen(({ view }) => {
120+
if (view.id !== 'vue-project-configurations') {
121+
removeSuggestions()
122+
}
123+
})
124+
125+
api.onConfigRead(({ config }) => {
126+
if (config.id === CONFIG) {
127+
if (config.foundFiles.vue) {
128+
api.addSuggestion({
129+
id: OPEN_VUE,
130+
type: 'action',
131+
label: 'pwa.suggestions.open-vue.label',
132+
handler () {
133+
const file = config.foundFiles.vue.path
134+
console.log('open', file)
135+
const launch = require('launch-editor')
136+
launch(file)
137+
return {
138+
keep: true
139+
}
140+
}
141+
})
142+
} else {
143+
api.removeSuggestion(OPEN_VUE)
144+
}
145+
if (config.foundFiles.manifest) {
146+
api.addSuggestion({
147+
id: OPEN_MANIFEST,
148+
type: 'action',
149+
label: 'pwa.suggestions.open-manifest.label',
150+
handler () {
151+
const file = config.foundFiles.manifest.path
152+
console.log('open', file)
153+
const launch = require('launch-editor')
154+
launch(file)
155+
return {
156+
keep: true
157+
}
158+
}
159+
})
160+
} else {
161+
api.removeSuggestion(OPEN_MANIFEST)
162+
}
163+
} else {
164+
removeSuggestions()
165+
}
166+
})
167+
168+
function removeSuggestions () {
169+
[OPEN_VUE, OPEN_MANIFEST].forEach(id => api.removeSuggestion(id))
170+
}
113171
}

packages/@vue/cli-service/lib/commands/serve.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ module.exports = (api, options) => {
8383

8484
// inject dev & hot-reload middleware entries
8585
if (!isProduction) {
86-
const sockjsUrl = url.format({
86+
const publicOpt = projectDevServerOptions.public
87+
const sockjsUrl = publicOpt ? `//${publicOpt}/sockjs-node` : url.format({
8788
protocol,
8889
port,
8990
hostname: urls.lanUrlForConfig || 'localhost',

packages/@vue/cli-service/lib/util/getAssetPath.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const path = require('path')
33
module.exports = function getAssetPath (options, filePath, placeAtRootIfRelative) {
44
// if the user is using a relative URL, place js & css at dist root to ensure
55
// relative paths work properly
6-
if (placeAtRootIfRelative && options.baseUrl.charAt(0) !== '/') {
6+
if (
7+
placeAtRootIfRelative &&
8+
!(/^https?:/.test(options.baseUrl)) &&
9+
options.baseUrl.charAt(0) !== '/'
10+
) {
711
return filePath.replace(/^\w+\//, '')
812
}
913
return options.assetsDir

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@
461461
"description": "Lints and fixes files",
462462
"noFix": "Do not fix errors"
463463
}
464+
},
465+
"suggestions": {
466+
"open-eslintrc": {
467+
"label": "Open eslintrc"
468+
}
464469
}
465470
},
466471
"pwa": {
@@ -492,6 +497,14 @@
492497
"description": "Style for the web app status bar on iOS"
493498
}
494499
}
500+
},
501+
"suggestions": {
502+
"open-vue": {
503+
"label": "Open vue config"
504+
},
505+
"open-manifest": {
506+
"label": "Open manifest"
507+
}
495508
}
496509
},
497510
"cypress": {

packages/@vue/cli-ui/src/components/SuggestionBar.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
>
66
<ApolloSubscribeToMore
77
:document="require('../graphql/suggestionAdded.gql')"
8-
:updateQuery="(previousResult, { subscriptionData }) => ({
9-
suggestions: [
10-
...previousResult.suggestions,
11-
subscriptionData.data.suggestionAdded
12-
]
13-
})"
8+
:updateQuery="(previousResult, { subscriptionData }) => {
9+
const newSuggestion = subscriptionData.data.suggestionAdded
10+
if (previousResult.suggestions.find(s => s.id === newSuggestion.id)) {
11+
return previousResult
12+
}
13+
return {
14+
suggestions: [
15+
...previousResult.suggestions,
16+
newSuggestion
17+
]
18+
}
19+
}"
1420
/>
1521

1622
<ApolloSubscribeToMore

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Subs
22
const channels = require('../channels')
3+
// Connectors
4+
const { log } = require('../utils/logger')
35

46
const suggestions = []
57

@@ -25,18 +27,23 @@ function add (suggestion, context) {
2527
suggestionAdded: suggestion
2628
})
2729

30+
log('Suggestion added', suggestion.id)
31+
2832
return suggestion
2933
}
3034

3135
function remove (id, context) {
3236
const suggestion = findOne(id)
37+
if (!suggestion) return
3338
const index = suggestions.indexOf(suggestion)
3439
suggestions.splice(index, 1)
3540

3641
context.pubsub.publish(channels.SUGGESTION_REMOVED, {
3742
suggestionRemoved: suggestion
3843
})
3944

45+
log('Suggestion removed', suggestion.id)
46+
4047
return suggestion
4148
}
4249

@@ -55,6 +62,8 @@ function update (data, context) {
5562
suggestionUpdated: suggestion
5663
})
5764

65+
log('Suggestion updated', suggestion.id)
66+
5867
return suggestion
5968
}
6069

0 commit comments

Comments
 (0)