sfdx-easy-sources 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +158 -0
  2. package/lib/commands/easysources/allmeta/merge.d.ts +15 -0
  3. package/lib/commands/easysources/allmeta/merge.js +47 -0
  4. package/lib/commands/easysources/allmeta/merge.js.map +1 -0
  5. package/lib/commands/easysources/allmeta/split.d.ts +11 -0
  6. package/lib/commands/easysources/allmeta/split.js +42 -0
  7. package/lib/commands/easysources/allmeta/split.js.map +1 -0
  8. package/lib/commands/easysources/allmeta/upsert.d.ts +11 -0
  9. package/lib/commands/easysources/allmeta/upsert.js +42 -0
  10. package/lib/commands/easysources/allmeta/upsert.js.map +1 -0
  11. package/lib/commands/easysources/applications/merge.d.ts +15 -0
  12. package/lib/commands/easysources/applications/merge.js +48 -0
  13. package/lib/commands/easysources/applications/merge.js.map +1 -0
  14. package/lib/commands/easysources/applications/split.d.ts +12 -0
  15. package/lib/commands/easysources/applications/split.js +47 -0
  16. package/lib/commands/easysources/applications/split.js.map +1 -0
  17. package/lib/commands/easysources/applications/updatekey.d.ts +11 -0
  18. package/lib/commands/easysources/applications/updatekey.js +43 -0
  19. package/lib/commands/easysources/applications/updatekey.js.map +1 -0
  20. package/lib/commands/easysources/applications/upsert.d.ts +15 -0
  21. package/lib/commands/easysources/applications/upsert.js +48 -0
  22. package/lib/commands/easysources/applications/upsert.js.map +1 -0
  23. package/lib/commands/easysources/globalvaluesets/merge.d.ts +15 -0
  24. package/lib/commands/easysources/globalvaluesets/merge.js +48 -0
  25. package/lib/commands/easysources/globalvaluesets/merge.js.map +1 -0
  26. package/lib/commands/easysources/globalvaluesets/split.d.ts +12 -0
  27. package/lib/commands/easysources/globalvaluesets/split.js +47 -0
  28. package/lib/commands/easysources/globalvaluesets/split.js.map +1 -0
  29. package/lib/commands/easysources/globalvaluesets/updatekey.d.ts +11 -0
  30. package/lib/commands/easysources/globalvaluesets/updatekey.js +43 -0
  31. package/lib/commands/easysources/globalvaluesets/updatekey.js.map +1 -0
  32. package/lib/commands/easysources/globalvaluesets/upsert.d.ts +15 -0
  33. package/lib/commands/easysources/globalvaluesets/upsert.js +48 -0
  34. package/lib/commands/easysources/globalvaluesets/upsert.js.map +1 -0
  35. package/lib/commands/easysources/globalvaluesettranslations/merge.d.ts +15 -0
  36. package/lib/commands/easysources/globalvaluesettranslations/merge.js +48 -0
  37. package/lib/commands/easysources/globalvaluesettranslations/merge.js.map +1 -0
  38. package/lib/commands/easysources/globalvaluesettranslations/split.d.ts +12 -0
  39. package/lib/commands/easysources/globalvaluesettranslations/split.js +47 -0
  40. package/lib/commands/easysources/globalvaluesettranslations/split.js.map +1 -0
  41. package/lib/commands/easysources/globalvaluesettranslations/updatekey.d.ts +11 -0
  42. package/lib/commands/easysources/globalvaluesettranslations/updatekey.js +43 -0
  43. package/lib/commands/easysources/globalvaluesettranslations/updatekey.js.map +1 -0
  44. package/lib/commands/easysources/globalvaluesettranslations/upsert.d.ts +15 -0
  45. package/lib/commands/easysources/globalvaluesettranslations/upsert.js +48 -0
  46. package/lib/commands/easysources/globalvaluesettranslations/upsert.js.map +1 -0
  47. package/lib/commands/easysources/labels/merge.d.ts +14 -0
  48. package/lib/commands/easysources/labels/merge.js +44 -0
  49. package/lib/commands/easysources/labels/merge.js.map +1 -0
  50. package/lib/commands/easysources/labels/split.d.ts +11 -0
  51. package/lib/commands/easysources/labels/split.js +43 -0
  52. package/lib/commands/easysources/labels/split.js.map +1 -0
  53. package/lib/commands/easysources/labels/updatekey.d.ts +10 -0
  54. package/lib/commands/easysources/labels/updatekey.js +39 -0
  55. package/lib/commands/easysources/labels/updatekey.js.map +1 -0
  56. package/lib/commands/easysources/labels/upsert.d.ts +14 -0
  57. package/lib/commands/easysources/labels/upsert.js +44 -0
  58. package/lib/commands/easysources/labels/upsert.js.map +1 -0
  59. package/lib/commands/easysources/permissionsets/delete.d.ts +16 -0
  60. package/lib/commands/easysources/permissionsets/delete.js +104 -0
  61. package/lib/commands/easysources/permissionsets/delete.js.map +1 -0
  62. package/lib/commands/easysources/permissionsets/merge.d.ts +15 -0
  63. package/lib/commands/easysources/permissionsets/merge.js +48 -0
  64. package/lib/commands/easysources/permissionsets/merge.js.map +1 -0
  65. package/lib/commands/easysources/permissionsets/split.d.ts +12 -0
  66. package/lib/commands/easysources/permissionsets/split.js +47 -0
  67. package/lib/commands/easysources/permissionsets/split.js.map +1 -0
  68. package/lib/commands/easysources/permissionsets/updatekey.d.ts +11 -0
  69. package/lib/commands/easysources/permissionsets/updatekey.js +43 -0
  70. package/lib/commands/easysources/permissionsets/updatekey.js.map +1 -0
  71. package/lib/commands/easysources/permissionsets/upsert.d.ts +15 -0
  72. package/lib/commands/easysources/permissionsets/upsert.js +48 -0
  73. package/lib/commands/easysources/permissionsets/upsert.js.map +1 -0
  74. package/lib/commands/easysources/profiles/delete.d.ts +16 -0
  75. package/lib/commands/easysources/profiles/delete.js +104 -0
  76. package/lib/commands/easysources/profiles/delete.js.map +1 -0
  77. package/lib/commands/easysources/profiles/merge.d.ts +15 -0
  78. package/lib/commands/easysources/profiles/merge.js +48 -0
  79. package/lib/commands/easysources/profiles/merge.js.map +1 -0
  80. package/lib/commands/easysources/profiles/split.d.ts +12 -0
  81. package/lib/commands/easysources/profiles/split.js +47 -0
  82. package/lib/commands/easysources/profiles/split.js.map +1 -0
  83. package/lib/commands/easysources/profiles/updatekey.d.ts +11 -0
  84. package/lib/commands/easysources/profiles/updatekey.js +43 -0
  85. package/lib/commands/easysources/profiles/updatekey.js.map +1 -0
  86. package/lib/commands/easysources/profiles/upsert.d.ts +15 -0
  87. package/lib/commands/easysources/profiles/upsert.js +48 -0
  88. package/lib/commands/easysources/profiles/upsert.js.map +1 -0
  89. package/lib/commands/easysources/recordtypes/delete.d.ts +17 -0
  90. package/lib/commands/easysources/recordtypes/delete.js +129 -0
  91. package/lib/commands/easysources/recordtypes/delete.js.map +1 -0
  92. package/lib/commands/easysources/recordtypes/merge.d.ts +16 -0
  93. package/lib/commands/easysources/recordtypes/merge.js +110 -0
  94. package/lib/commands/easysources/recordtypes/merge.js.map +1 -0
  95. package/lib/commands/easysources/recordtypes/split.d.ts +13 -0
  96. package/lib/commands/easysources/recordtypes/split.js +125 -0
  97. package/lib/commands/easysources/recordtypes/split.js.map +1 -0
  98. package/lib/commands/easysources/recordtypes/updatekey.d.ts +12 -0
  99. package/lib/commands/easysources/recordtypes/updatekey.js +104 -0
  100. package/lib/commands/easysources/recordtypes/updatekey.js.map +1 -0
  101. package/lib/commands/easysources/recordtypes/upsert.d.ts +16 -0
  102. package/lib/commands/easysources/recordtypes/upsert.js +144 -0
  103. package/lib/commands/easysources/recordtypes/upsert.js.map +1 -0
  104. package/lib/commands/hello/org.d.ts +17 -0
  105. package/lib/commands/hello/org.js +72 -0
  106. package/lib/commands/hello/org.js.map +1 -0
  107. package/lib/index.d.ts +2 -0
  108. package/lib/index.js +4 -0
  109. package/lib/index.js.map +1 -0
  110. package/lib/utils/commands/keyupdater.d.ts +3 -0
  111. package/lib/utils/commands/keyupdater.js +55 -0
  112. package/lib/utils/commands/keyupdater.js.map +1 -0
  113. package/lib/utils/commands/merger.d.ts +3 -0
  114. package/lib/utils/commands/merger.js +53 -0
  115. package/lib/utils/commands/merger.js.map +1 -0
  116. package/lib/utils/commands/splitter.d.ts +3 -0
  117. package/lib/utils/commands/splitter.js +73 -0
  118. package/lib/utils/commands/splitter.js.map +1 -0
  119. package/lib/utils/commands/upserter.d.ts +3 -0
  120. package/lib/utils/commands/upserter.js +85 -0
  121. package/lib/utils/commands/upserter.js.map +1 -0
  122. package/lib/utils/constants/constants.d.ts +6 -0
  123. package/lib/utils/constants/constants.js +10 -0
  124. package/lib/utils/constants/constants.js.map +1 -0
  125. package/lib/utils/constants/constants_applications.d.ts +13 -0
  126. package/lib/utils/constants/constants_applications.js +15 -0
  127. package/lib/utils/constants/constants_applications.js.map +1 -0
  128. package/lib/utils/constants/constants_globalvaluesets.d.ts +13 -0
  129. package/lib/utils/constants/constants_globalvaluesets.js +15 -0
  130. package/lib/utils/constants/constants_globalvaluesets.js.map +1 -0
  131. package/lib/utils/constants/constants_globalvaluesettranslations.d.ts +13 -0
  132. package/lib/utils/constants/constants_globalvaluesettranslations.js +15 -0
  133. package/lib/utils/constants/constants_globalvaluesettranslations.js.map +1 -0
  134. package/lib/utils/constants/constants_labels.d.ts +13 -0
  135. package/lib/utils/constants/constants_labels.js +15 -0
  136. package/lib/utils/constants/constants_labels.js.map +1 -0
  137. package/lib/utils/constants/constants_permissionsets.d.ts +83 -0
  138. package/lib/utils/constants/constants_permissionsets.js +55 -0
  139. package/lib/utils/constants/constants_permissionsets.js.map +1 -0
  140. package/lib/utils/constants/constants_profiles.d.ts +83 -0
  141. package/lib/utils/constants/constants_profiles.js +68 -0
  142. package/lib/utils/constants/constants_profiles.js.map +1 -0
  143. package/lib/utils/constants/constants_recordtypes.d.ts +13 -0
  144. package/lib/utils/constants/constants_recordtypes.js +15 -0
  145. package/lib/utils/constants/constants_recordtypes.js.map +1 -0
  146. package/lib/utils/filesUtils.d.ts +9 -0
  147. package/lib/utils/filesUtils.js +75 -0
  148. package/lib/utils/filesUtils.js.map +1 -0
  149. package/lib/utils/performance.d.ts +9 -0
  150. package/lib/utils/performance.js +22 -0
  151. package/lib/utils/performance.js.map +1 -0
  152. package/lib/utils/utils.d.ts +5 -0
  153. package/lib/utils/utils.js +84 -0
  154. package/lib/utils/utils.js.map +1 -0
  155. package/lib/utils/utils_recordtypes.d.ts +2 -0
  156. package/lib/utils/utils_recordtypes.js +37 -0
  157. package/lib/utils/utils_recordtypes.js.map +1 -0
  158. package/lib/utils/xmlFormatter.d.ts +4 -0
  159. package/lib/utils/xmlFormatter.js +18 -0
  160. package/lib/utils/xmlFormatter.js.map +1 -0
  161. package/messages/all_merge.json +11 -0
  162. package/messages/all_split.json +12 -0
  163. package/messages/all_upsert.json +11 -0
  164. package/messages/applications_merge.json +12 -0
  165. package/messages/applications_split.json +15 -0
  166. package/messages/applications_updatekey.json +11 -0
  167. package/messages/applications_upsert.json +12 -0
  168. package/messages/globalvaluesets_merge.json +12 -0
  169. package/messages/globalvaluesets_split.json +15 -0
  170. package/messages/globalvaluesets_updatekey.json +11 -0
  171. package/messages/globalvaluesets_upsert.json +12 -0
  172. package/messages/globalvaluesettranslations_merge.json +12 -0
  173. package/messages/globalvaluesettranslations_split.json +15 -0
  174. package/messages/globalvaluesettranslations_updatekey.json +11 -0
  175. package/messages/globalvaluesettranslations_upsert.json +12 -0
  176. package/messages/labels_merge.json +11 -0
  177. package/messages/labels_split.json +12 -0
  178. package/messages/labels_updatekey.json +10 -0
  179. package/messages/labels_upsert.json +11 -0
  180. package/messages/org.json +10 -0
  181. package/messages/permissionsets_delete.json +23 -0
  182. package/messages/permissionsets_merge.json +12 -0
  183. package/messages/permissionsets_split.json +15 -0
  184. package/messages/permissionsets_updatekey.json +11 -0
  185. package/messages/permissionsets_upsert.json +12 -0
  186. package/messages/profiles_delete.json +23 -0
  187. package/messages/profiles_merge.json +12 -0
  188. package/messages/profiles_split.json +15 -0
  189. package/messages/profiles_updatekey.json +11 -0
  190. package/messages/profiles_upsert.json +12 -0
  191. package/messages/recordtypes_delete.json +16 -0
  192. package/messages/recordtypes_merge.json +15 -0
  193. package/messages/recordtypes_split.json +16 -0
  194. package/messages/recordtypes_updatekey.json +13 -0
  195. package/messages/recordtypes_upsert.json +15 -0
  196. package/oclif.manifest.json +1 -0
  197. package/package.json +76 -0
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2020, salesforce.com, inc.
5
+ * All rights reserved.
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
8
+ */
9
+ const os = require("os");
10
+ const command_1 = require("@salesforce/command");
11
+ const core_1 = require("@salesforce/core");
12
+ const fs = require('fs-extra');
13
+ const path_1 = require("path");
14
+ const performance_1 = require("../../../utils/performance");
15
+ const constants_1 = require("../../../utils/constants/constants");
16
+ const constants_recordtypes_1 = require("../../../utils/constants/constants_recordtypes");
17
+ const filesUtils_1 = require("../../../utils/filesUtils");
18
+ const utils_1 = require("../../../utils/utils");
19
+ const utils_recordtypes_1 = require("../../../utils/utils_recordtypes");
20
+ // Initialize Messages with the current plugin directory
21
+ core_1.Messages.importMessagesDirectory(__dirname);
22
+ // Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
23
+ // or any library that is using the messages framework can also be loaded this way.
24
+ const messages = core_1.Messages.loadMessages('sfdx-easy-sources', 'recordtypes_merge');
25
+ class Merge extends command_1.SfdxCommand {
26
+ async run() {
27
+ performance_1.default.getInstance().start();
28
+ const baseInputDir = (0, path_1.join)((this.flags.dir || constants_1.DEFAULT_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
29
+ const baseOutputDir = this.flags.output == null ? baseInputDir : (0, path_1.join)(this.flags.output, constants_recordtypes_1.RECORDTYPES_SUBPATH);
30
+ const inputObject = (this.flags.object);
31
+ const inputRecordType = (this.flags.recordtype);
32
+ if (!fs.existsSync(baseInputDir)) {
33
+ console.log('Input folder ' + baseInputDir + ' does not exist!');
34
+ return;
35
+ }
36
+ var objectList = [];
37
+ if (inputObject) {
38
+ objectList = inputObject.split(',');
39
+ }
40
+ else {
41
+ objectList = fs.readdirSync(baseInputDir, { withFileTypes: true })
42
+ .filter(item => item.isDirectory())
43
+ .map(item => item.name);
44
+ }
45
+ for (const obj of objectList) {
46
+ if (!fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes')))
47
+ continue;
48
+ var recordTypeList = [];
49
+ if (inputRecordType) {
50
+ recordTypeList = inputRecordType.split(',');
51
+ }
52
+ else {
53
+ recordTypeList = fs.readdirSync((0, path_1.join)(baseInputDir, obj, 'recordTypes'), { withFileTypes: true })
54
+ .filter(item => item.isDirectory())
55
+ .map(item => item.name);
56
+ }
57
+ for (const dir of recordTypeList) {
58
+ console.log('Merging: ' + (0, path_1.join)(obj, dir));
59
+ const inputXML = (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir, dir) + constants_1.XML_PART_EXTENSION;
60
+ const mergedXml = (await (0, filesUtils_1.readXmlFromFile)(inputXML)) ?? {};
61
+ const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes');
62
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
63
+ const csvFilePath = (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
64
+ if (fs.existsSync(csvFilePath)) {
65
+ var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
66
+ jsonArray = (0, utils_1.sortByKey)(jsonArray);
67
+ for (var i in jsonArray) {
68
+ delete jsonArray[i]['_tagid'];
69
+ }
70
+ var jsonArrayForXML = (0, utils_recordtypes_1.transformCSVtoXML)(jsonArray);
71
+ mergedXml[constants_recordtypes_1.RECORDTYPES_ROOT_TAG][constants_recordtypes_1.RECORDTYPES_PICKVAL_ROOT] = jsonArrayForXML;
72
+ }
73
+ }
74
+ const outputFile = (0, path_1.join)(outputDir, dir + constants_recordtypes_1.RECORDTYPES_EXTENSION);
75
+ if (!fs.existsSync(outputDir)) {
76
+ fs.mkdirSync(outputDir);
77
+ }
78
+ (0, filesUtils_1.writeXmlToFile)(outputFile, mergedXml);
79
+ }
80
+ }
81
+ // dir is the record type name without the extension
82
+ performance_1.default.getInstance().end();
83
+ var outputString = 'OK';
84
+ return { outputString };
85
+ }
86
+ }
87
+ exports.default = Merge;
88
+ Merge.description = messages.getMessage('commandDescription');
89
+ Merge.examples = messages.getMessage('examples').split(os.EOL);
90
+ Merge.args = [{ name: 'file' }];
91
+ Merge.flagsConfig = {
92
+ // flag with a value (-n, --name=VALUE)
93
+ dir: command_1.flags.string({
94
+ char: 'd',
95
+ description: messages.getMessage('dirFlagDescription', [constants_1.DEFAULT_PATH]),
96
+ }),
97
+ object: command_1.flags.string({
98
+ char: 's',
99
+ description: messages.getMessage('objectFlagDescription'),
100
+ }),
101
+ recordtype: command_1.flags.string({
102
+ char: 'r',
103
+ description: messages.getMessage('recordtypeFlagDescription'),
104
+ }),
105
+ output: command_1.flags.string({
106
+ char: 'o',
107
+ description: messages.getMessage('outputFlagDescription', [constants_1.DEFAULT_PATH]),
108
+ })
109
+ };
110
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../src/commands/easysources/recordtypes/merge.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,4DAAqD;AAErD,kEAG4C;AAE5C,0FAMwD;AAExD,0DAAgH;AAChH,gDAAgD;AAChD,wEAAqE;AAGrE,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AAEjF,MAAqB,KAAM,SAAQ,qBAAW;IA2BnC,KAAK,CAAC,GAAG;QACZ,qBAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;QAElC,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,wBAAY,CAAC,EAAE,2CAAmB,CAAW,CAAC;QAC3F,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,2CAAmB,CAAW,CAAC;QACxH,MAAM,WAAW,GAA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@salesforce/command';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class Split extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ protected static flagsConfig: {
7
+ dir: flags.Discriminated<flags.String>;
8
+ object: flags.Discriminated<flags.String>;
9
+ recordtype: flags.Discriminated<flags.String>;
10
+ output: flags.Discriminated<flags.String>;
11
+ };
12
+ run(): Promise<AnyJson>;
13
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2020, salesforce.com, inc.
5
+ * All rights reserved.
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
8
+ */
9
+ const os = require("os");
10
+ const command_1 = require("@salesforce/command");
11
+ const core_1 = require("@salesforce/core");
12
+ const filesUtils_1 = require("../../../utils/filesUtils");
13
+ // import { generateTagId } from '../../../utils/utils'
14
+ const { Parser } = require('json2csv');
15
+ const constants_recordtypes_1 = require("../../../utils/constants/constants_recordtypes");
16
+ const performance_1 = require("../../../utils/performance");
17
+ const path_1 = require("path");
18
+ const utils_1 = require("../../../utils/utils");
19
+ const constants_1 = require("../../../utils/constants/constants");
20
+ const utils_recordtypes_1 = require("../../../utils/utils_recordtypes");
21
+ const fs = require('fs-extra');
22
+ // Initialize Messages with the current plugin directory
23
+ core_1.Messages.importMessagesDirectory(__dirname);
24
+ // Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
25
+ // or any library that is using the messages framework can also be loaded this way.
26
+ const messages = core_1.Messages.loadMessages('sfdx-easy-sources', 'recordtypes_split');
27
+ class Split extends command_1.SfdxCommand {
28
+ async run() {
29
+ performance_1.default.getInstance().start();
30
+ const baseInputDir = (0, path_1.join)((this.flags.dir || constants_1.DEFAULT_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
31
+ const baseOutputDir = this.flags.output == null ? baseInputDir : (0, path_1.join)(this.flags.output, constants_recordtypes_1.RECORDTYPES_SUBPATH);
32
+ const inputObject = (this.flags.object);
33
+ const inputRecordType = (this.flags.recordtype);
34
+ if (!fs.existsSync(baseInputDir)) {
35
+ console.log('Input folder ' + baseInputDir + ' does not exist!');
36
+ return;
37
+ }
38
+ var objectList = [];
39
+ if (inputObject) {
40
+ objectList = inputObject.split(',');
41
+ }
42
+ else {
43
+ objectList = fs.readdirSync(baseInputDir, { withFileTypes: true })
44
+ .filter(item => item.isDirectory())
45
+ .map(item => item.name);
46
+ }
47
+ for (const obj of objectList) {
48
+ if (!fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes')))
49
+ continue;
50
+ var recordTypeList = [];
51
+ if (inputRecordType) {
52
+ recordTypeList = inputRecordType.split(',');
53
+ }
54
+ else {
55
+ recordTypeList = fs.readdirSync((0, path_1.join)(baseInputDir, obj, 'recordTypes'), { withFileTypes: true })
56
+ .filter(item => !item.isDirectory() && item.name.endsWith(constants_recordtypes_1.RECORDTYPES_EXTENSION))
57
+ .map(item => item.name);
58
+ }
59
+ for (const filename of recordTypeList) {
60
+ console.log('Splitting: ' + (0, path_1.join)(obj, filename));
61
+ const inputFile = (0, path_1.join)(baseInputDir, obj, 'recordTypes', filename);
62
+ const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
63
+ const recordtypeProperties = xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
64
+ const recordTypeName = (0, filesUtils_1.removeExtension)(filename);
65
+ const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordTypeName);
66
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
67
+ var myjson = recordtypeProperties[constants_recordtypes_1.RECORDTYPES_PICKVAL_ROOT];
68
+ if (myjson == undefined)
69
+ continue;
70
+ if (!Array.isArray(myjson))
71
+ myjson = [myjson];
72
+ var jsforcsv = (0, utils_recordtypes_1.transformXMLtoCSV)(myjson);
73
+ // generate _tagId column
74
+ (0, utils_1.generateTagId)(jsforcsv, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
75
+ jsforcsv = (0, utils_1.sortByKey)(jsforcsv);
76
+ const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
77
+ const parser = new Parser({ fields: [...(0, utils_1.setDefault)(headers), '_tagid'] });
78
+ const csv = parser.parse(jsforcsv);
79
+ const outputFileCSV = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(recordTypeName, tag_section));
80
+ if (!fs.existsSync(outputDir)) {
81
+ fs.mkdirSync(outputDir, { recursive: true });
82
+ }
83
+ try {
84
+ fs.writeFileSync(outputFileCSV, csv, { flag: 'w+' });
85
+ // file written successfully
86
+ }
87
+ catch (err) {
88
+ console.error(err);
89
+ }
90
+ xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG][tag_section] = null;
91
+ }
92
+ if (fs.existsSync(outputDir)) {
93
+ const outputFileXML = (0, path_1.join)(outputDir, recordTypeName + constants_1.XML_PART_EXTENSION);
94
+ (0, filesUtils_1.writeXmlToFile)(outputFileXML, xmlFileContent);
95
+ }
96
+ }
97
+ }
98
+ performance_1.default.getInstance().end();
99
+ var outputString = 'OK';
100
+ return { outputString };
101
+ }
102
+ }
103
+ exports.default = Split;
104
+ Split.description = messages.getMessage('commandDescription');
105
+ Split.examples = messages.getMessage('examples').split(os.EOL);
106
+ Split.flagsConfig = {
107
+ // flag with a value (-n, --name=VALUE)
108
+ dir: command_1.flags.string({
109
+ char: 'd',
110
+ description: messages.getMessage('dirFlagDescription', [constants_1.DEFAULT_PATH]),
111
+ }),
112
+ object: command_1.flags.string({
113
+ char: 's',
114
+ description: messages.getMessage('objectFlagDescription'),
115
+ }),
116
+ recordtype: command_1.flags.string({
117
+ char: 'r',
118
+ description: messages.getMessage('recordtypeFlagDescription'),
119
+ }),
120
+ output: command_1.flags.string({
121
+ char: 'o',
122
+ description: messages.getMessage('outputFlagDescription', [constants_1.DEFAULT_PATH]),
123
+ }),
124
+ };
125
+ //# sourceMappingURL=split.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.js","sourceRoot":"","sources":["../../../../src/commands/easysources/recordtypes/split.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,0DAA6G;AAC7G,uDAAuD;AACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACvC,0FAA8K;AAC9K,4DAAqD;AACrD,+BAA4B;AAC5B,gDAA4E;AAC5E,kEAAsF;AACtF,wEAAqE;AACrE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AAEjF,MAAqB,KAAM,SAAQ,qBAAW;IA0BnC,KAAK,CAAC,GAAG;QACZ,qBAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;QAElC,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,wBAAY,CAAC,EAAE,2CAAmB,CAAW,CAAC;QAC3F,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,2CAAmB,CAAW,CAAC;QAExH,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAW,CAAC;QAClD,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,C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C3B,uCAAuC;IACvC,GAAG,EAAE,eAAK,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,wBAAY,CAAC,CAAC;KACzE,CAAC;IACF,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;KAC5D,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;KAChE,CAAC;IACF,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,wBAAY,CAAC,CAAC;KAC5E,CAAC;CACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class UpdateKey extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ protected static flagsConfig: {
7
+ dir: flags.Discriminated<flags.String>;
8
+ object: flags.Discriminated<flags.String>;
9
+ recordtype: flags.Discriminated<flags.String>;
10
+ };
11
+ run(): Promise<AnyJson>;
12
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2020, salesforce.com, inc.
5
+ * All rights reserved.
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
8
+ */
9
+ const os = require("os");
10
+ const command_1 = require("@salesforce/command");
11
+ const core_1 = require("@salesforce/core");
12
+ const filesUtils_1 = require("../../../utils/filesUtils");
13
+ const utils_1 = require("../../../utils/utils");
14
+ const { Parser, transforms: { unwind } } = require('json2csv');
15
+ const constants_1 = require("../../../utils/constants/constants");
16
+ const performance_1 = require("../../../utils/performance");
17
+ const path_1 = require("path");
18
+ const constants_recordtypes_1 = require("../../../utils/constants/constants_recordtypes");
19
+ const fs = require('fs-extra');
20
+ // Initialize Messages with the current plugin directory
21
+ core_1.Messages.importMessagesDirectory(__dirname);
22
+ // Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
23
+ // or any library that is using the messages framework can also be loaded this way.
24
+ const messages = core_1.Messages.loadMessages('sfdx-easy-sources', 'recordtypes_updatekey');
25
+ class UpdateKey extends command_1.SfdxCommand {
26
+ async run() {
27
+ performance_1.default.getInstance().start();
28
+ const baseInputDir = (0, path_1.join)((this.flags.dir || constants_1.DEFAULT_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
29
+ const inputObject = (this.flags.object);
30
+ const inputRecordType = (this.flags.recordtype);
31
+ if (!fs.existsSync(baseInputDir)) {
32
+ console.log('Input folder ' + baseInputDir + ' does not exist!');
33
+ return;
34
+ }
35
+ var objectList = [];
36
+ if (inputObject) {
37
+ objectList = inputObject.split(',');
38
+ }
39
+ else {
40
+ objectList = fs.readdirSync(baseInputDir, { withFileTypes: true })
41
+ .filter(item => item.isDirectory())
42
+ .map(item => item.name);
43
+ }
44
+ for (const obj of objectList) {
45
+ var recordTypeList = [];
46
+ if (inputRecordType) {
47
+ recordTypeList = inputRecordType.split(',');
48
+ }
49
+ else {
50
+ if (!fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes')))
51
+ continue;
52
+ recordTypeList = fs.readdirSync((0, path_1.join)(baseInputDir, obj, 'recordTypes'), { withFileTypes: true })
53
+ .filter(item => item.isDirectory())
54
+ .map(item => item.name);
55
+ }
56
+ // dir is the record type name without the extension
57
+ for (const dir of recordTypeList) {
58
+ console.log('UpdateKey: ' + dir);
59
+ // key is each profile section (applicationVisibilities, classAccess ecc)
60
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
61
+ const csvFilePath = (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
62
+ if (fs.existsSync(csvFilePath)) {
63
+ var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
64
+ (0, utils_1.generateTagId)(jsonArray, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
65
+ jsonArray = (0, utils_1.sortByKey)(jsonArray);
66
+ const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
67
+ const transforms = [unwind({ paths: headers })];
68
+ const parser = new Parser({ fields: [...(0, utils_1.setDefault)(headers), '_tagid'], transforms });
69
+ const csv = parser.parse(jsonArray);
70
+ try {
71
+ fs.writeFileSync(csvFilePath, csv, { flag: 'w+' });
72
+ // file written successfully
73
+ }
74
+ catch (err) {
75
+ console.error(err);
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ performance_1.default.getInstance().end();
82
+ var outputString = 'OK';
83
+ return { outputString };
84
+ }
85
+ }
86
+ exports.default = UpdateKey;
87
+ UpdateKey.description = messages.getMessage('commandDescription');
88
+ UpdateKey.examples = messages.getMessage('examples').split(os.EOL);
89
+ UpdateKey.flagsConfig = {
90
+ // flag with a value (-n, --name=VALUE)
91
+ dir: command_1.flags.string({
92
+ char: 'd',
93
+ description: messages.getMessage('dirFlagDescription', [constants_1.DEFAULT_PATH]),
94
+ }),
95
+ object: command_1.flags.string({
96
+ char: 's',
97
+ description: messages.getMessage('objectFlagDescription'),
98
+ }),
99
+ recordtype: command_1.flags.string({
100
+ char: 'r',
101
+ description: messages.getMessage('recordtypeFlagDescription'),
102
+ })
103
+ };
104
+ //# sourceMappingURL=updatekey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updatekey.js","sourceRoot":"","sources":["../../../../src/commands/easysources/recordtypes/updatekey.ts"],"names":[],"mappings":";;A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ACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,wBAAY,CAAC,CAAC;KACzE,CAAC;IACF,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;KAC5D,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;KAChE,CAAC;CACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class Upsert extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ static args: {
7
+ name: string;
8
+ }[];
9
+ protected static flagsConfig: {
10
+ dir: flags.Discriminated<flags.String>;
11
+ object: flags.Discriminated<flags.String>;
12
+ recordtype: flags.Discriminated<flags.String>;
13
+ output: flags.Discriminated<flags.String>;
14
+ };
15
+ run(): Promise<AnyJson>;
16
+ }
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2020, salesforce.com, inc.
5
+ * All rights reserved.
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
8
+ */
9
+ const os = require("os");
10
+ const command_1 = require("@salesforce/command");
11
+ const core_1 = require("@salesforce/core");
12
+ const filesUtils_1 = require("../../../utils/filesUtils");
13
+ const utils_1 = require("../../../utils/utils");
14
+ const { Parser, transforms: { unwind } } = require('json2csv');
15
+ const constants_1 = require("../../../utils/constants/constants");
16
+ const performance_1 = require("../../../utils/performance");
17
+ const path_1 = require("path");
18
+ const constants_recordtypes_1 = require("../../../utils/constants/constants_recordtypes");
19
+ const utils_recordtypes_1 = require("../../../utils/utils_recordtypes");
20
+ const fs = require('fs-extra');
21
+ // Initialize Messages with the current plugin directory
22
+ core_1.Messages.importMessagesDirectory(__dirname);
23
+ // Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
24
+ // or any library that is using the messages framework can also be loaded this way.
25
+ const messages = core_1.Messages.loadMessages('sfdx-easy-sources', 'recordtypes_upsert');
26
+ class Upsert extends command_1.SfdxCommand {
27
+ async run() {
28
+ performance_1.default.getInstance().start();
29
+ const baseInputDir = (0, path_1.join)((this.flags.dir || constants_1.DEFAULT_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
30
+ const baseOutputDir = this.flags.output == null ? baseInputDir : (0, path_1.join)(this.flags.output, constants_recordtypes_1.RECORDTYPES_SUBPATH);
31
+ const inputObject = (this.flags.object);
32
+ const inputRecordType = (this.flags.recordtype);
33
+ if (!fs.existsSync(baseInputDir)) {
34
+ console.log('Input folder ' + baseInputDir + ' does not exist!');
35
+ return;
36
+ }
37
+ var objectList = [];
38
+ if (inputObject) {
39
+ objectList = inputObject.split(',');
40
+ }
41
+ else {
42
+ objectList = fs.readdirSync(baseInputDir, { withFileTypes: true })
43
+ .filter(item => item.isDirectory())
44
+ .map(item => item.name);
45
+ }
46
+ for (const obj of objectList) {
47
+ var recordTypeList = [];
48
+ if (inputRecordType) {
49
+ recordTypeList = inputRecordType.split(',');
50
+ }
51
+ else {
52
+ if (!fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes')))
53
+ continue;
54
+ recordTypeList = fs.readdirSync((0, path_1.join)(baseInputDir, obj, 'recordTypes'), { withFileTypes: true })
55
+ .filter(item => !item.isDirectory() && item.name.endsWith(constants_recordtypes_1.RECORDTYPES_EXTENSION))
56
+ .map(item => item.name);
57
+ }
58
+ for (const filename of recordTypeList) {
59
+ console.log('Upserting: ' + filename);
60
+ const inputFile = (0, path_1.join)(baseInputDir, obj, 'recordTypes', filename);
61
+ const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
62
+ const recordtypeProperties = xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
63
+ const recordtypeName = (0, filesUtils_1.removeExtension)(filename);
64
+ const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName);
65
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
66
+ var jsonArray = recordtypeProperties[tag_section];
67
+ if (jsonArray == undefined)
68
+ continue;
69
+ if (!Array.isArray(jsonArray))
70
+ jsonArray = [jsonArray];
71
+ var jsonArrayNew = (0, utils_recordtypes_1.transformXMLtoCSV)(jsonArray);
72
+ (0, utils_1.generateTagId)(jsonArrayNew, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
73
+ const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
74
+ const transforms = [unwind({ paths: headers })];
75
+ const parser = new Parser({ fields: [...(0, utils_1.setDefault)(headers), '_tagid'], transforms });
76
+ const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
77
+ if (!fs.existsSync(outputDir)) {
78
+ fs.mkdirSync(outputDir);
79
+ }
80
+ if (fs.existsSync(outputFile)) {
81
+ const csvFilePath = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
82
+ var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(csvFilePath);
83
+ var jsonMapNew = (0, filesUtils_1.jsonArrayToMap)(jsonArrayNew);
84
+ for (var k in jsonMapNew) {
85
+ jsonMapOld[k] = jsonMapNew[k];
86
+ }
87
+ jsonArrayNew = Object.values(jsonMapOld);
88
+ }
89
+ try {
90
+ jsonArrayNew = (0, utils_1.sortByKey)(jsonArrayNew);
91
+ const csv = parser.parse(jsonArrayNew);
92
+ fs.writeFileSync(outputFile, csv, { flag: 'w+' });
93
+ // file written successfully
94
+ }
95
+ catch (err) {
96
+ console.error(err);
97
+ }
98
+ xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG][tag_section] = null;
99
+ }
100
+ const inputFilePart = (0, path_1.join)(baseInputDir, obj, 'recordTypes', recordtypeName, recordtypeName + constants_1.XML_PART_EXTENSION);
101
+ if (fs.existsSync(inputFilePart)) {
102
+ const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
103
+ const recordtypePropertiesPart = xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
104
+ for (var k in recordtypeProperties) {
105
+ recordtypePropertiesPart[k] = recordtypeProperties[k];
106
+ }
107
+ (0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
108
+ }
109
+ else {
110
+ if (fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes', recordtypeName))) {
111
+ (0, filesUtils_1.writeXmlToFile)(inputFilePart, recordtypeProperties);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ performance_1.default.getInstance().end();
117
+ var outputString = 'OK';
118
+ return { outputString };
119
+ }
120
+ }
121
+ exports.default = Upsert;
122
+ Upsert.description = messages.getMessage('commandDescription');
123
+ Upsert.examples = messages.getMessage('examples').split(os.EOL);
124
+ Upsert.args = [{ name: 'file' }];
125
+ Upsert.flagsConfig = {
126
+ // flag with a value (-n, --name=VALUE)
127
+ dir: command_1.flags.string({
128
+ char: 'd',
129
+ description: messages.getMessage('dirFlagDescription', [constants_1.DEFAULT_PATH]),
130
+ }),
131
+ object: command_1.flags.string({
132
+ char: 's',
133
+ description: messages.getMessage('objectFlagDescription'),
134
+ }),
135
+ recordtype: command_1.flags.string({
136
+ char: 'r',
137
+ description: messages.getMessage('recordtypeFlagDescription'),
138
+ }),
139
+ output: command_1.flags.string({
140
+ char: 'o',
141
+ description: messages.getMessage('outputFlagDescription', [constants_1.DEFAULT_PATH]),
142
+ }),
143
+ };
144
+ //# sour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AAC,CAAC;KACzE,CAAC;IACF,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;KAC5D,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;KAChE,CAAC;IACF,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,wBAAY,CAAC,CAAC;KAC5E,CAAC;CACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class Org extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ static args: {
7
+ name: string;
8
+ }[];
9
+ protected static flagsConfig: {
10
+ name: flags.Discriminated<flags.String>;
11
+ force: flags.Discriminated<flags.Boolean<boolean>>;
12
+ };
13
+ protected static requiresUsername: boolean;
14
+ protected static supportsDevhubUsername: boolean;
15
+ protected static requiresProject: boolean;
16
+ run(): Promise<AnyJson>;
17
+ }