@salesforce/plugin-custom-metadata 1.0.10 → 1.1.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +96 -43
  3. package/lib/commands/force/cmdt/create.d.ts +4 -4
  4. package/lib/commands/force/cmdt/create.js +84 -80
  5. package/lib/commands/force/cmdt/create.js.map +1 -1
  6. package/lib/commands/force/cmdt/field/create.d.ts +3 -3
  7. package/lib/commands/force/cmdt/field/create.js +102 -89
  8. package/lib/commands/force/cmdt/field/create.js.map +1 -1
  9. package/lib/commands/force/cmdt/generate.d.ts +6 -6
  10. package/lib/commands/force/cmdt/generate.js +256 -243
  11. package/lib/commands/force/cmdt/generate.js.map +1 -1
  12. package/lib/commands/force/cmdt/record/create.d.ts +6 -6
  13. package/lib/commands/force/cmdt/record/create.js +130 -124
  14. package/lib/commands/force/cmdt/record/create.js.map +1 -1
  15. package/lib/commands/force/cmdt/record/insert.d.ts +5 -5
  16. package/lib/commands/force/cmdt/record/insert.js +105 -105
  17. package/lib/commands/force/cmdt/record/insert.js.map +1 -1
  18. package/lib/index.js +3 -3
  19. package/lib/lib/helpers/createUtil.js +14 -10
  20. package/lib/lib/helpers/createUtil.js.map +1 -1
  21. package/lib/lib/helpers/fileWriter.d.ts +2 -0
  22. package/lib/lib/helpers/fileWriter.js +5 -3
  23. package/lib/lib/helpers/fileWriter.js.map +1 -1
  24. package/lib/lib/helpers/metadataUtil.d.ts +2 -2
  25. package/lib/lib/helpers/metadataUtil.js +22 -15
  26. package/lib/lib/helpers/metadataUtil.js.map +1 -1
  27. package/lib/lib/helpers/validationUtil.js +9 -6
  28. package/lib/lib/helpers/validationUtil.js.map +1 -1
  29. package/lib/lib/interfaces/createConfig.js +3 -3
  30. package/lib/lib/interfaces/customField.js +3 -3
  31. package/lib/lib/interfaces/errorMessage.js +3 -3
  32. package/lib/lib/interfaces/record.js +3 -3
  33. package/lib/lib/interfaces/saveResults.js +3 -3
  34. package/lib/lib/templates/templates.d.ts +2 -0
  35. package/lib/lib/templates/templates.js +64 -23
  36. package/lib/lib/templates/templates.js.map +1 -1
  37. package/oclif.manifest.json +1 -1
  38. package/package.json +19 -19
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.1.0](https://github.com/salesforcecli/plugin-custom-metadata/compare/v1.0.12...v1.1.0) (2022-04-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * bump deps ([d33c882](https://github.com/salesforcecli/plugin-custom-metadata/commit/d33c882817d296a7e039a78641553bcb00685727))
11
+
12
+ ### [1.0.12](https://github.com/salesforcecli/plugin-custom-metadata/compare/v1.0.11...v1.0.12) (2021-04-06)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * leif .yml merge [skip-validate-pr] ([9177fdc](https://github.com/salesforcecli/plugin-custom-metadata/commit/9177fdc23b42f6cd1c96ee1d34cf74093994c407))
18
+
19
+ ### [1.0.11](https://github.com/salesforcecli/plugin-custom-metadata/compare/v1.0.10...v1.0.11) (2020-12-10)
20
+
5
21
  ### [1.0.10](https://github.com/salesforcecli/plugin-custom-metadata/compare/v1.0.8...v1.0.10) (2020-08-27)
6
22
 
7
23
 
package/README.md CHANGED
@@ -7,13 +7,66 @@ Tools for working with custom metadata types and their records.
7
7
  [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-custom-metadata/tree/master.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-custom-metadata/tree/master)
8
8
  [![License](https://img.shields.io/npm/l/@salesforce/plugin-custom-metadata.svg)](https://github.com/salesforcecli/plugin-custom-metadata/blob/master/LICENSE.txt)
9
9
 
10
- # Installation
11
- This is a [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) plugin and bundled with the CLI via [salesforcedx](https://www.npmjs.com/package/salesforcedx) as of `48.18.0`.
10
+ This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
12
11
 
13
- To install it manually or install a specific plugin version, run the following.
14
- <!-- install -->
15
- ```sh-session
16
- $ sfdx plugins:install custom-metadata@1.0.0
12
+ We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ sfdx plugins:install custom-metadata@x.y.z
18
+ ```
19
+
20
+ ## Issues
21
+
22
+ Please report any issues at https://github.com/forcedotcom/cli/issues
23
+
24
+ ## Contributing
25
+
26
+ 1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
27
+ 2. Create a new issue before starting your project so that we can keep track of
28
+ what you are trying to add/fix. That way, we can also offer suggestions or
29
+ let you know if there is already an effort in progress.
30
+ 3. Fork this repository.
31
+ 4. [Build the plugin locally](#build)
32
+ 5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
33
+ 6. Edit the code in your fork.
34
+ 7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
35
+ 8. Sign CLA (see [CLA](#cla) below).
36
+ 9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
37
+
38
+ ### CLA
39
+
40
+ External contributors will be required to sign a Contributor's License
41
+ Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
42
+
43
+ ### Build
44
+
45
+ To build the plugin locally, make sure to have yarn installed and run the following commands:
46
+
47
+ ```bash
48
+ # Clone the repository
49
+ git clone git@github.com:salesforcecli/plugin-custom-metadata
50
+
51
+ # Install the dependencies and compile
52
+ yarn install
53
+ yarn build
54
+ ```
55
+
56
+ To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
57
+
58
+ ```bash
59
+ # Run using local run file.
60
+ ./bin/run force:cmdt
61
+ ```
62
+
63
+ There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
64
+
65
+ ```bash
66
+ # Link your plugin to the sfdx cli
67
+ sfdx plugins:link .
68
+ # To verify
69
+ sfdx plugins
17
70
  ```
18
71
 
19
72
  # Commands
@@ -55,13 +108,13 @@ OPTIONS
55
108
 
56
109
  EXAMPLES
57
110
  Create a custom metadata type with developer name 'MyCustomType'; this name will also be used as the label:
58
- $ sfdx force:cmdt:create --typename MyCustomType
111
+ $ sfdx force:cmdt:create --typename MyCustomType
59
112
  Create a protected custom metadata type with a specific label:
60
- $ sfdx force:cmdt:create --typename MyCustomType --label "Custom Type" --plurallabel "Custom Types" --visibility
113
+ $ sfdx force:cmdt:create --typename MyCustomType --label "Custom Type" --plurallabel "Custom Types" --visibility
61
114
  Protected
62
115
  ```
63
116
 
64
- _See code: [src/commands/force/cmdt/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.0.10/src/commands/force/cmdt/create.ts)_
117
+ _See code: [src/commands/force/cmdt/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.1.0/src/commands/force/cmdt/create.ts)_
65
118
 
66
119
  ## `sfdx force:cmdt:field:create -n <string> -f Checkbox|Date|DateTime|Email|Number|Percent|Phone|Picklist|Text|TextArea|LongTextArea|Url [-p <array>] [-s <number>] [-l <string>] [-d <directory>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
67
120
 
@@ -91,7 +144,7 @@ OPTIONS
91
144
  comma-separated list of picklist values; required for Picklist fields
92
145
 
93
146
  -s, --decimalplaces=decimalplaces
94
- number of decimal places to use for Number or Percent fields
147
+ [default: 0] number of decimal places to use for Number or Percent fields
95
148
 
96
149
  --json
97
150
  format output as json
@@ -101,14 +154,14 @@ OPTIONS
101
154
 
102
155
  EXAMPLES
103
156
  Create a metadata file for a custom checkbox field:
104
- $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Checkbox
157
+ $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Checkbox
105
158
  Create a metadata file for a custom picklist field:
106
- $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Picklist --picklistvalues "A,B,C"
159
+ $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Picklist --picklistvalues "A,B,C"
107
160
  Create a metadata file for a custom number field:
108
- $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Number --decimalplaces 2
161
+ $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Number --decimalplaces 2
109
162
  ```
110
163
 
111
- _See code: [src/commands/force/cmdt/field/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.0.10/src/commands/force/cmdt/field/create.ts)_
164
+ _See code: [src/commands/force/cmdt/field/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.1.0/src/commands/force/cmdt/field/create.ts)_
112
165
 
113
166
  ## `sfdx force:cmdt:generate -n <string> -s <string> [-l <string>] [-p <string>] [-v PackageProtected|Protected|Public] [-i] [-d <directory>] [-r <directory>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
114
167
 
@@ -136,10 +189,10 @@ OPTIONS
136
189
  -p, --plurallabel=plurallabel plural version of the label value;
137
190
  if blank, uses label
138
191
 
139
- -r, --recordsoutputdir=recordsoutputdir [default:
140
- force-app/main/default/customMetadat
141
- a/] directory to store newly-created
142
- custom metadata record files
192
+ -r, --recordsoutputdir=recordsoutputdir [default: force-app/main/default/cus
193
+ tomMetadata/] directory to store
194
+ newly-created custom metadata record
195
+ files
143
196
 
144
197
  -s, --sobjectname=sobjectname (required) API name of the sObject
145
198
  source for custom metadata
@@ -161,27 +214,27 @@ OPTIONS
161
214
 
162
215
  EXAMPLES
163
216
  Generate a custom metadata type from an sObject in the default target org:
164
- $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname MySourceObject__c
165
- Generate a custom metadata type from an sObject in the specified target org; ignore unsupported field types instead of
166
- converting them to text:
167
- $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname MySourceObject__c --ignoreunsupported --targetusername
217
+ $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname MySourceObject__c
218
+ Generate a custom metadata type from an sObject in the specified target org; ignore unsupported field types instead of
219
+ converting them to text:
220
+ $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname MySourceObject__c --ignoreunsupported --targetusername
168
221
  'alias or user email of the org containing the source type'
169
222
  Generate a protected custom metadata type from an sObject in the default target org:
170
- $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomObject__c --visibility Protected
223
+ $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomObject__c --visibility Protected
171
224
  Generate a protected custom metadata type with a specific label from an sObject in the default target org:
172
- $ sfdx force:cmdt:generate --devname MyCMDT --label "My CMDT" --plurallabel "My CMDTs" --sobjectname
225
+ $ sfdx force:cmdt:generate --devname MyCMDT --label "My CMDT" --plurallabel "My CMDTs" --sobjectname
173
226
  SourceCustomSetting__c --visibility Protected
174
- Generate a custom metadata type from an sObject in the default target org; put the resulting type metadata file in the
175
- specified directory:
176
- $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomSetting__c --typeoutputdir
227
+ Generate a custom metadata type from an sObject in the default target org; put the resulting type metadata file in the
228
+ specified directory:
229
+ $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomSetting__c --typeoutputdir
177
230
  'path/to/my/cmdt/directory'
178
231
  Generate a custom metadata type from an sObject in the default target org; put the resulting record metadata file(s)
179
232
  in the specified directory:
180
- $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomSetting__c --recordsoutputdir
233
+ $ sfdx force:cmdt:generate --devname MyCMDT --sobjectname SourceCustomSetting__c --recordsoutputdir
181
234
  'path/to/my/cmdt/record/directory'
182
235
  ```
183
236
 
184
- _See code: [src/commands/force/cmdt/generate.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.0.10/src/commands/force/cmdt/generate.ts)_
237
+ _See code: [src/commands/force/cmdt/generate.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.1.0/src/commands/force/cmdt/generate.ts)_
185
238
 
186
239
  ## `sfdx force:cmdt:record:create [name=value...] -t <string> -n <string> [-l <string>] [-p <string>] [-i <directory>] [-d <directory>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
187
240
 
@@ -193,10 +246,10 @@ USAGE
193
246
  [-d <directory>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
194
247
 
195
248
  OPTIONS
196
- -d, --outputdir=outputdir [default:
197
- force-app/main/default/customMetadat
198
- a] directory to store newly-created
199
- custom metadata record files
249
+ -d, --outputdir=outputdir [default: force-app/main/default/cus
250
+ tomMetadata] directory to store
251
+ newly-created custom metadata record
252
+ files
200
253
 
201
254
  -i, --inputdir=inputdir [default:
202
255
  force-app/main/default/objects]
@@ -220,15 +273,15 @@ OPTIONS
220
273
 
221
274
  EXAMPLES
222
275
  Create a record metadata file for custom metadata type 'MyCMT' with values specified for two custom fields:
223
- $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord My_Custom_Field_1=Foo
276
+ $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord My_Custom_Field_1=Foo
224
277
  My_Custom_Field_2=Bar
225
278
  Create a protected record metadata file for custom metadata type 'MyCMT' with a specific label and values specified
226
279
  for two custom fields:
227
- $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord --label "My Record" --protected true
280
+ $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord --label "My Record" --protected true
228
281
  My_Custom_Field_1=Foo My_Custom_Field_2=Bar
229
282
  ```
230
283
 
231
- _See code: [src/commands/force/cmdt/record/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.0.10/src/commands/force/cmdt/record/create.ts)_
284
+ _See code: [src/commands/force/cmdt/record/create.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.1.0/src/commands/force/cmdt/record/create.ts)_
232
285
 
233
286
  ## `sfdx force:cmdt:record:insert -f <string> -t <string> [-i <directory>] [-d <directory>] [-n <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
234
287
 
@@ -240,10 +293,10 @@ USAGE
240
293
  [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
241
294
 
242
295
  OPTIONS
243
- -d, --outputdir=outputdir [default:
244
- force-app/main/default/customMetadat
245
- a] directory to store newly-created
246
- custom metadata record files
296
+ -d, --outputdir=outputdir [default: force-app/main/default/cus
297
+ tomMetadata] directory to store
298
+ newly-created custom metadata record
299
+ files
247
300
 
248
301
  -f, --filepath=filepath (required) path to the CSV file
249
302
 
@@ -266,14 +319,14 @@ OPTIONS
266
319
  EXAMPLES
267
320
  Create record metadata files for type 'My_CMDT_Name' (from your local project) based on values in a CSV file, using
268
321
  'Name' as the column that specifies the record name:
269
- $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name
322
+ $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name
270
323
  Create record metadata files for type 'My_CMDT_Name' (from the specified directory) based on values in a CSV file,
271
324
  using 'PrimaryKey' as the column that specifies the record name:
272
- $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name --inputdir
325
+ $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name --inputdir
273
326
  "path/to/my/cmdt/directory" --namecolumn "PrimaryKey"
274
327
  ```
275
328
 
276
- _See code: [src/commands/force/cmdt/record/insert.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.0.10/src/commands/force/cmdt/record/insert.ts)_
329
+ _See code: [src/commands/force/cmdt/record/insert.ts](https://github.com/salesforcecli/plugin-custom-metadata/blob/v1.1.0/src/commands/force/cmdt/record/insert.ts)_
277
330
  <!-- commandsstop -->
278
331
 
279
332
  <!-- debugging-your-plugin -->
@@ -8,11 +8,11 @@ export default class Create extends SfdxCommand {
8
8
  name: string;
9
9
  }[];
10
10
  protected static flagsConfig: {
11
- typename: flags.Discriminated<flags.Option<string>>;
12
- label: flags.Discriminated<flags.Option<string>>;
13
- plurallabel: flags.Discriminated<flags.Option<string>>;
11
+ typename: flags.Discriminated<flags.String>;
12
+ label: flags.Discriminated<flags.String>;
13
+ plurallabel: flags.Discriminated<flags.String>;
14
14
  visibility: flags.Discriminated<flags.Enum<string>>;
15
- outputdir: flags.Discriminated<flags.Option<string>>;
15
+ outputdir: flags.Discriminated<flags.String>;
16
16
  };
17
17
  protected static requiresProject: boolean;
18
18
  run(): Promise<AnyJson>;
@@ -1,96 +1,100 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2018-2020, salesforce.com, inc.
3
+ * Copyright (c) 2020, salesforce.com, inc.
4
4
  * All rights reserved.
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const command_1 = require("@salesforce/command");
10
+ const core_1 = require("@salesforce/core");
10
11
  const fileWriter_1 = require("../../../lib/helpers/fileWriter");
11
12
  const validationUtil_1 = require("../../../lib/helpers/validationUtil");
12
13
  const templates_1 = require("../../../lib/templates/templates");
13
14
  // Initialize Messages with the current plugin directory
14
- command_1.core.Messages.importMessagesDirectory(__dirname);
15
+ core_1.Messages.importMessagesDirectory(__dirname);
15
16
  // Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
16
17
  // or any library that is using the messages framework can also be loaded this way.
17
- const messages = command_1.core.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createType');
18
- let Create = /** @class */ (() => {
19
- class Create extends command_1.SfdxCommand {
20
- async run() {
21
- const typename = this.flags.typename; // this should become the new file name
22
- const label = this.flags.label || this.flags.typename.replace('__mdt', ''); // If a label is not provided default using the dev name. trim __mdt out
23
- const pluralLabel = this.flags.plurallabel || label;
24
- const visibility = this.flags.visibility || 'Public';
25
- const dir = this.flags.outputdir || '';
26
- const templates = new templates_1.Templates();
27
- const fileWriter = new fileWriter_1.FileWriter();
28
- let saveResults;
29
- const validator = new validationUtil_1.ValidationUtil();
30
- if (!validator.validateMetadataTypeName(typename)) {
31
- throw new command_1.core.SfdxError(messages.getMessage('errorNotValidAPIName', [typename]));
32
- }
33
- if (!validator.validateLessThanForty(label)) {
34
- throw new command_1.core.SfdxError(messages.getMessage('errorNotValidLabelName', [label]));
35
- }
36
- if (!validator.validateLessThanForty(pluralLabel)) {
37
- throw new command_1.core.SfdxError(messages.getMessage('errorNotValidPluralLabelName', [pluralLabel]));
38
- }
39
- const objectXML = templates.createObjectXML({ label, pluralLabel }, visibility);
40
- saveResults = await fileWriter.writeTypeFile(command_1.core.fs, dir, typename, objectXML);
41
- this.ux.log(messages.getMessage('targetDirectory', [saveResults.dir]));
42
- this.ux.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [saveResults.fileName]));
43
- return {
44
- typename,
45
- label,
46
- pluralLabel,
47
- visibility
48
- };
18
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createType');
19
+ class Create extends command_1.SfdxCommand {
20
+ async run() {
21
+ const typename = this.flags.typename; // this should become the new file name
22
+ const label = this.flags.label || this.flags.typename.replace('__mdt', ''); // If a label is not provided default using the dev name. trim __mdt out
23
+ const pluralLabel = this.flags.plurallabel || label;
24
+ const visibility = this.flags.visibility || 'Public';
25
+ const dir = this.flags.outputdir || '';
26
+ const templates = new templates_1.Templates();
27
+ const fileWriter = new fileWriter_1.FileWriter();
28
+ let saveResults;
29
+ const validator = new validationUtil_1.ValidationUtil();
30
+ if (!validator.validateMetadataTypeName(typename)) {
31
+ throw new core_1.SfdxError(messages.getMessage('errorNotValidAPIName', [typename]));
49
32
  }
33
+ if (!validator.validateLessThanForty(label)) {
34
+ throw new core_1.SfdxError(messages.getMessage('errorNotValidLabelName', [label]));
35
+ }
36
+ if (!validator.validateLessThanForty(pluralLabel)) {
37
+ throw new core_1.SfdxError(messages.getMessage('errorNotValidPluralLabelName', [pluralLabel]));
38
+ }
39
+ const objectXML = templates.createObjectXML({ label, pluralLabel }, visibility);
40
+ saveResults = await fileWriter.writeTypeFile(core_1.fs, dir, typename, objectXML);
41
+ this.ux.log(messages.getMessage('targetDirectory', [saveResults.dir]));
42
+ this.ux.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [
43
+ saveResults.fileName,
44
+ ]));
45
+ return {
46
+ typename,
47
+ label,
48
+ pluralLabel,
49
+ visibility,
50
+ };
50
51
  }
51
- Create.description = messages.getMessage('commandDescription');
52
- Create.longDescription = messages.getMessage('commandLongDescription');
53
- Create.examples = [
54
- messages.getMessage('exampleCaption1'),
55
- ' $ sfdx force:cmdt:create --typename MyCustomType',
56
- messages.getMessage('exampleCaption2'),
57
- ' $ sfdx force:cmdt:create --typename MyCustomType --label "' + messages.getMessage('labelFlagExample') + '" ' +
58
- '--plurallabel "' + messages.getMessage('plurallabelFlagExample') + '" --visibility Protected'
59
- ];
60
- Create.args = [{ name: 'file' }];
61
- Create.flagsConfig = {
62
- typename: command_1.flags.string({
63
- char: 'n',
64
- description: messages.getMessage('nameFlagDescription'),
65
- longDescription: messages.getMessage('nameFlagLongDescription'),
66
- required: true
67
- }),
68
- label: command_1.flags.string({
69
- char: 'l',
70
- description: messages.getMessage('labelFlagDescription'),
71
- longDescription: messages.getMessage('labelFlagLongDescription')
72
- }),
73
- plurallabel: command_1.flags.string({
74
- char: 'p',
75
- description: messages.getMessage('plurallabelFlagDescription'),
76
- longDescription: messages.getMessage('plurallabelFlagLongDescription')
77
- }),
78
- visibility: command_1.flags.enum({
79
- char: 'v',
80
- description: messages.getMessage('visibilityFlagDescription'),
81
- longDescription: messages.getMessage('visibilityFlagLongDescription'),
82
- options: ['PackageProtected', 'Protected', 'Public'],
83
- default: 'Public'
84
- }),
85
- outputdir: command_1.flags.directory({
86
- char: 'd',
87
- description: messages.getMessage('outputDirectoryFlagDescription'),
88
- longDescription: messages.getMessage('outputDirectoryFlagLongDescription')
89
- })
90
- };
91
- // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
92
- Create.requiresProject = true;
93
- return Create;
94
- })();
52
+ }
95
53
  exports.default = Create;
54
+ Create.description = messages.getMessage('commandDescription');
55
+ Create.longDescription = messages.getMessage('commandLongDescription');
56
+ Create.examples = [
57
+ messages.getMessage('exampleCaption1'),
58
+ ' $ sfdx force:cmdt:create --typename MyCustomType',
59
+ messages.getMessage('exampleCaption2'),
60
+ ' $ sfdx force:cmdt:create --typename MyCustomType --label "' +
61
+ messages.getMessage('labelFlagExample') +
62
+ '" ' +
63
+ '--plurallabel "' +
64
+ messages.getMessage('plurallabelFlagExample') +
65
+ '" --visibility Protected',
66
+ ];
67
+ Create.args = [{ name: 'file' }];
68
+ Create.flagsConfig = {
69
+ typename: command_1.flags.string({
70
+ char: 'n',
71
+ description: messages.getMessage('nameFlagDescription'),
72
+ longDescription: messages.getMessage('nameFlagLongDescription'),
73
+ required: true,
74
+ }),
75
+ label: command_1.flags.string({
76
+ char: 'l',
77
+ description: messages.getMessage('labelFlagDescription'),
78
+ longDescription: messages.getMessage('labelFlagLongDescription'),
79
+ }),
80
+ plurallabel: command_1.flags.string({
81
+ char: 'p',
82
+ description: messages.getMessage('plurallabelFlagDescription'),
83
+ longDescription: messages.getMessage('plurallabelFlagLongDescription'),
84
+ }),
85
+ visibility: command_1.flags.enum({
86
+ char: 'v',
87
+ description: messages.getMessage('visibilityFlagDescription'),
88
+ longDescription: messages.getMessage('visibilityFlagLongDescription'),
89
+ options: ['PackageProtected', 'Protected', 'Public'],
90
+ default: 'Public',
91
+ }),
92
+ outputdir: command_1.flags.directory({
93
+ char: 'd',
94
+ description: messages.getMessage('outputDirectoryFlagDescription'),
95
+ longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
96
+ }),
97
+ };
98
+ // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
99
+ Create.requiresProject = true;
96
100
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/force/cmdt/create.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,iDAA+D;AAE/D,gEAA6D;AAC7D,wEAAqE;AAErE,gEAA6D;AAE7D,wDAAwD;AACxD,cAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAEjD,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,YAAY,CAAC,CAAC;AAEhG;IAAA,MAAqB,MAAO,SAAQ,qBAAW;QAiDpC,KAAK,CAAC,GAAG;YACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,uCAAuC;YAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,wEAAwE;YACpJ,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC;YACpD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,QAAQ,CAAC;YACrD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,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AW,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC;QAC9D,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;KACvE,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,IAAI,CAAC;QACrB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;QAC7D,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC;QACrE,OAAO,EAAE,CAAC,kBAAkB,EAAE,WAAW,EAAE,QAAQ,CAAC;QACpD,OAAO,EAAE,QAAQ;KAClB,CAAC;IACF,SAAS,EAAE,eAAK,CAAC,SAAS,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;QAClE,eAAe,EAAE,QAAQ,CAAC,UAAU,CAClC,oCAAoC,CACrC;KACF,CAAC;CACH,CAAC;AAEF,uGAAuG;AACtF,sBAAe,GAAG,IAAI,CAAC"}
@@ -8,12 +8,12 @@ export default class Create extends SfdxCommand {
8
8
  name: string;
9
9
  }[];
10
10
  protected static flagsConfig: {
11
- fieldname: flags.Discriminated<flags.Option<string>>;
11
+ fieldname: flags.Discriminated<flags.String>;
12
12
  fieldtype: flags.Discriminated<flags.Enum<string>>;
13
13
  picklistvalues: flags.Discriminated<flags.Array<string>>;
14
14
  decimalplaces: flags.Discriminated<flags.Number>;
15
- label: flags.Discriminated<flags.Option<string>>;
16
- outputdir: flags.Discriminated<flags.Option<string>>;
15
+ label: flags.Discriminated<flags.String>;
16
+ outputdir: flags.Discriminated<flags.String>;
17
17
  };
18
18
  protected static requiresProject: boolean;
19
19
  run(): Promise<AnyJson>;