clever-tools 3.9.0 → 3.10.0
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/bin/clever.js +1 -0
- package/package.json +1 -1
- package/src/commands/domain.js +9 -3
- package/src/models/addon.js +7 -3
- package/src/parsers.js +11 -0
package/bin/clever.js
CHANGED
|
@@ -342,6 +342,7 @@ function run () {
|
|
|
342
342
|
}),
|
|
343
343
|
addonOptions: cliparse.option('option', {
|
|
344
344
|
metavar: 'option',
|
|
345
|
+
parser: Parsers.addonOptions,
|
|
345
346
|
description: 'Option to enable for the add-on. Multiple --option argument can be passed to enable multiple options',
|
|
346
347
|
}),
|
|
347
348
|
region: cliparse.option('region', {
|
package/package.json
CHANGED
package/src/commands/domain.js
CHANGED
|
@@ -192,7 +192,8 @@ export async function overview (params) {
|
|
|
192
192
|
.filter((domain) => filter == null || domain.fqdn.includes(filter))
|
|
193
193
|
.map((domain) => {
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
// `validateHostname` is set to `false` so that wildcard domains may be parsed correctly
|
|
196
|
+
const parsedDomain = parseDomain(domain.fqdn, { validateHostname: false });
|
|
196
197
|
const pathname = new URL('https://' + domain.fqdn).pathname;
|
|
197
198
|
const subdomains = parsedDomain.subdomain !== '' ? parsedDomain.subdomain.split('.') : [];
|
|
198
199
|
|
|
@@ -337,7 +338,7 @@ function reportDomainDiagnostics ({ hostname, pathPrefix, resolvedDnsConfig, dia
|
|
|
337
338
|
|
|
338
339
|
unknownDiags.forEach((diag) => {
|
|
339
340
|
const source = hasCnameRecord ? `(from CNAME ${resolvedDnsConfig.cnameRecords[0]}.)` : '';
|
|
340
|
-
printlnWithIndent(diag.record.value
|
|
341
|
+
printlnWithIndent(`${diag.record.value} ${source}`, 6);
|
|
341
342
|
});
|
|
342
343
|
}
|
|
343
344
|
|
|
@@ -395,7 +396,12 @@ function recursiveSort (obj) {
|
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
const sortedObj = {};
|
|
398
|
-
Object.keys(obj).sort((a, b) =>
|
|
399
|
+
Object.keys(obj).sort((a, b) => {
|
|
400
|
+
// if the domain contains a wildcard, we want it to be the first of subdomains
|
|
401
|
+
const aWithReplacedWildcard = a.replace(/^\*/, 'a');
|
|
402
|
+
const bWithReplacedWildcard = b.replace(/^\*/, 'a');
|
|
403
|
+
return aWithReplacedWildcard.localeCompare(bWithReplacedWildcard);
|
|
404
|
+
}).forEach((key) => {
|
|
399
405
|
sortedObj[key] = recursiveSort(obj[key]);
|
|
400
406
|
});
|
|
401
407
|
|
package/src/models/addon.js
CHANGED
|
@@ -274,10 +274,14 @@ export function parseAddonOptions (options) {
|
|
|
274
274
|
return {};
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
const pairs = options.split(/,(?=\w+=)/) || [];
|
|
278
|
+
|
|
279
|
+
return pairs.reduce((options, pair) => {
|
|
280
|
+
const [key, ...valueParts] = pair.split('=');
|
|
281
|
+
const value = valueParts.join('=');
|
|
282
|
+
|
|
279
283
|
if (value == null) {
|
|
280
|
-
throw new Error("Options are malformed. Usage is '--option name=enabled|disabled|true|false'");
|
|
284
|
+
throw new Error("Options are malformed. Usage is '--option name=enabled|disabled|true|false|plugin1,plugin2'");
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
let formattedValue = value;
|
package/src/parsers.js
CHANGED
|
@@ -4,6 +4,17 @@ import * as Application from './models/application.js';
|
|
|
4
4
|
import ISO8601 from 'iso8601-duration';
|
|
5
5
|
import Duration from 'duration-js';
|
|
6
6
|
|
|
7
|
+
const addonOptionsRegex = /^\w+=.+$/;
|
|
8
|
+
|
|
9
|
+
export function addonOptions (options) {
|
|
10
|
+
for (const option of options) {
|
|
11
|
+
if (!option.match(addonOptionsRegex)) {
|
|
12
|
+
return cliparse.parsers.error('Invalid option: ' + option);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return cliparse.parsers.success(options.join(','));
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export function flavor (flavor) {
|
|
8
19
|
const flavors = Application.listAvailableFlavors();
|
|
9
20
|
if (flavors.includes(flavor)) {
|