@anu8151/adonisjs-blueprint 0.4.10 → 0.5.1

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.
@@ -190,9 +190,9 @@ statementsRegistry.register("service", async (value, { generators }) => {
190
190
  var ControllerGenerator = class extends BaseGenerator {
191
191
  async generate(name, definition, useInertia = false, isApi = false, models) {
192
192
  const nameParts = name.split(/[\/.]/);
193
- const baseName = nameParts.pop();
193
+ const baseName = nameParts.pop() || "";
194
194
  const entity = this.app.generators.createEntity(baseName);
195
- if (nameParts.length > 0) entity.path = nameParts.map((p) => string.snakeCase(p)).join("/");
195
+ if (nameParts.length > 0) entity.path = nameParts.map((p) => string.snakeCase(p || "")).join("/");
196
196
  const eventGenerator = new EventGenerator(this.app, this.logger, this.manifest);
197
197
  const mailGenerator = new MailGenerator(this.app, this.logger, this.manifest);
198
198
  const jobGenerator = new JobGenerator(this.app, this.logger, this.manifest);
@@ -210,8 +210,8 @@ var ControllerGenerator = class extends BaseGenerator {
210
210
  services: /* @__PURE__ */ new Map()
211
211
  };
212
212
  const middleware = definition.middleware || [];
213
- const pluralName = string.plural(string.camelCase(entity.name));
214
- const singularName = string.camelCase(entity.name);
213
+ const pluralName = string.plural(string.camelCase(entity.name || ""));
214
+ const singularName = string.camelCase(entity.name || "");
215
215
  let normalizedDefinition = definition;
216
216
  if (definition.resource) normalizedDefinition = isApi ? {
217
217
  index: {
@@ -309,19 +309,21 @@ var ControllerGenerator = class extends BaseGenerator {
309
309
  });
310
310
  logicLines.push(...result.logicLines);
311
311
  if (result.imports) {
312
- if (result.imports.models) result.imports.models.forEach((i) => imports.models.add(i));
313
- if (result.imports.validators) result.imports.validators.forEach((i) => imports.validators.add(i));
314
- if (result.imports.events) result.imports.events.forEach((i) => imports.events.add(i));
315
- if (result.imports.policies) result.imports.policies.forEach((i) => imports.policies.add(i));
316
- if (result.imports.mails) result.imports.mails.forEach((i) => imports.mails.add(i));
317
- if (result.imports.jobs) result.imports.jobs.forEach((i) => imports.jobs.add(i));
318
- if (result.imports.notifications) result.imports.notifications.forEach((i) => imports.notifications.add(i));
312
+ if (result.imports.models) result.imports.models.forEach((i) => i && imports.models.add(i));
313
+ if (result.imports.validators) result.imports.validators.forEach((i) => i && imports.validators.add(i));
314
+ if (result.imports.events) result.imports.events.forEach((i) => i && imports.events.add(i));
315
+ if (result.imports.policies) result.imports.policies.forEach((i) => i && imports.policies.add(i));
316
+ if (result.imports.mails) result.imports.mails.forEach((i) => i && imports.mails.add(i));
317
+ if (result.imports.jobs) result.imports.jobs.forEach((i) => i && imports.jobs.add(i));
318
+ if (result.imports.notifications) result.imports.notifications.forEach((i) => i && imports.notifications.add(i));
319
319
  if (result.imports.services) result.imports.services.forEach((serviceName) => {
320
- const servicePath = string.snakeCase(serviceName.replace("Service", "")) + "_service";
321
- imports.services.set(serviceName, servicePath);
320
+ if (serviceName) {
321
+ const servicePath = string.snakeCase(serviceName.replace("Service", "")) + "_service";
322
+ imports.services.set(serviceName, servicePath);
323
+ }
322
324
  });
323
325
  }
324
- if (result.context) result.context.forEach((c) => contextItems.add(c));
326
+ if (result.context) result.context.forEach((c) => c && contextItems.add(c));
325
327
  }
326
328
  }
327
329
  }
@@ -333,19 +335,19 @@ var ControllerGenerator = class extends BaseGenerator {
333
335
  }
334
336
  const importsLines = [];
335
337
  imports.models.forEach((model) => {
336
- importsLines.push(`import ${model} from '#models/${string.snakeCase(model)}'`);
338
+ if (model) importsLines.push(`import ${model} from '#models/${string.snakeCase(model)}'`);
337
339
  });
338
340
  imports.validators.forEach((v) => {
339
- importsLines.push(`import { ${v} } from '#validators/${entity.name.toLowerCase()}'`);
341
+ if (v) importsLines.push(`import { ${v} } from '#validators/${(entity.name || "").toLowerCase()}'`);
340
342
  });
341
343
  imports.events.forEach((e) => {
342
- importsLines.push(`import ${e} from '#events/${e.toLowerCase()}'`);
344
+ if (e) importsLines.push(`import ${e} from '#events/${e.toLowerCase()}'`);
343
345
  });
344
346
  imports.policies.forEach((p) => {
345
- importsLines.push(`import ${p} from '#policies/${entity.name.toLowerCase()}_policy'`);
347
+ if (p) importsLines.push(`import ${p} from '#policies/${(entity.name || "").toLowerCase()}_policy'`);
346
348
  });
347
349
  imports.services.forEach((path, serviceName) => {
348
- importsLines.push(`import ${serviceName} from '#services/${path}'`);
350
+ if (serviceName && path) importsLines.push(`import ${serviceName} from '#services/${path}'`);
349
351
  });
350
352
  const middlewareLines = middleware.length > 0 ? `static middleware = [\n ${middleware.map((m) => `middleware.${m}()`).join(",\n ")}\n ]` : "";
351
353
  const actionLines = actions.map((action) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anu8151/adonisjs-blueprint",
3
3
  "description": "Blueprint for AdonisJS 7",
4
- "version": "0.4.10",
4
+ "version": "0.5.1",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },