@adonisjs/assembler 8.0.0-next.6 → 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.
@@ -3,7 +3,7 @@ import {
3
3
  debug_default,
4
4
  removeExtension,
5
5
  throttle
6
- } from "./chunk-F4RAGKQN.js";
6
+ } from "./chunk-PORDZS62.js";
7
7
 
8
8
  // src/index_generator/source.ts
9
9
  import string from "@poppinss/utils/string";
@@ -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());
@@ -172,14 +178,6 @@ var IndexGeneratorSource = class {
172
178
  glob: this.#config.glob
173
179
  });
174
180
  }
175
- /**
176
- * Set the logger instance used for CLI output
177
- *
178
- * @param cliLogger - New logger instance to use
179
- */
180
- setLogger(cliLogger) {
181
- this.#cliLogger = cliLogger;
182
- }
183
181
  /**
184
182
  * Converts a recursive file tree to a string representation
185
183
  *
@@ -193,9 +191,9 @@ var IndexGeneratorSource = class {
193
191
  Object.keys(input).forEach((key) => {
194
192
  const value = input[key];
195
193
  if (typeof value === "string") {
196
- buffer.write(`'${key}': ${value},`);
194
+ buffer.write(`${key}: ${value},`);
197
195
  } else {
198
- buffer.write(`'${key}': {`).indent();
196
+ buffer.write(`${key}: {`).indent();
199
197
  this.#treeToString(value, buffer);
200
198
  buffer.dedent().write(`},`);
201
199
  }
@@ -211,8 +209,13 @@ var IndexGeneratorSource = class {
211
209
  #createBarrelFileKeyGenerator(config) {
212
210
  return function(key) {
213
211
  const paths = key.split("/");
214
- const baseName = new StringBuilder(paths.pop()).removeSuffix(config.removeSuffix ?? "").pascalCase().toString();
215
- return [...paths.map((p) => string.camelCase(p)), baseName].join("/");
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("/");
216
219
  };
217
220
  }
218
221
  /**
@@ -229,10 +232,10 @@ var IndexGeneratorSource = class {
229
232
  return function(filePath) {
230
233
  if (config.importAlias) {
231
234
  debug_default('converting "%s" to import alias, source "%s"', filePath, source);
232
- return `() => import('${removeExtension(filePath.replace(source, config.importAlias))}')`;
235
+ return removeExtension(filePath.replace(source, config.importAlias));
233
236
  }
234
237
  debug_default('converting "%s" to relative import, source "%s"', filePath, outputDirname);
235
- return `() => import('${relative(outputDirname, filePath)}')`;
238
+ return relative(outputDirname, filePath);
236
239
  };
237
240
  }
238
241
  /**
@@ -254,7 +257,9 @@ var IndexGeneratorSource = class {
254
257
  );
255
258
  const tree = vfs.asTree({
256
259
  transformKey: keyGenerator,
257
- transformValue: importGenerator
260
+ transformValue: (filePath) => {
261
+ return `() => import('${importGenerator(filePath)}')`;
262
+ }
258
263
  });
259
264
  buffer.write(`export const ${exportName} = {`).indent();
260
265
  this.#treeToString(tree, buffer);
@@ -324,7 +329,7 @@ var IndexGenerator = class {
324
329
  /**
325
330
  * The application root directory path
326
331
  */
327
- #appRoot;
332
+ appRoot;
328
333
  /**
329
334
  * Collection of registered index generator sources
330
335
  */
@@ -337,18 +342,7 @@ var IndexGenerator = class {
337
342
  * @param cliLogger - Logger instance for CLI output
338
343
  */
339
344
  constructor(appRoot, cliLogger) {
340
- this.#appRoot = appRoot;
341
- this.#cliLogger = cliLogger;
342
- }
343
- /**
344
- * Set the logger instance used for CLI output
345
- *
346
- * Updates the CLI logger instance for this index generator and all
347
- * registered sources to use the new logger for output.
348
- *
349
- * @param cliLogger - New logger instance to use
350
- */
351
- setLogger(cliLogger) {
345
+ this.appRoot = appRoot;
352
346
  this.#cliLogger = cliLogger;
353
347
  }
354
348
  /**
@@ -359,7 +353,7 @@ var IndexGenerator = class {
359
353
  * @returns This IndexGenerator instance for method chaining
360
354
  */
361
355
  add(name, config) {
362
- this.#sources[name] = new IndexGeneratorSource(name, this.#appRoot, this.#cliLogger, config);
356
+ this.#sources[name] = new IndexGeneratorSource(name, this.appRoot, this.#cliLogger, config);
363
357
  return this;
364
358
  }
365
359
  /**
@@ -152,7 +152,11 @@ async function loadHooks(rcFileHooks, names) {
152
152
  const hooks = new Hooks();
153
153
  for (const { group, hooks: collection } of groups) {
154
154
  for (const item of collection) {
155
- hooks.add(group, await importDefault(item));
155
+ if ("run" in item) {
156
+ hooks.add(group, item.run);
157
+ } else {
158
+ hooks.add(group, await importDefault(item));
159
+ }
156
160
  }
157
161
  }
158
162
  return hooks;
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { hooks } from './src/hooks.ts';
1
2
  export { Bundler } from './src/bundler.ts';
2
3
  export { DevServer } from './src/dev_server.ts';
3
4
  export { TestRunner } from './src/test_runner.ts';