forked from netlify/vue-cli-plugin-netlify-lambda
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.js
40 lines (38 loc) · 1.09 KB
/
ui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require('fs');
const path = require('path');
function getConfigData(data) {
return (data.vue && data.vue.pluginOptions && data.vue.pluginOptions.netlify) || {};
}
module.exports = api => api.describeConfig({
id: 'com.netlify.netlify-lambda',
name: 'Netlify configuration',
description: 'Configure Netlify Functions',
link: 'https://github.com/netlify/vue-cli-plugin-netlify-lambda',
files: {
vue: {
js: ['vue.config.js'],
},
},
onRead({ data, cwd }) {
return {
prompts: [
{
name: 'webpackConfig',
type: 'input',
default: null,
value: getConfigData(data).webpackConfig,
validate: input => fs.existsSync(path.join(cwd, input)),
message: 'Webpack config module',
description: 'Additional webpack configuration',
},
],
};
},
async onWrite({ api: writeApi, prompts }) {
const result = {};
for (const prompt of prompts) {
result[`pluginOptions.netlify.${prompt.id}`] = await writeApi.getAnswer(prompt.id);
}
writeApi.setData('vue', result);
},
});