@sharinpix/sharinpix-sf-cli 1.9.0 → 1.9.1
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 +74 -2
- package/lib/commands/sharinpix/form/csv2json.d.ts +12 -0
- package/lib/commands/sharinpix/form/csv2json.js +159 -0
- package/lib/commands/sharinpix/form/csv2json.js.map +1 -0
- package/lib/commands/sharinpix/form/json2csv.d.ts +12 -0
- package/lib/commands/sharinpix/form/json2csv.js +97 -0
- package/lib/commands/sharinpix/form/json2csv.js.map +1 -0
- package/lib/commands/sharinpix/form/pull.d.ts +1 -0
- package/lib/commands/sharinpix/form/pull.js +9 -1
- package/lib/commands/sharinpix/form/pull.js.map +1 -1
- package/lib/commands/sharinpix/form/push.d.ts +1 -0
- package/lib/commands/sharinpix/form/push.js +9 -0
- package/lib/commands/sharinpix/form/push.js.map +1 -1
- package/lib/helpers/form/elementKeyOrder.d.ts +1 -0
- package/lib/helpers/form/elementKeyOrder.js +53 -0
- package/lib/helpers/form/elementKeyOrder.js.map +1 -0
- package/lib/helpers/utils.d.ts +2 -0
- package/lib/helpers/utils.js +25 -0
- package/lib/helpers/utils.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/messages/sharinpix.form.csv2json.md +49 -0
- package/messages/sharinpix.form.json2csv.md +37 -0
- package/messages/sharinpix.form.pull.md +12 -0
- package/messages/sharinpix.form.push.md +12 -0
- package/oclif.lock +43 -11
- package/oclif.manifest.json +123 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -127,20 +127,73 @@ Both `form push` and `permission push` commands support a `--delete/-d` flag tha
|
|
|
127
127
|
## Commands
|
|
128
128
|
|
|
129
129
|
<!-- commands -->
|
|
130
|
+
* [`sf sharinpix form csv2json`](#sf-sharinpix-form-csv2json)
|
|
131
|
+
* [`sf sharinpix form json2csv`](#sf-sharinpix-form-json2csv)
|
|
130
132
|
* [`sf sharinpix form pull`](#sf-sharinpix-form-pull)
|
|
131
133
|
* [`sf sharinpix form push`](#sf-sharinpix-form-push)
|
|
132
134
|
* [`sf sharinpix permission pull`](#sf-sharinpix-permission-pull)
|
|
133
135
|
* [`sf sharinpix permission push`](#sf-sharinpix-permission-push)
|
|
134
136
|
|
|
137
|
+
## `sf sharinpix form csv2json`
|
|
138
|
+
|
|
139
|
+
Generate JSON files from SharinPix form CSV definitions.
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
USAGE
|
|
143
|
+
$ sf sharinpix form csv2json [--json] [--flags-dir <value>]
|
|
144
|
+
|
|
145
|
+
GLOBAL FLAGS
|
|
146
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
147
|
+
--json Format output as json.
|
|
148
|
+
|
|
149
|
+
DESCRIPTION
|
|
150
|
+
Generate JSON files from SharinPix form CSV definitions.
|
|
151
|
+
|
|
152
|
+
Scans the local `sharinpix/forms` directory for SharinPix form CSV definition files and generates corresponding JSON
|
|
153
|
+
files. Each CSV file is expected to have a header row of element keys and one row per element, as produced by the
|
|
154
|
+
json2csv command.
|
|
155
|
+
|
|
156
|
+
EXAMPLES
|
|
157
|
+
Generate JSON files for all local SharinPix form CSV definitions:
|
|
158
|
+
|
|
159
|
+
$ sf sharinpix form csv2json
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## `sf sharinpix form json2csv`
|
|
163
|
+
|
|
164
|
+
Generate CSV files from SharinPix form JSON definitions.
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
USAGE
|
|
168
|
+
$ sf sharinpix form json2csv [--json] [--flags-dir <value>]
|
|
169
|
+
|
|
170
|
+
GLOBAL FLAGS
|
|
171
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
172
|
+
--json Format output as json.
|
|
173
|
+
|
|
174
|
+
DESCRIPTION
|
|
175
|
+
Generate CSV files from SharinPix form JSON definitions.
|
|
176
|
+
|
|
177
|
+
Scans the local `sharinpix/forms` directory for SharinPix form JSON definition files and generates corresponding CSV
|
|
178
|
+
files. The CSV files contain a header row built from all element keys and one row per element. Nested values are
|
|
179
|
+
stringified.
|
|
180
|
+
|
|
181
|
+
EXAMPLES
|
|
182
|
+
Generate CSV files for all local SharinPix form JSON definitions:
|
|
183
|
+
|
|
184
|
+
$ sf sharinpix form json2csv
|
|
185
|
+
```
|
|
186
|
+
|
|
135
187
|
## `sf sharinpix form pull`
|
|
136
188
|
|
|
137
189
|
Pull SharinPix form templates from Salesforce org.
|
|
138
190
|
|
|
139
191
|
```
|
|
140
192
|
USAGE
|
|
141
|
-
$ sf sharinpix form pull -o <value> [--json] [--flags-dir <value>]
|
|
193
|
+
$ sf sharinpix form pull -o <value> [--json] [--flags-dir <value>] [-c]
|
|
142
194
|
|
|
143
195
|
FLAGS
|
|
196
|
+
-c, --csv Also generate CSV files from the downloaded JSON form definitions.
|
|
144
197
|
-o, --org=<value> (required) The Salesforce org to pull form templates from.
|
|
145
198
|
|
|
146
199
|
GLOBAL FLAGS
|
|
@@ -163,7 +216,16 @@ EXAMPLES
|
|
|
163
216
|
|
|
164
217
|
$ sf sharinpix form pull --target-org myorg@example.com
|
|
165
218
|
|
|
219
|
+
Pull form templates and also generate CSV files:
|
|
220
|
+
|
|
221
|
+
$ sf sharinpix form pull --csv
|
|
222
|
+
|
|
166
223
|
FLAG DESCRIPTIONS
|
|
224
|
+
-c, --csv Also generate CSV files from the downloaded JSON form definitions.
|
|
225
|
+
|
|
226
|
+
When enabled, after downloading all form templates as JSON into `sharinpix/forms`, the command runs the JSON-to-CSV
|
|
227
|
+
conversion (same as `sharinpix:form:json2csv`).
|
|
228
|
+
|
|
167
229
|
-o, --org=<value> The Salesforce org to pull form templates from.
|
|
168
230
|
|
|
169
231
|
The target Salesforce org containing the SharinPix form templates to be pulled.
|
|
@@ -175,9 +237,10 @@ Push SharinPix form templates to Salesforce org.
|
|
|
175
237
|
|
|
176
238
|
```
|
|
177
239
|
USAGE
|
|
178
|
-
$ sf sharinpix form push -o <value> [--json] [--flags-dir <value>] [-d]
|
|
240
|
+
$ sf sharinpix form push -o <value> [--json] [--flags-dir <value>] [-d] [-c]
|
|
179
241
|
|
|
180
242
|
FLAGS
|
|
243
|
+
-c, --csv Convert local CSV files to JSON before pushing.
|
|
181
244
|
-d, --delete Delete form templates from org that no longer have corresponding local files.
|
|
182
245
|
-o, --org=<value> (required) The Salesforce org to push form templates to.
|
|
183
246
|
|
|
@@ -205,7 +268,16 @@ EXAMPLES
|
|
|
205
268
|
|
|
206
269
|
$ sf sharinpix form push --delete
|
|
207
270
|
|
|
271
|
+
Convert CSV to JSON, then push:
|
|
272
|
+
|
|
273
|
+
$ sf sharinpix form push --csv
|
|
274
|
+
|
|
208
275
|
FLAG DESCRIPTIONS
|
|
276
|
+
-c, --csv Convert local CSV files to JSON before pushing.
|
|
277
|
+
|
|
278
|
+
When enabled, the command first runs the CSV-to-JSON conversion (same as `sharinpix:form:csv2json`) on files in
|
|
279
|
+
`sharinpix/forms`, then proceeds to push the resulting JSON files.
|
|
280
|
+
|
|
209
281
|
-d, --delete Delete form templates from org that no longer have corresponding local files.
|
|
210
282
|
|
|
211
283
|
When enabled, this flag will delete form template records from the Salesforce org if their corresponding local JSON
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type Csv2JsonResult = {
|
|
3
|
+
name: string;
|
|
4
|
+
converted: number;
|
|
5
|
+
skipped: number;
|
|
6
|
+
};
|
|
7
|
+
export default class Csv2Json extends SfCommand<Csv2JsonResult> {
|
|
8
|
+
static readonly summary: string;
|
|
9
|
+
static readonly description: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
run(): Promise<Csv2JsonResult>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse } from 'csv-parse/sync';
|
|
4
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
5
|
+
import { Messages } from '@salesforce/core';
|
|
6
|
+
import { getCsvFiles, formatErrorMessage, orderElementKeys } from '../../../helpers/utils.js';
|
|
7
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
8
|
+
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'sharinpix.form.csv2json');
|
|
9
|
+
const FORMS_DIRECTORY = 'sharinpix/forms';
|
|
10
|
+
const NUMERIC_FIELDS = ['index', 'max', 'min', 'step', 'rows', 'cols'];
|
|
11
|
+
const CSV_PARSE_OPTIONS = {
|
|
12
|
+
skipEmptyLines: true,
|
|
13
|
+
relaxColumnCount: true,
|
|
14
|
+
relaxQuotes: true,
|
|
15
|
+
};
|
|
16
|
+
function parseCsvRows(content) {
|
|
17
|
+
return parse(content, CSV_PARSE_OPTIONS);
|
|
18
|
+
}
|
|
19
|
+
function parseCellValue(header, rawValue) {
|
|
20
|
+
const trimmed = rawValue.trim();
|
|
21
|
+
if (trimmed === '')
|
|
22
|
+
return '';
|
|
23
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(trimmed);
|
|
26
|
+
if (typeof parsed === 'object' && parsed !== null)
|
|
27
|
+
return parsed;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Ignore parse errors, continue with other type detection
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (NUMERIC_FIELDS.includes(header)) {
|
|
34
|
+
const numValue = Number(trimmed);
|
|
35
|
+
const numberPattern = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
|
|
36
|
+
if (!Number.isNaN(numValue) && isFinite(numValue) && numberPattern.test(trimmed)) {
|
|
37
|
+
return numValue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return trimmed;
|
|
41
|
+
}
|
|
42
|
+
function parseElementRow(row, headers) {
|
|
43
|
+
const values = new Map();
|
|
44
|
+
for (let index = 0; index < headers.length; index++) {
|
|
45
|
+
const header = headers[index];
|
|
46
|
+
const rawValue = row[index] ?? '';
|
|
47
|
+
if (header && rawValue !== '') {
|
|
48
|
+
values.set(header, parseCellValue(header, rawValue));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const orderedKeys = orderElementKeys(Array.from(values.keys()));
|
|
52
|
+
const element = {};
|
|
53
|
+
for (const key of orderedKeys) {
|
|
54
|
+
element[key] = values.get(key);
|
|
55
|
+
}
|
|
56
|
+
return element;
|
|
57
|
+
}
|
|
58
|
+
function preserveElementTypes(csvElements, originalElements) {
|
|
59
|
+
const originalElementsById = new Map(originalElements.map((el) => [String(el.id), el]));
|
|
60
|
+
return csvElements.map((csvElement) => {
|
|
61
|
+
const typedElement = { ...csvElement };
|
|
62
|
+
const originalElement = originalElementsById.get(String(csvElement.id));
|
|
63
|
+
if (originalElement) {
|
|
64
|
+
for (const [key, csvValue] of Object.entries(csvElement)) {
|
|
65
|
+
const originalValue = originalElement[key];
|
|
66
|
+
if (typeof csvValue === 'string' && (csvValue === 'true' || csvValue === 'false'))
|
|
67
|
+
if (typeof originalValue === 'boolean')
|
|
68
|
+
typedElement[key] = csvValue === 'true';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return typedElement;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function mergeElementsIntoJson(existingJson, elements) {
|
|
75
|
+
const originalElements = Array.isArray(existingJson.elements) ? existingJson.elements : [];
|
|
76
|
+
const typedElements = preserveElementTypes(elements, originalElements);
|
|
77
|
+
const merged = {};
|
|
78
|
+
for (const [key, value] of Object.entries(existingJson)) {
|
|
79
|
+
merged[key] = key === 'elements' ? typedElements : value;
|
|
80
|
+
}
|
|
81
|
+
return merged;
|
|
82
|
+
}
|
|
83
|
+
async function loadAndValidateJson(jsonPath) {
|
|
84
|
+
const jsonFileName = path.basename(jsonPath);
|
|
85
|
+
let content;
|
|
86
|
+
try {
|
|
87
|
+
content = await fs.promises.readFile(jsonPath, 'utf8');
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error.code === 'ENOENT')
|
|
91
|
+
throw new Error(messages.getMessage('error.jsonNotFound', [jsonFileName]));
|
|
92
|
+
throw new Error(messages.getMessage('error.jsonReadFailed', [jsonFileName, formatErrorMessage(error)]));
|
|
93
|
+
}
|
|
94
|
+
let existingJson;
|
|
95
|
+
try {
|
|
96
|
+
existingJson = JSON.parse(content);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error(messages.getMessage('error.jsonInvalid', [jsonFileName, formatErrorMessage(error)]));
|
|
100
|
+
}
|
|
101
|
+
if (typeof existingJson !== 'object' || existingJson === null || Array.isArray(existingJson))
|
|
102
|
+
throw new Error(messages.getMessage('error.jsonNotObject', [jsonFileName]));
|
|
103
|
+
return existingJson;
|
|
104
|
+
}
|
|
105
|
+
async function processCsvFile(filePath) {
|
|
106
|
+
const fileName = path.basename(filePath);
|
|
107
|
+
try {
|
|
108
|
+
const content = await fs.promises.readFile(filePath, 'utf8');
|
|
109
|
+
const rows = parseCsvRows(content);
|
|
110
|
+
if (rows.length < 2)
|
|
111
|
+
throw new Error(messages.getMessage('error.noDataRows'));
|
|
112
|
+
const headers = rows[0];
|
|
113
|
+
const elements = [];
|
|
114
|
+
for (let i = 1; i < rows.length; i++) {
|
|
115
|
+
elements.push(parseElementRow(rows[i], headers));
|
|
116
|
+
}
|
|
117
|
+
const jsonPath = filePath.replace(/\.csv$/i, '.json');
|
|
118
|
+
const existingJson = await loadAndValidateJson(jsonPath);
|
|
119
|
+
const mergedJson = mergeElementsIntoJson(existingJson, elements);
|
|
120
|
+
await fs.promises.writeFile(jsonPath, JSON.stringify(mergedJson, null, 2), 'utf8');
|
|
121
|
+
return { success: true, fileName };
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return { success: false, fileName, reason: formatErrorMessage(error) };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export default class Csv2Json extends SfCommand {
|
|
128
|
+
static summary = messages.getMessage('summary');
|
|
129
|
+
static description = messages.getMessage('description');
|
|
130
|
+
static examples = messages.getMessages('examples');
|
|
131
|
+
async run() {
|
|
132
|
+
let files;
|
|
133
|
+
try {
|
|
134
|
+
files = getCsvFiles(FORMS_DIRECTORY);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
this.warn(messages.getMessage('error.directoryNotFound', [FORMS_DIRECTORY, formatErrorMessage(error)]));
|
|
138
|
+
return { name: 'OK', converted: 0, skipped: 0 };
|
|
139
|
+
}
|
|
140
|
+
const results = await Promise.all(files.map((file) => processCsvFile(file)));
|
|
141
|
+
let converted = 0;
|
|
142
|
+
let skipped = 0;
|
|
143
|
+
results.forEach((result) => {
|
|
144
|
+
if (result.success) {
|
|
145
|
+
converted++;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.log(messages.getMessage('info.skipped', [result.fileName, result.reason]));
|
|
149
|
+
skipped++;
|
|
150
|
+
});
|
|
151
|
+
this.log(messages.getMessage('info.summary', [converted, skipped]));
|
|
152
|
+
return {
|
|
153
|
+
name: 'OK',
|
|
154
|
+
converted,
|
|
155
|
+
skipped,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=csv2json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv2json.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/csv2json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAg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AAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAEpE,OAAO;YACL,IAAI,EAAE,IAAI;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type Json2CsvResult = {
|
|
3
|
+
name: string;
|
|
4
|
+
converted: number;
|
|
5
|
+
skipped: number;
|
|
6
|
+
};
|
|
7
|
+
export default class Json2Csv extends SfCommand<Json2CsvResult> {
|
|
8
|
+
static readonly summary: string;
|
|
9
|
+
static readonly description: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
run(): Promise<Json2CsvResult>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { stringify } from 'csv-stringify/sync';
|
|
4
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
5
|
+
import { Messages } from '@salesforce/core';
|
|
6
|
+
import { getJsonFiles, formatErrorMessage, orderElementKeys } from '../../../helpers/utils.js';
|
|
7
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
8
|
+
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'sharinpix.form.json2csv');
|
|
9
|
+
const FORMS_DIRECTORY = 'sharinpix/forms';
|
|
10
|
+
const CSV_OPTIONS = {
|
|
11
|
+
quotedMatch: /[",\n\r]/,
|
|
12
|
+
quotedEmpty: false,
|
|
13
|
+
escape: '"',
|
|
14
|
+
};
|
|
15
|
+
function formatCell(value) {
|
|
16
|
+
if (value === null || value === undefined)
|
|
17
|
+
return '';
|
|
18
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
|
|
19
|
+
return String(value);
|
|
20
|
+
if (Array.isArray(value) || typeof value === 'object')
|
|
21
|
+
return JSON.stringify(value);
|
|
22
|
+
return String(value);
|
|
23
|
+
}
|
|
24
|
+
function buildHeaders(elements) {
|
|
25
|
+
const allKeys = new Set();
|
|
26
|
+
for (const element of elements) {
|
|
27
|
+
for (const key of Object.keys(element)) {
|
|
28
|
+
allKeys.add(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return orderElementKeys(Array.from(allKeys));
|
|
32
|
+
}
|
|
33
|
+
function generateCsvContent(headers, elements) {
|
|
34
|
+
const rows = [headers];
|
|
35
|
+
for (const element of elements) {
|
|
36
|
+
const row = headers.map((key) => formatCell(element[key]));
|
|
37
|
+
rows.push(row);
|
|
38
|
+
}
|
|
39
|
+
return stringify(rows, CSV_OPTIONS);
|
|
40
|
+
}
|
|
41
|
+
function extractElements(parsed) {
|
|
42
|
+
const { elements } = parsed;
|
|
43
|
+
if (!Array.isArray(elements))
|
|
44
|
+
throw new Error(messages.getMessage('error.noElementsArray'));
|
|
45
|
+
if (elements.length === 0)
|
|
46
|
+
throw new Error(messages.getMessage('error.emptyElementsArray'));
|
|
47
|
+
return elements;
|
|
48
|
+
}
|
|
49
|
+
async function processJsonFile(filePath) {
|
|
50
|
+
const fileName = path.basename(filePath);
|
|
51
|
+
try {
|
|
52
|
+
const content = await fs.promises.readFile(filePath, 'utf8');
|
|
53
|
+
const parsed = JSON.parse(content);
|
|
54
|
+
const elements = extractElements(parsed);
|
|
55
|
+
const headers = buildHeaders(elements);
|
|
56
|
+
const csvContent = generateCsvContent(headers, elements);
|
|
57
|
+
const csvPath = filePath.replace(/\.json$/i, '.csv');
|
|
58
|
+
await fs.promises.writeFile(csvPath, csvContent, 'utf8');
|
|
59
|
+
return { success: true, fileName };
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return { success: false, fileName, reason: formatErrorMessage(error) };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export default class Json2Csv extends SfCommand {
|
|
66
|
+
static summary = messages.getMessage('summary');
|
|
67
|
+
static description = messages.getMessage('description');
|
|
68
|
+
static examples = messages.getMessages('examples');
|
|
69
|
+
async run() {
|
|
70
|
+
let files;
|
|
71
|
+
try {
|
|
72
|
+
files = getJsonFiles(FORMS_DIRECTORY);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.warn(messages.getMessage('error.directoryNotFound', [FORMS_DIRECTORY, formatErrorMessage(error)]));
|
|
76
|
+
return { name: 'OK', converted: 0, skipped: 0 };
|
|
77
|
+
}
|
|
78
|
+
const results = await Promise.all(files.map((file) => processJsonFile(file)));
|
|
79
|
+
let converted = 0;
|
|
80
|
+
let skipped = 0;
|
|
81
|
+
results.forEach((result) => {
|
|
82
|
+
if (result.success) {
|
|
83
|
+
converted++;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.log(messages.getMessage('info.skipped', [result.fileName, result.reason]));
|
|
87
|
+
skipped++;
|
|
88
|
+
});
|
|
89
|
+
this.log(messages.getMessage('info.summary', [converted, skipped]));
|
|
90
|
+
return {
|
|
91
|
+
name: 'OK',
|
|
92
|
+
converted,
|
|
93
|
+
skipped,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=json2csv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json2csv.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/json2csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE/F,QAAQ,CAAC,kCAAkC,C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ACzB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,SAAS,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAChF,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAEpE,OAAO;YACL,IAAI,EAAE,IAAI;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC"}
|
|
@@ -10,6 +10,7 @@ export default class Pull extends SfCommand<PullResult> {
|
|
|
10
10
|
static readonly examples: string[];
|
|
11
11
|
static readonly flags: {
|
|
12
12
|
org: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
};
|
|
14
15
|
run(): Promise<PullResult>;
|
|
15
16
|
}
|
|
@@ -16,6 +16,12 @@ export default class Pull extends SfCommand {
|
|
|
16
16
|
summary: messages.getMessage('flags.org.summary'),
|
|
17
17
|
description: messages.getMessage('flags.org.description'),
|
|
18
18
|
}),
|
|
19
|
+
csv: Flags.boolean({
|
|
20
|
+
char: 'c',
|
|
21
|
+
summary: messages.getMessage('flags.csv.summary'),
|
|
22
|
+
description: messages.getMessage('flags.csv.description'),
|
|
23
|
+
default: false,
|
|
24
|
+
}),
|
|
19
25
|
};
|
|
20
26
|
async run() {
|
|
21
27
|
const { flags } = await this.parse(Pull);
|
|
@@ -41,12 +47,14 @@ export default class Pull extends SfCommand {
|
|
|
41
47
|
formsDownloaded++;
|
|
42
48
|
}
|
|
43
49
|
catch (error) {
|
|
44
|
-
// Skip forms that can't be fetched (e.g., network errors, invalid URLs)
|
|
45
50
|
this.warn(`Failed to fetch form template ${record.Name}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
46
51
|
formsFailed++;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
this.log(`Successfully downloaded ${formsDownloaded} form template(s). ${formsFailed} failed.`);
|
|
55
|
+
if (flags.csv) {
|
|
56
|
+
await this.config.runCommand('sharinpix:form:json2csv', []);
|
|
57
|
+
}
|
|
50
58
|
return {
|
|
51
59
|
name: 'OK',
|
|
52
60
|
formsDownloaded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/pull.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,qCAAqC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAe7F,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAqB;IAC9C,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC;YACrB,IAA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,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;gBACzF,eAAe,EAAE,CAAC;YACpB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CACP,iCAAiC,MAAM,CAAC,IAAI,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAC5G,CAAC;gBACF,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,2BAA2B,eAAe,sBAAsB,WAAW,UAAU,CAAC,CAAC;QAEhG,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,eAAe;YACf,WAAW;SACZ,CAAC;IACJ,CAAC"}
|
|
@@ -13,6 +13,7 @@ export default class Push extends SfCommand<PushResult> {
|
|
|
13
13
|
static readonly flags: {
|
|
14
14
|
org: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
17
|
};
|
|
17
18
|
run(): Promise<PushResult>;
|
|
18
19
|
}
|
|
@@ -21,10 +21,19 @@ export default class Push extends SfCommand {
|
|
|
21
21
|
description: messages.getMessage('flags.delete.description'),
|
|
22
22
|
default: false,
|
|
23
23
|
}),
|
|
24
|
+
csv: Flags.boolean({
|
|
25
|
+
char: 'c',
|
|
26
|
+
summary: messages.getMessage('flags.csv.summary'),
|
|
27
|
+
description: messages.getMessage('flags.csv.description'),
|
|
28
|
+
default: false,
|
|
29
|
+
}),
|
|
24
30
|
};
|
|
25
31
|
async run() {
|
|
26
32
|
const { flags } = await this.parse(Push);
|
|
27
33
|
const connection = flags.org.getConnection('63.0');
|
|
34
|
+
if (flags.csv) {
|
|
35
|
+
await this.config.runCommand('sharinpix:form:csv2json', []);
|
|
36
|
+
}
|
|
28
37
|
const files = getJsonFiles('sharinpix/forms');
|
|
29
38
|
const body = {
|
|
30
39
|
// eslint-disable-next-line camelcase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/push.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,qCAAqC;AACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,SAAS,EACT,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAEnC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAiB7F,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAqB;IAC9C,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,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AAI;YACV,QAAQ;YACR,MAAM;YACN,OAAO;YACP,OAAO;SACR,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ELEMENT_KEY_ORDER: readonly string[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const ELEMENT_KEY_ORDER = [
|
|
2
|
+
'id',
|
|
3
|
+
'index',
|
|
4
|
+
'label',
|
|
5
|
+
'type',
|
|
6
|
+
'elemType',
|
|
7
|
+
'richDescription',
|
|
8
|
+
'info',
|
|
9
|
+
'apiName',
|
|
10
|
+
'codeScan',
|
|
11
|
+
'inputType',
|
|
12
|
+
'magicFill',
|
|
13
|
+
'mobileApp',
|
|
14
|
+
'sfMapping',
|
|
15
|
+
'visibility',
|
|
16
|
+
'placeholder',
|
|
17
|
+
'validations',
|
|
18
|
+
'autocomplete',
|
|
19
|
+
'defaultValue',
|
|
20
|
+
'labelFormula',
|
|
21
|
+
'sfFieldUpdate',
|
|
22
|
+
'disabledFormula',
|
|
23
|
+
'allowBlankUpdate',
|
|
24
|
+
'defaultValueFormula',
|
|
25
|
+
'preserveRelaunchValueFormula',
|
|
26
|
+
'max',
|
|
27
|
+
'min',
|
|
28
|
+
'decimal',
|
|
29
|
+
'disabled',
|
|
30
|
+
'setToNow',
|
|
31
|
+
'calendarFormat',
|
|
32
|
+
'setToNowButton',
|
|
33
|
+
'options',
|
|
34
|
+
'description',
|
|
35
|
+
'required',
|
|
36
|
+
'style',
|
|
37
|
+
'sfRecordMapping',
|
|
38
|
+
'sfPullRecordMapping',
|
|
39
|
+
'parentId',
|
|
40
|
+
'sectionId',
|
|
41
|
+
'columnLabels',
|
|
42
|
+
'sortable',
|
|
43
|
+
'addFormula',
|
|
44
|
+
'addOptions',
|
|
45
|
+
'deleteFormula',
|
|
46
|
+
'height',
|
|
47
|
+
'size',
|
|
48
|
+
'readonly',
|
|
49
|
+
'step',
|
|
50
|
+
'rows',
|
|
51
|
+
'cols',
|
|
52
|
+
];
|
|
53
|
+
//# sourceMappingURL=elementKeyOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementKeyOrder.js","sourceRoot":"","sources":["../../../src/helpers/form/elementKeyOrder.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,IAAI;IACJ,OAAO;IACP,OAAO;IACP,MAAM;IACN,UAAU;IACV,iBAAiB;IACjB,MAAM;IACN,SAAS;IACT,UAAU;IACV,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,8BAA8B;IAC9B,KAAK;IACL,KAAK;IACL,SAAS;IACT,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,UAAU;IACV,OAAO;IACP,iBAAiB;IACjB,qBAAqB;IACrB,UAAU;IACV,WAAW;IACX,cAAc;IACd,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,QAAQ;IACR,MAAM;IACN,UAAU;IACV,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAC"}
|
package/lib/helpers/utils.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export declare function getNameFromJson(json: Record<string, unknown>): string;
|
|
|
7
7
|
export declare function ensureDirectoryExists(dirPath: string): void;
|
|
8
8
|
export declare function formatErrorMessage(error: unknown): string;
|
|
9
9
|
export declare function getJsonFiles(dirPath: string): string[];
|
|
10
|
+
export declare function getCsvFiles(dirPath: string): string[];
|
|
11
|
+
export declare function orderElementKeys(keys: string[]): string[];
|
package/lib/helpers/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import { ELEMENT_KEY_ORDER } from './form/elementKeyOrder.js';
|
|
3
4
|
export function isJsonEqual(obj1, obj2) {
|
|
4
5
|
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
5
6
|
}
|
|
@@ -38,4 +39,28 @@ export function getJsonFiles(dirPath) {
|
|
|
38
39
|
.filter((file) => file.endsWith('.json'))
|
|
39
40
|
.map((file) => `${dirPath}/${file}`);
|
|
40
41
|
}
|
|
42
|
+
export function getCsvFiles(dirPath) {
|
|
43
|
+
return fs
|
|
44
|
+
.readdirSync(dirPath)
|
|
45
|
+
.filter((file) => file.endsWith('.csv'))
|
|
46
|
+
.map((file) => `${dirPath}/${file}`);
|
|
47
|
+
}
|
|
48
|
+
export function orderElementKeys(keys) {
|
|
49
|
+
const keySet = new Set(keys);
|
|
50
|
+
const ordered = [];
|
|
51
|
+
const unknownKeys = [];
|
|
52
|
+
for (const key of ELEMENT_KEY_ORDER) {
|
|
53
|
+
if (keySet.has(key)) {
|
|
54
|
+
ordered.push(key);
|
|
55
|
+
keySet.delete(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const key of keys) {
|
|
59
|
+
if (keySet.has(key)) {
|
|
60
|
+
unknownKeys.push(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
unknownKeys.sort();
|
|
64
|
+
return [...ordered, ...unknownKeys];
|
|
65
|
+
}
|
|
41
66
|
//# sourceMappingURL=utils.js.map
|
package/lib/helpers/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO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;YACpB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,WAAW,CAAC,IAAI,EAAE,CAAC;IAEnB,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,WAAW,CAAC,CAAC;AACtC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as formPull } from './commands/sharinpix/form/pull.js';
|
|
2
2
|
export { default as formPush } from './commands/sharinpix/form/push.js';
|
|
3
|
+
export { default as formJson2Csv } from './commands/sharinpix/form/json2csv.js';
|
|
4
|
+
export { default as formCsv2Json } from './commands/sharinpix/form/csv2json.js';
|
|
3
5
|
export { default as permissionPull } from './commands/sharinpix/permission/pull.js';
|
|
4
6
|
export { default as permissionPush } from './commands/sharinpix/permission/push.js';
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as formPull } from './commands/sharinpix/form/pull.js';
|
|
2
2
|
export { default as formPush } from './commands/sharinpix/form/push.js';
|
|
3
|
+
export { default as formJson2Csv } from './commands/sharinpix/form/json2csv.js';
|
|
4
|
+
export { default as formCsv2Json } from './commands/sharinpix/form/csv2json.js';
|
|
3
5
|
export { default as permissionPull } from './commands/sharinpix/permission/pull.js';
|
|
4
6
|
export { default as permissionPush } from './commands/sharinpix/permission/push.js';
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Generate JSON files from SharinPix form CSV definitions.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Scans the local `sharinpix/forms` directory for SharinPix form CSV definition files and generates corresponding JSON files. Each CSV file is expected to have a header row of element keys and one row per element, as produced by the json2csv command.
|
|
8
|
+
|
|
9
|
+
# examples
|
|
10
|
+
|
|
11
|
+
- Generate JSON files for all local SharinPix form CSV definitions:
|
|
12
|
+
|
|
13
|
+
<%= config.bin %> <%= command.id %>
|
|
14
|
+
|
|
15
|
+
# info.converted
|
|
16
|
+
|
|
17
|
+
Converted %s to JSON
|
|
18
|
+
|
|
19
|
+
# info.skipped
|
|
20
|
+
|
|
21
|
+
Skipped %s: %s
|
|
22
|
+
|
|
23
|
+
# info.summary
|
|
24
|
+
|
|
25
|
+
Conversion completed: %d file(s) converted, %d file(s) skipped
|
|
26
|
+
|
|
27
|
+
# error.directoryNotFound
|
|
28
|
+
|
|
29
|
+
Directory %s not found or could not be read: %s
|
|
30
|
+
|
|
31
|
+
# error.noDataRows
|
|
32
|
+
|
|
33
|
+
No data rows found
|
|
34
|
+
|
|
35
|
+
# error.jsonNotFound
|
|
36
|
+
|
|
37
|
+
Corresponding JSON file %s does not exist
|
|
38
|
+
|
|
39
|
+
# error.jsonReadFailed
|
|
40
|
+
|
|
41
|
+
Failed to read JSON file %s: %s
|
|
42
|
+
|
|
43
|
+
# error.jsonInvalid
|
|
44
|
+
|
|
45
|
+
Invalid JSON in file %s: %s
|
|
46
|
+
|
|
47
|
+
# error.jsonNotObject
|
|
48
|
+
|
|
49
|
+
JSON file %s is not a valid form definition (expected an object)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Generate CSV files from SharinPix form JSON definitions.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Scans the local `sharinpix/forms` directory for SharinPix form JSON definition files and generates corresponding CSV files. The CSV files contain a header row built from all element keys and one row per element. Nested values are stringified.
|
|
8
|
+
|
|
9
|
+
# examples
|
|
10
|
+
|
|
11
|
+
- Generate CSV files for all local SharinPix form JSON definitions:
|
|
12
|
+
|
|
13
|
+
<%= config.bin %> <%= command.id %>
|
|
14
|
+
|
|
15
|
+
# info.converted
|
|
16
|
+
|
|
17
|
+
Converted %s to CSV
|
|
18
|
+
|
|
19
|
+
# info.skipped
|
|
20
|
+
|
|
21
|
+
Skipped %s: %s
|
|
22
|
+
|
|
23
|
+
# info.summary
|
|
24
|
+
|
|
25
|
+
Conversion completed: %d file(s) converted, %d file(s) skipped
|
|
26
|
+
|
|
27
|
+
# error.directoryNotFound
|
|
28
|
+
|
|
29
|
+
Directory %s not found or could not be read: %s
|
|
30
|
+
|
|
31
|
+
# error.noElementsArray
|
|
32
|
+
|
|
33
|
+
No 'elements' array found
|
|
34
|
+
|
|
35
|
+
# error.emptyElementsArray
|
|
36
|
+
|
|
37
|
+
Empty 'elements' array
|
|
@@ -14,6 +14,14 @@ The Salesforce org to pull form templates from.
|
|
|
14
14
|
|
|
15
15
|
The target Salesforce org containing the SharinPix form templates to be pulled.
|
|
16
16
|
|
|
17
|
+
# flags.csv.summary
|
|
18
|
+
|
|
19
|
+
Also generate CSV files from the downloaded JSON form definitions.
|
|
20
|
+
|
|
21
|
+
# flags.csv.description
|
|
22
|
+
|
|
23
|
+
When enabled, after downloading all form templates as JSON into `sharinpix/forms`, the command runs the JSON-to-CSV conversion (same as `sharinpix:form:json2csv`).
|
|
24
|
+
|
|
17
25
|
# examples
|
|
18
26
|
|
|
19
27
|
- Pull all form templates from the default org:
|
|
@@ -24,6 +32,10 @@ The target Salesforce org containing the SharinPix form templates to be pulled.
|
|
|
24
32
|
|
|
25
33
|
<%= config.bin %> <%= command.id %> --target-org myorg@example.com
|
|
26
34
|
|
|
35
|
+
- Pull form templates and also generate CSV files:
|
|
36
|
+
|
|
37
|
+
<%= config.bin %> <%= command.id %> --csv
|
|
38
|
+
|
|
27
39
|
# info.hello
|
|
28
40
|
|
|
29
41
|
Pulled form template %s from %s
|
|
@@ -22,6 +22,14 @@ Delete form templates from org that no longer have corresponding local files.
|
|
|
22
22
|
|
|
23
23
|
When enabled, this flag will delete form template records from the Salesforce org if their corresponding local JSON files are missing. Use with caution as this operation cannot be undone.
|
|
24
24
|
|
|
25
|
+
# flags.csv.summary
|
|
26
|
+
|
|
27
|
+
Convert local CSV files to JSON before pushing.
|
|
28
|
+
|
|
29
|
+
# flags.csv.description
|
|
30
|
+
|
|
31
|
+
When enabled, the command first runs the CSV-to-JSON conversion (same as `sharinpix:form:csv2json`) on files in `sharinpix/forms`, then proceeds to push the resulting JSON files.
|
|
32
|
+
|
|
25
33
|
# examples
|
|
26
34
|
|
|
27
35
|
- Push all form templates to the default org:
|
|
@@ -36,6 +44,10 @@ When enabled, this flag will delete form template records from the Salesforce or
|
|
|
36
44
|
|
|
37
45
|
<%= config.bin %> <%= command.id %> --delete
|
|
38
46
|
|
|
47
|
+
- Convert CSV to JSON, then push:
|
|
48
|
+
|
|
49
|
+
<%= config.bin %> <%= command.id %> --csv
|
|
50
|
+
|
|
39
51
|
# info.created
|
|
40
52
|
|
|
41
53
|
Created form template %s
|
package/oclif.lock
CHANGED
|
@@ -3965,7 +3965,14 @@ create-require@^1.1.0:
|
|
|
3965
3965
|
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
|
|
3966
3966
|
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
|
|
3967
3967
|
|
|
3968
|
-
cross-
|
|
3968
|
+
cross-env@^7.0.3:
|
|
3969
|
+
version "7.0.3"
|
|
3970
|
+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
|
|
3971
|
+
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
|
|
3972
|
+
dependencies:
|
|
3973
|
+
cross-spawn "^7.0.1"
|
|
3974
|
+
|
|
3975
|
+
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3, cross-spawn@^7.0.6:
|
|
3969
3976
|
version "7.0.6"
|
|
3970
3977
|
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz"
|
|
3971
3978
|
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
|
|
@@ -3998,16 +4005,36 @@ csstype@^3.0.2:
|
|
|
3998
4005
|
resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz"
|
|
3999
4006
|
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
|
|
4000
4007
|
|
|
4008
|
+
csv-generate@^4.5.0:
|
|
4009
|
+
version "4.5.0"
|
|
4010
|
+
resolved "https://registry.yarnpkg.com/csv-generate/-/csv-generate-4.5.0.tgz#5fbbb89bd9f8ce705871c9baf02e1d4bb4000fb3"
|
|
4011
|
+
integrity sha512-aQr/vmOKyBSBHNwYhAoXw1+kUsPnMSwmYgpNoo36rIXoG1ecWILnvPGZeQ6oUjzrWknZAD3+jfpqYOBAl4x15A==
|
|
4012
|
+
|
|
4001
4013
|
csv-parse@^5.5.2:
|
|
4002
4014
|
version "5.6.0"
|
|
4003
4015
|
resolved "https://registry.npmjs.org/csv-parse/-/csv-parse-5.6.0.tgz"
|
|
4004
4016
|
integrity sha512-l3nz3euub2QMg5ouu5U09Ew9Wf6/wQ8I++ch1loQ0ljmzhmfZYrH9fflS22i/PQEvsPvxCwxgz5q7UB8K1JO4Q==
|
|
4005
4017
|
|
|
4006
|
-
csv-
|
|
4018
|
+
csv-parse@^6.1.0:
|
|
4019
|
+
version "6.1.0"
|
|
4020
|
+
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-6.1.0.tgz#c642ec5b7fc57c1f477a07d179beb5ff0dfd5ed0"
|
|
4021
|
+
integrity sha512-CEE+jwpgLn+MmtCpVcPtiCZpVtB6Z2OKPTr34pycYYoL7sxdOkXDdQ4lRiw6ioC0q6BLqhc6cKweCVvral8yhw==
|
|
4022
|
+
|
|
4023
|
+
csv-stringify@^6.4.4, csv-stringify@^6.6.0:
|
|
4007
4024
|
version "6.6.0"
|
|
4008
4025
|
resolved "https://registry.npmjs.org/csv-stringify/-/csv-stringify-6.6.0.tgz"
|
|
4009
4026
|
integrity sha512-YW32lKOmIBgbxtu3g5SaiqWNwa/9ISQt2EcgOq0+RAIFufFp9is6tqNnKahqE5kuKvrnYAzs28r+s6pXJR8Vcw==
|
|
4010
4027
|
|
|
4028
|
+
csv@^6.4.1:
|
|
4029
|
+
version "6.4.1"
|
|
4030
|
+
resolved "https://registry.yarnpkg.com/csv/-/csv-6.4.1.tgz#c9a62130c025f8adb2a85a75d4c2608612995822"
|
|
4031
|
+
integrity sha512-ajGosmTGnTwYyGl8STqZDu7R6LkDf3xL39XiOmliV/GufQeVUxHzTKIm4NOBCwmEuujK7B6isxs4Uqt9GcRCvA==
|
|
4032
|
+
dependencies:
|
|
4033
|
+
csv-generate "^4.5.0"
|
|
4034
|
+
csv-parse "^6.1.0"
|
|
4035
|
+
csv-stringify "^6.6.0"
|
|
4036
|
+
stream-transform "^3.4.0"
|
|
4037
|
+
|
|
4011
4038
|
dargs@^7.0.0:
|
|
4012
4039
|
version "7.0.0"
|
|
4013
4040
|
resolved "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz"
|
|
@@ -6450,9 +6477,9 @@ just-extend@^6.2.0:
|
|
|
6450
6477
|
resolved "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz"
|
|
6451
6478
|
integrity sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==
|
|
6452
6479
|
|
|
6453
|
-
jwa@^1.4.
|
|
6480
|
+
jwa@^1.4.2:
|
|
6454
6481
|
version "1.4.2"
|
|
6455
|
-
resolved "https://registry.
|
|
6482
|
+
resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.2.tgz#16011ac6db48de7b102777e57897901520eec7b9"
|
|
6456
6483
|
integrity sha512-eeH5JO+21J78qMvTIDdBXidBd6nG2kZjg5Ohz/1fpa28Z4CcsWUzJ1ZZyFq/3z3N17aZy+ZuBoHljASbL1WfOw==
|
|
6457
6484
|
dependencies:
|
|
6458
6485
|
buffer-equal-constant-time "^1.0.1"
|
|
@@ -6460,11 +6487,11 @@ jwa@^1.4.1:
|
|
|
6460
6487
|
safe-buffer "^5.0.1"
|
|
6461
6488
|
|
|
6462
6489
|
jws@^3.2.2:
|
|
6463
|
-
version "3.2.
|
|
6464
|
-
resolved "https://registry.
|
|
6465
|
-
integrity sha512-
|
|
6490
|
+
version "3.2.3"
|
|
6491
|
+
resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.3.tgz#5ac0690b460900a27265de24520526853c0b8ca1"
|
|
6492
|
+
integrity sha512-byiJ0FLRdLdSVSReO/U4E7RoEyOCKnEnEPMjq3HxWtvzLsV08/i5RQKsFVNkCldrCaPr2vDNAOMsfs8T/Hze7g==
|
|
6466
6493
|
dependencies:
|
|
6467
|
-
jwa "^1.4.
|
|
6494
|
+
jwa "^1.4.2"
|
|
6468
6495
|
safe-buffer "^5.0.1"
|
|
6469
6496
|
|
|
6470
6497
|
keyv@^4.5.3:
|
|
@@ -6945,9 +6972,9 @@ math-intrinsics@^1.1.0:
|
|
|
6945
6972
|
integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==
|
|
6946
6973
|
|
|
6947
6974
|
mdast-util-to-hast@^13.0.0:
|
|
6948
|
-
version "13.2.
|
|
6949
|
-
resolved "https://registry.
|
|
6950
|
-
integrity sha512-
|
|
6975
|
+
version "13.2.1"
|
|
6976
|
+
resolved "https://registry.yarnpkg.com/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz#d7ff84ca499a57e2c060ae67548ad950e689a053"
|
|
6977
|
+
integrity sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==
|
|
6951
6978
|
dependencies:
|
|
6952
6979
|
"@types/hast" "^3.0.0"
|
|
6953
6980
|
"@types/mdast" "^4.0.0"
|
|
@@ -9244,6 +9271,11 @@ stream-combiner2@~1.1.1:
|
|
|
9244
9271
|
duplexer2 "~0.1.0"
|
|
9245
9272
|
readable-stream "^2.0.2"
|
|
9246
9273
|
|
|
9274
|
+
stream-transform@^3.4.0:
|
|
9275
|
+
version "3.4.0"
|
|
9276
|
+
resolved "https://registry.yarnpkg.com/stream-transform/-/stream-transform-3.4.0.tgz#38d562fbdad38c3b6cda959ad36751014bb26e18"
|
|
9277
|
+
integrity sha512-QO3OGhKyeIV8p6eRQdG+W6WounFw519zk690hHCNfhgfP9bylVS+NTXsuBc7n+RsGn31UgFPGrWYIgoAbArKEw==
|
|
9278
|
+
|
|
9247
9279
|
"string-width-cjs@npm:string-width@^4.2.0":
|
|
9248
9280
|
version "4.2.3"
|
|
9249
9281
|
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
|
package/oclif.manifest.json
CHANGED
|
@@ -1,12 +1,115 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
+
"sharinpix:form:csv2json": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {},
|
|
6
|
+
"description": "Scans the local `sharinpix/forms` directory for SharinPix form CSV definition files and generates corresponding JSON files. Each CSV file is expected to have a header row of element keys and one row per element, as produced by the json2csv command.",
|
|
7
|
+
"examples": [
|
|
8
|
+
"Generate JSON files for all local SharinPix form CSV definitions:\n<%= config.bin %> <%= command.id %>"
|
|
9
|
+
],
|
|
10
|
+
"flags": {
|
|
11
|
+
"json": {
|
|
12
|
+
"description": "Format output as json.",
|
|
13
|
+
"helpGroup": "GLOBAL",
|
|
14
|
+
"name": "json",
|
|
15
|
+
"allowNo": false,
|
|
16
|
+
"type": "boolean"
|
|
17
|
+
},
|
|
18
|
+
"flags-dir": {
|
|
19
|
+
"helpGroup": "GLOBAL",
|
|
20
|
+
"name": "flags-dir",
|
|
21
|
+
"summary": "Import flag values from a directory.",
|
|
22
|
+
"hasDynamicHelp": false,
|
|
23
|
+
"multiple": false,
|
|
24
|
+
"type": "option"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"hasDynamicHelp": false,
|
|
28
|
+
"hiddenAliases": [],
|
|
29
|
+
"id": "sharinpix:form:csv2json",
|
|
30
|
+
"pluginAlias": "@sharinpix/sharinpix-sf-cli",
|
|
31
|
+
"pluginName": "@sharinpix/sharinpix-sf-cli",
|
|
32
|
+
"pluginType": "core",
|
|
33
|
+
"strict": true,
|
|
34
|
+
"summary": "Generate JSON files from SharinPix form CSV definitions.",
|
|
35
|
+
"enableJsonFlag": true,
|
|
36
|
+
"isESM": true,
|
|
37
|
+
"relativePath": [
|
|
38
|
+
"lib",
|
|
39
|
+
"commands",
|
|
40
|
+
"sharinpix",
|
|
41
|
+
"form",
|
|
42
|
+
"csv2json.js"
|
|
43
|
+
],
|
|
44
|
+
"aliasPermutations": [],
|
|
45
|
+
"permutations": [
|
|
46
|
+
"sharinpix:form:csv2json",
|
|
47
|
+
"form:sharinpix:csv2json",
|
|
48
|
+
"form:csv2json:sharinpix",
|
|
49
|
+
"sharinpix:csv2json:form",
|
|
50
|
+
"csv2json:sharinpix:form",
|
|
51
|
+
"csv2json:form:sharinpix"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"sharinpix:form:json2csv": {
|
|
55
|
+
"aliases": [],
|
|
56
|
+
"args": {},
|
|
57
|
+
"description": "Scans the local `sharinpix/forms` directory for SharinPix form JSON definition files and generates corresponding CSV files. The CSV files contain a header row built from all element keys and one row per element. Nested values are stringified.",
|
|
58
|
+
"examples": [
|
|
59
|
+
"Generate CSV files for all local SharinPix form JSON definitions:\n<%= config.bin %> <%= command.id %>"
|
|
60
|
+
],
|
|
61
|
+
"flags": {
|
|
62
|
+
"json": {
|
|
63
|
+
"description": "Format output as json.",
|
|
64
|
+
"helpGroup": "GLOBAL",
|
|
65
|
+
"name": "json",
|
|
66
|
+
"allowNo": false,
|
|
67
|
+
"type": "boolean"
|
|
68
|
+
},
|
|
69
|
+
"flags-dir": {
|
|
70
|
+
"helpGroup": "GLOBAL",
|
|
71
|
+
"name": "flags-dir",
|
|
72
|
+
"summary": "Import flag values from a directory.",
|
|
73
|
+
"hasDynamicHelp": false,
|
|
74
|
+
"multiple": false,
|
|
75
|
+
"type": "option"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"hasDynamicHelp": false,
|
|
79
|
+
"hiddenAliases": [],
|
|
80
|
+
"id": "sharinpix:form:json2csv",
|
|
81
|
+
"pluginAlias": "@sharinpix/sharinpix-sf-cli",
|
|
82
|
+
"pluginName": "@sharinpix/sharinpix-sf-cli",
|
|
83
|
+
"pluginType": "core",
|
|
84
|
+
"strict": true,
|
|
85
|
+
"summary": "Generate CSV files from SharinPix form JSON definitions.",
|
|
86
|
+
"enableJsonFlag": true,
|
|
87
|
+
"isESM": true,
|
|
88
|
+
"relativePath": [
|
|
89
|
+
"lib",
|
|
90
|
+
"commands",
|
|
91
|
+
"sharinpix",
|
|
92
|
+
"form",
|
|
93
|
+
"json2csv.js"
|
|
94
|
+
],
|
|
95
|
+
"aliasPermutations": [],
|
|
96
|
+
"permutations": [
|
|
97
|
+
"sharinpix:form:json2csv",
|
|
98
|
+
"form:sharinpix:json2csv",
|
|
99
|
+
"form:json2csv:sharinpix",
|
|
100
|
+
"sharinpix:json2csv:form",
|
|
101
|
+
"json2csv:sharinpix:form",
|
|
102
|
+
"json2csv:form:sharinpix"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
3
105
|
"sharinpix:form:pull": {
|
|
4
106
|
"aliases": [],
|
|
5
107
|
"args": {},
|
|
6
108
|
"description": "Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition files.",
|
|
7
109
|
"examples": [
|
|
8
110
|
"Pull all form templates from the default org:\n<%= config.bin %> <%= command.id %>",
|
|
9
|
-
"Pull form templates from a specific org:\n<%= config.bin %> <%= command.id %> --target-org myorg@example.com"
|
|
111
|
+
"Pull form templates from a specific org:\n<%= config.bin %> <%= command.id %> --target-org myorg@example.com",
|
|
112
|
+
"Pull form templates and also generate CSV files:\n<%= config.bin %> <%= command.id %> --csv"
|
|
10
113
|
],
|
|
11
114
|
"flags": {
|
|
12
115
|
"json": {
|
|
@@ -34,6 +137,14 @@
|
|
|
34
137
|
"hasDynamicHelp": true,
|
|
35
138
|
"multiple": false,
|
|
36
139
|
"type": "option"
|
|
140
|
+
},
|
|
141
|
+
"csv": {
|
|
142
|
+
"char": "c",
|
|
143
|
+
"description": "When enabled, after downloading all form templates as JSON into `sharinpix/forms`, the command runs the JSON-to-CSV conversion (same as `sharinpix:form:json2csv`).",
|
|
144
|
+
"name": "csv",
|
|
145
|
+
"summary": "Also generate CSV files from the downloaded JSON form definitions.",
|
|
146
|
+
"allowNo": false,
|
|
147
|
+
"type": "boolean"
|
|
37
148
|
}
|
|
38
149
|
},
|
|
39
150
|
"hasDynamicHelp": true,
|
|
@@ -70,7 +181,8 @@
|
|
|
70
181
|
"examples": [
|
|
71
182
|
"Push all form templates to the default org:\n<%= config.bin %> <%= command.id %>",
|
|
72
183
|
"Push form templates to a specific org:\n<%= config.bin %> <%= command.id %> --target-org myorg@example.com",
|
|
73
|
-
"Push form templates and delete orphaned records:\n<%= config.bin %> <%= command.id %> --delete"
|
|
184
|
+
"Push form templates and delete orphaned records:\n<%= config.bin %> <%= command.id %> --delete",
|
|
185
|
+
"Convert CSV to JSON, then push:\n<%= config.bin %> <%= command.id %> --csv"
|
|
74
186
|
],
|
|
75
187
|
"flags": {
|
|
76
188
|
"json": {
|
|
@@ -106,6 +218,14 @@
|
|
|
106
218
|
"summary": "Delete form templates from org that no longer have corresponding local files.",
|
|
107
219
|
"allowNo": false,
|
|
108
220
|
"type": "boolean"
|
|
221
|
+
},
|
|
222
|
+
"csv": {
|
|
223
|
+
"char": "c",
|
|
224
|
+
"description": "When enabled, the command first runs the CSV-to-JSON conversion (same as `sharinpix:form:csv2json`) on files in `sharinpix/forms`, then proceeds to push the resulting JSON files.",
|
|
225
|
+
"name": "csv",
|
|
226
|
+
"summary": "Convert local CSV files to JSON before pushing.",
|
|
227
|
+
"allowNo": false,
|
|
228
|
+
"type": "boolean"
|
|
109
229
|
}
|
|
110
230
|
},
|
|
111
231
|
"hasDynamicHelp": true,
|
|
@@ -271,5 +391,5 @@
|
|
|
271
391
|
]
|
|
272
392
|
}
|
|
273
393
|
},
|
|
274
|
-
"version": "1.9.
|
|
394
|
+
"version": "1.9.1"
|
|
275
395
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharinpix/sharinpix-sf-cli",
|
|
3
3
|
"description": "SharinPix salesforce cli plugin",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^4",
|
|
7
7
|
"@salesforce/core": "^8",
|
|
8
|
-
"@salesforce/sf-plugins-core": "^12"
|
|
8
|
+
"@salesforce/sf-plugins-core": "^12",
|
|
9
|
+
"csv": "^6.4.1"
|
|
9
10
|
},
|
|
10
11
|
"engines": {
|
|
11
12
|
"node": ">=18.0.0"
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"postpack": "sf-clean --ignore-signing-artifacts",
|
|
49
50
|
"prepack": "sf-prepack",
|
|
50
51
|
"test": "wireit",
|
|
51
|
-
"test:nuts": "TS_NODE_PROJECT=./test/tsconfig.json nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
|
|
52
|
+
"test:nuts": "cross-env TS_NODE_PROJECT=./test/tsconfig.json nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
|
|
52
53
|
"test:only": "wireit",
|
|
53
54
|
"version": "oclif readme",
|
|
54
55
|
"prepare": "husky",
|
|
@@ -184,6 +185,7 @@
|
|
|
184
185
|
"@salesforce/dev-scripts": "^10",
|
|
185
186
|
"@types/mocha": "^10.0.7",
|
|
186
187
|
"@types/mock-fs": "^4.13.4",
|
|
188
|
+
"cross-env": "^7.0.3",
|
|
187
189
|
"eslint-plugin-sf-plugin": "^1.18.6",
|
|
188
190
|
"husky": "^9.1.7",
|
|
189
191
|
"mock-fs": "^5.5.0",
|