@kubb/core 3.0.0-alpha.29 → 3.0.0-alpha.30
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/dist/{FileManager-4lbobkix.d.cts → FileManager-CqvmdzNO.d.cts} +21 -23
- package/dist/{FileManager-CdXrquQt.d.ts → FileManager-DIArE3b0.d.ts} +21 -23
- package/dist/{chunk-E3LZA47U.cjs → chunk-2UQARE2O.cjs} +8 -8
- package/dist/{chunk-E3LZA47U.cjs.map → chunk-2UQARE2O.cjs.map} +1 -1
- package/dist/{chunk-YKBUGVEZ.cjs → chunk-LLKRRIBF.cjs} +10 -10
- package/dist/{chunk-YKBUGVEZ.cjs.map → chunk-LLKRRIBF.cjs.map} +1 -1
- package/dist/{chunk-CLTNHSMO.js → chunk-MD2LDZ3Z.js} +45 -51
- package/dist/chunk-MD2LDZ3Z.js.map +1 -0
- package/dist/{chunk-P655QOG5.cjs → chunk-OX2X7B4Z.cjs} +4 -4
- package/dist/{chunk-P655QOG5.cjs.map → chunk-OX2X7B4Z.cjs.map} +1 -1
- package/dist/{chunk-BQ5EEZ3C.cjs → chunk-RIW2LFFQ.cjs} +6 -6
- package/dist/{chunk-BQ5EEZ3C.cjs.map → chunk-RIW2LFFQ.cjs.map} +1 -1
- package/dist/{chunk-YZITPSOO.cjs → chunk-SX5FHSVT.cjs} +76 -81
- package/dist/chunk-SX5FHSVT.cjs.map +1 -0
- package/dist/{chunk-6KGAP5LO.cjs → chunk-VBGWLAET.cjs} +4 -4
- package/dist/{chunk-6KGAP5LO.cjs.map → chunk-VBGWLAET.cjs.map} +1 -1
- package/dist/index.cjs +40 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +7 -7
- package/dist/mocks.cjs +11 -11
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +3 -3
- package/dist/mocks.js.map +1 -1
- package/dist/{prompt-2EVJOUVT.cjs → prompt-2PN2F25D.cjs} +62 -62
- package/dist/{prompt-2EVJOUVT.cjs.map → prompt-2PN2F25D.cjs.map} +1 -1
- package/dist/transformers.cjs +23 -23
- package/dist/utils.cjs +17 -17
- package/dist/utils.d.cts +4 -7
- package/dist/utils.d.ts +4 -7
- package/dist/utils.js +1 -1
- package/package.json +6 -6
- package/src/FileManager.ts +17 -14
- package/src/PluginManager.ts +3 -3
- package/src/__snapshots__/barrel.json +11 -31
- package/src/__snapshots__/grouped.json +6 -6
- package/src/__snapshots__/ordered.json +6 -6
- package/src/build.ts +5 -6
- package/src/types.ts +17 -16
- package/src/utils/parser.ts +25 -35
- package/dist/chunk-CLTNHSMO.js.map +0 -1
- package/dist/chunk-YZITPSOO.cjs.map +0 -1
package/dist/transformers.cjs
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var chunkOX2X7B4Z_cjs = require('./chunk-OX2X7B4Z.cjs');
|
|
6
|
+
var chunkRIW2LFFQ_cjs = require('./chunk-RIW2LFFQ.cjs');
|
|
7
|
+
var chunkVBGWLAET_cjs = require('./chunk-VBGWLAET.cjs');
|
|
8
8
|
var remeda = require('remeda');
|
|
9
9
|
|
|
10
10
|
// src/transformers/index.ts
|
|
11
|
-
|
|
11
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
12
12
|
|
|
13
13
|
// src/transformers/combineCodes.ts
|
|
14
|
-
|
|
14
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
15
15
|
function combineCodes(codes) {
|
|
16
16
|
return codes.join("\n");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// src/transformers/createJSDocBlockText.ts
|
|
20
|
-
|
|
20
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
21
21
|
function createJSDocBlockText({ comments }) {
|
|
22
22
|
const filteredComments = comments.filter(Boolean);
|
|
23
23
|
if (!filteredComments.length) {
|
|
@@ -29,7 +29,7 @@ function createJSDocBlockText({ comments }) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// src/transformers/escape.ts
|
|
32
|
-
|
|
32
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
33
33
|
function escape(text) {
|
|
34
34
|
return text ? text.replaceAll("`", "\\`") : "";
|
|
35
35
|
}
|
|
@@ -56,13 +56,13 @@ function jsStringEscape(input) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// src/transformers/indent.ts
|
|
59
|
-
|
|
59
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
60
60
|
function createIndent(size) {
|
|
61
61
|
return Array.from({ length: size + 1 }).join(" ");
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/transformers/nameSorter.ts
|
|
65
|
-
|
|
65
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
66
66
|
function nameSorter(a, b) {
|
|
67
67
|
if (a.name < b.name) {
|
|
68
68
|
return -1;
|
|
@@ -74,7 +74,7 @@ function nameSorter(a, b) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// src/transformers/searchAndReplace.ts
|
|
77
|
-
|
|
77
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
78
78
|
function searchAndReplace(options) {
|
|
79
79
|
const { text, replaceBy, prefix = "", key } = options;
|
|
80
80
|
const searchValues = options.searchValues?.(prefix, key) || [
|
|
@@ -92,10 +92,10 @@ function searchAndReplace(options) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// src/transformers/stringify.ts
|
|
95
|
-
|
|
95
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
96
96
|
|
|
97
97
|
// src/transformers/trim.ts
|
|
98
|
-
|
|
98
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
99
99
|
function trim(text) {
|
|
100
100
|
return text.replaceAll(/\n/g, "").trim();
|
|
101
101
|
}
|
|
@@ -132,7 +132,7 @@ function stringifyObject(value) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// src/transformers/toRegExp.ts
|
|
135
|
-
|
|
135
|
+
chunkVBGWLAET_cjs.init_cjs_shims();
|
|
136
136
|
function stringToRegex(text) {
|
|
137
137
|
const isStartWithSlash = text.startsWith("/");
|
|
138
138
|
const isEndWithSlash = text.endsWith("/");
|
|
@@ -156,7 +156,7 @@ var transformers_default = {
|
|
|
156
156
|
escape,
|
|
157
157
|
jsStringEscape,
|
|
158
158
|
createIndent,
|
|
159
|
-
transformReservedWord:
|
|
159
|
+
transformReservedWord: chunkOX2X7B4Z_cjs.transformReservedWord,
|
|
160
160
|
nameSorter,
|
|
161
161
|
searchAndReplace,
|
|
162
162
|
stringify,
|
|
@@ -168,32 +168,32 @@ var transformers_default = {
|
|
|
168
168
|
JSDoc: {
|
|
169
169
|
createJSDocBlockText
|
|
170
170
|
},
|
|
171
|
-
orderBy:
|
|
171
|
+
orderBy: chunkRIW2LFFQ_cjs.orderBy,
|
|
172
172
|
merge: remeda.merge,
|
|
173
|
-
camelCase:
|
|
174
|
-
pascalCase:
|
|
175
|
-
pathCase:
|
|
173
|
+
camelCase: chunkRIW2LFFQ_cjs.camelCase,
|
|
174
|
+
pascalCase: chunkRIW2LFFQ_cjs.pascalCase,
|
|
175
|
+
pathCase: chunkRIW2LFFQ_cjs.pathCase
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
Object.defineProperty(exports, "transformReservedWord", {
|
|
179
179
|
enumerable: true,
|
|
180
|
-
get: function () { return
|
|
180
|
+
get: function () { return chunkOX2X7B4Z_cjs.transformReservedWord; }
|
|
181
181
|
});
|
|
182
182
|
Object.defineProperty(exports, "camelCase", {
|
|
183
183
|
enumerable: true,
|
|
184
|
-
get: function () { return
|
|
184
|
+
get: function () { return chunkRIW2LFFQ_cjs.camelCase; }
|
|
185
185
|
});
|
|
186
186
|
Object.defineProperty(exports, "orderBy", {
|
|
187
187
|
enumerable: true,
|
|
188
|
-
get: function () { return
|
|
188
|
+
get: function () { return chunkRIW2LFFQ_cjs.orderBy; }
|
|
189
189
|
});
|
|
190
190
|
Object.defineProperty(exports, "pascalCase", {
|
|
191
191
|
enumerable: true,
|
|
192
|
-
get: function () { return
|
|
192
|
+
get: function () { return chunkRIW2LFFQ_cjs.pascalCase; }
|
|
193
193
|
});
|
|
194
194
|
Object.defineProperty(exports, "pathCase", {
|
|
195
195
|
enumerable: true,
|
|
196
|
-
get: function () { return
|
|
196
|
+
get: function () { return chunkRIW2LFFQ_cjs.pathCase; }
|
|
197
197
|
});
|
|
198
198
|
Object.defineProperty(exports, "merge", {
|
|
199
199
|
enumerable: true,
|
package/dist/utils.cjs
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkSX5FHSVT_cjs = require('./chunk-SX5FHSVT.cjs');
|
|
4
|
+
require('./chunk-RIW2LFFQ.cjs');
|
|
5
|
+
require('./chunk-VBGWLAET.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "FunctionParams", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkSX5FHSVT_cjs.FunctionParams; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "URLPath", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkSX5FHSVT_cjs.URLPath; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "createFile", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkSX5FHSVT_cjs.createFile; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "createFileExport", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkSX5FHSVT_cjs.createFileExport; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "createFileImport", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkSX5FHSVT_cjs.createFileImport; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "createFileParser", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkSX5FHSVT_cjs.createFileParser; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "getFileParser", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkSX5FHSVT_cjs.getFileParser; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "getUniqueName", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkSX5FHSVT_cjs.getUniqueName; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "isPromise", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkSX5FHSVT_cjs.isPromise; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "isPromiseFulfilledResult", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkSX5FHSVT_cjs.isPromiseFulfilledResult; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "isPromiseRejectedResult", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkSX5FHSVT_cjs.isPromiseRejectedResult; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "renderTemplate", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkSX5FHSVT_cjs.renderTemplate; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "setUniqueName", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkSX5FHSVT_cjs.setUniqueName; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "timeout", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkSX5FHSVT_cjs.timeout; }
|
|
64
64
|
});
|
|
65
65
|
//# sourceMappingURL=utils.cjs.map
|
|
66
66
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.d.cts
CHANGED
|
@@ -108,18 +108,14 @@ declare class URLPath {
|
|
|
108
108
|
*/
|
|
109
109
|
declare function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta>;
|
|
110
110
|
/**
|
|
111
|
-
* Helper to create a fileImport with
|
|
111
|
+
* Helper to create a fileImport with extname set
|
|
112
112
|
*/
|
|
113
113
|
declare function createFileImport(imp: KubbFile.Import): KubbFile.ResolvedImport;
|
|
114
114
|
/**
|
|
115
|
-
* Helper to create a fileExport with
|
|
115
|
+
* Helper to create a fileExport with extname set
|
|
116
116
|
*/
|
|
117
117
|
declare function createFileExport(exp: KubbFile.Export): KubbFile.ResolvedExport;
|
|
118
118
|
type ParserModule<TMeta extends object = object> = {
|
|
119
|
-
/**
|
|
120
|
-
* By default @kubb/react is used
|
|
121
|
-
*/
|
|
122
|
-
render: (item: any) => any;
|
|
123
119
|
format: (source: string) => Promise<string>;
|
|
124
120
|
/**
|
|
125
121
|
* Convert a file to string
|
|
@@ -128,8 +124,9 @@ type ParserModule<TMeta extends object = object> = {
|
|
|
128
124
|
};
|
|
129
125
|
declare function createFileParser<TMeta extends object = object>(parser: ParserModule<TMeta>): ParserModule<TMeta>;
|
|
130
126
|
type PrintOptions = {
|
|
127
|
+
extname?: KubbFile.Extname;
|
|
131
128
|
logger?: Logger;
|
|
132
129
|
};
|
|
133
|
-
declare function getFileParser<TMeta extends object = object>(
|
|
130
|
+
declare function getFileParser<TMeta extends object = object>(extname: KubbFile.Extname | undefined): Promise<ParserModule<TMeta>>;
|
|
134
131
|
|
|
135
132
|
export { FunctionParams, type FunctionParamsAST, type ParserModule, type URLObject, URLPath, createFile, createFileExport, createFileImport, createFileParser, getFileParser, getUniqueName, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, renderTemplate, setUniqueName, timeout };
|
package/dist/utils.d.ts
CHANGED
|
@@ -108,18 +108,14 @@ declare class URLPath {
|
|
|
108
108
|
*/
|
|
109
109
|
declare function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta>;
|
|
110
110
|
/**
|
|
111
|
-
* Helper to create a fileImport with
|
|
111
|
+
* Helper to create a fileImport with extname set
|
|
112
112
|
*/
|
|
113
113
|
declare function createFileImport(imp: KubbFile.Import): KubbFile.ResolvedImport;
|
|
114
114
|
/**
|
|
115
|
-
* Helper to create a fileExport with
|
|
115
|
+
* Helper to create a fileExport with extname set
|
|
116
116
|
*/
|
|
117
117
|
declare function createFileExport(exp: KubbFile.Export): KubbFile.ResolvedExport;
|
|
118
118
|
type ParserModule<TMeta extends object = object> = {
|
|
119
|
-
/**
|
|
120
|
-
* By default @kubb/react is used
|
|
121
|
-
*/
|
|
122
|
-
render: (item: any) => any;
|
|
123
119
|
format: (source: string) => Promise<string>;
|
|
124
120
|
/**
|
|
125
121
|
* Convert a file to string
|
|
@@ -128,8 +124,9 @@ type ParserModule<TMeta extends object = object> = {
|
|
|
128
124
|
};
|
|
129
125
|
declare function createFileParser<TMeta extends object = object>(parser: ParserModule<TMeta>): ParserModule<TMeta>;
|
|
130
126
|
type PrintOptions = {
|
|
127
|
+
extname?: KubbFile.Extname;
|
|
131
128
|
logger?: Logger;
|
|
132
129
|
};
|
|
133
|
-
declare function getFileParser<TMeta extends object = object>(
|
|
130
|
+
declare function getFileParser<TMeta extends object = object>(extname: KubbFile.Extname | undefined): Promise<ParserModule<TMeta>>;
|
|
134
131
|
|
|
135
132
|
export { FunctionParams, type FunctionParamsAST, type ParserModule, type URLObject, URLPath, createFile, createFileExport, createFileImport, createFileParser, getFileParser, getUniqueName, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, renderTemplate, setUniqueName, timeout };
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FunctionParams, URLPath, createFile, createFileExport, createFileImport, createFileParser, getFileParser, getUniqueName, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, renderTemplate, setUniqueName, timeout } from './chunk-
|
|
1
|
+
export { FunctionParams, URLPath, createFile, createFileExport, createFileImport, createFileParser, getFileParser, getUniqueName, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, renderTemplate, setUniqueName, timeout } from './chunk-MD2LDZ3Z.js';
|
|
2
2
|
import './chunk-4X5FFJPJ.js';
|
|
3
3
|
//# sourceMappingURL=utils.js.map
|
|
4
4
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.30",
|
|
4
4
|
"description": "Generator core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"remeda": "^2.14.0",
|
|
84
84
|
"seedrandom": "^3.0.5",
|
|
85
85
|
"semver": "^7.6.3",
|
|
86
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
87
|
-
"@kubb/parser-ts": "3.0.0-alpha.
|
|
88
|
-
"@kubb/types": "3.0.0-alpha.
|
|
86
|
+
"@kubb/fs": "3.0.0-alpha.30",
|
|
87
|
+
"@kubb/parser-ts": "3.0.0-alpha.30",
|
|
88
|
+
"@kubb/types": "3.0.0-alpha.30"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/object-hash": "^3.0.6",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"tinyrainbow": "^1.2.0",
|
|
97
97
|
"tsup": "^8.3.0",
|
|
98
98
|
"typescript": "^5.6.2",
|
|
99
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
100
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
99
|
+
"@kubb/config-ts": "3.0.0-alpha.30",
|
|
100
|
+
"@kubb/config-tsup": "3.0.0-alpha.30"
|
|
101
101
|
},
|
|
102
102
|
"engines": {
|
|
103
103
|
"node": ">=20"
|
package/src/FileManager.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { ResolvedFile } from '@kubb/fs/types'
|
|
|
13
13
|
import type { GreaterThan } from '@kubb/types'
|
|
14
14
|
import PQueue from 'p-queue'
|
|
15
15
|
import type { Logger } from './logger.ts'
|
|
16
|
-
import type { Config, Plugin } from './types.ts'
|
|
16
|
+
import type { BarrelType, Config, Plugin } from './types.ts'
|
|
17
17
|
import { createFile, getFileParser } from './utils'
|
|
18
18
|
import { type DirectoryTree, TreeNode, buildDirectoryTree } from './utils/TreeNode.ts'
|
|
19
19
|
|
|
@@ -24,6 +24,7 @@ export type FileMetaBase = {
|
|
|
24
24
|
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>
|
|
25
25
|
|
|
26
26
|
type AddIndexesProps = {
|
|
27
|
+
type: BarrelType | false | undefined
|
|
27
28
|
/**
|
|
28
29
|
* Root based on root and output.path specified in the config
|
|
29
30
|
*/
|
|
@@ -34,9 +35,6 @@ type AddIndexesProps = {
|
|
|
34
35
|
*/
|
|
35
36
|
output: {
|
|
36
37
|
path: string
|
|
37
|
-
extName?: KubbFile.Extname
|
|
38
|
-
exportAs?: string
|
|
39
|
-
exportType?: 'barrel' | 'barrelNamed' | false
|
|
40
38
|
}
|
|
41
39
|
group?: {
|
|
42
40
|
output: string
|
|
@@ -136,14 +134,13 @@ export class FileManager {
|
|
|
136
134
|
this.#filesByPath.delete(path)
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
async getBarrelFiles({ files, meta = {}, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]> {
|
|
140
|
-
|
|
141
|
-
const barrelManager = new BarrelManager({ logger })
|
|
142
|
-
|
|
143
|
-
if (exportType === false) {
|
|
137
|
+
async getBarrelFiles({ type, files, meta = {}, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]> {
|
|
138
|
+
if (!type) {
|
|
144
139
|
return []
|
|
145
140
|
}
|
|
146
141
|
|
|
142
|
+
const barrelManager = new BarrelManager({ logger })
|
|
143
|
+
|
|
147
144
|
const pathToBuildFrom = join(root, output.path)
|
|
148
145
|
|
|
149
146
|
if (trimExtName(pathToBuildFrom).endsWith('index')) {
|
|
@@ -154,7 +151,7 @@ export class FileManager {
|
|
|
154
151
|
|
|
155
152
|
const barrelFiles = barrelManager.getFiles({ files, root: pathToBuildFrom, meta })
|
|
156
153
|
|
|
157
|
-
if (
|
|
154
|
+
if (type === 'all') {
|
|
158
155
|
return barrelFiles.map((file) => {
|
|
159
156
|
return {
|
|
160
157
|
...file,
|
|
@@ -194,12 +191,16 @@ export class FileManager {
|
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
type GetSourceOptions = {
|
|
194
|
+
extname?: KubbFile.Extname
|
|
197
195
|
logger?: Logger
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
export async function getSource<TMeta extends FileMetaBase = FileMetaBase>(
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
export async function getSource<TMeta extends FileMetaBase = FileMetaBase>(
|
|
199
|
+
file: ResolvedFile<TMeta>,
|
|
200
|
+
{ logger, extname }: GetSourceOptions = {},
|
|
201
|
+
): Promise<string> {
|
|
202
|
+
const parser = await getFileParser(file.extname)
|
|
203
|
+
const source = await parser.print(file, { logger, extname })
|
|
203
204
|
|
|
204
205
|
return parser.format(source)
|
|
205
206
|
}
|
|
@@ -396,8 +397,10 @@ export async function processFiles({ dryRun, config, logger, files }: WriteFiles
|
|
|
396
397
|
const promises = orderedFiles.map(async (file) => {
|
|
397
398
|
await queue.add(async () => {
|
|
398
399
|
const message = file ? `Writing ${relative(config.root, file.path)}` : ''
|
|
400
|
+
const extnames = config.output.extension?.({})
|
|
401
|
+
const extname = extnames?.[file.extname]
|
|
399
402
|
|
|
400
|
-
const source = await getSource(file, { logger })
|
|
403
|
+
const source = await getSource(file, { logger, extname })
|
|
401
404
|
|
|
402
405
|
await write(file.path, source, { sanity: false })
|
|
403
406
|
|
package/src/PluginManager.ts
CHANGED
|
@@ -67,7 +67,7 @@ type Events = {
|
|
|
67
67
|
type GetFileProps<TOptions = object> = {
|
|
68
68
|
name: string
|
|
69
69
|
mode?: KubbFile.Mode
|
|
70
|
-
|
|
70
|
+
extname: KubbFile.Extname
|
|
71
71
|
pluginKey: Plugin['key']
|
|
72
72
|
options?: TOptions
|
|
73
73
|
}
|
|
@@ -117,8 +117,8 @@ export class PluginManager {
|
|
|
117
117
|
return this
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
getFile<TOptions = object>({ name, mode,
|
|
121
|
-
const baseName = `${name}${
|
|
120
|
+
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {
|
|
121
|
+
const baseName = `${name}${extname}` as const
|
|
122
122
|
const path = this.resolvePath({ baseName, mode, pluginKey, options })
|
|
123
123
|
|
|
124
124
|
if (!path) {
|
|
@@ -4,25 +4,13 @@
|
|
|
4
4
|
"baseName": "index.ts",
|
|
5
5
|
"exports": [
|
|
6
6
|
{
|
|
7
|
-
"
|
|
8
|
-
"hello"
|
|
9
|
-
],
|
|
10
|
-
"path": "./sub/hello.ts",
|
|
11
|
-
"extName": ".ts"
|
|
7
|
+
"path": "./sub/hello.ts"
|
|
12
8
|
},
|
|
13
9
|
{
|
|
14
|
-
"
|
|
15
|
-
"world"
|
|
16
|
-
],
|
|
17
|
-
"path": "./sub/world.ts",
|
|
18
|
-
"extName": ".ts"
|
|
10
|
+
"path": "./sub/world.ts"
|
|
19
11
|
},
|
|
20
12
|
{
|
|
21
|
-
"
|
|
22
|
-
"test"
|
|
23
|
-
],
|
|
24
|
-
"path": "./test.ts",
|
|
25
|
-
"extName": ".ts"
|
|
13
|
+
"path": "./test.ts"
|
|
26
14
|
}
|
|
27
15
|
],
|
|
28
16
|
"sources": [
|
|
@@ -45,29 +33,21 @@
|
|
|
45
33
|
"isIndexable": false
|
|
46
34
|
}
|
|
47
35
|
],
|
|
48
|
-
"meta": {},
|
|
49
36
|
"id": "feabc02536bd6630458e734990f7e2a21a55c469",
|
|
50
37
|
"name": "index",
|
|
51
|
-
"
|
|
52
|
-
"imports": []
|
|
38
|
+
"extname": ".ts",
|
|
39
|
+
"imports": [],
|
|
40
|
+
"meta": {}
|
|
53
41
|
},
|
|
54
42
|
{
|
|
55
43
|
"path": "src/sub/index.ts",
|
|
56
44
|
"baseName": "index.ts",
|
|
57
45
|
"exports": [
|
|
58
46
|
{
|
|
59
|
-
"
|
|
60
|
-
"hello"
|
|
61
|
-
],
|
|
62
|
-
"path": "./hello.ts",
|
|
63
|
-
"extName": ".ts"
|
|
47
|
+
"path": "./hello.ts"
|
|
64
48
|
},
|
|
65
49
|
{
|
|
66
|
-
"
|
|
67
|
-
"world"
|
|
68
|
-
],
|
|
69
|
-
"path": "./world.ts",
|
|
70
|
-
"extName": ".ts"
|
|
50
|
+
"path": "./world.ts"
|
|
71
51
|
}
|
|
72
52
|
],
|
|
73
53
|
"sources": [
|
|
@@ -84,10 +64,10 @@
|
|
|
84
64
|
"isIndexable": false
|
|
85
65
|
}
|
|
86
66
|
],
|
|
87
|
-
"meta": {},
|
|
88
67
|
"id": "c67967bd2363dd9637437671f6fe1ed146debdbf",
|
|
89
68
|
"name": "index",
|
|
90
|
-
"
|
|
91
|
-
"imports": []
|
|
69
|
+
"extname": ".ts",
|
|
70
|
+
"imports": [],
|
|
71
|
+
"meta": {}
|
|
92
72
|
}
|
|
93
73
|
]
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"sources": [],
|
|
19
19
|
"id": "6af477de6b602aafbb2e1ce0011b1f411a7ab3a5",
|
|
20
20
|
"name": "file2",
|
|
21
|
-
"
|
|
21
|
+
"extname": ".ts",
|
|
22
22
|
"imports": [],
|
|
23
23
|
"exports": [],
|
|
24
24
|
"meta": {}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"sources": [],
|
|
34
34
|
"id": "a9679944d24c174b2f2fd5b1f19c9861f1d35d0e",
|
|
35
35
|
"name": "file2",
|
|
36
|
-
"
|
|
36
|
+
"extname": ".ts",
|
|
37
37
|
"imports": [],
|
|
38
38
|
"exports": [],
|
|
39
39
|
"meta": {}
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"sources": [],
|
|
53
53
|
"id": "8beaaf5e1b1a6b89a11589c2e3dc5fd7f5eb5e8c",
|
|
54
54
|
"name": "pet",
|
|
55
|
-
"
|
|
55
|
+
"extname": ".ts",
|
|
56
56
|
"imports": [],
|
|
57
57
|
"exports": [],
|
|
58
58
|
"meta": {}
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"sources": [],
|
|
70
70
|
"id": "b077038b83c1ef4050649be406937a73c1f41ad3",
|
|
71
71
|
"name": "index",
|
|
72
|
-
"
|
|
72
|
+
"extname": ".ts",
|
|
73
73
|
"imports": [],
|
|
74
74
|
"exports": [],
|
|
75
75
|
"meta": {}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"sources": [],
|
|
91
91
|
"id": "a2d277093a81a74c56c0d094071195302d6bb484",
|
|
92
92
|
"name": "test",
|
|
93
|
-
"
|
|
93
|
+
"extname": ".ts",
|
|
94
94
|
"imports": [],
|
|
95
95
|
"exports": [],
|
|
96
96
|
"meta": {}
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"sources": [],
|
|
108
108
|
"id": "f8e2d98f76d6e33f21aa686d674544b5c7d6fa3e",
|
|
109
109
|
"name": "test",
|
|
110
|
-
"
|
|
110
|
+
"extname": ".ts",
|
|
111
111
|
"imports": [],
|
|
112
112
|
"exports": [],
|
|
113
113
|
"meta": {}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"sources": [],
|
|
6
6
|
"id": "f8e2d98f76d6e33f21aa686d674544b5c7d6fa3e",
|
|
7
7
|
"name": "test",
|
|
8
|
-
"
|
|
8
|
+
"extname": ".ts",
|
|
9
9
|
"imports": [],
|
|
10
10
|
"exports": [],
|
|
11
11
|
"meta": {}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"sources": [],
|
|
17
17
|
"id": "6af477de6b602aafbb2e1ce0011b1f411a7ab3a5",
|
|
18
18
|
"name": "file2",
|
|
19
|
-
"
|
|
19
|
+
"extname": ".ts",
|
|
20
20
|
"imports": [],
|
|
21
21
|
"exports": [],
|
|
22
22
|
"meta": {}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"sources": [],
|
|
28
28
|
"id": "a9679944d24c174b2f2fd5b1f19c9861f1d35d0e",
|
|
29
29
|
"name": "file2",
|
|
30
|
-
"
|
|
30
|
+
"extname": ".ts",
|
|
31
31
|
"imports": [],
|
|
32
32
|
"exports": [],
|
|
33
33
|
"meta": {}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"sources": [],
|
|
39
39
|
"id": "b077038b83c1ef4050649be406937a73c1f41ad3",
|
|
40
40
|
"name": "index",
|
|
41
|
-
"
|
|
41
|
+
"extname": ".ts",
|
|
42
42
|
"imports": [],
|
|
43
43
|
"exports": [],
|
|
44
44
|
"meta": {}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"sources": [],
|
|
50
50
|
"id": "a2d277093a81a74c56c0d094071195302d6bb484",
|
|
51
51
|
"name": "test",
|
|
52
|
-
"
|
|
52
|
+
"extname": ".ts",
|
|
53
53
|
"imports": [],
|
|
54
54
|
"exports": [],
|
|
55
55
|
"meta": {}
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"sources": [],
|
|
61
61
|
"id": "8beaaf5e1b1a6b89a11589c2e3dc5fd7f5eb5e8c",
|
|
62
62
|
"name": "pet",
|
|
63
|
-
"
|
|
63
|
+
"extname": ".ts",
|
|
64
64
|
"imports": [],
|
|
65
65
|
"exports": [],
|
|
66
66
|
"meta": {}
|
package/src/build.ts
CHANGED
|
@@ -108,17 +108,17 @@ export async function safeBuild(options: BuildOptions): Promise<BuildOutput> {
|
|
|
108
108
|
const meta = file.meta as any
|
|
109
109
|
return item.key === meta?.pluginKey
|
|
110
110
|
})
|
|
111
|
-
const
|
|
111
|
+
const pluginOptions = (plugin?.options as { output?: Output }) ?? {}
|
|
112
112
|
|
|
113
|
-
if (
|
|
113
|
+
if (pluginOptions.output?.barrelType === false) {
|
|
114
114
|
return undefined
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
if (FileManager.getMode(
|
|
117
|
+
if (FileManager.getMode(pluginOptions.output?.path) === 'single') {
|
|
118
118
|
return undefined
|
|
119
119
|
}
|
|
120
120
|
return {
|
|
121
|
-
name:
|
|
121
|
+
name: pluginOptions.output?.barrelType === 'all' ? undefined : [source.name],
|
|
122
122
|
path: getRelativePath(rootPath, file.path),
|
|
123
123
|
isTypeOnly: source.isTypeOnly,
|
|
124
124
|
} as KubbFile.Export
|
|
@@ -130,11 +130,10 @@ export async function safeBuild(options: BuildOptions): Promise<BuildOutput> {
|
|
|
130
130
|
meta: {},
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
if (options.config.output.
|
|
133
|
+
if (options.config.output.barrelType) {
|
|
134
134
|
await pluginManager.fileManager.add(rootFile)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
//TODO set extName here instead of the files, extName is private. All exports will have extName, it's up the the process to hide.override the name
|
|
138
137
|
files = await processFiles({
|
|
139
138
|
config: options.config,
|
|
140
139
|
dryRun: !options.config.output.write,
|