@commercelayer/cli-plugin-exports
Advanced tools
Comparing version 3.3.3 to 3.4.0
@@ -36,2 +36,3 @@ import type { ApiMode, KeyValRel, KeyValString } from '@commercelayer/cli-core'; | ||
protected whereFlag(flag: string[] | undefined): KeyValString; | ||
protected fieldsFlag(flag: string[] | undefined): string[]; | ||
protected getFileFormat(flags: any): ExportFormat; | ||
@@ -38,0 +39,0 @@ protected handleExportError(error: any, resDesc: string): void; |
@@ -242,2 +242,16 @@ "use strict"; | ||
} | ||
fieldsFlag(flag) { | ||
const values = []; | ||
if (flag) { | ||
const flagValues = flag.map(f => f.split(',').map(t => t.trim())); | ||
flagValues.forEach(a => { | ||
a.forEach(v => { | ||
if (values.includes(v)) | ||
this.warn(`Field ${cli_core_1.clColor.msg.warning(v)} already defined`); | ||
values.push(v); | ||
}); | ||
}); | ||
} | ||
return values; | ||
} | ||
getFileFormat(flags) { | ||
@@ -244,0 +258,0 @@ return flags.csv ? 'csv' : flags.format; |
@@ -13,2 +13,3 @@ import { ExportCommand } from '../../base'; | ||
where: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>; | ||
fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>; | ||
'dry-data': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>; | ||
@@ -15,0 +16,0 @@ format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>; |
@@ -94,2 +94,4 @@ "use strict"; | ||
const wheres = this.whereFlag(flags.where); | ||
// Fields flags | ||
const fields = this.fieldsFlag(flags.fields); | ||
const exportJob = { | ||
@@ -114,2 +116,4 @@ groupId: '', | ||
exportJob.filter = {}; | ||
if (fields && (fields.length > 0)) | ||
exportJob.fields = fields; | ||
try { | ||
@@ -224,3 +228,4 @@ this.commercelayerInit(flags); | ||
includes: expJob.include, | ||
filters: { ...expJob.filter } | ||
filters: { ...expJob.filter }, | ||
fields: expJob.fields | ||
}; | ||
@@ -227,0 +232,0 @@ if (!expCreate.filters) |
@@ -10,2 +10,3 @@ import { ExportCommand } from '../../base'; | ||
where: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>; | ||
fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>; | ||
'dry-data': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>; | ||
@@ -12,0 +13,0 @@ format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>; |
@@ -34,2 +34,7 @@ "use strict"; | ||
}), | ||
fields: base_1.Flags.string({ | ||
char: 'f', | ||
description: 'comma separated list of fields to include in the export', | ||
multiple: true | ||
}), | ||
'dry-data': base_1.Flags.boolean({ | ||
@@ -103,2 +108,4 @@ char: 'D', | ||
const wheres = this.whereFlag(flags.where); | ||
// Fields flags | ||
const fields = this.fieldsFlag(flags.fields); | ||
const expCreate = { | ||
@@ -113,2 +120,4 @@ resource_type: resType, | ||
expCreate.filters = wheres; | ||
if (fields && (fields.length > 0)) | ||
expCreate.fields = fields; | ||
try { | ||
@@ -115,0 +124,0 @@ this.commercelayerInit(flags); |
@@ -107,2 +107,10 @@ { | ||
}, | ||
"fields": { | ||
"char": "f", | ||
"description": "comma separated list of fields to include in the export", | ||
"name": "fields", | ||
"hasDynamicHelp": false, | ||
"multiple": true, | ||
"type": "option" | ||
}, | ||
"dry-data": { | ||
@@ -331,2 +339,10 @@ "char": "D", | ||
}, | ||
"fields": { | ||
"char": "f", | ||
"description": "comma separated list of fields to include in the export", | ||
"name": "fields", | ||
"hasDynamicHelp": false, | ||
"multiple": true, | ||
"type": "option" | ||
}, | ||
"dry-data": { | ||
@@ -905,3 +921,3 @@ "char": "D", | ||
}, | ||
"version": "3.3.3" | ||
"version": "3.4.0" | ||
} |
{ | ||
"name": "@commercelayer/cli-plugin-exports", | ||
"description": "Commerce Layer CLI Exports plugin", | ||
"version": "3.3.3", | ||
"version": "3.4.0", | ||
"author": "Pierluigi Viti <pierluigi@commercelayer.io>", | ||
@@ -56,5 +56,5 @@ "homepage": "https://github.com/commercelayer/commercelayer-cli-plugin-exports", | ||
"devDependencies": { | ||
"@commercelayer/cli-dev": "^3.0.6", | ||
"@commercelayer/cli-dev": "^3.0.7", | ||
"@commercelayer/eslint-config-ts": "^1.4.5", | ||
"@oclif/plugin-help": "^6.2.18", | ||
"@oclif/plugin-help": "^6.2.22", | ||
"@oclif/test": "^3.2.15", | ||
@@ -65,3 +65,3 @@ "@semantic-release/changelog": "^6.0.3", | ||
"@types/mocha": "^10.0.10", | ||
"@types/node": "^22.10.1", | ||
"@types/node": "^22.10.7", | ||
"@types/node-notifier": "^8.0.5", | ||
@@ -72,11 +72,11 @@ "chai": "^4.5.0", | ||
"nyc": "^15.1.0", | ||
"oclif": "^4.16.0", | ||
"semantic-release": "^24.2.0", | ||
"oclif": "^4.17.16", | ||
"semantic-release": "^24.2.1", | ||
"tsx": "^4.19.2", | ||
"typescript": "^5.7.2" | ||
"typescript": "^5.7.3" | ||
}, | ||
"dependencies": { | ||
"@commercelayer/cli-core": "^5.4.2", | ||
"@commercelayer/cli-ux": "^1.0.6", | ||
"@commercelayer/sdk": "^6.25.2", | ||
"@commercelayer/cli-core": "^5.6.2", | ||
"@commercelayer/cli-ux": "^1.0.7", | ||
"@commercelayer/sdk": "^6.29.0", | ||
"@oclif/core": "^3.27.0", | ||
@@ -83,0 +83,0 @@ "axios": "^1.7.9", |
@@ -81,3 +81,3 @@ # @commercelayer/cli-plugin-exports | ||
$ commercelayer exports:all -t addresses|authorizations|bundles|captures|... [-i <value>...] [-w <value>...] | ||
[-D] [-F csv|json | -C | ] [-x <value> | -X <value>] [-b] [-P | ] [-O] [-q] [-k] | ||
[-f <value>...] [-D] [-F csv|json | -C | ] [-x <value> | -X <value>] [-b] [-P | ] [-O] [-q] [-k] | ||
@@ -94,2 +94,3 @@ FLAGS | ||
-b, --blind execute in blind mode without showing the progress monitor | ||
-f, --fields=<value>... comma separated list of fields to include in the export | ||
-i, --include=<value>... comma separated resources to include | ||
@@ -126,3 +127,3 @@ -k, --keep keep original export files in temp dir | ||
$ commercelayer exports:create -t addresses|authorizations|bundles|captures|... [-i <value>...] [-w <value>...] | ||
[-D] [-F csv|json | -C | ] [-x <value> | -X <value>] [-b] [-P | ] [-O] | ||
[-f <value>...] [-D] [-F csv|json | -C | ] [-x <value> | -X <value>] [-b] [-P | ] [-O] | ||
@@ -139,2 +140,3 @@ FLAGS | ||
-b, --blind execute in blind mode without showing the progress monitor | ||
-f, --fields=<value>... comma separated list of fields to include in the export | ||
-i, --include=<value>... comma separated resources to include | ||
@@ -141,0 +143,0 @@ -t, --type=addresses|authorizations|bundles|captures|... (required) the type of resource being exported |
102151
2303
278
Updated@commercelayer/cli-ux@^1.0.7
Updated@commercelayer/sdk@^6.29.0