Skip to content

Commit 4f39461

Browse files
Akryumyyx990803
authored andcommitted
fix: UI fixes (vuejs#1397)
* fix: ERROR AssertionError [ERR_ASSERTION]: missing path * refactor(ui): export portfinder and graphql-server from @vue/cli-ui and new VUE_CLI_UI_DEV env var * fix(ui): invoke: force load package.json
1 parent 118bd8f commit 4f39461

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

packages/@vue/cli-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"serve": "vue-cli-service serve",
66
"build": "vue-cli-service build",
77
"lint": "vue-cli-service lint",
8-
"graphql-api": "cross-env VUE_CLI_DEBUG=true vue-cli-service graphql-api",
8+
"graphql-api": "cross-env VUE_CLI_DEBUG=true VUE_CLI_UI_DEV=true vue-cli-service graphql-api",
99
"run-graphql-api": "vue-cli-service run-graphql-api",
1010
"run-test-graphql-api": "cross-env NODE_ENV=test VUE_APP_GRAPHQL_PORT=4040 VUE_APP_CLI_UI_URL=ws://localhost:4040/graphql yarn run graphql-api",
1111
"prepublishOnly": "yarn run lint --no-fix && yarn run build",

packages/@vue/cli-ui/server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exports.server = require('vue-cli-plugin-apollo/graphql-server')
2+
exports.portfinder = require('portfinder')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function _loadFolder (root, context) {
4747

4848
function loadFolder (root, context) {
4949
const folder = path.join(root, './locales')
50-
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' && !watchedTrees.get(root) && fs.existsSync(folder)) {
50+
if (process.env.VUE_CLI_UI_DEV && !watchedTrees.get(root) && fs.existsSync(folder)) {
5151
watchedTrees.set(root, true)
5252
const watch = require('watch')
5353
watch.watchTree(folder, () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const chalk = require('chalk')
22

33
exports.log = (...args) => {
4-
if (process.env.NODE_ENV === 'production') return
4+
if (!process.env.VUE_CLI_UI_DEV) return
55
const date = new Date()
66
const timestamp = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}.${date.getSeconds().toString().padStart(2, '0')}`
77
const first = args.shift()
@@ -15,7 +15,7 @@ const simpleTypes = [
1515
]
1616

1717
exports.dumpObject = (obj) => {
18-
if (process.env.NODE_ENV === 'production') return
18+
if (!process.env.VUE_CLI_UI_DEV) return
1919
const result = {}
2020
Object.keys(obj).forEach(key => {
2121
const value = obj[key]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function getPkg (context) {
4141
if (!fs.existsSync(pkgPath)) {
4242
throw new Error(`package.json not found in ${chalk.yellow(context)}`)
4343
}
44-
return require(pkgPath)
44+
return loadModule(pkgPath, context, true)
4545
}
4646

4747
async function invoke (pluginName, options = {}, context = process.cwd()) {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { log, error, openBrowser } = require('@vue/cli-shared-utils')
2-
const portfinder = require('portfinder')
2+
const { portfinder, server } = require('@vue/cli-ui/server')
33

44
async function ui (options = {}, context = process.cwd()) {
55
let port = options.port
@@ -10,14 +10,15 @@ async function ui (options = {}, context = process.cwd()) {
1010
// Config
1111
process.env.VUE_APP_CLI_UI_URL = ''
1212

13-
if (!options.dev) {
14-
// Optimize express
15-
process.env.NODE_ENV = 'production'
13+
// Optimize express
14+
process.env.NODE_ENV = 'production'
15+
16+
// Dev mode
17+
if (options.dev) {
18+
process.env.VUE_CLI_UI_DEV = true
1619
}
1720

1821
if (!options.quiet) log(`🚀 Starting GUI...`)
19-
let server = require('vue-cli-plugin-apollo/graphql-server')
20-
server = server.default || server
2122

2223
const opts = {
2324
port,
@@ -34,7 +35,8 @@ async function ui (options = {}, context = process.cwd()) {
3435
resolvers: require.resolve('@vue/cli-ui/src/graphql-api/resolvers.js'),
3536
context: require.resolve('@vue/cli-ui/src/graphql-api/context.js'),
3637
pubsub: require.resolve('@vue/cli-ui/src/graphql-api/pubsub.js'),
37-
server: require.resolve('@vue/cli-ui/src/graphql-api/server.js')
38+
server: require.resolve('@vue/cli-ui/src/graphql-api/server.js'),
39+
directives: require.resolve('@vue/cli-ui/src/graphql-api/directives.js')
3840
}
3941
}
4042

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy