nextjs-cms-kit 0.5.29 → 0.5.31

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.
Files changed (37) hide show
  1. package/dist/commands/db-config.d.ts +1 -2
  2. package/dist/commands/db-config.d.ts.map +1 -1
  3. package/dist/commands/db-config.js +7 -9
  4. package/dist/commands/fix-master-admin.d.ts +1 -2
  5. package/dist/commands/fix-master-admin.d.ts.map +1 -1
  6. package/dist/commands/fix-master-admin.js +6 -7
  7. package/dist/commands/set-master-admin.d.ts +1 -2
  8. package/dist/commands/set-master-admin.d.ts.map +1 -1
  9. package/dist/commands/set-master-admin.js +11 -13
  10. package/dist/commands/setup.d.ts +1 -2
  11. package/dist/commands/setup.d.ts.map +1 -1
  12. package/dist/commands/setup.js +16 -15
  13. package/dist/commands/update-sections.d.ts +1 -2
  14. package/dist/commands/update-sections.d.ts.map +1 -1
  15. package/dist/commands/update-sections.js +14 -15
  16. package/dist/index.d.ts +1 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -37
  19. package/dist/lib/actions.d.ts.map +1 -1
  20. package/dist/lib/actions.js +12 -5
  21. package/dist/lib/add-table-keys.d.ts.map +1 -1
  22. package/dist/lib/add-table-keys.js +2 -1
  23. package/dist/lib/db-config-setup.d.ts.map +1 -1
  24. package/dist/lib/db-config-setup.js +1 -1
  25. package/dist/lib/fix-master-admin.d.ts.map +1 -1
  26. package/dist/lib/fix-master-admin.js +1 -1
  27. package/dist/lib/program.d.ts +4 -0
  28. package/dist/lib/program.d.ts.map +1 -0
  29. package/dist/lib/program.js +61 -0
  30. package/dist/lib/schema-generator.d.ts +2 -2
  31. package/dist/lib/schema-generator.d.ts.map +1 -1
  32. package/dist/lib/schema-generator.js +2 -2
  33. package/dist/lib/set-master-admin.d.ts.map +1 -1
  34. package/dist/lib/set-master-admin.js +3 -1
  35. package/dist/lib/update-sections.d.ts.map +1 -1
  36. package/dist/lib/update-sections.js +1 -2
  37. package/package.json +7 -2
@@ -1,3 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare const dbConfigCommand: Command;
1
+ export declare function runDbConfig(dev: boolean): Promise<void>;
3
2
  //# sourceMappingURL=db-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-config.d.ts","sourceRoot":"","sources":["../../src/commands/db-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,eAAO,MAAM,eAAe,SAYtB,CAAA"}
1
+ {"version":3,"file":"db-config.d.ts","sourceRoot":"","sources":["../../src/commands/db-config.ts"],"names":[],"mappings":"AAEA,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,iBAc7C"}
@@ -1,20 +1,18 @@
1
- import { Command } from 'commander';
2
- // import { intro, outro } from '@clack/prompts'
3
- import { dbConfigSetup } from '../lib/db-config-setup.js';
4
1
  import chalk from 'chalk';
5
- import { dbConnectionClose } from 'nextjs-cms/db/client';
6
- export const dbConfigCommand = new Command('db-config')
7
- .description('Initialize nextjs-cms database configuration')
8
- .action(async () => {
2
+ export async function runDbConfig(dev) {
9
3
  try {
10
- await dbConfigSetup({ dev: dbConfigCommand.parent?.opts().dev ? true : false });
4
+ // Lazy import to avoid eager database connection
5
+ const { dbConfigSetup } = await import('../lib/db-config-setup.js');
6
+ await dbConfigSetup({ dev });
11
7
  }
12
8
  catch (error) {
13
9
  console.error(chalk.red('Error during initialization:'), error);
14
10
  process.exit(1);
15
11
  }
16
12
  finally {
13
+ // Lazy import for cleanup
14
+ const { dbConnectionClose } = await import('nextjs-cms/db/client');
17
15
  await dbConnectionClose();
18
16
  process.exit(0);
19
17
  }
20
- });
18
+ }
@@ -1,3 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare const fixMasterAdminCommand: Command;
1
+ export declare function runFixMasterAdmin(): Promise<void>;
3
2
  //# sourceMappingURL=fix-master-admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fix-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/fix-master-admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,qBAAqB,SAY5B,CAAA"}
1
+ {"version":3,"file":"fix-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/fix-master-admin.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,kBActC"}
@@ -1,11 +1,8 @@
1
- import { Command } from 'commander';
2
- import { fixMasterAdmin } from '../lib/fix-master-admin.js';
3
- import { dbConnectionClose } from 'nextjs-cms/db/client';
4
1
  import chalk from 'chalk';
5
- export const fixMasterAdminCommand = new Command('fix-master-admin')
6
- .description('Fix master admin privileges for all sections')
7
- .action(async () => {
2
+ export async function runFixMasterAdmin() {
8
3
  try {
4
+ // Lazy import to avoid eager database connection
5
+ const { fixMasterAdmin } = await import('../lib/fix-master-admin.js');
9
6
  await fixMasterAdmin();
10
7
  }
11
8
  catch (error) {
@@ -13,7 +10,9 @@ export const fixMasterAdminCommand = new Command('fix-master-admin')
13
10
  process.exit(1);
14
11
  }
15
12
  finally {
13
+ // Lazy import for cleanup
14
+ const { dbConnectionClose } = await import('nextjs-cms/db/client');
16
15
  await dbConnectionClose();
17
16
  process.exit(0);
18
17
  }
19
- });
18
+ }
@@ -1,3 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare const setMasterAdminCommand: Command;
1
+ export declare function runSetMasterAdmin(dev: boolean): Promise<void>;
3
2
  //# sourceMappingURL=set-master-admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"set-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/set-master-admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,qBAAqB,SA0B5B,CAAA"}
1
+ {"version":3,"file":"set-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/set-master-admin.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,iBAuBnD"}
@@ -1,21 +1,17 @@
1
- import { Command } from 'commander';
2
- import { setMasterAdmin } from '../lib/set-master-admin.js';
3
- import { dbConnectionClose } from 'nextjs-cms/db/client';
4
1
  import chalk from 'chalk';
5
- export const setMasterAdminCommand = new Command('set-master-admin')
6
- .description('Set or update master admin password')
7
- .action(async () => {
2
+ export async function runSetMasterAdmin(dev) {
8
3
  try {
9
- console.log(chalk.hex('#E8DCFF').bold(setMasterAdminCommand.parent?.name()));
10
- console.log(setMasterAdminCommand.parent?.version());
11
- console.log(setMasterAdminCommand.parent?.description());
4
+ console.log(chalk.hex('#E8DCFF').bold('nextjs-cms-kit'));
5
+ console.log(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'));
12
6
  console.log(chalk.gray('--------------------------'));
13
- console.log(chalk.hex('#E8DCFF').bold(setMasterAdminCommand.name()));
14
- console.log(setMasterAdminCommand.description());
7
+ console.log(chalk.hex('#E8DCFF').bold('set-master-admin'));
8
+ console.log('Set or update master admin password');
15
9
  console.log(chalk.gray('--------------------------'));
16
- console.log(chalk.yellow(`Running in ${setMasterAdminCommand.parent?.opts().dev ? 'development' : 'production'} mode`));
10
+ console.log(chalk.yellow(`Running in ${dev ? 'development' : 'production'} mode`));
17
11
  console.log(chalk.gray('--------------------------'));
18
12
  console.log(chalk.gray(`.......................................................`));
13
+ // Lazy import to avoid eager database connection
14
+ const { setMasterAdmin } = await import('../lib/set-master-admin.js');
19
15
  await setMasterAdmin();
20
16
  }
21
17
  catch (error) {
@@ -23,7 +19,9 @@ export const setMasterAdminCommand = new Command('set-master-admin')
23
19
  process.exit(1);
24
20
  }
25
21
  finally {
22
+ // Lazy import for cleanup
23
+ const { dbConnectionClose } = await import('nextjs-cms/db/client');
26
24
  await dbConnectionClose();
27
25
  process.exit(0);
28
26
  }
29
- });
27
+ }
@@ -1,3 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare const setupCommand: Command;
1
+ export declare function runSetup(dev: boolean): Promise<void>;
3
2
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,eAAO,MAAM,YAAY,SAyDvB,CAAA"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAIA,wBAAsB,QAAQ,CAAC,GAAG,EAAE,OAAO,iBA8D1C"}
@@ -1,31 +1,28 @@
1
- import { Command } from 'commander';
2
1
  import { note, intro, outro, spinner } from '@clack/prompts';
3
2
  import { spawn } from 'child_process';
4
- import { setMasterAdmin } from '../lib/set-master-admin.js';
5
- import { dbConnectionClose } from 'nextjs-cms/db/client';
6
3
  import chalk from 'chalk';
7
- import { dbConfigSetup } from '../lib/db-config-setup.js';
8
- export const setupCommand = new Command('setup').description('Complete nextjs-cms setup').action(async () => {
4
+ export async function runSetup(dev) {
9
5
  const s = spinner();
10
- console.log(chalk.hex('#E8DCFF').bold(setupCommand.parent?.name()));
11
- console.log(setupCommand.parent?.version());
12
- console.log(setupCommand.parent?.description());
6
+ console.log(chalk.hex('#E8DCFF').bold('nextjs-cms-kit'));
7
+ console.log(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'));
13
8
  console.log(chalk.gray('--------------------------'));
14
- console.log(chalk.hex('#E8DCFF').bold(setupCommand.name()));
15
- console.log(setupCommand.description());
9
+ console.log(chalk.hex('#E8DCFF').bold('setup'));
10
+ console.log('Complete nextjs-cms setup');
16
11
  console.log(chalk.gray('--------------------------'));
17
- console.log(chalk.yellow(`Running in ${setupCommand.parent?.opts().dev ? 'development' : 'production'} mode`));
12
+ console.log(chalk.yellow(`Running in ${dev ? 'development' : 'production'} mode`));
18
13
  console.log(chalk.gray('--------------------------'));
19
14
  console.log(chalk.gray(`.......................................................`));
20
15
  console.log();
21
16
  intro('Setting up nextjs-cms... 🚀');
22
17
  try {
23
18
  note('Configuring database...');
24
- await dbConfigSetup({ dev: setupCommand.parent?.opts().dev ? true : false });
19
+ // Lazy import to avoid eager database connection
20
+ const { dbConfigSetup } = await import('../lib/db-config-setup.js');
21
+ await dbConfigSetup({ dev });
25
22
  note('Generating database schema...');
26
23
  // Use spawn to properly handle streams and prevent hanging
27
24
  await new Promise((resolve, reject) => {
28
- const child = spawn('pnpm', ['drizzle-kit', 'push --force', '--config=drizzle.config.ts'], {
25
+ const child = spawn('pnpm drizzle-kit push --force --config=drizzle.config.ts', {
29
26
  cwd: process.cwd(),
30
27
  env: { ...process.env },
31
28
  stdio: 'inherit', // Inherit stdio to prevent hanging and show output directly
@@ -45,17 +42,21 @@ export const setupCommand = new Command('setup').description('Complete nextjs-cm
45
42
  });
46
43
  s.message('Database schema generated');
47
44
  note('Setting up master admin...');
45
+ // Lazy import to avoid eager database connection
46
+ const { setMasterAdmin } = await import('../lib/set-master-admin.js');
48
47
  await setMasterAdmin();
49
48
  note('Master admin configured');
50
49
  outro('nextjs-cms setup completed successfully! 🎉');
51
50
  }
52
51
  catch (error) {
53
- s.stop('Setup failed');
54
52
  console.error(chalk.red('Error during setup:'), error);
53
+ s.stop('Setup failed');
55
54
  process.exit(1);
56
55
  }
57
56
  finally {
57
+ // Lazy import for cleanup
58
+ const { dbConnectionClose } = await import('nextjs-cms/db/client');
58
59
  await dbConnectionClose();
59
60
  process.exit(0);
60
61
  }
61
- });
62
+ }
@@ -1,3 +1,2 @@
1
- import { Command } from 'commander';
2
- export declare const updateSectionsCommand: Command;
1
+ export declare function runUpdateSections(dev: boolean): Promise<void>;
3
2
  //# sourceMappingURL=update-sections.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../src/commands/update-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,eAAO,MAAM,qBAAqB,SA6B5B,CAAA"}
1
+ {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../src/commands/update-sections.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,iBA4BnD"}
@@ -1,24 +1,21 @@
1
- import { Command } from 'commander';
2
- import { updateSections } from '../lib/update-sections.js';
3
- import { fixMasterAdminPrivileges } from '../lib/actions.js';
4
1
  import chalk from 'chalk';
5
- import { dbConnectionClose } from 'nextjs-cms/db/client';
6
- export const updateSectionsCommand = new Command('update-sections')
7
- .description('Update database tables based on current sections and update master admin privileges')
8
- .action(async (options) => {
2
+ export async function runUpdateSections(dev) {
9
3
  try {
10
- console.log(chalk.hex('#E8DCFF').bold(updateSectionsCommand.parent?.name()));
11
- console.log(updateSectionsCommand.parent?.version());
12
- console.log(updateSectionsCommand.parent?.description());
4
+ console.log(chalk.hex('#E8DCFF').bold('nextjs-cms-kit'));
5
+ console.log(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'));
13
6
  console.log(chalk.gray('--------------------------'));
14
- console.log(chalk.hex('#E8DCFF').bold(updateSectionsCommand.name()));
15
- console.log(updateSectionsCommand.description());
7
+ console.log(chalk.hex('#E8DCFF').bold('update-sections'));
8
+ console.log('Update database tables based on current sections and update master admin privileges');
16
9
  console.log(chalk.gray('--------------------------'));
17
- console.log(chalk.yellow(`Running in ${updateSectionsCommand.parent?.opts().dev ? 'development' : 'production'} mode`));
10
+ console.log(chalk.yellow(`Running in ${dev ? 'development' : 'production'} mode`));
18
11
  console.log(chalk.gray('--------------------------'));
19
12
  console.log(chalk.gray(`.......................................................`));
20
- await updateSections(options.dev);
13
+ // Lazy import to avoid eager database connection
14
+ const { updateSections } = await import('../lib/update-sections.js');
15
+ await updateSections(dev);
21
16
  console.log(chalk.blue('Modifying master admin privileges...'));
17
+ // Lazy import to avoid eager database connection
18
+ const { fixMasterAdminPrivileges } = await import('../lib/actions.js');
22
19
  await fixMasterAdminPrivileges();
23
20
  console.log(chalk.green('Master admin privileges fixed.'));
24
21
  }
@@ -27,7 +24,9 @@ export const updateSectionsCommand = new Command('update-sections')
27
24
  process.exit(1);
28
25
  }
29
26
  finally {
27
+ // Lazy import for cleanup
28
+ const { dbConnectionClose } = await import('nextjs-cms/db/client');
30
29
  await dbConnectionClose();
31
30
  process.exit(0);
32
31
  }
33
- });
32
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- declare const program: Command;
4
- export default program;
2
+ export {};
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAWnC,QAAA,MAAM,OAAO,SAAgB,CAAA;AAgC7B,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1,38 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import chalk from 'chalk';
4
- // import { intro, outro } from '@clack/prompts'
5
- // Import command modules
6
- import { dbConfigCommand } from './commands/db-config.js';
7
- import { setupCommand } from './commands/setup.js';
8
- import { setMasterAdminCommand } from './commands/set-master-admin.js';
9
- import { fixMasterAdminCommand } from './commands/fix-master-admin.js';
10
- import { updateSectionsCommand } from './commands/update-sections.js';
11
- const program = new Command();
12
- program
13
- .name('nextjs-cms-kit')
14
- .description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
15
- .version('0.4.0')
16
- .option('-d, --dev', 'Use development environment file')
17
- .action(() => {
18
- console.log(chalk.hex('#E8DCFF').bold(program.name()));
19
- console.log(program.version());
20
- console.log(program.description());
21
- console.log(chalk.gray('--------------------------'));
22
- console.log(chalk.yellow(`Running in ${process.env.NODE_ENV} mode`));
23
- console.log(chalk.gray('--------------------------'));
24
- });
25
- program.addCommand(setupCommand);
26
- program.addCommand(dbConfigCommand);
27
- program.addCommand(setMasterAdminCommand);
28
- program.addCommand(fixMasterAdminCommand);
29
- program.addCommand(updateSectionsCommand);
30
- // Handle unknown commands
31
- program.on('command:*', (operands) => {
32
- console.error(chalk.red(`Unknown command: ${operands[0]}`));
33
- console.log(chalk.gray('Run nextjs-cms-kit --help to see available commands'));
34
- process.exit(1);
35
- });
36
- // Parse arguments
37
- // program.parse()
38
- export default program;
2
+ import program from './lib/program.js';
3
+ program.parse(process.argv);
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/lib/actions.ts"],"names":[],"mappings":"AAMA,wBAAsB,wBAAwB,kBAyB7C;AAED,wBAAsB,cAAc;;;sBAWnC;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,iBAoBnD"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/lib/actions.ts"],"names":[],"mappings":"AAAA,wBAAsB,wBAAwB,kBA8B7C;AAED,wBAAsB,cAAc;;;sBAgBnC;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,iBAyBnD"}
@@ -1,9 +1,8 @@
1
- import { SectionFactory } from 'nextjs-cms/core/factories';
2
- import { db } from 'nextjs-cms/db/client';
3
- import { AdminPrivilegesTable, AdminsTable } from 'nextjs-cms/db/schema';
4
- import { eq, and } from 'drizzle-orm';
5
- import bcrypt from 'bcrypt';
6
1
  export async function fixMasterAdminPrivileges() {
2
+ // Lazy import heavy dependencies to avoid eager database connection initialization
3
+ const { SectionFactory } = await import('nextjs-cms/core/factories');
4
+ const { db } = await import('nextjs-cms/db/client');
5
+ const { AdminPrivilegesTable } = await import('nextjs-cms/db/schema');
7
6
  // Let's also add privileges for all the sections to the master admin
8
7
  // Loop through the sections to get the section ids for the insertion into the admin_privileges table
9
8
  const sections = await SectionFactory.getSections();
@@ -28,6 +27,10 @@ export async function fixMasterAdminPrivileges() {
28
27
  return;
29
28
  }
30
29
  export async function getMasterAdmin() {
30
+ // Lazy import heavy dependencies to avoid eager database connection initialization
31
+ const { db } = await import('nextjs-cms/db/client');
32
+ const { AdminsTable } = await import('nextjs-cms/db/schema');
33
+ const { eq, and } = await import('drizzle-orm');
31
34
  const masterAdmin = await db
32
35
  .select({
33
36
  id: AdminsTable.id,
@@ -40,6 +43,10 @@ export async function getMasterAdmin() {
40
43
  return masterAdmin[0];
41
44
  }
42
45
  export async function setMaterAdmin(password) {
46
+ // Lazy import heavy dependencies to avoid eager database connection initialization
47
+ const bcrypt = await import('bcrypt');
48
+ const { db } = await import('nextjs-cms/db/client');
49
+ const { AdminsTable } = await import('nextjs-cms/db/schema');
43
50
  try {
44
51
  const hashedPassword = await bcrypt.hash(password, 10);
45
52
  await db
@@ -1 +1 @@
1
- {"version":3,"file":"add-table-keys.d.ts","sourceRoot":"","sources":["../../src/lib/add-table-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIzD,wBAAsB,YAAY,CAC9B,KAAK,EAAE;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;IACnD,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;IACpD,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;CACzD,EACD,YAAY,CAAC,EAAE;IACX,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;IACjD,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;IAChD,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CACtD,mBA6OJ"}
1
+ {"version":3,"file":"add-table-keys.d.ts","sourceRoot":"","sources":["../../src/lib/add-table-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGzD,wBAAsB,YAAY,CAC9B,KAAK,EAAE;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;IACnD,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;IACpD,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAA;CACzD,EACD,YAAY,CAAC,EAAE;IACX,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;IACjD,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;IAChD,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CACtD,mBAgPJ"}
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
- import { db } from 'nextjs-cms/db/client';
3
2
  export async function addTableKeys(table, existingKeys) {
3
+ // Lazy import heavy dependencies to avoid eager database connection initialization
4
+ const { db } = await import('nextjs-cms/db/client');
4
5
  // console.log(chalk.gray(` - Checking table keys`))
5
6
  /**
6
7
  * Number of SQL errors
@@ -1 +1 @@
1
- {"version":3,"file":"db-config-setup.d.ts","sourceRoot":"","sources":["../../src/lib/db-config-setup.ts"],"names":[],"mappings":"AAkCA,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,iBAqN5D"}
1
+ {"version":3,"file":"db-config-setup.d.ts","sourceRoot":"","sources":["../../src/lib/db-config-setup.ts"],"names":[],"mappings":"AAiCA,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,iBAuN5D"}
@@ -3,7 +3,6 @@ import { intro, isCancel, outro, text, spinner, note } from '@clack/prompts';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import { cwd } from 'process';
6
- import { reloadAndUpdateEnvironmentVariables } from './reload-env.js';
7
6
  /**
8
7
  * Removes specific environment variables from the .env file content
9
8
  * Removes both the generated comment block and the individual variable lines
@@ -174,6 +173,7 @@ DB_PASSWORD='${dbPassword}'
174
173
  DB_USER: String(dbUser),
175
174
  DB_PASSWORD: String(dbPassword),
176
175
  };
176
+ const { reloadAndUpdateEnvironmentVariables } = await import('./reload-env.js');
177
177
  const reloadSuccess = reloadAndUpdateEnvironmentVariables(dbVariables, dev ? '.env.development' : '.env.production');
178
178
  if (reloadSuccess) {
179
179
  console.log('✓ Environment variables reloaded successfully!');
@@ -1 +1 @@
1
- {"version":3,"file":"fix-master-admin.d.ts","sourceRoot":"","sources":["../../src/lib/fix-master-admin.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,kBAInC"}
1
+ {"version":3,"file":"fix-master-admin.d.ts","sourceRoot":"","sources":["../../src/lib/fix-master-admin.ts"],"names":[],"mappings":"AAEA,wBAAsB,cAAc,kBAKnC"}
@@ -1,7 +1,7 @@
1
1
  import { intro, outro } from '@clack/prompts';
2
- import { fixMasterAdminPrivileges } from './actions.js';
3
2
  export async function fixMasterAdmin() {
4
3
  intro(`Looking up sections...`);
4
+ const { fixMasterAdminPrivileges } = await import('./actions.js');
5
5
  await fixMasterAdminPrivileges();
6
6
  outro(`Master admin privileges fixed`);
7
7
  }
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const program: Command;
3
+ export default program;
4
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,QAAA,MAAM,OAAO,SAAgB,CAAA;AAmE7B,eAAe,OAAO,CAAA"}
@@ -0,0 +1,61 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ const program = new Command();
4
+ program
5
+ .name('nextjs-cms-kit')
6
+ .description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
7
+ .version('0.4.0')
8
+ .option('-d, --dev', 'Use development environment file')
9
+ .action(() => {
10
+ console.log(chalk.hex('#E8DCFF').bold(program.name()));
11
+ console.log(program.version());
12
+ console.log(program.description());
13
+ console.log(chalk.gray('--------------------------'));
14
+ console.log(chalk.yellow(`Running in ${process.env.NODE_ENV} mode`));
15
+ console.log(chalk.gray('--------------------------'));
16
+ });
17
+ // Lazy-load commands to avoid eager database connection initialization
18
+ // This significantly improves CLI startup time by deferring heavy imports
19
+ // until the specific command is actually invoked
20
+ program
21
+ .command('setup')
22
+ .description('Complete nextjs-cms setup')
23
+ .action(async () => {
24
+ const { runSetup } = await import('../commands/setup.js');
25
+ await runSetup(Boolean(program.opts().dev));
26
+ });
27
+ program
28
+ .command('db-config')
29
+ .description('Initialize nextjs-cms database configuration')
30
+ .action(async () => {
31
+ const { runDbConfig } = await import('../commands/db-config.js');
32
+ await runDbConfig(Boolean(program.opts().dev));
33
+ });
34
+ program
35
+ .command('set-master-admin')
36
+ .description('Set or update master admin password')
37
+ .action(async () => {
38
+ const { runSetMasterAdmin } = await import('../commands/set-master-admin.js');
39
+ await runSetMasterAdmin(Boolean(program.opts().dev));
40
+ });
41
+ program
42
+ .command('fix-master-admin')
43
+ .description('Fix master admin privileges for all sections')
44
+ .action(async () => {
45
+ const { runFixMasterAdmin } = await import('../commands/fix-master-admin.js');
46
+ await runFixMasterAdmin();
47
+ });
48
+ program
49
+ .command('update-sections')
50
+ .description('Update database tables based on current sections and update master admin privileges')
51
+ .action(async () => {
52
+ const { runUpdateSections } = await import('../commands/update-sections.js');
53
+ await runUpdateSections(Boolean(program.opts().dev));
54
+ });
55
+ // Handle unknown commands
56
+ program.on('command:*', (operands) => {
57
+ console.error(chalk.red(`Unknown command: ${operands[0]}`));
58
+ console.log(chalk.gray('Run nextjs-cms-kit --help to see available commands'));
59
+ process.exit(1);
60
+ });
61
+ export default program;
@@ -3,8 +3,8 @@ export declare function generateDrizzleSchema(table: {
3
3
  name: string;
4
4
  fields: FieldConfig[];
5
5
  identifier: FieldConfig;
6
- }): {
6
+ }): Promise<{
7
7
  schema: string;
8
8
  columnTypes: string[];
9
- };
9
+ }>;
10
10
  //# sourceMappingURL=schema-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-generator.d.ts","sourceRoot":"","sources":["../../src/lib/schema-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAqBzD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,GAAG;IAC5G,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,EAAE,CAAA;CACxB,CAiKA"}
1
+ {"version":3,"file":"schema-generator.d.ts","sourceRoot":"","sources":["../../src/lib/schema-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAoBzD,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,UAAU,EAAE,WAAW,CAAA;CAC1B,GAAG,OAAO,CAAC;IACR,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,EAAE,CAAA;CACxB,CAAC,CAkKD"}
@@ -1,4 +1,3 @@
1
- import { getCMSConfig } from 'nextjs-cms/core/config';
2
1
  // Converts snake_case to camelCase
3
2
  function toCamelCase(snake) {
4
3
  return snake.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
@@ -14,7 +13,8 @@ function toSnakeCase(str) {
14
13
  .replace(/^_/, '') // Remove leading underscore if any
15
14
  .toLowerCase();
16
15
  }
17
- export function generateDrizzleSchema(table) {
16
+ export async function generateDrizzleSchema(table) {
17
+ const { getCMSConfig } = await import('nextjs-cms/core/config');
18
18
  let tableCaseStyleFn;
19
19
  let columnCaseStyleFn;
20
20
  const lzConfig = getCMSConfig();
@@ -1 +1 @@
1
- {"version":3,"file":"set-master-admin.d.ts","sourceRoot":"","sources":["../../src/lib/set-master-admin.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,kBA2DnC"}
1
+ {"version":3,"file":"set-master-admin.d.ts","sourceRoot":"","sources":["../../src/lib/set-master-admin.ts"],"names":[],"mappings":"AAEA,wBAAsB,cAAc,kBA8DnC"}
@@ -1,10 +1,10 @@
1
1
  import * as p from '@clack/prompts';
2
- import { fixMasterAdminPrivileges, getMasterAdmin, setMaterAdmin } from './actions.js';
3
2
  export async function setMasterAdmin() {
4
3
  p.intro(`Setting up master admin...`);
5
4
  /**
6
5
  * Check if the master admin is already set
7
6
  */
7
+ const { getMasterAdmin } = await import('./actions.js');
8
8
  const masterAdmin = await getMasterAdmin();
9
9
  if (masterAdmin) {
10
10
  p.log.info(`Master admin is already set.`);
@@ -46,6 +46,8 @@ export async function setMasterAdmin() {
46
46
  p.log.error('Passwords do not match. Please try again.');
47
47
  }
48
48
  }
49
+ const { setMaterAdmin } = await import('./actions.js');
50
+ const { fixMasterAdminPrivileges } = await import('./actions.js');
49
51
  await setMaterAdmin(password);
50
52
  await fixMasterAdminPrivileges();
51
53
  p.outro(`Master admin username is: Master. You're all set! 🎉 \n\n you can login here: http://localhost:3000/auth/login`);
@@ -1 +1 @@
1
- {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../src/lib/update-sections.ts"],"names":[],"mappings":"AAgjCA,wBAAsB,cAAc,CAAC,SAAS,UAAQ,iBAmBrD"}
1
+ {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../src/lib/update-sections.ts"],"names":[],"mappings":"AA+iCA,wBAAsB,cAAc,CAAC,SAAS,UAAQ,iBAmBrD"}
@@ -1,4 +1,3 @@
1
- // import '@/envConfig'
2
1
  import { db } from 'nextjs-cms/db/client';
3
2
  import { LZTablesTable } from 'nextjs-cms/db/schema';
4
3
  import { eq, sql } from 'drizzle-orm';
@@ -557,7 +556,7 @@ const main = async (s) => {
557
556
  /**
558
557
  * Generate the Drizzle schema for the table
559
558
  */
560
- const drizzleSchema = generateDrizzleSchema({
559
+ const drizzleSchema = await generateDrizzleSchema({
561
560
  name: s.db.table,
562
561
  fields: s.fieldConfigs,
563
562
  identifier: s.db.identifier,
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "nextjs-cms-kit",
3
3
  "private": false,
4
- "version": "0.5.29",
4
+ "version": "0.5.31",
5
+ "type": "module",
5
6
  "bin": {
6
7
  "nextjs-cms-kit": "./dist/index.js"
7
8
  },
@@ -10,6 +11,10 @@
10
11
  ".": {
11
12
  "types": "./dist/index.d.ts",
12
13
  "default": "./dist/index.js"
14
+ },
15
+ "./cli": {
16
+ "types": "./dist/lib/program.d.ts",
17
+ "default": "./dist/lib/program.js"
13
18
  }
14
19
  },
15
20
  "files": [
@@ -27,7 +32,7 @@
27
32
  "mysql2": "^3.12.0"
28
33
  },
29
34
  "peerDependencies": {
30
- "nextjs-cms": "0.5.29"
35
+ "nextjs-cms": "0.5.31"
31
36
  },
32
37
  "devDependencies": {
33
38
  "@types/bcrypt": "^6.0.0",