versioned-d.ts-tools 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -12
- package/dist/dts-utilities.d.ts +27 -2
- package/dist/dts-utilities.js +92 -54
- package/dist/whats-new.d.ts +1 -1
- package/dist/whats-new.js +55 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,33 +105,76 @@ whats-new office-scripts.d.ts office-scripts-old.d.ts office-scripts-whats-new j
|
|
|
105
105
|
|
|
106
106
|
This generates a markdown file (e.g., `excel_whats_new.md`) containing a table showing what's new between the two versions.
|
|
107
107
|
|
|
108
|
-
####
|
|
108
|
+
#### Configuration File
|
|
109
109
|
|
|
110
|
-
You can provide an optional JSON configuration file to customize
|
|
110
|
+
You can provide an optional JSON configuration file to customize the output by excluding specific fields, classes, and controlling what types of declarations are included.
|
|
111
111
|
|
|
112
112
|
**Configuration file format:**
|
|
113
113
|
|
|
114
114
|
```json
|
|
115
115
|
{
|
|
116
|
+
"excludedFieldNames": [
|
|
117
|
+
"load", "set", "toJSON", "context", "track", "untrack"
|
|
118
|
+
],
|
|
119
|
+
"excludedClassPatterns": [
|
|
120
|
+
"LoadOptions$", "Data$"
|
|
121
|
+
],
|
|
122
|
+
"excludedFieldPatterns": [
|
|
123
|
+
"\\w+\\??:\\s*\".*\""
|
|
124
|
+
],
|
|
125
|
+
"includeStaticFields": false,
|
|
126
|
+
"includeEnums": false,
|
|
116
127
|
"linkConfigs": [
|
|
117
128
|
{
|
|
118
|
-
"name": "Office Scripts",
|
|
119
129
|
"pathPattern": "office-scripts",
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"name": "Standard Office Applications",
|
|
124
|
-
"pathPattern": ".*",
|
|
125
|
-
"description": "Standard URL pattern for Excel, Word, PowerPoint, Outlook"
|
|
130
|
+
"globalFunctionTemplate": "/{basePath}#officescript-officescript-{fieldName}-function(1)",
|
|
131
|
+
"classTemplate": "/{basePath}/officescript.{className}",
|
|
132
|
+
"classMemberTemplate": "/{basePath}/officescript.{className}#officescript-officescript-{className}-{fieldName}{suffix}"
|
|
126
133
|
}
|
|
127
134
|
]
|
|
128
135
|
}
|
|
129
136
|
```
|
|
130
137
|
|
|
131
|
-
|
|
138
|
+
**Configuration Options:**
|
|
139
|
+
|
|
140
|
+
- **`excludedFieldNames`** - Array of exact field names to exclude from output
|
|
141
|
+
- **`excludedClassPatterns`** - Array of regex patterns for class names to exclude
|
|
142
|
+
- **`excludedFieldPatterns`** - Array of regex patterns for field declarations to exclude
|
|
143
|
+
- **`includeStaticFields`** - Boolean to include/exclude static fields (default: true)
|
|
144
|
+
- **`includeEnums`** - Boolean to include/exclude enum declarations (default: true when loading from config, false for backward compatibility when called directly)
|
|
145
|
+
- **`linkConfigs`** - Array of custom URL generation templates (see Link Configuration section below)
|
|
146
|
+
|
|
147
|
+
**Enum Configurability:**
|
|
148
|
+
|
|
149
|
+
The `includeEnums` option provides fine-grained control over enum inclusion:
|
|
150
|
+
|
|
151
|
+
- **Default behavior**: When calling the API directly, enums are excluded by default (`includeEnums: false`) for backward compatibility
|
|
152
|
+
- **Config file behavior**: When loading from a config file, enums are included by default (`includeEnums: true`) unless explicitly set to false
|
|
153
|
+
- **Explicit control**: Set `"includeEnums": true` to include enums, or `"includeEnums": false` to exclude them
|
|
154
|
+
|
|
155
|
+
This dual-default approach ensures existing integrations continue working while enabling new functionality when explicitly configured.
|
|
156
|
+
|
|
157
|
+
#### Link Configuration
|
|
158
|
+
|
|
159
|
+
The `linkConfigs` section allows you to customize how URLs are generated for different API types using flexible templates with placeholders.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Available Template Placeholders:**
|
|
163
|
+
|
|
164
|
+
- `{basePath}` - relativePath without the trailing dot (e.g., 'javascript/api/excel/excel')
|
|
165
|
+
- `{hostName}` - extracted host name (e.g., 'excel', 'office-scripts')
|
|
166
|
+
- `{fileName}` - extracted file name (e.g., 'excel', 'officescript')
|
|
167
|
+
- `{className}` - class name in lowercase
|
|
168
|
+
- `{fieldName}` - field/method name in lowercase
|
|
169
|
+
- `{suffix}` - '-member(1)' for methods/functions, '-member' for properties
|
|
170
|
+
|
|
171
|
+
**Template Types:**
|
|
172
|
+
|
|
173
|
+
- `globalFunctionTemplate` - For namespace-level functions (global functions)
|
|
174
|
+
- `classTemplate` - For class/interface URLs in the first column
|
|
175
|
+
- `classMemberTemplate` - For class members (methods, properties, events)
|
|
132
176
|
|
|
133
|
-
|
|
134
|
-
- Other Office applications will use the standard URL format
|
|
177
|
+
When a configuration file is provided, the tool will use the appropriate URL template based on the pattern matching. The first matching `pathPattern` (regex) wins.
|
|
135
178
|
|
|
136
179
|
See `example-link-config.json` for a complete example.
|
|
137
180
|
|
package/dist/dts-utilities.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
export interface LinkConfig {
|
|
2
2
|
pathPattern: string;
|
|
3
|
-
|
|
3
|
+
globalFunctionTemplate: string;
|
|
4
|
+
classTemplate: string;
|
|
5
|
+
classMemberTemplate: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WhatsNewConfig {
|
|
8
|
+
excludedFieldNames?: string[];
|
|
9
|
+
excludedClassPatterns?: string[];
|
|
10
|
+
excludedFieldPatterns?: string[];
|
|
11
|
+
includeStaticFields?: boolean;
|
|
12
|
+
includeEnums?: boolean;
|
|
13
|
+
linkConfigs?: LinkConfig[];
|
|
14
|
+
replacements?: any[];
|
|
4
15
|
}
|
|
5
16
|
export declare const DEFAULT_LINK_CONFIGS: LinkConfig[];
|
|
6
17
|
declare enum ClassType {
|
|
@@ -40,7 +51,21 @@ export declare class APISet {
|
|
|
40
51
|
containsField(clas: ClassStruct, field: FieldStruct): boolean;
|
|
41
52
|
diff(other: APISet): APISet;
|
|
42
53
|
getAsDTS(): string;
|
|
43
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Generates markdown documentation for API differences.
|
|
56
|
+
* By default, all classes and fields are included in the output.
|
|
57
|
+
* Exclusions must be explicitly configured via the parameters.
|
|
58
|
+
*
|
|
59
|
+
* @param relativePath - The relative path for generating links
|
|
60
|
+
* @param linkConfigs - Link configuration templates (defaults to built-in Office configs)
|
|
61
|
+
* @param excludedFieldNames - Array of field names to exclude (no defaults)
|
|
62
|
+
* @param excludedClassPatterns - Array of regex patterns for classes to exclude (no defaults)
|
|
63
|
+
* @param excludedFieldPatterns - Array of regex patterns for fields to exclude (no defaults)
|
|
64
|
+
* @param includeStaticFields - Whether to include static fields (default: true)
|
|
65
|
+
* @param includeEnums - Whether to include enums (default: true)
|
|
66
|
+
* @returns Markdown table string
|
|
67
|
+
*/
|
|
68
|
+
getAsMarkdown(relativePath: string, linkConfigs?: LinkConfig[], excludedFieldNames?: string[], excludedClassPatterns?: string[], excludedFieldPatterns?: string[], includeStaticFields?: boolean, includeEnums?: boolean): string;
|
|
44
69
|
sort(): void;
|
|
45
70
|
}
|
|
46
71
|
export declare function parseDTS(fileName: string, fileContents: string): APISet;
|
package/dist/dts-utilities.js
CHANGED
|
@@ -36,47 +36,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.APISet = exports.DEFAULT_LINK_CONFIGS = void 0;
|
|
37
37
|
exports.parseDTS = parseDTS;
|
|
38
38
|
const ts = __importStar(require("typescript"));
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
// Available placeholders:
|
|
40
|
+
// {basePath} - relativePath without the trailing dot
|
|
41
|
+
// {hostName} - extracted host name (e.g., "excel", "office-scripts")
|
|
42
|
+
// {fileName} - extracted file name (e.g., "excel", "officescript")
|
|
43
|
+
// {className} - class name in lowercase
|
|
44
|
+
// {fieldName} - field/method name in lowercase
|
|
45
|
+
// {suffix} - "-member(1)" for methods/functions, "-member" for properties
|
|
46
|
+
// Default link builder using templates
|
|
47
|
+
function buildLinkFromTemplate(template, relativePath, className, field) {
|
|
48
|
+
const basePath = relativePath.substring(0, relativePath.lastIndexOf("."));
|
|
49
|
+
const hostName = relativePath.includes("/api/")
|
|
50
|
+
? relativePath.substring(relativePath.indexOf("/api/") + 5, relativePath.lastIndexOf("/"))
|
|
51
|
+
: "";
|
|
52
|
+
const fileName = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
|
|
53
|
+
let result = template
|
|
54
|
+
.replace(/{basePath}/g, basePath)
|
|
55
|
+
.replace(/{hostName}/g, hostName)
|
|
56
|
+
.replace(/{fileName}/g, fileName);
|
|
57
|
+
if (className && className !== "<global>") {
|
|
58
|
+
result = result.replace(/{className}/g, className.toLowerCase());
|
|
44
59
|
}
|
|
45
|
-
|
|
60
|
+
if (field) {
|
|
46
61
|
const suffix = (field.type === FieldType.Method || field.type === FieldType.Function) ? "-member(1)" : "-member";
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Default link builder for standard Office applications
|
|
53
|
-
function buildStandardLink(relativePath, className, field) {
|
|
54
|
-
if (className === "<global>") {
|
|
55
|
-
const hostName = relativePath.substring(relativePath.indexOf("/api/") + 5, relativePath.lastIndexOf("/"));
|
|
56
|
-
const fileName = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
|
|
57
|
-
const basePath = relativePath.substring(0, relativePath.lastIndexOf("."));
|
|
58
|
-
const anchorPrefix = hostName + "-" + fileName + "-";
|
|
59
|
-
return "/" + basePath + "#" + anchorPrefix + field.name.toLowerCase() + "-function(1)";
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
const hostName = relativePath.substring(relativePath.indexOf("/api/") + 5, relativePath.lastIndexOf("/"));
|
|
63
|
-
const fileName = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
|
|
64
|
-
const suffix = (field.type === FieldType.Method || field.type === FieldType.Function) ? "-member(1)" : "-member";
|
|
65
|
-
const url = "/" + relativePath + className.toLowerCase();
|
|
66
|
-
const anchorPrefix = hostName + "-" + fileName + "-";
|
|
67
|
-
const anchor = anchorPrefix + className.toLowerCase() + "-" + field.name.toLowerCase() + suffix;
|
|
68
|
-
return url + "#" + anchor;
|
|
62
|
+
result = result
|
|
63
|
+
.replace(/{fieldName}/g, field.name.toLowerCase())
|
|
64
|
+
.replace(/{suffix}/g, suffix);
|
|
69
65
|
}
|
|
66
|
+
return result;
|
|
70
67
|
}
|
|
71
68
|
// Default configurations for known Office applications
|
|
72
69
|
exports.DEFAULT_LINK_CONFIGS = [
|
|
73
70
|
{
|
|
74
71
|
pathPattern: "office-scripts",
|
|
75
|
-
|
|
72
|
+
globalFunctionTemplate: "/{basePath}#officescript-officescript-{fieldName}-function(1)",
|
|
73
|
+
classTemplate: "/{basePath}/officescript.{className}",
|
|
74
|
+
classMemberTemplate: "/{basePath}/officescript.{className}#officescript-officescript-{className}-{fieldName}{suffix}"
|
|
76
75
|
},
|
|
77
76
|
{
|
|
78
77
|
pathPattern: ".*", // matches any path as fallback
|
|
79
|
-
|
|
78
|
+
globalFunctionTemplate: "/{basePath}#{hostName}-{fileName}-{fieldName}-function(1)",
|
|
79
|
+
classTemplate: "/{basePath}.{className}",
|
|
80
|
+
classMemberTemplate: "/{basePath}.{className}#{hostName}-{fileName}-{className}-{fieldName}{suffix}"
|
|
80
81
|
}
|
|
81
82
|
];
|
|
82
83
|
// capturing these because of eccentricities with the compiler ordering
|
|
@@ -199,42 +200,69 @@ class APISet {
|
|
|
199
200
|
});
|
|
200
201
|
return output.join("\n");
|
|
201
202
|
}
|
|
202
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Generates markdown documentation for API differences.
|
|
205
|
+
* By default, all classes and fields are included in the output.
|
|
206
|
+
* Exclusions must be explicitly configured via the parameters.
|
|
207
|
+
*
|
|
208
|
+
* @param relativePath - The relative path for generating links
|
|
209
|
+
* @param linkConfigs - Link configuration templates (defaults to built-in Office configs)
|
|
210
|
+
* @param excludedFieldNames - Array of field names to exclude (no defaults)
|
|
211
|
+
* @param excludedClassPatterns - Array of regex patterns for classes to exclude (no defaults)
|
|
212
|
+
* @param excludedFieldPatterns - Array of regex patterns for fields to exclude (no defaults)
|
|
213
|
+
* @param includeStaticFields - Whether to include static fields (default: true)
|
|
214
|
+
* @param includeEnums - Whether to include enums (default: true)
|
|
215
|
+
* @returns Markdown table string
|
|
216
|
+
*/
|
|
217
|
+
getAsMarkdown(relativePath, linkConfigs = exports.DEFAULT_LINK_CONFIGS, excludedFieldNames = [], excludedClassPatterns = [], excludedFieldPatterns = [], includeStaticFields = true, includeEnums = false) {
|
|
203
218
|
this.sort();
|
|
204
219
|
// table header
|
|
205
220
|
let output = "| Class | Fields | Description |\n|:---|:---|:---|\n";
|
|
206
221
|
this.api.forEach((clas) => {
|
|
207
222
|
// Ignore the following:
|
|
208
|
-
// - Enums.
|
|
209
|
-
// -
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
223
|
+
// - Enums (configurable via includeEnums, default: true - enums included by default).
|
|
224
|
+
// - Classes matching excluded patterns (configurable, no defaults - all classes included unless explicitly excluded)
|
|
225
|
+
const className = clas.getClassName();
|
|
226
|
+
const isExcludedByPattern = excludedClassPatterns.some(pattern => {
|
|
227
|
+
try {
|
|
228
|
+
return new RegExp(pattern).test(className);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.warn(`Invalid regex pattern "${pattern}": ${error.message}`);
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const isEnum = clas.type === ClassType.Enum;
|
|
236
|
+
if ((includeEnums || !isEnum) && !isExcludedByPattern) {
|
|
214
237
|
const className = clas.getClassName();
|
|
215
238
|
// Special handling for <global> - no link
|
|
216
239
|
if (className === "<global>") {
|
|
217
240
|
output += "|*global*|";
|
|
218
241
|
}
|
|
219
242
|
else {
|
|
220
|
-
output += "|[" + className + "](
|
|
221
|
-
+ relativePath
|
|
243
|
+
output += "|[" + className + "]("
|
|
244
|
+
+ buildClassLink(relativePath, className, linkConfigs) + ")|";
|
|
222
245
|
}
|
|
223
246
|
// Ignore the following:
|
|
224
|
-
// -
|
|
225
|
-
// -
|
|
226
|
-
// -
|
|
227
|
-
// - Static fields.
|
|
247
|
+
// - Fields matching excluded patterns (configurable, no defaults - all fields included unless explicitly excluded)
|
|
248
|
+
// - Excluded field names (configurable, no defaults - all field names included unless explicitly excluded)
|
|
249
|
+
// - Static fields (configurable via includeStaticFields, default: true - static fields included by default)
|
|
228
250
|
let filteredFields = clas.fields.filter((field) => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
251
|
+
// Check if field matches any excluded pattern
|
|
252
|
+
const isExcludedByPattern = excludedFieldPatterns.some(pattern => {
|
|
253
|
+
try {
|
|
254
|
+
return new RegExp(pattern, 'g').test(field.declarationString);
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.warn(`Invalid field regex pattern "${pattern}": ${error.message}`);
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
// Check if field is static and should be excluded
|
|
262
|
+
const isStaticField = field.declarationString.includes("static ");
|
|
263
|
+
return (!isExcludedByPattern &&
|
|
264
|
+
!excludedFieldNames.includes(field.name) &&
|
|
265
|
+
(includeStaticFields || !isStaticField));
|
|
238
266
|
});
|
|
239
267
|
let first = true;
|
|
240
268
|
if (filteredFields.length > 0) {
|
|
@@ -320,11 +348,21 @@ function removeAtLink(commentText) {
|
|
|
320
348
|
commentText = commentText.replace(/{@link ([^}]*?) \| (http.*?)}/gm, "[$1]($2)");
|
|
321
349
|
return commentText;
|
|
322
350
|
}
|
|
351
|
+
function buildClassLink(relativePath, className, linkConfigs = exports.DEFAULT_LINK_CONFIGS) {
|
|
352
|
+
// Find the first matching configuration
|
|
353
|
+
const config = linkConfigs.find(config => new RegExp(config.pathPattern).test(relativePath)) || exports.DEFAULT_LINK_CONFIGS[exports.DEFAULT_LINK_CONFIGS.length - 1]; // fallback to last config
|
|
354
|
+
return buildLinkFromTemplate(config.classTemplate, relativePath, className);
|
|
355
|
+
}
|
|
323
356
|
function buildFieldLink(relativePath, className, field, linkConfigs = exports.DEFAULT_LINK_CONFIGS) {
|
|
324
357
|
// Find the first matching configuration
|
|
325
358
|
const config = linkConfigs.find(config => new RegExp(config.pathPattern).test(relativePath)) || exports.DEFAULT_LINK_CONFIGS[exports.DEFAULT_LINK_CONFIGS.length - 1]; // fallback to last config
|
|
326
|
-
// Use
|
|
327
|
-
|
|
359
|
+
// Use appropriate template based on whether it's a global function or class member
|
|
360
|
+
if (className.trim() === "<global>") {
|
|
361
|
+
return buildLinkFromTemplate(config.globalFunctionTemplate, relativePath, className, field);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
return buildLinkFromTemplate(config.classMemberTemplate, relativePath, className, field);
|
|
365
|
+
}
|
|
328
366
|
}
|
|
329
367
|
function parseDTS(fileName, fileContents) {
|
|
330
368
|
// Reset global state for new parse
|
package/dist/whats-new.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { LinkConfig } from './dts-utilities';
|
|
3
|
-
export declare function generateWhatsNew(newDtsPath: string, oldDtsPath: string, outputPath: string, relativePath: string, linkConfigs?: LinkConfig[], configFilePath?: string): void;
|
|
3
|
+
export declare function generateWhatsNew(newDtsPath: string, oldDtsPath: string, outputPath: string, relativePath: string, linkConfigs?: LinkConfig[], configFilePath?: string, excludedFieldNames?: string[], excludedClassPatterns?: string[], excludedFieldPatterns?: string[], includeStaticFields?: boolean, includeEnums?: boolean): void;
|
package/dist/whats-new.js
CHANGED
|
@@ -38,36 +38,72 @@ exports.generateWhatsNew = generateWhatsNew;
|
|
|
38
38
|
const fsx = __importStar(require("fs-extra"));
|
|
39
39
|
const dts_utilities_1 = require("./dts-utilities");
|
|
40
40
|
/**
|
|
41
|
-
* Loads
|
|
41
|
+
* Loads configuration from a JSON file
|
|
42
42
|
* @param configFilePath Path to the configuration file
|
|
43
|
-
* @returns
|
|
43
|
+
* @returns Configuration object with linkConfigs, excludedFieldNames, excludedClassPatterns, excludedFieldPatterns, includeStaticFields, and includeEnums
|
|
44
44
|
*/
|
|
45
|
-
function
|
|
45
|
+
function loadWhatsNewConfig(configFilePath) {
|
|
46
46
|
try {
|
|
47
47
|
const configContent = fsx.readFileSync(configFilePath, 'utf8');
|
|
48
48
|
const config = JSON.parse(configContent);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
:
|
|
59
|
-
|
|
49
|
+
let linkConfigs = undefined;
|
|
50
|
+
// Handle linkConfigs if present
|
|
51
|
+
if (config.linkConfigs) {
|
|
52
|
+
linkConfigs = config.linkConfigs.map((item) => {
|
|
53
|
+
if (!item.globalFunctionTemplate || !item.classTemplate || !item.classMemberTemplate) {
|
|
54
|
+
throw new Error(`Configuration item missing required template properties: ${JSON.stringify(item)}`);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
pathPattern: item.pathPattern,
|
|
58
|
+
globalFunctionTemplate: item.globalFunctionTemplate,
|
|
59
|
+
classTemplate: item.classTemplate,
|
|
60
|
+
classMemberTemplate: item.classMemberTemplate
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
linkConfigs,
|
|
66
|
+
excludedFieldNames: config.excludedFieldNames,
|
|
67
|
+
excludedClassPatterns: config.excludedClassPatterns,
|
|
68
|
+
excludedFieldPatterns: config.excludedFieldPatterns,
|
|
69
|
+
includeStaticFields: config.includeStaticFields,
|
|
70
|
+
includeEnums: config.includeEnums
|
|
71
|
+
};
|
|
60
72
|
}
|
|
61
73
|
catch (error) {
|
|
62
74
|
console.warn(`Could not load config file ${configFilePath}: ${error}. Using default configuration.`);
|
|
63
|
-
return
|
|
75
|
+
return {};
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
|
-
function generateWhatsNew(newDtsPath, oldDtsPath, outputPath, relativePath, linkConfigs, configFilePath) {
|
|
78
|
+
function generateWhatsNew(newDtsPath, oldDtsPath, outputPath, relativePath, linkConfigs, configFilePath, excludedFieldNames, excludedClassPatterns, excludedFieldPatterns, includeStaticFields, includeEnums) {
|
|
67
79
|
// Load configuration from file if provided
|
|
68
80
|
let effectiveLinkConfigs = linkConfigs;
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
let effectiveExcludedFieldNames = excludedFieldNames;
|
|
82
|
+
let effectiveExcludedClassPatterns = excludedClassPatterns;
|
|
83
|
+
let effectiveExcludedFieldPatterns = excludedFieldPatterns;
|
|
84
|
+
let effectiveIncludeStaticFields = includeStaticFields;
|
|
85
|
+
let effectiveIncludeEnums = includeEnums;
|
|
86
|
+
if (configFilePath && (!linkConfigs || !excludedFieldNames || !excludedClassPatterns || !excludedFieldPatterns || includeStaticFields === undefined || includeEnums === undefined)) {
|
|
87
|
+
const config = loadWhatsNewConfig(configFilePath);
|
|
88
|
+
if (!linkConfigs && config.linkConfigs) {
|
|
89
|
+
effectiveLinkConfigs = config.linkConfigs;
|
|
90
|
+
}
|
|
91
|
+
if (!excludedFieldNames && config.excludedFieldNames) {
|
|
92
|
+
effectiveExcludedFieldNames = config.excludedFieldNames;
|
|
93
|
+
}
|
|
94
|
+
if (!excludedClassPatterns && config.excludedClassPatterns) {
|
|
95
|
+
effectiveExcludedClassPatterns = config.excludedClassPatterns;
|
|
96
|
+
}
|
|
97
|
+
if (!excludedFieldPatterns && config.excludedFieldPatterns) {
|
|
98
|
+
effectiveExcludedFieldPatterns = config.excludedFieldPatterns;
|
|
99
|
+
}
|
|
100
|
+
if (includeStaticFields === undefined && config.includeStaticFields !== undefined) {
|
|
101
|
+
effectiveIncludeStaticFields = config.includeStaticFields;
|
|
102
|
+
}
|
|
103
|
+
if (includeEnums === undefined) {
|
|
104
|
+
// Default to true when loading from config (inclusive by default)
|
|
105
|
+
effectiveIncludeEnums = config.includeEnums !== undefined ? config.includeEnums : true;
|
|
106
|
+
}
|
|
71
107
|
}
|
|
72
108
|
// read whole files
|
|
73
109
|
let wholeRelease = fsx.readFileSync(oldDtsPath).toString();
|
|
@@ -78,7 +114,7 @@ function generateWhatsNew(newDtsPath, oldDtsPath, outputPath, relativePath, link
|
|
|
78
114
|
if (!fsx.existsSync(outputPath + ".md")) {
|
|
79
115
|
fsx.createFileSync(outputPath + ".md");
|
|
80
116
|
}
|
|
81
|
-
fsx.writeFileSync(outputPath + ".md", diffAPI.getAsMarkdown(relativePath, effectiveLinkConfigs));
|
|
117
|
+
fsx.writeFileSync(outputPath + ".md", diffAPI.getAsMarkdown(relativePath, effectiveLinkConfigs, effectiveExcludedFieldNames, effectiveExcludedClassPatterns, effectiveExcludedFieldPatterns, effectiveIncludeStaticFields, effectiveIncludeEnums));
|
|
82
118
|
}
|
|
83
119
|
// CLI entry point
|
|
84
120
|
if (require.main === module) {
|