clever-tools 2.9.0 → 2.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +24 -20
- package/bin/clever.js +248 -3
- package/package.json +7 -6
- package/src/commands/applications.js +24 -15
- package/src/commands/console.js +1 -1
- package/src/commands/login.js +1 -1
- package/src/commands/networkgroups/commands.js +7 -0
- package/src/commands/networkgroups/index.js +67 -0
- package/src/commands/networkgroups/members.js +80 -0
- package/src/commands/networkgroups/peers.js +83 -0
- package/src/commands/open.js +1 -1
- package/src/models/app_configuration.js +38 -0
- package/src/models/format-ng-table.js +115 -0
- package/src/models/format-string.js +44 -0
- package/src/models/networkgroup.js +62 -0
- package/src/models/wireguard-conf.js +95 -0
- package/src/models/wireguard.js +75 -0
- package/src/parsers.js +76 -1
package/src/parsers.js
CHANGED
|
@@ -48,7 +48,7 @@ function appIdOrName (string) {
|
|
|
48
48
|
return cliparse.parsers.success({ app_name: string });
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const orgaIdRegex = /^orga_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
51
|
+
const orgaIdRegex = /^(user_|orga_)[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
52
52
|
|
|
53
53
|
function orgaIdOrName (string) {
|
|
54
54
|
if (string.match(orgaIdRegex)) {
|
|
@@ -66,6 +66,15 @@ function addonIdOrName (string) {
|
|
|
66
66
|
return cliparse.parsers.success({ addon_name: string });
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
const ngIdRegex = /^ng_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
70
|
+
|
|
71
|
+
function ngIdOrLabel (string) {
|
|
72
|
+
if (string.match(ngIdRegex)) {
|
|
73
|
+
return cliparse.parsers.success({ ng_id: string });
|
|
74
|
+
}
|
|
75
|
+
return cliparse.parsers.success({ ng_label: string });
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
function commaSeparated (string) {
|
|
70
79
|
return cliparse.parsers.success(string.split(','));
|
|
71
80
|
}
|
|
@@ -86,6 +95,63 @@ function integer (string) {
|
|
|
86
95
|
return cliparse.parsers.success(integer);
|
|
87
96
|
}
|
|
88
97
|
|
|
98
|
+
// /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/i;
|
|
99
|
+
const tagRegex = /^[^,\s]+$/;
|
|
100
|
+
|
|
101
|
+
function tag (string) {
|
|
102
|
+
if (string.match(tagRegex)) {
|
|
103
|
+
return cliparse.parsers.success(string);
|
|
104
|
+
}
|
|
105
|
+
return cliparse.parsers.error(`Invalid tag '${string}'. Should match ${tagRegex}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function tags (string) {
|
|
109
|
+
if (String(string).length === 0) {
|
|
110
|
+
return cliparse.parsers.success([]);
|
|
111
|
+
}
|
|
112
|
+
const tags = String(string).split(',');
|
|
113
|
+
for (const current of tags) {
|
|
114
|
+
if (tag(current).error) {
|
|
115
|
+
return cliparse.parsers.error(`Invalid tag '${current}'. Should match \`${tagRegex}\``);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return cliparse.parsers.success(tags);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function ngMemberType (string) {
|
|
122
|
+
const possible = ['application', 'addon', 'external'];
|
|
123
|
+
if (possible.includes(string)) {
|
|
124
|
+
return cliparse.parsers.success(string);
|
|
125
|
+
}
|
|
126
|
+
return cliparse.parsers.error(`Invalid member type '${string}'. Should be in ${JSON.stringify(possible)}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function ngPeerRole (string) {
|
|
130
|
+
const possible = ['client', 'server'];
|
|
131
|
+
if (possible.includes(string)) {
|
|
132
|
+
return cliparse.parsers.success(string);
|
|
133
|
+
}
|
|
134
|
+
return cliparse.parsers.error(`Invalid peer role '${string}'. Should be in ${JSON.stringify(possible)}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const ipAddressRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/;
|
|
138
|
+
|
|
139
|
+
function ipAddress (string) {
|
|
140
|
+
if (string.match(ipAddressRegex)) {
|
|
141
|
+
return cliparse.parsers.success(string);
|
|
142
|
+
}
|
|
143
|
+
return cliparse.parsers.error(`Invalid IP address '${string}'. Should match ${ipAddressRegex}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const portNumberRegex = /^\d{1,5}$/;
|
|
147
|
+
|
|
148
|
+
function portNumber (number) {
|
|
149
|
+
if (String(number).match(portNumberRegex)) {
|
|
150
|
+
return cliparse.parsers.success(number);
|
|
151
|
+
}
|
|
152
|
+
return cliparse.parsers.error(`Invalid port number '${number}'. Should match ${portNumberRegex}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
89
155
|
module.exports = {
|
|
90
156
|
buildFlavor,
|
|
91
157
|
flavor,
|
|
@@ -94,7 +160,16 @@ module.exports = {
|
|
|
94
160
|
appIdOrName,
|
|
95
161
|
orgaIdOrName,
|
|
96
162
|
addonIdOrName,
|
|
163
|
+
ngIdOrLabel,
|
|
97
164
|
commaSeparated,
|
|
98
165
|
accessLogsFormat,
|
|
99
166
|
integer,
|
|
167
|
+
tag,
|
|
168
|
+
tags,
|
|
169
|
+
ngMemberType,
|
|
170
|
+
ngPeerRole,
|
|
171
|
+
ipAddressRegex,
|
|
172
|
+
ipAddress,
|
|
173
|
+
portNumberRegex,
|
|
174
|
+
portNumber,
|
|
100
175
|
};
|