@salesforce/plugin-custom-metadata 2.2.13 → 3.0.2
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 +46 -46
- package/lib/commands/cmdt/generate/field.d.ts +7 -7
- package/lib/commands/cmdt/generate/field.js +76 -79
- package/lib/commands/cmdt/generate/field.js.map +1 -1
- package/lib/commands/cmdt/generate/fromorg.d.ts +11 -11
- package/lib/commands/cmdt/generate/fromorg.js +87 -92
- package/lib/commands/cmdt/generate/fromorg.js.map +1 -1
- package/lib/commands/cmdt/generate/object.d.ts +6 -6
- package/lib/commands/cmdt/generate/object.js +55 -58
- package/lib/commands/cmdt/generate/object.js.map +1 -1
- package/lib/commands/cmdt/generate/record.d.ts +7 -7
- package/lib/commands/cmdt/generate/record.js +64 -68
- package/lib/commands/cmdt/generate/record.js.map +1 -1
- package/lib/commands/cmdt/generate/records.d.ts +7 -7
- package/lib/commands/cmdt/generate/records.js +58 -60
- package/lib/commands/cmdt/generate/records.js.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/shared/helpers/createUtil.d.ts +2 -2
- package/lib/shared/helpers/createUtil.js +17 -27
- package/lib/shared/helpers/createUtil.js.map +1 -1
- package/lib/shared/helpers/fileWriter.d.ts +2 -2
- package/lib/shared/helpers/fileWriter.js +4 -9
- package/lib/shared/helpers/fileWriter.js.map +1 -1
- package/lib/shared/helpers/metadataUtil.js +5 -12
- package/lib/shared/helpers/metadataUtil.js.map +1 -1
- package/lib/shared/helpers/validationUtil.js +15 -21
- package/lib/shared/helpers/validationUtil.js.map +1 -1
- package/lib/shared/interfaces/createConfig.js +1 -2
- package/lib/shared/interfaces/createConfig.js.map +1 -1
- package/lib/shared/templates/templates.js +13 -18
- package/lib/shared/templates/templates.js.map +1 -1
- package/oclif.lock +292 -390
- package/oclif.manifest.json +520 -268
- package/package.json +29 -26
package/README.md
CHANGED
|
@@ -71,19 +71,19 @@ sfdx plugins
|
|
|
71
71
|
|
|
72
72
|
<!-- commands -->
|
|
73
73
|
|
|
74
|
-
- [`
|
|
75
|
-
- [`
|
|
76
|
-
- [`
|
|
77
|
-
- [`
|
|
78
|
-
- [`
|
|
74
|
+
- [`sf cmdt generate field`](#sf-cmdt-generate-field)
|
|
75
|
+
- [`sf cmdt generate fromorg`](#sf-cmdt-generate-fromorg)
|
|
76
|
+
- [`sf cmdt generate object`](#sf-cmdt-generate-object)
|
|
77
|
+
- [`sf cmdt generate record`](#sf-cmdt-generate-record)
|
|
78
|
+
- [`sf cmdt generate records`](#sf-cmdt-generate-records)
|
|
79
79
|
|
|
80
|
-
## `
|
|
80
|
+
## `sf cmdt generate field`
|
|
81
81
|
|
|
82
82
|
Generate a field for a custom metadata type based on the provided field type.
|
|
83
83
|
|
|
84
84
|
```
|
|
85
85
|
USAGE
|
|
86
|
-
$
|
|
86
|
+
$ sf cmdt generate field -n <value> -f
|
|
87
87
|
Checkbox|Date|DateTime|Email|Number|Percent|Phone|Picklist|Text|TextArea|LongTextArea|Url [--json] [-p <value>] [-s
|
|
88
88
|
<value>] [-l <value>] [-d <value>]
|
|
89
89
|
|
|
@@ -111,23 +111,23 @@ DESCRIPTION
|
|
|
111
111
|
for the custom metadata type called MyCmdt.
|
|
112
112
|
|
|
113
113
|
ALIASES
|
|
114
|
-
$
|
|
115
|
-
$
|
|
114
|
+
$ sf force cmdt field create
|
|
115
|
+
$ sf cmdt field create
|
|
116
116
|
|
|
117
117
|
EXAMPLES
|
|
118
118
|
Generate a metadata file for a custom checkbox field and add the file to the MyCmdt__mdt/fields directory:
|
|
119
119
|
|
|
120
|
-
$
|
|
120
|
+
$ sf cmdt generate field --name MyCheckboxField --type Checkbox --output-directory \
|
|
121
121
|
force-app/main/default/objects/MyCmdt__mdt
|
|
122
122
|
|
|
123
123
|
Generate a metadata file for a custom picklist field and add a few values:
|
|
124
124
|
|
|
125
|
-
$
|
|
125
|
+
$ sf cmdt generate field --name MyPicklistField --type Picklist --picklist-values A --picklist-values B \
|
|
126
126
|
--picklist-values C --output-directory force-app/main/default/objects/MyCmdt__mdt
|
|
127
127
|
|
|
128
128
|
Generate a metadata file for a custom number field and specify 2 decimal places:
|
|
129
129
|
|
|
130
|
-
$
|
|
130
|
+
$ sf cmdt generate field --name MyNumberField --type Number --decimal-places 2 --output-directory \
|
|
131
131
|
force-app/main/default/objects/MyCmdt__mdt
|
|
132
132
|
|
|
133
133
|
FLAG DESCRIPTIONS
|
|
@@ -148,15 +148,15 @@ FLAG DESCRIPTIONS
|
|
|
148
148
|
The value must be greater than or equal to zero. Default value is 0.
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
_See code: [src/commands/cmdt/generate/field.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/
|
|
151
|
+
_See code: [src/commands/cmdt/generate/field.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/3.0.2/src/commands/cmdt/generate/field.ts)_
|
|
152
152
|
|
|
153
|
-
## `
|
|
153
|
+
## `sf cmdt generate fromorg`
|
|
154
154
|
|
|
155
155
|
Generate a custom metadata type and all its records from a Salesforce object.
|
|
156
156
|
|
|
157
157
|
```
|
|
158
158
|
USAGE
|
|
159
|
-
$
|
|
159
|
+
$ sf cmdt generate fromorg -o <value> -n <value> -s <value> [--json] [--api-version <value>] [-l <value>] [-p <value>]
|
|
160
160
|
[-v PackageProtected|Protected|Public] [-i] [-d <value>] [-r <value>]
|
|
161
161
|
|
|
162
162
|
FLAGS
|
|
@@ -173,7 +173,7 @@ FLAGS
|
|
|
173
173
|
metadata type.
|
|
174
174
|
-v, --visibility=<option> [default: Public] Who can see the custom metadata type.
|
|
175
175
|
<options: PackageProtected|Protected|Public>
|
|
176
|
-
|
|
176
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
177
177
|
|
|
178
178
|
GLOBAL FLAGS
|
|
179
179
|
--json Format output as json.
|
|
@@ -182,7 +182,7 @@ DESCRIPTION
|
|
|
182
182
|
Generate a custom metadata type and all its records from a Salesforce object.
|
|
183
183
|
|
|
184
184
|
Use this command to migrate existing custom objects or custom settings in an org to custom metadata types. If a field
|
|
185
|
-
of the Salesforce object is of an unsupported type, the field type is automatically converted to text. Run "
|
|
185
|
+
of the Salesforce object is of an unsupported type, the field type is automatically converted to text. Run "sf cmdt
|
|
186
186
|
generate field --help" to see the list of supported cmdt field types, listed in the --type flag summary. Use the
|
|
187
187
|
--ignore-unsupported to ignore these fields.
|
|
188
188
|
|
|
@@ -191,36 +191,36 @@ DESCRIPTION
|
|
|
191
191
|
--dev-name flag. Use --type-output-directory to create them in a different directory.
|
|
192
192
|
|
|
193
193
|
ALIASES
|
|
194
|
-
$
|
|
194
|
+
$ sf force cmdt generate
|
|
195
195
|
|
|
196
196
|
EXAMPLES
|
|
197
197
|
Generate a custom metadata type from a custom object called MySourceObject__c in your default org:
|
|
198
198
|
|
|
199
|
-
$
|
|
199
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --sobject MySourceObject__c
|
|
200
200
|
|
|
201
201
|
Generate a custom metadata type from a custom object in an org with alias my-scratch-org; ignore unsupported field
|
|
202
202
|
types instead of converting them to text:
|
|
203
203
|
|
|
204
|
-
$
|
|
204
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --sobject MySourceObject__c --ignore-unsupported --target-org \
|
|
205
205
|
my-scratch-org
|
|
206
206
|
|
|
207
207
|
Generate a protected custom metadata type from a custom object:
|
|
208
208
|
|
|
209
|
-
$
|
|
209
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --sobject MySourceObject__c --visibility Protected
|
|
210
210
|
|
|
211
211
|
Generate a protected custom metadata type from a custom setting with a specific singular and plural label:
|
|
212
212
|
|
|
213
|
-
$
|
|
213
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --label "My CMDT" --plural-label "My CMDTs" --sobject \
|
|
214
214
|
MySourceSetting__c --visibility Protected
|
|
215
215
|
|
|
216
216
|
Generate a custom metadata type and put the resulting metadata files in the specified directory:
|
|
217
217
|
|
|
218
|
-
$
|
|
218
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --sobject MySourceObject__c --type-output-directory \
|
|
219
219
|
path/to/my/cmdt/directory
|
|
220
220
|
|
|
221
221
|
Generate a custom metadata type and put the resulting record metadata file(s) in the specified directory:
|
|
222
222
|
|
|
223
|
-
$
|
|
223
|
+
$ sf cmdt generate fromorg --dev-name MyCMDT --sobject MySourceObject__c --records-output-dir \
|
|
224
224
|
path/to/my/cmdt/record/directory
|
|
225
225
|
|
|
226
226
|
FLAG DESCRIPTIONS
|
|
@@ -235,15 +235,15 @@ FLAG DESCRIPTIONS
|
|
|
235
235
|
https://help.salesforce.com/s/articleView?id=sf.custommetadatatypes_ui_create.htm&type=5.
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
_See code: [src/commands/cmdt/generate/fromorg.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/
|
|
238
|
+
_See code: [src/commands/cmdt/generate/fromorg.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/3.0.2/src/commands/cmdt/generate/fromorg.ts)_
|
|
239
239
|
|
|
240
|
-
## `
|
|
240
|
+
## `sf cmdt generate object`
|
|
241
241
|
|
|
242
242
|
Generate a new custom metadata type in the current project.
|
|
243
243
|
|
|
244
244
|
```
|
|
245
245
|
USAGE
|
|
246
|
-
$
|
|
246
|
+
$ sf cmdt generate object -n <value> [--json] [-l <value>] [-p <value>] [-v PackageProtected|Protected|Public] [-d
|
|
247
247
|
<value>]
|
|
248
248
|
|
|
249
249
|
FLAGS
|
|
@@ -266,17 +266,17 @@ DESCRIPTION
|
|
|
266
266
|
"force-app/main/default/objects".
|
|
267
267
|
|
|
268
268
|
ALIASES
|
|
269
|
-
$
|
|
270
|
-
$
|
|
269
|
+
$ sf force cmdt create
|
|
270
|
+
$ sf cmdt create
|
|
271
271
|
|
|
272
272
|
EXAMPLES
|
|
273
273
|
Generate a custom metadata type with developer name 'MyCustomType'; this name is also used as the label:
|
|
274
274
|
|
|
275
|
-
$
|
|
275
|
+
$ sf cmdt generate object --type-name MyCustomType
|
|
276
276
|
|
|
277
277
|
Generate a protected custom metadata type with a specific label:
|
|
278
278
|
|
|
279
|
-
$
|
|
279
|
+
$ sf cmdt generate object --type-name MyCustomType --label "Custom Type" --plural-label "Custom Types" \
|
|
280
280
|
--visibility Protected
|
|
281
281
|
|
|
282
282
|
FLAG DESCRIPTIONS
|
|
@@ -296,15 +296,15 @@ FLAG DESCRIPTIONS
|
|
|
296
296
|
https://help.salesforce.com/s/articleView?id=sf.custommetadatatypes_ui_create.htm&type=5.
|
|
297
297
|
```
|
|
298
298
|
|
|
299
|
-
_See code: [src/commands/cmdt/generate/object.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/
|
|
299
|
+
_See code: [src/commands/cmdt/generate/object.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/3.0.2/src/commands/cmdt/generate/object.ts)_
|
|
300
300
|
|
|
301
|
-
## `
|
|
301
|
+
## `sf cmdt generate record`
|
|
302
302
|
|
|
303
303
|
Generate a new record for a given custom metadata type in the current project.
|
|
304
304
|
|
|
305
305
|
```
|
|
306
306
|
USAGE
|
|
307
|
-
$
|
|
307
|
+
$ sf cmdt generate record -t <value> -n <value> [--json] [-l <value>] [-p true|false] [-i <value>] [-d <value>]
|
|
308
308
|
|
|
309
309
|
FLAGS
|
|
310
310
|
-d, --output-directory=<value> [default: force-app/main/default/customMetadata] Directory to store newly-created
|
|
@@ -328,19 +328,19 @@ DESCRIPTION
|
|
|
328
328
|
name=value pairs to specify the values for the fields, such as MyTextField="some text here" or MyNumberField=32.
|
|
329
329
|
|
|
330
330
|
ALIASES
|
|
331
|
-
$
|
|
332
|
-
$
|
|
331
|
+
$ sf force cmdt record create
|
|
332
|
+
$ sf cmdt record create
|
|
333
333
|
|
|
334
334
|
EXAMPLES
|
|
335
335
|
Create a record metadata file for custom metadata type 'MyCMT' with specified values for two custom fields:
|
|
336
336
|
|
|
337
|
-
$
|
|
337
|
+
$ sf cmdt generate record --type-name MyCMT__mdt --record-name MyRecord My_Custom_Field_1=Foo \
|
|
338
338
|
My_Custom_Field_2=Bar
|
|
339
339
|
|
|
340
340
|
Create a protected record metadata file for custom metadata type 'MyCMT' with a specific label and values specified
|
|
341
341
|
for two custom fields:
|
|
342
342
|
|
|
343
|
-
$
|
|
343
|
+
$ sf cmdt generate record --type-name MyCMT__mdt --record-name MyRecord --label "My Record" --protected true \
|
|
344
344
|
My_Custom_Field_1=Foo My_Custom_Field_2=Bar
|
|
345
345
|
|
|
346
346
|
FLAG DESCRIPTIONS
|
|
@@ -349,15 +349,15 @@ FLAG DESCRIPTIONS
|
|
|
349
349
|
Protected records can only be accessed by code in the same managed package namespace.
|
|
350
350
|
```
|
|
351
351
|
|
|
352
|
-
_See code: [src/commands/cmdt/generate/record.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/
|
|
352
|
+
_See code: [src/commands/cmdt/generate/record.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/3.0.2/src/commands/cmdt/generate/record.ts)_
|
|
353
353
|
|
|
354
|
-
## `
|
|
354
|
+
## `sf cmdt generate records`
|
|
355
355
|
|
|
356
356
|
Generate new custom metadata type records from a CSV file.
|
|
357
357
|
|
|
358
358
|
```
|
|
359
359
|
USAGE
|
|
360
|
-
$
|
|
360
|
+
$ sf cmdt generate records -f <value> -t <value> [--json] [-i <value>] [-d <value>] [-n <value>]
|
|
361
361
|
|
|
362
362
|
FLAGS
|
|
363
363
|
-d, --output-directory=<value> [default: force-app/main/default/customMetadata] Directory to store newly-created
|
|
@@ -378,19 +378,19 @@ DESCRIPTION
|
|
|
378
378
|
record name; use the --name-column flag to specify a different column.
|
|
379
379
|
|
|
380
380
|
ALIASES
|
|
381
|
-
$
|
|
382
|
-
$
|
|
381
|
+
$ sf force cmdt record insert
|
|
382
|
+
$ sf cmdt record insert
|
|
383
383
|
|
|
384
384
|
EXAMPLES
|
|
385
385
|
Generate record metadata files from values in a CSV file for the custom metadata type MyCmdt. Use 'Name' as the
|
|
386
386
|
column that specifies the record name:
|
|
387
387
|
|
|
388
|
-
$
|
|
388
|
+
$ sf cmdt generate records --csv path/to/my.csv --type-name MyCmdt
|
|
389
389
|
|
|
390
390
|
Generate record metadata files from a CSV file in the directory different from the default, and use 'PrimaryKey' as
|
|
391
391
|
the column that specifies the record name:
|
|
392
392
|
|
|
393
|
-
$
|
|
393
|
+
$ sf cmdt generate records --csv path/to/my.csv --type-name MyCmdt --input-directory path/to/my/cmdt/directory \
|
|
394
394
|
--name-column "PrimaryKey"
|
|
395
395
|
|
|
396
396
|
FLAG DESCRIPTIONS
|
|
@@ -399,7 +399,7 @@ FLAG DESCRIPTIONS
|
|
|
399
399
|
The '__mdt' suffix is appended to the end of the name if it's omitted.
|
|
400
400
|
```
|
|
401
401
|
|
|
402
|
-
_See code: [src/commands/cmdt/generate/records.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/
|
|
402
|
+
_See code: [src/commands/cmdt/generate/records.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/3.0.2/src/commands/cmdt/generate/records.ts)_
|
|
403
403
|
|
|
404
404
|
<!-- commandsstop -->
|
|
405
405
|
|
|
@@ -11,13 +11,13 @@ export default class Create extends SfCommand<CmdtFieldCreateResponse> {
|
|
|
11
11
|
static readonly requiresProject = true;
|
|
12
12
|
static readonly aliases: string[];
|
|
13
13
|
static readonly flags: {
|
|
14
|
-
loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
-
name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
|
-
type: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
-
'picklist-values': import("@oclif/core/lib/interfaces").OptionFlag<string[]
|
|
18
|
-
'decimal-places': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
|
-
label: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
|
-
'output-directory': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
loglevel: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
type: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
+
'picklist-values': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[], import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
18
|
+
'decimal-places': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
19
|
+
label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
20
|
+
'output-directory': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
21
21
|
};
|
|
22
22
|
run(): Promise<CmdtFieldCreateResponse>;
|
|
23
23
|
}
|
|
@@ -1,30 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
1
|
/*
|
|
5
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
3
|
* All rights reserved.
|
|
7
4
|
* Licensed under the BSD 3-Clause license.
|
|
8
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { dirname } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { arrayWithDeprecation, Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core';
|
|
11
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
12
|
+
import { writeFieldFile } from '../../../shared/helpers/fileWriter.js';
|
|
13
|
+
import { validateAPIName } from '../../../shared/helpers/validationUtil.js';
|
|
14
|
+
import { createDefaultTypeStructure, createFieldXML } from '../../../shared/templates/templates.js';
|
|
15
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
|
16
|
+
const messages = Messages.loadMessages('@salesforce/plugin-custom-metadata', 'field');
|
|
17
|
+
export default class Create extends SfCommand {
|
|
18
|
+
static summary = messages.getMessage('summary');
|
|
19
|
+
static description = messages.getMessage('description');
|
|
20
|
+
static examples = messages.getMessages('examples');
|
|
21
|
+
static requiresProject = true;
|
|
22
|
+
static aliases = ['force:cmdt:field:create', 'cmdt:field:create'];
|
|
23
|
+
static flags = {
|
|
24
|
+
loglevel,
|
|
25
|
+
name: Flags.string({
|
|
26
|
+
char: 'n',
|
|
27
|
+
required: true,
|
|
28
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
29
|
+
parse: async (input) => Promise.resolve(validateAPIName(input, messages.getMessage('invalidCustomFieldError', [input]))),
|
|
30
|
+
aliases: ['fieldname'],
|
|
31
|
+
}),
|
|
32
|
+
type: Flags.string({
|
|
33
|
+
char: 'f',
|
|
34
|
+
required: true,
|
|
35
|
+
summary: messages.getMessage('flags.type.summary'),
|
|
36
|
+
description: messages.getMessage('flags.type.description'),
|
|
37
|
+
options: [
|
|
38
|
+
'Checkbox',
|
|
39
|
+
'Date',
|
|
40
|
+
'DateTime',
|
|
41
|
+
'Email',
|
|
42
|
+
'Number',
|
|
43
|
+
'Percent',
|
|
44
|
+
'Phone',
|
|
45
|
+
'Picklist',
|
|
46
|
+
'Text',
|
|
47
|
+
'TextArea',
|
|
48
|
+
'LongTextArea',
|
|
49
|
+
'Url',
|
|
50
|
+
],
|
|
51
|
+
aliases: ['fieldtype'],
|
|
52
|
+
}),
|
|
53
|
+
'picklist-values': arrayWithDeprecation({
|
|
54
|
+
char: 'p',
|
|
55
|
+
summary: messages.getMessage('flags.picklist-values.summary'),
|
|
56
|
+
aliases: ['picklistvalues'],
|
|
57
|
+
}),
|
|
58
|
+
'decimal-places': Flags.integer({
|
|
59
|
+
char: 's',
|
|
60
|
+
summary: messages.getMessage('flags.decimal-places.summary'),
|
|
61
|
+
description: messages.getMessage('flags.decimal-places.description'),
|
|
62
|
+
default: 0,
|
|
63
|
+
min: 0,
|
|
64
|
+
aliases: ['decimalplaces'],
|
|
65
|
+
}),
|
|
66
|
+
label: Flags.string({
|
|
67
|
+
char: 'l',
|
|
68
|
+
summary: messages.getMessage('flags.label.summary'),
|
|
69
|
+
}),
|
|
70
|
+
'output-directory': Flags.directory({
|
|
71
|
+
char: 'd',
|
|
72
|
+
summary: messages.getMessage('flags.output-directory.summary'),
|
|
73
|
+
description: messages.getMessage('flags.output-directory.description'),
|
|
74
|
+
default: '',
|
|
75
|
+
aliases: ['outputdir', 'outputdirectory'],
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
19
78
|
async run() {
|
|
20
|
-
const { flags } = await this.parse(
|
|
79
|
+
const { flags } = await this.parse(Create);
|
|
21
80
|
const picklistvalues = flags['picklist-values'] ?? [];
|
|
22
81
|
if (flags.type === 'Picklist' && picklistvalues?.length === 0) {
|
|
23
|
-
throw new
|
|
82
|
+
throw new SfError(messages.getMessage('picklistValuesNotSuppliedError'));
|
|
24
83
|
}
|
|
25
|
-
const data =
|
|
26
|
-
const fieldXML =
|
|
27
|
-
const saveResults = await
|
|
84
|
+
const data = createDefaultTypeStructure(flags.name, flags.type, flags.label ?? flags.name, picklistvalues, flags['decimal-places']);
|
|
85
|
+
const fieldXML = createFieldXML(data, false);
|
|
86
|
+
const saveResults = await writeFieldFile(fs, flags['output-directory'], flags.name, fieldXML);
|
|
28
87
|
this.log(messages.getMessage('targetDirectory', [saveResults.dir]));
|
|
29
88
|
this.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [saveResults.fileName]));
|
|
30
89
|
return {
|
|
@@ -34,66 +93,4 @@ class Create extends sf_plugins_core_1.SfCommand {
|
|
|
34
93
|
};
|
|
35
94
|
}
|
|
36
95
|
}
|
|
37
|
-
_a = Create;
|
|
38
|
-
Create.summary = messages.getMessage('summary');
|
|
39
|
-
Create.description = messages.getMessage('description');
|
|
40
|
-
Create.examples = messages.getMessages('examples');
|
|
41
|
-
Create.requiresProject = true;
|
|
42
|
-
Create.aliases = ['force:cmdt:field:create', 'cmdt:field:create'];
|
|
43
|
-
Create.flags = {
|
|
44
|
-
loglevel: sf_plugins_core_1.loglevel,
|
|
45
|
-
name: sf_plugins_core_1.Flags.string({
|
|
46
|
-
char: 'n',
|
|
47
|
-
required: true,
|
|
48
|
-
summary: messages.getMessage('flags.name.summary'),
|
|
49
|
-
parse: async (input) => Promise.resolve((0, validationUtil_1.validateAPIName)(input, messages.getMessage('invalidCustomFieldError', [input]))),
|
|
50
|
-
aliases: ['fieldname'],
|
|
51
|
-
}),
|
|
52
|
-
type: sf_plugins_core_1.Flags.string({
|
|
53
|
-
char: 'f',
|
|
54
|
-
required: true,
|
|
55
|
-
summary: messages.getMessage('flags.type.summary'),
|
|
56
|
-
description: messages.getMessage('flags.type.description'),
|
|
57
|
-
options: [
|
|
58
|
-
'Checkbox',
|
|
59
|
-
'Date',
|
|
60
|
-
'DateTime',
|
|
61
|
-
'Email',
|
|
62
|
-
'Number',
|
|
63
|
-
'Percent',
|
|
64
|
-
'Phone',
|
|
65
|
-
'Picklist',
|
|
66
|
-
'Text',
|
|
67
|
-
'TextArea',
|
|
68
|
-
'LongTextArea',
|
|
69
|
-
'Url',
|
|
70
|
-
],
|
|
71
|
-
aliases: ['fieldtype'],
|
|
72
|
-
}),
|
|
73
|
-
'picklist-values': (0, sf_plugins_core_1.arrayWithDeprecation)({
|
|
74
|
-
char: 'p',
|
|
75
|
-
summary: messages.getMessage('flags.picklist-values.summary'),
|
|
76
|
-
aliases: ['picklistvalues'],
|
|
77
|
-
}),
|
|
78
|
-
'decimal-places': sf_plugins_core_1.Flags.integer({
|
|
79
|
-
char: 's',
|
|
80
|
-
summary: messages.getMessage('flags.decimal-places.summary'),
|
|
81
|
-
description: messages.getMessage('flags.decimal-places.description'),
|
|
82
|
-
default: 0,
|
|
83
|
-
min: 0,
|
|
84
|
-
aliases: ['decimalplaces'],
|
|
85
|
-
}),
|
|
86
|
-
label: sf_plugins_core_1.Flags.string({
|
|
87
|
-
char: 'l',
|
|
88
|
-
summary: messages.getMessage('flags.label.summary'),
|
|
89
|
-
}),
|
|
90
|
-
'output-directory': sf_plugins_core_1.Flags.directory({
|
|
91
|
-
char: 'd',
|
|
92
|
-
summary: messages.getMessage('flags.output-directory.summary'),
|
|
93
|
-
description: messages.getMessage('flags.output-directory.description'),
|
|
94
|
-
default: '',
|
|
95
|
-
aliases: ['outputdir', 'outputdirectory'],
|
|
96
|
-
}),
|
|
97
|
-
};
|
|
98
|
-
exports.default = Create;
|
|
99
96
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../../../src/commands/cmdt/generate/field.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../../../src/commands/cmdt/generate/field.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,K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CAAC,IAAI;YAChC,SAAS,EAAE,KAAK,CAAC,IAAI;SACtB,CAAC;IACJ,CAAC"}
|
|
@@ -10,17 +10,17 @@ export default class Generate extends SfCommand<CmdtGenerateResponse> {
|
|
|
10
10
|
static readonly requiresProject = true;
|
|
11
11
|
static readonly aliases: string[];
|
|
12
12
|
static readonly flags: {
|
|
13
|
-
'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
-
'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
-
loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
|
-
'dev-name': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
-
label: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
|
-
'plural-label': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
|
-
visibility: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
|
-
sobject: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
-
'ignore-unsupported': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
22
|
-
'type-output-directory': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
23
|
-
'records-output-dir': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
'api-version': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
|
+
loglevel: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
'dev-name': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
+
label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
18
|
+
'plural-label': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
19
|
+
visibility: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
20
|
+
sobject: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
21
|
+
'ignore-unsupported': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
22
|
+
'type-output-directory': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
23
|
+
'records-output-dir': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
24
24
|
};
|
|
25
25
|
run(): Promise<CmdtGenerateResponse>;
|
|
26
26
|
}
|