@adonisjs/assembler 8.0.0-next.7 → 8.0.0-next.8
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.
|
@@ -143,7 +143,13 @@ var IndexGeneratorSource = class {
|
|
|
143
143
|
if (this.#config.as === "barrelFile") {
|
|
144
144
|
this.#asBarrelFile(this.#vfs, buffer, this.#config.exportName);
|
|
145
145
|
} else {
|
|
146
|
-
this.#config.as(this.#vfs, buffer, this.#config
|
|
146
|
+
this.#config.as(this.#vfs, buffer, this.#config, {
|
|
147
|
+
toImportPath: this.#createBarrelFileImportGenerator(
|
|
148
|
+
this.#source,
|
|
149
|
+
this.#outputDirname,
|
|
150
|
+
this.#config
|
|
151
|
+
)
|
|
152
|
+
});
|
|
147
153
|
}
|
|
148
154
|
await mkdir(dirname(this.#output), { recursive: true });
|
|
149
155
|
await writeFile(this.#output, buffer.flush());
|
|
@@ -185,9 +191,9 @@ var IndexGeneratorSource = class {
|
|
|
185
191
|
Object.keys(input).forEach((key) => {
|
|
186
192
|
const value = input[key];
|
|
187
193
|
if (typeof value === "string") {
|
|
188
|
-
buffer.write(
|
|
194
|
+
buffer.write(`${key}: ${value},`);
|
|
189
195
|
} else {
|
|
190
|
-
buffer.write(
|
|
196
|
+
buffer.write(`${key}: {`).indent();
|
|
191
197
|
this.#treeToString(value, buffer);
|
|
192
198
|
buffer.dedent().write(`},`);
|
|
193
199
|
}
|
|
@@ -203,8 +209,13 @@ var IndexGeneratorSource = class {
|
|
|
203
209
|
#createBarrelFileKeyGenerator(config) {
|
|
204
210
|
return function(key) {
|
|
205
211
|
const paths = key.split("/");
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
let baseName = new StringBuilder(paths.pop());
|
|
213
|
+
if (config.computeBaseName) {
|
|
214
|
+
baseName = config.computeBaseName(baseName);
|
|
215
|
+
} else {
|
|
216
|
+
baseName = baseName.removeSuffix(config.removeSuffix ?? "").pascalCase();
|
|
217
|
+
}
|
|
218
|
+
return [...paths.map((p) => string.camelCase(p)), baseName.toString()].join("/");
|
|
208
219
|
};
|
|
209
220
|
}
|
|
210
221
|
/**
|
|
@@ -221,10 +232,10 @@ var IndexGeneratorSource = class {
|
|
|
221
232
|
return function(filePath) {
|
|
222
233
|
if (config.importAlias) {
|
|
223
234
|
debug_default('converting "%s" to import alias, source "%s"', filePath, source);
|
|
224
|
-
return
|
|
235
|
+
return removeExtension(filePath.replace(source, config.importAlias));
|
|
225
236
|
}
|
|
226
237
|
debug_default('converting "%s" to relative import, source "%s"', filePath, outputDirname);
|
|
227
|
-
return
|
|
238
|
+
return relative(outputDirname, filePath);
|
|
228
239
|
};
|
|
229
240
|
}
|
|
230
241
|
/**
|
|
@@ -246,7 +257,9 @@ var IndexGeneratorSource = class {
|
|
|
246
257
|
);
|
|
247
258
|
const tree = vfs.asTree({
|
|
248
259
|
transformKey: keyGenerator,
|
|
249
|
-
transformValue:
|
|
260
|
+
transformValue: (filePath) => {
|
|
261
|
+
return `() => import('${importGenerator(filePath)}')`;
|
|
262
|
+
}
|
|
250
263
|
});
|
|
251
264
|
buffer.write(`export const ${exportName} = {`).indent();
|
|
252
265
|
this.#treeToString(tree, buffer);
|
|
@@ -316,7 +329,7 @@ var IndexGenerator = class {
|
|
|
316
329
|
/**
|
|
317
330
|
* The application root directory path
|
|
318
331
|
*/
|
|
319
|
-
|
|
332
|
+
appRoot;
|
|
320
333
|
/**
|
|
321
334
|
* Collection of registered index generator sources
|
|
322
335
|
*/
|
|
@@ -329,7 +342,7 @@ var IndexGenerator = class {
|
|
|
329
342
|
* @param cliLogger - Logger instance for CLI output
|
|
330
343
|
*/
|
|
331
344
|
constructor(appRoot, cliLogger) {
|
|
332
|
-
this
|
|
345
|
+
this.appRoot = appRoot;
|
|
333
346
|
this.#cliLogger = cliLogger;
|
|
334
347
|
}
|
|
335
348
|
/**
|
|
@@ -340,7 +353,7 @@ var IndexGenerator = class {
|
|
|
340
353
|
* @returns This IndexGenerator instance for method chaining
|
|
341
354
|
*/
|
|
342
355
|
add(name, config) {
|
|
343
|
-
this.#sources[name] = new IndexGeneratorSource(name, this
|
|
356
|
+
this.#sources[name] = new IndexGeneratorSource(name, this.appRoot, this.#cliLogger, config);
|
|
344
357
|
return this;
|
|
345
358
|
}
|
|
346
359
|
/**
|
package/build/index.js
CHANGED
|
@@ -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.8",
|
|
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",
|