mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-18 21:30:04 -06:00
38 lines
938 B
JavaScript
38 lines
938 B
JavaScript
const { createSchema, validateSync } = require('@vue/cli-shared-utils')
|
|
|
|
const schema = joi => ({
|
|
description: joi.string(),
|
|
link: joi.string().uri(),
|
|
icon: joi.string(),
|
|
prompts: joi.array(),
|
|
views: joi.array().items(joi.object({
|
|
id: joi.string().required(),
|
|
label: joi.string().required(),
|
|
icon: joi.string(),
|
|
component: joi.string().required()
|
|
})),
|
|
defaultView: joi.string(),
|
|
onBeforeRun: joi.func(),
|
|
onRun: joi.func(),
|
|
onExit: joi.func()
|
|
})
|
|
|
|
const describeSchema = createSchema(joi => ({
|
|
match: joi.object().type(RegExp).required().description('Match a npm script command'),
|
|
...schema(joi)
|
|
}))
|
|
|
|
const addSchema = createSchema(joi => ({
|
|
name: joi.string().required(),
|
|
command: joi.string().required(),
|
|
...schema(joi)
|
|
}))
|
|
|
|
exports.validateDescribeTask = (options) => {
|
|
validateSync(options, describeSchema)
|
|
}
|
|
|
|
exports.validateAddTask = (options) => {
|
|
validateSync(options, addSchema)
|
|
}
|