This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompts.js
95 lines (90 loc) · 2.01 KB
/
prompts.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const axios = require('axios');
const http = axios.create({
headers: {
Authorization: `Bearer ${process.argv[4]}`,
},
baseURL: 'https://api.staging-chameleon.nsoft.cloud',
});
const validateBundleName = (name) => {
if (name.length < 2) {
return 'Bundle name must contain two or more characters';
}
return http.get('/bundles', {
params: {
name: name,
},
}).then((response) => {
if (response.data.length > 0) {
return `Bundle name already exist, try with a different name!`;
}
return true;
});
};
const validateBundleNamespace = (namespace) => {
const paramsName = `${namespace}-`;
const pattern = /^[a-z]{1,2}$/;
const isValid = pattern.test(namespace);
if (!isValid) {
return `Bundle namespace must contain at least one and maximum of 2 characters.
Special characters and numbers are not allowed.`;
}
return http.get('/bundles', {
params: {
name: paramsName,
},
}).then((response) => {
if (response.data.length > 0) {
return `Bundle namespace already exist, try with a different namespace!`;
}
return true;
});
};
module.exports = [
{
name: 'name',
type: 'string',
required: true,
message: 'Project Name',
default: 'chameleon-bundle',
},
{
name: 'description',
type: 'string',
message: 'Project Description',
default: 'Chameleon Bundle Project',
},
{
name: 'author',
type: 'string',
message: 'Author',
},
{
name: 'license',
type: 'string',
label: 'License',
default: 'MIT',
},
{
name: 'bundleNamespace',
type: 'string',
required: true,
message: 'Bundle Namespace',
default: 'z',
validate: validateBundleNamespace,
},
{
name: 'bundleName',
type: 'string',
required: true,
message: 'Bundle Name',
default: 'sample',
validate: validateBundleName,
},
{
name: 'friendlyName',
type: 'string',
required: true,
message: 'Friendly Bundle Name (for display purposes)',
default: 'Sample',
},
];