@devkong/cli 0.0.14 → 0.0.15

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/index.js CHANGED
@@ -43402,6 +43402,228 @@ var require_create_nx_workspace = __commonJS({
43402
43402
  }
43403
43403
  });
43404
43404
 
43405
+ // node_modules/json-schema/lib/validate.js
43406
+ var require_validate = __commonJS({
43407
+ "node_modules/json-schema/lib/validate.js"(exports2, module2) {
43408
+ (function(root, factory) {
43409
+ if (typeof define === "function" && define.amd) {
43410
+ define([], function() {
43411
+ return factory();
43412
+ });
43413
+ } else if (typeof module2 === "object" && module2.exports) {
43414
+ module2.exports = factory();
43415
+ } else {
43416
+ root.jsonSchema = factory();
43417
+ }
43418
+ })(exports2, function() {
43419
+ var exports3 = validate4;
43420
+ exports3.Integer = { type: "integer" };
43421
+ var primitiveConstructors = {
43422
+ String,
43423
+ Boolean,
43424
+ Number,
43425
+ Object,
43426
+ Array,
43427
+ Date
43428
+ };
43429
+ exports3.validate = validate4;
43430
+ function validate4(instance, schema) {
43431
+ return validate4(instance, schema, { changing: false });
43432
+ }
43433
+ ;
43434
+ exports3.checkPropertyChange = function(value, schema, property) {
43435
+ return validate4(value, schema, { changing: property || "property" });
43436
+ };
43437
+ var validate4 = exports3._validate = function(instance, schema, options) {
43438
+ if (!options)
43439
+ options = {};
43440
+ var _changing = options.changing;
43441
+ function getType(schema2) {
43442
+ return schema2.type || primitiveConstructors[schema2.name] == schema2 && schema2.name.toLowerCase();
43443
+ }
43444
+ var errors = [];
43445
+ function checkProp(value, schema2, path6, i) {
43446
+ var l;
43447
+ path6 += path6 ? typeof i == "number" ? "[" + i + "]" : typeof i == "undefined" ? "" : "." + i : i;
43448
+ function addError(message2) {
43449
+ errors.push({ property: path6, message: message2 });
43450
+ }
43451
+ if ((typeof schema2 != "object" || schema2 instanceof Array) && (path6 || typeof schema2 != "function") && !(schema2 && getType(schema2))) {
43452
+ if (typeof schema2 == "function") {
43453
+ if (!(value instanceof schema2)) {
43454
+ addError("is not an instance of the class/constructor " + schema2.name);
43455
+ }
43456
+ } else if (schema2) {
43457
+ addError("Invalid schema/property definition " + schema2);
43458
+ }
43459
+ return null;
43460
+ }
43461
+ if (_changing && schema2.readonly) {
43462
+ addError("is a readonly field, it can not be changed");
43463
+ }
43464
+ if (schema2["extends"]) {
43465
+ checkProp(value, schema2["extends"], path6, i);
43466
+ }
43467
+ function checkType(type, value2) {
43468
+ if (type) {
43469
+ if (typeof type == "string" && type != "any" && (type == "null" ? value2 !== null : typeof value2 != type) && !(value2 instanceof Array && type == "array") && !(value2 instanceof Date && type == "date") && !(type == "integer" && value2 % 1 === 0)) {
43470
+ return [{ property: path6, message: value2 + " - " + typeof value2 + " value found, but a " + type + " is required" }];
43471
+ }
43472
+ if (type instanceof Array) {
43473
+ var unionErrors = [];
43474
+ for (var j2 = 0; j2 < type.length; j2++) {
43475
+ if (!(unionErrors = checkType(type[j2], value2)).length) {
43476
+ break;
43477
+ }
43478
+ }
43479
+ if (unionErrors.length) {
43480
+ return unionErrors;
43481
+ }
43482
+ } else if (typeof type == "object") {
43483
+ var priorErrors = errors;
43484
+ errors = [];
43485
+ checkProp(value2, type, path6);
43486
+ var theseErrors = errors;
43487
+ errors = priorErrors;
43488
+ return theseErrors;
43489
+ }
43490
+ }
43491
+ return [];
43492
+ }
43493
+ if (value === void 0) {
43494
+ if (schema2.required) {
43495
+ addError("is missing and it is required");
43496
+ }
43497
+ } else {
43498
+ errors = errors.concat(checkType(getType(schema2), value));
43499
+ if (schema2.disallow && !checkType(schema2.disallow, value).length) {
43500
+ addError(" disallowed value was matched");
43501
+ }
43502
+ if (value !== null) {
43503
+ if (value instanceof Array) {
43504
+ if (schema2.items) {
43505
+ var itemsIsArray = schema2.items instanceof Array;
43506
+ var propDef = schema2.items;
43507
+ for (i = 0, l = value.length; i < l; i += 1) {
43508
+ if (itemsIsArray)
43509
+ propDef = schema2.items[i];
43510
+ if (options.coerce)
43511
+ value[i] = options.coerce(value[i], propDef);
43512
+ errors.concat(checkProp(value[i], propDef, path6, i));
43513
+ }
43514
+ }
43515
+ if (schema2.minItems && value.length < schema2.minItems) {
43516
+ addError("There must be a minimum of " + schema2.minItems + " in the array");
43517
+ }
43518
+ if (schema2.maxItems && value.length > schema2.maxItems) {
43519
+ addError("There must be a maximum of " + schema2.maxItems + " in the array");
43520
+ }
43521
+ } else if (schema2.properties || schema2.additionalProperties) {
43522
+ errors.concat(checkObj(value, schema2.properties, path6, schema2.additionalProperties));
43523
+ }
43524
+ if (schema2.pattern && typeof value == "string" && !value.match(schema2.pattern)) {
43525
+ addError("does not match the regex pattern " + schema2.pattern);
43526
+ }
43527
+ if (schema2.maxLength && typeof value == "string" && value.length > schema2.maxLength) {
43528
+ addError("may only be " + schema2.maxLength + " characters long");
43529
+ }
43530
+ if (schema2.minLength && typeof value == "string" && value.length < schema2.minLength) {
43531
+ addError("must be at least " + schema2.minLength + " characters long");
43532
+ }
43533
+ if (typeof schema2.minimum !== "undefined" && typeof value == typeof schema2.minimum && schema2.minimum > value) {
43534
+ addError("must have a minimum value of " + schema2.minimum);
43535
+ }
43536
+ if (typeof schema2.maximum !== "undefined" && typeof value == typeof schema2.maximum && schema2.maximum < value) {
43537
+ addError("must have a maximum value of " + schema2.maximum);
43538
+ }
43539
+ if (schema2["enum"]) {
43540
+ var enumer = schema2["enum"];
43541
+ l = enumer.length;
43542
+ var found;
43543
+ for (var j = 0; j < l; j++) {
43544
+ if (enumer[j] === value) {
43545
+ found = 1;
43546
+ break;
43547
+ }
43548
+ }
43549
+ if (!found) {
43550
+ addError("does not have a value in the enumeration " + enumer.join(", "));
43551
+ }
43552
+ }
43553
+ if (typeof schema2.maxDecimal == "number" && value.toString().match(new RegExp("\\.[0-9]{" + (schema2.maxDecimal + 1) + ",}"))) {
43554
+ addError("may only have " + schema2.maxDecimal + " digits of decimal places");
43555
+ }
43556
+ }
43557
+ }
43558
+ return null;
43559
+ }
43560
+ function checkObj(instance2, objTypeDef, path6, additionalProp) {
43561
+ if (typeof objTypeDef == "object") {
43562
+ if (typeof instance2 != "object" || instance2 instanceof Array) {
43563
+ errors.push({ property: path6, message: "an object is required" });
43564
+ }
43565
+ for (var i in objTypeDef) {
43566
+ if (objTypeDef.hasOwnProperty(i) && i != "__proto__" && i != "constructor") {
43567
+ var value = instance2.hasOwnProperty(i) ? instance2[i] : void 0;
43568
+ if (value === void 0 && options.existingOnly)
43569
+ continue;
43570
+ var propDef = objTypeDef[i];
43571
+ if (value === void 0 && propDef["default"]) {
43572
+ value = instance2[i] = propDef["default"];
43573
+ }
43574
+ if (options.coerce && i in instance2) {
43575
+ value = instance2[i] = options.coerce(value, propDef);
43576
+ }
43577
+ checkProp(value, propDef, path6, i);
43578
+ }
43579
+ }
43580
+ }
43581
+ for (i in instance2) {
43582
+ if (instance2.hasOwnProperty(i) && !(i.charAt(0) == "_" && i.charAt(1) == "_") && objTypeDef && !objTypeDef[i] && additionalProp === false) {
43583
+ if (options.filter) {
43584
+ delete instance2[i];
43585
+ continue;
43586
+ } else {
43587
+ errors.push({ property: path6, message: "The property " + i + " is not defined in the schema and the schema does not allow additional properties" });
43588
+ }
43589
+ }
43590
+ var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
43591
+ if (requires && !(requires in instance2)) {
43592
+ errors.push({ property: path6, message: "the presence of the property " + i + " requires that " + requires + " also be present" });
43593
+ }
43594
+ value = instance2[i];
43595
+ if (additionalProp && (!(objTypeDef && typeof objTypeDef == "object") || !(i in objTypeDef))) {
43596
+ if (options.coerce) {
43597
+ value = instance2[i] = options.coerce(value, additionalProp);
43598
+ }
43599
+ checkProp(value, additionalProp, path6, i);
43600
+ }
43601
+ if (!_changing && value && value.$schema) {
43602
+ errors = errors.concat(checkProp(value, value.$schema, path6, i));
43603
+ }
43604
+ }
43605
+ return errors;
43606
+ }
43607
+ if (schema) {
43608
+ checkProp(instance, schema, "", _changing || "");
43609
+ }
43610
+ if (!_changing && instance && instance.$schema) {
43611
+ checkProp(instance, instance.$schema, "", "");
43612
+ }
43613
+ return { valid: !errors.length, errors };
43614
+ };
43615
+ exports3.mustBeValid = function(result) {
43616
+ if (!result.valid) {
43617
+ throw new TypeError(result.errors.map(function(error) {
43618
+ return "for property " + error.property + ": " + error.message;
43619
+ }).join(", \n"));
43620
+ }
43621
+ };
43622
+ return exports3;
43623
+ });
43624
+ }
43625
+ });
43626
+
43405
43627
  // node_modules/listr2/node_modules/eventemitter3/index.js
43406
43628
  var require_eventemitter3 = __commonJS({
43407
43629
  "node_modules/listr2/node_modules/eventemitter3/index.js"(exports2, module2) {
@@ -44430,13 +44652,13 @@ var init_lookup = __esm({
44430
44652
  });
44431
44653
 
44432
44654
  // node_modules/get-east-asian-width/index.js
44433
- function validate2(codePoint) {
44655
+ function validate3(codePoint) {
44434
44656
  if (!Number.isSafeInteger(codePoint)) {
44435
44657
  throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
44436
44658
  }
44437
44659
  }
44438
44660
  function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
44439
- validate2(codePoint);
44661
+ validate3(codePoint);
44440
44662
  if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
44441
44663
  return 2;
44442
44664
  }
@@ -45992,252 +46214,30 @@ var init_wrap_ansi2 = __esm({
45992
46214
  if (groups.code !== void 0) {
45993
46215
  const code2 = Number.parseFloat(groups.code);
45994
46216
  escapeCode = code2 === END_CODE2 ? void 0 : code2;
45995
- } else if (groups.uri !== void 0) {
45996
- escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
45997
- }
45998
- }
45999
- const code = ansi_styles_default3.codes.get(Number(escapeCode));
46000
- if (pre[index + 1] === "\n") {
46001
- if (escapeUrl) {
46002
- returnValue += wrapAnsiHyperlink2("");
46003
- }
46004
- if (escapeCode && code) {
46005
- returnValue += wrapAnsiCode2(code);
46006
- }
46007
- } else if (character === "\n") {
46008
- if (escapeCode && code) {
46009
- returnValue += wrapAnsiCode2(escapeCode);
46010
- }
46011
- if (escapeUrl) {
46012
- returnValue += wrapAnsiHyperlink2(escapeUrl);
46013
- }
46014
- }
46015
- preStringIndex += character.length;
46016
- }
46017
- return returnValue;
46018
- };
46019
- }
46020
- });
46021
-
46022
- // node_modules/json-schema/lib/validate.js
46023
- var require_validate = __commonJS({
46024
- "node_modules/json-schema/lib/validate.js"(exports2, module2) {
46025
- (function(root, factory) {
46026
- if (typeof define === "function" && define.amd) {
46027
- define([], function() {
46028
- return factory();
46029
- });
46030
- } else if (typeof module2 === "object" && module2.exports) {
46031
- module2.exports = factory();
46032
- } else {
46033
- root.jsonSchema = factory();
46034
- }
46035
- })(exports2, function() {
46036
- var exports3 = validate4;
46037
- exports3.Integer = { type: "integer" };
46038
- var primitiveConstructors = {
46039
- String,
46040
- Boolean,
46041
- Number,
46042
- Object,
46043
- Array,
46044
- Date
46045
- };
46046
- exports3.validate = validate4;
46047
- function validate4(instance, schema) {
46048
- return validate4(instance, schema, { changing: false });
46049
- }
46050
- ;
46051
- exports3.checkPropertyChange = function(value, schema, property) {
46052
- return validate4(value, schema, { changing: property || "property" });
46053
- };
46054
- var validate4 = exports3._validate = function(instance, schema, options) {
46055
- if (!options)
46056
- options = {};
46057
- var _changing = options.changing;
46058
- function getType(schema2) {
46059
- return schema2.type || primitiveConstructors[schema2.name] == schema2 && schema2.name.toLowerCase();
46060
- }
46061
- var errors = [];
46062
- function checkProp(value, schema2, path6, i) {
46063
- var l;
46064
- path6 += path6 ? typeof i == "number" ? "[" + i + "]" : typeof i == "undefined" ? "" : "." + i : i;
46065
- function addError(message2) {
46066
- errors.push({ property: path6, message: message2 });
46067
- }
46068
- if ((typeof schema2 != "object" || schema2 instanceof Array) && (path6 || typeof schema2 != "function") && !(schema2 && getType(schema2))) {
46069
- if (typeof schema2 == "function") {
46070
- if (!(value instanceof schema2)) {
46071
- addError("is not an instance of the class/constructor " + schema2.name);
46072
- }
46073
- } else if (schema2) {
46074
- addError("Invalid schema/property definition " + schema2);
46075
- }
46076
- return null;
46077
- }
46078
- if (_changing && schema2.readonly) {
46079
- addError("is a readonly field, it can not be changed");
46080
- }
46081
- if (schema2["extends"]) {
46082
- checkProp(value, schema2["extends"], path6, i);
46083
- }
46084
- function checkType(type, value2) {
46085
- if (type) {
46086
- if (typeof type == "string" && type != "any" && (type == "null" ? value2 !== null : typeof value2 != type) && !(value2 instanceof Array && type == "array") && !(value2 instanceof Date && type == "date") && !(type == "integer" && value2 % 1 === 0)) {
46087
- return [{ property: path6, message: value2 + " - " + typeof value2 + " value found, but a " + type + " is required" }];
46088
- }
46089
- if (type instanceof Array) {
46090
- var unionErrors = [];
46091
- for (var j2 = 0; j2 < type.length; j2++) {
46092
- if (!(unionErrors = checkType(type[j2], value2)).length) {
46093
- break;
46094
- }
46095
- }
46096
- if (unionErrors.length) {
46097
- return unionErrors;
46098
- }
46099
- } else if (typeof type == "object") {
46100
- var priorErrors = errors;
46101
- errors = [];
46102
- checkProp(value2, type, path6);
46103
- var theseErrors = errors;
46104
- errors = priorErrors;
46105
- return theseErrors;
46106
- }
46107
- }
46108
- return [];
46109
- }
46110
- if (value === void 0) {
46111
- if (schema2.required) {
46112
- addError("is missing and it is required");
46113
- }
46114
- } else {
46115
- errors = errors.concat(checkType(getType(schema2), value));
46116
- if (schema2.disallow && !checkType(schema2.disallow, value).length) {
46117
- addError(" disallowed value was matched");
46118
- }
46119
- if (value !== null) {
46120
- if (value instanceof Array) {
46121
- if (schema2.items) {
46122
- var itemsIsArray = schema2.items instanceof Array;
46123
- var propDef = schema2.items;
46124
- for (i = 0, l = value.length; i < l; i += 1) {
46125
- if (itemsIsArray)
46126
- propDef = schema2.items[i];
46127
- if (options.coerce)
46128
- value[i] = options.coerce(value[i], propDef);
46129
- errors.concat(checkProp(value[i], propDef, path6, i));
46130
- }
46131
- }
46132
- if (schema2.minItems && value.length < schema2.minItems) {
46133
- addError("There must be a minimum of " + schema2.minItems + " in the array");
46134
- }
46135
- if (schema2.maxItems && value.length > schema2.maxItems) {
46136
- addError("There must be a maximum of " + schema2.maxItems + " in the array");
46137
- }
46138
- } else if (schema2.properties || schema2.additionalProperties) {
46139
- errors.concat(checkObj(value, schema2.properties, path6, schema2.additionalProperties));
46140
- }
46141
- if (schema2.pattern && typeof value == "string" && !value.match(schema2.pattern)) {
46142
- addError("does not match the regex pattern " + schema2.pattern);
46143
- }
46144
- if (schema2.maxLength && typeof value == "string" && value.length > schema2.maxLength) {
46145
- addError("may only be " + schema2.maxLength + " characters long");
46146
- }
46147
- if (schema2.minLength && typeof value == "string" && value.length < schema2.minLength) {
46148
- addError("must be at least " + schema2.minLength + " characters long");
46149
- }
46150
- if (typeof schema2.minimum !== "undefined" && typeof value == typeof schema2.minimum && schema2.minimum > value) {
46151
- addError("must have a minimum value of " + schema2.minimum);
46152
- }
46153
- if (typeof schema2.maximum !== "undefined" && typeof value == typeof schema2.maximum && schema2.maximum < value) {
46154
- addError("must have a maximum value of " + schema2.maximum);
46155
- }
46156
- if (schema2["enum"]) {
46157
- var enumer = schema2["enum"];
46158
- l = enumer.length;
46159
- var found;
46160
- for (var j = 0; j < l; j++) {
46161
- if (enumer[j] === value) {
46162
- found = 1;
46163
- break;
46164
- }
46165
- }
46166
- if (!found) {
46167
- addError("does not have a value in the enumeration " + enumer.join(", "));
46168
- }
46169
- }
46170
- if (typeof schema2.maxDecimal == "number" && value.toString().match(new RegExp("\\.[0-9]{" + (schema2.maxDecimal + 1) + ",}"))) {
46171
- addError("may only have " + schema2.maxDecimal + " digits of decimal places");
46172
- }
46173
- }
46174
- }
46175
- return null;
46176
- }
46177
- function checkObj(instance2, objTypeDef, path6, additionalProp) {
46178
- if (typeof objTypeDef == "object") {
46179
- if (typeof instance2 != "object" || instance2 instanceof Array) {
46180
- errors.push({ property: path6, message: "an object is required" });
46181
- }
46182
- for (var i in objTypeDef) {
46183
- if (objTypeDef.hasOwnProperty(i) && i != "__proto__" && i != "constructor") {
46184
- var value = instance2.hasOwnProperty(i) ? instance2[i] : void 0;
46185
- if (value === void 0 && options.existingOnly)
46186
- continue;
46187
- var propDef = objTypeDef[i];
46188
- if (value === void 0 && propDef["default"]) {
46189
- value = instance2[i] = propDef["default"];
46190
- }
46191
- if (options.coerce && i in instance2) {
46192
- value = instance2[i] = options.coerce(value, propDef);
46193
- }
46194
- checkProp(value, propDef, path6, i);
46195
- }
46196
- }
46197
- }
46198
- for (i in instance2) {
46199
- if (instance2.hasOwnProperty(i) && !(i.charAt(0) == "_" && i.charAt(1) == "_") && objTypeDef && !objTypeDef[i] && additionalProp === false) {
46200
- if (options.filter) {
46201
- delete instance2[i];
46202
- continue;
46203
- } else {
46204
- errors.push({ property: path6, message: "The property " + i + " is not defined in the schema and the schema does not allow additional properties" });
46205
- }
46206
- }
46207
- var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
46208
- if (requires && !(requires in instance2)) {
46209
- errors.push({ property: path6, message: "the presence of the property " + i + " requires that " + requires + " also be present" });
46210
- }
46211
- value = instance2[i];
46212
- if (additionalProp && (!(objTypeDef && typeof objTypeDef == "object") || !(i in objTypeDef))) {
46213
- if (options.coerce) {
46214
- value = instance2[i] = options.coerce(value, additionalProp);
46215
- }
46216
- checkProp(value, additionalProp, path6, i);
46217
- }
46218
- if (!_changing && value && value.$schema) {
46219
- errors = errors.concat(checkProp(value, value.$schema, path6, i));
46220
- }
46217
+ } else if (groups.uri !== void 0) {
46218
+ escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
46221
46219
  }
46222
- return errors;
46223
- }
46224
- if (schema) {
46225
- checkProp(instance, schema, "", _changing || "");
46226
- }
46227
- if (!_changing && instance && instance.$schema) {
46228
- checkProp(instance, instance.$schema, "", "");
46229
46220
  }
46230
- return { valid: !errors.length, errors };
46231
- };
46232
- exports3.mustBeValid = function(result) {
46233
- if (!result.valid) {
46234
- throw new TypeError(result.errors.map(function(error) {
46235
- return "for property " + error.property + ": " + error.message;
46236
- }).join(", \n"));
46221
+ const code = ansi_styles_default3.codes.get(Number(escapeCode));
46222
+ if (pre[index + 1] === "\n") {
46223
+ if (escapeUrl) {
46224
+ returnValue += wrapAnsiHyperlink2("");
46225
+ }
46226
+ if (escapeCode && code) {
46227
+ returnValue += wrapAnsiCode2(code);
46228
+ }
46229
+ } else if (character === "\n") {
46230
+ if (escapeCode && code) {
46231
+ returnValue += wrapAnsiCode2(escapeCode);
46232
+ }
46233
+ if (escapeUrl) {
46234
+ returnValue += wrapAnsiHyperlink2(escapeUrl);
46235
+ }
46237
46236
  }
46238
- };
46239
- return exports3;
46240
- });
46237
+ preStringIndex += character.length;
46238
+ }
46239
+ return returnValue;
46240
+ };
46241
46241
  }
46242
46242
  });
46243
46243
 
@@ -66915,53 +66915,258 @@ var ConfigureCommand = class {
66915
66915
  currentProfileName,
66916
66916
  availableProfiles[currentProfileName]
66917
66917
  );
66918
- availableProfiles[currentProfileName] = updatedProfile;
66919
- saveProfiles(availableProfiles);
66918
+ availableProfiles[currentProfileName] = updatedProfile;
66919
+ saveProfiles(availableProfiles);
66920
+ }
66921
+ async selectProfile(profiles) {
66922
+ const profileNames = Object.keys(profiles);
66923
+ const { profileName } = await esm_default12.prompt({
66924
+ type: "list",
66925
+ name: "profileName",
66926
+ message: "Select a profile to configure:",
66927
+ choices: [...profileNames, "Create a new profile"]
66928
+ });
66929
+ if (profileName === "Create a new profile") {
66930
+ const { newProfileName } = await esm_default12.prompt({
66931
+ type: "input",
66932
+ name: "newProfileName",
66933
+ message: "Enter the name for the new profile:",
66934
+ validate: (input) => profileNames.includes(input) ? "Profile already exists!" : true
66935
+ });
66936
+ profiles[newProfileName] = {
66937
+ kongBaseUrl: urlText("")
66938
+ };
66939
+ return newProfileName;
66940
+ }
66941
+ return profileName;
66942
+ }
66943
+ async configureProfile(profileName, profile) {
66944
+ const currentConfig = profile || {
66945
+ kongBaseUrl: urlText("")
66946
+ };
66947
+ const answers = await esm_default12.prompt({
66948
+ type: "input",
66949
+ name: "kongUrl",
66950
+ message: `Enter Kong URL for profile "${profileName}":`,
66951
+ default: currentConfig.kongBaseUrl
66952
+ });
66953
+ const updatedProfile = { ...currentConfig };
66954
+ updatedProfile.kongBaseUrl = urlText(answers.kongUrl);
66955
+ console.log(`Configuration for profile "${profileName}" has been updated.`);
66956
+ return updatedProfile;
66957
+ }
66958
+ };
66959
+
66960
+ // packages/kong-cli/src/commands/generateCommand.ts
66961
+ var import_create_nx_workspace = __toESM(require_create_nx_workspace());
66962
+
66963
+ // packages/kong-cli/src/common/kongJson.ts
66964
+ var import_fs3 = __toESM(require("fs"));
66965
+ var import_json_schema = __toESM(require_validate());
66966
+
66967
+ // packages/kong-cli/src/common/kongJsonSchema.ts
66968
+ var KONG_JSON_SCHEMA = {
66969
+ $schema: "http://json-schema.org/draft-07/schema#",
66970
+ type: "object",
66971
+ properties: {
66972
+ id: {
66973
+ type: "string"
66974
+ },
66975
+ name: {
66976
+ type: "string"
66977
+ },
66978
+ ownership: {
66979
+ type: "array",
66980
+ items: {
66981
+ type: "string"
66982
+ }
66983
+ },
66984
+ sdk: {
66985
+ type: "string",
66986
+ enum: ["python", "kotlin"]
66987
+ },
66988
+ alias: {
66989
+ type: "object",
66990
+ properties: {
66991
+ env: {
66992
+ type: "object",
66993
+ additionalProperties: true
66994
+ },
66995
+ input: {
66996
+ type: "object",
66997
+ properties: {
66998
+ filter: {
66999
+ type: "string"
67000
+ },
67001
+ schema: {
67002
+ $ref: "https://json-schema.org/draft-07/schema#"
67003
+ }
67004
+ },
67005
+ required: ["schema", "filter"]
67006
+ },
67007
+ output: {
67008
+ type: "object",
67009
+ properties: {
67010
+ filter: {
67011
+ type: "string"
67012
+ },
67013
+ schema: {
67014
+ $ref: "https://json-schema.org/draft-07/schema#"
67015
+ }
67016
+ },
67017
+ required: ["schema", "filter"]
67018
+ },
67019
+ invoke: {
67020
+ type: "object",
67021
+ properties: {
67022
+ prefix: {
67023
+ type: "string"
67024
+ },
67025
+ cache: {
67026
+ type: "object",
67027
+ properties: {
67028
+ enabled: {
67029
+ type: "boolean"
67030
+ },
67031
+ key: {
67032
+ type: ["string"]
67033
+ },
67034
+ ttl: {
67035
+ type: "string"
67036
+ },
67037
+ onFailure: {
67038
+ type: "string",
67039
+ enum: ["skip", "retry"]
67040
+ }
67041
+ },
67042
+ required: ["enabled", "key", "ttl", "onFailure"]
67043
+ },
67044
+ retry: {
67045
+ type: "object",
67046
+ properties: {
67047
+ maxAttempts: {
67048
+ type: "number"
67049
+ },
67050
+ attemptDelay: {
67051
+ type: "string"
67052
+ },
67053
+ attemptTimeout: {
67054
+ type: "string"
67055
+ }
67056
+ },
67057
+ required: ["maxAttempts", "attemptDelay", "attemptTimeout"]
67058
+ },
67059
+ circuitBreaker: {
67060
+ type: "object",
67061
+ properties: {
67062
+ enabled: {
67063
+ type: "boolean"
67064
+ },
67065
+ requestVolumeThreshold: {
67066
+ type: "number"
67067
+ },
67068
+ failureRatio: {
67069
+ type: "number"
67070
+ },
67071
+ successThreshold: {
67072
+ type: "number"
67073
+ }
67074
+ },
67075
+ required: ["enabled", "requestVolumeThreshold", "failureRatio", "successThreshold"]
67076
+ },
67077
+ rateLimiter: {
67078
+ type: "object",
67079
+ properties: {
67080
+ enabled: {
67081
+ type: "boolean"
67082
+ },
67083
+ value: {
67084
+ type: "number"
67085
+ },
67086
+ window: {
67087
+ type: "string"
67088
+ },
67089
+ minSpacing: {
67090
+ type: "string"
67091
+ }
67092
+ },
67093
+ required: ["enabled", "value", "window", "minSpacing"]
67094
+ }
67095
+ }
67096
+ }
67097
+ },
67098
+ additionalProperties: false
67099
+ }
67100
+ },
67101
+ additionalProperties: false,
67102
+ required: ["id", "name", "ownership", "sdk"]
67103
+ };
67104
+
67105
+ // packages/kong-cli/src/common/kongJson.ts
67106
+ var SUPPORTED_SDK = ["kotlin", "python"];
67107
+ function validateKongJson(kongJson) {
67108
+ if (isEmpty(kongJson.id)) {
67109
+ throw new AppError(
67110
+ "The `id` field should not be empty. Please provide a valid identifier in kong.json."
67111
+ );
67112
+ }
67113
+ if (!/^[a-zA-Z0-9]{12}$/.test(kongJson.id)) {
67114
+ throw new AppError(
67115
+ "The `id` should contain exactly 12 alphanumeric characters (letters and digits). Ensure the ID is not longer than 12 characters and does not include any special characters.Please provide a valid identifier in kong.json."
67116
+ );
67117
+ }
67118
+ if (!SUPPORTED_SDK.includes(kongJson.sdk)) {
67119
+ throw new AppError(
67120
+ `Unexpected SDK value: ${kongJson.sdk}. Supported SDK: ${SUPPORTED_SDK}.Please provide a valid identifier in kong.json.`
67121
+ );
67122
+ }
67123
+ if (isEmpty(kongJson.name)) {
67124
+ throw new AppError(
67125
+ "The `name` field should not be empty. Please provide a valid name in kong.json."
67126
+ );
67127
+ }
67128
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(kongJson.name)) {
67129
+ throw new AppError(
67130
+ "The `name` should only contain lowercase letters, digits, and dashes. Dashes can only appear between alphanumeric characters, and the name cannot start or end with a dash.Please provide a valid name in kong.json."
67131
+ );
67132
+ }
67133
+ if (kongJson.ownership.length === 0) {
67134
+ throw new AppError(
67135
+ "The `ownership` field should contain at least one user name. Please provide valid ownership information in kong.json."
67136
+ );
67137
+ }
67138
+ const result = (0, import_json_schema.validate)(kongJson.alias, KONG_JSON_SCHEMA);
67139
+ if (result.errors.length) {
67140
+ throw new AppError(
67141
+ "The provided `kong.json` does not follow the expected JSON schema. Errors: \n" + prettyJson(result.errors)
67142
+ );
66920
67143
  }
66921
- async selectProfile(profiles) {
66922
- const profileNames = Object.keys(profiles);
66923
- const { profileName } = await esm_default12.prompt({
66924
- type: "list",
66925
- name: "profileName",
66926
- message: "Select a profile to configure:",
66927
- choices: [...profileNames, "Create a new profile"]
66928
- });
66929
- if (profileName === "Create a new profile") {
66930
- const { newProfileName } = await esm_default12.prompt({
66931
- type: "input",
66932
- name: "newProfileName",
66933
- message: "Enter the name for the new profile:",
66934
- validate: (input) => profileNames.includes(input) ? "Profile already exists!" : true
66935
- });
66936
- profiles[newProfileName] = {
66937
- kongBaseUrl: urlText("")
66938
- };
66939
- return newProfileName;
67144
+ return kongJson;
67145
+ }
67146
+ function getKongJson() {
67147
+ const kongJsonPath = resolveProjectPath("kong.json");
67148
+ try {
67149
+ const fileContent = import_fs3.default.readFileSync(kongJsonPath, "utf-8");
67150
+ const kongJson = JSON.parse(fileContent);
67151
+ return validateKongJson(kongJson);
67152
+ } catch (ex) {
67153
+ if (ex instanceof SyntaxError) {
67154
+ throw new AppError(`Error parsing kong.json: ${ex.message}`);
66940
67155
  }
66941
- return profileName;
66942
- }
66943
- async configureProfile(profileName, profile) {
66944
- const currentConfig = profile || {
66945
- kongBaseUrl: urlText("")
66946
- };
66947
- const answers = await esm_default12.prompt({
66948
- type: "input",
66949
- name: "kongUrl",
66950
- message: `Enter Kong URL for profile "${profileName}":`,
66951
- default: currentConfig.kongBaseUrl
66952
- });
66953
- const updatedProfile = { ...currentConfig };
66954
- updatedProfile.kongBaseUrl = urlText(answers.kongUrl);
66955
- console.log(`Configuration for profile "${profileName}" has been updated.`);
66956
- return updatedProfile;
67156
+ throw ex;
66957
67157
  }
66958
- };
67158
+ }
66959
67159
 
66960
67160
  // packages/kong-cli/src/commands/generateCommand.ts
66961
- var import_create_nx_workspace = __toESM(require_create_nx_workspace());
66962
67161
  var GenerateCommand = class {
66963
67162
  async execute(extensionName, sdk, presetVersion) {
66964
67163
  const id = generateShortId();
67164
+ validateKongJson({
67165
+ id,
67166
+ sdk,
67167
+ name: extensionName,
67168
+ ownership: ["devkong"]
67169
+ });
66965
67170
  await (0, import_create_nx_workspace.createWorkspace)(`@devkong/cli-nx@${presetVersion}`, {
66966
67171
  name: extensionName,
66967
67172
  id,
@@ -69513,201 +69718,6 @@ var InstallCommand = class {
69513
69718
  }
69514
69719
  };
69515
69720
 
69516
- // packages/kong-cli/src/common/kongJson.ts
69517
- var import_fs3 = __toESM(require("fs"));
69518
- var import_json_schema = __toESM(require_validate());
69519
-
69520
- // packages/kong-cli/src/common/kongJsonSchema.ts
69521
- var KONG_JSON_SCHEMA = {
69522
- $schema: "http://json-schema.org/draft-07/schema#",
69523
- type: "object",
69524
- properties: {
69525
- id: {
69526
- type: "string"
69527
- },
69528
- name: {
69529
- type: "string"
69530
- },
69531
- ownership: {
69532
- type: "array",
69533
- items: {
69534
- type: "string"
69535
- }
69536
- },
69537
- sdk: {
69538
- type: "string",
69539
- enum: ["python", "kotlin"]
69540
- },
69541
- alias: {
69542
- type: "object",
69543
- properties: {
69544
- env: {
69545
- type: "object",
69546
- additionalProperties: true
69547
- },
69548
- input: {
69549
- type: "object",
69550
- properties: {
69551
- filter: {
69552
- type: "string"
69553
- },
69554
- schema: {
69555
- $ref: "https://json-schema.org/draft-07/schema#"
69556
- }
69557
- },
69558
- required: ["schema", "filter"]
69559
- },
69560
- output: {
69561
- type: "object",
69562
- properties: {
69563
- filter: {
69564
- type: "string"
69565
- },
69566
- schema: {
69567
- $ref: "https://json-schema.org/draft-07/schema#"
69568
- }
69569
- },
69570
- required: ["schema", "filter"]
69571
- },
69572
- invoke: {
69573
- type: "object",
69574
- properties: {
69575
- prefix: {
69576
- type: "string"
69577
- },
69578
- cache: {
69579
- type: "object",
69580
- properties: {
69581
- enabled: {
69582
- type: "boolean"
69583
- },
69584
- key: {
69585
- type: ["string"]
69586
- },
69587
- ttl: {
69588
- type: "string"
69589
- },
69590
- onFailure: {
69591
- type: "string",
69592
- enum: ["skip", "retry"]
69593
- }
69594
- },
69595
- required: ["enabled", "key", "ttl", "onFailure"]
69596
- },
69597
- retry: {
69598
- type: "object",
69599
- properties: {
69600
- maxAttempts: {
69601
- type: "number"
69602
- },
69603
- attemptDelay: {
69604
- type: "string"
69605
- },
69606
- attemptTimeout: {
69607
- type: "string"
69608
- }
69609
- },
69610
- required: ["maxAttempts", "attemptDelay", "attemptTimeout"]
69611
- },
69612
- circuitBreaker: {
69613
- type: "object",
69614
- properties: {
69615
- enabled: {
69616
- type: "boolean"
69617
- },
69618
- requestVolumeThreshold: {
69619
- type: "number"
69620
- },
69621
- failureRatio: {
69622
- type: "number"
69623
- },
69624
- successThreshold: {
69625
- type: "number"
69626
- }
69627
- },
69628
- required: ["enabled", "requestVolumeThreshold", "failureRatio", "successThreshold"]
69629
- },
69630
- rateLimiter: {
69631
- type: "object",
69632
- properties: {
69633
- enabled: {
69634
- type: "boolean"
69635
- },
69636
- value: {
69637
- type: "number"
69638
- },
69639
- window: {
69640
- type: "string"
69641
- },
69642
- minSpacing: {
69643
- type: "string"
69644
- }
69645
- },
69646
- required: ["enabled", "value", "window", "minSpacing"]
69647
- }
69648
- }
69649
- }
69650
- },
69651
- additionalProperties: false
69652
- }
69653
- },
69654
- additionalProperties: false,
69655
- required: ["id", "name", "ownership", "sdk"]
69656
- };
69657
-
69658
- // packages/kong-cli/src/common/kongJson.ts
69659
- var SUPPORTED_SDK = ["kotlin", "python"];
69660
- function validateKongJson(kongJson) {
69661
- if (isEmpty(kongJson.id)) {
69662
- throw new AppError(
69663
- "The `id` field should not be empty. Please provide a valid identifier in kong.json."
69664
- );
69665
- }
69666
- if (!SUPPORTED_SDK.includes(kongJson.sdk)) {
69667
- throw new AppError(`Unexpected SDK value: ${kongJson.sdk}. Supported SDK: ${SUPPORTED_SDK}.`);
69668
- }
69669
- if (!/^[a-zA-Z0-9]{12}$/.test(kongJson.id)) {
69670
- throw new AppError(
69671
- "The `id` should contain exactly 12 alphanumeric characters (letters and digits). Ensure the ID is not longer than 12 characters and does not include any special characters."
69672
- );
69673
- }
69674
- if (isEmpty(kongJson.name)) {
69675
- throw new AppError(
69676
- "The `name` field should not be empty. Please provide a valid name in kong.json."
69677
- );
69678
- }
69679
- if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(kongJson.name)) {
69680
- throw new AppError(
69681
- "The `name` should only contain lowercase letters, digits, and dashes. Dashes can only appear between alphanumeric characters, and the name cannot start or end with a dash."
69682
- );
69683
- }
69684
- if (kongJson.ownership.length === 0) {
69685
- throw new AppError(
69686
- "The `ownership` field should contain at least one user name. Please provide valid ownership information in kong.json."
69687
- );
69688
- }
69689
- const result = (0, import_json_schema.validate)(kongJson.alias, KONG_JSON_SCHEMA);
69690
- if (result.errors.length) {
69691
- throw new AppError(
69692
- "The provided `kong.json` does not follow the expected JSON schema. Errors: \n" + prettyJson(result.errors)
69693
- );
69694
- }
69695
- return kongJson;
69696
- }
69697
- function getKongJson() {
69698
- const kongJsonPath = resolveProjectPath("kong.json");
69699
- try {
69700
- const fileContent = import_fs3.default.readFileSync(kongJsonPath, "utf-8");
69701
- const kongJson = JSON.parse(fileContent);
69702
- return validateKongJson(kongJson);
69703
- } catch (ex) {
69704
- if (ex instanceof SyntaxError) {
69705
- throw new AppError(`Error parsing kong.json: ${ex.message}`);
69706
- }
69707
- throw ex;
69708
- }
69709
- }
69710
-
69711
69721
  // packages/kong-cli/src/services/api.ts
69712
69722
  var API_HEADERS = {
69713
69723
  headers: {
@@ -69942,12 +69952,23 @@ var PublicClient = class {
69942
69952
  };
69943
69953
 
69944
69954
  // packages/kong-cli/src/commands/setExtensionAliasCommand.ts
69955
+ function validateName(value) {
69956
+ if (isEmpty(value)) {
69957
+ throw new AppError("The alias name should not be empty.");
69958
+ }
69959
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) {
69960
+ throw new AppError(
69961
+ "The alias name should only contain lowercase letters, digits, and dashes. Dashes can only appear between alphanumeric characters, and the name cannot start or end with a dash."
69962
+ );
69963
+ }
69964
+ }
69945
69965
  var SetExtensionAliasCommand = class {
69946
69966
  constructor(profile) {
69947
69967
  this.publicClient = new PublicClient(profile.kongBaseUrl);
69948
69968
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
69949
69969
  }
69950
69970
  async execute(aliasName, extensionVersion) {
69971
+ validateName(aliasName);
69951
69972
  await new Listr(
69952
69973
  [
69953
69974
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -7,4 +7,5 @@ export interface KongJson {
7
7
  ownership: [User["name"], ...Array<User["name"]>];
8
8
  alias?: SdkExtensionAlias;
9
9
  }
10
+ export declare function validateKongJson(kongJson: KongJson): KongJson;
10
11
  export declare function getKongJson(): KongJson;
@@ -1,3 +1,4 @@
1
+ import { ShortUUID } from "@kong/ts";
1
2
  export interface ILogger {
2
3
  info(message: string): any;
3
4
  debug(message: string): any;
@@ -7,6 +8,6 @@ export interface ILogger {
7
8
  export declare function env(key: string): string;
8
9
  export declare function optionalEnv(key: string): string;
9
10
  export declare function resolveProjectPath(fileName: string): string;
10
- export declare function generateShortId(): string;
11
+ export declare function generateShortId(): ShortUUID;
11
12
  export declare function spawnCommand(commandText: string, logger?: ILogger, shell?: boolean): Promise<string>;
12
13
  export declare function printError(message: string, error: unknown): void;