@langri-sha/projen-typescript-config 0.2.1 → 0.4.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/CHANGELOG.json CHANGED
@@ -2,7 +2,169 @@
2
2
  "name": "@langri-sha/projen-typescript-config",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 21 May 2024 05:21:32 GMT",
5
+ "date": "Mon, 08 Jul 2024 21:40:45 GMT",
6
+ "version": "0.4.0",
7
+ "tag": "@langri-sha/projen-typescript-config_v0.4.0",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "filip.dupanovic@gmail.com",
12
+ "package": "@langri-sha/projen-typescript-config",
13
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
14
+ "comment": "fix(projen): Use correct output directory"
15
+ },
16
+ {
17
+ "author": "email not defined",
18
+ "package": "@langri-sha/projen-typescript-config",
19
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
20
+ "comment": "chore(deps): chore(deps): update node.js to v20.15.0"
21
+ },
22
+ {
23
+ "author": "email not defined",
24
+ "package": "@langri-sha/projen-typescript-config",
25
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
26
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.7"
27
+ },
28
+ {
29
+ "author": "email not defined",
30
+ "package": "@langri-sha/projen-typescript-config",
31
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
32
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.10"
33
+ },
34
+ {
35
+ "author": "email not defined",
36
+ "package": "@langri-sha/projen-typescript-config",
37
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
38
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.8"
39
+ },
40
+ {
41
+ "author": "email not defined",
42
+ "package": "@langri-sha/projen-typescript-config",
43
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
44
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.3"
45
+ },
46
+ {
47
+ "author": "email not defined",
48
+ "package": "@langri-sha/projen-typescript-config",
49
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
50
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.5"
51
+ },
52
+ {
53
+ "author": "email not defined",
54
+ "package": "@langri-sha/projen-typescript-config",
55
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
56
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.6"
57
+ }
58
+ ],
59
+ "none": [
60
+ {
61
+ "author": "filip.dupanovic@gmail.com",
62
+ "package": "@langri-sha/projen-typescript-config",
63
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
64
+ "comment": "feat(tsconfig): Use `${configDir}`"
65
+ },
66
+ {
67
+ "author": "filip.dupanovic@gmail.com",
68
+ "package": "@langri-sha/projen-typescript-config",
69
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
70
+ "comment": "feat(workspace): Add explicit return types"
71
+ },
72
+ {
73
+ "author": "filip.dupanovic@gmail.com",
74
+ "package": "@langri-sha/projen-typescript-config",
75
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
76
+ "comment": "feat(workspace): Add repository path"
77
+ }
78
+ ],
79
+ "minor": [
80
+ {
81
+ "author": "filip.dupanovic@gmail.com",
82
+ "package": "@langri-sha/projen-typescript-config",
83
+ "commit": "94472e1a79e065f4ef9c4e668453e9266b428281",
84
+ "comment": "feat(workspace): Use `vitest`"
85
+ }
86
+ ]
87
+ }
88
+ },
89
+ {
90
+ "date": "Sat, 15 Jun 2024 09:09:05 GMT",
91
+ "version": "0.3.0",
92
+ "tag": "@langri-sha/projen-typescript-config_v0.3.0",
93
+ "comments": {
94
+ "minor": [
95
+ {
96
+ "author": "filip.dupanovic@gmail.com",
97
+ "package": "@langri-sha/projen-typescript-config",
98
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
99
+ "comment": "feat(typescript-config): Dedupe files"
100
+ },
101
+ {
102
+ "author": "filip.dupanovic@gmail.com",
103
+ "package": "@langri-sha/projen-typescript-config",
104
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
105
+ "comment": "feat(projen): Reconfigure project expressions"
106
+ },
107
+ {
108
+ "author": "filip.dupanovic@gmail.com",
109
+ "package": "@langri-sha/projen-typescript-config",
110
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
111
+ "comment": "feat(typescript-config): Sort files array"
112
+ },
113
+ {
114
+ "author": "filip.dupanovic@gmail.com",
115
+ "package": "@langri-sha/projen-typescript-config",
116
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
117
+ "comment": "feat(typescript-config): Dedupe references"
118
+ },
119
+ {
120
+ "author": "filip.dupanovic@gmail.com",
121
+ "package": "@langri-sha/projen-typescript-config",
122
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
123
+ "comment": "feat(projen): Drop pinning peer dependencies"
124
+ },
125
+ {
126
+ "author": "filip.dupanovic@gmail.com",
127
+ "package": "@langri-sha/projen-typescript-config",
128
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
129
+ "comment": "feat(project): Omit Node.js engine package defaults"
130
+ },
131
+ {
132
+ "author": "filip.dupanovic@gmail.com",
133
+ "package": "@langri-sha/projen-typescript-config",
134
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
135
+ "comment": "feat(typescript-config): Sort references"
136
+ },
137
+ {
138
+ "author": "filip.dupanovic@gmail.com",
139
+ "package": "@langri-sha/projen-typescript-config",
140
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
141
+ "comment": "feat(typescript-config): Manage package with projen"
142
+ }
143
+ ],
144
+ "patch": [
145
+ {
146
+ "author": "email not defined",
147
+ "package": "@langri-sha/projen-typescript-config",
148
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
149
+ "comment": "chore(deps): chore(deps): update node.js to v20.14.0"
150
+ },
151
+ {
152
+ "author": "email not defined",
153
+ "package": "@langri-sha/projen-typescript-config",
154
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
155
+ "comment": "chore(deps): chore(deps): update dependency projen to v0.82.3"
156
+ },
157
+ {
158
+ "author": "email not defined",
159
+ "package": "@langri-sha/projen-typescript-config",
160
+ "commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
161
+ "comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.2"
162
+ }
163
+ ]
164
+ }
165
+ },
166
+ {
167
+ "date": "Tue, 21 May 2024 05:22:50 GMT",
6
168
  "version": "0.2.1",
7
169
  "tag": "@langri-sha/projen-typescript-config_v0.2.1",
8
170
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,52 @@
1
1
  # Change Log - @langri-sha/projen-typescript-config
2
2
 
3
- This log was last generated on Tue, 21 May 2024 05:21:32 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 08 Jul 2024 21:40:45 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.4.0
8
+
9
+ Mon, 08 Jul 2024 21:40:45 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - feat(workspace): Use `vitest` (filip.dupanovic@gmail.com)
14
+
15
+ ### Patches
16
+
17
+ - fix(projen): Use correct output directory (filip.dupanovic@gmail.com)
18
+ - chore(deps): chore(deps): update node.js to v20.15.0 (email not defined)
19
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.7 (email not defined)
20
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.10 (email not defined)
21
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.8 (email not defined)
22
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.3 (email not defined)
23
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.5 (email not defined)
24
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.6 (email not defined)
25
+
26
+ ## 0.3.0
27
+
28
+ Sat, 15 Jun 2024 09:09:05 GMT
29
+
30
+ ### Minor changes
31
+
32
+ - feat(typescript-config): Dedupe files (filip.dupanovic@gmail.com)
33
+ - feat(projen): Reconfigure project expressions (filip.dupanovic@gmail.com)
34
+ - feat(typescript-config): Sort files array (filip.dupanovic@gmail.com)
35
+ - feat(typescript-config): Dedupe references (filip.dupanovic@gmail.com)
36
+ - feat(projen): Drop pinning peer dependencies (filip.dupanovic@gmail.com)
37
+ - feat(project): Omit Node.js engine package defaults (filip.dupanovic@gmail.com)
38
+ - feat(typescript-config): Sort references (filip.dupanovic@gmail.com)
39
+ - feat(typescript-config): Manage package with projen (filip.dupanovic@gmail.com)
40
+
41
+ ### Patches
42
+
43
+ - chore(deps): chore(deps): update node.js to v20.14.0 (email not defined)
44
+ - chore(deps): chore(deps): update dependency projen to v0.82.3 (email not defined)
45
+ - chore(deps): chore(deps): update dependency @types/node to v20.14.2 (email not defined)
46
+
7
47
  ## 0.2.1
8
48
 
9
- Tue, 21 May 2024 05:21:32 GMT
49
+ Tue, 21 May 2024 05:22:50 GMT
10
50
 
11
51
  ### Patches
12
52
 
@@ -1,6 +1,7 @@
1
1
  import type { JSONSchemaForTheTypeScriptCompilerSConfigurationFile } from '@schemastore/tsconfig';
2
- import { Component, Project } from 'projen';
2
+ import { IResolver, JsonFile, Project } from 'projen';
3
3
  export interface TypeScriptConfigOptions {
4
+ fileName?: string;
4
5
  config?: JSONSchemaForTheTypeScriptCompilerSConfigurationFile & {
5
6
  /**
6
7
  * Referenced projects. Requires TypeScript version 3.0 or later.
@@ -12,11 +13,10 @@ export interface TypeScriptConfigOptions {
12
13
  path: string;
13
14
  }[];
14
15
  };
15
- fileName?: string;
16
16
  }
17
- export declare class TypeScriptConfig extends Component {
18
- #private;
17
+ export declare class TypeScriptConfig extends JsonFile {
19
18
  constructor(project: Project, options: TypeScriptConfigOptions);
19
+ protected synthesizeContent(resolver: IResolver): string | undefined;
20
20
  /**
21
21
  * Appends to the list of filenames and patterns to exclude in the program.
22
22
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oDAAoD,EAAE,MAAM,uBAAuB,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,MAAM,CAAC,EAAE,oDAAoD,GAAG;QAC9D;;WAEG;QACH,UAAU,CAAC,EAAE;YACX;;eAEG;YACH,IAAI,EAAE,MAAM,CAAA;SACb,EAAE,CAAA;KACJ,CAAA;CACF;AAED,qBAAa,gBAAiB,SAAQ,QAAQ;gBAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB;cAY3C,iBAAiB,CAClC,QAAQ,EAAE,SAAS,GAClB,MAAM,GAAG,SAAS;IA6CrB;;OAEG;IACH,UAAU,CAAC,GAAG,mBAAmB,EAAE,MAAM,EAAE,GAAG,IAAI;IAIlD;;OAEG;IACH,UAAU,CAAC,GAAG,mBAAmB,EAAE,MAAM,EAAE,GAAG,IAAI;IAIlD;;OAEG;IACH,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAIrC;;OAEG;IACH,YAAY,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;CAQvC"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ import { JsonFile } from 'projen';
2
+ export class TypeScriptConfig extends JsonFile {
3
+ constructor(project, options) {
4
+ const fileName = options.fileName ?? 'tsconfig.json';
5
+ super(project, fileName, {
6
+ allowComments: true,
7
+ obj: {
8
+ $schema: 'https://json.schemastore.org/tsconfig',
9
+ ...options?.config,
10
+ },
11
+ });
12
+ }
13
+ synthesizeContent(resolver) {
14
+ const content = super.synthesizeContent(resolver);
15
+ if (!content) {
16
+ return;
17
+ }
18
+ const pattern = /{[\s\S]*}/;
19
+ const matched = content.match(pattern)?.[0];
20
+ if (!matched) {
21
+ return;
22
+ }
23
+ const config = JSON.parse(matched);
24
+ if (config.references) {
25
+ config.references.sort((a, b) => a.path.localeCompare(b.path));
26
+ const deduped = Object.values(config.references.reduce((acc, item) => {
27
+ acc[item.path] = item;
28
+ return acc;
29
+ }, {}));
30
+ config.references = deduped;
31
+ }
32
+ if (Array.isArray(config.files)) {
33
+ config.files.sort();
34
+ config.files = [...new Set(config.files)];
35
+ }
36
+ const json = JSON.stringify(config, null, 2);
37
+ return content.replace(pattern, json);
38
+ }
39
+ /**
40
+ * Appends to the list of filenames and patterns to exclude in the program.
41
+ */
42
+ addExclude(...fileNamesOrPatterns) {
43
+ this.addToArray('exclude', ...fileNamesOrPatterns);
44
+ }
45
+ /**
46
+ * Appends to the list of filenames and patterns to include in the program.
47
+ */
48
+ addInclude(...fileNamesOrPatterns) {
49
+ this.addToArray('include', ...fileNamesOrPatterns);
50
+ }
51
+ /**
52
+ * Appends to the list of filenames to include in the program.
53
+ */
54
+ addFile(...fileNames) {
55
+ this.addToArray('files', ...fileNames);
56
+ }
57
+ /**
58
+ * Adds a reference project.
59
+ */
60
+ addReference(...paths) {
61
+ this.addToArray('references', ...paths.map((path) => ({
62
+ path,
63
+ })));
64
+ }
65
+ }
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAW,MAAM,QAAQ,CAAA;AAkBrD,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAC5C,YAAY,OAAgB,EAAE,OAAgC;QAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAA;QAEpD,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE;YACvB,aAAa,EAAE,IAAI;YACnB,GAAG,EAAE;gBACH,OAAO,EAAE,uCAAuC;gBAChD,GAAG,OAAO,EAAE,MAAM;aACnB;SACF,CAAC,CAAA;IACJ,CAAC;IAEkB,iBAAiB,CAClC,QAAmB;QAEnB,MAAM,OAAO,GAAG,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAA;QAEjD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAM;QACR,CAAC;QAED,MAAM,OAAO,GAAG,WAAW,CAAA;QAE3B,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAE3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAM;QACR,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,OAAO,CACuC,CAAA;QAEhD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;YAE9D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC3B,MAAM,CAAC,UAAU,CAAC,MAAM,CACtB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBACZ,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;gBACrB,OAAO,GAAG,CAAA;YACZ,CAAC,EACD,EAAsC,CACvC,CACF,CAAA;YAED,MAAM,CAAC,UAAU,GAAG,OAAO,CAAA;QAC7B,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;YACnB,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3C,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAE5C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACvC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAG,mBAA6B;QACzC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAG,mBAA6B;QACzC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAG,SAAmB;QAC5B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,GAAG,KAAe;QAC7B,IAAI,CAAC,UAAU,CACb,YAAY,EACZ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACtB,IAAI;SACL,CAAC,CAAC,CACJ,CAAA;IACH,CAAC;CACF"}
package/license CHANGED
@@ -1,20 +1,10 @@
1
+
1
2
  MIT License
2
3
 
3
4
  Copyright (c) 2024 Filip Dupanović <filip.dupanovic@gmail.com> (https://langri-sha.com)
4
5
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
7
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
9
 
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, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,26 +1,39 @@
1
1
  {
2
2
  "name": "@langri-sha/projen-typescript-config",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
+ "bugs": {
5
+ "url": "https://github.com/langri-sha/langri-sha.com/issues"
6
+ },
7
+ "repository": {
8
+ "url": "git+https://github.com/langri-sha/langri-sha.com.git",
9
+ "path": "/packages/projen-typescript-config"
10
+ },
4
11
  "license": "MIT",
12
+ "author": {
13
+ "name": "Filip Dupanović",
14
+ "email": "filip.dupanovic@gmail.com",
15
+ "url": "https://langri-sha.com",
16
+ "organization": false
17
+ },
5
18
  "type": "module",
6
- "main": "lib/index.js",
19
+ "main": "dist/index.js",
7
20
  "scripts": {
8
- "prepublishOnly": "rm -rf lib; tsc --project tsconfig.build.json"
21
+ "prepublishOnly": "rm -rf dist; tsc --project tsconfig.build.json"
9
22
  },
10
23
  "dependencies": {
11
24
  "@schemastore/tsconfig": "0.0.11"
12
25
  },
13
26
  "devDependencies": {
14
- "@langri-sha/jest-test": "0.7.1",
15
- "@langri-sha/tsconfig": "0.9.0",
16
- "@types/node": "20.12.12",
17
- "projen": "0.81.15"
27
+ "@langri-sha/tsconfig": "0.10.0",
28
+ "@langri-sha/vitest": "0.1.0",
29
+ "@types/node": "20.14.10"
18
30
  },
19
31
  "peerDependencies": {
20
- "projen": "^0.81.1"
32
+ "projen": "^0.82.0"
21
33
  },
22
34
  "publishConfig": {
23
35
  "access": "public"
24
36
  },
25
- "types": "lib/index.d.ts"
37
+ "//": "~~ Generated by projen. To modify, edit .projenrc.mts and run \"npx projen\".",
38
+ "types": "dist/index.d.ts"
26
39
  }
package/src/index.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { JSONSchemaForTheTypeScriptCompilerSConfigurationFile } from '@schemastore/tsconfig'
2
- import { Component, JsonFile, Project } from 'projen'
2
+ import { IResolver, JsonFile, Project } from 'projen'
3
3
 
4
4
  export interface TypeScriptConfigOptions {
5
+ fileName?: string
6
+
5
7
  config?: JSONSchemaForTheTypeScriptCompilerSConfigurationFile & {
6
8
  /**
7
9
  * Referenced projects. Requires TypeScript version 3.0 or later.
@@ -13,58 +15,94 @@ export interface TypeScriptConfigOptions {
13
15
  path: string
14
16
  }[]
15
17
  }
16
- fileName?: string
17
18
  }
18
19
 
19
- export class TypeScriptConfig extends Component {
20
- #file: JsonFile
21
- #options: Required<TypeScriptConfigOptions>
22
-
20
+ export class TypeScriptConfig extends JsonFile {
23
21
  constructor(project: Project, options: TypeScriptConfigOptions) {
24
22
  const fileName = options.fileName ?? 'tsconfig.json'
25
23
 
26
- super(project, fileName)
27
-
28
- this.#options = {
29
- config: options.config ?? {},
30
- fileName,
31
- }
32
-
33
- this.#file = new JsonFile(this, fileName, {
24
+ super(project, fileName, {
34
25
  allowComments: true,
35
26
  obj: {
36
27
  $schema: 'https://json.schemastore.org/tsconfig',
37
- ...this.#options.config,
28
+ ...options?.config,
38
29
  },
39
30
  })
40
31
  }
41
32
 
33
+ protected override synthesizeContent(
34
+ resolver: IResolver,
35
+ ): string | undefined {
36
+ const content = super.synthesizeContent(resolver)
37
+
38
+ if (!content) {
39
+ return
40
+ }
41
+
42
+ const pattern = /{[\s\S]*}/
43
+
44
+ const matched = content.match(pattern)?.[0]
45
+
46
+ if (!matched) {
47
+ return
48
+ }
49
+
50
+ const config = JSON.parse(
51
+ matched,
52
+ ) as Required<TypeScriptConfigOptions>['config']
53
+
54
+ if (config.references) {
55
+ config.references.sort((a, b) => a.path.localeCompare(b.path))
56
+
57
+ const deduped = Object.values(
58
+ config.references.reduce(
59
+ (acc, item) => {
60
+ acc[item.path] = item
61
+ return acc
62
+ },
63
+ {} as Record<string, { path: string }>,
64
+ ),
65
+ )
66
+
67
+ config.references = deduped
68
+ }
69
+
70
+ if (Array.isArray(config.files)) {
71
+ config.files.sort()
72
+ config.files = [...new Set(config.files)]
73
+ }
74
+
75
+ const json = JSON.stringify(config, null, 2)
76
+
77
+ return content.replace(pattern, json)
78
+ }
79
+
42
80
  /**
43
81
  * Appends to the list of filenames and patterns to exclude in the program.
44
82
  */
45
- addExclude(...fileNamesOrPatterns: string[]) {
46
- this.#file.addToArray('exclude', ...fileNamesOrPatterns)
83
+ addExclude(...fileNamesOrPatterns: string[]): void {
84
+ this.addToArray('exclude', ...fileNamesOrPatterns)
47
85
  }
48
86
 
49
87
  /**
50
88
  * Appends to the list of filenames and patterns to include in the program.
51
89
  */
52
- addInclude(...fileNamesOrPatterns: string[]) {
53
- this.#file.addToArray('include', ...fileNamesOrPatterns)
90
+ addInclude(...fileNamesOrPatterns: string[]): void {
91
+ this.addToArray('include', ...fileNamesOrPatterns)
54
92
  }
55
93
 
56
94
  /**
57
95
  * Appends to the list of filenames to include in the program.
58
96
  */
59
- addFile(...fileNames: string[]) {
60
- this.#file.addToArray('files', ...fileNames)
97
+ addFile(...fileNames: string[]): void {
98
+ this.addToArray('files', ...fileNames)
61
99
  }
62
100
 
63
101
  /**
64
102
  * Adds a reference project.
65
103
  */
66
- addReference(...paths: string[]) {
67
- this.#file.addToArray(
104
+ addReference(...paths: string[]): void {
105
+ this.addToArray(
68
106
  'references',
69
107
  ...paths.map((path) => ({
70
108
  path,
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oDAAoD,EAAE,MAAM,uBAAuB,CAAA;AACjG,OAAO,EAAE,SAAS,EAAY,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErD,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,oDAAoD,GAAG;QAC9D;;WAEG;QACH,UAAU,CAAC,EAAE;YACX;;eAEG;YACH,IAAI,EAAE,MAAM,CAAA;SACb,EAAE,CAAA;KACJ,CAAA;IACD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,gBAAiB,SAAQ,SAAS;;gBAIjC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB;IAmB9D;;OAEG;IACH,UAAU,CAAC,GAAG,mBAAmB,EAAE,MAAM,EAAE;IAI3C;;OAEG;IACH,UAAU,CAAC,GAAG,mBAAmB,EAAE,MAAM,EAAE;IAI3C;;OAEG;IACH,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE;IAI9B;;OAEG;IACH,YAAY,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE;CAQhC"}
package/lib/index.js DELETED
@@ -1,60 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _TypeScriptConfig_file, _TypeScriptConfig_options;
13
- import { Component, JsonFile } from 'projen';
14
- export class TypeScriptConfig extends Component {
15
- constructor(project, options) {
16
- const fileName = options.fileName ?? 'tsconfig.json';
17
- super(project, fileName);
18
- _TypeScriptConfig_file.set(this, void 0);
19
- _TypeScriptConfig_options.set(this, void 0);
20
- __classPrivateFieldSet(this, _TypeScriptConfig_options, {
21
- config: options.config ?? {},
22
- fileName,
23
- }, "f");
24
- __classPrivateFieldSet(this, _TypeScriptConfig_file, new JsonFile(this, fileName, {
25
- allowComments: true,
26
- obj: {
27
- $schema: 'https://json.schemastore.org/tsconfig',
28
- ...__classPrivateFieldGet(this, _TypeScriptConfig_options, "f").config,
29
- },
30
- }), "f");
31
- }
32
- /**
33
- * Appends to the list of filenames and patterns to exclude in the program.
34
- */
35
- addExclude(...fileNamesOrPatterns) {
36
- __classPrivateFieldGet(this, _TypeScriptConfig_file, "f").addToArray('exclude', ...fileNamesOrPatterns);
37
- }
38
- /**
39
- * Appends to the list of filenames and patterns to include in the program.
40
- */
41
- addInclude(...fileNamesOrPatterns) {
42
- __classPrivateFieldGet(this, _TypeScriptConfig_file, "f").addToArray('include', ...fileNamesOrPatterns);
43
- }
44
- /**
45
- * Appends to the list of filenames to include in the program.
46
- */
47
- addFile(...fileNames) {
48
- __classPrivateFieldGet(this, _TypeScriptConfig_file, "f").addToArray('files', ...fileNames);
49
- }
50
- /**
51
- * Adds a reference project.
52
- */
53
- addReference(...paths) {
54
- __classPrivateFieldGet(this, _TypeScriptConfig_file, "f").addToArray('references', ...paths.map((path) => ({
55
- path,
56
- })));
57
- }
58
- }
59
- _TypeScriptConfig_file = new WeakMap(), _TypeScriptConfig_options = new WeakMap();
60
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAW,MAAM,QAAQ,CAAA;AAiBrD,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAI7C,YAAY,OAAgB,EAAE,OAAgC;QAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAA;QAEpD,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAN1B,yCAAe;QACf,4CAA2C;QAOzC,uBAAA,IAAI,6BAAY;YACd,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;YAC5B,QAAQ;SACT,MAAA,CAAA;QAED,uBAAA,IAAI,0BAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE;YACxC,aAAa,EAAE,IAAI;YACnB,GAAG,EAAE;gBACH,OAAO,EAAE,uCAAuC;gBAChD,GAAG,uBAAA,IAAI,iCAAS,CAAC,MAAM;aACxB;SACF,CAAC,MAAA,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAG,mBAA6B;QACzC,uBAAA,IAAI,8BAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC,CAAA;IAC1D,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAG,mBAA6B;QACzC,uBAAA,IAAI,8BAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC,CAAA;IAC1D,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAG,SAAmB;QAC5B,uBAAA,IAAI,8BAAM,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,CAAA;IAC9C,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,GAAG,KAAe;QAC7B,uBAAA,IAAI,8BAAM,CAAC,UAAU,CACnB,YAAY,EACZ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACtB,IAAI;SACL,CAAC,CAAC,CACJ,CAAA;IACH,CAAC;CACF"}