@sharinpix/sharinpix-sf-cli 1.11.0 → 1.12.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 +30 -9
- package/lib/commands/sharinpix/form/csv2json.js +54 -61
- package/lib/commands/sharinpix/form/csv2json.js.map +1 -1
- package/lib/commands/sharinpix/form/json2csv.js +10 -13
- package/lib/commands/sharinpix/form/json2csv.js.map +1 -1
- package/lib/commands/sharinpix/form/pull.js +8 -4
- package/lib/commands/sharinpix/form/pull.js.map +1 -1
- package/lib/commands/sharinpix/form/push.d.ts +2 -0
- package/lib/commands/sharinpix/form/push.js +31 -5
- package/lib/commands/sharinpix/form/push.js.map +1 -1
- package/lib/commands/sharinpix/push.d.ts +1 -0
- package/lib/commands/sharinpix/push.js +6 -0
- package/lib/commands/sharinpix/push.js.map +1 -1
- package/lib/helpers/form/elementKeys.d.ts +3 -0
- package/lib/helpers/form/elementKeys.js +74 -0
- package/lib/helpers/form/elementKeys.js.map +1 -0
- package/lib/helpers/form/transformers.d.ts +9 -0
- package/lib/helpers/form/transformers.js +84 -0
- package/lib/helpers/form/transformers.js.map +1 -0
- package/lib/helpers/utils.d.ts +1 -0
- package/lib/helpers/utils.js +8 -18
- package/lib/helpers/utils.js.map +1 -1
- package/messages/sharinpix.form.pull.md +2 -2
- package/messages/sharinpix.form.push.md +13 -1
- package/messages/sharinpix.push.md +12 -0
- package/oclif.lock +1412 -2051
- package/oclif.manifest.json +158 -140
- package/package.json +43 -11
- package/lib/helpers/form/elementKeyOrder.d.ts +0 -1
- package/lib/helpers/form/elementKeyOrder.js +0 -53
- package/lib/helpers/form/elementKeyOrder.js.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { arrayTransformer, booleanTransformer, jsonTransformer, numberTransformer, stringTransformer, } from './transformers.js';
|
|
2
|
+
const elementKeys = [
|
|
3
|
+
{ key: 'id', transformer: stringTransformer },
|
|
4
|
+
{ key: 'note', transformer: jsonTransformer },
|
|
5
|
+
{ key: 'index', transformer: numberTransformer },
|
|
6
|
+
{ key: 'label', transformer: stringTransformer },
|
|
7
|
+
{ key: 'height', transformer: numberTransformer },
|
|
8
|
+
{ key: 'style', transformer: stringTransformer },
|
|
9
|
+
{ key: 'apiName', transformer: stringTransformer },
|
|
10
|
+
{ key: 'options', transformer: arrayTransformer },
|
|
11
|
+
{ key: 'formula', transformer: stringTransformer },
|
|
12
|
+
{ key: 'elemType', transformer: stringTransformer },
|
|
13
|
+
{ key: 'required', transformer: booleanTransformer },
|
|
14
|
+
{ key: 'defaultValueFormula', transformer: stringTransformer },
|
|
15
|
+
{ key: 'parentId', transformer: stringTransformer },
|
|
16
|
+
{ key: 'setToNow', transformer: booleanTransformer },
|
|
17
|
+
{ key: 'inputType', transformer: stringTransformer },
|
|
18
|
+
{ key: 'magicFill', transformer: jsonTransformer },
|
|
19
|
+
{ key: 'backgroundImage', transformer: stringTransformer },
|
|
20
|
+
{ key: 'mobileApp', transformer: jsonTransformer },
|
|
21
|
+
{ key: 'sectionId', transformer: stringTransformer },
|
|
22
|
+
{ key: 'addOptions', transformer: arrayTransformer },
|
|
23
|
+
{ key: 'visibility', transformer: stringTransformer },
|
|
24
|
+
{ key: 'defaultValue', transformer: jsonTransformer },
|
|
25
|
+
{ key: 'richDescription', transformer: stringTransformer },
|
|
26
|
+
{ key: 'validations', transformer: arrayTransformer },
|
|
27
|
+
{ key: 'annotation_config', transformer: stringTransformer },
|
|
28
|
+
{ key: 'labelFormula', transformer: stringTransformer },
|
|
29
|
+
{ key: 'sfMapping', transformer: arrayTransformer },
|
|
30
|
+
{ key: 'calendarFormat', transformer: stringTransformer },
|
|
31
|
+
{ key: 'setToNowButton', transformer: booleanTransformer },
|
|
32
|
+
{ key: 'sfFieldUpdate', transformer: arrayTransformer },
|
|
33
|
+
{ key: 'type', transformer: stringTransformer },
|
|
34
|
+
{ key: 'codeScan', transformer: jsonTransformer },
|
|
35
|
+
{ key: 'floatingLabel', transformer: booleanTransformer },
|
|
36
|
+
{ key: 'sfRecordMapping', transformer: arrayTransformer },
|
|
37
|
+
{ key: 'sfPullRecordMapping', transformer: arrayTransformer },
|
|
38
|
+
{ key: 'autocomplete', transformer: stringTransformer },
|
|
39
|
+
{ key: 'placeholder', transformer: stringTransformer },
|
|
40
|
+
{ key: 'disabledFormula', transformer: stringTransformer },
|
|
41
|
+
{ key: 'allowBlankUpdate', transformer: booleanTransformer },
|
|
42
|
+
{ key: 'preserveRelaunchValueFormula', transformer: stringTransformer },
|
|
43
|
+
{ key: 'max', transformer: numberTransformer },
|
|
44
|
+
{ key: 'min', transformer: numberTransformer },
|
|
45
|
+
{ key: 'decimal', transformer: booleanTransformer },
|
|
46
|
+
{ key: 'disabled', transformer: booleanTransformer },
|
|
47
|
+
{ key: 'description', transformer: stringTransformer },
|
|
48
|
+
{ key: 'info', transformer: stringTransformer },
|
|
49
|
+
{ key: 'columnLabels', transformer: arrayTransformer },
|
|
50
|
+
{ key: 'sortable', transformer: booleanTransformer },
|
|
51
|
+
{ key: 'addFormula', transformer: stringTransformer },
|
|
52
|
+
{ key: 'deleteFormula', transformer: stringTransformer },
|
|
53
|
+
{ key: 'size', transformer: stringTransformer },
|
|
54
|
+
{ key: 'readonly', transformer: booleanTransformer },
|
|
55
|
+
{ key: 'step', transformer: numberTransformer },
|
|
56
|
+
];
|
|
57
|
+
export const elementKeyOrder = elementKeys.map((d) => d.key);
|
|
58
|
+
function getTransformer(header) {
|
|
59
|
+
const keyDef = elementKeys.find((d) => d.key === header);
|
|
60
|
+
if (!keyDef)
|
|
61
|
+
throw new Error(`Unknown key "${header}"`);
|
|
62
|
+
return keyDef.transformer;
|
|
63
|
+
}
|
|
64
|
+
export function parseCell(header, rawValue) {
|
|
65
|
+
return getTransformer(header).parse(rawValue);
|
|
66
|
+
}
|
|
67
|
+
export function serializeCell(header, value) {
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
if (value === '')
|
|
71
|
+
return '""';
|
|
72
|
+
return getTransformer(header).serialize(value);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=elementKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementKeys.js","sourceRoot":"","sources":["../../../src/helpers/form/elementKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,GAAG;IAClB,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAC7C,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE;IAC7C,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAChD,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAChD,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE;IACjD,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAChD,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAClD,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE;IACjD,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAClD,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE;IACnD,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE;IACpD,EAAE,GAAG,EAAE,qBAAqB,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAC9D,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE;IACnD,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE;IACpD,EAAE,GAA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;AAExF,MAAM,CAAC,MAAM,eAAe,GAAsB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEhF,SAAS,cAAc,CAAC,MAAc;IACpC,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,MAAM,GAAG,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,QAAgB;IACxD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,KAAc;IAC1D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Transformer = Readonly<{
|
|
2
|
+
parse: (rawValue: string) => unknown;
|
|
3
|
+
serialize: (value: unknown) => string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const stringTransformer: Transformer;
|
|
6
|
+
export declare const jsonTransformer: Transformer;
|
|
7
|
+
export declare const arrayTransformer: Transformer;
|
|
8
|
+
export declare const booleanTransformer: Transformer;
|
|
9
|
+
export declare const numberTransformer: Transformer;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const stringTransformer = {
|
|
2
|
+
parse: (rawValue) => rawValue,
|
|
3
|
+
serialize: (value) => {
|
|
4
|
+
if (typeof value !== 'string')
|
|
5
|
+
throw new Error(`Cannot serialize string: got value of type "${typeof value}" with value "${String(value)}"`);
|
|
6
|
+
return value;
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export const jsonTransformer = {
|
|
10
|
+
parse: (rawValue) => {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(rawValue);
|
|
13
|
+
return parsed;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw new Error(`Cannot parse JSON value: ${error instanceof Error ? error.message : String(error)}`, {
|
|
17
|
+
cause: error,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
serialize: (value) => {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
throw new Error('Cannot serialize undefined JSON value');
|
|
24
|
+
try {
|
|
25
|
+
return JSON.stringify(value);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Cannot serialize JSON value: ${error instanceof Error ? error.message : String(error)}`, {
|
|
29
|
+
cause: error,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const arrayTransformer = {
|
|
35
|
+
parse: (rawValue) => {
|
|
36
|
+
const genericError = 'Cannot parse array value';
|
|
37
|
+
try {
|
|
38
|
+
if (!rawValue.startsWith('['))
|
|
39
|
+
throw new Error(genericError);
|
|
40
|
+
const parsed = JSON.parse(rawValue);
|
|
41
|
+
if (!Array.isArray(parsed))
|
|
42
|
+
throw new Error(genericError);
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new Error(genericError);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
serialize: (value) => {
|
|
50
|
+
if (!Array.isArray(value))
|
|
51
|
+
throw new Error(`Cannot serialize array: got value of type "${typeof value}" with value "${String(value)}"`);
|
|
52
|
+
return JSON.stringify(value);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export const booleanTransformer = {
|
|
56
|
+
parse: (rawValue) => {
|
|
57
|
+
if (rawValue === 'true')
|
|
58
|
+
return true;
|
|
59
|
+
if (rawValue === 'false')
|
|
60
|
+
return false;
|
|
61
|
+
throw new Error(`Cannot parse boolean value: expected "true" or "false", got "${rawValue}"`);
|
|
62
|
+
},
|
|
63
|
+
serialize: (value) => {
|
|
64
|
+
if (typeof value !== 'boolean')
|
|
65
|
+
throw new Error(`Cannot serialize boolean: got value of type "${typeof value}" with value "${String(value)}"`);
|
|
66
|
+
return value ? 'true' : 'false';
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const numberTransformer = {
|
|
70
|
+
parse: (rawValue) => {
|
|
71
|
+
const numberPattern = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
|
|
72
|
+
const numValue = Number(rawValue);
|
|
73
|
+
if (!Number.isNaN(numValue) && Number.isFinite(numValue) && numberPattern.test(rawValue))
|
|
74
|
+
return numValue;
|
|
75
|
+
throw new Error(`Cannot parse number value: got "${rawValue}"`);
|
|
76
|
+
},
|
|
77
|
+
serialize: (value) => {
|
|
78
|
+
if (typeof value !== 'number') {
|
|
79
|
+
throw new Error(`Cannot serialize number: got value of type "${typeof value}" with value "${String(value)}"`);
|
|
80
|
+
}
|
|
81
|
+
return value.toString();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=transformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../../../src/helpers/form/transformers.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC5C,KAAK,EAAE,CAAC,QAAgB,EAAW,EAAE,CAAC,QAAQ;IAC9C,SAAS,EAAE,CAAC,KAAc,EAAU,EAAE;QACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC3B,MAAM,IAAI,KAAK,CAAC,+CAA+C,OAAO,KAAK,iBAAiB,MAAM,CAAC,KAAK,CAAC,GAAG,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,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;QAC1G,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,GAAG,CAAC,CAAC;IAClE,CAAC;IACD,SAAS,EAAE,CAAC,KAAc,EAAU,EAAE;QACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,+CAA+C,OAAO,KAAK,iBAAiB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChH,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;CACF,CAAC"}
|
package/lib/helpers/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function isJsonEqual(obj1: unknown, obj2: unknown): boolean;
|
|
2
|
+
export declare function sanitizeFilename(name: string): string;
|
|
2
3
|
export declare function createSafeFilename(name: string): string;
|
|
3
4
|
export declare function readJsonFile(filePath: string): Record<string, unknown>;
|
|
4
5
|
export declare function writeJsonFile(filePath: string, data: unknown): void;
|
package/lib/helpers/utils.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { elementKeyOrder } from './form/elementKeys.js';
|
|
4
4
|
export function isJsonEqual(obj1, obj2) {
|
|
5
5
|
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
6
6
|
}
|
|
7
|
+
export function sanitizeFilename(name) {
|
|
8
|
+
return name.replaceAll(/[^a-zA-Z0-9]/g, '_');
|
|
9
|
+
}
|
|
7
10
|
export function createSafeFilename(name) {
|
|
8
11
|
const md5Hash = crypto.createHash('md5').update(name).digest('hex').slice(0, 8);
|
|
9
|
-
return `${name
|
|
12
|
+
return `${sanitizeFilename(name)}-${md5Hash}`;
|
|
10
13
|
}
|
|
11
14
|
export function readJsonFile(filePath) {
|
|
12
15
|
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
@@ -46,21 +49,8 @@ export function getCsvFiles(dirPath) {
|
|
|
46
49
|
.map((file) => `${dirPath}/${file}`);
|
|
47
50
|
}
|
|
48
51
|
export function orderElementKeys(keys) {
|
|
49
|
-
const
|
|
50
|
-
const ordered =
|
|
51
|
-
|
|
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];
|
|
52
|
+
const knownKeys = new Set(elementKeyOrder);
|
|
53
|
+
const ordered = elementKeyOrder.filter((key) => keys.includes(key));
|
|
54
|
+
return ordered.filter((key) => knownKeys.has(key));
|
|
65
55
|
}
|
|
66
56
|
//# 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;AACzB,OAAO,EAAE,
|
|
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,EAAE,eAAe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AAG,CAAC,CAAC,CAAC;IACpE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -4,7 +4,7 @@ Pull SharinPix form templates from Salesforce org.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Retrieves
|
|
7
|
+
Retrieves active, version-record 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.
|
|
8
8
|
|
|
9
9
|
# flags.org.summary
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ When enabled, after downloading all form templates as JSON into `sharinpix/forms
|
|
|
24
24
|
|
|
25
25
|
# examples
|
|
26
26
|
|
|
27
|
-
- Pull
|
|
27
|
+
- Pull active form templates from the default org:
|
|
28
28
|
|
|
29
29
|
<%= config.bin %> <%= command.id %>
|
|
30
30
|
|
|
@@ -4,7 +4,7 @@ Push SharinPix form templates to Salesforce org.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Uploads SharinPix form templates from local JSON files to the connected Salesforce org. This command reads form templates from the local directory and creates or updates corresponding records in Salesforce.
|
|
7
|
+
Uploads SharinPix form templates from local JSON files to the connected Salesforce org. This command reads form templates from the local directory and creates or updates corresponding records in Salesforce. Each file is matched to an existing form template only by its `mainId`; if the file has no `mainId` or it is not found in the target org, a new form template is created. Pushing to a different org is therefore a one-time copy.
|
|
8
8
|
|
|
9
9
|
# flags.org.summary
|
|
10
10
|
|
|
@@ -30,6 +30,14 @@ Convert local CSV files to JSON before pushing.
|
|
|
30
30
|
|
|
31
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
32
|
|
|
33
|
+
# flags.activate.summary
|
|
34
|
+
|
|
35
|
+
Activate the pushed form template version.
|
|
36
|
+
|
|
37
|
+
# flags.activate.description
|
|
38
|
+
|
|
39
|
+
When enabled, the newly pushed form template version is set as the active version in Salesforce. Without this flag, the version is created but not activated.
|
|
40
|
+
|
|
33
41
|
# examples
|
|
34
42
|
|
|
35
43
|
- Push all form templates to the default org:
|
|
@@ -48,6 +56,10 @@ When enabled, the command first runs the CSV-to-JSON conversion (same as `sharin
|
|
|
48
56
|
|
|
49
57
|
<%= config.bin %> <%= command.id %> --csv
|
|
50
58
|
|
|
59
|
+
- Push form templates and activate the new versions:
|
|
60
|
+
|
|
61
|
+
<%= config.bin %> <%= command.id %> --activate
|
|
62
|
+
|
|
51
63
|
# info.created
|
|
52
64
|
|
|
53
65
|
Created form template %s
|
|
@@ -22,6 +22,14 @@ Delete assets in the org that do not exist locally.
|
|
|
22
22
|
|
|
23
23
|
If specified, any form templates or permissions that exist in the org but not in the local project will be deleted.
|
|
24
24
|
|
|
25
|
+
# flags.activate.summary
|
|
26
|
+
|
|
27
|
+
Activate the pushed form template version.
|
|
28
|
+
|
|
29
|
+
# flags.activate.description
|
|
30
|
+
|
|
31
|
+
When enabled, newly pushed form template versions are set as active in Salesforce. Without this flag, versions are created but not activated. Forwarded to form push only.
|
|
32
|
+
|
|
25
33
|
# examples
|
|
26
34
|
|
|
27
35
|
- Push all assets to the default org:
|
|
@@ -35,3 +43,7 @@ If specified, any form templates or permissions that exist in the org but not in
|
|
|
35
43
|
- Push all assets and delete missing ones from the org:
|
|
36
44
|
|
|
37
45
|
<%= config.bin %> <%= command.id %> --delete
|
|
46
|
+
|
|
47
|
+
- Push all assets and activate new form versions:
|
|
48
|
+
|
|
49
|
+
<%= config.bin %> <%= command.id %> --activate
|