@adonisjs/assembler 8.0.0-next.7 → 8.0.0-next.9
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/build/{chunk-25Q3N5JR.js → chunk-7XU453QB.js} +39 -13
- package/build/index.d.ts +2 -0
- package/build/index.js +5 -1
- package/build/src/file_buffer.d.ts +3 -2
- package/build/src/index_generator/main.d.ts +4 -0
- package/build/src/index_generator/main.js +1 -1
- package/build/src/types/common.d.ts +5 -1
- package/package.json +6 -4
|
@@ -50,8 +50,13 @@ var FileBuffer = class _FileBuffer {
|
|
|
50
50
|
* @returns This FileBuffer instance for method chaining
|
|
51
51
|
*/
|
|
52
52
|
writeLine(text) {
|
|
53
|
-
|
|
53
|
+
if (typeof text === "string") {
|
|
54
|
+
this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}
|
|
54
55
|
`);
|
|
56
|
+
} else {
|
|
57
|
+
this.#buffer.push(text);
|
|
58
|
+
this.#buffer.push("");
|
|
59
|
+
}
|
|
55
60
|
return this;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
@@ -61,7 +66,11 @@ var FileBuffer = class _FileBuffer {
|
|
|
61
66
|
* @returns This FileBuffer instance for method chaining
|
|
62
67
|
*/
|
|
63
68
|
write(text) {
|
|
64
|
-
|
|
69
|
+
if (typeof text === "string") {
|
|
70
|
+
this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}`);
|
|
71
|
+
} else {
|
|
72
|
+
this.#buffer.push(text);
|
|
73
|
+
}
|
|
65
74
|
return this;
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
@@ -85,6 +94,9 @@ var FileBuffer = class _FileBuffer {
|
|
|
85
94
|
}
|
|
86
95
|
return this;
|
|
87
96
|
}
|
|
97
|
+
toString() {
|
|
98
|
+
return this.flush();
|
|
99
|
+
}
|
|
88
100
|
/**
|
|
89
101
|
* Return template as a string, joining all buffer lines
|
|
90
102
|
*
|
|
@@ -143,7 +155,13 @@ var IndexGeneratorSource = class {
|
|
|
143
155
|
if (this.#config.as === "barrelFile") {
|
|
144
156
|
this.#asBarrelFile(this.#vfs, buffer, this.#config.exportName);
|
|
145
157
|
} else {
|
|
146
|
-
this.#config.as(this.#vfs, buffer, this.#config
|
|
158
|
+
this.#config.as(this.#vfs, buffer, this.#config, {
|
|
159
|
+
toImportPath: this.#createBarrelFileImportGenerator(
|
|
160
|
+
this.#source,
|
|
161
|
+
this.#outputDirname,
|
|
162
|
+
this.#config
|
|
163
|
+
)
|
|
164
|
+
});
|
|
147
165
|
}
|
|
148
166
|
await mkdir(dirname(this.#output), { recursive: true });
|
|
149
167
|
await writeFile(this.#output, buffer.flush());
|
|
@@ -185,9 +203,9 @@ var IndexGeneratorSource = class {
|
|
|
185
203
|
Object.keys(input).forEach((key) => {
|
|
186
204
|
const value = input[key];
|
|
187
205
|
if (typeof value === "string") {
|
|
188
|
-
buffer.write(
|
|
206
|
+
buffer.write(`${key}: ${value},`);
|
|
189
207
|
} else {
|
|
190
|
-
buffer.write(
|
|
208
|
+
buffer.write(`${key}: {`).indent();
|
|
191
209
|
this.#treeToString(value, buffer);
|
|
192
210
|
buffer.dedent().write(`},`);
|
|
193
211
|
}
|
|
@@ -203,8 +221,13 @@ var IndexGeneratorSource = class {
|
|
|
203
221
|
#createBarrelFileKeyGenerator(config) {
|
|
204
222
|
return function(key) {
|
|
205
223
|
const paths = key.split("/");
|
|
206
|
-
|
|
207
|
-
|
|
224
|
+
let baseName = new StringBuilder(paths.pop());
|
|
225
|
+
if (config.computeBaseName) {
|
|
226
|
+
baseName = config.computeBaseName(baseName);
|
|
227
|
+
} else {
|
|
228
|
+
baseName = baseName.removeSuffix(config.removeSuffix ?? "").pascalCase();
|
|
229
|
+
}
|
|
230
|
+
return [...paths.map((p) => string.camelCase(p)), baseName.toString()].join("/");
|
|
208
231
|
};
|
|
209
232
|
}
|
|
210
233
|
/**
|
|
@@ -221,10 +244,10 @@ var IndexGeneratorSource = class {
|
|
|
221
244
|
return function(filePath) {
|
|
222
245
|
if (config.importAlias) {
|
|
223
246
|
debug_default('converting "%s" to import alias, source "%s"', filePath, source);
|
|
224
|
-
return
|
|
247
|
+
return removeExtension(filePath.replace(source, config.importAlias));
|
|
225
248
|
}
|
|
226
249
|
debug_default('converting "%s" to relative import, source "%s"', filePath, outputDirname);
|
|
227
|
-
return
|
|
250
|
+
return relative(outputDirname, filePath);
|
|
228
251
|
};
|
|
229
252
|
}
|
|
230
253
|
/**
|
|
@@ -246,7 +269,9 @@ var IndexGeneratorSource = class {
|
|
|
246
269
|
);
|
|
247
270
|
const tree = vfs.asTree({
|
|
248
271
|
transformKey: keyGenerator,
|
|
249
|
-
transformValue:
|
|
272
|
+
transformValue: (filePath) => {
|
|
273
|
+
return `() => import('${importGenerator(filePath)}')`;
|
|
274
|
+
}
|
|
250
275
|
});
|
|
251
276
|
buffer.write(`export const ${exportName} = {`).indent();
|
|
252
277
|
this.#treeToString(tree, buffer);
|
|
@@ -316,7 +341,7 @@ var IndexGenerator = class {
|
|
|
316
341
|
/**
|
|
317
342
|
* The application root directory path
|
|
318
343
|
*/
|
|
319
|
-
|
|
344
|
+
appRoot;
|
|
320
345
|
/**
|
|
321
346
|
* Collection of registered index generator sources
|
|
322
347
|
*/
|
|
@@ -329,7 +354,7 @@ var IndexGenerator = class {
|
|
|
329
354
|
* @param cliLogger - Logger instance for CLI output
|
|
330
355
|
*/
|
|
331
356
|
constructor(appRoot, cliLogger) {
|
|
332
|
-
this
|
|
357
|
+
this.appRoot = appRoot;
|
|
333
358
|
this.#cliLogger = cliLogger;
|
|
334
359
|
}
|
|
335
360
|
/**
|
|
@@ -340,7 +365,7 @@ var IndexGenerator = class {
|
|
|
340
365
|
* @returns This IndexGenerator instance for method chaining
|
|
341
366
|
*/
|
|
342
367
|
add(name, config) {
|
|
343
|
-
this.#sources[name] = new IndexGeneratorSource(name, this
|
|
368
|
+
this.#sources[name] = new IndexGeneratorSource(name, this.appRoot, this.#cliLogger, config);
|
|
344
369
|
return this;
|
|
345
370
|
}
|
|
346
371
|
/**
|
|
@@ -388,5 +413,6 @@ var IndexGenerator = class {
|
|
|
388
413
|
};
|
|
389
414
|
|
|
390
415
|
export {
|
|
416
|
+
FileBuffer,
|
|
391
417
|
IndexGenerator
|
|
392
418
|
};
|
package/build/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export { hooks } from './src/hooks.ts';
|
|
|
2
2
|
export { Bundler } from './src/bundler.ts';
|
|
3
3
|
export { DevServer } from './src/dev_server.ts';
|
|
4
4
|
export { TestRunner } from './src/test_runner.ts';
|
|
5
|
+
export { FileBuffer } from './src/file_buffer.ts';
|
|
6
|
+
export { VirtualFileSystem } from './src/virtual_file_system.ts';
|
|
5
7
|
export { SUPPORTED_PACKAGE_MANAGERS } from './src/bundler.ts';
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FileBuffer,
|
|
2
3
|
IndexGenerator
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7XU453QB.js";
|
|
4
5
|
import {
|
|
6
|
+
VirtualFileSystem,
|
|
5
7
|
copyFiles,
|
|
6
8
|
debug_default,
|
|
7
9
|
getPort,
|
|
@@ -1735,7 +1737,9 @@ var TestRunner = class {
|
|
|
1735
1737
|
export {
|
|
1736
1738
|
Bundler,
|
|
1737
1739
|
DevServer,
|
|
1740
|
+
FileBuffer,
|
|
1738
1741
|
SUPPORTED_PACKAGE_MANAGERS,
|
|
1739
1742
|
TestRunner,
|
|
1743
|
+
VirtualFileSystem,
|
|
1740
1744
|
hooks
|
|
1741
1745
|
};
|
|
@@ -35,14 +35,14 @@ export declare class FileBuffer {
|
|
|
35
35
|
* @param text - The text to write as a new line
|
|
36
36
|
* @returns This FileBuffer instance for method chaining
|
|
37
37
|
*/
|
|
38
|
-
writeLine(text: string): this;
|
|
38
|
+
writeLine(text: string | FileBuffer): this;
|
|
39
39
|
/**
|
|
40
40
|
* Write text to the output without adding a new line
|
|
41
41
|
*
|
|
42
42
|
* @param text - The text to write without a newline
|
|
43
43
|
* @returns This FileBuffer instance for method chaining
|
|
44
44
|
*/
|
|
45
|
-
write(text: string): this;
|
|
45
|
+
write(text: string | FileBuffer): this;
|
|
46
46
|
/**
|
|
47
47
|
* Increase indentation by 2 spaces
|
|
48
48
|
*
|
|
@@ -55,6 +55,7 @@ export declare class FileBuffer {
|
|
|
55
55
|
* @returns This FileBuffer instance for method chaining
|
|
56
56
|
*/
|
|
57
57
|
dedent(): this;
|
|
58
|
+
toString(): string;
|
|
58
59
|
/**
|
|
59
60
|
* Return template as a string, joining all buffer lines
|
|
60
61
|
*
|
|
@@ -19,6 +19,10 @@ import { type IndexGeneratorSourceConfig } from '../types/common.ts';
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class IndexGenerator {
|
|
21
21
|
#private;
|
|
22
|
+
/**
|
|
23
|
+
* The application root directory path
|
|
24
|
+
*/
|
|
25
|
+
appRoot: string;
|
|
22
26
|
/**
|
|
23
27
|
* Create a new IndexGenerator instance
|
|
24
28
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@poppinss/cliui';
|
|
2
2
|
import { type Prettify } from '@poppinss/utils/types';
|
|
3
|
+
import type StringBuilder from '@poppinss/utils/string_builder';
|
|
3
4
|
import { type AllHooks } from './hooks.ts';
|
|
4
5
|
import { type FileBuffer } from '../file_buffer.ts';
|
|
5
6
|
import { type VirtualFileSystem } from '../virtual_file_system.ts';
|
|
@@ -22,8 +23,11 @@ export type IndexGeneratorSourceConfig = ({
|
|
|
22
23
|
exportName: string;
|
|
23
24
|
as: 'barrelFile';
|
|
24
25
|
} | {
|
|
25
|
-
as: (vfs: VirtualFileSystem, buffer: FileBuffer, config: IndexGeneratorSourceConfig
|
|
26
|
+
as: (vfs: VirtualFileSystem, buffer: FileBuffer, config: IndexGeneratorSourceConfig, helpers: {
|
|
27
|
+
toImportPath(filePath: string): string;
|
|
28
|
+
}) => void;
|
|
26
29
|
}) & {
|
|
30
|
+
computeBaseName?: (baseName: StringBuilder) => StringBuilder;
|
|
27
31
|
source: string;
|
|
28
32
|
output: string;
|
|
29
33
|
glob?: string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
-
"version": "8.0.0-next.
|
|
4
|
+
"version": "8.0.0-next.9",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"precompile": "npm run lint && npm run clean",
|
|
34
34
|
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
|
|
35
35
|
"build": "npm run compile",
|
|
36
|
+
"docs": "typedoc",
|
|
36
37
|
"release": "release-it",
|
|
37
38
|
"version": "npm run build",
|
|
38
39
|
"prepublishOnly": "npm run build",
|
|
@@ -48,18 +49,19 @@
|
|
|
48
49
|
"@japa/snapshot": "^2.0.9",
|
|
49
50
|
"@poppinss/ts-exec": "^1.4.1",
|
|
50
51
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
51
|
-
"@types/node": "^24.3.
|
|
52
|
+
"@types/node": "^24.3.1",
|
|
52
53
|
"@types/picomatch": "^4.0.2",
|
|
53
54
|
"@types/pretty-hrtime": "^1.0.3",
|
|
54
55
|
"c8": "^10.1.3",
|
|
55
56
|
"cross-env": "^10.0.0",
|
|
56
57
|
"del-cli": "^6.0.0",
|
|
57
|
-
"eslint": "^9.
|
|
58
|
+
"eslint": "^9.35.0",
|
|
58
59
|
"hot-hook": "^0.4.1-next.0",
|
|
59
60
|
"p-event": "^6.0.1",
|
|
60
61
|
"prettier": "^3.6.2",
|
|
61
62
|
"release-it": "^19.0.4",
|
|
62
63
|
"tsup": "^8.5.0",
|
|
64
|
+
"typedoc": "^0.28.12",
|
|
63
65
|
"typescript": "^5.9.2"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"@poppinss/hooks": "^7.2.6",
|
|
71
73
|
"@poppinss/utils": "^7.0.0-next.3",
|
|
72
74
|
"chokidar": "^4.0.3",
|
|
73
|
-
"dedent": "^1.
|
|
75
|
+
"dedent": "^1.7.0",
|
|
74
76
|
"execa": "^9.6.0",
|
|
75
77
|
"fast-glob": "^3.3.3",
|
|
76
78
|
"fdir": "^6.5.0",
|