@kitalive/sfdx-plugin 0.1.2 → 0.1.6

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/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @kitalive/sfdx-plugin
18
18
  $ sfdx COMMAND
19
19
  running command...
20
20
  $ sfdx (-v|--version|version)
21
- @kitalive/sfdx-plugin/0.1.2 darwin-x64 node-v14.15.0
21
+ @kitalive/sfdx-plugin/0.1.6 darwin-x64 node-v14.15.0
22
22
  $ sfdx --help [COMMAND]
23
23
  USAGE
24
24
  $ sfdx COMMAND
@@ -29,12 +29,13 @@ USAGE
29
29
  ## Commands
30
30
 
31
31
  <!-- commands -->
32
- * [`sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--setnull] [--save] [--saveonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitdatabulkupsert--o-string--i-string--f-filepath--e-string--d-string--m-filepath--c-filepath---setnull---save---saveonly---concurrencymode-string---assignmentruleid-string--s-integer--w-integer--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
33
- * [`sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitdatacsvconvert--f-filepath--o-filepath--e-string--d-string--m-filepath--c-filepath---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
32
+ * [`sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitdatabulkupsert--o-string--i-string--f-filepath--r-filepath--e-string--d-string--q-string---skiplines-integer---trim--m-filepath--c-filepath---setnull---convertonly---concurrencymode-string---assignmentruleid-string--s-integer--w-integer--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
33
+ * [`sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitdatacsvconvert--f-filepath--o-filepath--e-string--d-string--q-string---skiplines-integer---trim--m-filepath--c-filepath---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
34
34
  * [`sfdx kit:layout:assignments:deploy -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitlayoutassignmentsdeploy--f-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
35
35
  * [`sfdx kit:layout:assignments:retrieve -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitlayoutassignmentsretrieve--f-string--p-string--o-string---merge--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
36
+ * [`sfdx kit:script:execute [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-kitscriptexecute--f-filepath--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
36
37
 
37
- ## `sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--setnull] [--save] [--saveonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
38
+ ## `sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
38
39
 
39
40
  bulk upsert records from a CSV file
40
41
 
@@ -44,10 +45,10 @@ Upsert records using Bulk API and returns a job ID and a batch ID. Use these IDs
44
45
  For information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.
45
46
 
46
47
  USAGE
47
- $ sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-e <string>] [-d <string>] [-m <filepath>] [-c
48
- <filepath>] [--setnull] [--save] [--saveonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s
49
- <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
50
- trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
48
+ $ sfdx kit:data:bulk:upsert -o <string> -i <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q
49
+ <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly]
50
+ [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion
51
+ <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
51
52
 
52
53
  OPTIONS
53
54
  -c, --converter=converter the path of the script to convert
@@ -59,8 +60,8 @@ OPTIONS
59
60
  -e, --encoding=encoding [default: utf8] the input CSV file
60
61
  encoding
61
62
 
62
- -f, --csvfile=csvfile (required) the path of the CSV file
63
- that defines the records to upsert
63
+ -f, --csvfile=csvfile (required) the CSV file path that
64
+ defines the records to upsert
64
65
 
65
66
  -i, --externalid=externalid (required) [default: Id] the column
66
67
  name of the external ID
@@ -71,6 +72,12 @@ OPTIONS
71
72
  -o, --object=object (required) the sObject name to
72
73
  upsert
73
74
 
75
+ -q, --quote=quote [default: "] the input CSV file
76
+ quote character
77
+
78
+ -r, --resultfile=resultfile the CSV file path for writing the
79
+ upsert results
80
+
74
81
  -s, --batchsize=batchsize [default: 10000] the batch size of
75
82
  the job
76
83
 
@@ -91,20 +98,22 @@ OPTIONS
91
98
  mode (Parallel or Serial) for the
92
99
  job
93
100
 
101
+ --convertonly output converted.csv file and skip
102
+ upsert for debugging
103
+
94
104
  --json format output as json
95
105
 
96
106
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
97
107
  this command invocation
98
108
 
99
- --save output converted.csv file
100
-
101
- --saveonly output converted.csv file and skip
102
- upsert for debugging
103
-
104
109
  --setnull set blank values as null values
105
110
  during upsert operations (default:
106
111
  empty field values are ignored)
107
112
 
113
+ --skiplines=skiplines the number of lines to skip
114
+
115
+ --trim trim all white space from columns
116
+
108
117
  DESCRIPTION
109
118
  Upsert records using Bulk API and returns a job ID and a batch ID. Use these IDs to check job status with
110
119
  data:bulk:status.
@@ -118,9 +127,9 @@ EXAMPLES
118
127
  10
119
128
  ```
120
129
 
121
- _See code: [src/commands/kit/data/bulk/upsert.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.2/src/commands/kit/data/bulk/upsert.ts)_
130
+ _See code: [src/commands/kit/data/bulk/upsert.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.6/src/commands/kit/data/bulk/upsert.ts)_
122
131
 
123
- ## `sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
132
+ ## `sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
124
133
 
125
134
  convert CSV data using column mapping file or Node.js script
126
135
 
@@ -128,8 +137,9 @@ convert CSV data using column mapping file or Node.js script
128
137
  convert CSV data using column mapping file or Node.js script
129
138
 
130
139
  USAGE
131
- $ sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-m <filepath>] [-c
132
- <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
140
+ $ sfdx kit:data:csv:convert [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines
141
+ <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel
142
+ trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
133
143
 
134
144
  OPTIONS
135
145
  -c, --converter=converter the path of the script to convert
@@ -150,17 +160,24 @@ OPTIONS
150
160
  -o, --outputfile=outputfile the path of the output CSV file
151
161
  (default: standard output)
152
162
 
163
+ -q, --quote=quote [default: "] the input CSV file
164
+ quote character
165
+
153
166
  --json format output as json
154
167
 
155
168
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
156
169
  this command invocation
157
170
 
171
+ --skiplines=skiplines the number of lines to skip
172
+
173
+ --trim trim all white space from columns
174
+
158
175
  EXAMPLES
159
176
  $ sfdx kit:data:csv:convert -f ./path/to/input.csv -m ./path/to/mapping.json
160
177
  $ sfdx kit:data:csv:convert -f ./path/to/input.csv -o ./path/to/output.csv -c ./path/to/convert.js -e cp932 -d :
161
178
  ```
162
179
 
163
- _See code: [src/commands/kit/data/csv/convert.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.2/src/commands/kit/data/csv/convert.ts)_
180
+ _See code: [src/commands/kit/data/csv/convert.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.6/src/commands/kit/data/csv/convert.ts)_
164
181
 
165
182
  ## `sfdx kit:layout:assignments:deploy -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
166
183
 
@@ -195,7 +212,7 @@ EXAMPLES
195
212
  $ sfdx kit:layout:assignments:deploy -u me@my.org -f config/layout-assignments.sandbox.json
196
213
  ```
197
214
 
198
- _See code: [src/commands/kit/layout/assignments/deploy.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.2/src/commands/kit/layout/assignments/deploy.ts)_
215
+ _See code: [src/commands/kit/layout/assignments/deploy.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.6/src/commands/kit/layout/assignments/deploy.ts)_
199
216
 
200
217
  ## `sfdx kit:layout:assignments:retrieve -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
201
218
 
@@ -241,5 +258,54 @@ EXAMPLES
241
258
  $ sfdx kit:layout:assignments:retrieve -u me@my.org -f config/layout-assignments.sandbox.json
242
259
  ```
243
260
 
244
- _See code: [src/commands/kit/layout/assignments/retrieve.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.2/src/commands/kit/layout/assignments/retrieve.ts)_
261
+ _See code: [src/commands/kit/layout/assignments/retrieve.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.6/src/commands/kit/layout/assignments/retrieve.ts)_
262
+
263
+ ## `sfdx kit:script:execute [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
264
+
265
+ execute Node.js scripts in SfdxCommand context
266
+
267
+ ```
268
+ execute Node.js scripts in SfdxCommand context
269
+ Available variables in Node.js scripts
270
+ argv: Parsed command line arguments after the file option
271
+ conn: jsforce Connection
272
+ context: SfdxCommand
273
+
274
+ USAGE
275
+ $ sfdx kit:script:execute [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
276
+ trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
277
+
278
+ OPTIONS
279
+ -f, --file=file the path of the Node.js script file
280
+ to execute
281
+
282
+ -u, --targetusername=targetusername username or alias for the target
283
+ org; overrides default target org
284
+
285
+ --apiversion=apiversion override the api version used for
286
+ api requests made by this command
287
+
288
+ --json format output as json
289
+
290
+ --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
291
+ this command invocation
292
+
293
+ DESCRIPTION
294
+ Available variables in Node.js scripts
295
+ argv: Parsed command line arguments after the file option
296
+ conn: jsforce Connection
297
+ context: SfdxCommand
298
+
299
+ ALIASES
300
+ $ sfdx kit:script
301
+
302
+ EXAMPLES
303
+ $ sfdx kit:script -f ./path/to/script.js
304
+ $ sfdx kit:script:execute
305
+ > await conn.query('SELECT Id, Name FROM Account LIMIT 1')
306
+ Top level await is not enabled by default in REPL before Node.js v16
307
+ $ NODE_OPTIONS=--experimental-repl-await sfdx kit:script:execute
308
+ ```
309
+
310
+ _See code: [src/commands/kit/script/execute.ts](https://github.com/Kitalive-Inc/sfdx-plugin/blob/v0.1.6/src/commands/kit/script/execute.ts)_
245
311
  <!-- commandsstop -->
@@ -11,22 +11,28 @@ export default class UpsertCommand extends SfdxCommand {
11
11
  object: flags.Discriminated<flags.String>;
12
12
  externalid: flags.Discriminated<flags.String>;
13
13
  csvfile: flags.Discriminated<flags.String>;
14
+ resultfile: flags.Discriminated<flags.String>;
14
15
  encoding: flags.Discriminated<flags.String>;
15
16
  delimiter: flags.Discriminated<flags.String>;
17
+ quote: flags.Discriminated<flags.String>;
18
+ skiplines: flags.Discriminated<flags.Number>;
19
+ trim: flags.Discriminated<flags.Boolean<boolean>>;
16
20
  mapping: flags.Discriminated<flags.String>;
17
21
  converter: flags.Discriminated<flags.String>;
18
22
  setnull: flags.Discriminated<flags.Boolean<boolean>>;
19
- save: flags.Discriminated<flags.Boolean<boolean>>;
20
- saveonly: flags.Discriminated<flags.Boolean<boolean>>;
23
+ convertonly: flags.Discriminated<flags.Boolean<boolean>>;
21
24
  concurrencymode: flags.Discriminated<flags.String>;
22
25
  assignmentruleid: flags.Discriminated<flags.String>;
23
26
  batchsize: flags.Discriminated<flags.Number>;
24
27
  wait: flags.Discriminated<flags.Number>;
25
28
  };
26
- run(): Promise<JsonMap[]>;
29
+ run(): Promise<JsonMap>;
27
30
  parseCsv(input: Readable, options?: {
28
31
  encoding?: string;
29
32
  delimiter?: string;
33
+ quote?: string;
34
+ skiplines?: number;
35
+ trim?: boolean;
30
36
  setnull?: boolean;
31
37
  mapping?: JsonMap;
32
38
  convert?: (row: JsonMap) => JsonMap | null | undefined;
@@ -35,6 +41,7 @@ export default class UpsertCommand extends SfdxCommand {
35
41
  };
36
42
  }): Promise<JsonMap[]>;
37
43
  private executeBatches;
44
+ private executeBatch;
38
45
  private saveCsv;
39
46
  private loadScript;
40
47
  private getFieldTypes;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@salesforce/command");
4
- const batcher_js_1 = require("@salesforce/plugin-data/lib/batcher.js");
5
4
  const dayjs = require("dayjs");
6
5
  const csv = require("fast-csv");
7
6
  const fs = require("fs-extra");
@@ -9,8 +8,6 @@ const path = require("path");
9
8
  const utils_1 = require("../../../../utils");
10
9
  const convert_1 = require("../csv/convert");
11
10
  const convert_2 = require("../csv/convert");
12
- // monkey patch
13
- batcher_js_1.Batcher.prototype['splitIntoBatches'] = arg => arg;
14
11
  function normalizeDateString(str, format) {
15
12
  if (!str)
16
13
  return str;
@@ -24,7 +21,7 @@ const converters = {
24
21
  const csvFlags = convert_1.default['flagsConfig'];
25
22
  class UpsertCommand extends command_1.SfdxCommand {
26
23
  async run() {
27
- const { csvfile, mapping, converter, encoding, delimiter, setnull } = this.flags;
24
+ const { csvfile, mapping, converter, encoding, delimiter, quote, skiplines, trim, setnull } = this.flags;
28
25
  const mappingJson = (mapping) ? (await fs.readJson(mapping)) : undefined;
29
26
  const script = converter ? this.loadScript(converter) : {};
30
27
  const fieldTypes = await this.getFieldTypes(this.flags.object);
@@ -34,6 +31,9 @@ class UpsertCommand extends command_1.SfdxCommand {
34
31
  let rows = await this.parseCsv(fs.createReadStream(csvfile), {
35
32
  encoding,
36
33
  delimiter,
34
+ quote,
35
+ skiplines,
36
+ trim: !!trim,
37
37
  setnull,
38
38
  mapping: mappingJson,
39
39
  convert: script.convert,
@@ -45,31 +45,70 @@ class UpsertCommand extends command_1.SfdxCommand {
45
45
  rows = result;
46
46
  }
47
47
  this.ux.stopSpinner();
48
- if (this.flags.save || this.flags.saveonly) {
48
+ if (this.flags.convertonly) {
49
49
  const base = path.basename(csvfile, path.extname(csvfile));
50
50
  this.saveCsv(path.join(path.dirname(csvfile), base + '.converted.csv'), rows);
51
- if (this.flags.saveonly)
52
- return;
51
+ return;
53
52
  }
54
53
  this.ux.startSpinner('Bulk Upsert');
54
+ let job;
55
55
  try {
56
- const job = await this.createJob(this.flags.object, {
56
+ job = await this.createJob(this.flags.object, {
57
57
  extIdField: this.flags.externalid,
58
58
  concurrencyMode: this.flags.concurrencymode,
59
59
  assignmentRuleId: this.flags.assignmentruleid
60
60
  });
61
- const batches = utils_1.chunk(rows, this.flags.batchsize);
62
- const result = await this.executeBatches(job, batches, this.flags.object, this.flags.wait);
63
- return result;
61
+ const batchResults = await this.executeBatches(job, rows, this.flags.batchsize, this.flags.wait);
62
+ const batchErrors = [];
63
+ if (this.flags.wait) {
64
+ rows = rows.map((data, i) => {
65
+ var _a;
66
+ const { id, errors } = (_a = batchResults[i]) !== null && _a !== void 0 ? _a : {};
67
+ const message = errors === null || errors === void 0 ? void 0 : errors.join(', ');
68
+ if (message) {
69
+ batchErrors.push({ line: i + 2, message, data });
70
+ }
71
+ return Object.assign(Object.assign({}, data), { Id: id, Errors: message });
72
+ });
73
+ if (batchErrors.length) {
74
+ this.ux.styledHeader('Upsert errors');
75
+ batchErrors.forEach(({ line, message }) => this.ux.log(`line ${line}: ${message}`));
76
+ }
77
+ }
78
+ else {
79
+ const batchInfos = await job.list();
80
+ let command = 'sfdx force:data:bulk:status';
81
+ if (this.flags.targetusername)
82
+ command += ' -u ' + this.flags.targetusername;
83
+ batchInfos.forEach((batch, i) => this.ux.log([
84
+ `Check batch #${i + 1}’s status with the command: `,
85
+ `${command} -i ${batch.jobId} -b ${batch.id}`
86
+ ].join('\n')));
87
+ }
88
+ if (this.flags.resultfile)
89
+ this.saveCsv(this.flags.resultfile, rows);
90
+ const jobInfo = await job.check();
91
+ delete jobInfo.$;
92
+ delete jobInfo.state;
93
+ if (this.flags.wait) {
94
+ this.ux.styledHeader('Job Status');
95
+ this.ux.styledObject(jobInfo, Object.keys(jobInfo));
96
+ }
97
+ if (batchErrors.length)
98
+ jobInfo.errors = batchErrors;
99
+ return jobInfo;
64
100
  }
65
101
  catch (e) {
66
102
  this.ux.stopSpinner('error');
67
103
  throw e;
68
104
  }
105
+ finally {
106
+ job === null || job === void 0 ? void 0 : job.close();
107
+ }
69
108
  }
70
109
  async parseCsv(input, options) {
71
- const { encoding, delimiter, mapping, convert, setnull, fieldTypes } = options !== null && options !== void 0 ? options : {};
72
- return await convert_2.parseCsv(input, { encoding, delimiter, mapping, convert: row => {
110
+ const { encoding, delimiter, quote, skiplines, trim, mapping, convert, setnull, fieldTypes } = options !== null && options !== void 0 ? options : {};
111
+ return await convert_2.parseCsv(input, { encoding, delimiter, quote, skiplines, trim, mapping, convert: row => {
73
112
  const result = convert ? convert(row) : row;
74
113
  if (!result)
75
114
  return;
@@ -91,9 +130,33 @@ class UpsertCommand extends command_1.SfdxCommand {
91
130
  return result;
92
131
  } });
93
132
  }
94
- executeBatches(job, batches, object, wait) {
95
- const batcher = new batcher_js_1.Batcher(this.org.getConnection(), this.ux);
96
- return batcher.createAndExecuteBatches(job, batches, object, wait);
133
+ executeBatches(job, rows, batchSize, wait) {
134
+ return Promise.all(utils_1.chunk(rows, batchSize).map(batchRows => this.executeBatch(job, batchRows, wait))).then(result => result.flat());
135
+ }
136
+ executeBatch(job, rows, wait) {
137
+ return new Promise((resolve, reject) => {
138
+ const batch = job.createBatch();
139
+ batch.on('error', e => {
140
+ if (e.message.startsWith('Polling time out'))
141
+ job.emit('error', e);
142
+ reject(e);
143
+ });
144
+ batch.on('queue', batchInfo => {
145
+ batch.check().then(result => {
146
+ if (result.state === 'Failed') {
147
+ reject(result.stateMessage);
148
+ }
149
+ else if (wait) {
150
+ batch.poll(5000, wait * 60000);
151
+ }
152
+ else {
153
+ resolve([]);
154
+ }
155
+ });
156
+ });
157
+ batch.on('response', resolve);
158
+ batch.execute(rows, error => error && reject(error));
159
+ });
97
160
  }
98
161
  saveCsv(file, rows) {
99
162
  csv.writeToPath(file, rows, { headers: true });
@@ -129,14 +192,17 @@ UpsertCommand.flagsConfig = {
129
192
  object: command_1.flags.string({ char: 'o', required: true, description: 'the sObject name to upsert' }),
130
193
  externalid: command_1.flags.string({ char: 'i', required: true, default: 'Id', description: 'the column name of the external ID' }),
131
194
  // csv settings
132
- csvfile: command_1.flags.filepath({ char: 'f', required: true, description: 'the path of the CSV file that defines the records to upsert' }),
195
+ csvfile: command_1.flags.filepath({ char: 'f', required: true, description: 'the CSV file path that defines the records to upsert' }),
196
+ resultfile: command_1.flags.filepath({ char: 'r', description: 'the CSV file path for writing the upsert results' }),
133
197
  encoding: csvFlags.encoding,
134
198
  delimiter: csvFlags.delimiter,
199
+ quote: csvFlags.quote,
200
+ skiplines: csvFlags.skiplines,
201
+ trim: csvFlags.trim,
135
202
  mapping: csvFlags.mapping,
136
203
  converter: csvFlags.converter,
137
204
  setnull: command_1.flags.boolean({ description: 'set blank values as null values during upsert operations (default: empty field values are ignored)' }),
138
- save: command_1.flags.boolean({ description: 'output converted.csv file' }),
139
- saveonly: command_1.flags.boolean({ description: 'output converted.csv file and skip upsert for debugging' }),
205
+ convertonly: command_1.flags.boolean({ description: 'output converted.csv file and skip upsert for debugging' }),
140
206
  // job settings
141
207
  concurrencymode: command_1.flags.string({ default: 'Parallel', description: 'the concurrency mode (Parallel or Serial) for the job' }),
142
208
  assignmentruleid: command_1.flags.string({ description: 'the ID of a specific assignment rule to run for a case or a lead.' }),
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/upsert.ts"],"names":[],"mappings":";;AAAA,iDAAyD;AACzD,uEAAiE;AAEjE,+BAA+B;AAC/B,gCAAgC;AAChC,+BAA+B;AAC/B,6BAA6B;AAE7B,6CAA0C;AAC1C,4CAA+C;AAC/C,4CAAsD;AAEtD,eAAe;AACf,oBAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC;AAEnD,SAAS,mBAAmB,CAAC,GAAG,EAAE,MAAO;IACvC,IAAI,CAAC,GAAG;QAAE,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E,CAAC;IAC3H,UAAU,EAAE,eAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IAC1G,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;IAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;IAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,SAAS,EAAE,QAAQ,CAAC,SAAS;IAC7B,OAAO,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,oGAAoG,EAAE,CAAC;IAC7I,WAAW,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,yDAAyD,EAAE,CAAC;IACtG,eAAe;IACf,eAAe,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;IAC5H,gBAAgB,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IACpH,SAAS,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACrH,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,yFAAyF,EAAE,CAAC;CACnJ,CAAC"}
@@ -12,6 +12,9 @@ export default class CsvConvertCommand extends SfdxCommand {
12
12
  outputfile: flags.Discriminated<flags.String>;
13
13
  encoding: flags.Discriminated<flags.String>;
14
14
  delimiter: flags.Discriminated<flags.String>;
15
+ quote: flags.Discriminated<flags.String>;
16
+ skiplines: flags.Discriminated<flags.Number>;
17
+ trim: flags.Discriminated<flags.Boolean<boolean>>;
15
18
  mapping: flags.Discriminated<flags.String>;
16
19
  converter: flags.Discriminated<flags.String>;
17
20
  };
@@ -22,6 +25,9 @@ export default class CsvConvertCommand extends SfdxCommand {
22
25
  export declare function parseCsv(input: Readable, options?: {
23
26
  encoding?: string;
24
27
  delimiter?: string;
28
+ quote?: string;
29
+ skiplines?: number;
30
+ trim?: boolean;
25
31
  mapping?: JsonMap;
26
32
  convert?: (row: JsonMap) => JsonMap | null | undefined;
27
33
  }): Promise<JsonMap[]>;
@@ -9,13 +9,16 @@ const path = require("path");
9
9
  const stream_1 = require("stream");
10
10
  class CsvConvertCommand extends command_1.SfdxCommand {
11
11
  async run() {
12
- const { inputfile, outputfile, mapping, converter, encoding, delimiter } = this.flags;
12
+ const { inputfile, outputfile, mapping, converter, encoding, delimiter, quote, skiplines, trim } = this.flags;
13
13
  const mappingJson = mapping ? (await fs.readJson(mapping)) : undefined;
14
14
  const convert = converter ? this.loadConverter(converter) : undefined;
15
15
  const input = inputfile ? fs.createReadStream(inputfile) : process.stdin;
16
16
  const rows = await parseCsv(input, {
17
17
  encoding,
18
18
  delimiter,
19
+ quote,
20
+ skiplines,
21
+ trim,
19
22
  mapping: mappingJson,
20
23
  convert
21
24
  });
@@ -45,11 +48,14 @@ CsvConvertCommand.flagsConfig = {
45
48
  outputfile: command_1.flags.filepath({ char: 'o', description: 'the path of the output CSV file (default: standard output)' }),
46
49
  encoding: command_1.flags.string({ char: 'e', default: 'utf8', description: 'the input CSV file encoding' }),
47
50
  delimiter: command_1.flags.string({ char: 'd', default: ',', description: 'the input CSV file delimiter' }),
51
+ quote: command_1.flags.string({ char: 'q', default: '"', description: 'the input CSV file quote character' }),
52
+ skiplines: command_1.flags.integer({ default: 0, description: 'the number of lines to skip' }),
53
+ trim: command_1.flags.boolean({ description: 'trim all white space from columns' }),
48
54
  mapping: command_1.flags.filepath({ char: 'm', description: 'the path of the JSON file that defines CSV column mappings' }),
49
55
  converter: command_1.flags.filepath({ char: 'c', description: 'the path of the script to convert CSV rows' })
50
56
  };
51
57
  function parseCsv(input, options) {
52
- const { encoding, delimiter, mapping, convert } = options !== null && options !== void 0 ? options : {};
58
+ const { encoding, delimiter, quote, skiplines, trim, mapping, convert } = options !== null && options !== void 0 ? options : {};
53
59
  return new Promise((resolve, reject) => {
54
60
  const mapper = mapping ? columnMapper(mapping) : undefined;
55
61
  let lines = 2;
@@ -57,7 +63,10 @@ function parseCsv(input, options) {
57
63
  const parser = csv.parse({
58
64
  headers: true,
59
65
  ignoreEmpty: true,
60
- delimiter: delimiter === '\\t' ? '\t' : (delimiter || ',')
66
+ delimiter: delimiter === '\\t' ? '\t' : (delimiter || ','),
67
+ quote: quote !== null && quote !== void 0 ? quote : '"',
68
+ skipLines: skiplines,
69
+ trim
61
70
  }).on('data', row => {
62
71
  try {
63
72
  if (mapper)
@@ -1 +1 @@
1
- {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/csv/convert.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAEzD,gCAAgC;AAChC,+BAA+B;AAC/B,2CAA0C;AAC1C,6BAA6B;AAC7B,mCAA4C;AAE5C,MAAqB,iBAAkB,SAAQ,qBAAW;IAoBjD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEtF,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACvE,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEtE,MAAM,KAAK,GAAG,SAA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;IAClC,OAAO,GAAG,CAAC,EAAE;QACX,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE;YACrB,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,gBAAgB,CAAC,CAAC;YACzE,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;SACxB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAXD,oCAWC"}
@@ -0,0 +1,13 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ export default class ScriptExecuteCommand extends SfdxCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static aliases: string[];
6
+ static strict: boolean;
7
+ protected static requiresUsername: boolean;
8
+ protected static requiresProject: boolean;
9
+ protected static flagsConfig: {
10
+ file: flags.Discriminated<flags.String>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@salesforce/command");
4
+ const fs = require("fs-extra");
5
+ const repl = require("repl");
6
+ const yargs_1 = require("yargs");
7
+ class ScriptExecuteCommand extends command_1.SfdxCommand {
8
+ async run() {
9
+ const { file } = this.flags;
10
+ module.paths.push('./node_modules');
11
+ if (file) {
12
+ const fileIndex = process.argv.indexOf(file);
13
+ const argv = yargs_1.default([]).parse(process.argv.slice(fileIndex + 1));
14
+ const script = fs.readFileSync(file).toString('utf8');
15
+ const asyncFunction = Object.getPrototypeOf(async () => { }).constructor;
16
+ return await new asyncFunction('require', 'argv', 'context', 'conn', script)(require, argv, this, this.org.getConnection());
17
+ }
18
+ else {
19
+ this.ux.log('Starting sfdx REPL mode');
20
+ this.ux.log('Available variables');
21
+ this.ux.log(' conn: jsforce Connection');
22
+ this.ux.log(' context: SfdxCommand');
23
+ this.ux.log('Type .exit or Press Ctrl+D to exit the REPL');
24
+ const replServer = repl.start('> ');
25
+ replServer.context.require = require;
26
+ replServer.context.context = this;
27
+ replServer.context.conn = this.org.getConnection();
28
+ return new Promise(resolve => replServer.on('exit', () => resolve()));
29
+ }
30
+ }
31
+ }
32
+ exports.default = ScriptExecuteCommand;
33
+ ScriptExecuteCommand.description = [
34
+ 'execute Node.js scripts in SfdxCommand context',
35
+ 'Available variables in Node.js scripts',
36
+ ' argv: Parsed command line arguments after the file option',
37
+ ' conn: jsforce Connection',
38
+ ' context: SfdxCommand'
39
+ ].join('\n');
40
+ ScriptExecuteCommand.examples = [
41
+ '$ sfdx kit:script -f ./path/to/script.js',
42
+ '$ sfdx kit:script:execute',
43
+ "> await conn.query('SELECT Id, Name FROM Account LIMIT 1')",
44
+ 'Top level await is not enabled by default in REPL before Node.js v16',
45
+ '$ NODE_OPTIONS=--experimental-repl-await sfdx kit:script:execute'
46
+ ];
47
+ ScriptExecuteCommand.aliases = ['kit:script'];
48
+ ScriptExecuteCommand.strict = false;
49
+ ScriptExecuteCommand.requiresUsername = true;
50
+ ScriptExecuteCommand.requiresProject = false;
51
+ ScriptExecuteCommand.flagsConfig = {
52
+ file: command_1.flags.filepath({ char: 'f', description: 'the path of the Node.js script file to execute' })
53
+ };
54
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../../src/commands/kit/script/execute.ts"],"names":[],"mappings":";;AAAA,iDAAyD;AACzD,+BAA+B;AAC/B,6BAA6B;AAC7B,iCAA0B;AAE1B,MAAqB,oBAAqB,SAAQ,qBAAW;IA0BpD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAEpC,IAAI,IAAI,E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AAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAClD,CAAC;SACH;IACH,CAAC;;AApDH,uCAqDC;AApDe,gCAAW,GAAG;IAC1B,gDAAgD;IAChD,wCAAwC;IACxC,6DAA6D;IAC7D,4BAA4B;IAC5B,wBAAwB;CACzB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEC,6BAAQ,GAAG;IACvB,0CAA0C;IAC1C,2BAA2B;IAC3B,4DAA4D;IAC5D,sEAAsE;IACtE,kEAAkE;CACnE,CAAC;AAEY,4BAAO,GAAG,CAAC,YAAY,CAAC,CAAC;AACzB,2BAAM,GAAG,KAAK,CAAC;AACZ,qCAAgB,GAAG,IAAI,CAAC;AACxB,oCAAe,GAAG,KAAK,CAAC;AAExB,gCAAW,GAAG;IAC7B,IAAI,EAAE,eAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;CACnG,CAAC"}
@@ -1 +1 @@
1
- {"version":"0.1.2","commands":{"kit:data:bulk:upsert":{"id":"kit:data:bulk:upsert","description":"bulk upsert records from a CSV file\nUpsert records using Bulk API and returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -i <string> -f <filepath> [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--setnull] [--save] [--saveonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:upsert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:upsert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -i MyExternalId__c -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to upsert","required":true},"externalid":{"name":"externalid","type":"option","char":"i","description":"the column name of the external ID","required":true,"default":"Id"},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the path of the CSV file that defines the records to upsert","required":true},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during upsert operations (default: empty field values are ignored)","allowNo":false},"save":{"name":"save","type":"boolean","description":"output converted.csv file","allowNo":false},"saveonly":{"name":"saveonly","type":"boolean","description":"output converted.csv file and skip upsert for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:csv:convert":{"id":"kit:data:csv:convert","description":"convert CSV data using column mapping file or Node.js script","usage":"<%= command.id %> [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:csv:convert -f ./path/to/input.csv -m ./path/to/mapping.json","$ sfdx kit:data:csv:convert -f ./path/to/input.csv -o ./path/to/output.csv -c ./path/to/convert.js -e cp932 -d :"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"inputfile":{"name":"inputfile","type":"option","char":"f","description":"the path of the input CSV file (default: standard input)"},"outputfile":{"name":"outputfile","type":"option","char":"o","description":"the path of the output CSV file (default: standard output)"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"}},"args":[]},"kit:layout:assignments:deploy":{"id":"kit:layout:assignments:deploy","description":"deploy page layout assignments from JSON file","usage":"<%= command.id %> -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:deploy","$ sfdx kit:layout:assignments:deploy -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:deploy -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"input file path","required":true,"default":"config/layout-assignments.json"}},"args":[]},"kit:layout:assignments:retrieve":{"id":"kit:layout:assignments:retrieve","description":"retrieve page layout assignments and save to JSON file","usage":"<%= command.id %> -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:retrieve","$ sfdx kit:layout:assignments:retrieve -p Admin,Standard,StandardAul -o Account,CustomObject__c -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:retrieve -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"output file path","required":true,"default":"config/layout-assignments.json"},"profile":{"name":"profile","type":"option","char":"p","description":"comma separated profile names to retrieve (default: all profiles)","required":false},"object":{"name":"object","type":"option","char":"o","description":"comma separated object names to retrieve (default: objects which have multiple layouts)","required":false},"merge":{"name":"merge","type":"boolean","description":"merge retrieved configurations with existing file","required":false,"allowNo":false}},"args":[]}}}
1
+ {"version":"0.1.6","commands":{"kit:script:execute":{"id":"kit:script:execute","description":"execute Node.js scripts in SfdxCommand context\nAvailable variables in Node.js scripts\n argv: Parsed command line arguments after the file option\n conn: jsforce Connection\n context: SfdxCommand","usage":"<%= command.id %> [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":["kit:script"],"examples":["$ sfdx kit:script -f ./path/to/script.js","$ sfdx kit:script:execute","> await conn.query('SELECT Id, Name FROM Account LIMIT 1')","Top level await is not enabled by default in REPL before Node.js v16","$ NODE_OPTIONS=--experimental-repl-await sfdx kit:script:execute"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"the path of the Node.js script file to execute"}},"args":[]},"kit:data:bulk:upsert":{"id":"kit:data:bulk:upsert","description":"bulk upsert records from a CSV file\nUpsert records using Bulk API and returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -i <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:upsert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:upsert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -i MyExternalId__c -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to upsert","required":true},"externalid":{"name":"externalid","type":"option","char":"i","description":"the column name of the external ID","required":true,"default":"Id"},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the CSV file path that defines the records to upsert","required":true},"resultfile":{"name":"resultfile","type":"option","char":"r","description":"the CSV file path for writing the upsert results"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during upsert operations (default: empty field values are ignored)","allowNo":false},"convertonly":{"name":"convertonly","type":"boolean","description":"output converted.csv file and skip upsert for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:csv:convert":{"id":"kit:data:csv:convert","description":"convert CSV data using column mapping file or Node.js script","usage":"<%= command.id %> [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:csv:convert -f ./path/to/input.csv -m ./path/to/mapping.json","$ sfdx kit:data:csv:convert -f ./path/to/input.csv -o ./path/to/output.csv -c ./path/to/convert.js -e cp932 -d :"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"inputfile":{"name":"inputfile","type":"option","char":"f","description":"the path of the input CSV file (default: standard input)"},"outputfile":{"name":"outputfile","type":"option","char":"o","description":"the path of the output CSV file (default: standard output)"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"}},"args":[]},"kit:layout:assignments:deploy":{"id":"kit:layout:assignments:deploy","description":"deploy page layout assignments from JSON file","usage":"<%= command.id %> -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:deploy","$ sfdx kit:layout:assignments:deploy -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:deploy -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"input file path","required":true,"default":"config/layout-assignments.json"}},"args":[]},"kit:layout:assignments:retrieve":{"id":"kit:layout:assignments:retrieve","description":"retrieve page layout assignments and save to JSON file","usage":"<%= command.id %> -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:retrieve","$ sfdx kit:layout:assignments:retrieve -p Admin,Standard,StandardAul -o Account,CustomObject__c -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:retrieve -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"output file path","required":true,"default":"config/layout-assignments.json"},"profile":{"name":"profile","type":"option","char":"p","description":"comma separated profile names to retrieve (default: all profiles)","required":false},"object":{"name":"object","type":"option","char":"o","description":"comma separated object names to retrieve (default: objects which have multiple layouts)","required":false},"merge":{"name":"merge","type":"boolean","description":"merge retrieved configurations with existing file","required":false,"allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kitalive/sfdx-plugin",
3
3
  "description": "Kitalive SFDX plugin",
4
- "version": "0.1.2",
4
+ "version": "0.1.6",
5
5
  "author": "Akihiro Ono",
6
6
  "bugs": "https://github.com/Kitalive-Inc/sfdx-plugin/issues",
7
7
  "dependencies": {
@@ -10,13 +10,13 @@
10
10
  "@oclif/errors": "^1",
11
11
  "@salesforce/command": "^3.1.3",
12
12
  "@salesforce/core": "^2.23.5",
13
- "@salesforce/plugin-data": "^0.4.11",
14
13
  "dayjs": "^1.10.4",
15
14
  "fast-csv": "^4.3.6",
16
15
  "fs-extra": "^9.1.0",
17
16
  "iconv-lite": "^0.6.2",
18
17
  "jsforce": "^1.10.1",
19
- "tslib": "^1"
18
+ "tslib": "^1",
19
+ "yargs": "^17.3.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@oclif/dev-cli": "^1",
@@ -27,6 +27,7 @@
27
27
  "@types/chai": "^4",
28
28
  "@types/jsforce": "^1.9.29",
29
29
  "@types/mocha": "^5",
30
+ "@types/yargs": "^17.0.8",
30
31
  "chai": "^4",
31
32
  "globby": "^8",
32
33
  "mocha": "^5",