merge-tsconfigs 0.2.1 → 0.2.4
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 +8 -16
- package/dist/index.cjs +145 -158
- package/dist/index.d.cts +277 -0
- package/dist/index.d.ts +240 -115
- package/dist/index.js +134 -140
- package/dist/program.d.ts +31 -0
- package/dist/program.js +474 -0
- package/package.json +118 -109
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
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)
|
|
7
5
|

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

|
|
@@ -29,6 +27,7 @@ By providing an easy way to create the tsconfig you want, your everyday tsconfig
|
|
|
29
27
|
### _For example_
|
|
30
28
|
|
|
31
29
|
By running `merge-tsconfigs ./tsconfig.build.json` you'll merge `tsconfig.json`
|
|
30
|
+
|
|
32
31
|
```ts
|
|
33
32
|
{
|
|
34
33
|
"compilerOptions": {
|
|
@@ -38,6 +37,7 @@ By running `merge-tsconfigs ./tsconfig.build.json` you'll merge `tsconfig.json`
|
|
|
38
37
|
```
|
|
39
38
|
|
|
40
39
|
and, `tsconfig.build.json`
|
|
40
|
+
|
|
41
41
|
```ts
|
|
42
42
|
{
|
|
43
43
|
"compilerOptions": {
|
|
@@ -48,6 +48,7 @@ and, `tsconfig.build.json`
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
into `tsconfig.merged.json`
|
|
51
|
+
|
|
51
52
|
```ts
|
|
52
53
|
{
|
|
53
54
|
"compilerOptions": {
|
|
@@ -66,6 +67,7 @@ Which you can now use for deployment, dockerfiles, or any other use case. And, y
|
|
|
66
67
|
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.
|
|
67
68
|
|
|
68
69
|
---
|
|
70
|
+
|
|
69
71
|
### CLI API
|
|
70
72
|
|
|
71
73
|
Listed below are the CLI options and arguments to execute merge-tsconfigs. To \*_view all_ cli options in your browser, run `merge-tsconfigs --help`!
|
|
@@ -199,7 +201,7 @@ merge-tsconfigs ./tsconfig.json ./tsconfig.build.json --path '{"item/*": ["foo":
|
|
|
199
201
|
The node API works exactly the same as the CLI API.
|
|
200
202
|
|
|
201
203
|
```ts
|
|
202
|
-
import mergeTsconfigs from 'merge-tsconfigs'
|
|
204
|
+
import mergeTsconfigs from 'merge-tsconfigs'
|
|
203
205
|
|
|
204
206
|
mergeTsconfigs({
|
|
205
207
|
files: ['./tsconfig.json', './tsconfig.build.json'],
|
|
@@ -210,8 +212,7 @@ mergeTsconfigs({
|
|
|
210
212
|
allowJs: true,
|
|
211
213
|
noEmit: true,
|
|
212
214
|
},
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
+
})
|
|
215
216
|
```
|
|
216
217
|
|
|
217
218
|
You can use any compiler options provided by [Typescript](https://www.typescriptlang.org/docs/handbook/compiler-options.html). Object keys aren't currently implemented but can be upon feature request.
|
|
@@ -223,7 +224,7 @@ Merge tsconfig files into a single tsconfig
|
|
|
223
224
|
```ts
|
|
224
225
|
const config = mergeTsconfigs({
|
|
225
226
|
files: ['./tsconfig.json', './tsconfig.build.json'],
|
|
226
|
-
})
|
|
227
|
+
})
|
|
227
228
|
// ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.merged.json
|
|
228
229
|
```
|
|
229
230
|
|
|
@@ -233,7 +234,7 @@ Merge tsconfig files into a custom output file
|
|
|
233
234
|
const config = mergeTsconfigs({
|
|
234
235
|
files: ['./tsconfig.json', './tsconfig.build.json'],
|
|
235
236
|
out: './new-dir/tsconfig.out.json',
|
|
236
|
-
})
|
|
237
|
+
})
|
|
237
238
|
// ./tsconfig.json + ./tsconfig.build.json => ./tsconfig.out.json
|
|
238
239
|
```
|
|
239
240
|
|
|
@@ -247,15 +248,6 @@ Install merge-tsconfigs with your preferred package manager.
|
|
|
247
248
|
npm install merge-tsconfigs --save-dev
|
|
248
249
|
```
|
|
249
250
|
|
|
250
|
-
\*_Untested_: In, Deno, Snowpack, or other options, you can import merge-tsconfigs directly into your project.
|
|
251
|
-
```ts
|
|
252
|
-
import mergeTsconfigs from 'npm:merge-tsconfigs';
|
|
253
|
-
// or
|
|
254
|
-
import mergeTsconfigs from "https://cdn.skypack.dev/merge-tsconfigs@latest";
|
|
255
|
-
// or
|
|
256
|
-
import mergeTsconfigs from "https://unpkg.com/merge-tsconfigs@latest/dist/index.js";
|
|
257
|
-
```
|
|
258
|
-
|
|
259
251
|
---
|
|
260
252
|
|
|
261
253
|
Made by [@yowainwright](https://github.com/yowainwright), MIT 2023
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,36 +15,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
default: () =>
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => index_default,
|
|
34
24
|
logger: () => logger,
|
|
35
25
|
mergeConfigContent: () => mergeConfigContent,
|
|
36
26
|
mergeConfigObjects: () => mergeConfigObjects,
|
|
37
27
|
mergeTsConfigs: () => mergeTsConfigs,
|
|
28
|
+
parseJson: () => parseJson,
|
|
38
29
|
parsePath: () => parsePath,
|
|
39
30
|
resolveJSON: () => resolveJSON,
|
|
40
31
|
script: () => script,
|
|
32
|
+
stripJsonComments: () => stripJsonComments,
|
|
33
|
+
stripTrailingCommas: () => stripTrailingCommas,
|
|
41
34
|
updateCompilerOptions: () => updateCompilerOptions,
|
|
42
35
|
writeTsconfig: () => writeTsconfig
|
|
43
36
|
});
|
|
44
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
38
|
|
|
46
39
|
// src/scripts.ts
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var import_json5 = __toESM(require("json5"), 1);
|
|
40
|
+
var import_node_fs = require("fs");
|
|
41
|
+
var import_node_path = require("path");
|
|
50
42
|
var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, name = "merge-tsconfigs" }) => (type) => (section) => (message) => (err) => {
|
|
51
43
|
const debugMsg = isDebugging ? "debugging:" : "";
|
|
52
44
|
const sectionMsg = section.length ? `${section}:` : "";
|
|
@@ -54,31 +46,100 @@ var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, na
|
|
|
54
46
|
const secondLine = message ? `${emoji}${gap}${message}` : "";
|
|
55
47
|
if (type === "error") {
|
|
56
48
|
console.error(firstLine);
|
|
57
|
-
if (secondLine)
|
|
58
|
-
|
|
59
|
-
if (err)
|
|
60
|
-
console.error(err);
|
|
49
|
+
if (secondLine) console.error(secondLine);
|
|
50
|
+
if (err) console.error(err);
|
|
61
51
|
} else if (type === "debug") {
|
|
62
52
|
console.debug(firstLine);
|
|
63
|
-
if (secondLine)
|
|
64
|
-
console.debug(secondLine);
|
|
53
|
+
if (secondLine) console.debug(secondLine);
|
|
65
54
|
} else if (type === "info") {
|
|
66
55
|
console.info(firstLine);
|
|
67
|
-
if (secondLine)
|
|
68
|
-
console.info(secondLine);
|
|
56
|
+
if (secondLine) console.info(secondLine);
|
|
69
57
|
} else {
|
|
70
58
|
console.log(firstLine);
|
|
71
|
-
if (secondLine)
|
|
72
|
-
console.log(secondLine);
|
|
59
|
+
if (secondLine) console.log(secondLine);
|
|
73
60
|
}
|
|
74
61
|
};
|
|
62
|
+
function stripJsonComments(source) {
|
|
63
|
+
let output = "";
|
|
64
|
+
let inString = false;
|
|
65
|
+
let isEscaped = false;
|
|
66
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
67
|
+
const char = source[index];
|
|
68
|
+
const nextChar = source[index + 1];
|
|
69
|
+
if (inString) {
|
|
70
|
+
output += char;
|
|
71
|
+
if (isEscaped) {
|
|
72
|
+
isEscaped = false;
|
|
73
|
+
} else if (char === "\\") {
|
|
74
|
+
isEscaped = true;
|
|
75
|
+
} else if (char === '"') {
|
|
76
|
+
inString = false;
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (char === '"') {
|
|
81
|
+
inString = true;
|
|
82
|
+
output += char;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (char === "/" && nextChar === "/") {
|
|
86
|
+
while (index < source.length && source[index] !== "\n") index += 1;
|
|
87
|
+
output += "\n";
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (char === "/" && nextChar === "*") {
|
|
91
|
+
index += 2;
|
|
92
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
|
|
93
|
+
if (source[index] === "\n") output += "\n";
|
|
94
|
+
index += 1;
|
|
95
|
+
}
|
|
96
|
+
index += 1;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
output += char;
|
|
100
|
+
}
|
|
101
|
+
return output;
|
|
102
|
+
}
|
|
103
|
+
function stripTrailingCommas(source) {
|
|
104
|
+
let output = "";
|
|
105
|
+
let inString = false;
|
|
106
|
+
let isEscaped = false;
|
|
107
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
108
|
+
const char = source[index];
|
|
109
|
+
if (inString) {
|
|
110
|
+
output += char;
|
|
111
|
+
if (isEscaped) {
|
|
112
|
+
isEscaped = false;
|
|
113
|
+
} else if (char === "\\") {
|
|
114
|
+
isEscaped = true;
|
|
115
|
+
} else if (char === '"') {
|
|
116
|
+
inString = false;
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (char === '"') {
|
|
121
|
+
inString = true;
|
|
122
|
+
output += char;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (char === ",") {
|
|
126
|
+
let nextIndex = index + 1;
|
|
127
|
+
while (/\s/.test(source[nextIndex] || "")) nextIndex += 1;
|
|
128
|
+
if (source[nextIndex] === "}" || source[nextIndex] === "]") continue;
|
|
129
|
+
}
|
|
130
|
+
output += char;
|
|
131
|
+
}
|
|
132
|
+
return output;
|
|
133
|
+
}
|
|
134
|
+
function parseJson(source) {
|
|
135
|
+
return JSON.parse(stripTrailingCommas(stripJsonComments(source.trim())));
|
|
136
|
+
}
|
|
75
137
|
function resolveJSON(path, debug = false) {
|
|
76
138
|
try {
|
|
77
|
-
const json =
|
|
139
|
+
const json = parseJson((0, import_node_fs.readFileSync)(path, "utf8"));
|
|
78
140
|
return json;
|
|
79
141
|
} catch (err) {
|
|
80
|
-
if (debug)
|
|
81
|
-
logger({ isDebugging: debug })("error")("resolveJSON")("There was an error:")(err);
|
|
142
|
+
if (debug) logger({ isDebugging: debug })("error")("resolveJSON")("There was an error:")(err);
|
|
82
143
|
return {};
|
|
83
144
|
}
|
|
84
145
|
}
|
|
@@ -90,16 +151,10 @@ var mergeConfigObjects = (tsconfig1, tsconfig2) => ({
|
|
|
90
151
|
...tsconfig2?.compilerOptions
|
|
91
152
|
},
|
|
92
153
|
...tsconfig1?.exclude || tsconfig2?.exclude ? {
|
|
93
|
-
exclude: [
|
|
94
|
-
...tsconfig1?.exclude || [],
|
|
95
|
-
...tsconfig2?.exclude || []
|
|
96
|
-
]
|
|
154
|
+
exclude: [...tsconfig1?.exclude || [], ...tsconfig2?.exclude || []]
|
|
97
155
|
} : {},
|
|
98
156
|
...tsconfig1?.include || tsconfig2?.include ? {
|
|
99
|
-
include: [
|
|
100
|
-
...tsconfig1?.include || [],
|
|
101
|
-
...tsconfig2?.include || []
|
|
102
|
-
]
|
|
157
|
+
include: [...tsconfig1?.include || [], ...tsconfig2?.include || []]
|
|
103
158
|
} : {}
|
|
104
159
|
});
|
|
105
160
|
var mergeConfigContent = (tsconfigs, cwd, debug = false) => tsconfigs.reduce((acc = {}, tsconfig) => {
|
|
@@ -107,58 +162,72 @@ var mergeConfigContent = (tsconfigs, cwd, debug = false) => tsconfigs.reduce((ac
|
|
|
107
162
|
let tsconfigJSON = resolveJSON(path, debug);
|
|
108
163
|
const parentPath = tsconfigJSON?.extends;
|
|
109
164
|
if (parentPath) {
|
|
110
|
-
const relativeParentPath = (0,
|
|
165
|
+
const relativeParentPath = (0, import_node_path.join)((0, import_node_path.dirname)(path), parentPath);
|
|
111
166
|
const parentTsconfig = resolveJSON(relativeParentPath, debug);
|
|
112
167
|
if (parentTsconfig?.extends) {
|
|
113
|
-
logger({ isDebugging: debug })("error")("mergeConfigContent")(
|
|
168
|
+
logger({ isDebugging: debug })("error")("mergeConfigContent")(
|
|
169
|
+
"Parent tsconfig:merge-tsconfigs only handles extending from a parent, consider extending tsconfigs less."
|
|
170
|
+
)(parentTsconfig);
|
|
114
171
|
}
|
|
115
172
|
const { extends: _, ...tsconfigWithoutExtends } = tsconfigJSON;
|
|
116
173
|
tsconfigJSON = mergeConfigObjects(parentTsconfig, tsconfigWithoutExtends);
|
|
117
174
|
}
|
|
118
175
|
if (!tsconfigJSON) {
|
|
119
|
-
if (debug)
|
|
120
|
-
logger({ isDebugging: debug })("error")("mergeConfigContent")("There was an error:")(tsconfigJSON);
|
|
176
|
+
if (debug) logger({ isDebugging: debug })("error")("mergeConfigContent")("There was an error:")(tsconfigJSON);
|
|
121
177
|
return acc;
|
|
122
178
|
}
|
|
123
179
|
return mergeConfigObjects(acc, tsconfigJSON);
|
|
124
180
|
}, {});
|
|
125
181
|
var writeTsconfig = (tsconfig, cwd, out, isTesting) => {
|
|
126
|
-
if (isTesting)
|
|
127
|
-
return tsconfig;
|
|
182
|
+
if (isTesting) return tsconfig;
|
|
128
183
|
const path = `${cwd}/${out}`;
|
|
129
|
-
(0,
|
|
130
|
-
(0,
|
|
184
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path), { recursive: true });
|
|
185
|
+
(0, import_node_fs.writeFileSync)(path, JSON.stringify(tsconfig, null, 2));
|
|
131
186
|
return tsconfig;
|
|
132
187
|
};
|
|
133
|
-
var updateCompilerOptions = (
|
|
134
|
-
const compilerOptionKeys =
|
|
188
|
+
var updateCompilerOptions = (compilerOptions = {}, currentCompilerOptions = {}, updatedPath = {}) => {
|
|
189
|
+
const compilerOptionKeys = compilerOptions ? Object.keys(compilerOptions) : [];
|
|
135
190
|
const hasCompilerOptions = compilerOptionKeys.length > 0;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
191
|
+
const hasUpdatedPath = Object.keys(updatedPath || {}).length > 0;
|
|
192
|
+
if (!hasCompilerOptions && !hasUpdatedPath) return {};
|
|
193
|
+
const updatedOptions = compilerOptionKeys.reduce(
|
|
194
|
+
(acc, key) => {
|
|
195
|
+
const value = compilerOptions?.[key];
|
|
196
|
+
if (value === "delete") {
|
|
197
|
+
const { [key]: _deletedOption, ...remainingOptions } = acc;
|
|
198
|
+
return remainingOptions;
|
|
199
|
+
}
|
|
200
|
+
const parsedPath = key === "paths" && typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
201
|
+
const paths = {
|
|
202
|
+
...acc.paths || {},
|
|
203
|
+
...parsedPath
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
...acc,
|
|
207
|
+
[key]: value,
|
|
208
|
+
...Object.keys(paths).length > 0 ? { paths } : {}
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
{ ...currentCompilerOptions }
|
|
212
|
+
);
|
|
213
|
+
if (hasUpdatedPath) {
|
|
214
|
+
return {
|
|
215
|
+
...updatedOptions,
|
|
216
|
+
paths: {
|
|
217
|
+
...updatedOptions.paths || {},
|
|
218
|
+
...updatedPath
|
|
219
|
+
}
|
|
149
220
|
};
|
|
150
|
-
|
|
151
|
-
|
|
221
|
+
}
|
|
222
|
+
return updatedOptions;
|
|
152
223
|
};
|
|
153
224
|
var parsePath = (path = "", debug = false) => {
|
|
154
|
-
if (!path)
|
|
155
|
-
return {};
|
|
225
|
+
if (!path) return {};
|
|
156
226
|
try {
|
|
157
|
-
const json =
|
|
227
|
+
const json = parseJson(path);
|
|
158
228
|
return json;
|
|
159
229
|
} catch (err) {
|
|
160
|
-
if (debug)
|
|
161
|
-
logger({ isDebugging: debug })("error")("parsePath")("There was an error:")(err);
|
|
230
|
+
if (debug) logger({ isDebugging: debug })("error")("parsePath")("There was an error:")(err);
|
|
162
231
|
return {};
|
|
163
232
|
}
|
|
164
233
|
};
|
|
@@ -166,24 +235,22 @@ var mergeTsConfigs = ({
|
|
|
166
235
|
tsconfigs = [],
|
|
167
236
|
exclude,
|
|
168
237
|
include,
|
|
169
|
-
compilerOptions
|
|
238
|
+
compilerOptions,
|
|
170
239
|
debug = false,
|
|
171
240
|
out = "tsconfig.merged.json",
|
|
172
241
|
path,
|
|
173
242
|
isTesting = false
|
|
174
243
|
}) => {
|
|
175
244
|
if (tsconfigs.length === 0) {
|
|
176
|
-
if (debug)
|
|
177
|
-
logger({ isDebugging: debug })("error")("mergeTsConfig")("No tsconfig files were provided.")(null);
|
|
245
|
+
if (debug) logger({ isDebugging: debug })("error")("mergeTsConfig")("No tsconfig files were provided.")(null);
|
|
178
246
|
return;
|
|
179
247
|
}
|
|
180
248
|
const cwd = process.cwd();
|
|
181
249
|
const updatedTsconfig = mergeConfigContent(tsconfigs, cwd, debug);
|
|
182
|
-
if (debug)
|
|
183
|
-
logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
250
|
+
if (debug) logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
184
251
|
const updatedPath = parsePath(path, debug);
|
|
185
252
|
const updatedCompilerOptions = updateCompilerOptions(
|
|
186
|
-
|
|
253
|
+
compilerOptions,
|
|
187
254
|
updatedTsconfig?.compilerOptions || {},
|
|
188
255
|
updatedPath
|
|
189
256
|
);
|
|
@@ -200,100 +267,20 @@ var mergeTsConfigs = ({
|
|
|
200
267
|
var script = mergeTsConfigs;
|
|
201
268
|
var scripts_default = mergeTsConfigs;
|
|
202
269
|
|
|
203
|
-
// src/program.ts
|
|
204
|
-
var import_commander = require("commander");
|
|
205
|
-
|
|
206
|
-
// src/config.ts
|
|
207
|
-
var compilerOptions = {
|
|
208
|
-
target: "string",
|
|
209
|
-
module: "string",
|
|
210
|
-
lib: "array",
|
|
211
|
-
allowJs: "boolean",
|
|
212
|
-
checkJs: "boolean",
|
|
213
|
-
jsx: "string",
|
|
214
|
-
declaration: "boolean",
|
|
215
|
-
sourceMap: "boolean",
|
|
216
|
-
outFile: "string",
|
|
217
|
-
outDir: "string",
|
|
218
|
-
rootDir: "string",
|
|
219
|
-
removeComments: "boolean",
|
|
220
|
-
noEmit: "boolean",
|
|
221
|
-
importHelpers: "boolean",
|
|
222
|
-
downlevelIteration: "boolean",
|
|
223
|
-
isolatedModules: "boolean",
|
|
224
|
-
strict: "boolean",
|
|
225
|
-
noImplicitAny: "boolean",
|
|
226
|
-
strictNullChecks: "boolean",
|
|
227
|
-
noImplicitThis: "boolean",
|
|
228
|
-
alwaysStrict: "boolean",
|
|
229
|
-
noUnusedLocals: "boolean",
|
|
230
|
-
noUnusedParameters: "boolean",
|
|
231
|
-
noImplicitReturns: "boolean",
|
|
232
|
-
noFallthroughCasesInSwitch: "boolean",
|
|
233
|
-
moduleResolution: "string",
|
|
234
|
-
baseUrl: "string",
|
|
235
|
-
paths: "object",
|
|
236
|
-
rootDirs: "array",
|
|
237
|
-
typeRoots: "array",
|
|
238
|
-
types: "array",
|
|
239
|
-
allowSyntheticDefaultImports: "boolean",
|
|
240
|
-
sourceRoot: "string",
|
|
241
|
-
mapRoot: "string",
|
|
242
|
-
inlineSourceMap: "boolean",
|
|
243
|
-
inlineSources: "boolean",
|
|
244
|
-
experimentalDecorators: "boolean",
|
|
245
|
-
emitDecoratorMetadata: "boolean"
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// src/program.ts
|
|
249
|
-
function action(files, options = {}) {
|
|
250
|
-
try {
|
|
251
|
-
const {
|
|
252
|
-
debug = false,
|
|
253
|
-
exclude,
|
|
254
|
-
include,
|
|
255
|
-
isTesting = false,
|
|
256
|
-
isTestingCLI = false,
|
|
257
|
-
out,
|
|
258
|
-
path,
|
|
259
|
-
...compilerOptions2
|
|
260
|
-
} = options;
|
|
261
|
-
if (isTestingCLI) {
|
|
262
|
-
console.info({ files, options });
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
script({ debug, exclude, include, isTesting, path, out, tsconfigs: files, compilerOptions: compilerOptions2 });
|
|
266
|
-
} catch (err) {
|
|
267
|
-
logger({ isDebugging: options.debug })("error")("action")("There was an error:")(err);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
import_commander.program.name("merge-tsconfigs").description(
|
|
271
|
-
"Merge-tsconfigs is a CLI and node tool for merging tsconfig files into the exact tsconfig file you want \u{1F6E3}\uFE0F"
|
|
272
|
-
).argument("[files...]", "files to check, matches an array pattern").option("-d, --debug", "enable debugging").option("-e, --exclude [exclude...]", "files to exclude, matches a glob or array pattern").option("-i, --include [include...]", "files to include, matches a glob or array pattern").option("--isTesting", "enable testing").option("-o, --out <file>", "output file, otherwise, the file will be written to tsconfig.merged.json").option("--isTesting", "enable testing").option("-t, --isTestingCLI", "enable CLI only testing").option("-p, --path <path>", 'a json parseable string wrapped object, e.g. {"item/*": ["foo": "bar"]}');
|
|
273
|
-
Object.keys(compilerOptions).map((name) => ({ name, value: compilerOptions[name] })).forEach(({ name, value }) => {
|
|
274
|
-
if (value === "boolean") {
|
|
275
|
-
import_commander.program.option(`--${name}`, `tsconfig.compilerOptions.${name}`);
|
|
276
|
-
} else if (value === "string") {
|
|
277
|
-
import_commander.program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
278
|
-
} else if (value === "array") {
|
|
279
|
-
import_commander.program.option(`--${name} [${value}...]`, `tsconfig.compilerOptions.${name}`);
|
|
280
|
-
} else if (value === "object") {
|
|
281
|
-
import_commander.program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
import_commander.program.action(action).parse(process.argv);
|
|
285
|
-
|
|
286
270
|
// src/index.ts
|
|
287
|
-
var
|
|
271
|
+
var index_default = scripts_default;
|
|
288
272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
289
273
|
0 && (module.exports = {
|
|
290
274
|
logger,
|
|
291
275
|
mergeConfigContent,
|
|
292
276
|
mergeConfigObjects,
|
|
293
277
|
mergeTsConfigs,
|
|
278
|
+
parseJson,
|
|
294
279
|
parsePath,
|
|
295
280
|
resolveJSON,
|
|
296
281
|
script,
|
|
282
|
+
stripJsonComments,
|
|
283
|
+
stripTrailingCommas,
|
|
297
284
|
updateCompilerOptions,
|
|
298
285
|
writeTsconfig
|
|
299
286
|
});
|