@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,142 +1,140 @@
|
|
|
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");
|
|
11
|
+
const path = require("path");
|
|
9
12
|
const command_1 = require("@salesforce/command");
|
|
13
|
+
const core_1 = require("@salesforce/core");
|
|
10
14
|
const createUtil_1 = require("../../../../lib/helpers/createUtil");
|
|
11
|
-
const fileWriter_1 = require("../../../../lib/helpers/fileWriter");
|
|
12
15
|
const validationUtil_1 = require("../../../../lib/helpers/validationUtil");
|
|
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
|
-
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
|
-
};
|
|
20
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'createRecord');
|
|
21
|
+
class Create extends command_1.SfdxCommand {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
23
|
+
async run() {
|
|
24
|
+
var _b;
|
|
25
|
+
try {
|
|
26
|
+
const createUtil = new createUtil_1.CreateUtil();
|
|
27
|
+
let typename = this.flags.typename;
|
|
28
|
+
const recordname = this.flags.recordname;
|
|
29
|
+
const label = (_b = this.flags.label) !== null && _b !== void 0 ? _b : recordname;
|
|
30
|
+
const protectedFlag = this.flags.protected === 'true';
|
|
31
|
+
const inputdir = this.flags.inputdir;
|
|
32
|
+
const outputdir = this.flags.outputdir;
|
|
33
|
+
const dirName = createUtil.appendDirectorySuffix(typename);
|
|
34
|
+
const fieldDirPath = path.join(inputdir, dirName, 'fields');
|
|
35
|
+
const fileNames = await fs.promises.readdir(fieldDirPath);
|
|
36
|
+
// forgive them if they passed in type__mdt, and cut off the __mdt
|
|
37
|
+
if (typename.endsWith('__mdt')) {
|
|
38
|
+
typename = typename.substring(0, typename.indexOf('__mdt'));
|
|
72
39
|
}
|
|
73
|
-
|
|
40
|
+
// if customMetadata folder does not exist, create it
|
|
41
|
+
await fs.promises.mkdir(outputdir, { recursive: true });
|
|
42
|
+
const fileData = await createUtil.getFileData(fieldDirPath, fileNames);
|
|
43
|
+
await createUtil.createRecord({
|
|
44
|
+
typename,
|
|
45
|
+
recordname,
|
|
46
|
+
label,
|
|
47
|
+
inputdir,
|
|
48
|
+
outputdir,
|
|
49
|
+
protected: protectedFlag,
|
|
50
|
+
varargs: this.varargs,
|
|
51
|
+
fileData,
|
|
52
|
+
});
|
|
53
|
+
this.ux.log(messages.getMessage('successResponse', [typename, recordname, label, protectedFlag, outputdir]));
|
|
54
|
+
// Return an object to be displayed with --json
|
|
55
|
+
return {
|
|
56
|
+
typename,
|
|
57
|
+
recordname,
|
|
58
|
+
label,
|
|
59
|
+
inputdir,
|
|
60
|
+
outputdir,
|
|
61
|
+
protectedFlag,
|
|
62
|
+
varargs: this.varargs,
|
|
63
|
+
fileData,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
if (err instanceof Error) {
|
|
74
68
|
this.ux.log(err.message);
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
|
-
|
|
79
|
-
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
80
|
-
Create.examples = [
|
|
81
|
-
messages.getMessage('exampleCaption1'),
|
|
82
|
-
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord My_Custom_Field_1=Foo My_Custom_Field_2=Bar',
|
|
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]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
|
|
138
|
-
Create.requiresProject = true;
|
|
139
|
-
return Create;
|
|
140
|
-
})();
|
|
72
|
+
}
|
|
141
73
|
exports.default = Create;
|
|
74
|
+
_a = Create;
|
|
75
|
+
Create.description = messages.getMessage('commandDescription');
|
|
76
|
+
Create.longDescription = messages.getMessage('commandLongDescription');
|
|
77
|
+
Create.examples = [
|
|
78
|
+
messages.getMessage('exampleCaption1'),
|
|
79
|
+
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord My_Custom_Field_1=Foo My_Custom_Field_2=Bar',
|
|
80
|
+
messages.getMessage('exampleCaption2'),
|
|
81
|
+
' $ sfdx force:cmdt:record:create --typename MyCMT__mdt --recordname MyRecord --label "' +
|
|
82
|
+
messages.getMessage('labelFlagExample') +
|
|
83
|
+
'" ' +
|
|
84
|
+
'--protected true My_Custom_Field_1=Foo My_Custom_Field_2=Bar',
|
|
85
|
+
];
|
|
86
|
+
Create.flagsConfig = {
|
|
87
|
+
typename: command_1.flags.string({
|
|
88
|
+
char: 't',
|
|
89
|
+
description: messages.getMessage('typenameFlagDescription'),
|
|
90
|
+
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
91
|
+
required: true,
|
|
92
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateMetadataTypeName)(input)),
|
|
93
|
+
}),
|
|
94
|
+
recordname: command_1.flags.string({
|
|
95
|
+
char: 'n',
|
|
96
|
+
description: messages.getMessage('recordNameFlagDescription'),
|
|
97
|
+
longDescription: messages.getMessage('recordNameFlagLongDescription'),
|
|
98
|
+
required: true,
|
|
99
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateMetadataRecordName)(input)),
|
|
100
|
+
}),
|
|
101
|
+
label: command_1.flags.string({
|
|
102
|
+
char: 'l',
|
|
103
|
+
description: messages.getMessage('labelFlagDescription'),
|
|
104
|
+
longDescription: messages.getMessage('labelFlagLongDescription'),
|
|
105
|
+
parse: async (input) => Promise.resolve((0, validationUtil_1.validateLessThanForty)(input, messages.getMessage('notAValidLabelNameError', [input]))),
|
|
106
|
+
}),
|
|
107
|
+
protected: command_1.flags.string({
|
|
108
|
+
char: 'p',
|
|
109
|
+
description: messages.getMessage('protectedFlagDescription'),
|
|
110
|
+
longDescription: messages.getMessage('protectedFlagLongDescription'),
|
|
111
|
+
options: ['true', 'false'],
|
|
112
|
+
default: 'false',
|
|
113
|
+
}),
|
|
114
|
+
inputdir: command_1.flags.directory({
|
|
115
|
+
char: 'i',
|
|
116
|
+
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
117
|
+
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
118
|
+
default: path.join('force-app', 'main', 'default', 'objects'),
|
|
119
|
+
}),
|
|
120
|
+
outputdir: command_1.flags.directory({
|
|
121
|
+
char: 'd',
|
|
122
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
123
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
124
|
+
default: path.join('force-app', 'main', 'default', 'customMetadata'),
|
|
125
|
+
}),
|
|
126
|
+
};
|
|
127
|
+
Create.varargs = {
|
|
128
|
+
required: false,
|
|
129
|
+
validator: (name) => {
|
|
130
|
+
// only custom fields allowed
|
|
131
|
+
if (!name.endsWith('__c')) {
|
|
132
|
+
const errMsg = `Invalid parameter [${name}] found`;
|
|
133
|
+
const errName = 'InvalidVarargName';
|
|
134
|
+
const errAction = messages.getMessage('errorInvalidCustomField');
|
|
135
|
+
throw new core_1.SfError(errMsg, errName, [errAction]);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
Create.requiresProject = true;
|
|
142
140
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/create.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,6BAA6B;AAC7B,iDAAyD;AACzD,2CAAqD;AAErD,mEAAgE;AAChE,2EAIgD;AAEhD,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,cAAc,CAAC,CA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,CAAC;QACjE,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,mCAAmC,CAAC;QACzE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;KAC9D,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,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,CAAC;KACrE,CAAC;CACF,CAAA;AAEe,cAAO,GAAG;IACzB,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,CAAC,IAAY,EAAQ,EAAE;QAChC,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,cAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;SACjD;IACH,CAAC;CACD,CAAA;AAEe,sBAAe,GAAG,IAAK,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { flags, SfdxCommand } from '@salesforce/command';
|
|
2
|
-
import {
|
|
2
|
+
import { CreateConfig } from '../../../../lib/interfaces/createConfig';
|
|
3
3
|
export default class Insert extends SfdxCommand {
|
|
4
4
|
static description: string;
|
|
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
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<CreateConfig[]>;
|
|
16
16
|
}
|
|
@@ -1,122 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
/*
|
|
3
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
5
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
6
|
+
* Licensed under the BSD 3-Clause license.
|
|
7
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const path = require("path");
|
|
9
11
|
const command_1 = require("@salesforce/command");
|
|
12
|
+
const core_1 = require("@salesforce/core");
|
|
10
13
|
const csv = require("../../../../../csvtojson");
|
|
11
14
|
const createUtil_1 = require("../../../../lib/helpers/createUtil");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const record = csvDataAry[0];
|
|
41
|
-
for (const key in record) {
|
|
42
|
-
if (!metadataTypeFields.includes(key)) {
|
|
43
|
-
throw new command_1.core.SfdxError(messages.getMessage('fieldNotFoundError', [key, typename]));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
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];
|
|
59
|
-
}
|
|
15
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
16
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-custom-metadata', 'insertRecord');
|
|
17
|
+
class Insert extends command_1.SfdxCommand {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
19
|
+
async run() {
|
|
20
|
+
const createUtil = new createUtil_1.CreateUtil();
|
|
21
|
+
const filepath = this.flags.filepath;
|
|
22
|
+
let typename = this.flags.typename;
|
|
23
|
+
const inputdir = this.flags.inputdir;
|
|
24
|
+
const outputdir = this.flags.outputdir;
|
|
25
|
+
const dirName = createUtil.appendDirectorySuffix(typename);
|
|
26
|
+
const fieldDirPath = path.join(inputdir, dirName, 'fields');
|
|
27
|
+
const fileNames = await fs.promises.readdir(fieldDirPath);
|
|
28
|
+
const nameField = this.flags.namecolumn;
|
|
29
|
+
// forgive them if they passed in type__mdt, and cut off the __mdt
|
|
30
|
+
if (typename.endsWith('__mdt')) {
|
|
31
|
+
typename = typename.substring(0, typename.indexOf('__mdt'));
|
|
32
|
+
}
|
|
33
|
+
// if customMetadata folder does not exist, create it
|
|
34
|
+
await fs.promises.mkdir(outputdir, { recursive: true });
|
|
35
|
+
const fileData = await createUtil.getFileData(fieldDirPath, fileNames);
|
|
36
|
+
const csvDataAry = (await csv().fromFile(filepath));
|
|
37
|
+
const metadataTypeFields = createUtil.getFieldNames(fileData, nameField);
|
|
38
|
+
if (csvDataAry.length > 0) {
|
|
39
|
+
const record = csvDataAry[0];
|
|
40
|
+
for (const key in record) {
|
|
41
|
+
if (!metadataTypeFields.includes(key)) {
|
|
42
|
+
throw new core_1.SfError(messages.getMessage('fieldNotFoundError', [key, typename]));
|
|
60
43
|
}
|
|
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
44
|
}
|
|
74
|
-
this.ux.log(messages.getMessage('successResponse', [filepath, outputdir]));
|
|
75
|
-
return ret;
|
|
76
45
|
}
|
|
46
|
+
// find the cmdt in the inputdir.
|
|
47
|
+
// loop through files and create records that match fields
|
|
48
|
+
const recordConfigs = csvDataAry.map((record) => ({
|
|
49
|
+
typename,
|
|
50
|
+
recordname: record[nameField].replace(' ', '_'),
|
|
51
|
+
label: record[nameField],
|
|
52
|
+
inputdir,
|
|
53
|
+
outputdir,
|
|
54
|
+
protected: false,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
56
|
+
varargs: Object.fromEntries(
|
|
57
|
+
// TODO: throw an error if any of the fields in the csvDataAry do not exist in the fileData
|
|
58
|
+
fileData.map((file) => (record[file.fullName] ? [file.fullName, record[file.fullName]] : []))),
|
|
59
|
+
fileData,
|
|
60
|
+
}));
|
|
61
|
+
await Promise.all(recordConfigs.map((r) => createUtil.createRecord(r)));
|
|
62
|
+
this.ux.log(messages.getMessage('successResponse', [filepath, outputdir]));
|
|
63
|
+
return recordConfigs;
|
|
77
64
|
}
|
|
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
|
-
})();
|
|
65
|
+
}
|
|
121
66
|
exports.default = Insert;
|
|
67
|
+
Insert.description = messages.getMessage('commandDescription');
|
|
68
|
+
Insert.longDescription = messages.getMessage('commandLongDescription');
|
|
69
|
+
Insert.examples = [
|
|
70
|
+
messages.getMessage('exampleCaption1'),
|
|
71
|
+
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name',
|
|
72
|
+
messages.getMessage('exampleCaption2'),
|
|
73
|
+
' $ sfdx force:cmdt:record:insert --filepath path/to/my.csv --typename My_CMDT_Name --inputdir "' +
|
|
74
|
+
messages.getMessage('inputDirectoryFlagExample') +
|
|
75
|
+
'" --namecolumn "PrimaryKey"',
|
|
76
|
+
];
|
|
77
|
+
Insert.flagsConfig = {
|
|
78
|
+
filepath: command_1.flags.string({
|
|
79
|
+
char: 'f',
|
|
80
|
+
description: messages.getMessage('filepathFlagDescription'),
|
|
81
|
+
longDescription: messages.getMessage('filepathFlagLongDescription'),
|
|
82
|
+
required: true,
|
|
83
|
+
}),
|
|
84
|
+
typename: command_1.flags.string({
|
|
85
|
+
char: 't',
|
|
86
|
+
description: messages.getMessage('typenameFlagDescription'),
|
|
87
|
+
longDescription: messages.getMessage('typenameFlagLongDescription'),
|
|
88
|
+
required: true,
|
|
89
|
+
}),
|
|
90
|
+
inputdir: command_1.flags.directory({
|
|
91
|
+
char: 'i',
|
|
92
|
+
description: messages.getMessage('inputDirectoryFlagDescription'),
|
|
93
|
+
longDescription: messages.getMessage('inputDirectoryFlagLongDescription'),
|
|
94
|
+
default: path.join('force-app', 'main', 'default', 'objects'),
|
|
95
|
+
}),
|
|
96
|
+
outputdir: command_1.flags.directory({
|
|
97
|
+
char: 'd',
|
|
98
|
+
description: messages.getMessage('outputDirectoryFlagDescription'),
|
|
99
|
+
longDescription: messages.getMessage('outputDirectoryFlagLongDescription'),
|
|
100
|
+
default: path.join('force-app', 'main', 'default', 'customMetadata'),
|
|
101
|
+
}),
|
|
102
|
+
namecolumn: command_1.flags.string({
|
|
103
|
+
char: 'n',
|
|
104
|
+
description: messages.getMessage('namecolumnFlagDescription'),
|
|
105
|
+
longDescription: messages.getMessage('namecolumnFlagLongDescription'),
|
|
106
|
+
default: 'Name',
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
109
|
+
Insert.requiresProject = true;
|
|
122
110
|
//# sourceMappingURL=insert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/insert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../../../../src/commands/force/cmdt/record/insert.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,6BAA6B;AAC7B,iDAAyD;AACzD,2CAAqD;AAErD,gDAAgD;AAChD,mEAAgE;AAGhE,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,cAAc,CAAC,CAAC;AAE7F,MAAqB,MAAO,SAAQ,qBAAW;IAgD7C,8DAA8D;IACvD,KAAK,CAAC,GAAG;QACd,MAAM,UAAU,GAAG,IAAI,uBAAU,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAkB,CAAC;QAC/C,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAkB,CAAC;QAC7C,MAAM,QAAQ,GAA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MAAM,CAAC;QACvB,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,MAAM;KAChB,CAAC;CACH,CAAC;AAEe,sBAAe,GAAG,IAAI,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
exports.default = {};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { CustomField } from 'jsforce/api/metadata';
|
|
1
2
|
import { CreateConfig } from '../interfaces/createConfig';
|
|
2
|
-
import { CustomField } from '../interfaces/customField';
|
|
3
3
|
export declare class CreateUtil {
|
|
4
|
-
private fieldTypeMap;
|
|
5
4
|
/**
|
|
6
5
|
* Number and Percent types will be int or double depending on their respective scale values.
|
|
7
6
|
* If the scale === 0, it is an int, otherwise it is a double
|
|
8
7
|
*/
|
|
9
|
-
constructor();
|
|
10
8
|
/**
|
|
11
9
|
* Creates the Custom Metadata Record
|
|
12
10
|
*
|
|
@@ -14,7 +12,13 @@ export declare class CreateUtil {
|
|
|
14
12
|
* @return void
|
|
15
13
|
*/
|
|
16
14
|
createRecord(createConfig: CreateConfig): Promise<void>;
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param fieldDirPath path to a /fields folder that contains all the fields to read
|
|
18
|
+
* @param fileNames filenames in that folder that should be read
|
|
19
|
+
* @returns CustomField[]
|
|
20
|
+
*/
|
|
21
|
+
getFileData(fieldDirPath: string, fileNames: string[]): Promise<CustomField[]>;
|
|
18
22
|
/**
|
|
19
23
|
* Filenames should have the suffix of '__mdt'. This will append that suffix if it does not exist.
|
|
20
24
|
*
|
|
@@ -36,7 +40,7 @@ export declare class CreateUtil {
|
|
|
36
40
|
* @param fieldName Name of the field
|
|
37
41
|
* @return {string} Data Type of the field.
|
|
38
42
|
*/
|
|
39
|
-
getFieldDataType(fileData?: CustomField[], fieldName?: string):
|
|
43
|
+
getFieldDataType(fileData?: CustomField[], fieldName?: string): CustomField['type'];
|
|
40
44
|
/**
|
|
41
45
|
* Goes through the file data that has been genreated and gets all of the field names and adds the
|
|
42
46
|
* name of the field that is used as the label for metadata record
|
|
@@ -45,7 +49,7 @@ export declare class CreateUtil {
|
|
|
45
49
|
* @param nameField name of the column that is going to be used for the name of the metadata record
|
|
46
50
|
* @return [] Array of field names
|
|
47
51
|
*/
|
|
48
|
-
getFieldNames(fileData:
|
|
52
|
+
getFieldNames(fileData: CustomField[], nameField: string): string[];
|
|
49
53
|
/**
|
|
50
54
|
* Takes JSON representation of CLI varargs and converts them to xml with help
|
|
51
55
|
* from helper.getFieldTemplate
|