mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-20 11:30:43 -05:00
refactor(ui): split schema
This commit is contained in:
@@ -16,15 +16,39 @@ const ONE_SECOND = 1000
|
||||
const INSPECTPACK_PROBLEM_ACTIONS = ['versions', 'duplicates']
|
||||
const INSPECTPACK_PROBLEM_TYPE = 'problems'
|
||||
|
||||
/* Message sending to vue-cli-ui */
|
||||
ipc.config.id = 'vue-cli'
|
||||
ipc.config.retry = 1500
|
||||
ipc.config.silent = true
|
||||
|
||||
let queue
|
||||
let sendMessage
|
||||
|
||||
ipc.connectTo('vue-cli', () => {
|
||||
sendMessage = data => ipc.of['vue-cli'].emit('message', data)
|
||||
})
|
||||
function resetSendMessage () {
|
||||
console.log('ipc sendMessage reset')
|
||||
queue = []
|
||||
sendMessage = data => queue.push(data)
|
||||
}
|
||||
|
||||
function connectSendMessage () {
|
||||
console.log('ipc connect...')
|
||||
ipc.connectTo('vue-cli', () => {
|
||||
console.log('ipc connected')
|
||||
console.log(queue)
|
||||
sendMessage = data => ipc.of['vue-cli'].emit('message', data)
|
||||
queue && queue.forEach(data => sendMessage(data))
|
||||
queue = null
|
||||
})
|
||||
}
|
||||
|
||||
function disconnectSendMessage () {
|
||||
console.log('ipc disconnect...')
|
||||
ipc.disconnect('vue-cli')
|
||||
resetSendMessage()
|
||||
}
|
||||
|
||||
resetSendMessage()
|
||||
/* ----- */
|
||||
|
||||
const cacheFilename = path.resolve(os.homedir(), '.webpack-dashboard-cache.db')
|
||||
|
||||
@@ -81,7 +105,7 @@ class DashboardPlugin {
|
||||
|
||||
if (sendMessage) {
|
||||
const ipcTimer = setTimeout(() => {
|
||||
ipc.disconnect('vue-cli')
|
||||
disconnectSendMessage()
|
||||
}, 15000)
|
||||
|
||||
sendMessage({
|
||||
@@ -91,7 +115,7 @@ class DashboardPlugin {
|
||||
ipc.of['vue-cli'].on('message', data => {
|
||||
if (data.webpackDashboardAck) {
|
||||
clearTimeout(ipcTimer)
|
||||
ipc.disconnect('vue-cli')
|
||||
disconnectSendMessage()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -111,8 +135,10 @@ class DashboardPlugin {
|
||||
|
||||
const nodeEnv = process.env.NODE_ENV
|
||||
|
||||
connectSendMessage()
|
||||
|
||||
if (!handler) {
|
||||
handler = data => sendMessage && sendMessage({
|
||||
handler = data => sendMessage({
|
||||
webpackDashboardData: {
|
||||
type: this.type,
|
||||
value: data
|
||||
@@ -151,6 +177,7 @@ class DashboardPlugin {
|
||||
|
||||
compiler.plugin('compile', () => {
|
||||
timer = Date.now()
|
||||
|
||||
handler([
|
||||
{
|
||||
type: 'status',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = api => {
|
||||
const { setSharedData } = api.namespace('webpack-dashboard-')
|
||||
const { setSharedData, getSharedData } = api.namespace('webpack-dashboard-')
|
||||
|
||||
function resetSharedData (key) {
|
||||
setSharedData(`${key}-status`, null)
|
||||
@@ -24,8 +24,10 @@ module.exports = api => {
|
||||
}
|
||||
|
||||
// Init data
|
||||
for (const key of ['serve', 'build']) {
|
||||
resetSharedData(key)
|
||||
if (typeof getSharedData('serve-status') === 'undefined') {
|
||||
for (const key of ['serve', 'build']) {
|
||||
resetSharedData(key)
|
||||
}
|
||||
}
|
||||
|
||||
// Tasks
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"graphql": "^0.13.0",
|
||||
"graphql-type-json": "^0.2.0",
|
||||
"js-yaml": "^3.11.0",
|
||||
"lodash.merge": "^4.6.1",
|
||||
"lowdb": "^1.0.0",
|
||||
"lru-cache": "^4.1.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
|
||||
@@ -201,11 +201,6 @@ function applyPreset (id, context) {
|
||||
return generateProjectCreation(creator)
|
||||
}
|
||||
|
||||
function answerPrompt ({ id, value }, context) {
|
||||
prompts.setValue({ id, value: JSON.parse(value) })
|
||||
return prompts.list()
|
||||
}
|
||||
|
||||
async function create (input, context) {
|
||||
return progress.wrap(PROGRESS_ID, context, async setProgress => {
|
||||
setProgress({
|
||||
@@ -340,7 +335,6 @@ module.exports = {
|
||||
getCreation,
|
||||
applyPreset,
|
||||
setFeatureEnabled,
|
||||
answerPrompt,
|
||||
create,
|
||||
import: importProject,
|
||||
open,
|
||||
|
||||
@@ -222,6 +222,11 @@ function getDefaultValue (prompt) {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
function answerPrompt ({ id, value }, context) {
|
||||
setValue({ id, value: JSON.parse(value) })
|
||||
return list()
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setAnswers,
|
||||
changeAnswers,
|
||||
@@ -233,5 +238,6 @@ module.exports = {
|
||||
start,
|
||||
setValue,
|
||||
findOne,
|
||||
getDefaultValue
|
||||
getDefaultValue,
|
||||
answerPrompt
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ function run (id, context) {
|
||||
if (task && task.status !== 'running') {
|
||||
const args = ['run', task.name]
|
||||
const answers = prompts.getAnswers()
|
||||
const command = getCommand()
|
||||
|
||||
// Save parameters
|
||||
updateSavedData({
|
||||
@@ -150,7 +151,11 @@ function run (id, context) {
|
||||
})
|
||||
}
|
||||
|
||||
const child = execa(getCommand(), args, {
|
||||
if (command === 'npm') {
|
||||
args.splice(0, 0, '--')
|
||||
}
|
||||
|
||||
const child = execa(command, args, {
|
||||
cwd: cwd.get(),
|
||||
stdio: ['inherit', 'pipe', 'pipe', 'ipc']
|
||||
})
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
const { withFilter } = require('graphql-subscriptions')
|
||||
const path = require('path')
|
||||
const globby = require('globby')
|
||||
const merge = require('lodash.merge')
|
||||
const exit = require('@vue/cli-shared-utils/lib/exit')
|
||||
const GraphQLJSON = require('graphql-type-json')
|
||||
// Channels for subscriptions
|
||||
const channels = require('./channels')
|
||||
// Connectors
|
||||
const cwd = require('./connectors/cwd')
|
||||
const folders = require('./connectors/folders')
|
||||
const projects = require('./connectors/projects')
|
||||
const progress = require('./connectors/progress')
|
||||
const logs = require('./connectors/logs')
|
||||
const plugins = require('./connectors/plugins')
|
||||
const tasks = require('./connectors/tasks')
|
||||
const configurations = require('./connectors/configurations')
|
||||
const git = require('./connectors/git')
|
||||
const files = require('./connectors/files')
|
||||
const routes = require('./connectors/routes')
|
||||
const clientAddons = require('./connectors/client-addons')
|
||||
@@ -25,84 +21,18 @@ exit.exitProcess = false
|
||||
|
||||
process.env.VUE_CLI_API_MODE = true
|
||||
|
||||
module.exports = {
|
||||
const resolvers = [{
|
||||
JSON: GraphQLJSON,
|
||||
|
||||
Folder: {
|
||||
children: (folder, args, context) => folders.list(folder.path, context),
|
||||
isPackage: (folder, args, context) => folders.isPackage(folder.path, context),
|
||||
isVueProject: (folder, args, context) => folders.isVueProject(folder.path, context)
|
||||
},
|
||||
|
||||
Project: {
|
||||
plugins: (project, args, context) => plugins.list(project.path, context)
|
||||
},
|
||||
|
||||
Plugin: {
|
||||
version: (plugin, args, context) => plugins.getVersion(plugin, context),
|
||||
description: (plugin, args, context) => plugins.getDescription(plugin, context),
|
||||
logo: (plugin, args, context) => plugins.getLogo(plugin, context)
|
||||
},
|
||||
|
||||
Task: {
|
||||
prompts: (task, args, context) => tasks.getPrompts(task.id, context)
|
||||
},
|
||||
|
||||
Configuration: {
|
||||
prompts: (configuration, args, context) => configurations.getPrompts(configuration.id, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
cwd: () => cwd.get(),
|
||||
consoleLogs: (root, args, context) => logs.list(context),
|
||||
consoleLogLast: (root, args, context) => logs.last(context),
|
||||
progress: (root, { id }, context) => progress.get(id, context),
|
||||
folderCurrent: (root, args, context) => folders.getCurrent(args, context),
|
||||
foldersFavorite: (root, args, context) => folders.listFavorite(context),
|
||||
projects: (root, args, context) => projects.list(context),
|
||||
projectCurrent: (root, args, context) => projects.getCurrent(context),
|
||||
projectCreation: (root, args, context) => projects.getCreation(context),
|
||||
pluginInstallation: (root, args, context) => plugins.getInstallation(context),
|
||||
plugin: (root, { id }, context) => plugins.findOne(id, context),
|
||||
tasks: (root, args, context) => tasks.list(context),
|
||||
task: (root, { id }, context) => tasks.findOne(id, context),
|
||||
configurations: (root, args, context) => configurations.list(context),
|
||||
configuration: (root, { id }, context) => configurations.findOne(id, context),
|
||||
fileDiffs: (root, args, context) => git.getDiffs(context),
|
||||
routes: (root, args, context) => routes.list(context),
|
||||
clientAddons: (root, args, context) => clientAddons.list(context),
|
||||
sharedData: (root, { id }, context) => sharedData.get(id, context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
consoleLogsClear: (root, args, context) => logs.clear(context),
|
||||
folderOpen: (root, { path }, context) => folders.open(path, context),
|
||||
folderOpenParent: (root, args, context) => folders.openParent(cwd.get(), context),
|
||||
folderSetFavorite: (root, args, context) => folders.setFavorite({
|
||||
file: args.path,
|
||||
favorite: args.favorite
|
||||
}, context),
|
||||
presetApply: (root, { id }, context) => projects.applyPreset(id, context),
|
||||
featureSetEnabled: (root, args, context) => projects.setFeatureEnabled(args, context),
|
||||
promptAnswer: (root, { input }, context) => projects.answerPrompt(input, context),
|
||||
projectCreate: (root, { input }, context) => projects.create(input, context),
|
||||
projectImport: (root, { input }, context) => projects.import(input, context),
|
||||
projectOpen: (root, { id }, context) => projects.open(id, context),
|
||||
projectRemove: (root, { id }, context) => projects.remove(id, context),
|
||||
projectCwdReset: (root, args, context) => projects.resetCwd(context),
|
||||
projectSetFavorite: (root, args, context) => projects.setFavorite(args, context),
|
||||
pluginInstall: (root, { id }, context) => plugins.install(id, context),
|
||||
pluginUninstall: (root, { id }, context) => plugins.uninstall(id, context),
|
||||
pluginInvoke: (root, { id }, context) => plugins.runInvoke(id, context),
|
||||
pluginFinishInstall: (root, args, context) => plugins.finishInstall(context),
|
||||
pluginUpdate: (root, { id }, context) => plugins.update(id, context),
|
||||
pluginActionCall: (root, args, context) => plugins.callAction(args, context),
|
||||
taskRun: (root, { id }, context) => tasks.run(id, context),
|
||||
taskStop: (root, { id }, context) => tasks.stop(id, context),
|
||||
taskLogsClear: (root, { id }, context) => tasks.clearLogs(id, context),
|
||||
configurationSave: (root, { id }, context) => configurations.save(id, context),
|
||||
configurationCancel: (root, { id }, context) => configurations.cancel(id, context),
|
||||
gitCommit: (root, { message }, context) => git.commit(message, context),
|
||||
fileOpenInEditor: (root, { input }, context) => files.openInEditor(input, context),
|
||||
sharedDataUpdate: (root, args, context) => sharedData.set(args, context)
|
||||
},
|
||||
@@ -127,21 +57,6 @@ module.exports = {
|
||||
(payload, vars) => payload.progressRemoved.id === vars.id
|
||||
)
|
||||
},
|
||||
consoleLogAdded: {
|
||||
subscribe: (parent, args, context) => {
|
||||
logs.init(context)
|
||||
return context.pubsub.asyncIterator(channels.CONSOLE_LOG_ADDED)
|
||||
}
|
||||
},
|
||||
taskChanged: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.TASK_CHANGED)
|
||||
},
|
||||
taskLogAdded: {
|
||||
subscribe: withFilter(
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator(channels.TASK_LOG_ADDED),
|
||||
(payload, vars) => payload.taskLogAdded.taskId === vars.id
|
||||
)
|
||||
},
|
||||
clientAddonAdded: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.CLIENT_ADDON_ADDED)
|
||||
},
|
||||
@@ -150,12 +65,15 @@ module.exports = {
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator(channels.SHARED_DATA_UPDATED),
|
||||
(payload, vars) => payload.sharedDataUpdated.id === vars.id
|
||||
)
|
||||
},
|
||||
pluginActionCalled: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.PLUGIN_ACTION_CALLED)
|
||||
},
|
||||
pluginActionResolved: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.PLUGIN_ACTION_RESOLVED)
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
// Load resolvers in './schema'
|
||||
const paths = globby.sync([path.join(__dirname, './schema/*.js')])
|
||||
paths.forEach(file => {
|
||||
const { resolvers: r } = require(file)
|
||||
r && resolvers.push(r)
|
||||
})
|
||||
|
||||
module.exports = merge.apply(null, resolvers)
|
||||
|
||||
40
packages/@vue/cli-ui/src/graphql-api/schema/configuration.js
Normal file
40
packages/@vue/cli-ui/src/graphql-api/schema/configuration.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Connectors
|
||||
const configurations = require('../connectors/configurations')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
configurations: [Configuration]
|
||||
configuration (id: ID!): Configuration
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
configurationSave (id: ID!): Configuration
|
||||
configurationCancel (id: ID!): Configuration
|
||||
}
|
||||
|
||||
type Configuration implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
icon: String
|
||||
prompts: [Prompt]
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Configuration: {
|
||||
prompts: (configuration, args, context) => configurations.getPrompts(configuration.id, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
configurations: (root, args, context) => configurations.list(context),
|
||||
configuration: (root, { id }, context) => configurations.findOne(id, context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
configurationSave: (root, { id }, context) => configurations.save(id, context),
|
||||
configurationCancel: (root, { id }, context) => configurations.cancel(id, context)
|
||||
}
|
||||
}
|
||||
56
packages/@vue/cli-ui/src/graphql-api/schema/console.js
Normal file
56
packages/@vue/cli-ui/src/graphql-api/schema/console.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Subs
|
||||
const channels = require('../channels')
|
||||
// Connectors
|
||||
const logs = require('../connectors/logs')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
consoleLogs: [ConsoleLog]
|
||||
consoleLogLast: ConsoleLog
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
consoleLogsClear: [ConsoleLog]
|
||||
}
|
||||
|
||||
extend type Subscription {
|
||||
consoleLogAdded: ConsoleLog!
|
||||
}
|
||||
|
||||
type ConsoleLog {
|
||||
id: ID!
|
||||
message: String!
|
||||
tag: String
|
||||
type: ConsoleLogType!
|
||||
date: String
|
||||
}
|
||||
|
||||
enum ConsoleLogType {
|
||||
log
|
||||
warn
|
||||
error
|
||||
info
|
||||
done
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Query: {
|
||||
consoleLogs: (root, args, context) => logs.list(context),
|
||||
consoleLogLast: (root, args, context) => logs.last(context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
consoleLogsClear: (root, args, context) => logs.clear(context)
|
||||
},
|
||||
|
||||
Subscription: {
|
||||
consoleLogAdded: {
|
||||
subscribe: (parent, args, context) => {
|
||||
logs.init(context)
|
||||
return context.pubsub.asyncIterator(channels.CONSOLE_LOG_ADDED)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
packages/@vue/cli-ui/src/graphql-api/schema/folder.js
Normal file
48
packages/@vue/cli-ui/src/graphql-api/schema/folder.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Connectors
|
||||
const folders = require('../connectors/folders')
|
||||
const cwd = require('../connectors/cwd')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
folderCurrent: Folder
|
||||
foldersFavorite: [Folder]
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
folderOpen (path: String!): Folder
|
||||
folderOpenParent: Folder
|
||||
folderSetFavorite (path: String!, favorite: Boolean!): Folder
|
||||
}
|
||||
|
||||
type Folder {
|
||||
name: String!
|
||||
path: String!
|
||||
isPackage: Boolean
|
||||
isVueProject: Boolean
|
||||
favorite: Boolean
|
||||
children: [Folder]
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Folder: {
|
||||
children: (folder, args, context) => folders.list(folder.path, context),
|
||||
isPackage: (folder, args, context) => folders.isPackage(folder.path, context),
|
||||
isVueProject: (folder, args, context) => folders.isVueProject(folder.path, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
folderCurrent: (root, args, context) => folders.getCurrent(args, context),
|
||||
foldersFavorite: (root, args, context) => folders.listFavorite(context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
folderOpen: (root, { path }, context) => folders.open(path, context),
|
||||
folderOpenParent: (root, args, context) => folders.openParent(cwd.get(), context),
|
||||
folderSetFavorite: (root, args, context) => folders.setFavorite({
|
||||
file: args.path,
|
||||
favorite: args.favorite
|
||||
}, context)
|
||||
}
|
||||
}
|
||||
56
packages/@vue/cli-ui/src/graphql-api/schema/git.js
Normal file
56
packages/@vue/cli-ui/src/graphql-api/schema/git.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Connectors
|
||||
const git = require('../connectors/git')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
fileDiffs: [FileDiff]
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
gitCommit (message: String!): Boolean
|
||||
}
|
||||
|
||||
type FileDiff {
|
||||
id: ID!
|
||||
from: String
|
||||
to: String
|
||||
new: Boolean
|
||||
deleted: Boolean
|
||||
binary: Boolean
|
||||
chunks: [FileDiffChunk]
|
||||
}
|
||||
|
||||
type FileDiffChunk {
|
||||
changes: [FileDiffChange]
|
||||
oldStart: Int
|
||||
oldLines: Int
|
||||
newStart: Int
|
||||
newLines: Int
|
||||
}
|
||||
|
||||
type FileDiffChange {
|
||||
type: FileDiffChangeType
|
||||
ln: Int
|
||||
ln1: Int
|
||||
ln2: Int
|
||||
content: String
|
||||
normal: Boolean
|
||||
}
|
||||
|
||||
enum FileDiffChangeType {
|
||||
normal
|
||||
add
|
||||
del
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Query: {
|
||||
fileDiffs: (root, args, context) => git.getDiffs(context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
gitCommit: (root, { message }, context) => git.commit(message, context)
|
||||
}
|
||||
}
|
||||
94
packages/@vue/cli-ui/src/graphql-api/schema/plugin.js
Normal file
94
packages/@vue/cli-ui/src/graphql-api/schema/plugin.js
Normal file
@@ -0,0 +1,94 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Subs
|
||||
const channels = require('../channels')
|
||||
// Connectors
|
||||
const plugins = require('../connectors/plugins')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
pluginInstallation: PluginInstallation
|
||||
plugin (id: ID!): Plugin
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
pluginInstall (id: ID!): PluginInstallation
|
||||
pluginUninstall (id: ID!): PluginInstallation
|
||||
pluginInvoke (id: ID!): PluginInstallation
|
||||
pluginFinishInstall: PluginInstallation
|
||||
pluginUpdate (id: ID!): Plugin
|
||||
pluginActionCall (id: ID!, params: JSON): PluginActionResult
|
||||
}
|
||||
|
||||
extend type Subscription {
|
||||
pluginActionCalled: PluginActionCall
|
||||
pluginActionResolved: PluginActionResult
|
||||
}
|
||||
|
||||
type Plugin {
|
||||
id: ID!
|
||||
version: Version!
|
||||
official: Boolean
|
||||
installed: Boolean
|
||||
website: String
|
||||
description: String
|
||||
githubStats: GitHubStats
|
||||
logo: String
|
||||
}
|
||||
|
||||
type PluginInstallation {
|
||||
id: ID!
|
||||
pluginId: ID
|
||||
step: PluginInstallationStep
|
||||
prompts: [Prompt]
|
||||
}
|
||||
|
||||
enum PluginInstallationStep {
|
||||
install
|
||||
uninstall
|
||||
config
|
||||
diff
|
||||
}
|
||||
|
||||
type PluginActionCall {
|
||||
id: ID!
|
||||
params: JSON
|
||||
}
|
||||
|
||||
type PluginActionResult {
|
||||
id: ID!
|
||||
params: JSON
|
||||
results: [JSON]
|
||||
errors: [JSON]
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Plugin: {
|
||||
version: (plugin, args, context) => plugins.getVersion(plugin, context),
|
||||
description: (plugin, args, context) => plugins.getDescription(plugin, context),
|
||||
logo: (plugin, args, context) => plugins.getLogo(plugin, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
pluginInstallation: (root, args, context) => plugins.getInstallation(context),
|
||||
plugin: (root, { id }, context) => plugins.findOne(id, context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
pluginInstall: (root, { id }, context) => plugins.install(id, context),
|
||||
pluginUninstall: (root, { id }, context) => plugins.uninstall(id, context),
|
||||
pluginInvoke: (root, { id }, context) => plugins.runInvoke(id, context),
|
||||
pluginFinishInstall: (root, args, context) => plugins.finishInstall(context),
|
||||
pluginUpdate: (root, { id }, context) => plugins.update(id, context),
|
||||
pluginActionCall: (root, args, context) => plugins.callAction(args, context)
|
||||
},
|
||||
|
||||
Subscription: {
|
||||
pluginActionCalled: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.PLUGIN_ACTION_CALLED)
|
||||
},
|
||||
pluginActionResolved: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.PLUGIN_ACTION_RESOLVED)
|
||||
}
|
||||
}
|
||||
}
|
||||
90
packages/@vue/cli-ui/src/graphql-api/schema/project.js
Normal file
90
packages/@vue/cli-ui/src/graphql-api/schema/project.js
Normal file
@@ -0,0 +1,90 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Connectors
|
||||
const projects = require('../connectors/projects')
|
||||
const plugins = require('../connectors/plugins')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
projects: [Project]
|
||||
projectCurrent: Project
|
||||
projectCreation: ProjectCreation
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
projectCreate (input: ProjectCreateInput!): Project!
|
||||
projectImport (input: ProjectImportInput!): Project!
|
||||
projectOpen (id: ID!): Project!
|
||||
projectRemove (id: ID!): Boolean!
|
||||
projectCwdReset: String
|
||||
projectSetFavorite (id: ID!, favorite: Int!): Project!
|
||||
presetApply (id: ID!): ProjectCreation
|
||||
featureSetEnabled (id: ID!, enabled: Boolean): Feature
|
||||
}
|
||||
|
||||
type Project {
|
||||
id: ID!
|
||||
name: String!
|
||||
path: String!
|
||||
favorite: Int
|
||||
plugins: [Plugin]
|
||||
}
|
||||
|
||||
input ProjectCreateInput {
|
||||
folder: String!
|
||||
force: Boolean!
|
||||
packageManager: PackageManager
|
||||
preset: String!
|
||||
remote: Boolean
|
||||
clone: Boolean
|
||||
save: String
|
||||
}
|
||||
|
||||
input ProjectImportInput {
|
||||
path: String!
|
||||
}
|
||||
|
||||
type Preset implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
features: [String]
|
||||
}
|
||||
|
||||
type ProjectCreation {
|
||||
presets: [Preset]
|
||||
features: [Feature]
|
||||
prompts: [Prompt]
|
||||
}
|
||||
|
||||
type Feature implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
enabled: Boolean!
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Project: {
|
||||
plugins: (project, args, context) => plugins.list(project.path, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
projects: (root, args, context) => projects.list(context),
|
||||
projectCurrent: (root, args, context) => projects.getCurrent(context),
|
||||
projectCreation: (root, args, context) => projects.getCreation(context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
projectCreate: (root, { input }, context) => projects.create(input, context),
|
||||
projectImport: (root, { input }, context) => projects.import(input, context),
|
||||
projectOpen: (root, { id }, context) => projects.open(id, context),
|
||||
projectRemove: (root, { id }, context) => projects.remove(id, context),
|
||||
projectCwdReset: (root, args, context) => projects.resetCwd(context),
|
||||
projectSetFavorite: (root, args, context) => projects.setFavorite(args, context),
|
||||
presetApply: (root, { id }, context) => projects.applyPreset(id, context),
|
||||
featureSetEnabled: (root, args, context) => projects.setFeatureEnabled(args, context)
|
||||
}
|
||||
}
|
||||
59
packages/@vue/cli-ui/src/graphql-api/schema/prompt.js
Normal file
59
packages/@vue/cli-ui/src/graphql-api/schema/prompt.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Connectors
|
||||
const prompts = require('../connectors/prompts')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Mutation {
|
||||
promptAnswer (input: PromptInput!): [Prompt]
|
||||
}
|
||||
|
||||
type Prompt implements DescribedEntity {
|
||||
id: ID!
|
||||
type: PromptType!
|
||||
visible: Boolean!
|
||||
enabled: Boolean
|
||||
name: String
|
||||
message: String
|
||||
description: String
|
||||
link: String
|
||||
choices: [PromptChoice]
|
||||
value: String
|
||||
valueChanged: Boolean
|
||||
error: PromptError
|
||||
}
|
||||
|
||||
input PromptInput {
|
||||
id: ID!
|
||||
value: String!
|
||||
}
|
||||
|
||||
type PromptChoice {
|
||||
value: String!
|
||||
name: String
|
||||
checked: Boolean
|
||||
disabled: Boolean
|
||||
isDefault: Boolean
|
||||
}
|
||||
|
||||
type PromptError {
|
||||
message: String!
|
||||
link: String
|
||||
}
|
||||
|
||||
enum PromptType {
|
||||
input
|
||||
confirm
|
||||
list
|
||||
rawlist
|
||||
expand
|
||||
checkbox
|
||||
password
|
||||
editor
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Mutation: {
|
||||
promptAnswer: (root, { input }, context) => prompts.answerPrompt(input, context)
|
||||
}
|
||||
}
|
||||
92
packages/@vue/cli-ui/src/graphql-api/schema/task.js
Normal file
92
packages/@vue/cli-ui/src/graphql-api/schema/task.js
Normal file
@@ -0,0 +1,92 @@
|
||||
const gql = require('graphql-tag')
|
||||
// Subs
|
||||
const { withFilter } = require('graphql-subscriptions')
|
||||
const channels = require('../channels')
|
||||
// Connectors
|
||||
const tasks = require('../connectors/tasks')
|
||||
|
||||
exports.types = gql`
|
||||
extend type Query {
|
||||
tasks: [Task]
|
||||
task (id: ID!): Task
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
taskRun (id: ID!): Task
|
||||
taskStop (id: ID!): Task
|
||||
taskLogsClear (id: ID!): Task
|
||||
}
|
||||
|
||||
extend type Subscription {
|
||||
taskChanged: Task
|
||||
taskLogAdded (id: ID!): TaskLog
|
||||
}
|
||||
|
||||
type Task implements DescribedEntity {
|
||||
id: ID!
|
||||
status: TaskStatus!
|
||||
command: String!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
logs: [TaskLog]
|
||||
prompts: [Prompt]
|
||||
views: [TaskView]
|
||||
defaultView: String
|
||||
}
|
||||
|
||||
enum TaskStatus {
|
||||
idle
|
||||
running
|
||||
done
|
||||
error
|
||||
terminated
|
||||
}
|
||||
|
||||
type TaskLog {
|
||||
taskId: ID!
|
||||
type: TaskLogType!
|
||||
text: String
|
||||
}
|
||||
|
||||
enum TaskLogType {
|
||||
stdout
|
||||
stderr
|
||||
}
|
||||
|
||||
type TaskView {
|
||||
id: ID!
|
||||
label: String!
|
||||
component: String!
|
||||
icon: String
|
||||
}
|
||||
`
|
||||
|
||||
exports.resolvers = {
|
||||
Task: {
|
||||
prompts: (task, args, context) => tasks.getPrompts(task.id, context)
|
||||
},
|
||||
|
||||
Query: {
|
||||
tasks: (root, args, context) => tasks.list(context),
|
||||
task: (root, { id }, context) => tasks.findOne(id, context)
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
taskRun: (root, { id }, context) => tasks.run(id, context),
|
||||
taskStop: (root, { id }, context) => tasks.stop(id, context),
|
||||
taskLogsClear: (root, { id }, context) => tasks.clearLogs(id, context)
|
||||
},
|
||||
|
||||
Subscription: {
|
||||
taskChanged: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator(channels.TASK_CHANGED)
|
||||
},
|
||||
taskLogAdded: {
|
||||
subscribe: withFilter(
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator(channels.TASK_LOG_ADDED),
|
||||
(payload, vars) => payload.taskLogAdded.taskId === vars.id
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,10 @@
|
||||
module.exports = `
|
||||
const gql = require('graphql-tag')
|
||||
const path = require('path')
|
||||
const globby = require('globby')
|
||||
|
||||
const typeDefs = [gql`
|
||||
scalar JSON
|
||||
|
||||
type ConsoleLog {
|
||||
id: ID!
|
||||
message: String!
|
||||
tag: String
|
||||
type: ConsoleLogType!
|
||||
date: String
|
||||
}
|
||||
|
||||
enum ConsoleLogType {
|
||||
log
|
||||
warn
|
||||
error
|
||||
info
|
||||
done
|
||||
}
|
||||
|
||||
enum PackageManager {
|
||||
npm
|
||||
yarn
|
||||
@@ -28,51 +16,6 @@ interface DescribedEntity {
|
||||
link: String
|
||||
}
|
||||
|
||||
type Folder {
|
||||
name: String!
|
||||
path: String!
|
||||
isPackage: Boolean
|
||||
isVueProject: Boolean
|
||||
favorite: Boolean
|
||||
children: [Folder]
|
||||
}
|
||||
|
||||
type Project {
|
||||
id: ID!
|
||||
name: String!
|
||||
path: String!
|
||||
favorite: Int
|
||||
plugins: [Plugin]
|
||||
}
|
||||
|
||||
input ProjectCreateInput {
|
||||
folder: String!
|
||||
force: Boolean!
|
||||
packageManager: PackageManager
|
||||
preset: String!
|
||||
remote: Boolean
|
||||
clone: Boolean
|
||||
save: String
|
||||
}
|
||||
|
||||
input ProjectImportInput {
|
||||
path: String!
|
||||
}
|
||||
|
||||
type Preset implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
features: [String]
|
||||
}
|
||||
|
||||
type ProjectCreation {
|
||||
presets: [Preset]
|
||||
features: [Feature]
|
||||
prompts: [Prompt]
|
||||
}
|
||||
|
||||
type Version {
|
||||
current: String
|
||||
latest: String
|
||||
@@ -84,95 +27,6 @@ type GitHubStats {
|
||||
stars: Int
|
||||
}
|
||||
|
||||
type Plugin {
|
||||
id: ID!
|
||||
version: Version!
|
||||
official: Boolean
|
||||
installed: Boolean
|
||||
website: String
|
||||
description: String
|
||||
githubStats: GitHubStats
|
||||
logo: String
|
||||
}
|
||||
|
||||
type PluginInstallation {
|
||||
id: ID!
|
||||
pluginId: ID
|
||||
step: PluginInstallationStep
|
||||
prompts: [Prompt]
|
||||
}
|
||||
|
||||
enum PluginInstallationStep {
|
||||
install
|
||||
uninstall
|
||||
config
|
||||
diff
|
||||
}
|
||||
|
||||
type PluginActionCall {
|
||||
id: ID!
|
||||
params: JSON
|
||||
}
|
||||
|
||||
type PluginActionResult {
|
||||
id: ID!
|
||||
params: JSON
|
||||
results: [JSON]
|
||||
errors: [JSON]
|
||||
}
|
||||
|
||||
type Feature implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
enabled: Boolean!
|
||||
}
|
||||
|
||||
enum PromptType {
|
||||
input
|
||||
confirm
|
||||
list
|
||||
rawlist
|
||||
expand
|
||||
checkbox
|
||||
password
|
||||
editor
|
||||
}
|
||||
|
||||
type PromptChoice {
|
||||
value: String!
|
||||
name: String
|
||||
checked: Boolean
|
||||
disabled: Boolean
|
||||
isDefault: Boolean
|
||||
}
|
||||
|
||||
type PromptError {
|
||||
message: String!
|
||||
link: String
|
||||
}
|
||||
|
||||
type Prompt implements DescribedEntity {
|
||||
id: ID!
|
||||
type: PromptType!
|
||||
visible: Boolean!
|
||||
enabled: Boolean
|
||||
name: String
|
||||
message: String
|
||||
description: String
|
||||
link: String
|
||||
choices: [PromptChoice]
|
||||
value: String
|
||||
valueChanged: Boolean
|
||||
error: PromptError
|
||||
}
|
||||
|
||||
input PromptInput {
|
||||
id: ID!
|
||||
value: String!
|
||||
}
|
||||
|
||||
type Progress {
|
||||
id: ID!
|
||||
status: String
|
||||
@@ -183,87 +37,6 @@ type Progress {
|
||||
args: [String]
|
||||
}
|
||||
|
||||
type Task implements DescribedEntity {
|
||||
id: ID!
|
||||
status: TaskStatus!
|
||||
command: String!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
logs: [TaskLog]
|
||||
prompts: [Prompt]
|
||||
views: [TaskView]
|
||||
defaultView: String
|
||||
}
|
||||
|
||||
enum TaskStatus {
|
||||
idle
|
||||
running
|
||||
done
|
||||
error
|
||||
terminated
|
||||
}
|
||||
|
||||
type TaskLog {
|
||||
taskId: ID!
|
||||
type: TaskLogType!
|
||||
text: String
|
||||
}
|
||||
|
||||
enum TaskLogType {
|
||||
stdout
|
||||
stderr
|
||||
}
|
||||
|
||||
type TaskView {
|
||||
id: ID!
|
||||
label: String!
|
||||
component: String!
|
||||
icon: String
|
||||
}
|
||||
|
||||
type Configuration implements DescribedEntity {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
link: String
|
||||
icon: String
|
||||
prompts: [Prompt]
|
||||
}
|
||||
|
||||
type FileDiff {
|
||||
id: ID!
|
||||
from: String
|
||||
to: String
|
||||
new: Boolean
|
||||
deleted: Boolean
|
||||
binary: Boolean
|
||||
chunks: [FileDiffChunk]
|
||||
}
|
||||
|
||||
type FileDiffChunk {
|
||||
changes: [FileDiffChange]
|
||||
oldStart: Int
|
||||
oldLines: Int
|
||||
newStart: Int
|
||||
newLines: Int
|
||||
}
|
||||
|
||||
type FileDiffChange {
|
||||
type: FileDiffChangeType
|
||||
ln: Int
|
||||
ln1: Int
|
||||
ln2: Int
|
||||
content: String
|
||||
normal: Boolean
|
||||
}
|
||||
|
||||
enum FileDiffChangeType {
|
||||
normal
|
||||
add
|
||||
del
|
||||
}
|
||||
|
||||
input OpenInEditorInput {
|
||||
file: String!
|
||||
line: Int
|
||||
@@ -291,51 +64,12 @@ type SharedData {
|
||||
type Query {
|
||||
progress (id: ID!): Progress
|
||||
cwd: String!
|
||||
consoleLogs: [ConsoleLog]
|
||||
consoleLogLast: ConsoleLog
|
||||
folderCurrent: Folder
|
||||
foldersFavorite: [Folder]
|
||||
projects: [Project]
|
||||
projectCurrent: Project
|
||||
projectCreation: ProjectCreation
|
||||
pluginInstallation: PluginInstallation
|
||||
plugin (id: ID!): Plugin
|
||||
tasks: [Task]
|
||||
task (id: ID!): Task
|
||||
configurations: [Configuration]
|
||||
configuration (id: ID!): Configuration
|
||||
fileDiffs: [FileDiff]
|
||||
routes: [Route]
|
||||
clientAddons: [ClientAddon]
|
||||
sharedData (id: ID!): SharedData
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
consoleLogsClear: [ConsoleLog]
|
||||
folderOpen (path: String!): Folder
|
||||
folderOpenParent: Folder
|
||||
folderSetFavorite (path: String!, favorite: Boolean!): Folder
|
||||
projectCreate (input: ProjectCreateInput!): Project!
|
||||
projectImport (input: ProjectImportInput!): Project!
|
||||
projectOpen (id: ID!): Project!
|
||||
projectSetFavorite (id: ID!, favorite: Int!): Project!
|
||||
projectRemove (id: ID!): Boolean!
|
||||
projectCwdReset: String
|
||||
presetApply (id: ID!): ProjectCreation
|
||||
featureSetEnabled (id: ID!, enabled: Boolean): Feature
|
||||
promptAnswer (input: PromptInput!): [Prompt]
|
||||
pluginInstall (id: ID!): PluginInstallation
|
||||
pluginUninstall (id: ID!): PluginInstallation
|
||||
pluginInvoke (id: ID!): PluginInstallation
|
||||
pluginFinishInstall: PluginInstallation
|
||||
pluginUpdate (id: ID!): Plugin
|
||||
pluginActionCall (id: ID!, params: JSON): PluginActionResult
|
||||
taskRun (id: ID!): Task
|
||||
taskStop (id: ID!): Task
|
||||
taskLogsClear (id: ID!): Task
|
||||
configurationSave (id: ID!): Configuration
|
||||
configurationCancel (id: ID!): Configuration
|
||||
gitCommit (message: String!): Boolean
|
||||
fileOpenInEditor (input: OpenInEditorInput!): Boolean
|
||||
sharedDataUpdate (id: ID!, value: JSON!): SharedData
|
||||
}
|
||||
@@ -343,16 +77,20 @@ type Mutation {
|
||||
type Subscription {
|
||||
progressChanged (id: ID!): Progress
|
||||
progressRemoved (id: ID!): ID
|
||||
consoleLogAdded: ConsoleLog!
|
||||
cwdChanged: String!
|
||||
taskChanged: Task
|
||||
taskLogAdded (id: ID!): TaskLog
|
||||
routeAdded: Route
|
||||
routeRemoved: Route
|
||||
routeChanged: Route
|
||||
clientAddonAdded: ClientAddon
|
||||
sharedDataUpdated (id: ID!): SharedData
|
||||
pluginActionCalled: PluginActionCall
|
||||
pluginActionResolved: PluginActionResult
|
||||
}
|
||||
`
|
||||
`]
|
||||
|
||||
// Load types in './schema'
|
||||
const paths = globby.sync([path.join(__dirname, './schema/*.js')])
|
||||
paths.forEach(file => {
|
||||
const { types } = require(file)
|
||||
types && typeDefs.push(types)
|
||||
})
|
||||
|
||||
module.exports = typeDefs
|
||||
|
||||
@@ -7055,7 +7055,7 @@ lodash.memoize@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
||||
|
||||
lodash.merge@^4.6.0:
|
||||
lodash.merge@^4.6.0, lodash.merge@^4.6.1:
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user