@forinda/kickjs-cli 3.0.8 → 3.1.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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v3.0.8
2
+ * @forinda/kickjs-cli v3.1.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1824,11 +1824,14 @@ export class HelloModule implements AppModule {
1824
1824
  `;
1825
1825
  }
1826
1826
  /** Generate kick.config.ts CLI configuration */
1827
- function generateKickConfig(template, defaultRepo = "inmemory") {
1827
+ function generateKickConfig(template, defaultRepo = "inmemory", packageManager = "pnpm") {
1828
1828
  return `import { defineConfig } from '@forinda/kickjs-cli'
1829
1829
 
1830
1830
  export default defineConfig({
1831
1831
  pattern: '${template}',
1832
+ // Pinned so \`kick add\` and other dep-installing commands always use the
1833
+ // project's intended package manager, regardless of which lockfile exists.
1834
+ packageManager: '${packageManager}',
1832
1835
  modules: {
1833
1836
  dir: 'src/modules',
1834
1837
  repo: ${[
@@ -1876,7 +1879,7 @@ export default defineConfig({
1876
1879
  //#region src/generators/patterns/minimal.ts
1877
1880
  async function generateMinimalFiles(ctx) {
1878
1881
  const { pascal, kebab, plural, write } = ctx;
1879
- await write("index.ts", generateMinimalModuleIndex({
1882
+ await write(`${kebab}.module.ts`, generateMinimalModuleIndex({
1880
1883
  pascal,
1881
1884
  kebab,
1882
1885
  plural
@@ -1899,7 +1902,7 @@ export class ${pascal}Controller {
1899
1902
  //#region src/generators/patterns/rest.ts
1900
1903
  async function generateRestFiles(ctx) {
1901
1904
  const { pascal, kebab, plural, pluralPascal, repo, noTests, prismaClientPath, write } = ctx;
1902
- await write("index.ts", generateRestModuleIndex({
1905
+ await write(`${kebab}.module.ts`, generateRestModuleIndex({
1903
1906
  pascal,
1904
1907
  kebab,
1905
1908
  plural,
@@ -1995,7 +1998,7 @@ async function generateRestFiles(ctx) {
1995
1998
  //#region src/generators/patterns/cqrs.ts
1996
1999
  async function generateCqrsFiles(ctx) {
1997
2000
  const { pascal, kebab, plural, pluralPascal, repo, noTests, prismaClientPath, write } = ctx;
1998
- await write("index.ts", generateCqrsModuleIndex({
2001
+ await write(`${kebab}.module.ts`, generateCqrsModuleIndex({
1999
2002
  pascal,
2000
2003
  kebab,
2001
2004
  plural,
@@ -2104,7 +2107,7 @@ async function generateCqrsFiles(ctx) {
2104
2107
  //#region src/generators/patterns/ddd.ts
2105
2108
  async function generateDddFiles(ctx) {
2106
2109
  const { pascal, kebab, plural, pluralPascal, repo, noEntity, noTests, prismaClientPath, write } = ctx;
2107
- await write("index.ts", generateModuleIndex({
2110
+ await write(`${kebab}.module.ts`, generateModuleIndex({
2108
2111
  pascal,
2109
2112
  kebab,
2110
2113
  plural,
@@ -2273,22 +2276,24 @@ async function generateModule(options) {
2273
2276
  await generateDddFiles(ctx);
2274
2277
  break;
2275
2278
  }
2276
- if (!dryRun) await autoRegisterModule(modulesDir, pascal, plural);
2279
+ if (!dryRun) await autoRegisterModule(modulesDir, pascal, plural, kebab);
2277
2280
  return files;
2278
2281
  }
2279
2282
  /** Add the new module to src/modules/index.ts */
2280
- async function autoRegisterModule(modulesDir, pascal, plural) {
2283
+ async function autoRegisterModule(modulesDir, pascal, plural, kebab) {
2281
2284
  const indexPath = join(modulesDir, "index.ts");
2282
- if (!await fileExists(indexPath)) {
2285
+ const exists = await fileExists(indexPath);
2286
+ const importPath = `./${plural}/${kebab}.module`;
2287
+ if (!exists) {
2283
2288
  await writeFileSafe(indexPath, `import type { AppModuleClass } from '@forinda/kickjs'
2284
- import { ${pascal}Module } from './${plural}'
2289
+ import { ${pascal}Module } from '${importPath}'
2285
2290
 
2286
2291
  export const modules: AppModuleClass[] = [${pascal}Module]
2287
2292
  `);
2288
2293
  return;
2289
2294
  }
2290
2295
  let content = await readFile(indexPath, "utf-8");
2291
- const importLine = `import { ${pascal}Module } from './${plural}'`;
2296
+ const importLine = `import { ${pascal}Module } from '${importPath}'`;
2292
2297
  if (!content.includes(`${pascal}Module`)) {
2293
2298
  const lastImportIdx = content.lastIndexOf("import ");
2294
2299
  if (lastImportIdx !== -1) {
@@ -3749,7 +3754,7 @@ async function initProject(options) {
3749
3754
  await writeFileSafe(join(dir, "src/modules/hello/hello.controller.ts"), generateHelloController());
3750
3755
  await writeFileSafe(join(dir, "src/modules/hello/hello.module.ts"), generateHelloModule());
3751
3756
  if (template === "graphql") await writeFileSafe(join(dir, "src/resolvers/.gitkeep"), "");
3752
- await writeFileSafe(join(dir, "kick.config.ts"), generateKickConfig(template, defaultRepo));
3757
+ await writeFileSafe(join(dir, "kick.config.ts"), generateKickConfig(template, defaultRepo, packageManager));
3753
3758
  await writeFileSafe(join(dir, "vitest.config.ts"), generateVitestConfig());
3754
3759
  await writeFileSafe(join(dir, "README.md"), generateReadme(name, template, packageManager));
3755
3760
  await writeFileSafe(join(dir, "CLAUDE.md"), generateClaude(name, template, packageManager));
@@ -3767,7 +3772,7 @@ async function initProject(options) {
3767
3772
  }
3768
3773
  }
3769
3774
  try {
3770
- const { runTypegen } = await import("./typegen-CbE_hoAJ.mjs");
3775
+ const { runTypegen } = await import("./typegen-uoVqx5ib.mjs");
3771
3776
  await runTypegen({
3772
3777
  cwd: dir,
3773
3778
  allowDuplicates: true,