@salesforce/plugin-custom-metadata 1.0.12 → 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.
- package/CHANGELOG.md +7 -0
- package/README.md +37 -37
- package/lib/commands/force/cmdt/create.d.ts +4 -4
- package/lib/commands/force/cmdt/create.js +84 -80
- package/lib/commands/force/cmdt/create.js.map +1 -1
- package/lib/commands/force/cmdt/field/create.d.ts +3 -3
- package/lib/commands/force/cmdt/field/create.js +102 -89
- package/lib/commands/force/cmdt/field/create.js.map +1 -1
- package/lib/commands/force/cmdt/generate.d.ts +6 -6
- package/lib/commands/force/cmdt/generate.js +256 -243
- package/lib/commands/force/cmdt/generate.js.map +1 -1
- package/lib/commands/force/cmdt/record/create.d.ts +6 -6
- package/lib/commands/force/cmdt/record/create.js +130 -124
- package/lib/commands/force/cmdt/record/create.js.map +1 -1
- package/lib/commands/force/cmdt/record/insert.d.ts +5 -5
- package/lib/commands/force/cmdt/record/insert.js +105 -105
- package/lib/commands/force/cmdt/record/insert.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/lib/helpers/createUtil.js +14 -10
- package/lib/lib/helpers/createUtil.js.map +1 -1
- package/lib/lib/helpers/fileWriter.d.ts +2 -0
- package/lib/lib/helpers/fileWriter.js +5 -3
- package/lib/lib/helpers/fileWriter.js.map +1 -1
- package/lib/lib/helpers/metadataUtil.d.ts +2 -2
- package/lib/lib/helpers/metadataUtil.js +22 -15
- package/lib/lib/helpers/metadataUtil.js.map +1 -1
- package/lib/lib/helpers/validationUtil.js +9 -6
- package/lib/lib/helpers/validationUtil.js.map +1 -1
- package/lib/lib/interfaces/createConfig.js +3 -3
- package/lib/lib/interfaces/customField.js +3 -3
- package/lib/lib/interfaces/errorMessage.js +3 -3
- package/lib/lib/interfaces/record.js +3 -3
- package/lib/lib/interfaces/saveResults.js +3 -3
- package/lib/lib/templates/templates.d.ts +2 -0
- package/lib/lib/templates/templates.js +64 -23
- package/lib/lib/templates/templates.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/commands/force/cmdt/generate.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/commands/force/cmdt/generate.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,iDAAyD;AACzD,2CAO0B;AAC1B,yCAA0C;AAC1C,mDAA0E;AAC1E,gEAA6D;AAC7D,gEAA6D;AAC7D,oEAAiE;AACjE,wEAAqE;AACrE,gEAA6D;AAE7D,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CACpC,oCAAoC,EACpC,UAAU,CACX,CAAC;AAEF,MAAqB,QAAS,SAAQ,qBAAW;IA4FxC,KAAK,CAAC,GAAG;QACd,uFAAuF;QACvF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAEtC,mDAAmD;QACnD,MAAM,SAAS,GAAG,IAAI,+BAAc,EAAE,CAAC;QAEvC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAElD,IAAI,QAAgB,CAAC;QACrB,IAAI,aAAyB,CAAC;QAC9B,IAAI,WAAW,CAAC;QAChB,gEAAgE;QAChE,IAAI,UAAU,EAAE;YACd,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,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@ export default class Create extends SfdxCommand {
|
|
|
5
5
|
static longDescription: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
protected static flagsConfig: {
|
|
8
|
-
typename: flags.Discriminated<flags.
|
|
9
|
-
recordname: flags.Discriminated<flags.
|
|
10
|
-
label: flags.Discriminated<flags.
|
|
11
|
-
protected: flags.Discriminated<flags.
|
|
12
|
-
inputdir: flags.Discriminated<flags.
|
|
13
|
-
outputdir: flags.Discriminated<flags.
|
|
8
|
+
typename: flags.Discriminated<flags.String>;
|
|
9
|
+
recordname: flags.Discriminated<flags.String>;
|
|
10
|
+
label: flags.Discriminated<flags.String>;
|
|
11
|
+
protected: flags.Discriminated<flags.String>;
|
|
12
|
+
inputdir: flags.Discriminated<flags.String>;
|
|
13
|
+
outputdir: flags.Discriminated<flags.String>;
|
|
14
14
|
};
|
|
15
15
|
protected static varargs: {
|
|
16
16
|
required: boolean;
|
|
@@ -1,142 +1,148 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
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 createUtil_1 = require("../../../../lib/helpers/createUtil");
|
|
11
12
|
const fileWriter_1 = require("../../../../lib/helpers/fileWriter");
|
|
12
13
|
const validationUtil_1 = require("../../../../lib/helpers/validationUtil");
|
|
13
14
|
// Initialize Messages with the current plugin directory
|
|
14
|
-
|
|
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 =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
throw new command_1.core.SfdxError(messages.getMessage('notValidAPINameError', [typename]));
|
|
35
|
-
}
|
|
36
|
-
if (!validator.validateMetadataRecordName(recordname)) {
|
|
37
|
-
throw new command_1.core.SfdxError(messages.getMessage('notAValidRecordNameError', [recordname]));
|
|
38
|
-
}
|
|
39
|
-
if (!validator.validateLessThanForty(label)) {
|
|
40
|
-
throw new command_1.core.SfdxError(messages.getMessage('notAValidLabelNameError', [label]));
|
|
41
|
-
}
|
|
42
|
-
const fileNames = await command_1.core.fs.readdir(fieldDirPath);
|
|
43
|
-
// forgive them if they passed in type__mdt, and cut off the __mdt
|
|
44
|
-
if (typename.endsWith('__mdt')) {
|
|
45
|
-
typename = typename.substring(0, typename.indexOf('__mdt'));
|
|
46
|
-
}
|
|
47
|
-
// if customMetadata folder does not exist, create it
|
|
48
|
-
await command_1.core.fs.mkdirp(outputdir);
|
|
49
|
-
const fileData = await createUtil.getFileData(fieldDirPath, fileNames);
|
|
50
|
-
await createUtil.createRecord({
|
|
51
|
-
typename,
|
|
52
|
-
recordname,
|
|
53
|
-
label,
|
|
54
|
-
inputdir,
|
|
55
|
-
outputdir,
|
|
56
|
-
protected: protectedFlag,
|
|
57
|
-
varargs: this.varargs,
|
|
58
|
-
fileData
|
|
59
|
-
});
|
|
60
|
-
this.ux.log(messages.getMessage('successResponse', [typename, recordname, label, protectedFlag, outputdir]));
|
|
61
|
-
// Return an object to be displayed with --json
|
|
62
|
-
return {
|
|
63
|
-
typename,
|
|
64
|
-
recordname,
|
|
65
|
-
label,
|
|
66
|
-
inputdir,
|
|
67
|
-
outputdir,
|
|
68
|
-
protectedFlag,
|
|
69
|
-
varargs: this.varargs,
|
|
70
|
-
fileData
|
|
71
|
-
};
|
|
18
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createRecord');
|
|
19
|
+
class Create extends command_1.SfdxCommand {
|
|
20
|
+
async run() {
|
|
21
|
+
try {
|
|
22
|
+
const validator = new validationUtil_1.ValidationUtil();
|
|
23
|
+
const createUtil = new createUtil_1.CreateUtil();
|
|
24
|
+
const fileWriter = new fileWriter_1.FileWriter();
|
|
25
|
+
let typename = this.flags.typename;
|
|
26
|
+
const recordname = this.flags.recordname;
|
|
27
|
+
const label = this.flags.label || this.flags.recordname;
|
|
28
|
+
const protectedFlag = this.flags.protected || 'false';
|
|
29
|
+
const inputdir = this.flags.inputdir || 'force-app/main/default/objects';
|
|
30
|
+
const outputdir = this.flags.outputdir || 'force-app/main/default/customMetadata';
|
|
31
|
+
const dirName = createUtil.appendDirectorySuffix(typename);
|
|
32
|
+
const fieldDirPath = `${fileWriter.createDir(inputdir)}${dirName}/fields`;
|
|
33
|
+
if (!validator.validateMetadataTypeName(typename)) {
|
|
34
|
+
throw new core_1.SfdxError(messages.getMessage('notValidAPINameError', [typename]));
|
|
72
35
|
}
|
|
73
|
-
|
|
74
|
-
|
|
36
|
+
if (!validator.validateMetadataRecordName(recordname)) {
|
|
37
|
+
throw new core_1.SfdxError(messages.getMessage('notAValidRecordNameError', [recordname]));
|
|
75
38
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
messages.getMessage('exampleCaption2'),
|
|
84
|
-
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord --label "' + messages.getMessage('labelFlagExample') + '" ' +
|
|
85
|
-
'--protected true My_Custom_Field_1=Foo My_Custom_Field_2=Bar'
|
|
86
|
-
];
|
|
87
|
-
Create.flagsConfig = {
|
|
88
|
-
typename: command_1.flags.string({
|
|
89
|
-
char: 't',
|
|
90
|
-
description: messages.getMessage('typenameFlagDescription'),
|
|
91
|
-
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
92
|
-
required: true
|
|
93
|
-
}),
|
|
94
|
-
recordname: command_1.flags.string({
|
|
95
|
-
char: 'n',
|
|
96
|
-
description: messages.getMessage('recordNameFlagDescription'),
|
|
97
|
-
longDescription: messages.getMessage('recordNameFlagLongDescription'),
|
|
98
|
-
required: true
|
|
99
|
-
}),
|
|
100
|
-
label: command_1.flags.string({
|
|
101
|
-
char: 'l',
|
|
102
|
-
description: messages.getMessage('labelFlagDescription'),
|
|
103
|
-
longDescription: messages.getMessage('labelFlagLongDescription')
|
|
104
|
-
}),
|
|
105
|
-
protected: command_1.flags.string({
|
|
106
|
-
char: 'p',
|
|
107
|
-
description: messages.getMessage('protectedFlagDescription'),
|
|
108
|
-
longDescription: messages.getMessage('protectedFlagLongDescription'),
|
|
109
|
-
options: ['true', 'false'],
|
|
110
|
-
default: 'false'
|
|
111
|
-
}),
|
|
112
|
-
inputdir: command_1.flags.directory({
|
|
113
|
-
char: 'i',
|
|
114
|
-
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
115
|
-
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
116
|
-
default: 'force-app/main/default/objects'
|
|
117
|
-
}),
|
|
118
|
-
outputdir: command_1.flags.directory({
|
|
119
|
-
char: 'd',
|
|
120
|
-
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
121
|
-
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
122
|
-
default: 'force-app/main/default/customMetadata'
|
|
123
|
-
})
|
|
124
|
-
};
|
|
125
|
-
Create.varargs = {
|
|
126
|
-
required: false,
|
|
127
|
-
validator: (name, value) => {
|
|
128
|
-
// only custom fields allowed
|
|
129
|
-
if (!name.endsWith('__c')) {
|
|
130
|
-
const errMsg = `Invalid parameter [${name}] found`;
|
|
131
|
-
const errName = 'InvalidVarargName';
|
|
132
|
-
const errAction = messages.getMessage('errorInvalidCustomField');
|
|
133
|
-
throw new command_1.core.SfdxError(errMsg, errName, [errAction]);
|
|
39
|
+
if (!validator.validateLessThanForty(label)) {
|
|
40
|
+
throw new core_1.SfdxError(messages.getMessage('notAValidLabelNameError', [label]));
|
|
41
|
+
}
|
|
42
|
+
const fileNames = await core_1.fs.readdir(fieldDirPath);
|
|
43
|
+
// forgive them if they passed in type__mdt, and cut off the __mdt
|
|
44
|
+
if (typename.endsWith('__mdt')) {
|
|
45
|
+
typename = typename.substring(0, typename.indexOf('__mdt'));
|
|
134
46
|
}
|
|
47
|
+
// if customMetadata folder does not exist, create it
|
|
48
|
+
await core_1.fs.mkdirp(outputdir);
|
|
49
|
+
const fileData = await createUtil.getFileData(fieldDirPath, fileNames);
|
|
50
|
+
await createUtil.createRecord({
|
|
51
|
+
typename,
|
|
52
|
+
recordname,
|
|
53
|
+
label,
|
|
54
|
+
inputdir,
|
|
55
|
+
outputdir,
|
|
56
|
+
protected: protectedFlag,
|
|
57
|
+
varargs: this.varargs,
|
|
58
|
+
fileData,
|
|
59
|
+
});
|
|
60
|
+
this.ux.log(messages.getMessage('successResponse', [
|
|
61
|
+
typename,
|
|
62
|
+
recordname,
|
|
63
|
+
label,
|
|
64
|
+
protectedFlag,
|
|
65
|
+
outputdir,
|
|
66
|
+
]));
|
|
67
|
+
// Return an object to be displayed with --json
|
|
68
|
+
return {
|
|
69
|
+
typename,
|
|
70
|
+
recordname,
|
|
71
|
+
label,
|
|
72
|
+
inputdir,
|
|
73
|
+
outputdir,
|
|
74
|
+
protectedFlag,
|
|
75
|
+
varargs: this.varargs,
|
|
76
|
+
fileData,
|
|
77
|
+
};
|
|
135
78
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
this.ux.log(err.message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
141
84
|
exports.default = Create;
|
|
85
|
+
Create.description = messages.getMessage('commandDescription');
|
|
86
|
+
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
87
|
+
Create.examples = [
|
|
88
|
+
messages.getMessage('exampleCaption1'),
|
|
89
|
+
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord My_Custom_Field_1=Foo My_Custom_Field_2=Bar',
|
|
90
|
+
messages.getMessage('exampleCaption2'),
|
|
91
|
+
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord --label "' +
|
|
92
|
+
messages.getMessage('labelFlagExample') +
|
|
93
|
+
'" ' +
|
|
94
|
+
'--protected true My_Custom_Field_1=Foo My_Custom_Field_2=Bar',
|
|
95
|
+
];
|
|
96
|
+
Create.flagsConfig = {
|
|
97
|
+
typename: command_1.flags.string({
|
|
98
|
+
char: 't',
|
|
99
|
+
description: messages.getMessage('typenameFlagDescription'),
|
|
100
|
+
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
101
|
+
required: true,
|
|
102
|
+
}),
|
|
103
|
+
recordname: command_1.flags.string({
|
|
104
|
+
char: 'n',
|
|
105
|
+
description: messages.getMessage('recordNameFlagDescription'),
|
|
106
|
+
longDescription: messages.getMessage('recordNameFlagLongDescription'),
|
|
107
|
+
required: true,
|
|
108
|
+
}),
|
|
109
|
+
label: command_1.flags.string({
|
|
110
|
+
char: 'l',
|
|
111
|
+
description: messages.getMessage('labelFlagDescription'),
|
|
112
|
+
longDescription: messages.getMessage('labelFlagLongDescription'),
|
|
113
|
+
}),
|
|
114
|
+
protected: command_1.flags.string({
|
|
115
|
+
char: 'p',
|
|
116
|
+
description: messages.getMessage('protectedFlagDescription'),
|
|
117
|
+
longDescription: messages.getMessage('protectedFlagLongDescription'),
|
|
118
|
+
options: ['true', 'false'],
|
|
119
|
+
default: 'false',
|
|
120
|
+
}),
|
|
121
|
+
inputdir: command_1.flags.directory({
|
|
122
|
+
char: 'i',
|
|
123
|
+
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
124
|
+
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
125
|
+
default: 'force-app/main/default/objects',
|
|
126
|
+
}),
|
|
127
|
+
outputdir: command_1.flags.directory({
|
|
128
|
+
char: 'd',
|
|
129
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
130
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
131
|
+
default: 'force-app/main/default/customMetadata',
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
Create.varargs = {
|
|
135
|
+
required: false,
|
|
136
|
+
validator: (name, value) => {
|
|
137
|
+
// only custom fields allowed
|
|
138
|
+
if (!name.endsWith('__c')) {
|
|
139
|
+
const errMsg = `Invalid parameter [${name}] found`;
|
|
140
|
+
const errName = 'InvalidVarargName';
|
|
141
|
+
const errAction = messages.getMessage('errorInvalidCustomField');
|
|
142
|
+
throw new core_1.SfdxError(errMsg, errName, [errAction]);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
|
|
147
|
+
Create.requiresProject = true;
|
|
142
148
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/create.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/create.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,iDAAyD;AACzD,2CAA2D;AAE3D,mEAAgE;AAChE,mEAAgE;AAChE,2EAAwE;AAExE,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,C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C1B,OAAO,EAAE,OAAO;KACjB,CAAC;IACF,QAAQ,EAAE,eAAK,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC;QACjE,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,mCAAmC,CAAC;QACzE,OAAO,EAAE,gCAAgC;KAC1C,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;QACD,OAAO,EAAE,uCAAuC;KACjD,CAAC;CACH,CAAC;AAEe,cAAO,GAAG;IACzB,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACzB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACzB,MAAM,MAAM,GAAG,sBAAsB,IAAI,SAAS,CAAC;YACnD,MAAM,OAAO,GAAG,mBAAmB,CAAC;YACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;YACjE,MAAM,IAAI,gBAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;SACnD;IACH,CAAC;CACF,CAAC;AAEF,uGAAuG;AACtF,sBAAe,GAAG,IAAI,CAAC"}
|
|
@@ -5,11 +5,11 @@ export default class Insert extends SfdxCommand {
|
|
|
5
5
|
static longDescription: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
protected static flagsConfig: {
|
|
8
|
-
filepath: flags.Discriminated<flags.
|
|
9
|
-
typename: flags.Discriminated<flags.
|
|
10
|
-
inputdir: flags.Discriminated<flags.
|
|
11
|
-
outputdir: flags.Discriminated<flags.
|
|
12
|
-
namecolumn: flags.Discriminated<flags.
|
|
8
|
+
filepath: flags.Discriminated<flags.String>;
|
|
9
|
+
typename: flags.Discriminated<flags.String>;
|
|
10
|
+
inputdir: flags.Discriminated<flags.String>;
|
|
11
|
+
outputdir: flags.Discriminated<flags.String>;
|
|
12
|
+
namecolumn: flags.Discriminated<flags.String>;
|
|
13
13
|
};
|
|
14
14
|
protected static requiresProject: boolean;
|
|
15
15
|
run(): Promise<AnyJson>;
|
|
@@ -1,122 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
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 csv = require("../../../../../csvtojson");
|
|
11
12
|
const createUtil_1 = require("../../../../lib/helpers/createUtil");
|
|
12
13
|
const fileWriter_1 = require("../../../../lib/helpers/fileWriter");
|
|
13
|
-
|
|
14
|
-
const messages =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
throw new command_1.core.SfdxError(messages.getMessage('fieldNotFoundError', [key, typename]));
|
|
44
|
-
}
|
|
14
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
15
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'insertRecord');
|
|
16
|
+
class Insert extends command_1.SfdxCommand {
|
|
17
|
+
async run() {
|
|
18
|
+
const createUtil = new createUtil_1.CreateUtil();
|
|
19
|
+
const fileWriter = new fileWriter_1.FileWriter();
|
|
20
|
+
const filepath = this.flags.filepath;
|
|
21
|
+
let typename = this.flags.typename;
|
|
22
|
+
const inputdir = this.flags.inputdir || 'force-app/main/default/objects';
|
|
23
|
+
const outputdir = this.flags.outputdir || 'force-app/main/default/customMetadata';
|
|
24
|
+
const dirName = createUtil.appendDirectorySuffix(typename);
|
|
25
|
+
const fieldDirPath = `${fileWriter.createDir(inputdir)}${dirName}/fields`;
|
|
26
|
+
const fileNames = await core_1.fs.readdir(fieldDirPath);
|
|
27
|
+
const nameField = this.flags.namecolumn || 'Name';
|
|
28
|
+
// forgive them if they passed in type__mdt, and cut off the __mdt
|
|
29
|
+
if (typename.endsWith('__mdt')) {
|
|
30
|
+
typename = typename.substring(0, typename.indexOf('__mdt'));
|
|
31
|
+
}
|
|
32
|
+
// if customMetadata folder does not exist, create it
|
|
33
|
+
await core_1.fs.mkdirp(outputdir);
|
|
34
|
+
const fileData = await createUtil.getFileData(fieldDirPath, fileNames);
|
|
35
|
+
const csvDataAry = await csv().fromFile(filepath);
|
|
36
|
+
let recordConfig;
|
|
37
|
+
const ret = [];
|
|
38
|
+
const metadataTypeFields = createUtil.getFieldNames(fileData, nameField);
|
|
39
|
+
if (csvDataAry.length > 0) {
|
|
40
|
+
const record = csvDataAry[0];
|
|
41
|
+
for (const key in record) {
|
|
42
|
+
if (!metadataTypeFields.includes(key)) {
|
|
43
|
+
throw new core_1.SfdxError(messages.getMessage('fieldNotFoundError', [key, typename]));
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
}
|
|
47
|
+
// find the cmdt in the inputdir.
|
|
48
|
+
// loop through files and create records that match fields
|
|
49
|
+
for (const record of csvDataAry) {
|
|
50
|
+
const recordname = record[nameField].replace(' ', '_');
|
|
51
|
+
const varargs = {};
|
|
52
|
+
// TODO: throw an error if any of the fields in the csvDataAry do not exist in the fileData
|
|
53
|
+
// create varargs
|
|
54
|
+
for (const file of fileData) {
|
|
55
|
+
const fullName = file.CustomField.fullName[0];
|
|
56
|
+
// only create fields indicated from the CSV
|
|
57
|
+
if (record.hasOwnProperty(fullName)) {
|
|
58
|
+
varargs[fullName] = record[fullName];
|
|
60
59
|
}
|
|
61
|
-
recordConfig = {
|
|
62
|
-
typename,
|
|
63
|
-
recordname,
|
|
64
|
-
label: record[nameField],
|
|
65
|
-
inputdir,
|
|
66
|
-
outputdir,
|
|
67
|
-
protected: false,
|
|
68
|
-
varargs,
|
|
69
|
-
fileData
|
|
70
|
-
};
|
|
71
|
-
ret.push(recordConfig);
|
|
72
|
-
await createUtil.createRecord(recordConfig);
|
|
73
60
|
}
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
recordConfig = {
|
|
62
|
+
typename,
|
|
63
|
+
recordname,
|
|
64
|
+
label: record[nameField],
|
|
65
|
+
inputdir,
|
|
66
|
+
outputdir,
|
|
67
|
+
protected: false,
|
|
68
|
+
varargs,
|
|
69
|
+
fileData,
|
|
70
|
+
};
|
|
71
|
+
ret.push(recordConfig);
|
|
72
|
+
await createUtil.createRecord(recordConfig);
|
|
76
73
|
}
|
|
74
|
+
this.ux.log(messages.getMessage('successResponse', [filepath, outputdir]));
|
|
75
|
+
return ret;
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
Insert.longDescription = messages.getMessage('commandLongDescription');
|
|
80
|
-
Insert.examples = [
|
|
81
|
-
messages.getMessage('exampleCaption1'),
|
|
82
|
-
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name',
|
|
83
|
-
messages.getMessage('exampleCaption2'),
|
|
84
|
-
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name --inputdir "' + messages.getMessage('inputDirectoryFlagExample') + '" --namecolumn "PrimaryKey"'
|
|
85
|
-
];
|
|
86
|
-
Insert.flagsConfig = {
|
|
87
|
-
filepath: command_1.flags.string({
|
|
88
|
-
char: 'f',
|
|
89
|
-
description: messages.getMessage('filepathFlagDescription'),
|
|
90
|
-
longDescription: messages.getMessage('filepathFlagLongDescription'),
|
|
91
|
-
required: true
|
|
92
|
-
}),
|
|
93
|
-
typename: command_1.flags.string({
|
|
94
|
-
char: 't',
|
|
95
|
-
description: messages.getMessage('typenameFlagDescription'),
|
|
96
|
-
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
97
|
-
required: true
|
|
98
|
-
}),
|
|
99
|
-
inputdir: command_1.flags.directory({
|
|
100
|
-
char: 'i',
|
|
101
|
-
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
102
|
-
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
103
|
-
default: 'force-app/main/default/objects'
|
|
104
|
-
}),
|
|
105
|
-
outputdir: command_1.flags.directory({
|
|
106
|
-
char: 'd',
|
|
107
|
-
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
108
|
-
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
109
|
-
default: 'force-app/main/default/customMetadata'
|
|
110
|
-
}),
|
|
111
|
-
namecolumn: command_1.flags.string({
|
|
112
|
-
char: 'n',
|
|
113
|
-
description: messages.getMessage('namecolumnFlagDescription'),
|
|
114
|
-
longDescription: messages.getMessage('namecolumnFlagLongDescription'),
|
|
115
|
-
default: 'Name'
|
|
116
|
-
})
|
|
117
|
-
};
|
|
118
|
-
Insert.requiresProject = true;
|
|
119
|
-
return Insert;
|
|
120
|
-
})();
|
|
77
|
+
}
|
|
121
78
|
exports.default = Insert;
|
|
79
|
+
Insert.description = messages.getMessage('commandDescription');
|
|
80
|
+
Insert.longDescription = messages.getMessage('commandLongDescription');
|
|
81
|
+
Insert.examples = [
|
|
82
|
+
messages.getMessage('exampleCaption1'),
|
|
83
|
+
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name',
|
|
84
|
+
messages.getMessage('exampleCaption2'),
|
|
85
|
+
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name --inputdir "' +
|
|
86
|
+
messages.getMessage('inputDirectoryFlagExample') +
|
|
87
|
+
'" --namecolumn "PrimaryKey"',
|
|
88
|
+
];
|
|
89
|
+
Insert.flagsConfig = {
|
|
90
|
+
filepath: command_1.flags.string({
|
|
91
|
+
char: 'f',
|
|
92
|
+
description: messages.getMessage('filepathFlagDescription'),
|
|
93
|
+
longDescription: messages.getMessage('filepathFlagLongDescription'),
|
|
94
|
+
required: true,
|
|
95
|
+
}),
|
|
96
|
+
typename: command_1.flags.string({
|
|
97
|
+
char: 't',
|
|
98
|
+
description: messages.getMessage('typenameFlagDescription'),
|
|
99
|
+
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
100
|
+
required: true,
|
|
101
|
+
}),
|
|
102
|
+
inputdir: command_1.flags.directory({
|
|
103
|
+
char: 'i',
|
|
104
|
+
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
105
|
+
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
106
|
+
default: 'force-app/main/default/objects',
|
|
107
|
+
}),
|
|
108
|
+
outputdir: command_1.flags.directory({
|
|
109
|
+
char: 'd',
|
|
110
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
111
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
112
|
+
default: 'force-app/main/default/customMetadata',
|
|
113
|
+
}),
|
|
114
|
+
namecolumn: command_1.flags.string({
|
|
115
|
+
char: 'n',
|
|
116
|
+
description: messages.getMessage('namecolumnFlagDescription'),
|
|
117
|
+
longDescription: messages.getMessage('namecolumnFlagLongDescription'),
|
|
118
|
+
default: 'Name',
|
|
119
|
+
}),
|
|
120
|
+
};
|
|
121
|
+
Insert.requiresProject = true;
|
|
122
122
|
//# sourceMappingURL=insert.js.map
|