versioned-d.ts-tools 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alex Jerabek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Versioned D.TS Tools
2
+
3
+ A collection of command-line tools for managing versioned TypeScript definition files, particularly useful for API documentation and version comparison.
4
+
5
+ ## Installation
6
+
7
+ Install globally to use the CLI tools from anywhere:
8
+
9
+ ```bash
10
+ npm install -g versioned-d.ts-tools
11
+ ```
12
+
13
+ Or install locally in your project:
14
+
15
+ ```bash
16
+ npm install versioned-d.ts-tools
17
+ ```
18
+
19
+ ## CLI Tools
20
+
21
+ ### version-remover
22
+
23
+ Removes specific API versions from TypeScript definition files.
24
+
25
+ ```bash
26
+ version-remover [source d.ts] [API set name] [output file name]
27
+ ```
28
+
29
+ **Example:**
30
+ ```bash
31
+ version-remover excel.d.ts "ExcelApi 1.8" excel_1_7.d.ts
32
+ ```
33
+
34
+ This tool removes all declarations marked with the specified API set version from the source `.d.ts` file and creates a new file with the remaining declarations.
35
+
36
+ ### whats-new
37
+
38
+ Compares two TypeScript definition files and generates a markdown report of the differences.
39
+
40
+ ```bash
41
+ whats-new [host name] [new d.ts] [old d.ts] [output file name (minus extension)]
42
+ ```
43
+
44
+ **Example:**
45
+ ```bash
46
+ whats-new Excel excel_1_9.d.ts excel_1_8.d.ts excel_whats_new
47
+ ```
48
+
49
+ This generates a `excel_whats_new.md` file containing a markdown table showing what's new between the two versions.
50
+
51
+ ## Programmatic Usage
52
+
53
+ You can also use the utilities programmatically in your own Node.js applications:
54
+
55
+ ```javascript
56
+ const { APISet, parseDTS } = require('versioned-d.ts-tools');
57
+
58
+ // Parse a TypeScript definition file
59
+ const apiSet = parseDTS('filename', fileContents);
60
+
61
+ // Compare two API sets
62
+ const diff = newApiSet.diff(oldApiSet);
63
+
64
+ // Generate markdown output
65
+ const markdown = diff.getAsMarkdown('javascript/api/excel/');
66
+ ```
67
+
68
+ ## License
69
+
70
+ MIT
@@ -0,0 +1,41 @@
1
+ declare enum ClassType {
2
+ Class = "Class",
3
+ Interface = "Interface",
4
+ Enum = "Enum"
5
+ }
6
+ declare enum FieldType {
7
+ Property = "Property",
8
+ Method = "Method",
9
+ Event = "Event",
10
+ Enum = "Enum"
11
+ }
12
+ declare class FieldStruct {
13
+ declarationString: string;
14
+ comment: string;
15
+ type: FieldType;
16
+ name: string;
17
+ constructor(decString: string, commentString: string, fieldType: FieldType, fieldName: string);
18
+ }
19
+ declare class ClassStruct {
20
+ declarationString: string;
21
+ comment: string;
22
+ type: ClassType;
23
+ fields: FieldStruct[];
24
+ constructor(decString: any, commentString: string, classType: ClassType);
25
+ copyWithoutFields(): ClassStruct;
26
+ sortFields(): void;
27
+ getClassName(): string;
28
+ }
29
+ export declare class APISet {
30
+ api: ClassStruct[];
31
+ constructor();
32
+ addClass(clas: ClassStruct): void;
33
+ containsClass(clas: ClassStruct): boolean;
34
+ containsField(clas: ClassStruct, field: FieldStruct): boolean;
35
+ diff(other: APISet): APISet;
36
+ getAsDTS(): string;
37
+ getAsMarkdown(relativePath: string): string;
38
+ sort(): void;
39
+ }
40
+ export declare function parseDTS(fileName: string, fileContents: string): APISet;
41
+ export {};
@@ -0,0 +1,306 @@
1
+ "use strict";
2
+ var __importStar = (this && this.__importStar) || function (mod) {
3
+ if (mod && mod.__esModule) return mod;
4
+ var result = {};
5
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
+ result["default"] = mod;
7
+ return result;
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const ts = __importStar(require("typescript"));
11
+ // capturing these because of eccentricities with the compiler ordering
12
+ let topClass = null;
13
+ let lastItem = null;
14
+ var ClassType;
15
+ (function (ClassType) {
16
+ ClassType["Class"] = "Class";
17
+ ClassType["Interface"] = "Interface";
18
+ ClassType["Enum"] = "Enum";
19
+ })(ClassType || (ClassType = {}));
20
+ var FieldType;
21
+ (function (FieldType) {
22
+ FieldType["Property"] = "Property";
23
+ FieldType["Method"] = "Method";
24
+ FieldType["Event"] = "Event";
25
+ FieldType["Enum"] = "Enum";
26
+ })(FieldType || (FieldType = {}));
27
+ class FieldStruct {
28
+ constructor(decString, commentString, fieldType, fieldName) {
29
+ this.declarationString = decString;
30
+ this.comment = commentString;
31
+ this.type = fieldType;
32
+ this.name = fieldName;
33
+ }
34
+ }
35
+ class ClassStruct {
36
+ constructor(decString, commentString, classType) {
37
+ this.declarationString = decString;
38
+ this.comment = commentString;
39
+ this.type = classType;
40
+ this.fields = [];
41
+ }
42
+ copyWithoutFields() {
43
+ return new ClassStruct(this.declarationString, this.comment, this.type);
44
+ }
45
+ sortFields() {
46
+ this.fields.sort((a, b) => {
47
+ if (a.declarationString === b.declarationString) {
48
+ return 0;
49
+ }
50
+ else {
51
+ return a.declarationString.replace("readonly ", "") < b.declarationString.replace("readonly ", "") ? -1 : 1;
52
+ }
53
+ });
54
+ }
55
+ getClassName() {
56
+ return this.declarationString.substring(this.declarationString.lastIndexOf(" ") + 1);
57
+ }
58
+ }
59
+ class APISet {
60
+ constructor() {
61
+ this.api = [];
62
+ }
63
+ addClass(clas) {
64
+ this.api.push(clas);
65
+ }
66
+ containsClass(clas) {
67
+ let found = false;
68
+ this.api.forEach((element) => {
69
+ if (element.declarationString === clas.declarationString) {
70
+ found = true;
71
+ }
72
+ });
73
+ return found;
74
+ }
75
+ containsField(clas, field) {
76
+ let found = false;
77
+ this.api.forEach((element) => {
78
+ if (element.declarationString === clas.declarationString) {
79
+ element.fields.forEach((thisField) => {
80
+ if (thisField.declarationString === field.declarationString) {
81
+ found = true;
82
+ }
83
+ });
84
+ }
85
+ });
86
+ return found;
87
+ }
88
+ // finds the new fields and classes
89
+ diff(other) {
90
+ const diffAPI = new APISet();
91
+ this.api.forEach((element) => {
92
+ if (other.containsClass(element)) {
93
+ let classShell = null;
94
+ element.fields.forEach((field) => {
95
+ if (!other.containsField(element, field)) {
96
+ if (classShell === null) {
97
+ classShell = element.copyWithoutFields();
98
+ diffAPI.addClass(classShell);
99
+ }
100
+ classShell.fields.push(field);
101
+ }
102
+ });
103
+ }
104
+ else {
105
+ diffAPI.addClass(element);
106
+ }
107
+ });
108
+ return diffAPI;
109
+ }
110
+ getAsDTS() {
111
+ this.sort();
112
+ const output = [];
113
+ this.api.forEach((clas) => {
114
+ output.push(clas.comment.trim());
115
+ output.push(clas.declarationString + " {");
116
+ clas.fields.forEach((field) => {
117
+ output.push(" " + field.comment);
118
+ if (field.type === FieldType.Enum) {
119
+ output.push(" " + field.declarationString + ",");
120
+ }
121
+ else {
122
+ output.push(" " + field.declarationString);
123
+ }
124
+ });
125
+ output.push("}");
126
+ });
127
+ return output.join("\n");
128
+ }
129
+ getAsMarkdown(relativePath) {
130
+ this.sort();
131
+ // table header
132
+ let output = "| Class | Fields | Description |\n|:---|:---|:---|\n";
133
+ this.api.forEach((clas) => {
134
+ // Ignore the following:
135
+ // - Enums.
136
+ // - LoadOptions interfaces
137
+ // - *Data classes for set/load methods
138
+ if (clas.type !== ClassType.Enum &&
139
+ !clas.getClassName().endsWith("LoadOptions") &&
140
+ !clas.getClassName().endsWith("Data")) {
141
+ const className = clas.getClassName();
142
+ output += "|[" + className + "](/"
143
+ + relativePath + className.toLowerCase() + ")|";
144
+ // Ignore the following:
145
+ // - String literal overloads.
146
+ // - `load`, `set`, `track`, `untrack`, and `toJSON` methods
147
+ // - The `context` property.
148
+ // - Static fields.
149
+ let filteredFields = clas.fields.filter((field) => {
150
+ let isLiteral = field.declarationString.search(/([a-zA-Z]+)(\??:)([\n]?([ |]*\"[\w]*\"[|,\n]*)+?)([ ]*[\),])/g) >= 0;
151
+ return (!isLiteral &&
152
+ field.name !== "load" &&
153
+ field.name !== "set" &&
154
+ field.name !== "toJSON" &&
155
+ field.name !== "context" &&
156
+ field.name !== "track" &&
157
+ field.name !== "untrack" &&
158
+ !field.declarationString.includes("static "));
159
+ });
160
+ let first = true;
161
+ if (filteredFields.length > 0) {
162
+ filteredFields.forEach((field) => {
163
+ if (first) {
164
+ first = false;
165
+ }
166
+ else {
167
+ output += "||";
168
+ }
169
+ // remove unnecessary parts of the declaration string
170
+ let newItemText = field.declarationString.replace(/;/g, "");
171
+ if (field.type === FieldType.Property) {
172
+ // Remove the optional modifier and type.
173
+ newItemText = newItemText.replace(/\?/g, "");
174
+ newItemText = newItemText.substring(0, newItemText.indexOf(":"));
175
+ }
176
+ else {
177
+ // Remove the return type.
178
+ newItemText = newItemText.substring(0, newItemText.lastIndexOf(":"));
179
+ }
180
+ newItemText = newItemText.replace("readonly ", "");
181
+ newItemText = newItemText.replace(/\|/g, "\\|").replace(/\n|\t/gm, "");
182
+ newItemText = newItemText.replace(/[\s][\s]+/g, " ").replace(/\( /g, "(").replace(/ \)/g, ")").replace(/,\)/g, ")").replace(/([\w]\??: )\\\| /g, "$1"); // dprint formatting quirks
183
+ newItemText = newItemText.replace(/\<any\>/g, "");
184
+ let tableLine = "[" + newItemText + "]("
185
+ + buildFieldLink(relativePath, className, field) + ")|";
186
+ tableLine += removeAtLink(extractFirstSentenceFromComment(field.comment));
187
+ output += tableLine + "|\n";
188
+ });
189
+ }
190
+ else {
191
+ output += "||\n";
192
+ }
193
+ }
194
+ });
195
+ return output;
196
+ }
197
+ sort() {
198
+ this.api.forEach((element) => {
199
+ element.sortFields();
200
+ });
201
+ this.api.sort((a, b) => {
202
+ if (a.getClassName() === b.getClassName()) {
203
+ return 0;
204
+ }
205
+ else {
206
+ return a.getClassName() < b.getClassName() ? -1 : 1;
207
+ }
208
+ });
209
+ }
210
+ }
211
+ exports.APISet = APISet;
212
+ function extractFirstSentenceFromComment(commentText) {
213
+ const firstSentenceIndex = commentText.indexOf("* ") + 2;
214
+ const multiSentenceEndIndex = commentText.indexOf(". ", firstSentenceIndex);
215
+ const lineBreakEndIndex = commentText.indexOf("\n", firstSentenceIndex);
216
+ const singleLineEndIndex = commentText.indexOf("\*/", firstSentenceIndex);
217
+ let endIndex;
218
+ if (multiSentenceEndIndex > 0 && lineBreakEndIndex > 0) {
219
+ endIndex = Math.min(multiSentenceEndIndex + 1, lineBreakEndIndex);
220
+ }
221
+ else if (multiSentenceEndIndex === -1 && lineBreakEndIndex === -1) {
222
+ endIndex = singleLineEndIndex;
223
+ }
224
+ else {
225
+ endIndex = Math.max(multiSentenceEndIndex + 1, lineBreakEndIndex);
226
+ }
227
+ return commentText.substring(firstSentenceIndex, endIndex).trim();
228
+ }
229
+ function removeAtLink(commentText) {
230
+ // Replace links with the format "{@link Foo}" with "Foo".
231
+ commentText = commentText.replace(/{@link ([^|]*?)}/gm, "$1");
232
+ // Replace links with the format "{@link Foo | URL}" with "[Foo](URL)".
233
+ commentText = commentText.replace(/{@link ([^}]*?) \| (http.*?)}/gm, "[$1]($2)");
234
+ return commentText;
235
+ }
236
+ function buildFieldLink(relativePath, className, field) {
237
+ // Build the standard link anchor format based on host.
238
+ let anchorPrefix = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
239
+ anchorPrefix = (relativePath.indexOf("outlook") > 0 ? "outlook" : anchorPrefix) + "-" + anchorPrefix + "-";
240
+ let fieldLink = "/" + relativePath.replace("api/outlook/outlook", "api/outlook/office") + className.toLowerCase() + "#" + anchorPrefix + className.toLowerCase() + "-" + field.name.toLowerCase() + (field.type === FieldType.Method ? "-member(1)" : "-member");
241
+ return fieldLink;
242
+ }
243
+ function parseDTS(fileName, fileContents) {
244
+ const node = ts.createSourceFile(fileName, fileContents, ts.ScriptTarget.ES2015, true);
245
+ const allClasses = new APISet();
246
+ parseDTSInternal(node, allClasses);
247
+ return allClasses;
248
+ }
249
+ exports.parseDTS = parseDTS;
250
+ function parseDTSInternal(node, allClasses) {
251
+ switch (node.kind) {
252
+ case ts.SyntaxKind.InterfaceDeclaration:
253
+ parseDTSTopLevelItem(node, allClasses, ClassType.Interface);
254
+ break;
255
+ case ts.SyntaxKind.ClassDeclaration:
256
+ parseDTSTopLevelItem(node, allClasses, ClassType.Class);
257
+ break;
258
+ case ts.SyntaxKind.EnumDeclaration:
259
+ parseDTSTopLevelItem(node, allClasses, ClassType.Enum);
260
+ break;
261
+ case ts.SyntaxKind.PropertySignature:
262
+ parseDTSFieldItem(node, FieldType.Property);
263
+ break;
264
+ case ts.SyntaxKind.PropertyDeclaration:
265
+ parseDTSFieldItem(node, FieldType.Property);
266
+ break;
267
+ case ts.SyntaxKind.EnumMember:
268
+ parseDTSFieldItem(node, FieldType.Enum);
269
+ break;
270
+ case ts.SyntaxKind.MethodSignature:
271
+ parseDTSFieldItem(node, FieldType.Method);
272
+ break;
273
+ case ts.SyntaxKind.MethodDeclaration:
274
+ parseDTSFieldItem(node, FieldType.Method);
275
+ break;
276
+ case ts.SyntaxKind.TypeLiteral:
277
+ return;
278
+ default:
279
+ // the compiler parses comments after the class/field, therefore this connects to the previous item
280
+ if (node.getText().indexOf("/**") >= 0 &&
281
+ node.getText().indexOf("*/") >= 0 &&
282
+ lastItem !== null &&
283
+ lastItem.comment === "") {
284
+ // clean up spacing as best we can for the diffed d.ts
285
+ lastItem.comment = node.getText().replace(/ \*/g, "*");
286
+ if (lastItem.comment.indexOf("@eventproperty") >= 0) {
287
+ // events are indistinguishable from properties aside from this tag
288
+ lastItem.type = FieldType.Event;
289
+ }
290
+ }
291
+ }
292
+ node.getChildren().forEach((element) => {
293
+ parseDTSInternal(element, allClasses);
294
+ });
295
+ }
296
+ function parseDTSTopLevelItem(node, allClasses, type) {
297
+ topClass = new ClassStruct("export " + type.toLowerCase() + " " + node.name.text, "", type);
298
+ allClasses.addClass(topClass);
299
+ lastItem = topClass;
300
+ }
301
+ function parseDTSFieldItem(node, type) {
302
+ const newField = new FieldStruct(node.getText(), "", type, node.name.getText());
303
+ topClass.fields.push(newField);
304
+ lastItem = newField;
305
+ }
306
+ //# sourceMappingURL=dts-utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dts-utilities.js","sourceRoot":"","sources":["../src/dts-utilities.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAiC;AAEjC,uEAAuE;AACvE,IAAI,QAAQ,GAAgB,IAAI,CAAC;AACjC,IAAI,QAAQ,GAA8B,IAAI,CAAC;AAE/C,IAAK,SAIJ;AAJD,WAAK,SAAS;IACV,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,0BAAa,CAAA;AACjB,CAAC,EAJI,SAAS,KAAT,SAAS,QAIb;AAED,IAAK,SAKJ;AALD,WAAK,SAAS;IACV,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,4BAAe,CAAA;IACf,0BAAa,CAAA;AACjB,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAED,MAAM,WAAW;IAMb,YAAY,SAAiB,EAAE,aAAqB,EAAE,SAAoB,EAAE,SAAiB;QACzF,I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AC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,oBAAoB,CACzB,IAAwE,EACxE,UAAkB,EAClB,IAAe;IACf,QAAQ,GAAG,IAAI,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5F,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,GAAG,QAAQ,CAAC;AACxB,CAAC;AAED,SAAS,iBAAiB,CACtB,IAA+G,EAC/G,IAAe;IACf,MAAM,QAAQ,GAAgB,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7F,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,QAAQ,GAAG,QAAQ,CAAC;AACxB,CAAC"}
@@ -0,0 +1 @@
1
+ export { APISet, parseDTS } from './dts-utilities';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var dts_utilities_1 = require("./dts-utilities");
4
+ exports.APISet = dts_utilities_1.APISet;
5
+ exports.parseDTS = dts_utilities_1.parseDTS;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,iDAAmD;AAA1C,iCAAA,MAAM,CAAA;AAAE,mCAAA,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importStar = (this && this.__importStar) || function (mod) {
4
+ if (mod && mod.__esModule) return mod;
5
+ var result = {};
6
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7
+ result["default"] = mod;
8
+ return result;
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ const fsx = __importStar(require("fs-extra"));
12
+ if (process.argv.length !== 5 || process.argv.find((x) => { return x === "-?"; })) {
13
+ console.log("usage: node version-remover [source d.ts] [API set name] [output file name]");
14
+ console.log("example: node version-remover excel.d.ts \"ExcelApi 1.8\" excel_1_7.d.ts");
15
+ process.exit(0);
16
+ }
17
+ console.log("Version Remover - Creating " + process.argv[4]);
18
+ let wholeDts = fsx.readFileSync(process.argv[2]).toString();
19
+ let declarationString;
20
+ // find the API tag
21
+ let indexOfApiSetTag = wholeDts.indexOf("Api set: " + process.argv[3]);
22
+ while (indexOfApiSetTag >= 0) {
23
+ // find the comment block around the API tag
24
+ let commentStart = wholeDts.lastIndexOf("/**", indexOfApiSetTag);
25
+ let commentEnd = wholeDts.indexOf("*/", indexOfApiSetTag);
26
+ commentEnd = wholeDts.indexOf("\n", commentEnd) + 1; // Account for newline and ending characters.
27
+ // the declaration string is the line following the comment
28
+ declarationString = wholeDts.substring(commentEnd, wholeDts.indexOf("\n", commentEnd));
29
+ let endPosition = commentEnd + declarationString.length;
30
+ if (declarationString.indexOf("class") >= 0 ||
31
+ declarationString.indexOf("enum") >= 0 ||
32
+ declarationString.indexOf("interface") >= 0) {
33
+ // Discount internal bracket pairs.
34
+ let nextStartBrace = wholeDts.indexOf("{", endPosition);
35
+ let nextEndBrace = wholeDts.indexOf("}", endPosition);
36
+ while (nextStartBrace < nextEndBrace && nextStartBrace >= 0) {
37
+ nextStartBrace = wholeDts.indexOf("{", nextStartBrace + 1);
38
+ nextEndBrace = wholeDts.indexOf("}", nextEndBrace + 1);
39
+ }
40
+ endPosition = wholeDts.indexOf("}", nextEndBrace - 1);
41
+ }
42
+ else {
43
+ endPosition = getDeclarationEnd(wholeDts, commentEnd);
44
+ }
45
+ if (endPosition === -1) {
46
+ endPosition = commentEnd;
47
+ }
48
+ wholeDts = wholeDts.substring(0, commentStart) + wholeDts.substring(endPosition + 1);
49
+ indexOfApiSetTag = wholeDts.indexOf("Api set: " + process.argv[3]);
50
+ }
51
+ /* Add necessary custom logic here*/
52
+ if (process.argv[3] === "ExcelApi 1.19") {
53
+ console.log("Address CardLayoutTwoColumnSection reference for when removing ExcelApi 1.19");
54
+ wholeDts = wholeDts.replace(/type CardLayoutSection = CardLayoutListSection \| CardLayoutTableSection \| CardLayoutTwoColumnSection;/g, "type CardLayoutSection = CardLayoutListSection | CardLayoutTableSection;");
55
+ console.log("Address EntityCompactLayoutIcons reference for when removing ExcelApi 1.19");
56
+ wholeDts = wholeDts.replace(/icon\?: string \| EntityCompactLayoutIcons;/g, "icon?: string;");
57
+ console.log("Address EntityCompactLayoutIcons reference for when removing ExcelApi 1.19");
58
+ wholeDts = wholeDts.replace(/type CellValue = \(ArrayCellValue \| BooleanCellValue \| DoubleCellValue \| EntityCellValue \| EmptyCellValue \| ErrorCellValue \| FormattedNumberCellValue \| FunctionCellValue \| LinkedEntityCellValue \| ReferenceCellValue \| StringCellValue \| ValueTypeNotAvailableCellValue \| WebImageCellValue\) \& CellValueExtraProperties;/g, "type CellValue = (ArrayCellValue | BooleanCellValue | DoubleCellValue | EntityCellValue | EmptyCellValue | ErrorCellValue | LinkedEntityCellValue | ReferenceCellValue | StringCellValue | ValueTypeNotAvailableCellValue | WebImageCellValue) & CellValueExtraProperties;");
59
+ }
60
+ if (process.argv[3] === "ExcelApi 1.11") {
61
+ console.log("Address CommentRichContent reference for when removing ExcelApi 1.11");
62
+ wholeDts = wholeDts.replace(/content: CommentRichContent \| string,/g, "content: string,");
63
+ }
64
+ if (process.argv[3] === "Mailbox 1.14") {
65
+ console.log("Address SpamReportingEventCompletedOptions reference when removing Mailbox 1.14");
66
+ wholeDts = wholeDts.replace(/options\?: SmartAlertsEventCompletedOptions \| SpamReportingEventCompletedOptions/g, "options?: SmartAlertsEventCompletedOptions");
67
+ }
68
+ if (process.argv[3] === "Mailbox 1.12") {
69
+ console.log("Address SmartAlertsEventCompletedOptions reference when removing Mailbox 1.12");
70
+ wholeDts = wholeDts.replace(/options\?: SmartAlertsEventCompletedOptions/g, "");
71
+ wholeDts = wholeDts.replace(/@param options - Optional. An object that specifies the behavior of an event-based or spam-reporting add-in when it completes processing an event./g, "");
72
+ }
73
+ if (process.argv[3] === "WordApiDesktop 1.1") {
74
+ console.log("Address ImportedStylesConflictBehavior reference when removing WordApiDesktop 1.1");
75
+ wholeDts = wholeDts.replace(/@param importedStylesConflictBehavior - Optional. Specifies how to handle any imported styles with the same name as existing styles in the current document./g, "");
76
+ wholeDts = wholeDts.replace(/Note: The `importedStylesConflictBehavior` parameter was introduced in WordApiDesktop 1.1./g, "");
77
+ wholeDts = wholeDts.replace(/, importedStylesConflictBehavior\?: Word\.ImportedStylesConflictBehavior[\w\W]*importedStylesConflictBehaviorString\?: "Ignore" \| "Overwrite" \| "CreateNew"\): OfficeExtension.ClientResult<string\[\]>;/gm, "): OfficeExtension.ClientResult<string[]>;");
78
+ }
79
+ fsx.writeFileSync(process.argv[4], wholeDts);
80
+ function getDeclarationEnd(wholeDts, startIndex) {
81
+ let nextSemicolon = wholeDts.indexOf(";", startIndex);
82
+ let nextNewLine = wholeDts.indexOf("\n", startIndex);
83
+ let nextStartBrace = wholeDts.indexOf("{", startIndex);
84
+ let nextEndBrace = wholeDts.indexOf("}", startIndex);
85
+ let nextComment = wholeDts.indexOf("/**", startIndex);
86
+ // Figure out if the declaration has an internal class.
87
+ if (nextSemicolon < nextNewLine) {
88
+ return nextSemicolon;
89
+ }
90
+ else if (nextStartBrace > nextEndBrace && nextEndBrace < nextComment) {
91
+ return wholeDts.lastIndexOf("\n", nextEndBrace);
92
+ }
93
+ else {
94
+ return wholeDts.lastIndexOf("\n", nextComment);
95
+ }
96
+ }
97
+ //# sourceMappingURL=version-remover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-remover.js","sour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+JAA+J,EAAE,EAAE,CAAC,CAAC;IACjM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,6FAA6F,EAAE,EAAE,CAAC,CAAC;IAC/H,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,8MAA8M,EAAE,4CAA4C,CAAC,CAAC;CAC7R;AAED,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAG7C,SAAS,iBAAiB,CAAC,QAAgB,EAAE,UAAkB;IAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACtD,IAAI,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEtD,uDAAuD;IACvD,IAAI,aAAa,GAAG,WAAW,EAAE;QAC7B,OAAO,aAAa,CAAC;KACxB;SAAM,IAAI,cAAc,GAAG,YAAY,IAAI,YAAY,GAAG,WAAW,EAAE;QACpE,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;KACnD;SAAM;QACH,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KAClD;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importStar = (this && this.__importStar) || function (mod) {
13
+ if (mod && mod.__esModule) return mod;
14
+ var result = {};
15
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
16
+ result["default"] = mod;
17
+ return result;
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const fsx = __importStar(require("fs-extra"));
21
+ const dts_utilities_1 = require("./dts-utilities");
22
+ if (process.argv.length !== 6 || process.argv.find((x) => { return x === "-?"; })) {
23
+ console.log("usage: node whats-new [host name] [new d.ts] [old d.ts] [output file name (minus extension)]");
24
+ console.log("example: node whats-new Excel excel_1_9.d.ts excel_1_8.d.ts excel_whats_new");
25
+ process.exit(0);
26
+ }
27
+ const hostName = process.argv[2];
28
+ const newDtsPath = process.argv[3];
29
+ const oldDtsPath = process.argv[4];
30
+ const outputPath = process.argv[5];
31
+ console.log(`What's New between ${newDtsPath} and ${oldDtsPath}?`);
32
+ tryCatch(() => __awaiter(void 0, void 0, void 0, function* () {
33
+ // read whole files
34
+ let wholeRelease = fsx.readFileSync(oldDtsPath).toString();
35
+ let wholePreview = fsx.readFileSync(newDtsPath).toString();
36
+ const releaseAPI = dts_utilities_1.parseDTS("release", wholeRelease);
37
+ const previewAPI = dts_utilities_1.parseDTS("preview", wholePreview);
38
+ const diffAPI = previewAPI.diff(releaseAPI);
39
+ const relativePath = `javascript/api/${hostName.toLowerCase()}/${hostName.toLowerCase() === "outlook" ? "office" : hostName.toLowerCase()}.`;
40
+ if (!fsx.existsSync(outputPath + ".md")) {
41
+ fsx.createFileSync(outputPath + ".md");
42
+ }
43
+ fsx.writeFileSync(outputPath + ".md", diffAPI.getAsMarkdown(relativePath));
44
+ }));
45
+ function tryCatch(call) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ yield call();
49
+ }
50
+ catch (e) {
51
+ console.error(e);
52
+ process.exit(1);
53
+ }
54
+ });
55
+ }
56
+ //# sourceMappingURL=whats-new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whats-new.js","sourceRoot":"","sources":["../src/whats-new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,8CAAgC;AAChC,mDAAmD;AAGnD,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,GAAE,OAAO,CAAC,KAAK,IAAI,CAAA,CAAA,CAAC,CAAC,EAAE;IACpF,OAAO,CAAC,GAAG,CAAC,8FAA8F,CAAC,CAAC;IAC5G,OAAO,CAAC,GAAG,CAAC,6EAA6E,CAAC,CAAC;IAC3F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACnB;AAED,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEnC,OAAO,CAAC,GAAG,CAAC,sBAAsB,UAAU,QAAQ,UAAU,GAAG,CAAC,CAAC;AAEnE,QAAQ,CAAC,GAAS,EAAE;IAChB,mBAAmB;IACnB,IAAI,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC3D,IAAI,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IAE3D,MAAM,UAAU,GAAW,wBAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAW,wBAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAW,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAW,kBAAkB,QAAQ,CAAC,WAAW,EAAE,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;IACrJ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE;QACrC,GAAG,CAAC,cAAc,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;KAC1C;IAED,GAAG,CAAC,aAAa,CAAC,UAAU,GAAG,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAA,CAAC,CAAC;AAEH,SAAe,QAAQ,CAAC,IAAyB;;QAC7C,IAAI;YACA,MAAM,IAAI,EAAE,CAAC;SAChB;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;IACL,CAAC;CAAA"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "versioned-d.ts-tools",
3
+ "version": "0.1.0",
4
+ "description": "Tools for managing versioned TypeScript definition files",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "version-remover": "dist/version-remover.js",
8
+ "whats-new": "dist/whats-new.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig.json",
12
+ "start": "tsc -p tsconfig.json --watch",
13
+ "lint": "eslint -c .eslintrc.js --ext .ts",
14
+ "prepublishOnly": "npm run build",
15
+ "clean": "if exist dist rmdir /s /q dist",
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "author": "AlexJerabek",
19
+ "license": "MIT",
20
+ "keywords": ["typescript", "d.ts", "versioning", "api", "documentation"],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/AlexJerabek/versioned-d.ts-tools.git"
24
+ },
25
+ "files": [
26
+ "dist/**/*",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "devDependencies": {
31
+ "@types/fs-extra": "3.0.1",
32
+ "@types/inquirer": "0.0.34",
33
+ "@types/js-yaml": "4.0.0",
34
+ "@types/lodash": "4.14.136",
35
+ "@types/node": "7.0.5",
36
+ "@typescript-eslint/eslint-plugin": "^6.16.0",
37
+ "@typescript-eslint/parser": "^6.16.0",
38
+ "del": "2.2.2",
39
+ "eslint": "^8.56.0",
40
+ "eslint-config-prettier": "^9.1.0",
41
+ "eslint-plugin-prefer-arrow": "^1.2.3",
42
+ "ts-node": "2.1.0"
43
+ },
44
+ "dependencies": {
45
+ "typescript": "~3.7.0",
46
+ "deep-diff": "^1.0.2",
47
+ "fs-extra": "3.0.1",
48
+ "inquirer": "^8.2.0",
49
+ "isomorphic-fetch": "^3.0.0",
50
+ "lodash": "^4.17.21"
51
+ }
52
+ }