@langri-sha/projen-typescript-config 0.2.1 → 0.3.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 +78 -1
- package/CHANGELOG.md +23 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +35 -29
- package/lib/index.js.map +1 -1
- package/license +4 -14
- package/package.json +12 -6
- package/src/index.ts +57 -19
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,84 @@
|
|
|
2
2
|
"name": "@langri-sha/projen-typescript-config",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Sat, 15 Jun 2024 09:06:45 GMT",
|
|
6
|
+
"version": "0.3.0",
|
|
7
|
+
"tag": "@langri-sha/projen-typescript-config_v0.3.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "filip.dupanovic@gmail.com",
|
|
12
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
13
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
14
|
+
"comment": "feat(typescript-config): Dedupe files"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "filip.dupanovic@gmail.com",
|
|
18
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
19
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
20
|
+
"comment": "feat(projen): Reconfigure project expressions"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "filip.dupanovic@gmail.com",
|
|
24
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
25
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
26
|
+
"comment": "feat(typescript-config): Sort files array"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "filip.dupanovic@gmail.com",
|
|
30
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
31
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
32
|
+
"comment": "feat(typescript-config): Dedupe references"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "filip.dupanovic@gmail.com",
|
|
36
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
37
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
38
|
+
"comment": "feat(projen): Drop pinning peer dependencies"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "filip.dupanovic@gmail.com",
|
|
42
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
43
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
44
|
+
"comment": "feat(project): Omit Node.js engine package defaults"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "filip.dupanovic@gmail.com",
|
|
48
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
49
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
50
|
+
"comment": "feat(typescript-config): Sort references"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "filip.dupanovic@gmail.com",
|
|
54
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
55
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
56
|
+
"comment": "feat(typescript-config): Manage package with projen"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"patch": [
|
|
60
|
+
{
|
|
61
|
+
"author": "email not defined",
|
|
62
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
63
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
64
|
+
"comment": "chore(deps): chore(deps): update node.js to v20.14.0"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"author": "email not defined",
|
|
68
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
69
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
70
|
+
"comment": "chore(deps): chore(deps): update dependency projen to v0.82.3"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"author": "email not defined",
|
|
74
|
+
"package": "@langri-sha/projen-typescript-config",
|
|
75
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
76
|
+
"comment": "chore(deps): chore(deps): update dependency @types/node to v20.14.2"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"date": "Tue, 21 May 2024 05:22:50 GMT",
|
|
6
83
|
"version": "0.2.1",
|
|
7
84
|
"tag": "@langri-sha/projen-typescript-config_v0.2.1",
|
|
8
85
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
# Change Log - @langri-sha/projen-typescript-config
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 15 Jun 2024 09:06:45 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.3.0
|
|
8
|
+
|
|
9
|
+
Sat, 15 Jun 2024 09:06:45 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat(typescript-config): Dedupe files (filip.dupanovic@gmail.com)
|
|
14
|
+
- feat(projen): Reconfigure project expressions (filip.dupanovic@gmail.com)
|
|
15
|
+
- feat(typescript-config): Sort files array (filip.dupanovic@gmail.com)
|
|
16
|
+
- feat(typescript-config): Dedupe references (filip.dupanovic@gmail.com)
|
|
17
|
+
- feat(projen): Drop pinning peer dependencies (filip.dupanovic@gmail.com)
|
|
18
|
+
- feat(project): Omit Node.js engine package defaults (filip.dupanovic@gmail.com)
|
|
19
|
+
- feat(typescript-config): Sort references (filip.dupanovic@gmail.com)
|
|
20
|
+
- feat(typescript-config): Manage package with projen (filip.dupanovic@gmail.com)
|
|
21
|
+
|
|
22
|
+
### Patches
|
|
23
|
+
|
|
24
|
+
- chore(deps): chore(deps): update node.js to v20.14.0 (email not defined)
|
|
25
|
+
- chore(deps): chore(deps): update dependency projen to v0.82.3 (email not defined)
|
|
26
|
+
- chore(deps): chore(deps): update dependency @types/node to v20.14.2 (email not defined)
|
|
27
|
+
|
|
7
28
|
## 0.2.1
|
|
8
29
|
|
|
9
|
-
Tue, 21 May 2024 05:
|
|
30
|
+
Tue, 21 May 2024 05:22:50 GMT
|
|
10
31
|
|
|
11
32
|
### Patches
|
|
12
33
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JSONSchemaForTheTypeScriptCompilerSConfigurationFile } from '@schemastore/tsconfig';
|
|
2
|
-
import {
|
|
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
|
|
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
|
*/
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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;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
CHANGED
|
@@ -1,60 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 {
|
|
1
|
+
import { JsonFile } from 'projen';
|
|
2
|
+
export class TypeScriptConfig extends JsonFile {
|
|
15
3
|
constructor(project, options) {
|
|
16
4
|
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, {
|
|
5
|
+
super(project, fileName, {
|
|
25
6
|
allowComments: true,
|
|
26
7
|
obj: {
|
|
27
8
|
$schema: 'https://json.schemastore.org/tsconfig',
|
|
28
|
-
...
|
|
9
|
+
...options?.config,
|
|
29
10
|
},
|
|
30
|
-
})
|
|
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);
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* Appends to the list of filenames and patterns to exclude in the program.
|
|
34
41
|
*/
|
|
35
42
|
addExclude(...fileNamesOrPatterns) {
|
|
36
|
-
|
|
43
|
+
this.addToArray('exclude', ...fileNamesOrPatterns);
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Appends to the list of filenames and patterns to include in the program.
|
|
40
47
|
*/
|
|
41
48
|
addInclude(...fileNamesOrPatterns) {
|
|
42
|
-
|
|
49
|
+
this.addToArray('include', ...fileNamesOrPatterns);
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* Appends to the list of filenames to include in the program.
|
|
46
53
|
*/
|
|
47
54
|
addFile(...fileNames) {
|
|
48
|
-
|
|
55
|
+
this.addToArray('files', ...fileNames);
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
51
58
|
* Adds a reference project.
|
|
52
59
|
*/
|
|
53
60
|
addReference(...paths) {
|
|
54
|
-
|
|
61
|
+
this.addToArray('references', ...paths.map((path) => ({
|
|
55
62
|
path,
|
|
56
63
|
})));
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
_TypeScriptConfig_file = new WeakMap(), _TypeScriptConfig_options = new WeakMap();
|
|
60
66
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":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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,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langri-sha/projen-typescript-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Filip Dupanović",
|
|
7
|
+
"email": "filip.dupanovic@gmail.com",
|
|
8
|
+
"url": "https://langri-sha.com",
|
|
9
|
+
"organization": false
|
|
10
|
+
},
|
|
5
11
|
"type": "module",
|
|
6
12
|
"main": "lib/index.js",
|
|
7
13
|
"scripts": {
|
|
@@ -11,16 +17,16 @@
|
|
|
11
17
|
"@schemastore/tsconfig": "0.0.11"
|
|
12
18
|
},
|
|
13
19
|
"devDependencies": {
|
|
14
|
-
"@langri-sha/jest-test": "0.
|
|
15
|
-
"@langri-sha/tsconfig": "0.
|
|
16
|
-
"@types/node": "20.
|
|
17
|
-
"projen": "0.81.15"
|
|
20
|
+
"@langri-sha/jest-test": "0.8.0",
|
|
21
|
+
"@langri-sha/tsconfig": "0.10.0",
|
|
22
|
+
"@types/node": "20.14.2"
|
|
18
23
|
},
|
|
19
24
|
"peerDependencies": {
|
|
20
|
-
"projen": "^0.
|
|
25
|
+
"projen": "^0.82.0"
|
|
21
26
|
},
|
|
22
27
|
"publishConfig": {
|
|
23
28
|
"access": "public"
|
|
24
29
|
},
|
|
30
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.mts and run \"npx projen\".",
|
|
25
31
|
"types": "lib/index.d.ts"
|
|
26
32
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { JSONSchemaForTheTypeScriptCompilerSConfigurationFile } from '@schemastore/tsconfig'
|
|
2
|
-
import {
|
|
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
|
|
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
|
-
...
|
|
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
83
|
addExclude(...fileNamesOrPatterns: string[]) {
|
|
46
|
-
this
|
|
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
90
|
addInclude(...fileNamesOrPatterns: string[]) {
|
|
53
|
-
this
|
|
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
97
|
addFile(...fileNames: string[]) {
|
|
60
|
-
this
|
|
98
|
+
this.addToArray('files', ...fileNames)
|
|
61
99
|
}
|
|
62
100
|
|
|
63
101
|
/**
|
|
64
102
|
* Adds a reference project.
|
|
65
103
|
*/
|
|
66
104
|
addReference(...paths: string[]) {
|
|
67
|
-
this
|
|
105
|
+
this.addToArray(
|
|
68
106
|
'references',
|
|
69
107
|
...paths.map((path) => ({
|
|
70
108
|
path,
|