merge-tsconfigs 0.0.5 → 0.0.7
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 +5 -1
- package/dist/index.cjs +12 -13
- package/dist/index.d.ts +4 -2
- package/dist/index.js +12 -7
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -128,12 +128,16 @@ const config = mergeTsconfigs({
|
|
|
128
128
|
|
|
129
129
|
---
|
|
130
130
|
|
|
131
|
-
## How do I
|
|
131
|
+
## How do I start using this?
|
|
132
|
+
|
|
133
|
+
Install merge-tsconfigs with your preferred package manager.
|
|
132
134
|
|
|
133
135
|
```sh
|
|
134
136
|
npm install merge-tsconfigs --save-dev
|
|
135
137
|
```
|
|
136
138
|
|
|
139
|
+
\*unpkg and skypack support coming very soon! 🚀
|
|
140
|
+
|
|
137
141
|
---
|
|
138
142
|
|
|
139
143
|
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,10 +15,6 @@ 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
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
|
|
26
20
|
// src/index.ts
|
|
@@ -38,7 +32,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
38
32
|
|
|
39
33
|
// src/scripts.ts
|
|
40
34
|
var import_fs = require("fs");
|
|
41
|
-
var import_gradient_string = __toESM(require("gradient-string"), 1);
|
|
42
35
|
var import_path = require("path");
|
|
43
36
|
var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, name = "merge-tsconfigs" }) => (type) => (section) => (message) => (err) => {
|
|
44
37
|
const debugMsg = isDebugging ? "debugging:" : "";
|
|
@@ -46,21 +39,21 @@ var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, na
|
|
|
46
39
|
const firstLine = `${name}:${debugMsg}${sectionMsg}`;
|
|
47
40
|
const secondLine = message ? `${emoji}${gap}${message}` : "";
|
|
48
41
|
if (type === "error") {
|
|
49
|
-
console.error(
|
|
42
|
+
console.error(firstLine);
|
|
50
43
|
if (secondLine)
|
|
51
44
|
console.error(secondLine);
|
|
52
45
|
if (err)
|
|
53
46
|
console.error(err);
|
|
54
47
|
} else if (type === "debug") {
|
|
55
|
-
console.debug(
|
|
48
|
+
console.debug(firstLine);
|
|
56
49
|
if (secondLine)
|
|
57
50
|
console.debug(secondLine);
|
|
58
51
|
} else if (type === "info") {
|
|
59
|
-
console.info(
|
|
52
|
+
console.info(firstLine);
|
|
60
53
|
if (secondLine)
|
|
61
54
|
console.info(secondLine);
|
|
62
55
|
} else {
|
|
63
|
-
console.log(
|
|
56
|
+
console.log(firstLine);
|
|
64
57
|
if (secondLine)
|
|
65
58
|
console.log(secondLine);
|
|
66
59
|
}
|
|
@@ -105,6 +98,8 @@ var writeTsconfig = (tsconfig, out) => {
|
|
|
105
98
|
};
|
|
106
99
|
var mergeTsConfigs = ({
|
|
107
100
|
tsconfigs = [],
|
|
101
|
+
exclude = [],
|
|
102
|
+
include = [],
|
|
108
103
|
compilerOptions: compilerOptions2 = {},
|
|
109
104
|
debug = false,
|
|
110
105
|
out = ""
|
|
@@ -119,6 +114,8 @@ var mergeTsConfigs = ({
|
|
|
119
114
|
logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
120
115
|
const tsconfig = {
|
|
121
116
|
...updatedTsconfig,
|
|
117
|
+
exclude: [...updatedTsconfig.exclude || [], ...exclude],
|
|
118
|
+
include: [...updatedTsconfig.include || [], ...include],
|
|
122
119
|
...compilerOptions2
|
|
123
120
|
};
|
|
124
121
|
return writeTsconfig(tsconfig, out);
|
|
@@ -175,7 +172,7 @@ var compilerOptions = {
|
|
|
175
172
|
async function action(files, options = {}) {
|
|
176
173
|
const { debug = false, isTesting = false, isTestingCLI = false, ...compilerOptions2 } = options;
|
|
177
174
|
if (isTestingCLI) {
|
|
178
|
-
console.info({ files });
|
|
175
|
+
console.info({ files, options });
|
|
179
176
|
return;
|
|
180
177
|
}
|
|
181
178
|
try {
|
|
@@ -188,7 +185,9 @@ import_commander.program.name("merge-tsconfigs").description(
|
|
|
188
185
|
"Merge-tsconfigs is a CLI and node tool for merging tsconfig files into the exact tsconfig file you want \u{1F6E3}\uFE0F"
|
|
189
186
|
).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("-t, --isTestingCLI", "enable CLI only testing");
|
|
190
187
|
Object.keys(compilerOptions).map((name) => ({ name, value: compilerOptions[name] })).forEach(({ name, value }) => {
|
|
191
|
-
if (
|
|
188
|
+
if (value === "boolean") {
|
|
189
|
+
import_commander.program.option(`--${name}`, `tsconfig.compilerOptions.${name}`);
|
|
190
|
+
} else if (value === "string") {
|
|
192
191
|
import_commander.program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
193
192
|
} else if (value === "array") {
|
|
194
193
|
import_commander.program.option(`--${name} [${value}...]`, `tsconfig.compilerOptions.${name}`);
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ interface ConfigOptions {
|
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
out?: string;
|
|
8
8
|
tsconfigs?: string[];
|
|
9
|
+
exclude?: string[];
|
|
10
|
+
include?: string[];
|
|
9
11
|
}
|
|
10
12
|
type LoggerParams = {
|
|
11
13
|
isDebugging?: boolean;
|
|
@@ -24,7 +26,7 @@ declare const logger: ({ isDebugging, emoji, gap, name }: LoggerParams) => (type
|
|
|
24
26
|
declare function resolveJSON(path: string, debug?: boolean): TsConfig;
|
|
25
27
|
declare const mergeConfigContent: (tsconfigs: string[], debug?: boolean) => TsConfig;
|
|
26
28
|
declare const writeTsconfig: (tsconfig: TsConfig, out: string) => TsConfig;
|
|
27
|
-
declare const mergeTsConfigs: ({ tsconfigs, compilerOptions, debug, out, }: ConfigOptions) => TsConfig | undefined;
|
|
28
|
-
declare const script: ({ tsconfigs, compilerOptions, debug, out, }: ConfigOptions) => TsConfig | undefined;
|
|
29
|
+
declare const mergeTsConfigs: ({ tsconfigs, exclude, include, compilerOptions, debug, out, }: ConfigOptions) => TsConfig | undefined;
|
|
30
|
+
declare const script: ({ tsconfigs, exclude, include, compilerOptions, debug, out, }: ConfigOptions) => TsConfig | undefined;
|
|
29
31
|
|
|
30
32
|
export { mergeTsConfigs as default, logger, mergeConfigContent, mergeTsConfigs, resolveJSON, script, writeTsconfig };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/scripts.ts
|
|
2
2
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
-
import gradient from "gradient-string";
|
|
4
3
|
import { dirname } from "path";
|
|
5
4
|
var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, name = "merge-tsconfigs" }) => (type) => (section) => (message) => (err) => {
|
|
6
5
|
const debugMsg = isDebugging ? "debugging:" : "";
|
|
@@ -8,21 +7,21 @@ var logger = ({ isDebugging = false, emoji = `\u{1F6E3}\uFE0F`, gap = ` => `, na
|
|
|
8
7
|
const firstLine = `${name}:${debugMsg}${sectionMsg}`;
|
|
9
8
|
const secondLine = message ? `${emoji}${gap}${message}` : "";
|
|
10
9
|
if (type === "error") {
|
|
11
|
-
console.error(
|
|
10
|
+
console.error(firstLine);
|
|
12
11
|
if (secondLine)
|
|
13
12
|
console.error(secondLine);
|
|
14
13
|
if (err)
|
|
15
14
|
console.error(err);
|
|
16
15
|
} else if (type === "debug") {
|
|
17
|
-
console.debug(
|
|
16
|
+
console.debug(firstLine);
|
|
18
17
|
if (secondLine)
|
|
19
18
|
console.debug(secondLine);
|
|
20
19
|
} else if (type === "info") {
|
|
21
|
-
console.info(
|
|
20
|
+
console.info(firstLine);
|
|
22
21
|
if (secondLine)
|
|
23
22
|
console.info(secondLine);
|
|
24
23
|
} else {
|
|
25
|
-
console.log(
|
|
24
|
+
console.log(firstLine);
|
|
26
25
|
if (secondLine)
|
|
27
26
|
console.log(secondLine);
|
|
28
27
|
}
|
|
@@ -67,6 +66,8 @@ var writeTsconfig = (tsconfig, out) => {
|
|
|
67
66
|
};
|
|
68
67
|
var mergeTsConfigs = ({
|
|
69
68
|
tsconfigs = [],
|
|
69
|
+
exclude = [],
|
|
70
|
+
include = [],
|
|
70
71
|
compilerOptions: compilerOptions2 = {},
|
|
71
72
|
debug = false,
|
|
72
73
|
out = ""
|
|
@@ -81,6 +82,8 @@ var mergeTsConfigs = ({
|
|
|
81
82
|
logger({ isDebugging: debug })("debug")("mergeTsConfig")("Updated tsconfig:")(updatedTsconfig);
|
|
82
83
|
const tsconfig = {
|
|
83
84
|
...updatedTsconfig,
|
|
85
|
+
exclude: [...updatedTsconfig.exclude || [], ...exclude],
|
|
86
|
+
include: [...updatedTsconfig.include || [], ...include],
|
|
84
87
|
...compilerOptions2
|
|
85
88
|
};
|
|
86
89
|
return writeTsconfig(tsconfig, out);
|
|
@@ -137,7 +140,7 @@ var compilerOptions = {
|
|
|
137
140
|
async function action(files, options = {}) {
|
|
138
141
|
const { debug = false, isTesting = false, isTestingCLI = false, ...compilerOptions2 } = options;
|
|
139
142
|
if (isTestingCLI) {
|
|
140
|
-
console.info({ files });
|
|
143
|
+
console.info({ files, options });
|
|
141
144
|
return;
|
|
142
145
|
}
|
|
143
146
|
try {
|
|
@@ -150,7 +153,9 @@ program.name("merge-tsconfigs").description(
|
|
|
150
153
|
"Merge-tsconfigs is a CLI and node tool for merging tsconfig files into the exact tsconfig file you want \u{1F6E3}\uFE0F"
|
|
151
154
|
).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("-t, --isTestingCLI", "enable CLI only testing");
|
|
152
155
|
Object.keys(compilerOptions).map((name) => ({ name, value: compilerOptions[name] })).forEach(({ name, value }) => {
|
|
153
|
-
if (
|
|
156
|
+
if (value === "boolean") {
|
|
157
|
+
program.option(`--${name}`, `tsconfig.compilerOptions.${name}`);
|
|
158
|
+
} else if (value === "string") {
|
|
154
159
|
program.option(`--${name} <${value}>`, `tsconfig.compilerOptions.${name}`);
|
|
155
160
|
} else if (value === "array") {
|
|
156
161
|
program.option(`--${name} [${value}...]`, `tsconfig.compilerOptions.${name}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "merge-tsconfigs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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",
|
|
@@ -35,15 +35,11 @@
|
|
|
35
35
|
"update": "codependence --update"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"commander": "^9.5.0"
|
|
39
|
-
"cosmiconfig": "^8.0.0",
|
|
40
|
-
"fast-glob": "^3.2.12",
|
|
41
|
-
"gradient-string": "^2.0.2"
|
|
38
|
+
"commander": "^9.5.0"
|
|
42
39
|
},
|
|
43
40
|
"devDependencies": {
|
|
44
41
|
"@commitlint/cli": "^17.4.2",
|
|
45
42
|
"@commitlint/config-conventional": "^17.4.2",
|
|
46
|
-
"@types/gradient-string": "^1.1.2",
|
|
47
43
|
"@types/node": "^18.11.18",
|
|
48
44
|
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
49
45
|
"@typescript-eslint/parser": "^5.48.1",
|