@terafina/tffa-sfdx-plugin 0.1.1 → 1.0.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 (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 +49 -26
  123. package/CHANGELOG.md +0 -12
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /**
5
+ * Copyright (c) NCR Terafina
6
+ **/
7
+ const apex_docs_error_1 = tslib_1.__importDefault(require("./apex-docs-error"));
8
+ const engine_config_1 = tslib_1.__importDefault(require("./models/engine-config"));
9
+ const utils_1 = tslib_1.__importDefault(require("./utils"));
10
+ const validator_1 = tslib_1.__importDefault(require("./validator"));
11
+ const fs_1 = require("fs");
12
+ const settings_1 = tslib_1.__importDefault(require("./settings"));
13
+ class ValidatorEngine extends validator_1.default {
14
+ constructor(config) {
15
+ super(config);
16
+ this.validFields = Object.keys(new engine_config_1.default());
17
+ }
18
+ // #region Engine Field Validators / Instance Methods
19
+ includes() {
20
+ ValidatorEngine.stringArray(this.config.includes, 'includes');
21
+ }
22
+ excludes() {
23
+ ValidatorEngine.stringArray(this.config.excludes, 'excludes');
24
+ }
25
+ cleanDir() {
26
+ this.config.cleanDir = utils_1.default.boolGuard(this.config.cleanDir, false);
27
+ }
28
+ showTOCSnippets() {
29
+ this.config.showTOCSnippets = utils_1.default.boolGuard(this.config.showTOCSnippets, true);
30
+ }
31
+ subtitle() {
32
+ ValidatorEngine.typeGuard('string', this.config.subtitle, 'subtitle');
33
+ }
34
+ pages() {
35
+ this.config.pages = ValidatorEngine.stringArray(this.config.pages, 'pages').map(path => ValidatorEngine.directory(path, 'pages', '.html'));
36
+ }
37
+ assets() {
38
+ // do not validate directory on assets, user will be warned at runtime
39
+ this.config.assets = ValidatorEngine.stringArray(this.config.assets, 'assets').map(path => utils_1.default.resolveWorkspaceFolder(path));
40
+ }
41
+ targetDirectory() {
42
+ const path = this.config.targetDirectory;
43
+ ValidatorEngine.typeGuard('string', path, 'targetDirectory');
44
+ if (path && path.length > 0) {
45
+ this.config.targetDirectory = utils_1.default.resolveWorkspaceFolder(path);
46
+ }
47
+ else {
48
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_TARGET_DIRECTORY(path));
49
+ }
50
+ }
51
+ homePagePath() {
52
+ ValidatorEngine.typeGuard('string', this.config.homePagePath, 'homePagePath');
53
+ this.config.homePagePath = ValidatorEngine.directory(this.config.homePagePath, 'homePagePath', '.html');
54
+ }
55
+ sortOrder() {
56
+ let sortOrder = this.config.sortOrder;
57
+ ValidatorEngine.typeGuard('string', sortOrder, 'sortOrder');
58
+ sortOrder = sortOrder.toLowerCase();
59
+ if (sortOrder === settings_1.default.ORDER_LOGICAL || sortOrder === settings_1.default.ORDER_ALPHA) {
60
+ this.config.sortOrder = sortOrder;
61
+ }
62
+ else {
63
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_SORT_ORDER(sortOrder));
64
+ }
65
+ }
66
+ title() {
67
+ ValidatorEngine.typeGuard('string', this.config.title, 'title');
68
+ this.config.title = this.config.title || 'Apex Documentation';
69
+ }
70
+ scope() {
71
+ const scopes = this.config.scope;
72
+ ValidatorEngine.typeGuard('array', scopes, 'scope');
73
+ if (scopes.length > 6) {
74
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.SCOPE_ENTRIES_MAX);
75
+ }
76
+ if (scopes.length === 0) {
77
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.SCOPE_ENTRIES_MIN);
78
+ }
79
+ const registeredScopes = new Array();
80
+ scopes.forEach(scope => {
81
+ if (typeof scope !== 'string') {
82
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.ONLY_STRINGS('scope'));
83
+ }
84
+ let foundScope = false;
85
+ scope = scope.toLowerCase().trim();
86
+ settings_1.default.SCOPES.forEach(s => {
87
+ if (s.toLowerCase() === scope) {
88
+ registeredScopes.push(s.toLowerCase());
89
+ foundScope = true;
90
+ }
91
+ });
92
+ if (!foundScope) {
93
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.SCOPE_ENTRY_INVALID(scope));
94
+ }
95
+ });
96
+ this.config.scope = registeredScopes;
97
+ }
98
+ source() {
99
+ this.config.source = this.config.source.map(src => ({
100
+ path: ValidatorEngine.directory(src.path, 'source.path'),
101
+ sourceUrl: ValidatorEngine.sourceUrl(src.sourceUrl)
102
+ }));
103
+ }
104
+ // #endregion
105
+ // #region Static ValidatorEngines
106
+ static port(port) {
107
+ this.typeGuard('number', port, 'port');
108
+ // only allows integers between 0-65535 as port numbers
109
+ if (!/^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/.test(String(port))) {
110
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_PORT(port));
111
+ }
112
+ return port;
113
+ }
114
+ // #endregion
115
+ // #region Static Helpers
116
+ static directory(path, arg, extension) {
117
+ this.typeGuard('string', path, arg);
118
+ // blank directory's can be ignored as default for non-required
119
+ // arguments. Source directory will always be populated by this point.
120
+ path = utils_1.default.resolveWorkspaceFolder(path);
121
+ if (path === '' || fs_1.existsSync(path)) {
122
+ if (path && extension && !path.endsWith(extension)) {
123
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_EXTENSION(arg, path, extension));
124
+ }
125
+ return path;
126
+ }
127
+ else {
128
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_DIRECTORY(arg, path));
129
+ }
130
+ }
131
+ static sourceUrl(str) {
132
+ if (!str) {
133
+ return undefined;
134
+ }
135
+ this.typeGuard('string', str, 'sourceUrl');
136
+ if (utils_1.default.isURL(str)) {
137
+ return str.trim();
138
+ }
139
+ else {
140
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_SOURCE_URL(str));
141
+ }
142
+ }
143
+ static stringArray(arr, argName) {
144
+ this.typeGuard('array', arr, argName);
145
+ arr.forEach(item => {
146
+ if (typeof item !== 'string') {
147
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.ONLY_STRINGS(argName));
148
+ }
149
+ });
150
+ return arr;
151
+ }
152
+ static typeGuard(type, value, arg) {
153
+ if ((type === 'array' && Array.isArray(value)) || typeof value === type) {
154
+ return true;
155
+ }
156
+ else {
157
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.INVALID_TYPE(arg, type));
158
+ }
159
+ }
160
+ }
161
+ exports.default = ValidatorEngine;
162
+ //# sourceMappingURL=validator-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator-engine.js","sourceRoot":"","sources":["../../../src/apexdoc/common/validator-engine.ts"],"names":[],"mappings":";;;AAAA;;IAEI;AACJ,gFAA6C;AAC7C,mFAAkD;AAClD,4DAA4B;AAC5B,oEAAoC;AACpC,2BAAgC;AAEhC,kEAAkC;AAElC,MAAM,eAAgB,SAAQ,mBAAwB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I,CAAC,CAAC,CAAC;SAC9D;IACH,CAAC;CAEF;AAED,kBAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ declare abstract class Validator<T> {
2
+ protected config: T;
3
+ [key: string]: any;
4
+ protected currentFields: string[];
5
+ protected validFields: string[];
6
+ constructor(config: T);
7
+ /**
8
+ * Since we're allowing rc and yaml config files (e.g. losing helpful intellisense)
9
+ * we need to carefully validate configs coming in. This method will match each config
10
+ * key to an instance method which validates that key. For engine configs, the 'port'
11
+ * setting is the exception which will be validated only at serveDocs runtime. This
12
+ * will also throw an error if any unexpected, rogue configuration settings are found.
13
+ */
14
+ validate(): T;
15
+ }
16
+ export default Validator;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /**
5
+ * Copyright (c) NCR Terafina
6
+ **/
7
+ const apex_docs_error_1 = tslib_1.__importDefault(require("./apex-docs-error"));
8
+ class Validator {
9
+ constructor(config) {
10
+ this.config = config;
11
+ this.validFields = [];
12
+ this.config = config;
13
+ this.currentFields = Object.keys(config);
14
+ }
15
+ /**
16
+ * Since we're allowing rc and yaml config files (e.g. losing helpful intellisense)
17
+ * we need to carefully validate configs coming in. This method will match each config
18
+ * key to an instance method which validates that key. For engine configs, the 'port'
19
+ * setting is the exception which will be validated only at serveDocs runtime. This
20
+ * will also throw an error if any unexpected, rogue configuration settings are found.
21
+ */
22
+ validate() {
23
+ for (const field of this.currentFields) {
24
+ if (this.validFields.includes(field)) {
25
+ this[field] && this[field]();
26
+ }
27
+ else {
28
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.UNKNOWN_CONFIG_SETTING(field));
29
+ }
30
+ }
31
+ return this.config;
32
+ }
33
+ }
34
+ exports.default = Validator;
35
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/apexdoc/common/validator.ts"],"names":[],"mappings":";;;AAAA;;IAEI;AACJ,gFAA6C;AAE7C,MAAe,SAAS;IAKtB,YAA6B,MAAS;QAAT,WAAM,GAAN,MAAM,CAAG;QAF5B,gBAAW,GAAG,EAAc,CAAC;QAGrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACb,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACpC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;aAC9B;iBAAM;gBACL,MAAM,IAAI,yBAAY,CAAC,yBAAY,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;aACpE;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAED,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright (c) NCR Terafina
3
+ **/
4
+ import * as Models from '../common/models';
5
+ import { ISourceEntry, Option, IApexDoxMenus } from '..';
6
+ declare class FileManager {
7
+ private path;
8
+ private projectTitle;
9
+ private userAssets;
10
+ constructor(targetDirectory: string, projectTitle: string, assets: string[]);
11
+ /**
12
+ * Collects the Apex .cls files the user has indicated they'd like to document via config settings.
13
+ *
14
+ * @param sources A list of `ISourceEntry` objects from where to collect our .cls files
15
+ * @param includes See config settings: a list of patterns to include
16
+ * @param excludes See config settings: a list of patterns to exclude
17
+ */
18
+ getFiles(sources: ISourceEntry[], includes: string[], excludes: string[]): ISourceEntry[];
19
+ /**
20
+ * Main routine that creates HTML file for each of our classes and for any additional
21
+ * pages that a user has included, e.g. home page, class group, supplementary.
22
+ *
23
+ * @param groupNameMap Map of our class group names to their ClassGroup instances
24
+ * @param models Map of our model names to their TopLevelModel instances
25
+ * @param pages Any additional pages, including the project home page, the user has included
26
+ */
27
+ createDocs(groupNameMap: Map<string, Models.ClassGroup>, models: Map<string, Models.TopLevelModel>, pages: string[]): void;
28
+ /**
29
+ * Parses HTML files provided by the user, like class group pages,
30
+ * and the project home page. Returns any content between
31
+ * the <body> tags, or the entire markup if no <body> tags are present.
32
+ * The extracted markup will be placed within the project's standard
33
+ * page layout (header, menu, footer) for the final product.
34
+ *
35
+ * @param filePath The path of the HTML file to parse.
36
+ * @returns string representing the markup or void.
37
+ */
38
+ parseHTMLFile(filePath: string): Option<string, void>;
39
+ private makeDirs;
40
+ private createHTMLFiles;
41
+ private createSearchIndex;
42
+ private collectApexDoxAssets;
43
+ private copyAssetsToTarget;
44
+ private makePage;
45
+ makeMenuItems(models: Map<string, Models.TopLevelModel>): void;
46
+ makeRestDefinition(models: Map<string, Models.TopLevelModel>): void;
47
+ mapToObj(inputMap: Map<string, any>): any;
48
+ makeDocumentationPages(fileMap: Map<string, string>, menus: IApexDoxMenus, models: Map<string, Models.TopLevelModel>): void;
49
+ private makeSupplementaryPages;
50
+ private makeClassGroupPages;
51
+ }
52
+ export default FileManager;
@@ -0,0 +1,390 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /**
5
+ * Copyright (c) NCR Terafina
6
+ **/
7
+ const Models = tslib_1.__importStar(require("../common/models"));
8
+ const apex_docs_error_1 = tslib_1.__importDefault(require("../common/apex-docs-error"));
9
+ const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
10
+ const class_markup_generator_1 = tslib_1.__importDefault(require("./generators/models/class-markup-generator"));
11
+ const enum_markup_generator_1 = tslib_1.__importDefault(require("./generators/models/enum-markup-generator"));
12
+ const fs_1 = tslib_1.__importDefault(require("fs"));
13
+ const generator_utils_1 = tslib_1.__importDefault(require("./generators/generator-utils"));
14
+ const line_reader_1 = tslib_1.__importDefault(require("../common/line-reader"));
15
+ const menu_generator_1 = tslib_1.__importDefault(require("./generators/menu-generator"));
16
+ const path_1 = tslib_1.__importDefault(require("path"));
17
+ const pretty_1 = tslib_1.__importDefault(require("pretty"));
18
+ const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
19
+ const utils_1 = tslib_1.__importDefault(require("../common/utils"));
20
+ const core_1 = require("@salesforce/core");
21
+ const settings_1 = tslib_1.__importDefault(require("../common/settings"));
22
+ class FileManager {
23
+ constructor(targetDirectory, projectTitle, assets) {
24
+ this.path = targetDirectory;
25
+ this.userAssets = assets;
26
+ this.projectTitle = projectTitle;
27
+ }
28
+ // ===========================================================================
29
+ // #region Public API Methods
30
+ // ===========================================================================
31
+ /**
32
+ * Collects the Apex .cls files the user has indicated they'd like to document via config settings.
33
+ *
34
+ * @param sources A list of `ISourceEntry` objects from where to collect our .cls files
35
+ * @param includes See config settings: a list of patterns to include
36
+ * @param excludes See config settings: a list of patterns to exclude
37
+ */
38
+ getFiles(sources, includes, excludes) {
39
+ const filesToCopy = new Array(), noneFound = new Array();
40
+ const isEntryMatch = (entry, fileName) => fileName === entry ||
41
+ (entry.startsWith('*') && fileName.endsWith(entry.slice(1))) ||
42
+ (entry.endsWith('*') && fileName.startsWith(entry.slice(0, -1)));
43
+ for (const src of sources) {
44
+ const files = fs_1.default.readdirSync(src.path);
45
+ if (files && files.some(file => file.endsWith('cls'))) {
46
+ files.forEach(fileName => {
47
+ // make sure entry is a file and is an apex class
48
+ if (!fileName.endsWith('.cls')) {
49
+ return;
50
+ }
51
+ // if file is explicitly excluded or matches wildcard, return early
52
+ for (const entry of excludes) {
53
+ if (isEntryMatch(entry, fileName)) {
54
+ return;
55
+ }
56
+ }
57
+ // no includes params, include file
58
+ if (includes.length === 0) {
59
+ filesToCopy.push({
60
+ path: path_1.default.resolve(src.path, fileName),
61
+ sourceUrl: src.sourceUrl
62
+ });
63
+ return;
64
+ }
65
+ // there are includes params, only include files that pass test
66
+ for (const entry of includes) {
67
+ // file matches explicitly matches or matches wildcard
68
+ if (isEntryMatch(entry, fileName)) {
69
+ filesToCopy.push({
70
+ path: path_1.default.resolve(src.path, fileName),
71
+ sourceUrl: src.sourceUrl
72
+ });
73
+ return;
74
+ }
75
+ }
76
+ });
77
+ }
78
+ else if (files && files.some(file => file.endsWith('page') || file.endsWith('component'))) {
79
+ files.forEach(fileName => {
80
+ // make sure entry is a file and is an apex class
81
+ if (!(fileName.endsWith('.page') || fileName.endsWith('.component'))) {
82
+ return;
83
+ }
84
+ // if file is explicitly excluded or matches wildcard, return early
85
+ for (const entry of excludes) {
86
+ if (isEntryMatch(entry, fileName)) {
87
+ return;
88
+ }
89
+ }
90
+ // no includes params, include file
91
+ if (includes.length === 0) {
92
+ filesToCopy.push({
93
+ path: path_1.default.resolve(src.path, fileName),
94
+ sourceUrl: src.sourceUrl
95
+ });
96
+ return;
97
+ }
98
+ // there are includes params, only include files that pass test
99
+ for (const entry of includes) {
100
+ // file matches explicitly matches or matches wildcard
101
+ if (isEntryMatch(entry, fileName)) {
102
+ filesToCopy.push({
103
+ path: path_1.default.resolve(src.path, fileName),
104
+ sourceUrl: src.sourceUrl
105
+ });
106
+ return;
107
+ }
108
+ }
109
+ });
110
+ }
111
+ else {
112
+ noneFound.push(src.path);
113
+ }
114
+ }
115
+ if (!filesToCopy.length) {
116
+ // no .cls files found at all, or all .cls files have been excluded, throw error
117
+ const sourceDirs = sources.map(src => src.path).join(',');
118
+ throw new apex_docs_error_1.default(apex_docs_error_1.default.NO_FILES_FOUND(sourceDirs));
119
+ }
120
+ else if (noneFound.length) {
121
+ // no .cls files found in one or more (but not all) of given source dirs, show warning
122
+ throw new core_1.SfdxError(`No matching .cls files found in ${noneFound.join(',')}`);
123
+ }
124
+ return filesToCopy;
125
+ }
126
+ /**
127
+ * Main routine that creates HTML file for each of our classes and for any additional
128
+ * pages that a user has included, e.g. home page, class group, supplementary.
129
+ *
130
+ * @param groupNameMap Map of our class group names to their ClassGroup instances
131
+ * @param models Map of our model names to their TopLevelModel instances
132
+ * @param pages Any additional pages, including the project home page, the user has included
133
+ */
134
+ createDocs(groupNameMap, models, pages) {
135
+ // make the menu and the scoping panel
136
+ // and initialize our main file map
137
+ const fileMap = new Map();
138
+ const menus = {
139
+ class: menu_generator_1.default.makeMenu(groupNameMap, models),
140
+ scope: menu_generator_1.default.makeScopeMenu()
141
+ };
142
+ // create the markup for our different varieties of HTML pages
143
+ // and add to our file map. HTML files will be created from this map.
144
+ this.makeSupplementaryPages(fileMap, menus, pages);
145
+ this.makeClassGroupPages(fileMap, menus, groupNameMap);
146
+ this.makeDocumentationPages(fileMap, menus, models);
147
+ // Now finalize everything... Make our directories first
148
+ // if they don't exist yet, then create our HTML files.
149
+ // Lastly, copy our assets, ours first, then the users.
150
+ // If they're using a favicon this will override ours.
151
+ this.makeDirs();
152
+ this.makeMenuItems(models);
153
+ this.makeRestDefinition(models);
154
+ this.createHTMLFiles(fileMap);
155
+ this.createSearchIndex(fileMap);
156
+ this.copyAssetsToTarget(this.collectApexDoxAssets());
157
+ this.copyAssetsToTarget(this.userAssets);
158
+ }
159
+ /**
160
+ * Parses HTML files provided by the user, like class group pages,
161
+ * and the project home page. Returns any content between
162
+ * the <body> tags, or the entire markup if no <body> tags are present.
163
+ * The extracted markup will be placed within the project's standard
164
+ * page layout (header, menu, footer) for the final product.
165
+ *
166
+ * @param filePath The path of the HTML file to parse.
167
+ * @returns string representing the markup or void.
168
+ */
169
+ parseHTMLFile(filePath) {
170
+ if (!filePath.trim()) {
171
+ return;
172
+ }
173
+ const contents = new line_reader_1.default(filePath).toString();
174
+ if (contents) {
175
+ const startIndex = contents.indexOf('<body>');
176
+ const endIndex = contents.indexOf('</body>');
177
+ if (startIndex !== -1 && endIndex !== -1) {
178
+ return contents.substring(startIndex + 6, endIndex);
179
+ }
180
+ else if (startIndex === -1 && endIndex === -1) {
181
+ return contents;
182
+ }
183
+ }
184
+ }
185
+ // #endregion
186
+ // ===========================================================================
187
+ // ===========================================================================
188
+ // #region FS Utils
189
+ // ===========================================================================
190
+ makeDirs() {
191
+ const root = this.path;
192
+ const assets = path_1.default.resolve(root, 'assets');
193
+ // clean directory first if user specified this
194
+ settings_1.default.config.cleanDir && rimraf_1.default.sync(root);
195
+ if (!fs_1.default.existsSync(root)) {
196
+ [root, assets].forEach(path => fs_1.default.mkdirSync(path));
197
+ }
198
+ else if (fs_1.default.existsSync(root) && !fs_1.default.existsSync(assets)) {
199
+ fs_1.default.mkdirSync(assets);
200
+ }
201
+ }
202
+ createHTMLFiles(fileMap) {
203
+ for (const fileName of fileMap.keys()) {
204
+ const contents = utils_1.default.preCodeTrim(pretty_1.default(fileMap.get(fileName)));
205
+ const fullyQualifiedFileName = path_1.default.resolve(this.path, fileName + '.html');
206
+ fs_1.default.writeFileSync(fullyQualifiedFileName, contents);
207
+ }
208
+ }
209
+ createSearchIndex(fileMap) {
210
+ const searchIndex = [];
211
+ fileMap.forEach((contents, fileName) => {
212
+ const $ = cheerio_1.default.load(contents.replace(/(<\/\w+>)/g, '$1 '));
213
+ // do some hacky replacements to keep
214
+ // text as searchable as possible
215
+ const plainText = $('.doc-page')
216
+ .text()
217
+ .replace(/\s\(/g, '(')
218
+ .split('\n')
219
+ .map(line => line.trim())
220
+ .filter(line => !!line);
221
+ searchIndex.push({
222
+ title: fileName === 'index' ? 'Home' : fileName,
223
+ fileName: fileName + '.html',
224
+ text: plainText.join(' ')
225
+ });
226
+ });
227
+ fs_1.default.writeFileSync(path_1.default.resolve(this.path, 'assets', 'search-idx.js'), `export default ${JSON.stringify(searchIndex, null, 4)};\n`);
228
+ }
229
+ collectApexDoxAssets() {
230
+ const extensionRoot = '../../../';
231
+ const files = fs_1.default.readdirSync(path_1.default.resolve(__dirname, extensionRoot, 'assets'));
232
+ return files.map(fileName => path_1.default.resolve(__dirname, extensionRoot, 'assets', fileName));
233
+ }
234
+ copyAssetsToTarget(files) {
235
+ files.forEach(file => {
236
+ if (fs_1.default.existsSync(file)) {
237
+ fs_1.default.copyFileSync(file, path_1.default.resolve(this.path, 'assets', path_1.default.basename(file)));
238
+ }
239
+ else {
240
+ throw new core_1.SfdxError(apex_docs_error_1.default.ASSET_NOT_FOUND(file));
241
+ }
242
+ });
243
+ }
244
+ // #endregion
245
+ // ===========================================================================
246
+ // ===========================================================================
247
+ // #region Document Generators
248
+ // ===========================================================================
249
+ makePage(contents, menus, title = '') {
250
+ const pageTitle = title ? `<h2 class='section-title'>${title}</h2>` : '';
251
+ const rows = [
252
+ ['scoping-panel', menus.scope],
253
+ ['doc-page', pageTitle + contents],
254
+ ['footer', generator_utils_1.default.footer]
255
+ ];
256
+ const html = `<!DOCTYPE html>
257
+ <html lang="en">
258
+ ${generator_utils_1.default.makeHead(this.projectTitle)}
259
+ <body>
260
+ ${menus.class}
261
+ <table id="content">
262
+ ${generator_utils_1.default.mapHTML(rows, ([className, contents]) => `<tr>
263
+ <td class="${className}">
264
+ ${contents}
265
+ </td>
266
+ </tr>`)}
267
+ </table>
268
+ </body>
269
+ </html>`;
270
+ return html;
271
+ }
272
+ makeMenuItems(models) {
273
+ const menuMap = new Map();
274
+ for (const model of models.values()) {
275
+ const group = model.groupName;
276
+ let items = menuMap.get(group);
277
+ if (!items) {
278
+ items = [];
279
+ }
280
+ const item = { name: model.name, path: model.name + '.html' };
281
+ items.push(item);
282
+ menuMap.set(group, items);
283
+ }
284
+ const menus = [];
285
+ for (const k of menuMap.keys()) {
286
+ const items = menuMap.get(k);
287
+ if (items) {
288
+ const menu = { name: k, items: items };
289
+ menus.push(menu);
290
+ }
291
+ }
292
+ menus.sort((a, b) => a.name.localeCompare(b.name));
293
+ const fullyQualifiedFileName = path_1.default.resolve(this.path, 'assets', 'menujson' + '.js');
294
+ let text = 'var menu = ' + JSON.stringify(menus, null, 4);
295
+ text = text + '\nexport {menu};';
296
+ fs_1.default.writeFileSync(fullyQualifiedFileName, text);
297
+ }
298
+ makeRestDefinition(models) {
299
+ const definitions = [];
300
+ const schemas = {};
301
+ const fileName = 'api';
302
+ for (const model of models.values()) {
303
+ if (model.modelType === Models.ModelType.CLASS) {
304
+ const cModel = model;
305
+ if (cModel.restUrl) {
306
+ definitions.push(...cModel.restDefinition);
307
+ }
308
+ if (cModel.isDTO) {
309
+ schemas[cModel.name] = cModel.dtoDefinition;
310
+ const childs = cModel.childClasses;
311
+ if (childs && childs.length > 0)
312
+ for (const cdto of childs) {
313
+ const name = cdto.name.replace(cModel.name + '.', '');
314
+ schemas[name] = cdto.dtoDefinition;
315
+ }
316
+ }
317
+ }
318
+ }
319
+ if (definitions.length > 0) {
320
+ const fullyQualifiedFileName = path_1.default.resolve(this.path, 'assets', fileName + '.json');
321
+ fs_1.default.writeFileSync(fullyQualifiedFileName, JSON.stringify(definitions, null, 4));
322
+ }
323
+ const fullyQualifiedFileName = path_1.default.resolve(this.path, 'assets', fileName + 'schemas' + '.json');
324
+ fs_1.default.writeFileSync(fullyQualifiedFileName, JSON.stringify(schemas, null, 4));
325
+ }
326
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
327
+ mapToObj(inputMap) {
328
+ const obj = {};
329
+ inputMap.forEach((value, key) => {
330
+ obj[key] = value;
331
+ });
332
+ return obj;
333
+ }
334
+ makeDocumentationPages(fileMap, menus, models) {
335
+ for (const model of models.values()) {
336
+ let fileName = '';
337
+ let contents = '';
338
+ if (model.nameLine) {
339
+ fileName = model.name;
340
+ if (model.modelType === Models.ModelType.CLASS) {
341
+ const cModel = model;
342
+ contents += class_markup_generator_1.default.generate(cModel, models);
343
+ // get child classes to work with in the order user specifies
344
+ const childClasses = settings_1.default.config.sortOrder === settings_1.default.ORDER_ALPHA ? cModel.childClassesSorted : cModel.childClasses;
345
+ // map over child classes, creating HTML, and concat result
346
+ contents += childClasses.map(cmChild => class_markup_generator_1.default.generate(cmChild, models)).join('');
347
+ }
348
+ else if (model.modelType === Models.ModelType.ENUM) {
349
+ const eModel = model;
350
+ contents += enum_markup_generator_1.default.generate(eModel, models);
351
+ }
352
+ }
353
+ else {
354
+ continue;
355
+ }
356
+ fileMap.set(fileName, this.makePage(contents, menus));
357
+ }
358
+ }
359
+ makeSupplementaryPages(fileMap, menus, pages) {
360
+ pages.forEach((pagePath, i) => {
361
+ if (i === 0) {
362
+ // our home page is always the first index
363
+ const homePageContents = this.parseHTMLFile(pagePath);
364
+ const markup = this.makePage(homePageContents || generator_utils_1.default.defaultHomePage, menus, 'Home');
365
+ fileMap.set('index', markup);
366
+ }
367
+ else {
368
+ const contents = this.parseHTMLFile(pagePath);
369
+ if (contents) {
370
+ const markup = this.makePage(contents, menus);
371
+ fileMap.set(path_1.default.basename(pagePath.substring(0, pagePath.lastIndexOf('.'))), markup);
372
+ }
373
+ }
374
+ });
375
+ }
376
+ makeClassGroupPages(fileMap, menus, classGroupMap) {
377
+ for (const group of classGroupMap.keys()) {
378
+ const cg = classGroupMap.get(group);
379
+ if (cg && cg.contentSource) {
380
+ const cgContent = this.parseHTMLFile(cg.contentSource);
381
+ if (cgContent) {
382
+ const markup = this.makePage(cgContent, menus, generator_utils_1.default.encodeText(cg.name, false));
383
+ fileMap.set(cg.contentFileName, markup);
384
+ }
385
+ }
386
+ }
387
+ }
388
+ }
389
+ exports.default = FileManager;
390
+ //# sourceMappingURL=file-manager.js.map