merge-tsconfigs 0.1.0 → 0.1.2
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 +100 -8
- package/dist/index.cjs +37 -13
- package/dist/index.d.ts +10 -5
- package/dist/index.js +36 -13
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
[](https://badge.fury.io/js/merge-tsconfigs)
|
|
5
|
+
[](https://unpkg.com/merge-tsconfigs@0.1.1/dist/index.js)
|
|
6
|
+
[](https://cdn.skypack.dev/merge-tsconfigs?min)
|
|
5
7
|

|
|
6
8
|
[](https://github.com/yowainwright/merge-tsconfigs)
|
|
7
9
|

|
|
@@ -10,6 +12,10 @@ _Merge-tsconfigs_ is a CLI and node tool for merging tsconfig files into the exa
|
|
|
10
12
|
|
|
11
13
|
---
|
|
12
14
|
|
|
15
|
+
**[Why do I want this?](#why-do-i-want-this)** | **[Example](#for-example)** | **[How do I use this?](#how-do-i-use-this)** | **[CLI API](#cli-api)** | **[Node API](#node-api)** | **[How do I start using this?](#how-do-i-start-using-this)**
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
13
19
|
## Why do I want this?
|
|
14
20
|
|
|
15
21
|
Tsconfig files are copied, pasted, or left as out-of-sync widows 😥 throughout projects. _Merge-tsconfigs_ provides a CLI and node functions to merge tsconfigs files and compilerOptions into _the single tsconfig file you want at a given time_.
|
|
@@ -20,6 +26,41 @@ By providing an easy way to create the tsconfig you want, your everyday tsconfig
|
|
|
20
26
|
|
|
21
27
|
---
|
|
22
28
|
|
|
29
|
+
### _For example_
|
|
30
|
+
|
|
31
|
+
By running `merge-tsconfigs ./tsconfig.build.json` you'll merge `tsconfig.json`
|
|
32
|
+
```ts
|
|
33
|
+
{
|
|
34
|
+
"compilerOptions": {
|
|
35
|
+
"allowJS": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
and, `tsconfig.build.json`
|
|
41
|
+
```ts
|
|
42
|
+
{
|
|
43
|
+
"compilerOptions": {
|
|
44
|
+
"target": "esnext"
|
|
45
|
+
},
|
|
46
|
+
"extends": "./tsconfig.json"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
into `tsconfig.merged.json`
|
|
51
|
+
```ts
|
|
52
|
+
{
|
|
53
|
+
"compilerOptions": {
|
|
54
|
+
"allowJS": true,
|
|
55
|
+
"target": "esnext"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Which you can now use for deployment, dockerfiles, or any other use case. And, you don't have to worry about copying, pasting, or keeping track of multiple tsconfigs! 🎉
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
23
64
|
## How do I use this?
|
|
24
65
|
|
|
25
66
|
Merge-tsconfigs is built to be uses as a CLI first and foremost. It also exports node functions which can be used to preform the same merge operation.
|
|
@@ -43,7 +84,8 @@ Options:
|
|
|
43
84
|
-e, --exclude [exclude...] files to exclude, matches a glob or array pattern
|
|
44
85
|
-h, --help display help for command
|
|
45
86
|
```
|
|
46
|
-
|
|
87
|
+
|
|
88
|
+
\*`compilerOptions` are not added above for readability (but they can be leveraged). To view all cli options, run `merge-tsconfigs --help`! `compilerOptions.paths` aren't implemented.
|
|
47
89
|
|
|
48
90
|
#### Recipes
|
|
49
91
|
|
|
@@ -51,34 +93,84 @@ Merge tsconfig files into a single tsconfig
|
|
|
51
93
|
|
|
52
94
|
```sh
|
|
53
95
|
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json
|
|
54
|
-
# => ./tsconfig.merged.json
|
|
96
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
55
97
|
```
|
|
56
98
|
|
|
57
99
|
Merge tsconfig files a specific tsconfig file
|
|
58
100
|
|
|
59
101
|
```sh
|
|
60
102
|
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --out ./tsconfig.out.json
|
|
61
|
-
# => ./tsconfig.out.json
|
|
103
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.out.json
|
|
62
104
|
```
|
|
63
105
|
|
|
64
106
|
Merge tsconfig files with unique `include` and `exclude` strings
|
|
65
107
|
|
|
66
108
|
```sh
|
|
67
109
|
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --include 'src/**.ts' --exclude 'test/**.ts'
|
|
68
|
-
# => ./tsconfig.merged.json
|
|
110
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
// tsconfig.merged.json
|
|
115
|
+
{
|
|
116
|
+
"compilerOptions": {
|
|
117
|
+
// ...options
|
|
118
|
+
},
|
|
119
|
+
"include": ["src/**.ts"],
|
|
120
|
+
"exclude": ["test/**.ts", "config/*.ts"]
|
|
121
|
+
}
|
|
69
122
|
```
|
|
70
123
|
|
|
71
124
|
Merge tsconfig files with unique `include` and `exclude` or by using arrays
|
|
72
125
|
|
|
73
126
|
```sh
|
|
74
127
|
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --include 'src/**.ts' --exclude 'test/**.ts' 'config/*.ts'
|
|
75
|
-
# => ./tsconfig.merged.json
|
|
128
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// tsconfig.merged.json
|
|
133
|
+
{
|
|
134
|
+
"compilerOptions": {
|
|
135
|
+
// ...options
|
|
136
|
+
},
|
|
137
|
+
"include": ["src/**.ts"],
|
|
138
|
+
"exclude": ["test/**.ts", "config/*.ts"]
|
|
139
|
+
}
|
|
76
140
|
```
|
|
77
141
|
|
|
78
142
|
Sprinkle in some `compilerOptions` to the mix
|
|
79
143
|
|
|
80
144
|
```sh
|
|
81
145
|
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --out ./tsconfig.out.json --allowJs true --noEmit true
|
|
146
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.out.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// tsconfig.out.json
|
|
151
|
+
{
|
|
152
|
+
"compilerOptions": {
|
|
153
|
+
"allowJS": true,
|
|
154
|
+
"noEmit": true,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Delete a compiler option
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --allowJS --noEmit 'delete'
|
|
163
|
+
# ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
// tsconfig.merged.json
|
|
168
|
+
{
|
|
169
|
+
"compilerOptions": {
|
|
170
|
+
"allowJS": true,
|
|
171
|
+
// "noEmit": true, // deleted
|
|
172
|
+
}
|
|
173
|
+
}
|
|
82
174
|
```
|
|
83
175
|
|
|
84
176
|
---
|
|
@@ -113,7 +205,7 @@ Merge tsconfig files into a single tsconfig
|
|
|
113
205
|
const config = mergeTsconfigs({
|
|
114
206
|
files: ['./tsconfig.json', './tsconfig.build.json'],
|
|
115
207
|
});
|
|
116
|
-
//
|
|
208
|
+
// ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
117
209
|
```
|
|
118
210
|
|
|
119
211
|
Merge tsconfig files into a custom output file
|
|
@@ -123,7 +215,7 @@ const config = mergeTsconfigs({
|
|
|
123
215
|
files: ['./tsconfig.json', './tsconfig.build.json'],
|
|
124
216
|
out: './new-dir/tsconfig.out.json',
|
|
125
217
|
});
|
|
126
|
-
//
|
|
218
|
+
// ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.out.json
|
|
127
219
|
```
|
|
128
220
|
|
|
129
221
|
---
|
|
@@ -136,7 +228,7 @@ Install merge-tsconfigs with your preferred package manager.
|
|
|
136
228
|
npm install merge-tsconfigs --save-dev
|
|
137
229
|
```
|
|
138
230
|
|
|
139
|
-
\*unpkg and skypack support coming very soon! 🚀
|
|
231
|
+
\*[unpkg](https://unpkg.com/merge-tsconfigs@0.1.1/dist/index.js) and [skypack](https://cdn.skypack.dev/merge-tsconfigs?min) support coming very soon! 🚀
|
|
140
232
|
|
|
141
233
|
---
|
|
142
234
|
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(src_exports, {
|
|
|
26
26
|
mergeTsConfigs: () => mergeTsConfigs,
|
|
27
27
|
resolveJSON: () => resolveJSON,
|
|
28
28
|
script: () => script,
|
|
29
|
+
updateCompilerOptions: () => updateCompilerOptions,
|
|
29
30
|
writeTsconfig: () => writeTsconfig
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -69,11 +70,12 @@ function resolveJSON(path, debug = false) {
|
|
|
69
70
|
return {};
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
var mergeConfigContent = (tsconfigs, debug = false) => tsconfigs.reduce((acc = {}, tsconfig) => {
|
|
73
|
-
|
|
73
|
+
var mergeConfigContent = (tsconfigs, cwd, debug = false) => tsconfigs.reduce((acc = {}, tsconfig) => {
|
|
74
|
+
const path = `${cwd}/${tsconfig}`;
|
|
75
|
+
let tsconfigJSON = resolveJSON(path, debug);
|
|
74
76
|
const parentPath = tsconfigJSON?.extends;
|
|
75
77
|
if (parentPath) {
|
|
76
|
-
const relativeParentPath = (0, import_path.join)((0, import_path.dirname)(
|
|
78
|
+
const relativeParentPath = (0, import_path.join)((0, import_path.dirname)(path), parentPath);
|
|
77
79
|
const parentTsconfig = resolveJSON(relativeParentPath, debug);
|
|
78
80
|
if (parentTsconfig?.extends) {
|
|
79
81
|
logger({ isDebugging: debug })("error")("mergeConfigContent")("Parent tsconfig:merge-tsconfigs only handles extending from a parent, consider extending tsconfigs less.")(parentTsconfig);
|
|
@@ -102,19 +104,34 @@ var mergeConfigContent = (tsconfigs, debug = false) => tsconfigs.reduce((acc = {
|
|
|
102
104
|
}
|
|
103
105
|
};
|
|
104
106
|
}, {});
|
|
105
|
-
var writeTsconfig = (tsconfig, out, isTesting) => {
|
|
107
|
+
var writeTsconfig = (tsconfig, cwd, out, isTesting) => {
|
|
106
108
|
if (isTesting)
|
|
107
109
|
return tsconfig;
|
|
108
|
-
const path = out.length ? out :
|
|
110
|
+
const path = out.length ? out : `${cwd}/tsconfig.merged.json`;
|
|
109
111
|
(0, import_fs.mkdirSync)((0, import_path.dirname)(path), { recursive: true });
|
|
110
112
|
(0, import_fs.writeFileSync)(path, JSON.stringify(tsconfig, null, 2));
|
|
111
113
|
return tsconfig;
|
|
112
114
|
};
|
|
115
|
+
var updateCompilerOptions = (compilerOptions2 = {}, currentCompilerOptions) => {
|
|
116
|
+
const compilerOptionKeys = compilerOptions2 ? Object.keys(compilerOptions2) : [];
|
|
117
|
+
const hasCompilerOptions = compilerOptionKeys.length > 0;
|
|
118
|
+
if (!hasCompilerOptions)
|
|
119
|
+
return {};
|
|
120
|
+
return compilerOptionKeys.reduce((acc = {}, key) => {
|
|
121
|
+
const updatedOptions = { ...acc, ...currentCompilerOptions };
|
|
122
|
+
const value = compilerOptions2?.[key];
|
|
123
|
+
if (updatedOptions?.[key] === "delete") {
|
|
124
|
+
delete updatedOptions[key];
|
|
125
|
+
return updatedOptions || {};
|
|
126
|
+
}
|
|
127
|
+
return { ...updatedOptions, [key]: value };
|
|
128
|
+
}, {});
|
|
129
|
+
};
|
|
113
130
|
var mergeTsConfigs = ({
|
|
114
131
|
tsconfigs = [],
|
|
115
|
-
exclude
|
|
116
|
-
include
|
|
117
|
-
compilerOptions: compilerOptions2
|
|
132
|
+
exclude,
|
|
133
|
+
include,
|
|
134
|
+
compilerOptions: compilerOptions2,
|
|
118
135
|
debug = false,
|
|
119
136
|
out = "",
|
|
120
137
|
isTesting = false
|
|
@@ -124,16 +141,20 @@ var mergeTsConfigs = ({
|
|
|
124
141
|
logger({ isDebugging: debug })("error")("mergeTsConfig")("No tsconfig files were provided.")(null);
|
|
125
142
|
return;
|
|
126
143
|
}
|
|
127
|
-
const
|
|
144
|
+
const cwd = process.cwd();
|
|
145
|
+
const updatedTsconfig = mergeConfigContent(tsconfigs, cwd, debug);
|
|
128
146
|
if (debug)
|
|
129
147
|
logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
148
|
+
const updatedCompilerOptions = updateCompilerOptions(compilerOptions2, updatedTsconfig?.compilerOptions || {});
|
|
149
|
+
const updatedExclude = exclude ? [...updatedTsconfig?.exclude || [], ...exclude] : updatedTsconfig?.exclude;
|
|
150
|
+
const updatedInclude = include ? [...updatedTsconfig.include || [], ...include] : updatedTsconfig?.include;
|
|
130
151
|
const tsconfig = {
|
|
131
152
|
...updatedTsconfig,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
...
|
|
153
|
+
...updatedExclude,
|
|
154
|
+
...updatedInclude,
|
|
155
|
+
...Object.keys(updatedCompilerOptions).length > 0 ? { compilerOptions: updatedCompilerOptions } : {}
|
|
135
156
|
};
|
|
136
|
-
return writeTsconfig(tsconfig, out, isTesting);
|
|
157
|
+
return writeTsconfig(tsconfig, cwd, out, isTesting);
|
|
137
158
|
};
|
|
138
159
|
var script = mergeTsConfigs;
|
|
139
160
|
var scripts_default = mergeTsConfigs;
|
|
@@ -206,6 +227,8 @@ Object.keys(compilerOptions).map((name) => ({ name, value: compilerOptions[name]
|
|
|
206
227
|
import_commander.program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
207
228
|
} else if (value === "array") {
|
|
208
229
|
import_commander.program.option(`--${name} [${value}...]`, `tsconfig.compilerOptions.${name}`);
|
|
230
|
+
} else if (value === "object") {
|
|
231
|
+
import_commander.program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
209
232
|
}
|
|
210
233
|
});
|
|
211
234
|
import_commander.program.action(action).parse(process.argv);
|
|
@@ -219,5 +242,6 @@ var src_default = scripts_default;
|
|
|
219
242
|
mergeTsConfigs,
|
|
220
243
|
resolveJSON,
|
|
221
244
|
script,
|
|
245
|
+
updateCompilerOptions,
|
|
222
246
|
writeTsconfig
|
|
223
247
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { CompilerOptions } from 'typescript';
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
3
|
|
|
4
|
+
interface CompilerOptionOverrides {
|
|
5
|
+
[key: string]: string | boolean | string[] | undefined;
|
|
6
|
+
}
|
|
7
|
+
type PartialCompilerOptions = PartialDeep<CompilerOptions | CompilerOptionOverrides>;
|
|
4
8
|
interface ConfigOptions {
|
|
5
|
-
compilerOptions?:
|
|
9
|
+
compilerOptions?: PartialCompilerOptions;
|
|
6
10
|
debug?: boolean;
|
|
7
11
|
out?: string;
|
|
8
12
|
tsconfigs?: string[];
|
|
@@ -18,16 +22,17 @@ type LoggerParams = {
|
|
|
18
22
|
};
|
|
19
23
|
interface TsConfig {
|
|
20
24
|
extends?: string;
|
|
21
|
-
compilerOptions?: CompilerOptions
|
|
25
|
+
compilerOptions?: PartialDeep<CompilerOptions>;
|
|
22
26
|
include?: string[];
|
|
23
27
|
exclude?: string[];
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
declare const logger: ({ isDebugging, emoji, gap, name }: LoggerParams) => (type: string) => (section: string) => (message: string) => (err: unknown) => void;
|
|
27
31
|
declare function resolveJSON(path: string, debug?: boolean): TsConfig;
|
|
28
|
-
declare const mergeConfigContent: (tsconfigs: string[], debug?: boolean) => TsConfig;
|
|
29
|
-
declare const writeTsconfig: (tsconfig: TsConfig, out: string, isTesting: boolean) => TsConfig;
|
|
32
|
+
declare const mergeConfigContent: (tsconfigs: string[], cwd: string, debug?: boolean) => TsConfig;
|
|
33
|
+
declare const writeTsconfig: (tsconfig: TsConfig, cwd: string, out: string, isTesting: boolean) => TsConfig;
|
|
34
|
+
declare const updateCompilerOptions: (compilerOptions: PartialCompilerOptions | undefined, currentCompilerOptions: PartialCompilerOptions) => PartialCompilerOptions;
|
|
30
35
|
declare const mergeTsConfigs: ({ tsconfigs, exclude, include, compilerOptions, debug, out, isTesting, }: ConfigOptions) => TsConfig | undefined;
|
|
31
36
|
declare const script: ({ tsconfigs, exclude, include, compilerOptions, debug, out, isTesting, }: ConfigOptions) => TsConfig | undefined;
|
|
32
37
|
|
|
33
|
-
export { mergeTsConfigs as default, logger, mergeConfigContent, mergeTsConfigs, resolveJSON, script, writeTsconfig };
|
|
38
|
+
export { mergeTsConfigs as default, logger, mergeConfigContent, mergeTsConfigs, resolveJSON, script, updateCompilerOptions, writeTsconfig };
|
package/dist/index.js
CHANGED
|
@@ -37,11 +37,12 @@ function resolveJSON(path, debug = false) {
|
|
|
37
37
|
return {};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
var mergeConfigContent = (tsconfigs, debug = false) => tsconfigs.reduce((acc = {}, tsconfig) => {
|
|
41
|
-
|
|
40
|
+
var mergeConfigContent = (tsconfigs, cwd, debug = false) => tsconfigs.reduce((acc = {}, tsconfig) => {
|
|
41
|
+
const path = `${cwd}/${tsconfig}`;
|
|
42
|
+
let tsconfigJSON = resolveJSON(path, debug);
|
|
42
43
|
const parentPath = tsconfigJSON?.extends;
|
|
43
44
|
if (parentPath) {
|
|
44
|
-
const relativeParentPath = join(dirname(
|
|
45
|
+
const relativeParentPath = join(dirname(path), parentPath);
|
|
45
46
|
const parentTsconfig = resolveJSON(relativeParentPath, debug);
|
|
46
47
|
if (parentTsconfig?.extends) {
|
|
47
48
|
logger({ isDebugging: debug })("error")("mergeConfigContent")("Parent tsconfig:merge-tsconfigs only handles extending from a parent, consider extending tsconfigs less.")(parentTsconfig);
|
|
@@ -70,19 +71,34 @@ var mergeConfigContent = (tsconfigs, debug = false) => tsconfigs.reduce((acc = {
|
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}, {});
|
|
73
|
-
var writeTsconfig = (tsconfig, out, isTesting) => {
|
|
74
|
+
var writeTsconfig = (tsconfig, cwd, out, isTesting) => {
|
|
74
75
|
if (isTesting)
|
|
75
76
|
return tsconfig;
|
|
76
|
-
const path = out.length ? out :
|
|
77
|
+
const path = out.length ? out : `${cwd}/tsconfig.merged.json`;
|
|
77
78
|
mkdirSync(dirname(path), { recursive: true });
|
|
78
79
|
writeFileSync(path, JSON.stringify(tsconfig, null, 2));
|
|
79
80
|
return tsconfig;
|
|
80
81
|
};
|
|
82
|
+
var updateCompilerOptions = (compilerOptions2 = {}, currentCompilerOptions) => {
|
|
83
|
+
const compilerOptionKeys = compilerOptions2 ? Object.keys(compilerOptions2) : [];
|
|
84
|
+
const hasCompilerOptions = compilerOptionKeys.length > 0;
|
|
85
|
+
if (!hasCompilerOptions)
|
|
86
|
+
return {};
|
|
87
|
+
return compilerOptionKeys.reduce((acc = {}, key) => {
|
|
88
|
+
const updatedOptions = { ...acc, ...currentCompilerOptions };
|
|
89
|
+
const value = compilerOptions2?.[key];
|
|
90
|
+
if (updatedOptions?.[key] === "delete") {
|
|
91
|
+
delete updatedOptions[key];
|
|
92
|
+
return updatedOptions || {};
|
|
93
|
+
}
|
|
94
|
+
return { ...updatedOptions, [key]: value };
|
|
95
|
+
}, {});
|
|
96
|
+
};
|
|
81
97
|
var mergeTsConfigs = ({
|
|
82
98
|
tsconfigs = [],
|
|
83
|
-
exclude
|
|
84
|
-
include
|
|
85
|
-
compilerOptions: compilerOptions2
|
|
99
|
+
exclude,
|
|
100
|
+
include,
|
|
101
|
+
compilerOptions: compilerOptions2,
|
|
86
102
|
debug = false,
|
|
87
103
|
out = "",
|
|
88
104
|
isTesting = false
|
|
@@ -92,16 +108,20 @@ var mergeTsConfigs = ({
|
|
|
92
108
|
logger({ isDebugging: debug })("error")("mergeTsConfig")("No tsconfig files were provided.")(null);
|
|
93
109
|
return;
|
|
94
110
|
}
|
|
95
|
-
const
|
|
111
|
+
const cwd = process.cwd();
|
|
112
|
+
const updatedTsconfig = mergeConfigContent(tsconfigs, cwd, debug);
|
|
96
113
|
if (debug)
|
|
97
114
|
logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
115
|
+
const updatedCompilerOptions = updateCompilerOptions(compilerOptions2, updatedTsconfig?.compilerOptions || {});
|
|
116
|
+
const updatedExclude = exclude ? [...updatedTsconfig?.exclude || [], ...exclude] : updatedTsconfig?.exclude;
|
|
117
|
+
const updatedInclude = include ? [...updatedTsconfig.include || [], ...include] : updatedTsconfig?.include;
|
|
98
118
|
const tsconfig = {
|
|
99
119
|
...updatedTsconfig,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
...
|
|
120
|
+
...updatedExclude,
|
|
121
|
+
...updatedInclude,
|
|
122
|
+
...Object.keys(updatedCompilerOptions).length > 0 ? { compilerOptions: updatedCompilerOptions } : {}
|
|
103
123
|
};
|
|
104
|
-
return writeTsconfig(tsconfig, out, isTesting);
|
|
124
|
+
return writeTsconfig(tsconfig, cwd, out, isTesting);
|
|
105
125
|
};
|
|
106
126
|
var script = mergeTsConfigs;
|
|
107
127
|
var scripts_default = mergeTsConfigs;
|
|
@@ -174,6 +194,8 @@ Object.keys(compilerOptions).map((name) => ({ name, value: compilerOptions[name]
|
|
|
174
194
|
program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
175
195
|
} else if (value === "array") {
|
|
176
196
|
program.option(`--${name} [${value}...]`, `tsconfig.compilerOptions.${name}`);
|
|
197
|
+
} else if (value === "object") {
|
|
198
|
+
program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
177
199
|
}
|
|
178
200
|
});
|
|
179
201
|
program.action(action).parse(process.argv);
|
|
@@ -187,5 +209,6 @@ export {
|
|
|
187
209
|
mergeTsConfigs,
|
|
188
210
|
resolveJSON,
|
|
189
211
|
script,
|
|
212
|
+
updateCompilerOptions,
|
|
190
213
|
writeTsconfig
|
|
191
214
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "merge-tsconfigs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Merge-tsconfigs is a CLI and node tool for merging tsconfig files into the exact tsconfig file you want 🛣️",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"unpkg": "dist/index.js",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"import": "./dist/index.js",
|