@salesforce/plugin-custom-metadata 1.0.11 → 2.0.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.
- package/CHANGELOG.md +23 -7
- package/LICENSE.txt +2 -2
- package/README.md +153 -149
- package/lib/commands/force/cmdt/create.d.ts +12 -6
- package/lib/commands/force/cmdt/create.js +80 -82
- package/lib/commands/force/cmdt/create.js.map +1 -1
- package/lib/commands/force/cmdt/field/create.d.ts +10 -5
- package/lib/commands/force/cmdt/field/create.js +98 -90
- package/lib/commands/force/cmdt/field/create.js.map +1 -1
- package/lib/commands/force/cmdt/generate.d.ts +12 -8
- package/lib/commands/force/cmdt/generate.js +199 -257
- package/lib/commands/force/cmdt/generate.js.map +1 -1
- package/lib/commands/force/cmdt/record/create.d.ts +20 -9
- package/lib/commands/force/cmdt/record/create.js +123 -125
- package/lib/commands/force/cmdt/record/create.js.map +1 -1
- package/lib/commands/force/cmdt/record/insert.d.ts +7 -7
- package/lib/commands/force/cmdt/record/insert.js +97 -109
- package/lib/commands/force/cmdt/record/insert.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/lib/helpers/createUtil.d.ts +10 -6
- package/lib/lib/helpers/createUtil.js +50 -98
- package/lib/lib/helpers/createUtil.js.map +1 -1
- package/lib/lib/helpers/fileWriter.d.ts +13 -11
- package/lib/lib/helpers/fileWriter.js +19 -27
- package/lib/lib/helpers/fileWriter.js.map +1 -1
- package/lib/lib/helpers/metadataUtil.d.ts +25 -51
- package/lib/lib/helpers/metadataUtil.js +58 -127
- package/lib/lib/helpers/metadataUtil.js.map +1 -1
- package/lib/lib/helpers/validationUtil.d.ts +25 -26
- package/lib/lib/helpers/validationUtil.js +69 -43
- package/lib/lib/helpers/validationUtil.js.map +1 -1
- package/lib/lib/interfaces/createConfig.d.ts +3 -2
- package/lib/lib/interfaces/createConfig.js +3 -3
- package/lib/lib/templates/templates.d.ts +10 -99
- package/lib/lib/templates/templates.js +52 -40
- package/lib/lib/templates/templates.js.map +1 -1
- package/messages/createField.json +22 -31
- package/messages/generate.json +38 -51
- package/messages/template.json +2 -2
- package/messages/validation.json +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +57 -46
- package/lib/lib/interfaces/customField.d.ts +0 -7
- package/lib/lib/interfaces/customField.js +0 -9
- package/lib/lib/interfaces/customField.js.map +0 -1
- package/lib/lib/interfaces/errorMessage.d.ts +0 -4
- package/lib/lib/interfaces/errorMessage.js +0 -9
- package/lib/lib/interfaces/errorMessage.js.map +0 -1
- package/lib/lib/interfaces/record.d.ts +0 -3
- package/lib/lib/interfaces/record.js +0 -9
- package/lib/lib/interfaces/record.js.map +0 -1
- package/lib/lib/interfaces/saveResults.d.ts +0 -5
- package/lib/lib/interfaces/saveResults.js +0 -9
- package/lib/lib/interfaces/saveResults.js.map +0 -1
|
@@ -1,96 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
4
|
/*
|
|
3
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
6
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
const fs = require("fs");
|
|
9
11
|
const command_1 = require("@salesforce/command");
|
|
12
|
+
const core_1 = require("@salesforce/core");
|
|
10
13
|
const fileWriter_1 = require("../../../lib/helpers/fileWriter");
|
|
11
14
|
const validationUtil_1 = require("../../../lib/helpers/validationUtil");
|
|
12
15
|
const templates_1 = require("../../../lib/templates/templates");
|
|
13
16
|
// Initialize Messages with the current plugin directory
|
|
14
|
-
|
|
17
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
15
18
|
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
|
|
16
19
|
// or any library that is using the messages framework can also be loaded this way.
|
|
17
|
-
const messages =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
};
|
|
49
|
-
}
|
|
20
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createType');
|
|
21
|
+
class Create extends command_1.SfdxCommand {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
23
|
+
async run() {
|
|
24
|
+
var _b, _c;
|
|
25
|
+
const typename = this.flags.typename; // this should become the new file name
|
|
26
|
+
const label = (_b = this.flags.label) !== null && _b !== void 0 ? _b : typename.replace('__mdt', ''); // If a label is not provided default using the dev name. trim __mdt out
|
|
27
|
+
const visibility = this.flags.visibility;
|
|
28
|
+
const pluralLabel = (_c = this.flags.plurallabel) !== null && _c !== void 0 ? _c : label;
|
|
29
|
+
const templates = new templates_1.Templates();
|
|
30
|
+
const fileWriter = new fileWriter_1.FileWriter();
|
|
31
|
+
const objectXML = templates.createObjectXML({ label, pluralLabel }, visibility);
|
|
32
|
+
const saveResults = await fileWriter.writeTypeFile(fs, this.flags.outputdir, typename, objectXML);
|
|
33
|
+
this.ux.log(messages.getMessage('targetDirectory', [saveResults.dir]));
|
|
34
|
+
this.ux.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [saveResults.fileName]));
|
|
35
|
+
return {
|
|
36
|
+
typename,
|
|
37
|
+
label,
|
|
38
|
+
pluralLabel,
|
|
39
|
+
visibility,
|
|
40
|
+
};
|
|
50
41
|
}
|
|
51
|
-
|
|
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
|
-
})();
|
|
42
|
+
}
|
|
95
43
|
exports.default = Create;
|
|
44
|
+
_a = Create;
|
|
45
|
+
Create.description = messages.getMessage('commandDescription');
|
|
46
|
+
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
47
|
+
Create.examples = [
|
|
48
|
+
messages.getMessage('exampleCaption1'),
|
|
49
|
+
' $ sfdx force:cmdt:create --typename MyCustomType',
|
|
50
|
+
messages.getMessage('exampleCaption2'),
|
|
51
|
+
' $ sfdx force:cmdt:create --typename MyCustomType --label "' +
|
|
52
|
+
messages.getMessage('labelFlagExample') +
|
|
53
|
+
'" ' +
|
|
54
|
+
'--plurallabel "' +
|
|
55
|
+
messages.getMessage('plurallabelFlagExample') +
|
|
56
|
+
'" --visibility Protected',
|
|
57
|
+
];
|
|
58
|
+
Create.args = [{ name: 'file' }];
|
|
59
|
+
Create.flagsConfig = {
|
|
60
|
+
typename: command_1.flags.string({
|
|
61
|
+
char: 'n',
|
|
62
|
+
description: messages.getMessage('nameFlagDescription'),
|
|
63
|
+
longDescription: messages.getMessage('nameFlagLongDescription'),
|
|
64
|
+
required: true,
|
|
65
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateMetadataTypeName)(input)),
|
|
66
|
+
}),
|
|
67
|
+
label: command_1.flags.string({
|
|
68
|
+
char: 'l',
|
|
69
|
+
description: messages.getMessage('labelFlagDescription'),
|
|
70
|
+
longDescription: messages.getMessage('labelFlagLongDescription'),
|
|
71
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateLessThanForty)(input, messages.getMessage('errorNotValidLabelName', [input]))),
|
|
72
|
+
}),
|
|
73
|
+
plurallabel: command_1.flags.string({
|
|
74
|
+
char: 'p',
|
|
75
|
+
description: messages.getMessage('plurallabelFlagDescription'),
|
|
76
|
+
longDescription: messages.getMessage('plurallabelFlagLongDescription'),
|
|
77
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateLessThanForty)(input, messages.getMessage('errorNotValidPluralLabelName', [input]))),
|
|
78
|
+
}),
|
|
79
|
+
visibility: command_1.flags.enum({
|
|
80
|
+
char: 'v',
|
|
81
|
+
description: messages.getMessage('visibilityFlagDescription'),
|
|
82
|
+
longDescription: messages.getMessage('visibilityFlagLongDescription'),
|
|
83
|
+
options: ['PackageProtected', 'Protected', 'Public'],
|
|
84
|
+
default: 'Public',
|
|
85
|
+
}),
|
|
86
|
+
outputdir: command_1.flags.directory({
|
|
87
|
+
char: 'd',
|
|
88
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
89
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
90
|
+
default: '',
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
Create.requiresProject = true;
|
|
96
94
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/force/cmdt/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/force/cmdt/create.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAC5C,gEAA6D;AAC7D,wEAAsG;AACtG,gEAA6D;AAE7D,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;A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BAAwB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACxG,CAAC;IACF,WAAW,EAAE,eAAK,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC;QAC9D,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;QACtE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CACrB,OAAO,CAAC,OAAO,CAAC,IAAA,sCAAqB,EAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC9G,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,CAAC,oCAAoC,CAAC;QAC1E,OAAO,EAAE,EAAE;KACZ,CAAC;CACF,CAAA;AAEe,sBAAe,GAAG,IAAK,CAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { flags, SfdxCommand } from '@salesforce/command';
|
|
2
|
-
|
|
2
|
+
interface CmdtFieldCreateResponse {
|
|
3
|
+
fieldName: string;
|
|
4
|
+
label: string;
|
|
5
|
+
fieldtype: string;
|
|
6
|
+
}
|
|
3
7
|
export default class Create extends SfdxCommand {
|
|
4
8
|
static description: string;
|
|
5
9
|
static longDescription: string;
|
|
@@ -8,13 +12,14 @@ export default class Create extends SfdxCommand {
|
|
|
8
12
|
name: string;
|
|
9
13
|
}[];
|
|
10
14
|
protected static flagsConfig: {
|
|
11
|
-
fieldname: flags.Discriminated<flags.
|
|
15
|
+
fieldname: flags.Discriminated<flags.String>;
|
|
12
16
|
fieldtype: flags.Discriminated<flags.Enum<string>>;
|
|
13
17
|
picklistvalues: flags.Discriminated<flags.Array<string>>;
|
|
14
18
|
decimalplaces: flags.Discriminated<flags.Number>;
|
|
15
|
-
label: flags.Discriminated<flags.
|
|
16
|
-
outputdir: flags.Discriminated<flags.
|
|
19
|
+
label: flags.Discriminated<flags.String>;
|
|
20
|
+
outputdir: flags.Discriminated<flags.String>;
|
|
17
21
|
};
|
|
18
22
|
protected static requiresProject: boolean;
|
|
19
|
-
run(): Promise<
|
|
23
|
+
run(): Promise<CmdtFieldCreateResponse>;
|
|
20
24
|
}
|
|
25
|
+
export {};
|
|
@@ -1,105 +1,113 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
4
|
/*
|
|
3
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
6
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
const fs = require("fs");
|
|
9
11
|
const command_1 = require("@salesforce/command");
|
|
12
|
+
const core_1 = require("@salesforce/core");
|
|
10
13
|
const fileWriter_1 = require("../../../../lib/helpers/fileWriter");
|
|
11
14
|
const validationUtil_1 = require("../../../../lib/helpers/validationUtil");
|
|
12
15
|
const templates_1 = require("../../../../lib/templates/templates");
|
|
13
16
|
// Initialize Messages with the current plugin directory
|
|
14
|
-
|
|
17
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
15
18
|
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
|
|
16
19
|
// or any library that is using the messages framework can also be loaded this way.
|
|
17
|
-
const messages =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!validator.validateAPIName(fieldName)) {
|
|
30
|
-
throw new command_1.core.SfdxError(messages.getMessage('invalidCustomFieldError', [fieldName]));
|
|
31
|
-
}
|
|
32
|
-
if (fieldtype === 'Picklist' && picklistvalues.length === 0) {
|
|
33
|
-
throw new command_1.core.SfdxError(messages.getMessage('picklistValuesNotSuppliedError'));
|
|
34
|
-
}
|
|
35
|
-
if (decimalplaces < 0) {
|
|
36
|
-
throw new command_1.core.SfdxError(messages.getMessage('invalidDecimalError'));
|
|
37
|
-
}
|
|
38
|
-
const templates = new templates_1.Templates();
|
|
39
|
-
const data = templates.createDefaultTypeStructure(fieldName, fieldtype, label, picklistvalues, decimalplaces);
|
|
40
|
-
const fieldXML = templates.createFieldXML(data, false);
|
|
41
|
-
const writer = new fileWriter_1.FileWriter();
|
|
42
|
-
saveResults = await writer.writeFieldFile(command_1.core.fs, dir, fieldName, fieldXML);
|
|
43
|
-
this.ux.log(messages.getMessage('targetDirectory', [saveResults.dir]));
|
|
44
|
-
this.ux.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [saveResults.fileName]));
|
|
45
|
-
// Return an object to be displayed with --json
|
|
46
|
-
return {
|
|
47
|
-
fieldName,
|
|
48
|
-
label,
|
|
49
|
-
fieldtype
|
|
50
|
-
};
|
|
20
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createField');
|
|
21
|
+
class Create extends command_1.SfdxCommand {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
23
|
+
async run() {
|
|
24
|
+
var _b, _c;
|
|
25
|
+
const fieldName = this.flags.fieldname; // this should become the new file name
|
|
26
|
+
const label = (_b = this.flags.label) !== null && _b !== void 0 ? _b : fieldName;
|
|
27
|
+
const fieldtype = this.flags.fieldtype;
|
|
28
|
+
const picklistvalues = (_c = this.flags.picklistvalues) !== null && _c !== void 0 ? _c : [];
|
|
29
|
+
const decimalplaces = this.flags.decimalplaces;
|
|
30
|
+
if (fieldtype === 'Picklist' && picklistvalues.length === 0) {
|
|
31
|
+
throw new core_1.SfError(messages.getMessage('picklistValuesNotSuppliedError'));
|
|
51
32
|
}
|
|
33
|
+
const templates = new templates_1.Templates();
|
|
34
|
+
const data = templates.createDefaultTypeStructure(fieldName, fieldtype, label, picklistvalues, decimalplaces);
|
|
35
|
+
const fieldXML = templates.createFieldXML(data, false);
|
|
36
|
+
const writer = new fileWriter_1.FileWriter();
|
|
37
|
+
const saveResults = await writer.writeFieldFile(fs, this.flags.outputdir, fieldName, fieldXML);
|
|
38
|
+
this.ux.log(messages.getMessage('targetDirectory', [saveResults.dir]));
|
|
39
|
+
this.ux.log(messages.getMessage(saveResults.updated ? 'fileUpdate' : 'fileCreated', [saveResults.fileName]));
|
|
40
|
+
return {
|
|
41
|
+
fieldName,
|
|
42
|
+
label,
|
|
43
|
+
fieldtype,
|
|
44
|
+
};
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
55
|
-
Create.examples = [
|
|
56
|
-
messages.getMessage('exampleCaption1'),
|
|
57
|
-
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Checkbox',
|
|
58
|
-
messages.getMessage('exampleCaption2'),
|
|
59
|
-
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Picklist --picklistvalues "A,B,C"',
|
|
60
|
-
messages.getMessage('exampleCaption3'),
|
|
61
|
-
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Number --decimalplaces 2'
|
|
62
|
-
];
|
|
63
|
-
Create.args = [{ name: 'file' }];
|
|
64
|
-
Create.flagsConfig = {
|
|
65
|
-
fieldname: command_1.flags.string({
|
|
66
|
-
char: 'n',
|
|
67
|
-
required: true,
|
|
68
|
-
description: messages.getMessage('nameFlagDescription'),
|
|
69
|
-
longDescription: messages.getMessage('nameFlagLongDescription')
|
|
70
|
-
}),
|
|
71
|
-
fieldtype: command_1.flags.enum({
|
|
72
|
-
char: 'f',
|
|
73
|
-
required: true,
|
|
74
|
-
description: messages.getMessage('fieldTypeDescription'),
|
|
75
|
-
longDescription: messages.getMessage('nameFlagLongDescription'),
|
|
76
|
-
options: ['Checkbox', 'Date', 'DateTime', 'Email', 'Number', 'Percent', 'Phone', 'Picklist', 'Text', 'TextArea', 'LongTextArea', 'Url']
|
|
77
|
-
}),
|
|
78
|
-
picklistvalues: command_1.flags.array({
|
|
79
|
-
char: 'p',
|
|
80
|
-
description: messages.getMessage('picklistValuesFlagDescription'),
|
|
81
|
-
longDescription: messages.getMessage('picklistValuesFlagLongDescription')
|
|
82
|
-
}),
|
|
83
|
-
decimalplaces: command_1.flags.number({
|
|
84
|
-
char: 's',
|
|
85
|
-
description: messages.getMessage('decimalplacesFlagDescription'),
|
|
86
|
-
longDescription: messages.getMessage('decimalplacesFlagLongDescription'),
|
|
87
|
-
default: 0
|
|
88
|
-
}),
|
|
89
|
-
label: command_1.flags.string({
|
|
90
|
-
char: 'l',
|
|
91
|
-
description: messages.getMessage('labelFlagDescription'),
|
|
92
|
-
longDescription: messages.getMessage('labelFlagLongDescription')
|
|
93
|
-
}),
|
|
94
|
-
outputdir: command_1.flags.directory({
|
|
95
|
-
char: 'd',
|
|
96
|
-
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
97
|
-
longDescription: messages.getMessage('outputDirectoryFlagLongDescription')
|
|
98
|
-
})
|
|
99
|
-
};
|
|
100
|
-
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
|
|
101
|
-
Create.requiresProject = true;
|
|
102
|
-
return Create;
|
|
103
|
-
})();
|
|
46
|
+
}
|
|
104
47
|
exports.default = Create;
|
|
48
|
+
_a = Create;
|
|
49
|
+
Create.description = messages.getMessage('commandDescription');
|
|
50
|
+
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
51
|
+
Create.examples = [
|
|
52
|
+
messages.getMessage('exampleCaption1'),
|
|
53
|
+
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Checkbox',
|
|
54
|
+
messages.getMessage('exampleCaption2'),
|
|
55
|
+
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Picklist --picklistvalues "A,B,C"',
|
|
56
|
+
messages.getMessage('exampleCaption3'),
|
|
57
|
+
' $ sfdx force:cmdt:field:create --fieldname MyField --fieldtype Number --decimalplaces 2',
|
|
58
|
+
];
|
|
59
|
+
Create.args = [{ name: 'file' }];
|
|
60
|
+
Create.flagsConfig = {
|
|
61
|
+
fieldname: command_1.flags.string({
|
|
62
|
+
char: 'n',
|
|
63
|
+
required: true,
|
|
64
|
+
description: messages.getMessage('nameFlagDescription'),
|
|
65
|
+
longDescription: messages.getMessage('nameFlagLongDescription'),
|
|
66
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateAPIName)(input, messages.getMessage('invalidCustomFieldError', [input]))),
|
|
67
|
+
}),
|
|
68
|
+
fieldtype: command_1.flags.enum({
|
|
69
|
+
char: 'f',
|
|
70
|
+
required: true,
|
|
71
|
+
description: messages.getMessage('fieldTypeDescription'),
|
|
72
|
+
longDescription: messages.getMessage('nameFlagLongDescription'),
|
|
73
|
+
options: [
|
|
74
|
+
'Checkbox',
|
|
75
|
+
'Date',
|
|
76
|
+
'DateTime',
|
|
77
|
+
'Email',
|
|
78
|
+
'Number',
|
|
79
|
+
'Percent',
|
|
80
|
+
'Phone',
|
|
81
|
+
'Picklist',
|
|
82
|
+
'Text',
|
|
83
|
+
'TextArea',
|
|
84
|
+
'LongTextArea',
|
|
85
|
+
'Url',
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
picklistvalues: command_1.flags.array({
|
|
89
|
+
char: 'p',
|
|
90
|
+
description: messages.getMessage('picklistValuesFlagDescription'),
|
|
91
|
+
longDescription: messages.getMessage('picklistValuesFlagLongDescription'),
|
|
92
|
+
}),
|
|
93
|
+
decimalplaces: command_1.flags.number({
|
|
94
|
+
char: 's',
|
|
95
|
+
description: messages.getMessage('decimalplacesFlagDescription'),
|
|
96
|
+
longDescription: messages.getMessage('decimalplacesFlagLongDescription'),
|
|
97
|
+
default: 0,
|
|
98
|
+
min: 0,
|
|
99
|
+
}),
|
|
100
|
+
label: command_1.flags.string({
|
|
101
|
+
char: 'l',
|
|
102
|
+
description: messages.getMessage('labelFlagDescription'),
|
|
103
|
+
longDescription: messages.getMessage('labelFlagLongDescription'),
|
|
104
|
+
}),
|
|
105
|
+
outputdir: command_1.flags.directory({
|
|
106
|
+
char: 'd',
|
|
107
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
108
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
109
|
+
default: '',
|
|
110
|
+
}),
|
|
111
|
+
};
|
|
112
|
+
Create.requiresProject = true;
|
|
105
113
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/field/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/field/create.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAAqD;AACrD,mEAAgE;AAChE,2EAAyE;AACzE,mEAAgE;AAEhE,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,aAAa,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
|
|
5
|
+
}
|
|
3
6
|
export default class Generate extends SfdxCommand {
|
|
4
7
|
static description: string;
|
|
5
8
|
static longDescription: string;
|
|
@@ -8,16 +11,17 @@ export default class Generate extends SfdxCommand {
|
|
|
8
11
|
name: string;
|
|
9
12
|
}[];
|
|
10
13
|
protected static flagsConfig: {
|
|
11
|
-
devname: flags.Discriminated<flags.
|
|
12
|
-
label: flags.Discriminated<flags.
|
|
13
|
-
plurallabel: flags.Discriminated<flags.
|
|
14
|
+
devname: flags.Discriminated<flags.String>;
|
|
15
|
+
label: flags.Discriminated<flags.String>;
|
|
16
|
+
plurallabel: flags.Discriminated<flags.String>;
|
|
14
17
|
visibility: flags.Discriminated<flags.Enum<string>>;
|
|
15
|
-
sobjectname: flags.Discriminated<flags.
|
|
18
|
+
sobjectname: flags.Discriminated<flags.String>;
|
|
16
19
|
ignoreunsupported: flags.Discriminated<flags.Boolean<boolean>>;
|
|
17
|
-
typeoutputdir: flags.Discriminated<flags.
|
|
18
|
-
recordsoutputdir: flags.Discriminated<flags.
|
|
20
|
+
typeoutputdir: flags.Discriminated<flags.String>;
|
|
21
|
+
recordsoutputdir: flags.Discriminated<flags.String>;
|
|
19
22
|
};
|
|
20
23
|
protected static requiresUsername: boolean;
|
|
21
24
|
protected static requiresProject: boolean;
|
|
22
|
-
run(): Promise<
|
|
25
|
+
run(): Promise<CmdtGenerateResponse>;
|
|
23
26
|
}
|
|
27
|
+
export {};
|