@ttoss/config 1.11.7 → 1.12.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 +26 -1
- package/dist/esm/index.js +7 -2
- package/dist/index.d.ts +247 -6
- package/dist/index.js +7 -2
- package/package.json +2 -2
- package/src/babel.spec.ts +21 -0
- package/src/babel.ts +3 -0
- package/src/commitlint.spec.ts +9 -4
- package/src/configCreator.spec.ts +36 -0
- package/src/configCreator.ts +10 -2
- package/src/jest.ts +1 -1
- package/src/tsup.spec.ts +10 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ttoss/config
|
|
2
2
|
|
|
3
|
-
<strong>@ttoss/config</strong> is
|
|
3
|
+
<strong>@ttoss/config</strong> is an opinionated configuration library for monorepo repositories, packages, and applications. It contains a set of <a href="/docs/core/config/default-configs">default configurations</a> that you can use on your projects.
|
|
4
4
|
|
|
5
5
|
Each configuration is customizable and you can extend them with your own. For example, you can use the default `.prettierrc.js` file in your monorepo:
|
|
6
6
|
|
|
@@ -20,6 +20,31 @@ module.exports = prettierConfig({
|
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
You can also pass a second argument to every configuration to handle array's append or overwrite items.
|
|
24
|
+
|
|
25
|
+
```js title="babel.config.js"
|
|
26
|
+
const { babelConfig } = require('@ttoss/config');
|
|
27
|
+
|
|
28
|
+
// Append plugins (default)
|
|
29
|
+
const appendConfig = babelConfig(
|
|
30
|
+
{
|
|
31
|
+
plugins: ['@babel/plugin-proposal-class-properties'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
arrayMerge: 'append',
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const overwriteConfig = babelConfig(
|
|
39
|
+
{
|
|
40
|
+
plugins: ['@babel/plugin-proposal-class-properties'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
arrayMerge: 'overwrite',
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
23
48
|
## Install
|
|
24
49
|
|
|
25
50
|
```shell
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/configCreator.ts
|
|
2
2
|
import deepmerge from "deepmerge";
|
|
3
3
|
var overwriteMerge = (_, sourceArray) => sourceArray;
|
|
4
|
-
var configCreator = (defaultConfig7 = {}) => (config = {}) => deepmerge(defaultConfig7, config, {
|
|
4
|
+
var configCreator = (defaultConfig7 = {}) => (config = {}, deepmergeConfig) => deepmerge(defaultConfig7, config, {
|
|
5
|
+
arrayMerge: (deepmergeConfig == null ? void 0 : deepmergeConfig.arrayMerge) === "overwrite" ? overwriteMerge : void 0
|
|
6
|
+
});
|
|
5
7
|
|
|
6
8
|
// src/babel.ts
|
|
7
9
|
var defaultConfig = {
|
|
@@ -17,7 +19,10 @@ var defaultConfig = {
|
|
|
17
19
|
idInterpolationPattern: "[sha512:contenthash:base64:6]",
|
|
18
20
|
ast: true
|
|
19
21
|
}
|
|
20
|
-
]
|
|
22
|
+
],
|
|
23
|
+
["@babel/plugin-proposal-class-properties", { loose: true }],
|
|
24
|
+
["@babel/plugin-proposal-private-methods", { loose: true }],
|
|
25
|
+
["@babel/plugin-proposal-private-property-in-object", { loose: true }]
|
|
21
26
|
]
|
|
22
27
|
};
|
|
23
28
|
var babelConfig = configCreator(defaultConfig);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,256 @@
|
|
|
1
|
+
import { Config } from '@jest/types';
|
|
1
2
|
import { Options } from 'tsup';
|
|
2
3
|
|
|
3
|
-
declare const babelConfig: (config?: any
|
|
4
|
+
declare const babelConfig: (config?: any, deepmergeConfig?: {
|
|
5
|
+
arrayMerge: "append" | "overwrite";
|
|
6
|
+
} | undefined) => any;
|
|
4
7
|
|
|
5
|
-
declare const commitlintConfig: (config?: any
|
|
8
|
+
declare const commitlintConfig: (config?: any, deepmergeConfig?: {
|
|
9
|
+
arrayMerge: "append" | "overwrite";
|
|
10
|
+
} | undefined) => any;
|
|
6
11
|
|
|
7
|
-
declare const jestConfig: (config?:
|
|
12
|
+
declare const jestConfig: (config?: Partial<{
|
|
13
|
+
automock: boolean;
|
|
14
|
+
bail: number | boolean;
|
|
15
|
+
cache: boolean;
|
|
16
|
+
cacheDirectory: string;
|
|
17
|
+
ci: boolean;
|
|
18
|
+
clearMocks: boolean;
|
|
19
|
+
changedFilesWithAncestor: boolean;
|
|
20
|
+
changedSince: string;
|
|
21
|
+
collectCoverage: boolean;
|
|
22
|
+
collectCoverageFrom: string[];
|
|
23
|
+
collectCoverageOnlyFrom: {
|
|
24
|
+
[key: string]: boolean;
|
|
25
|
+
};
|
|
26
|
+
coverageDirectory: string;
|
|
27
|
+
coveragePathIgnorePatterns: string[];
|
|
28
|
+
coverageProvider: "v8" | "babel";
|
|
29
|
+
coverageReporters: Config.CoverageReporters;
|
|
30
|
+
coverageThreshold: {
|
|
31
|
+
[path: string]: Config.CoverageThresholdValue;
|
|
32
|
+
global: Config.CoverageThresholdValue;
|
|
33
|
+
};
|
|
34
|
+
dependencyExtractor: string;
|
|
35
|
+
detectLeaks: boolean;
|
|
36
|
+
detectOpenHandles: boolean;
|
|
37
|
+
displayName: string | Config.DisplayName;
|
|
38
|
+
expand: boolean;
|
|
39
|
+
extensionsToTreatAsEsm: string[];
|
|
40
|
+
extraGlobals: string[];
|
|
41
|
+
filter: string;
|
|
42
|
+
findRelatedTests: boolean;
|
|
43
|
+
forceCoverageMatch: string[];
|
|
44
|
+
forceExit: boolean;
|
|
45
|
+
json: boolean;
|
|
46
|
+
globals: Config.ConfigGlobals;
|
|
47
|
+
globalSetup: string | null | undefined;
|
|
48
|
+
globalTeardown: string | null | undefined;
|
|
49
|
+
haste: Config.HasteConfig;
|
|
50
|
+
injectGlobals: boolean;
|
|
51
|
+
reporters: (string | Config.ReporterConfig)[];
|
|
52
|
+
logHeapUsage: boolean;
|
|
53
|
+
lastCommit: boolean;
|
|
54
|
+
listTests: boolean;
|
|
55
|
+
maxConcurrency: number;
|
|
56
|
+
maxWorkers: string | number;
|
|
57
|
+
moduleDirectories: string[];
|
|
58
|
+
moduleFileExtensions: string[];
|
|
59
|
+
moduleLoader: string;
|
|
60
|
+
moduleNameMapper: {
|
|
61
|
+
[key: string]: string | string[];
|
|
62
|
+
};
|
|
63
|
+
modulePathIgnorePatterns: string[];
|
|
64
|
+
modulePaths: string[];
|
|
65
|
+
name: string;
|
|
66
|
+
noStackTrace: boolean;
|
|
67
|
+
notify: boolean;
|
|
68
|
+
notifyMode: string;
|
|
69
|
+
onlyChanged: boolean;
|
|
70
|
+
onlyFailures: boolean;
|
|
71
|
+
outputFile: string;
|
|
72
|
+
passWithNoTests: boolean;
|
|
73
|
+
preprocessorIgnorePatterns: string[];
|
|
74
|
+
preset: string | null | undefined;
|
|
75
|
+
prettierPath: string | null | undefined;
|
|
76
|
+
projects: (string | Config.InitialProjectOptions)[];
|
|
77
|
+
replname: string | null | undefined;
|
|
78
|
+
resetMocks: boolean;
|
|
79
|
+
resetModules: boolean;
|
|
80
|
+
resolver: string | null | undefined;
|
|
81
|
+
restoreMocks: boolean;
|
|
82
|
+
rootDir: string;
|
|
83
|
+
roots: string[];
|
|
84
|
+
runner: string;
|
|
85
|
+
runTestsByPath: boolean;
|
|
86
|
+
scriptPreprocessor: string;
|
|
87
|
+
setupFiles: string[];
|
|
88
|
+
setupTestFrameworkScriptFile: string;
|
|
89
|
+
setupFilesAfterEnv: string[];
|
|
90
|
+
silent: boolean;
|
|
91
|
+
skipFilter: boolean;
|
|
92
|
+
skipNodeResolution: boolean;
|
|
93
|
+
slowTestThreshold: number;
|
|
94
|
+
snapshotResolver: string;
|
|
95
|
+
snapshotSerializers: string[];
|
|
96
|
+
snapshotFormat: Config.PrettyFormatOptions;
|
|
97
|
+
errorOnDeprecated: boolean;
|
|
98
|
+
testEnvironment: string;
|
|
99
|
+
testEnvironmentOptions: Record<string, unknown>;
|
|
100
|
+
testFailureExitCode: string | number;
|
|
101
|
+
testLocationInResults: boolean;
|
|
102
|
+
testMatch: string[];
|
|
103
|
+
testNamePattern: string;
|
|
104
|
+
testPathDirs: string[];
|
|
105
|
+
testPathIgnorePatterns: string[];
|
|
106
|
+
testRegex: string | string[];
|
|
107
|
+
testResultsProcessor: string;
|
|
108
|
+
testRunner: string;
|
|
109
|
+
testSequencer: string;
|
|
110
|
+
testURL: string;
|
|
111
|
+
testTimeout: number;
|
|
112
|
+
timers: "fake" | "real" | "modern" | "legacy";
|
|
113
|
+
transform: {
|
|
114
|
+
[regex: string]: string | Config.TransformerConfig;
|
|
115
|
+
};
|
|
116
|
+
transformIgnorePatterns: string[];
|
|
117
|
+
watchPathIgnorePatterns: string[];
|
|
118
|
+
unmockedModulePathPatterns: string[];
|
|
119
|
+
updateSnapshot: boolean;
|
|
120
|
+
useStderr: boolean;
|
|
121
|
+
verbose?: boolean | undefined;
|
|
122
|
+
watch: boolean;
|
|
123
|
+
watchAll: boolean;
|
|
124
|
+
watchman: boolean;
|
|
125
|
+
watchPlugins: (string | [string, Record<string, unknown>])[];
|
|
126
|
+
}>, deepmergeConfig?: {
|
|
127
|
+
arrayMerge: "append" | "overwrite";
|
|
128
|
+
} | undefined) => Partial<{
|
|
129
|
+
automock: boolean;
|
|
130
|
+
bail: number | boolean;
|
|
131
|
+
cache: boolean;
|
|
132
|
+
cacheDirectory: string;
|
|
133
|
+
ci: boolean;
|
|
134
|
+
clearMocks: boolean;
|
|
135
|
+
changedFilesWithAncestor: boolean;
|
|
136
|
+
changedSince: string;
|
|
137
|
+
collectCoverage: boolean;
|
|
138
|
+
collectCoverageFrom: string[];
|
|
139
|
+
collectCoverageOnlyFrom: {
|
|
140
|
+
[key: string]: boolean;
|
|
141
|
+
};
|
|
142
|
+
coverageDirectory: string;
|
|
143
|
+
coveragePathIgnorePatterns: string[];
|
|
144
|
+
coverageProvider: "v8" | "babel";
|
|
145
|
+
coverageReporters: Config.CoverageReporters;
|
|
146
|
+
coverageThreshold: {
|
|
147
|
+
[path: string]: Config.CoverageThresholdValue;
|
|
148
|
+
global: Config.CoverageThresholdValue;
|
|
149
|
+
};
|
|
150
|
+
dependencyExtractor: string;
|
|
151
|
+
detectLeaks: boolean;
|
|
152
|
+
detectOpenHandles: boolean;
|
|
153
|
+
displayName: string | Config.DisplayName;
|
|
154
|
+
expand: boolean;
|
|
155
|
+
extensionsToTreatAsEsm: string[];
|
|
156
|
+
extraGlobals: string[];
|
|
157
|
+
filter: string;
|
|
158
|
+
findRelatedTests: boolean;
|
|
159
|
+
forceCoverageMatch: string[];
|
|
160
|
+
forceExit: boolean;
|
|
161
|
+
json: boolean;
|
|
162
|
+
globals: Config.ConfigGlobals;
|
|
163
|
+
globalSetup: string | null | undefined;
|
|
164
|
+
globalTeardown: string | null | undefined;
|
|
165
|
+
haste: Config.HasteConfig;
|
|
166
|
+
injectGlobals: boolean;
|
|
167
|
+
reporters: (string | Config.ReporterConfig)[];
|
|
168
|
+
logHeapUsage: boolean;
|
|
169
|
+
lastCommit: boolean;
|
|
170
|
+
listTests: boolean;
|
|
171
|
+
maxConcurrency: number;
|
|
172
|
+
maxWorkers: string | number;
|
|
173
|
+
moduleDirectories: string[];
|
|
174
|
+
moduleFileExtensions: string[];
|
|
175
|
+
moduleLoader: string;
|
|
176
|
+
moduleNameMapper: {
|
|
177
|
+
[key: string]: string | string[];
|
|
178
|
+
};
|
|
179
|
+
modulePathIgnorePatterns: string[];
|
|
180
|
+
modulePaths: string[];
|
|
181
|
+
name: string;
|
|
182
|
+
noStackTrace: boolean;
|
|
183
|
+
notify: boolean;
|
|
184
|
+
notifyMode: string;
|
|
185
|
+
onlyChanged: boolean;
|
|
186
|
+
onlyFailures: boolean;
|
|
187
|
+
outputFile: string;
|
|
188
|
+
passWithNoTests: boolean;
|
|
189
|
+
preprocessorIgnorePatterns: string[];
|
|
190
|
+
preset: string | null | undefined;
|
|
191
|
+
prettierPath: string | null | undefined;
|
|
192
|
+
projects: (string | Config.InitialProjectOptions)[];
|
|
193
|
+
replname: string | null | undefined;
|
|
194
|
+
resetMocks: boolean;
|
|
195
|
+
resetModules: boolean;
|
|
196
|
+
resolver: string | null | undefined;
|
|
197
|
+
restoreMocks: boolean;
|
|
198
|
+
rootDir: string;
|
|
199
|
+
roots: string[];
|
|
200
|
+
runner: string;
|
|
201
|
+
runTestsByPath: boolean;
|
|
202
|
+
scriptPreprocessor: string;
|
|
203
|
+
setupFiles: string[];
|
|
204
|
+
setupTestFrameworkScriptFile: string;
|
|
205
|
+
setupFilesAfterEnv: string[];
|
|
206
|
+
silent: boolean;
|
|
207
|
+
skipFilter: boolean;
|
|
208
|
+
skipNodeResolution: boolean;
|
|
209
|
+
slowTestThreshold: number;
|
|
210
|
+
snapshotResolver: string;
|
|
211
|
+
snapshotSerializers: string[];
|
|
212
|
+
snapshotFormat: Config.PrettyFormatOptions;
|
|
213
|
+
errorOnDeprecated: boolean;
|
|
214
|
+
testEnvironment: string;
|
|
215
|
+
testEnvironmentOptions: Record<string, unknown>;
|
|
216
|
+
testFailureExitCode: string | number;
|
|
217
|
+
testLocationInResults: boolean;
|
|
218
|
+
testMatch: string[];
|
|
219
|
+
testNamePattern: string;
|
|
220
|
+
testPathDirs: string[];
|
|
221
|
+
testPathIgnorePatterns: string[];
|
|
222
|
+
testRegex: string | string[];
|
|
223
|
+
testResultsProcessor: string;
|
|
224
|
+
testRunner: string;
|
|
225
|
+
testSequencer: string;
|
|
226
|
+
testURL: string;
|
|
227
|
+
testTimeout: number;
|
|
228
|
+
timers: "fake" | "real" | "modern" | "legacy";
|
|
229
|
+
transform: {
|
|
230
|
+
[regex: string]: string | Config.TransformerConfig;
|
|
231
|
+
};
|
|
232
|
+
transformIgnorePatterns: string[];
|
|
233
|
+
watchPathIgnorePatterns: string[];
|
|
234
|
+
unmockedModulePathPatterns: string[];
|
|
235
|
+
updateSnapshot: boolean;
|
|
236
|
+
useStderr: boolean;
|
|
237
|
+
verbose?: boolean | undefined;
|
|
238
|
+
watch: boolean;
|
|
239
|
+
watchAll: boolean;
|
|
240
|
+
watchman: boolean;
|
|
241
|
+
watchPlugins: (string | [string, Record<string, unknown>])[];
|
|
242
|
+
}>;
|
|
8
243
|
|
|
9
|
-
declare const lintstagedConfig: (config?: any
|
|
244
|
+
declare const lintstagedConfig: (config?: any, deepmergeConfig?: {
|
|
245
|
+
arrayMerge: "append" | "overwrite";
|
|
246
|
+
} | undefined) => any;
|
|
10
247
|
|
|
11
|
-
declare const prettierConfig: (config?: any
|
|
248
|
+
declare const prettierConfig: (config?: any, deepmergeConfig?: {
|
|
249
|
+
arrayMerge: "append" | "overwrite";
|
|
250
|
+
} | undefined) => any;
|
|
12
251
|
|
|
13
|
-
declare const tsupConfig: (config?: Options
|
|
252
|
+
declare const tsupConfig: (config?: Options, deepmergeConfig?: {
|
|
253
|
+
arrayMerge: "append" | "overwrite";
|
|
254
|
+
} | undefined) => Options;
|
|
14
255
|
|
|
15
256
|
export { babelConfig, commitlintConfig, jestConfig, lintstagedConfig, prettierConfig, tsupConfig };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ module.exports = __toCommonJS(src_exports);
|
|
|
34
34
|
// src/configCreator.ts
|
|
35
35
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
36
36
|
var overwriteMerge = (_, sourceArray) => sourceArray;
|
|
37
|
-
var configCreator = (defaultConfig7 = {}) => (config = {}) => (0, import_deepmerge.default)(defaultConfig7, config, {
|
|
37
|
+
var configCreator = (defaultConfig7 = {}) => (config = {}, deepmergeConfig) => (0, import_deepmerge.default)(defaultConfig7, config, {
|
|
38
|
+
arrayMerge: (deepmergeConfig == null ? void 0 : deepmergeConfig.arrayMerge) === "overwrite" ? overwriteMerge : void 0
|
|
39
|
+
});
|
|
38
40
|
|
|
39
41
|
// src/babel.ts
|
|
40
42
|
var defaultConfig = {
|
|
@@ -50,7 +52,10 @@ var defaultConfig = {
|
|
|
50
52
|
idInterpolationPattern: "[sha512:contenthash:base64:6]",
|
|
51
53
|
ast: true
|
|
52
54
|
}
|
|
53
|
-
]
|
|
55
|
+
],
|
|
56
|
+
["@babel/plugin-proposal-class-properties", { loose: true }],
|
|
57
|
+
["@babel/plugin-proposal-private-methods", { loose: true }],
|
|
58
|
+
["@babel/plugin-proposal-private-property-in-object", { loose: true }]
|
|
54
59
|
]
|
|
55
60
|
};
|
|
56
61
|
var babelConfig = configCreator(defaultConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "Default configuration for packages.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"identity-obj-proxy": "^3.0.0",
|
|
41
41
|
"tsup": "^5.11.11"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "da3750c7ee25f994a1fd647d48278fc46707257e",
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@jest/types": "^27.4.2"
|
|
46
46
|
}
|
package/src/babel.spec.ts
CHANGED
|
@@ -3,3 +3,24 @@ import { babelConfig, defaultConfig } from './babel';
|
|
|
3
3
|
test('should return default config', () => {
|
|
4
4
|
expect(babelConfig()).toEqual(defaultConfig);
|
|
5
5
|
});
|
|
6
|
+
|
|
7
|
+
test('should update plugin', () => {
|
|
8
|
+
expect(
|
|
9
|
+
babelConfig(
|
|
10
|
+
{ plugins: ['relay'] },
|
|
11
|
+
{
|
|
12
|
+
arrayMerge: 'overwrite',
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
).toEqual({
|
|
16
|
+
...defaultConfig,
|
|
17
|
+
plugins: ['relay'],
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('should append plugin', () => {
|
|
22
|
+
expect(babelConfig({ plugins: ['relay'] })).toEqual({
|
|
23
|
+
...defaultConfig,
|
|
24
|
+
plugins: [...defaultConfig.plugins, 'relay'],
|
|
25
|
+
});
|
|
26
|
+
});
|
package/src/babel.ts
CHANGED
|
@@ -22,6 +22,9 @@ export const defaultConfig: any = {
|
|
|
22
22
|
ast: true,
|
|
23
23
|
},
|
|
24
24
|
],
|
|
25
|
+
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
26
|
+
['@babel/plugin-proposal-private-methods', { loose: true }],
|
|
27
|
+
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
|
|
25
28
|
],
|
|
26
29
|
};
|
|
27
30
|
|
package/src/commitlint.spec.ts
CHANGED
|
@@ -4,10 +4,15 @@ test('should return default configuration', () => {
|
|
|
4
4
|
expect(commitlintConfig()).toEqual(defaultConfig);
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
test('should return default configuration', () => {
|
|
7
|
+
test('should return default configuration with different extends', () => {
|
|
8
8
|
expect(
|
|
9
|
-
commitlintConfig(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
commitlintConfig(
|
|
10
|
+
{
|
|
11
|
+
extends: ['other-config'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
arrayMerge: 'overwrite',
|
|
15
|
+
}
|
|
16
|
+
)
|
|
12
17
|
).toEqual({ ...defaultConfig, extends: ['other-config'] });
|
|
13
18
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { configCreator } from './configCreator';
|
|
2
|
+
|
|
3
|
+
const defaultConfig: any = {
|
|
4
|
+
obj: { a: 1, b: 2 },
|
|
5
|
+
arr: [1, 2, 3],
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const config = configCreator(defaultConfig);
|
|
9
|
+
|
|
10
|
+
test('should append array', () => {
|
|
11
|
+
expect(config({ arr: [4, 5] })).toEqual({
|
|
12
|
+
obj: { a: 1, b: 2 },
|
|
13
|
+
arr: [1, 2, 3, 4, 5],
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should overwrite array', () => {
|
|
18
|
+
expect(
|
|
19
|
+
config(
|
|
20
|
+
{ arr: [4, 5] },
|
|
21
|
+
{
|
|
22
|
+
arrayMerge: 'overwrite',
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
).toEqual({
|
|
26
|
+
obj: { a: 1, b: 2 },
|
|
27
|
+
arr: [4, 5],
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('should add obj key', () => {
|
|
32
|
+
expect(config({ obj: { c: 3 } })).toEqual({
|
|
33
|
+
arr: [1, 2, 3],
|
|
34
|
+
obj: { a: 1, b: 2, c: 3 },
|
|
35
|
+
});
|
|
36
|
+
});
|
package/src/configCreator.ts
CHANGED
|
@@ -4,5 +4,13 @@ const overwriteMerge = (_: any, sourceArray: any) => sourceArray;
|
|
|
4
4
|
|
|
5
5
|
export const configCreator =
|
|
6
6
|
<T extends Record<string, any>>(defaultConfig: T = {} as T) =>
|
|
7
|
-
(
|
|
8
|
-
|
|
7
|
+
(
|
|
8
|
+
config: T = {} as T,
|
|
9
|
+
deepmergeConfig?: { arrayMerge: 'append' | 'overwrite' }
|
|
10
|
+
) =>
|
|
11
|
+
deepmerge<T>(defaultConfig, config, {
|
|
12
|
+
arrayMerge:
|
|
13
|
+
deepmergeConfig?.arrayMerge === 'overwrite'
|
|
14
|
+
? overwriteMerge
|
|
15
|
+
: undefined,
|
|
16
|
+
});
|
package/src/jest.ts
CHANGED
package/src/tsup.spec.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultConfig, tsupConfig } from './tsup';
|
|
2
2
|
|
|
3
3
|
test('should return default configuration', () => {
|
|
4
4
|
expect(tsupConfig()).toEqual(defaultConfig);
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
test('should return default configuration', () => {
|
|
7
|
+
test('should return default configuration with different entrypoint', () => {
|
|
8
8
|
expect(
|
|
9
|
-
tsupConfig(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
tsupConfig(
|
|
10
|
+
{
|
|
11
|
+
entryPoints: ['src/index.tsx'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
arrayMerge: 'overwrite',
|
|
15
|
+
}
|
|
16
|
+
)
|
|
12
17
|
).toEqual({ ...defaultConfig, entryPoints: ['src/index.tsx'] });
|
|
13
18
|
});
|