@terafina/tffa-sfdx-plugin 0.1.2 → 1.0.1

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 (123) hide show
  1. package/README.md +5 -0
  2. package/assets/favicon.png +0 -0
  3. package/assets/highlight.css +68 -0
  4. package/assets/highlight.js +2801 -0
  5. package/assets/icon.png +0 -0
  6. package/assets/index.css +447 -0
  7. package/assets/index.js +411 -0
  8. package/assets/logo.png +0 -0
  9. package/assets/lunr.js +3471 -0
  10. package/assets/mark.js +13 -0
  11. package/assets/menu.js +34 -0
  12. package/assets/search.js +98 -0
  13. package/lib/apexdoc/common/apex-docs-error.d.ts +23 -0
  14. package/lib/apexdoc/common/apex-docs-error.js +28 -0
  15. package/lib/apexdoc/common/apex-docs-error.js.map +1 -0
  16. package/lib/apexdoc/common/array-utils.d.ts +9 -0
  17. package/lib/apexdoc/common/array-utils.js +36 -0
  18. package/lib/apexdoc/common/array-utils.js.map +1 -0
  19. package/lib/apexdoc/common/line-reader.d.ts +40 -0
  20. package/lib/apexdoc/common/line-reader.js +92 -0
  21. package/lib/apexdoc/common/line-reader.js.map +1 -0
  22. package/lib/apexdoc/common/models/apex-model.d.ts +51 -0
  23. package/lib/apexdoc/common/models/apex-model.js +264 -0
  24. package/lib/apexdoc/common/models/apex-model.js.map +1 -0
  25. package/lib/apexdoc/common/models/class-group.d.ts +10 -0
  26. package/lib/apexdoc/common/models/class-group.js +32 -0
  27. package/lib/apexdoc/common/models/class-group.js.map +1 -0
  28. package/lib/apexdoc/common/models/class-model.d.ts +38 -0
  29. package/lib/apexdoc/common/models/class-model.js +216 -0
  30. package/lib/apexdoc/common/models/class-model.js.map +1 -0
  31. package/lib/apexdoc/common/models/engine-config.d.ts +21 -0
  32. package/lib/apexdoc/common/models/engine-config.js +29 -0
  33. package/lib/apexdoc/common/models/engine-config.js.map +1 -0
  34. package/lib/apexdoc/common/models/enum-model.d.ts +15 -0
  35. package/lib/apexdoc/common/models/enum-model.js +47 -0
  36. package/lib/apexdoc/common/models/enum-model.js.map +1 -0
  37. package/lib/apexdoc/common/models/index.d.ts +10 -0
  38. package/lib/apexdoc/common/models/index.js +14 -0
  39. package/lib/apexdoc/common/models/index.js.map +1 -0
  40. package/lib/apexdoc/common/models/method-model.d.ts +26 -0
  41. package/lib/apexdoc/common/models/method-model.js +309 -0
  42. package/lib/apexdoc/common/models/method-model.js.map +1 -0
  43. package/lib/apexdoc/common/models/property-model.d.ts +12 -0
  44. package/lib/apexdoc/common/models/property-model.js +47 -0
  45. package/lib/apexdoc/common/models/property-model.js.map +1 -0
  46. package/lib/apexdoc/common/models/top-level-model.d.ts +19 -0
  47. package/lib/apexdoc/common/models/top-level-model.js +32 -0
  48. package/lib/apexdoc/common/models/top-level-model.js.map +1 -0
  49. package/lib/apexdoc/common/settings.d.ts +55 -0
  50. package/lib/apexdoc/common/settings.js +124 -0
  51. package/lib/apexdoc/common/settings.js.map +1 -0
  52. package/lib/apexdoc/common/tags.d.ts +22 -0
  53. package/lib/apexdoc/common/tags.js +168 -0
  54. package/lib/apexdoc/common/tags.js.map +1 -0
  55. package/lib/apexdoc/common/utils.d.ts +38 -0
  56. package/lib/apexdoc/common/utils.js +198 -0
  57. package/lib/apexdoc/common/utils.js.map +1 -0
  58. package/lib/apexdoc/common/validator-engine.d.ts +24 -0
  59. package/lib/apexdoc/common/validator-engine.js +162 -0
  60. package/lib/apexdoc/common/validator-engine.js.map +1 -0
  61. package/lib/apexdoc/common/validator.d.ts +16 -0
  62. package/lib/apexdoc/common/validator.js +35 -0
  63. package/lib/apexdoc/common/validator.js.map +1 -0
  64. package/lib/apexdoc/engine/file-manager.d.ts +52 -0
  65. package/lib/apexdoc/engine/file-manager.js +390 -0
  66. package/lib/apexdoc/engine/file-manager.js.map +1 -0
  67. package/lib/apexdoc/engine/generators/generator-utils.d.ts +12 -0
  68. package/lib/apexdoc/engine/generators/generator-utils.js +100 -0
  69. package/lib/apexdoc/engine/generators/generator-utils.js.map +1 -0
  70. package/lib/apexdoc/engine/generators/menu-generator.d.ts +9 -0
  71. package/lib/apexdoc/engine/generators/menu-generator.js +81 -0
  72. package/lib/apexdoc/engine/generators/menu-generator.js.map +1 -0
  73. package/lib/apexdoc/engine/generators/models/child-enum-markup-generator.d.ts +10 -0
  74. package/lib/apexdoc/engine/generators/models/child-enum-markup-generator.js +65 -0
  75. package/lib/apexdoc/engine/generators/models/child-enum-markup-generator.js.map +1 -0
  76. package/lib/apexdoc/engine/generators/models/class-markup-generator.d.ts +8 -0
  77. package/lib/apexdoc/engine/generators/models/class-markup-generator.js +49 -0
  78. package/lib/apexdoc/engine/generators/models/class-markup-generator.js.map +1 -0
  79. package/lib/apexdoc/engine/generators/models/enum-markup-generator.d.ts +9 -0
  80. package/lib/apexdoc/engine/generators/models/enum-markup-generator.js +40 -0
  81. package/lib/apexdoc/engine/generators/models/enum-markup-generator.js.map +1 -0
  82. package/lib/apexdoc/engine/generators/models/markup-generator.d.ts +27 -0
  83. package/lib/apexdoc/engine/generators/models/markup-generator.js +148 -0
  84. package/lib/apexdoc/engine/generators/models/markup-generator.js.map +1 -0
  85. package/lib/apexdoc/engine/generators/models/method-markup-generator.d.ts +22 -0
  86. package/lib/apexdoc/engine/generators/models/method-markup-generator.js +224 -0
  87. package/lib/apexdoc/engine/generators/models/method-markup-generator.js.map +1 -0
  88. package/lib/apexdoc/engine/generators/models/property-markup-generator.d.ts +11 -0
  89. package/lib/apexdoc/engine/generators/models/property-markup-generator.js +66 -0
  90. package/lib/apexdoc/engine/generators/models/property-markup-generator.js.map +1 -0
  91. package/lib/apexdoc/engine/generators/models/source-markup-generator.d.ts +10 -0
  92. package/lib/apexdoc/engine/generators/models/source-markup-generator.js +39 -0
  93. package/lib/apexdoc/engine/generators/models/source-markup-generator.js.map +1 -0
  94. package/lib/apexdoc/engine/generators/models/top-level-markup-generator.d.ts +10 -0
  95. package/lib/apexdoc/engine/generators/models/top-level-markup-generator.js +49 -0
  96. package/lib/apexdoc/engine/generators/models/top-level-markup-generator.js.map +1 -0
  97. package/lib/apexdoc/engine/generators/see-link-generator.d.ts +20 -0
  98. package/lib/apexdoc/engine/generators/see-link-generator.js +183 -0
  99. package/lib/apexdoc/engine/generators/see-link-generator.js.map +1 -0
  100. package/lib/commands/tffa/apexdoc.d.ts +29 -0
  101. package/lib/commands/tffa/apexdoc.js +272 -0
  102. package/lib/commands/tffa/apexdoc.js.map +1 -0
  103. package/lib/commands/tffa/ping.d.ts +3 -0
  104. package/lib/commands/tffa/ping.js +3 -0
  105. package/lib/commands/tffa/ping.js.map +1 -1
  106. package/lib/commands/tffa/scan.d.ts +52 -0
  107. package/lib/commands/tffa/scan.js +362 -0
  108. package/lib/commands/tffa/scan.js.map +1 -0
  109. package/lib/index.d.ts +3 -0
  110. package/lib/index.js +3 -0
  111. package/lib/index.js.map +1 -1
  112. package/lib/shared/model.d.ts +30 -0
  113. package/lib/shared/model.js +17 -0
  114. package/lib/shared/model.js.map +1 -0
  115. package/lib/shared/parser.d.ts +3 -0
  116. package/lib/shared/parser.js +101 -0
  117. package/lib/shared/parser.js.map +1 -0
  118. package/lib/shared/rules.d.ts +3 -0
  119. package/lib/shared/rules.js +5 -0
  120. package/lib/shared/rules.js.map +1 -0
  121. package/oclif.manifest.json +1 -1
  122. package/package.json +43 -21
  123. package/CHANGELOG.md +0 -14
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) NCR Terafina
4
+ **/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tslib_1 = require("tslib");
7
+ const command_1 = require("@salesforce/command");
8
+ const path = tslib_1.__importStar(require("path"));
9
+ const fs_1 = require("fs");
10
+ const child = tslib_1.__importStar(require("child_process"));
11
+ const util = tslib_1.__importStar(require("util"));
12
+ const core_1 = require("@salesforce/core");
13
+ class Scan extends command_1.SfdxCommand {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.minapi = 53.0;
17
+ this.dir = '';
18
+ this.allowedListEnd = [
19
+ 'Repository',
20
+ 'DTO',
21
+ 'Request',
22
+ 'Response',
23
+ 'Result',
24
+ 'Provider',
25
+ 'Service',
26
+ 'Controller',
27
+ 'Constants',
28
+ 'Job',
29
+ 'Executor',
30
+ 'Processor',
31
+ 'Ext',
32
+ 'Utlity',
33
+ 'Utils',
34
+ 'Util',
35
+ 'Resolver',
36
+ 'Factory',
37
+ 'EventExtension',
38
+ 'Exception',
39
+ 'Calculator',
40
+ 'Builder',
41
+ 'Type',
42
+ 'Logger',
43
+ 'Context',
44
+ 'Exporter',
45
+ 'Status',
46
+ 'Handler',
47
+ 'Client',
48
+ 'Serializer',
49
+ 'Parser',
50
+ 'Adapter',
51
+ 'Configuration',
52
+ 'Configurations',
53
+ 'Mapper',
54
+ 'Helper',
55
+ 'Extension',
56
+ 'Dom',
57
+ 'Render',
58
+ 'Record',
59
+ 'Records',
60
+ 'Generator',
61
+ 'Formatter',
62
+ 'Notifier',
63
+ 'Enricher',
64
+ 'Signer',
65
+ 'Batch',
66
+ 'Assigner',
67
+ 'Dispatcher',
68
+ 'Namespace',
69
+ 'Interaction',
70
+ 'Cipher',
71
+ 'APICall',
72
+ 'Cache',
73
+ 'Validator',
74
+ 'Evaluator',
75
+ 'Matcher',
76
+ 'Credential',
77
+ 'Comparator'
78
+ ];
79
+ this.allowedISVTEViolations = ['Translations', 'SECURITY_ENFORCED', 'Multiple Change Processes per Object'];
80
+ this.classFiles = [];
81
+ this.violations = [];
82
+ this.allowedListStart = ['Migration', 'SObject'];
83
+ this.ignoreFiles = [
84
+ 'Logger',
85
+ 'AbstractRepository',
86
+ 'SObjectMapper',
87
+ 'ContentRepository',
88
+ 'DocumentRepository',
89
+ 'JobRepository',
90
+ 'QueryBuilder',
91
+ 'Migration_V4_3_0_3',
92
+ 'Migration_V5_1_0',
93
+ 'DisclosureTemplateConfigurationFactory',
94
+ 'EmailTemplateRepository',
95
+ 'EnvironmentConfigurationRepository',
96
+ 'MigrationExecutor',
97
+ 'Migration_V4_0_0_1',
98
+ 'Migration_V4_3_0_1',
99
+ 'Migration_V4_3_0_2',
100
+ 'Namespace',
101
+ 'OrganizationRepository',
102
+ 'PermissionRepository',
103
+ 'QueueRepository',
104
+ 'ServiceFactory',
105
+ 'StaticResourceRepository',
106
+ 'Migration_V4_3_0',
107
+ 'InstallationService',
108
+ 'RepositoryUtils',
109
+ 'SObjectSchema',
110
+ 'Migration_V4_3_0_4',
111
+ 'WellKnownResourceController',
112
+ 'MigrationScriptProvider',
113
+ 'Migration_V7_0_0_1',
114
+ 'Migration_V7_0_0',
115
+ 'UserRepository',
116
+ 'CustomNotificationTypeRepository',
117
+ 'DecisionStrategyConfigurationCache',
118
+ 'Migration_V4_0_0',
119
+ 'Migration_V13_0_0'
120
+ ];
121
+ this.ignoreCZFiles = [];
122
+ }
123
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
+ async run() {
125
+ //node ${JENKINS_HOME}/tf/jobs/sfdc/sh/tffa/lib/scan-violations.js $SRC_PATH $converted_code_path json > "${temp_path}/scan.json" || true
126
+ // const project = await SfdxProject.resolve(this.flags.sourcefolder);
127
+ // const projectJSON = project.getSfdxProjectJson().getContents();
128
+ // const model = new Inventory();
129
+ // model.namespace = projectJSON.namespace;
130
+ // model.sourceApiVersion = projectJSON.sourceApiVersion;
131
+ // model.minapi = this.flags.minapi;
132
+ // model.path = projectJSON.packageDirectories[0].path;
133
+ // model.fullpath = this.flags.sourcefolder + path.sep + model.path;
134
+ // model.codepath = model.fullpath + path.sep + 'main/default/';
135
+ // model.testpath = model.fullpath + path.sep + 'test/default/';
136
+ // model.languagescan = this.flags.json;
137
+ // parse(model);
138
+ // console.log(model);
139
+ const project = await core_1.SfdxProject.resolve(this.flags.sourcefolder);
140
+ this.dir = this.flags.sourcefolder + path.sep + '/app/main/default/classes';
141
+ this.classFiles = this.getFilesInDirectory(this.dir, '.cls');
142
+ Promise.all([
143
+ this.checkFileNameConvention(),
144
+ this.checkClassesForKeywords('System\\.debug', 'Use tffa.Logger instead'),
145
+ this.checkClassesForKeywords('\\.isCreateable', 'CRUD/FLS Checks are checked by tffa.AbstractRepository'),
146
+ this.checkClassesForKeywords('\\.isAccessible', 'CRUD/FLS Checks are checked by tffa.AbstractRepository'),
147
+ this.checkClassesForKeywords('\\.isUpdateable', 'CRUD/FLS Checks are checked by tffa.AbstractRepository'),
148
+ this.checkClassesForKeywords('tffa\\.AbstractRepository\\.', 'Do not call methods directly of an abstract class . Call methods from Repository classes extending tffa.AbstractRepository'),
149
+ this.checkClassesForKeywords('tffa\\.AbstractController\\.', 'Do not call methods directly of an abstract class . Call methods from Controllers classes extending tffa.AbstractController'),
150
+ this.checkClassesForKeywords('tffa\\.AbstractRESTService\\.', 'Do not call methods directly of an abstract class . Call methods from RESTService classes extending tffa.AbstractRESTService'),
151
+ this.checkClassesForKeywords('select ', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
152
+ this.checkClassesForKeywords('update ', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doUpdate method '),
153
+ this.checkClassesForKeywords('upsert ', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doUpsert method '),
154
+ this.checkClassesForKeywords('delete ', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doDelete method '),
155
+ this.checkClassesForKeywords('Database\\.query', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
156
+ this.checkClassesForKeywords('Database\\.update', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
157
+ this.checkClassesForKeywords('Database\\.insert', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
158
+ this.checkClassesForKeywords('Database\\.upsert', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
159
+ this.checkClassesForKeywords('Database\\.delete', 'Any SOQL should be encapsulated into Repository classes extending tffa.AbstractRepository. Use doQuery method '),
160
+ this.scanJSONFiles(this.flags.sourcefolder),
161
+ this.scanISVTEQuality(this.flags.mdoutfolder)
162
+ ])
163
+ .then(() => this.printViolations(this.flags.format))
164
+ .catch(error => {
165
+ console.error(error.message);
166
+ });
167
+ return '';
168
+ }
169
+ /**
170
+ * test file names as per conventions
171
+ */
172
+ checkFileNameConvention() {
173
+ return new Promise(resolve => {
174
+ const violatingFiles = [];
175
+ for (const file of this.classFiles) {
176
+ const filepath = path.join(this.dir, file);
177
+ if (path.extname(filepath) == '.cls') {
178
+ const filename = path.basename(filepath, '.cls');
179
+ if (!this.allowedListEnd.some(substring => filename.endsWith(substring)) &&
180
+ !this.allowedListStart.some(substring => filename.startsWith(substring))) {
181
+ violatingFiles.push(filename);
182
+ }
183
+ }
184
+ }
185
+ if (violatingFiles.length > 0) {
186
+ const o = {
187
+ label: 'Files violating naming conventions',
188
+ message: 'Classes should' + '\nend with [' + this.allowedListEnd.join(', ') + ']',
189
+ exceptions: violatingFiles,
190
+ category: 'INTERNAL',
191
+ level: 'FATAL'
192
+ };
193
+ this.violations.push(o);
194
+ }
195
+ resolve(null);
196
+ });
197
+ }
198
+ /**
199
+ * test class files for filter
200
+ * @param {*} keywords
201
+ * @param {*} hint
202
+ */
203
+ checkClassesForKeywords(keywords, hint) {
204
+ return new Promise(resolve => {
205
+ const violatingFiles = [];
206
+ // We want full words, so we use full word boundary in regex.
207
+ // const regex = new RegExp('^(?!.*(\\//|\\*)).*\\b' + keywords + '\\b', 'gim');
208
+ const regex = new RegExp("^(?!\\s*(\\'|\\//|\\*)\\s*).*(\\b" + keywords + '\\b).*$', 'gim');
209
+ // console.log(regex);
210
+ this.classFiles.forEach(file => {
211
+ const fileContent = fs_1.readFileSync(file);
212
+ const filec = fileContent.toString();
213
+ let found = false;
214
+ if (regex.test(filec)) {
215
+ const output = filec.match(regex);
216
+ for (let i = 0; i < output.length; ++i) {
217
+ if (output[i].indexOf("'") < 0 || output[i].toLowerCase().indexOf(keywords.toLowerCase()) < output[i].indexOf("'")) {
218
+ // console.log(path.basename(file, '.cls'));
219
+ // console.log(output[i]);
220
+ // console.log(output[i].indexOf(keywords));
221
+ // console.log(filec.indexOf("'"));
222
+ found = true;
223
+ break;
224
+ }
225
+ }
226
+ if (found) {
227
+ const filename = path.basename(file, '.cls');
228
+ if (this.ignoreFiles.indexOf(filename) < 0 && this.ignoreCZFiles.indexOf(filename) < 0) {
229
+ violatingFiles.push(filename);
230
+ }
231
+ }
232
+ }
233
+ });
234
+ if (violatingFiles.length > 0) {
235
+ const o = {
236
+ label: 'Instances of ' + keywords + ' keyword',
237
+ message: hint,
238
+ exceptions: violatingFiles,
239
+ category: 'INTERNAL',
240
+ level: 'FATAL'
241
+ };
242
+ this.violations.push(o);
243
+ }
244
+ resolve(null);
245
+ });
246
+ }
247
+ /**
248
+ * Using recursion, we find every file with the desired extention, even if its deeply nested in subfolders.
249
+ * @param {*} dir
250
+ * @param {*} ext
251
+ */
252
+ getFilesInDirectory(dir, ext) {
253
+ let files = [];
254
+ if (!fs_1.existsSync(dir)) {
255
+ throw Error(`Specified directory: ${dir} does not exist`);
256
+ }
257
+ fs_1.readdirSync(dir).forEach(file => {
258
+ const filePath = path.join(dir, file);
259
+ const stat = fs_1.lstatSync(filePath);
260
+ // If we hit a directory, apply our function to that dir. If we hit a file, add it to the array of files.
261
+ if (stat.isDirectory()) {
262
+ const nestedFiles = this.getFilesInDirectory(filePath, ext);
263
+ files = files.concat(nestedFiles);
264
+ }
265
+ else {
266
+ if (path.extname(file) === ext) {
267
+ files.push(filePath);
268
+ }
269
+ }
270
+ });
271
+ return files;
272
+ }
273
+ /**
274
+ * scan json files
275
+ */
276
+ async scanJSONFiles(path) {
277
+ const fileContent = fs_1.readFileSync(path + '/sfdx-project.json');
278
+ const obj = JSON.parse(fileContent.toString());
279
+ if (this.minapi > parseInt(obj['sourceApiVersion'])) {
280
+ // console.log(obj["sourceApiVersion"]);
281
+ const o = {
282
+ label: 'Project source api version not equal to ' + this.minapi,
283
+ message: 'Please update sourceApiVersion to ' + this.minapi + ' sfdx-project.json',
284
+ category: 'INTERNAL',
285
+ level: 'FATAL',
286
+ exceptions: [{ 0: 'sfdx-project.json' }]
287
+ };
288
+ this.violations.push(o);
289
+ }
290
+ }
291
+ /**
292
+ * scan ISVTE plugin for quality rules
293
+ * @param {} convertedPath
294
+ */
295
+ async scanISVTEQuality(convertedPath) {
296
+ try {
297
+ if (!convertedPath) {
298
+ return;
299
+ }
300
+ const exec = util.promisify(child.exec);
301
+ const { stdout, stderr } = await exec(`SFDX_JSON_TO_STDOUT=true sfdx isvte:mdscan -s ZeroInventory,Enablement,Alerts,Warnings --minapi ${this.minapi} --json -d ${convertedPath}`);
302
+ if (stderr) {
303
+ console.log('stderr:', stderr);
304
+ }
305
+ if (stdout) {
306
+ const obj = JSON.parse(stdout);
307
+ if (obj.status == 0 && obj.result.CodeQualityNotes) {
308
+ for (const o of obj.result.CodeQualityNotes) {
309
+ if (!this.allowedISVTEViolations.some(substring => o.message.includes(substring) || o.label.includes(substring))) {
310
+ o.message = o.message.replace('the minimum specified. Use the --minapi flag to adjust the minimum API version.', this.minapi);
311
+ o.category = 'ISVTE';
312
+ o.level = 'FATAL';
313
+ if (o && o.exceptions && o.exceptions.length > 0) {
314
+ this.violations.push(o);
315
+ }
316
+ }
317
+ }
318
+ }
319
+ }
320
+ }
321
+ catch (e) {
322
+ console.error(e); // should contain code (exit code) and signal (that caused the termination).
323
+ throw new Error(e);
324
+ }
325
+ }
326
+ /**
327
+ * print output
328
+ */
329
+ printViolations(option) {
330
+ if (option && option == 'json') {
331
+ console.log(JSON.stringify(this.violations, null, 4));
332
+ }
333
+ else {
334
+ for (const o of this.violations) {
335
+ console.log('---------------------------------------------------------------------------------');
336
+ console.log(o.category + ' - ' + o.level);
337
+ console.log(o.label + ' - ' + o.message);
338
+ console.table(o.exceptions);
339
+ }
340
+ }
341
+ }
342
+ }
343
+ exports.default = Scan;
344
+ Scan.description = 'scan a package and provide recommendations based on package inventory';
345
+ Scan.examples = [`Scan a package and provide inventory of metadata items :\t$sfdx tffa:scan`];
346
+ Scan.flagsConfig = {
347
+ sourcefolder: command_1.flags.directory({
348
+ char: 's',
349
+ description: 'directory containing package metadata',
350
+ default: '.'
351
+ }),
352
+ mdoutfolder: command_1.flags.directory({
353
+ char: 'm',
354
+ description: 'directory containing mdapi src metadata',
355
+ default: '.'
356
+ }),
357
+ format: command_1.flags.string({
358
+ char: 'f',
359
+ description: 'generate json output'
360
+ })
361
+ };
362
+ //# sourceMappingURL=scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/commands/tffa/scan.ts"],"names":[],"mappings":";AAAA;;IAEI;;;AAEJ,iDAAyD;AACzD,mDAA6B;AAC7B,2BAAsE;AACtE,6DAAuC;AACvC,mDAA6B;AAC7B,2CAA+C;AAE/C,MAAqB,IAAK,SAAQ,qBAAW;IAA7C;;QAKE,WAAM,GAAG,IAAI,CAAC;QACd,QAAG,GAAG,EAAE,CAAC;QAET,mBAAc,GAAG;YACf,YAAY;YACZ,KAAK;YACL,SAAS;YACT,UAAU;YACV,QAAQ;YACR,UAAU;YACV,SAAS;YACT,YAAY;YACZ,WAAW;YACX,KAAK;YACL,UAAU;YACV,WAAW;YACX,KAAK;YACL,QAAQ;YACR,OAAO;YACP,MAAM;YACN,UAAU;YACV,SAAS;YACT,gBAAgB;YAChB,WAAW;YACX,YAAY;YACZ,SAAS;YACT,MAAM;YACN,QAAQ;YACR,SAAS;YACT,UAAU;YACV,QAAQ;YACR,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,QAAQ;YACR,SAAS;YACT,eAAe;YACf,gBAAgB;YAChB,QAAQ;YACR,QAAQ;YACR,WAAW;YACX,KAAK;YACL,QAAQ;YACR,QAAQ;YACR,SAAS;YACT,WAAW;YACX,WAAW;YACX,UAAU;YACV,UAAU;YACV,QAAQ;YACR,OAAO;YACP,UAAU;YACV,YAAY;YACZ,WAAW;YACX,a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yright (c) NCR Terafina
4
+ **/
2
5
  export default _default;
package/lib/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Copyright (c) NCR Terafina
5
+ **/
3
6
  exports.default = {};
4
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,kBAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA;;IAEI;AACJ,kBAAe,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) NCR Terafina
3
+ **/
4
+ export declare class Inventory {
5
+ namespace: string;
6
+ path: string;
7
+ fullpath: string;
8
+ codepath: string;
9
+ testpath: string;
10
+ sourceApiVersion: string;
11
+ minapi: string;
12
+ languagescan: string;
13
+ apexcount: number;
14
+ classes: ClassModel[];
15
+ violations: Map<string, string[]>;
16
+ }
17
+ export declare class ClassModel {
18
+ name: string;
19
+ apiVersion: number;
20
+ hasFuture: boolean;
21
+ isController: boolean;
22
+ isRESTController: boolean;
23
+ isWebController: boolean;
24
+ hasAuraEnabled: boolean;
25
+ isBatchJob: boolean;
26
+ isRepository: boolean;
27
+ hasInvocable: boolean;
28
+ charCount: number;
29
+ fileNameViolation: boolean;
30
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassModel = exports.Inventory = void 0;
4
+ /**
5
+ * Copyright (c) NCR Terafina
6
+ **/
7
+ class Inventory {
8
+ constructor() {
9
+ this.classes = [];
10
+ this.violations = new Map();
11
+ }
12
+ }
13
+ exports.Inventory = Inventory;
14
+ class ClassModel {
15
+ }
16
+ exports.ClassModel = ClassModel;
17
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/shared/model.ts"],"names":[],"mappings":";;;AAAA;;IAEI;AACJ,MAAa,SAAS;IAAtB;QAUS,YAAO,GAAiB,EAAE,CAAC;QAC3B,eAAU,GAA0B,IAAI,GAAG,EAAoB,CAAC;IACzE,CAAC;CAAA;AAZD,8BAYC;AAED,MAAa,UAAU;CAatB;AAbD,gCAaC"}
@@ -0,0 +1,3 @@
1
+ import { Inventory } from './model';
2
+ export declare function parse(model: Inventory): void;
3
+ export declare function parseXML(xmlfile: any, dieOnError?: boolean): any[];
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseXML = exports.parse = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Copyright (c) NCR Terafina
7
+ **/
8
+ const core_1 = require("@salesforce/core");
9
+ const fs = tslib_1.__importStar(require("fs-extra"));
10
+ const xml2js = tslib_1.__importStar(require("xml2js"));
11
+ const model_1 = require("./model");
12
+ function parse(model) {
13
+ parseApexClasses(model);
14
+ }
15
+ exports.parse = parse;
16
+ function parseApexClasses(model) {
17
+ const classes = fs.readdirSync(model.codepath + 'classes').filter(t => !t.endsWith('-meta.xml'));
18
+ model.apexcount = classes.length;
19
+ for (const clazz of classes) {
20
+ const classFile = `${model.codepath}classes/${clazz}`;
21
+ if (!fs.existsSync(classFile)) {
22
+ console.log(classFile + ' not found');
23
+ continue;
24
+ }
25
+ const classModel = new model_1.ClassModel();
26
+ classModel.name = clazz;
27
+ const classMetaFile = `${model.codepath}classes/${clazz}-meta.xml`;
28
+ if (fs.existsSync(classMetaFile)) {
29
+ const classMetaJSON = parseXML(classMetaFile);
30
+ if (classMetaJSON['ApexClass'] && classMetaJSON['ApexClass']['apiVersion']) {
31
+ classModel.apiVersion = parseFloat(classMetaJSON['ApexClass']['apiVersion'][0]);
32
+ }
33
+ }
34
+ else {
35
+ continue;
36
+ }
37
+ let classBody = fs.readFileSync(classFile, 'utf8');
38
+ classBody = stripApexComments(classBody);
39
+ const futureReg = /@future/i;
40
+ const auraEnabledReg = /@AuraEnabled/i;
41
+ const invocableReg = /@InvocableMethod|InvocableVariable/i;
42
+ const batchReg = /extends\s+AbstractBatchJob/i;
43
+ const repoReg = /extends\s+AbstractRepository/i;
44
+ const restReg = /@RestResource/i;
45
+ const cntrlReg = /@RemoteAction/i;
46
+ if (futureReg.test(classBody)) {
47
+ classModel.hasFuture = true;
48
+ }
49
+ if (auraEnabledReg.test(classBody)) {
50
+ classModel.hasAuraEnabled = true;
51
+ }
52
+ if (invocableReg.test(classBody)) {
53
+ classModel.hasInvocable = true;
54
+ }
55
+ if (restReg.test(classBody)) {
56
+ classModel.isRESTController = true;
57
+ }
58
+ if (cntrlReg.test(classBody)) {
59
+ classModel.isController = true;
60
+ }
61
+ if (batchReg.test(classBody)) {
62
+ classModel.isBatchJob = true;
63
+ }
64
+ if (repoReg.test(classBody)) {
65
+ classModel.isRepository = true;
66
+ }
67
+ classModel.charCount = classBody.length;
68
+ model.classes.push(classModel);
69
+ }
70
+ }
71
+ function stripApexComments(apexBody) {
72
+ const commentReg = /\/\*[\s\S]*?\*\/|((?<!:)|^)\/\/.*$/gm;
73
+ return apexBody.replace(commentReg, '');
74
+ }
75
+ function parseXML(xmlfile, dieOnError = false) {
76
+ const parser = new xml2js.Parser({
77
+ attrkey: 'ATTR'
78
+ });
79
+ let json = [];
80
+ let error;
81
+ if (!fs.existsSync(xmlfile)) {
82
+ const message = `Cannot find XML File: ${xmlfile}`;
83
+ if (dieOnError === true) {
84
+ throw new core_1.SfdxError(message, 'XMLNotFoundError');
85
+ }
86
+ else {
87
+ return json;
88
+ }
89
+ }
90
+ const xmlData = fs.readFileSync(xmlfile, 'utf8');
91
+ parser.parseString(xmlData.substring(0, xmlData.length), (err, result) => {
92
+ error = err;
93
+ json = result || json;
94
+ });
95
+ if (error && dieOnError) {
96
+ throw new core_1.SfdxError(`Error parsing ${xmlfile}: ${error}`, 'XMLParseError');
97
+ }
98
+ return json;
99
+ }
100
+ exports.parseXML = parseXML;
101
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/shared/parser.ts"],"names":[],"mappings":";;;;AAAA;;IAEI;AACJ,2CAA6C;AAC7C,qDAA+B;AAC/B,uDAAiC;AACjC,mCAAgD;AAEhD,SAAgB,KAAK,CAAC,KAAgB;IACpC,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAFD,sBAEC;AACD,SAAS,gBAAgB,CAAC,KAAgB;IACxC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAEjG,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,SAAS,GAAG,GAAG,KAAK,CAAC,QAAQ,WAAW,KAAK,EAAE,CAAC;QACtD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC;YACtC,SAAS;SACV;QAED,MAAM,UAAU,GAAG,IAAI,kBAAU,EAAE,CAAC;QACpC,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;QACxB,MAAM,aAAa,GAAG,GAAG,KAAK,CAAC,QAAQ,WAAW,KAAK,WAAW,CAAC;QACnE,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAChC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC9C,IAAI,aAAa,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,EAAE;gB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,IAAI,CAAC;AACd,CAAC;AAzBD,4BAyBC"}
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Copyright (c) NCR Terafina
3
+ **/
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) NCR Terafina
4
+ **/
5
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/shared/rules.ts"],"names":[],"mappings":";AAAA;;IAEI"}
@@ -1 +1 @@
1
- {"version":"0.1.2","commands":{"tffa:ping":{"id":"tffa:ping","description":"ping","usage":"<%= command.id %> [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@terafina/tffa-sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx tffa:ping "],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"}},"args":[{"name":"file"}]}}}
1
+ {"version":"1.0.1","commands":{"tffa:apexdoc":{"id":"tffa:apexdoc","description":"Generate Apex API Documentation","usage":"<%= command.id %> [-d <directory>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@terafina/tffa-sfdx-plugin","pluginType":"core","aliases":[],"examples":["Generate Apex API Documentation :\t$sfdx tffa:apexdoc "],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"sourcefolder":{"name":"sourcefolder","type":"option","char":"d","description":"directory containing package metadata","default":"."}},"args":[]},"tffa:ping":{"id":"tffa:ping","description":"ping","usage":"<%= command.id %> [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@terafina/tffa-sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx tffa:ping "],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"}},"args":[{"name":"file"}]},"tffa:scan":{"id":"tffa:scan","description":"scan a package and provide recommendations based on package inventory","usage":"<%= command.id %> [-s <directory>] [-m <directory>] [-f <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@terafina/tffa-sfdx-plugin","pluginType":"core","aliases":[],"examples":["Scan a package and provide inventory of metadata items :\t$sfdx tffa:scan"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"sourcefolder":{"name":"sourcefolder","type":"option","char":"s","description":"directory containing package metadata","default":"."},"mdoutfolder":{"name":"mdoutfolder","type":"option","char":"m","description":"directory containing mdapi src metadata","default":"."},"format":{"name":"format","type":"option","char":"f","description":"generate json output"}},"args":[]}}}