@commercelayer/cli-plugin-provisioning 1.0.1 → 2.0.0-oclif3.10

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.
Files changed (39) hide show
  1. package/README.md +68 -16
  2. package/bin/run.js +7 -0
  3. package/lib/base.d.ts +16 -6
  4. package/lib/base.js +115 -92
  5. package/lib/commands/provisioning/create.d.ts +14 -7
  6. package/lib/commands/provisioning/create.js +48 -44
  7. package/lib/commands/provisioning/delete.d.ts +8 -4
  8. package/lib/commands/provisioning/delete.js +21 -20
  9. package/lib/commands/provisioning/exec.d.ts +4 -4
  10. package/lib/commands/provisioning/exec.js +18 -18
  11. package/lib/commands/provisioning/fetch.d.ts +14 -9
  12. package/lib/commands/provisioning/fetch.js +19 -18
  13. package/lib/commands/provisioning/get.d.ts +13 -9
  14. package/lib/commands/provisioning/get.js +16 -15
  15. package/lib/commands/provisioning/list.d.ts +14 -7
  16. package/lib/commands/provisioning/list.js +65 -61
  17. package/lib/commands/provisioning/noc.js +2 -2
  18. package/lib/commands/provisioning/relationship.d.ts +14 -10
  19. package/lib/commands/provisioning/relationship.js +26 -23
  20. package/lib/commands/provisioning/resources.js +9 -9
  21. package/lib/commands/provisioning/retrieve.d.ts +9 -5
  22. package/lib/commands/provisioning/retrieve.js +43 -42
  23. package/lib/commands/provisioning/update.d.ts +14 -10
  24. package/lib/commands/provisioning/update.js +57 -55
  25. package/lib/lang/curl.d.ts +4 -0
  26. package/lib/lang/curl.js +17 -0
  27. package/lib/lang/index.d.ts +19 -0
  28. package/lib/lang/index.js +51 -0
  29. package/lib/lang/node.d.ts +4 -0
  30. package/lib/lang/node.js +26 -0
  31. package/lib/lang/request.d.ts +32 -0
  32. package/lib/lang/request.js +108 -0
  33. package/lib/lang/ruby.d.ts +4 -0
  34. package/lib/lang/ruby.js +7 -0
  35. package/oclif.manifest.json +508 -12
  36. package/package.json +21 -19
  37. package/bin/dev +0 -18
  38. package/bin/dev.cmd +0 -3
  39. package/bin/run +0 -5
package/README.md CHANGED
@@ -27,7 +27,7 @@ commercelayer [COMMAND] (--help | -h) for detailed information about plugin comm
27
27
  * [`commercelayer provisioning:create RESOURCE`](#commercelayer-provisioningcreate-resource)
28
28
  * [`commercelayer provisioning:delete RESOURCE [ID]`](#commercelayer-provisioningdelete-resource-id)
29
29
  * [`commercelayer provisioning:exec RESOURCE [ID] [ACTION]`](#commercelayer-provisioningexec-resource-id-action)
30
- * [`commercelayer provisioning:fetch PATH [ID]`](#commercelayer-provisioningfetch-path-id)
30
+ * [`commercelayer provisioning:fetch RESOURCE PATH [ID]`](#commercelayer-provisioningfetch-resource-path-id)
31
31
  * [`commercelayer provisioning:get RESOURCE [ID]`](#commercelayer-provisioningget-resource-id)
32
32
  * [`commercelayer provisioning:list RESOURCE`](#commercelayer-provisioninglist-resource)
33
33
  * [`commercelayer provisioning:resources`](#commercelayer-provisioningresources)
@@ -40,8 +40,8 @@ Create a new resource.
40
40
 
41
41
  ```sh-session
42
42
  USAGE
43
- $ commercelayer provisioning:create RESOURCE [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-O <value>] [-D <value> |
44
- -a <value> | -r <value> | -m <value> | ]
43
+ $ commercelayer provisioning:create RESOURCE [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl ]
44
+ [--node ] [-H ] [-Y ] [-O <value>] [-D <value> | -a <value> | -r <value> | -m <value> | ]
45
45
 
46
46
  ARGUMENTS
47
47
  RESOURCE the resource type
@@ -60,6 +60,13 @@ FLAGS
60
60
  -r, --relationship=<value>... define a relationship with another resource
61
61
  -u, --unformatted print unformatted JSON output
62
62
 
63
+ DOCUMENTATION FLAGS
64
+ -l, --lang=<option> show the CLI command in the specified language syntax
65
+ <options: curl|node>
66
+ --curl show the equivalent cURL command of the CLI command
67
+ --doc show the CLI command in a specific language
68
+ --node show the equivalent Node SDK source code of the CLI command
69
+
63
70
  DESCRIPTION
64
71
  create a new resource
65
72
 
@@ -86,7 +93,8 @@ Delete an existing resource.
86
93
 
87
94
  ```sh-session
88
95
  USAGE
89
- $ commercelayer provisioning:delete RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ]
96
+ $ commercelayer provisioning:delete RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl
97
+ ] [--node ] [-H ] [-Y ]
90
98
 
91
99
  ARGUMENTS
92
100
  RESOURCE the resource type
@@ -101,6 +109,13 @@ FLAGS
101
109
  -j, --json convert output in standard JSON format
102
110
  -u, --unformatted print unformatted JSON output
103
111
 
112
+ DOCUMENTATION FLAGS
113
+ -l, --lang=<option> show the CLI command in the specified language syntax
114
+ <options: curl|node>
115
+ --curl show the equivalent cURL command of the CLI command
116
+ --doc show the CLI command in a specific language
117
+ --node show the equivalent Node SDK source code of the CLI command
118
+
104
119
  DESCRIPTION
105
120
  delete an existing resource
106
121
 
@@ -150,18 +165,19 @@ EXAMPLES
150
165
 
151
166
  _See code: [src/commands/provisioning/exec.ts](https://github.com/commercelayer/commercelayer-cli-plugin-provisioning/blob/main/src/commands/provisioning/exec.ts)_
152
167
 
153
- ### `commercelayer provisioning:fetch PATH [ID]`
168
+ ### `commercelayer provisioning:fetch RESOURCE PATH [ID]`
154
169
 
155
170
  Retrieve a resource or list a set of resources.
156
171
 
157
172
  ```sh-session
158
173
  USAGE
159
- $ commercelayer provisioning:fetch PATH [ID] [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-e <value> | ] [-w
160
- <value>] [-p <value>] [-n <value>] [-s <value>]
174
+ $ commercelayer provisioning:fetch RESOURCE PATH [ID] [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]]
175
+ [--curl ] [--node ] [-H ] [-Y ] [-e <value> | ] [-w <value>] [-p <value>] [-n <value>] [-s <value>]
161
176
 
162
177
  ARGUMENTS
163
- PATH path (or URL) of the resource(s) to fetch
164
- ID resource id
178
+ RESOURCE the resource type
179
+ PATH path (or URL) of the resource(s) to fetch
180
+ ID resource id
165
181
 
166
182
  FLAGS
167
183
  -H, --headers show response headers
@@ -177,6 +193,13 @@ FLAGS
177
193
  -u, --unformatted print unformatted JSON output
178
194
  -w, --where=<value>... comma separated list of query filters
179
195
 
196
+ DOCUMENTATION FLAGS
197
+ -l, --lang=<option> show the CLI command in the specified language syntax
198
+ <options: curl|node>
199
+ --curl show the equivalent cURL command of the CLI command
200
+ --doc show the CLI command in a specific language
201
+ --node show the equivalent Node SDK source code of the CLI command
202
+
180
203
  DESCRIPTION
181
204
  retrieve a resource or list a set of resources
182
205
 
@@ -204,8 +227,8 @@ Retrieve a resource or list a set of resources.
204
227
 
205
228
  ```sh-session
206
229
  USAGE
207
- $ commercelayer provisioning:get RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-w <value>] [-p
208
- <value>] [-n <value>] [-s <value>] [-e <value> | ]
230
+ $ commercelayer provisioning:get RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl
231
+ ] [--node ] [-H ] [-Y ] [-e <value> | ] [-w <value>] [-p <value>] [-n <value>] [-s <value>]
209
232
 
210
233
  ARGUMENTS
211
234
  RESOURCE the resource type
@@ -225,6 +248,13 @@ FLAGS
225
248
  -u, --unformatted print unformatted JSON output
226
249
  -w, --where=<value>... comma separated list of query filters
227
250
 
251
+ DOCUMENTATION FLAGS
252
+ -l, --lang=<option> show the CLI command in the specified language syntax
253
+ <options: curl|node>
254
+ --curl show the equivalent cURL command of the CLI command
255
+ --doc show the CLI command in a specific language
256
+ --node show the equivalent Node SDK source code of the CLI command
257
+
228
258
  DESCRIPTION
229
259
  retrieve a resource or list a set of resources
230
260
 
@@ -251,8 +281,8 @@ Fetch a collection of resources.
251
281
 
252
282
  ```sh-session
253
283
  USAGE
254
- $ commercelayer provisioning:list RESOURCE [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-w <value>] [-p <value>]
255
- [-n <value>] [-s <value>] [-e <value> | ]
284
+ $ commercelayer provisioning:list RESOURCE [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl ]
285
+ [--node ] [-H ] [-Y ] [-w <value>] [-p <value>] [-n <value>] [-s <value>] [-e <value> | ]
256
286
 
257
287
  ARGUMENTS
258
288
  RESOURCE the resource type
@@ -271,6 +301,13 @@ FLAGS
271
301
  -u, --unformatted print unformatted JSON output
272
302
  -w, --where=<value>... comma separated list of query filters
273
303
 
304
+ DOCUMENTATION FLAGS
305
+ -l, --lang=<option> show the CLI command in the specified language syntax
306
+ <options: curl|node>
307
+ --curl show the equivalent cURL command of the CLI command
308
+ --doc show the CLI command in a specific language
309
+ --node show the equivalent Node SDK source code of the CLI command
310
+
274
311
  DESCRIPTION
275
312
  fetch a collection of resources
276
313
 
@@ -322,7 +359,8 @@ Fetch a single resource.
322
359
 
323
360
  ```sh-session
324
361
  USAGE
325
- $ commercelayer provisioning:retrieve RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-e <value> | ]
362
+ $ commercelayer provisioning:retrieve RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl
363
+ ] [--node ] [-H ] [-Y ] [-e <value> | ]
326
364
 
327
365
  ARGUMENTS
328
366
  RESOURCE the resource type
@@ -338,6 +376,13 @@ FLAGS
338
376
  -j, --json convert output in standard JSON format
339
377
  -u, --unformatted print unformatted JSON output
340
378
 
379
+ DOCUMENTATION FLAGS
380
+ -l, --lang=<option> show the CLI command in the specified language syntax
381
+ <options: curl|node>
382
+ --curl show the equivalent cURL command of the CLI command
383
+ --doc show the CLI command in a specific language
384
+ --node show the equivalent Node SDK source code of the CLI command
385
+
341
386
  DESCRIPTION
342
387
  fetch a single resource
343
388
 
@@ -364,8 +409,8 @@ Update an existing resource.
364
409
 
365
410
  ```sh-session
366
411
  USAGE
367
- $ commercelayer provisioning:update RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-H -R] [-Y ] [-O <value>] [-D
368
- <value> | -a <value> | -r <value> | [-m <value> | -M <value>] | | ]
412
+ $ commercelayer provisioning:update RESOURCE [ID] [-i <value>] [-f <value>] [-u -j] [-l curl|node [--doc | -R]] [--curl
413
+ ] [--node ] [-H ] [-Y ] [-O <value>] [-D <value> | -a <value> | -r <value> | [-m <value> | -M <value>] | | ]
369
414
 
370
415
  ARGUMENTS
371
416
  RESOURCE the resource type
@@ -388,6 +433,13 @@ FLAGS
388
433
  -r, --relationship=<value>... define a relationship with another resource
389
434
  -u, --unformatted print unformatted JSON output
390
435
 
436
+ DOCUMENTATION FLAGS
437
+ -l, --lang=<option> show the CLI command in the specified language syntax
438
+ <options: curl|node>
439
+ --curl show the equivalent cURL command of the CLI command
440
+ --doc show the CLI command in a specific language
441
+ --node show the equivalent Node SDK source code of the CLI command
442
+
391
443
  DESCRIPTION
392
444
  update an existing resource
393
445
 
package/bin/run.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line unicorn/prefer-top-level-await
4
+ (async () => {
5
+ const oclif = await import('@oclif/core')
6
+ await oclif.execute({development: false, dir: __dirname})
7
+ })()
package/lib/base.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { Command, Flags, Args, ux as cliux } from '@oclif/core';
2
2
  import { type Resource } from './util/resources';
3
- import { type CommerceLayerProvisioningClient } from '@commercelayer/provisioning-sdk';
3
+ import { type CommerceLayerProvisioningClient, type QueryParams } from '@commercelayer/provisioning-sdk';
4
+ import { type RequestData } from './lang';
4
5
  import type { KeyValRel, KeyValObj, KeyValArray, KeyValString, KeyValSort, ResAttributes, KeyVal } from '@commercelayer/cli-core';
5
6
  import type { CommandError } from '@oclif/core/lib/interfaces';
6
7
  export declare abstract class BaseCommand extends Command {
7
8
  static baseFlags: {
8
- domain: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- accessToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ domain: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ accessToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
11
  };
11
12
  protected checkApplication(accessToken: string, kinds: string[]): boolean;
12
13
  checkResourceId(resource: string, resourceId?: string, required?: boolean): {
@@ -28,14 +29,21 @@ export declare abstract class BaseCommand extends Command {
28
29
  }
29
30
  export declare abstract class BaseFilterCommand extends BaseCommand {
30
31
  static flags: {
31
- include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
32
- fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
32
+ include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
33
+ fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
33
34
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
34
35
  unformatted: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
35
36
  raw: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
37
+ doc: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
38
+ lang: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
39
+ curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
40
+ node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
36
41
  headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
37
42
  'headers-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
38
43
  };
44
+ static args: {
45
+ [x: string]: import("@oclif/core/lib/interfaces").Arg<any, import("@oclif/core/lib/interfaces").CustomOptions>;
46
+ };
39
47
  init(): Promise<any>;
40
48
  catch(error: CommandError): Promise<any>;
41
49
  includeFlag(flag: string[] | undefined, relationships?: KeyValRel, force?: boolean): string[];
@@ -50,10 +58,12 @@ export declare abstract class BaseFilterCommand extends BaseCommand {
50
58
  extractFlag(flag: string[]): KeyValArray;
51
59
  extractObjectFields(fields: KeyValArray, obj: any): void;
52
60
  saveOutput(output: any, flags: any): void;
61
+ protected showLiveDocumentation(request: RequestData, params?: QueryParams, flags?: any): Promise<string>;
62
+ protected printCommand(lang: string, command: string): void;
53
63
  }
54
64
  export default abstract class extends BaseFilterCommand {
55
65
  static args: {
56
- resource: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
66
+ resource: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
57
67
  };
58
68
  }
59
69
  export { Flags, Args, cliux };
package/lib/base.js CHANGED
@@ -11,7 +11,7 @@ const output_1 = require("./output");
11
11
  const csv_1 = require("./csv");
12
12
  const fs_1 = require("fs");
13
13
  const provisioning_sdk_1 = tslib_1.__importStar(require("@commercelayer/provisioning-sdk"));
14
- // import { availableLanguages, buildCommand, getLanguageArg, languageInfo, promptLanguage, type RequestData } from './lang'
14
+ const lang_1 = require("./lang");
15
15
  const cli_core_1 = require("@commercelayer/cli-core");
16
16
  // import { aliasExists, checkAlias, type CommandParams, loadCommandData, type ResourceOperation, saveCommandData } from './commands'
17
17
  // import type { ResourceId, ResourceType } from '@commercelayer/provisioning-sdk/lib/cjs/resource'
@@ -19,6 +19,19 @@ const pkg = require('../package.json');
19
19
  // export const FLAG_SAVE_PARAMS = 'save-args'
20
20
  // export const FLAG_LOAD_PARAMS = 'load-args'
21
21
  class BaseCommand extends core_1.Command {
22
+ static baseFlags = {
23
+ domain: core_1.Flags.string({
24
+ char: 'd',
25
+ required: false,
26
+ hidden: true,
27
+ env: 'CL_CLI_DOMAIN',
28
+ }),
29
+ accessToken: core_1.Flags.string({
30
+ hidden: true,
31
+ required: true,
32
+ env: 'CL_CLI_ACCESS_TOKEN',
33
+ })
34
+ };
22
35
  checkApplication(accessToken, kinds) {
23
36
  const info = cli_core_1.clToken.decodeAccessToken(accessToken);
24
37
  if (info === null)
@@ -146,20 +159,86 @@ class BaseCommand extends core_1.Command {
146
159
  }
147
160
  }
148
161
  exports.BaseCommand = BaseCommand;
149
- BaseCommand.baseFlags = {
150
- domain: core_1.Flags.string({
151
- char: 'd',
152
- required: false,
153
- hidden: true,
154
- env: 'CL_CLI_DOMAIN',
155
- }),
156
- accessToken: core_1.Flags.string({
157
- hidden: true,
158
- required: true,
159
- env: 'CL_CLI_ACCESS_TOKEN',
160
- })
161
- };
162
162
  class BaseFilterCommand extends BaseCommand {
163
+ static flags = {
164
+ ...BaseCommand.flags,
165
+ include: core_1.Flags.string({
166
+ char: 'i',
167
+ multiple: true,
168
+ description: 'comma separated resources to include',
169
+ }),
170
+ fields: core_1.Flags.string({
171
+ char: 'f',
172
+ multiple: true,
173
+ description: 'comma separeted list of fields in the format [resourceType/]field1,field2...',
174
+ }),
175
+ json: core_1.Flags.boolean({
176
+ char: 'j',
177
+ description: 'convert output in standard JSON format',
178
+ }),
179
+ unformatted: core_1.Flags.boolean({
180
+ char: 'u',
181
+ description: 'print unformatted JSON output',
182
+ dependsOn: ['json'],
183
+ }),
184
+ raw: core_1.Flags.boolean({
185
+ char: 'R',
186
+ description: 'print out the raw API response',
187
+ hidden: false,
188
+ }),
189
+ doc: core_1.Flags.boolean({
190
+ description: 'show the CLI command in a specific language',
191
+ exclusive: ['raw'],
192
+ helpGroup: 'documentation',
193
+ }),
194
+ lang: core_1.Flags.string({
195
+ char: 'l',
196
+ description: 'show the CLI command in the specified language syntax',
197
+ exclusive: lang_1.availableLanguages,
198
+ options: lang_1.availableLanguages,
199
+ dependsOn: ['doc'],
200
+ helpGroup: 'documentation',
201
+ }),
202
+ curl: core_1.Flags.boolean({
203
+ description: `show the equivalent ${lang_1.languageInfo.curl.label} of the CLI command`,
204
+ exclusive: ['lang', ...lang_1.availableLanguages.filter(l => l !== 'curl')],
205
+ parse: async () => await Promise.resolve('curl'),
206
+ hidden: !lang_1.availableLanguages.includes('curl'),
207
+ dependsOn: ['doc'],
208
+ helpGroup: 'documentation',
209
+ }),
210
+ node: core_1.Flags.boolean({
211
+ description: `show the equivalent ${lang_1.languageInfo.node.label} of the CLI command`,
212
+ exclusive: ['lang', ...lang_1.availableLanguages.filter(l => l !== 'node')],
213
+ parse: async () => await Promise.resolve('node'),
214
+ hidden: !lang_1.availableLanguages.includes('node'),
215
+ dependsOn: ['doc'],
216
+ helpGroup: 'documentation',
217
+ }),
218
+ /*
219
+ [FLAG_SAVE_PARAMS]: Flags.string({
220
+ description: 'save command data to file for future use',
221
+ }),
222
+ [FLAG_LOAD_PARAMS]: Flags.string({
223
+ description: 'load previously saved command arguments',
224
+ }),
225
+ */
226
+ headers: core_1.Flags.boolean({
227
+ char: 'H',
228
+ description: 'show response headers',
229
+ dependsOn: ['raw'],
230
+ exclusive: ['headers-only'],
231
+ }),
232
+ 'headers-only': core_1.Flags.boolean({
233
+ char: 'Y',
234
+ description: 'show only response headers',
235
+ dependsOn: ['raw'],
236
+ exclusive: ['headers', 'fields', 'include'],
237
+ })
238
+ };
239
+ static args = {
240
+ ...BaseCommand.args
241
+ };
163
242
  // INIT (override)
164
243
  async init() {
165
244
  // Check for plugin updates only if in visible mode
@@ -411,86 +490,30 @@ class BaseFilterCommand extends BaseCommand {
411
490
  this.log();
412
491
  }
413
492
  }
493
+ async showLiveDocumentation(request, params, flags) {
494
+ const lang = (0, lang_1.getLanguageArg)(flags) || await (0, lang_1.promptLanguage)();
495
+ const cmd = (0, lang_1.buildCommand)(lang, request, params, flags);
496
+ this.printCommand(lang, cmd);
497
+ return cmd;
498
+ }
499
+ printCommand(lang, command) {
500
+ const header = lang_1.languageInfo[lang].label;
501
+ // const footer = header.replace(/./g, '-')
502
+ this.log();
503
+ this.log(`${cli_core_1.clColor.underline.cyan(header)}`);
504
+ // this.log(chalk.cyan(`------------------------------{ ${header} }------------------------------`))
505
+ this.log();
506
+ this.log(command);
507
+ // this.log()
508
+ // this.log(chalk.cyan(`---------------------------------${footer}---------------------------------`))
509
+ this.log();
510
+ }
414
511
  }
415
512
  exports.BaseFilterCommand = BaseFilterCommand;
416
- BaseFilterCommand.flags = {
417
- include: core_1.Flags.string({
418
- char: 'i',
419
- multiple: true,
420
- description: 'comma separated resources to include',
421
- }),
422
- fields: core_1.Flags.string({
423
- char: 'f',
424
- multiple: true,
425
- description: 'comma separeted list of fields in the format [resourceType/]field1,field2...',
426
- }),
427
- json: core_1.Flags.boolean({
428
- char: 'j',
429
- description: 'convert output in standard JSON format',
430
- }),
431
- unformatted: core_1.Flags.boolean({
432
- char: 'u',
433
- description: 'print unformatted JSON output',
434
- dependsOn: ['json'],
435
- }),
436
- raw: core_1.Flags.boolean({
437
- char: 'R',
438
- description: 'print out the raw API response',
439
- hidden: false,
440
- }),
441
- /*
442
- doc: Flags.boolean({
443
- description: 'show the CLI command in a specific language',
444
- exclusive: ['raw'],
445
- helpGroup: 'documentation',
446
- }),
447
- lang: Flags.string({
448
- char: 'l',
449
- description: 'show the CLI command in the specified language syntax',
450
- exclusive: availableLanguages,
451
- options: availableLanguages,
452
- dependsOn: ['doc'],
453
- helpGroup: 'documentation',
454
- }),
455
- curl: Flags.boolean({
456
- description: `show the equivalent ${languageInfo.curl.label} of the CLI command`,
457
- exclusive: ['lang', ...availableLanguages.filter(l => l !== 'curl')],
458
- parse: async (): Promise<string> => await Promise.resolve('curl'),
459
- hidden: !availableLanguages.includes('curl'),
460
- dependsOn: ['doc'],
461
- helpGroup: 'documentation',
462
- }),
463
- node: Flags.boolean({
464
- description: `show the equivalent ${languageInfo.node.label} of the CLI command`,
465
- exclusive: ['lang', ...availableLanguages.filter(l => l !== 'node')],
466
- parse: async (): Promise<string> => await Promise.resolve('node'),
467
- hidden: !availableLanguages.includes('node'),
468
- dependsOn: ['doc'],
469
- helpGroup: 'documentation',
470
- }),
471
- [FLAG_SAVE_PARAMS]: Flags.string({
472
- description: 'save command data to file for future use',
473
- }),
474
- [FLAG_LOAD_PARAMS]: Flags.string({
475
- description: 'load previously saved command arguments',
476
- }),
477
- */
478
- headers: core_1.Flags.boolean({
479
- char: 'H',
480
- description: 'show response headers',
481
- dependsOn: ['raw'],
482
- exclusive: ['headers-only'],
483
- }),
484
- 'headers-only': core_1.Flags.boolean({
485
- char: 'Y',
486
- description: 'show only response headers',
487
- dependsOn: ['raw'],
488
- exclusive: ['headers', 'fields', 'include'],
489
- }),
490
- };
491
513
  class default_1 extends BaseFilterCommand {
514
+ static args = {
515
+ ...BaseFilterCommand.args,
516
+ resource: core_1.Args.string({ name: 'resource', description: 'the resource type', required: true }),
517
+ };
492
518
  }
493
- default_1.args = {
494
- resource: core_1.Args.string({ name: 'resource', description: 'the resource type', required: true }),
495
- };
496
519
  exports.default = default_1;
@@ -4,18 +4,25 @@ export default class ProvisioningCreate extends Command {
4
4
  static aliases: string[];
5
5
  static examples: string[];
6
6
  static flags: {
7
- attribute: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- object: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- relationship: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
- metadata: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
- data: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
- include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
- fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ attribute: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ object: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ relationship: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ metadata: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ data: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
15
  unformatted: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
16
  raw: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
+ doc: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
+ lang: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
19
+ curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
20
+ node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
17
21
  headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
22
  'headers-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
19
23
  };
24
+ static args: {
25
+ resource: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
26
+ };
20
27
  run(): Promise<any>;
21
28
  }
@@ -3,10 +3,50 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importStar(require("../../base"));
5
5
  const cli_core_1 = require("@commercelayer/cli-core");
6
- // import { addRequestReader, isRequestInterrupted } from '../../lang'
6
+ const lang_1 = require("../../lang");
7
7
  // import { mergeCommandParams } from '../../commands'
8
8
  const OPERATION = 'create';
9
9
  class ProvisioningCreate extends base_1.default {
10
+ static description = 'create a new resource';
11
+ static aliases = ['prov:create', 'pc', 'pcreate'];
12
+ static examples = [
13
+ '$ commercelayer provisioning:create organizations -a name=MyOrg',
14
+ '$ clayer prov:create subscriptions -r plan=plans/<planId>',
15
+ '$ cl prov:create organization -a name=MyOrg -m meta_key="meta value"',
16
+ '$ cl pc roles -D /path/to/data/file/data.json',
17
+ ];
18
+ static flags = {
19
+ ...base_1.default.flags,
20
+ attribute: base_1.Flags.string({
21
+ char: 'a',
22
+ description: 'define a resource attribute',
23
+ multiple: true,
24
+ }),
25
+ object: base_1.Flags.string({
26
+ char: 'O',
27
+ description: 'define a resource object attribute',
28
+ multiple: true,
29
+ }),
30
+ relationship: base_1.Flags.string({
31
+ char: 'r',
32
+ description: 'define a relationship with another resource',
33
+ multiple: true,
34
+ }),
35
+ metadata: base_1.Flags.string({
36
+ char: 'm',
37
+ description: 'define a metadata attribute or a set of metadata attributes',
38
+ multiple: true,
39
+ }),
40
+ data: base_1.Flags.string({
41
+ char: 'D',
42
+ description: 'the data file to use as request body',
43
+ multiple: false,
44
+ exclusive: ['attribute', 'relationship', 'metadata', 'doc' /* , FLAG_LOAD_PARAMS, FLAG_SAVE_PARAMS */],
45
+ })
46
+ };
47
+ static args = {
48
+ ...base_1.default.args
49
+ };
10
50
  async run() {
11
51
  const { args, flags } = await this.parse(ProvisioningCreate);
12
52
  const resource = this.checkResource(args.resource, { singular: true });
@@ -65,7 +105,7 @@ class ProvisioningCreate extends base_1.default {
65
105
  // Fields flags
66
106
  const fields = this.fieldsFlag(flags.fields, resource.api);
67
107
  const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
68
- // const reqReader = flags.doc ? addRequestReader(cl) : undefined
108
+ const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
69
109
  const params = {};
70
110
  try {
71
111
  const resSdk = cl[resource.api];
@@ -89,49 +129,13 @@ class ProvisioningCreate extends base_1.default {
89
129
  return out;
90
130
  }
91
131
  catch (error) {
92
- /*
93
- if (isRequestInterrupted(error) && reqReader) {
94
- await this.showLiveDocumentation(reqReader.request, params, flags)
95
- cl.removeInterceptor('request', reqReader.id)
96
- } else */ this.printError(error);
132
+ if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
133
+ await this.showLiveDocumentation(reqReader.request, params, flags);
134
+ cl.removeInterceptor('request', reqReader.id);
135
+ }
136
+ else
137
+ this.printError(error);
97
138
  }
98
139
  }
99
140
  }
100
- ProvisioningCreate.description = 'create a new resource';
101
- ProvisioningCreate.aliases = ['prov:create', 'pc', 'pcreate'];
102
- ProvisioningCreate.examples = [
103
- '$ commercelayer provisioning:create organizations -a name=MyOrg',
104
- '$ clayer prov:create subscriptions -r plan=plans/<planId>',
105
- '$ cl prov:create organization -a name=MyOrg -m meta_key="meta value"',
106
- '$ cl pc roles -D /path/to/data/file/data.json',
107
- ];
108
- ProvisioningCreate.flags = {
109
- ...base_1.default.flags,
110
- attribute: base_1.Flags.string({
111
- char: 'a',
112
- description: 'define a resource attribute',
113
- multiple: true,
114
- }),
115
- object: base_1.Flags.string({
116
- char: 'O',
117
- description: 'define a resource object attribute',
118
- multiple: true,
119
- }),
120
- relationship: base_1.Flags.string({
121
- char: 'r',
122
- description: 'define a relationship with another resource',
123
- multiple: true,
124
- }),
125
- metadata: base_1.Flags.string({
126
- char: 'm',
127
- description: 'define a metadata attribute or a set of metadata attributes',
128
- multiple: true,
129
- }),
130
- data: base_1.Flags.string({
131
- char: 'D',
132
- description: 'the data file to use as request body',
133
- multiple: false,
134
- exclusive: ['attribute', 'relationship', 'metadata', 'doc' /* , FLAG_LOAD_PARAMS, FLAG_SAVE_PARAMS */],
135
- })
136
- };
137
141
  exports.default = ProvisioningCreate;