@axway/axway-central-cli 2.17.0 → 2.18.0-rc.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/dist/cli.js +6 -28
- package/dist/commands/apply/index.js +9 -24
- package/dist/commands/completion/index.js +3 -9
- package/dist/commands/config/common/index.js +2 -11
- package/dist/commands/config/index.js +2 -7
- package/dist/commands/config/list.js +2 -6
- package/dist/commands/config/set.js +4 -31
- package/dist/commands/config/unset.js +2 -12
- package/dist/commands/create/agentResource.js +12 -32
- package/dist/commands/create/environment.js +6 -16
- package/dist/commands/create/index.js +9 -26
- package/dist/commands/create/serviceAccount.js +2 -6
- package/dist/commands/delete/index.js +15 -33
- package/dist/commands/edit/environment.js +6 -21
- package/dist/commands/edit/index.js +4 -8
- package/dist/commands/get/index.js +27 -44
- package/dist/commands/install/agents.js +44 -73
- package/dist/commands/install/apigeexSaasAgents.js +35 -98
- package/dist/commands/install/awsAgents.js +89 -139
- package/dist/commands/install/awsSaasAgents.js +50 -142
- package/dist/commands/install/azureAgents.js +39 -79
- package/dist/commands/install/edgeAgents.js +17 -110
- package/dist/commands/install/gitHubSaasAgents.js +286 -0
- package/dist/commands/install/helpers/creators.js +17 -70
- package/dist/commands/install/helpers/deleters.js +2 -11
- package/dist/commands/install/helpers/getters.js +4 -30
- package/dist/commands/install/helpers/index.js +13 -48
- package/dist/commands/install/helpers/inputs.js +26 -98
- package/dist/commands/install/helpers/regex.js +29 -34
- package/dist/commands/install/helpers/templates/awsTemplates.js +6 -23
- package/dist/commands/install/helpers/templates/azureTemplates.js +5 -24
- package/dist/commands/install/helpers/templates/edgeTemplates.js +7 -38
- package/dist/commands/install/helpers/templates/istioTemplates.js +5 -16
- package/dist/commands/install/index.js +4 -10
- package/dist/commands/install/istioAgents.js +40 -117
- package/dist/commands/install/platform.js +20 -52
- package/dist/commands/proxies/create.js +2 -18
- package/dist/commands/proxies/index.js +4 -8
- package/dist/commands/proxies/promote.js +2 -21
- package/dist/common/ApiServerClient.js +64 -173
- package/dist/common/CacheController.js +11 -32
- package/dist/common/CliConfigManager.js +14 -27
- package/dist/common/CompositeError.js +6 -30
- package/dist/common/CoreConfigController.js +18 -40
- package/dist/common/DefinitionsManager.js +29 -76
- package/dist/common/Kubectl.js +2 -25
- package/dist/common/PlatformClient.js +19 -63
- package/dist/common/Renderer.js +25 -87
- package/dist/common/TmpFile.js +11 -28
- package/dist/common/bashCommands.js +3 -22
- package/dist/common/basicPrompts.js +8 -43
- package/dist/common/dataService.js +22 -50
- package/dist/common/errorHandler.js +0 -9
- package/dist/common/resultsRenderers.js +10 -42
- package/dist/common/types.js +116 -341
- package/dist/common/utils.js +37 -99
- package/dist/main.js +0 -2
- package/package.json +2 -2
package/dist/common/utils.js
CHANGED
|
@@ -7,43 +7,27 @@ exports.FormatString = FormatString;
|
|
|
7
7
|
exports.parseScopeParam = exports.loadAndVerifySpecs = exports.loadAndVerifyApigeeXCredentialFile = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
|
|
8
8
|
exports.sanitizeMetadata = sanitizeMetadata;
|
|
9
9
|
exports.writeToFile = exports.writeTemplates = exports.verifyScopeParam = exports.verifyFile = exports.transformSimpleFilters = void 0;
|
|
10
|
-
|
|
11
10
|
var _fsExtra = require("fs-extra");
|
|
12
|
-
|
|
13
11
|
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
14
|
-
|
|
15
12
|
var _jsYaml = require("js-yaml");
|
|
16
|
-
|
|
17
13
|
var _os = require("os");
|
|
18
|
-
|
|
19
14
|
var _path = require("path");
|
|
20
|
-
|
|
21
15
|
var _CompositeError = require("./CompositeError");
|
|
22
|
-
|
|
23
16
|
var _types = require("./types");
|
|
24
|
-
|
|
25
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
exports.isWindows = isWindows;
|
|
29
|
-
const configFile = (0, _path.join)((0, _os.homedir)(), '.axway', 'central.json');
|
|
30
|
-
exports.configFile = configFile;
|
|
31
|
-
|
|
18
|
+
const isWindows = exports.isWindows = /^win/.test(process.platform);
|
|
19
|
+
const configFile = exports.configFile = (0, _path.join)((0, _os.homedir)(), '.axway', 'central.json');
|
|
32
20
|
const getConfig = async () => !(0, _fsExtra.existsSync)(configFile) ? Promise.resolve({}) : await (0, _fsExtra.readJson)(configFile);
|
|
33
|
-
|
|
34
21
|
exports.getConfig = getConfig;
|
|
35
|
-
|
|
36
22
|
const verifyFile = specFilePath => {
|
|
37
23
|
let stats;
|
|
38
24
|
let fileExtension;
|
|
39
|
-
|
|
40
25
|
try {
|
|
41
26
|
stats = (0, _fsExtra.lstatSync)(specFilePath);
|
|
42
27
|
fileExtension = (0, _path.extname)(specFilePath);
|
|
43
28
|
} catch (e) {
|
|
44
29
|
throw new Error(`Couldn't find the definition file: ${specFilePath}`);
|
|
45
30
|
}
|
|
46
|
-
|
|
47
31
|
if (!stats.isFile()) {
|
|
48
32
|
throw new Error(`Couldn't load the definition file: ${specFilePath}`);
|
|
49
33
|
} else if (stats.size >= _types.MAX_FILE_SIZE) {
|
|
@@ -52,9 +36,7 @@ const verifyFile = specFilePath => {
|
|
|
52
36
|
throw new Error(`File extension is invalid, please provide '.yaml' or '.yml' or '.json' file`);
|
|
53
37
|
}
|
|
54
38
|
};
|
|
55
|
-
|
|
56
39
|
exports.verifyFile = verifyFile;
|
|
57
|
-
|
|
58
40
|
const writeToFile = (path, data) => {
|
|
59
41
|
try {
|
|
60
42
|
(0, _fsExtra.writeFileSync)(path, data);
|
|
@@ -63,93 +45,86 @@ const writeToFile = (path, data) => {
|
|
|
63
45
|
throw new Error(`Error while writing the yaml file to: ${path}`);
|
|
64
46
|
}
|
|
65
47
|
};
|
|
48
|
+
|
|
66
49
|
/**
|
|
67
50
|
* Checks if the passed item can be converted to a JSON or is a valid JSON object.
|
|
68
51
|
* @param item item to check
|
|
69
52
|
* @returns true if the item can be converted, false otherwise.
|
|
70
53
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
54
|
exports.writeToFile = writeToFile;
|
|
74
|
-
|
|
75
55
|
const isValidJson = item => {
|
|
76
56
|
let parsedItem = typeof item !== 'string' ? JSON.stringify(item) : item;
|
|
77
|
-
|
|
78
57
|
try {
|
|
79
58
|
parsedItem = JSON.parse(parsedItem);
|
|
80
59
|
} catch (e) {
|
|
81
60
|
return false;
|
|
82
61
|
}
|
|
83
|
-
|
|
84
62
|
return typeof parsedItem === 'object' && item !== null;
|
|
85
63
|
};
|
|
64
|
+
|
|
86
65
|
/**
|
|
87
66
|
* Loads and parse file from path, accepts JSON and YAML files. Also completing validation on "kind" values.
|
|
88
67
|
* @param specFilePath file path
|
|
89
68
|
* @param allowedKinds array of allowed "kind" values
|
|
90
69
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
70
|
exports.isValidJson = isValidJson;
|
|
94
|
-
|
|
95
71
|
const loadAndVerifySpecs = async (specFilePath, allowedKinds) => {
|
|
96
72
|
// Load the given JSON or YAML file.
|
|
97
73
|
let docs = [];
|
|
98
74
|
let isMissingName = false;
|
|
99
|
-
|
|
100
75
|
try {
|
|
101
76
|
docs = (0, _jsYaml.loadAll)(await (0, _fsExtra.readFile)(specFilePath, 'utf8'));
|
|
102
77
|
} catch (e) {
|
|
103
78
|
throw new Error(e.reason && e.reason.includes('null byte') ? `File encoding is invalid, please make sure it is using UTF-8` : `File content is invalid.`);
|
|
104
|
-
}
|
|
105
|
-
|
|
79
|
+
}
|
|
106
80
|
|
|
81
|
+
// if user pass an array of json objects, docs const will have nested array, workaround for this:
|
|
107
82
|
if ((0, _path.extname)(specFilePath) === '.json' && docs.length === 1 && Array.isArray(docs[0])) {
|
|
108
83
|
docs = docs[0];
|
|
109
|
-
}
|
|
110
|
-
|
|
84
|
+
}
|
|
111
85
|
|
|
112
|
-
|
|
86
|
+
// Do not continue if given an empty file.
|
|
87
|
+
if (!docs.length) throw new Error(`File is empty.`);
|
|
113
88
|
|
|
89
|
+
// Validate all entries in the file.
|
|
114
90
|
const errors = [];
|
|
115
|
-
|
|
116
91
|
const createErrorPrefix = (index, kind, name) => {
|
|
117
92
|
return `Entry ${index + 1}, "${kind}/${name || 'Unknown name'}"`;
|
|
118
93
|
};
|
|
119
|
-
|
|
120
94
|
for (let index = 0; index < docs.length; index++) {
|
|
121
95
|
// Verify document is defined/valid.
|
|
122
96
|
const doc = docs[index];
|
|
123
|
-
|
|
124
97
|
if (typeof doc !== 'object' || !doc) {
|
|
125
98
|
errors.push(new Error(`${createErrorPrefix(index)}: Entry format is invalid.`));
|
|
126
99
|
continue;
|
|
127
|
-
}
|
|
128
|
-
|
|
100
|
+
}
|
|
129
101
|
|
|
102
|
+
// Set a flag if at least 1 name is messing in file.
|
|
130
103
|
if (!doc.name) {
|
|
131
104
|
isMissingName = true;
|
|
132
|
-
}
|
|
133
|
-
|
|
105
|
+
}
|
|
134
106
|
|
|
107
|
+
// Validate resource kind.
|
|
135
108
|
if (!doc.kind) {
|
|
136
109
|
errors.push(Error(`${createErrorPrefix(index, doc.kind, doc.name)}: The "kind" field is missing.` + `\nCurrently supported values are (case sensitive): ${[...allowedKinds.values()].join(', ')}`));
|
|
137
110
|
} else if (!allowedKinds.has(doc.kind)) {
|
|
138
111
|
errors.push(new Error(`${createErrorPrefix(index, doc.kind, doc.name)}: Kind "${doc.kind}" is unsupported.` + `\nCurrently supported values are (case sensitive): ${[...allowedKinds.values()].join(', ')}`));
|
|
139
|
-
}
|
|
112
|
+
}
|
|
140
113
|
|
|
114
|
+
// TODO: Validate "metadata.scope.kind" if available. Requires DefinitionManager.getSortedKindsMap() result.
|
|
141
115
|
}
|
|
142
116
|
|
|
143
117
|
if (errors.length > 0) {
|
|
144
118
|
throw new _CompositeError.CompositeError(errors);
|
|
145
|
-
}
|
|
146
|
-
|
|
119
|
+
}
|
|
147
120
|
|
|
121
|
+
// File's contents appears to be valid. Return loaded info.
|
|
148
122
|
return {
|
|
149
123
|
docs,
|
|
150
124
|
isMissingName
|
|
151
125
|
};
|
|
152
126
|
};
|
|
127
|
+
|
|
153
128
|
/**
|
|
154
129
|
* Generate a GenericResource instance from resource definition, resource name, and scope name. Used
|
|
155
130
|
* in some rendering logic for the "delete" command.
|
|
@@ -159,10 +134,7 @@ const loadAndVerifySpecs = async (specFilePath, allowedKinds) => {
|
|
|
159
134
|
* @param {string} scopeName optional scope name
|
|
160
135
|
* @returns {GenericResource} generic resource representation
|
|
161
136
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
137
|
exports.loadAndVerifySpecs = loadAndVerifySpecs;
|
|
165
|
-
|
|
166
138
|
const buildGenericResource = ({
|
|
167
139
|
resourceDef,
|
|
168
140
|
resourceName,
|
|
@@ -180,74 +152,63 @@ const buildGenericResource = ({
|
|
|
180
152
|
scope: {
|
|
181
153
|
kind: resourceDef.spec.scope.kind,
|
|
182
154
|
name: scopeName
|
|
183
|
-
}
|
|
184
|
-
|
|
155
|
+
}
|
|
156
|
+
// note: forced conversion here only because using generated resources for rendering simple text
|
|
185
157
|
} : undefined,
|
|
186
158
|
spec: {}
|
|
187
159
|
};
|
|
188
160
|
};
|
|
161
|
+
|
|
189
162
|
/**
|
|
190
163
|
* Returns true if error object is of type ApiServerError
|
|
191
164
|
* @param err error object to check
|
|
192
165
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
166
|
exports.buildGenericResource = buildGenericResource;
|
|
196
|
-
|
|
197
167
|
const isApiServerErrorType = err => {
|
|
198
168
|
const cast = err;
|
|
199
169
|
return !!cast.status && !!cast.title && !!cast.detail;
|
|
200
170
|
};
|
|
171
|
+
|
|
201
172
|
/**
|
|
202
173
|
* Returns true if error object is of type ApiServerErrorResponse
|
|
203
174
|
* @param err error object to check
|
|
204
175
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
176
|
exports.isApiServerErrorType = isApiServerErrorType;
|
|
208
|
-
|
|
209
177
|
const isApiServerErrorResponseType = err => {
|
|
210
178
|
const cast = err;
|
|
211
179
|
return !!cast.errors && Array.isArray(cast.errors);
|
|
212
180
|
};
|
|
181
|
+
|
|
213
182
|
/**
|
|
214
183
|
* Wrapper to return a compare function for sorting by "kind" value in array of resources in ascending
|
|
215
184
|
* order. Order based on "sortedKindValues" array.
|
|
216
185
|
* @param {Array<ResourceDefinition>} sortedResourceDefs array of ResourceDefinitions defining a required order of the resources.
|
|
217
186
|
* @returns {Function} Array sorting function
|
|
218
187
|
*/
|
|
219
|
-
|
|
220
|
-
|
|
221
188
|
exports.isApiServerErrorResponseType = isApiServerErrorResponseType;
|
|
222
|
-
|
|
223
189
|
const compareResourcesByKindAsc = sortedResourceDefs => (a, b) => sortedResourceDefs.findIndex(def => {
|
|
224
190
|
var _def$spec$scope, _a$metadata, _a$metadata$scope;
|
|
225
|
-
|
|
226
191
|
return def.spec.kind === a.kind && ((_def$spec$scope = def.spec.scope) === null || _def$spec$scope === void 0 ? void 0 : _def$spec$scope.kind) === ((_a$metadata = a.metadata) === null || _a$metadata === void 0 ? void 0 : (_a$metadata$scope = _a$metadata.scope) === null || _a$metadata$scope === void 0 ? void 0 : _a$metadata$scope.kind);
|
|
227
192
|
}) - sortedResourceDefs.findIndex(def => {
|
|
228
193
|
var _def$spec$scope2, _b$metadata, _b$metadata$scope;
|
|
229
|
-
|
|
230
194
|
return def.spec.kind === b.kind && ((_def$spec$scope2 = def.spec.scope) === null || _def$spec$scope2 === void 0 ? void 0 : _def$spec$scope2.kind) === ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : (_b$metadata$scope = _b$metadata.scope) === null || _b$metadata$scope === void 0 ? void 0 : _b$metadata$scope.kind);
|
|
231
195
|
});
|
|
196
|
+
|
|
232
197
|
/**
|
|
233
198
|
* Wrapper to return a compare function for sorting by "kind" value in array of resources in descending
|
|
234
199
|
* order. Order based on "sortedKindValues" array.
|
|
235
200
|
* @param {Array<ResourceDefinition>} sortedResourceDefs array of ResourceDefinitions defining a required order of the resources.
|
|
236
201
|
* @returns {Function} Array sorting function
|
|
237
202
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
203
|
exports.compareResourcesByKindAsc = compareResourcesByKindAsc;
|
|
241
|
-
|
|
242
204
|
const compareResourcesByKindDesc = sortedResourceDefs => (a, b) => sortedResourceDefs.findIndex(def => {
|
|
243
205
|
var _def$spec$scope3, _b$metadata2, _b$metadata2$scope;
|
|
244
|
-
|
|
245
206
|
return def.spec.kind === b.kind && ((_def$spec$scope3 = def.spec.scope) === null || _def$spec$scope3 === void 0 ? void 0 : _def$spec$scope3.kind) === ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 ? void 0 : (_b$metadata2$scope = _b$metadata2.scope) === null || _b$metadata2$scope === void 0 ? void 0 : _b$metadata2$scope.kind);
|
|
246
207
|
}) - sortedResourceDefs.findIndex(def => {
|
|
247
208
|
var _def$spec$scope4, _a$metadata2, _a$metadata2$scope;
|
|
248
|
-
|
|
249
209
|
return def.spec.kind === a.kind && ((_def$spec$scope4 = def.spec.scope) === null || _def$spec$scope4 === void 0 ? void 0 : _def$spec$scope4.kind) === ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 ? void 0 : (_a$metadata2$scope = _a$metadata2.scope) === null || _a$metadata2$scope === void 0 ? void 0 : _a$metadata2$scope.kind);
|
|
250
210
|
});
|
|
211
|
+
|
|
251
212
|
/**
|
|
252
213
|
* Api-server returns the "resourceVersion" in metadata object as a counter for resource updates.
|
|
253
214
|
* If a user will send this key in the payload it will throw an error so using this helper to sanitizing metadata on
|
|
@@ -255,27 +216,21 @@ const compareResourcesByKindDesc = sortedResourceDefs => (a, b) => sortedResourc
|
|
|
255
216
|
* @param doc resource data
|
|
256
217
|
* @returns {GenericResource} resource data without metadata.resourceVersion key
|
|
257
218
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
219
|
exports.compareResourcesByKindDesc = compareResourcesByKindDesc;
|
|
261
|
-
|
|
262
220
|
function sanitizeMetadata(doc) {
|
|
263
221
|
var _doc$metadata;
|
|
264
|
-
|
|
265
222
|
if (doc !== null && doc !== void 0 && (_doc$metadata = doc.metadata) !== null && _doc$metadata !== void 0 && _doc$metadata.resourceVersion) {
|
|
266
223
|
delete doc.metadata.resourceVersion;
|
|
267
224
|
}
|
|
268
|
-
|
|
269
225
|
return doc;
|
|
270
226
|
}
|
|
271
|
-
|
|
272
227
|
const buildTemplate = (templateFunc, input) => {
|
|
273
228
|
const template = _handlebars.default.compile(templateFunc(), {
|
|
274
229
|
noEscape: true
|
|
275
230
|
});
|
|
276
|
-
|
|
277
231
|
return template(input);
|
|
278
232
|
};
|
|
233
|
+
|
|
279
234
|
/**
|
|
280
235
|
* Takes in a set of parameters (values), compiles a string utilizing the provided handlebars templating function (templateFunc)
|
|
281
236
|
* and the buildTemplate function with those parameters, and finally writes the output string to a file of the name that was provided (fileName).
|
|
@@ -283,24 +238,19 @@ const buildTemplate = (templateFunc, input) => {
|
|
|
283
238
|
* @param {object} values
|
|
284
239
|
* @param {()=>string} templateFunc
|
|
285
240
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
241
|
exports.buildTemplate = buildTemplate;
|
|
289
|
-
|
|
290
242
|
const writeTemplates = (fileName, values, templateFunc) => {
|
|
291
243
|
const data = buildTemplate(templateFunc, values);
|
|
292
244
|
writeToFile(fileName, data);
|
|
293
245
|
};
|
|
246
|
+
|
|
294
247
|
/**
|
|
295
248
|
* helper function to extend the handlebars built-in helpers functionality to add a way to compare equality of two strings or numbers
|
|
296
249
|
* @param {string|number} lvalue
|
|
297
250
|
* @param {string|number} rvalue
|
|
298
251
|
* @param {{fn:(} options
|
|
299
252
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
253
|
exports.writeTemplates = writeTemplates;
|
|
303
|
-
|
|
304
254
|
const hbsCompare = () => {
|
|
305
255
|
_handlebars.default.registerHelper('compare', (context, lvalue, rvalue, options) => {
|
|
306
256
|
let operator = options.hash.operator || '===';
|
|
@@ -331,7 +281,6 @@ const hbsCompare = () => {
|
|
|
331
281
|
}
|
|
332
282
|
};
|
|
333
283
|
var result = operators[operator](lvalue, rvalue);
|
|
334
|
-
|
|
335
284
|
if (result) {
|
|
336
285
|
return options.fn(context);
|
|
337
286
|
} else {
|
|
@@ -339,15 +288,13 @@ const hbsCompare = () => {
|
|
|
339
288
|
}
|
|
340
289
|
});
|
|
341
290
|
};
|
|
291
|
+
|
|
342
292
|
/**
|
|
343
293
|
* Parse and verify scope param, returns undefined if param is undefined. Throws an error if "Kind" is unknown.
|
|
344
294
|
* @param scopeParam raw scope param value
|
|
345
295
|
* @returns {ParsedScopeParam | undefined}
|
|
346
296
|
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
297
|
exports.hbsCompare = hbsCompare;
|
|
350
|
-
|
|
351
298
|
const parseScopeParam = scopeParam => {
|
|
352
299
|
if (!scopeParam) return undefined;else if (scopeParam.indexOf('/') === -1) return {
|
|
353
300
|
name: scopeParam
|
|
@@ -361,6 +308,7 @@ const parseScopeParam = scopeParam => {
|
|
|
361
308
|
};
|
|
362
309
|
}
|
|
363
310
|
};
|
|
311
|
+
|
|
364
312
|
/**
|
|
365
313
|
* Verify parsed scope param:
|
|
366
314
|
* 1. scope kind should be known.
|
|
@@ -369,19 +317,16 @@ const parseScopeParam = scopeParam => {
|
|
|
369
317
|
* @param defs resource definitions where at least one should match the scope kind if some "scoped" resources are there.
|
|
370
318
|
* @param scopeParam parsed scope param.
|
|
371
319
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
374
320
|
exports.parseScopeParam = parseScopeParam;
|
|
375
|
-
|
|
376
321
|
const verifyScopeParam = (allKinds, defs, scopeParam) => {
|
|
377
322
|
const allowedScopeKinds = new Set();
|
|
378
323
|
defs.forEach(defs => !!defs.scope && allowedScopeKinds.add(defs.scope.spec.kind));
|
|
379
|
-
|
|
380
324
|
if (scopeParam !== null && scopeParam !== void 0 && scopeParam.kind) {
|
|
381
325
|
if (!allKinds.has(scopeParam.kind)) throw new Error(`unsupported kind value "${scopeParam.kind}" in the "--scope" param.` + `\nCurrently supported values are (case sensitive): ${[...allKinds.values()].join(', ')}`);
|
|
382
326
|
if (allowedScopeKinds.size > 0 && !allowedScopeKinds.has(scopeParam.kind)) throw Error(`scope kind "${scopeParam.kind}" is invalid.` + `\n"${defs[0].resource.spec.kind}" resource might exist in the following scopes: ${[...allowedScopeKinds.values()].join(', ')}`);
|
|
383
327
|
}
|
|
384
328
|
};
|
|
329
|
+
|
|
385
330
|
/**
|
|
386
331
|
* Transforms simple filters(title, attribute, tag) into an RSQL-formatted query string the GET API supports.
|
|
387
332
|
* @param {string} title The title the user wants to filter the resource list by.
|
|
@@ -389,10 +334,7 @@ const verifyScopeParam = (allKinds, defs, scopeParam) => {
|
|
|
389
334
|
* @param {string} tag The tag the user wants to filter the resource list by.
|
|
390
335
|
* @returns {string} transformedFilter, the RSQL formatted query string
|
|
391
336
|
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
337
|
exports.verifyScopeParam = verifyScopeParam;
|
|
395
|
-
|
|
396
338
|
const transformSimpleFilters = (title, attribute, tag) => {
|
|
397
339
|
const titleFilter = title ? `title=='*${title}*'` : '';
|
|
398
340
|
const attributeKey = attribute && attribute.split('=')[0];
|
|
@@ -403,37 +345,33 @@ const transformSimpleFilters = (title, attribute, tag) => {
|
|
|
403
345
|
const transformedFilter = formattedFilter.charAt(formattedFilter.length - 1) === ';' ? formattedFilter.slice(0, -1) : formattedFilter;
|
|
404
346
|
return transformedFilter;
|
|
405
347
|
};
|
|
406
|
-
|
|
407
348
|
exports.transformSimpleFilters = transformSimpleFilters;
|
|
408
|
-
|
|
409
349
|
function FormatString(str, ...val) {
|
|
410
350
|
for (let index = 0; index < val.length; index++) {
|
|
411
351
|
str = str.replace(`{${index}}`, val[index]);
|
|
412
352
|
}
|
|
413
|
-
|
|
414
353
|
return str;
|
|
415
354
|
}
|
|
355
|
+
|
|
416
356
|
/**
|
|
417
357
|
* Loads and parse file from path, accepts JSON file. Also validates additional details.
|
|
418
358
|
* @param credentialFilePath file path
|
|
419
359
|
*/
|
|
420
|
-
|
|
421
|
-
|
|
422
360
|
const loadAndVerifyApigeeXCredentialFile = async credentialFilePath => {
|
|
423
361
|
// Load the given JSON file.
|
|
424
362
|
let fileInfo = '';
|
|
425
|
-
|
|
426
363
|
try {
|
|
427
364
|
fileInfo = await (0, _fsExtra.readJson)(credentialFilePath);
|
|
428
365
|
} catch (e) {
|
|
429
366
|
throw new Error(e.reason);
|
|
430
|
-
}
|
|
367
|
+
}
|
|
431
368
|
|
|
369
|
+
// Do not continue if given an empty file.
|
|
370
|
+
if (fileInfo === '') throw new Error(`File is empty.`);
|
|
432
371
|
|
|
433
|
-
|
|
434
|
-
// Return loaded info.
|
|
372
|
+
// TODO: Validate additional details if needed
|
|
435
373
|
|
|
374
|
+
// Return loaded info.
|
|
436
375
|
return fileInfo;
|
|
437
376
|
};
|
|
438
|
-
|
|
439
377
|
exports.loadAndVerifyApigeeXCredentialFile = loadAndVerifyApigeeXCredentialFile;
|
package/dist/main.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cli = _interopRequireDefault(require("./cli"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
_cli.default.exec().catch(err => {
|
|
8
6
|
console.error(err);
|
|
9
7
|
process.exit(err.exitCode || 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axway/axway-central-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0-rc.0",
|
|
4
4
|
"description": "Manage APIs, services and publish to the Unified Catalog",
|
|
5
5
|
"homepage": "https://platform.axway.com",
|
|
6
6
|
"author": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"json5": "^2.2.3",
|
|
60
60
|
"lodash": "^4.17.21",
|
|
61
61
|
"node-cache": "^5.1.2",
|
|
62
|
-
"npm-check-updates": "
|
|
62
|
+
"npm-check-updates": "16.14.5",
|
|
63
63
|
"ora": "^5.4.1",
|
|
64
64
|
"promise-limit": "^2.7.0",
|
|
65
65
|
"semver": "^7.3.7",
|