versioned-d.ts-tools 0.1.0 → 0.2.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 CHANGED
@@ -23,16 +23,64 @@ npm install versioned-d.ts-tools
23
23
  Removes specific API versions from TypeScript definition files.
24
24
 
25
25
  ```bash
26
- version-remover [source d.ts] [API set name] [output file name]
26
+ version-remover [source d.ts] [API set name] [output file name] [optional config file]
27
27
  ```
28
28
 
29
- **Example:**
29
+ **Examples:**
30
+
30
31
  ```bash
32
+ # Basic usage
31
33
  version-remover excel.d.ts "ExcelApi 1.8" excel_1_7.d.ts
34
+
35
+ # With configuration file for custom replacements
36
+ version-remover excel.d.ts "ExcelApi 1.8" excel_1_7.d.ts config.json
32
37
  ```
33
38
 
34
39
  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
40
 
41
+ #### Configuration File
42
+
43
+ You can provide an optional JSON configuration file to specify additional text replacements that should be applied after removing the API version. This is useful for cleaning up type unions or references that become invalid after removing certain APIs.
44
+
45
+ **Configuration file format:**
46
+
47
+ ```json
48
+ {
49
+ "replacements": [
50
+ {
51
+ "find": "old text to find",
52
+ "replace": "replacement text",
53
+ "description": "Optional description of what this replacement does"
54
+ },
55
+ {
56
+ "find": "/regex pattern/g",
57
+ "replace": "replacement",
58
+ "isRegex": true,
59
+ "description": "Example regex replacement"
60
+ }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ **Example configuration:**
66
+
67
+ ```json
68
+ {
69
+ "replacements": [
70
+ {
71
+ "find": "type CardLayoutSection = CardLayoutListSection | CardLayoutTableSection | CardLayoutTwoColumnSection;",
72
+ "replace": "type CardLayoutSection = CardLayoutListSection | CardLayoutTableSection;",
73
+ "description": "Remove CardLayoutTwoColumnSection from union type"
74
+ },
75
+ {
76
+ "find": "icon?: string | EntityCompactLayoutIcons;",
77
+ "replace": "icon?: string;",
78
+ "description": "Remove EntityCompactLayoutIcons from icon property"
79
+ }
80
+ ]
81
+ }
82
+ ```
83
+
36
84
  ### whats-new
37
85
 
38
86
  Compares two TypeScript definition files and generates a markdown report of the differences.
@@ -42,6 +90,7 @@ whats-new [host name] [new d.ts] [old d.ts] [output file name (minus extension)]
42
90
  ```
43
91
 
44
92
  **Example:**
93
+
45
94
  ```bash
46
95
  whats-new Excel excel_1_9.d.ts excel_1_8.d.ts excel_whats_new
47
96
  ```
@@ -1,41 +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 {};
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 {};