nextjs-cms-kit 0.5.28 → 0.5.30
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/commands/db-config.d.ts +1 -2
- package/dist/commands/db-config.d.ts.map +1 -1
- package/dist/commands/db-config.js +7 -9
- package/dist/commands/fix-master-admin.d.ts +1 -2
- package/dist/commands/fix-master-admin.d.ts.map +1 -1
- package/dist/commands/fix-master-admin.js +6 -7
- package/dist/commands/set-master-admin.d.ts +1 -2
- package/dist/commands/set-master-admin.d.ts.map +1 -1
- package/dist/commands/set-master-admin.js +11 -13
- package/dist/commands/setup.d.ts +1 -2
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +16 -15
- package/dist/commands/update-sections.d.ts +1 -2
- package/dist/commands/update-sections.d.ts.map +1 -1
- package/dist/commands/update-sections.js +14 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -14
- package/dist/lib/actions.d.ts.map +1 -1
- package/dist/lib/actions.js +12 -5
- package/dist/lib/add-table-keys.d.ts.map +1 -1
- package/dist/lib/add-table-keys.js +2 -1
- package/dist/lib/db-config-setup.d.ts.map +1 -1
- package/dist/lib/db-config-setup.js +1 -1
- package/dist/lib/fix-master-admin.d.ts.map +1 -1
- package/dist/lib/fix-master-admin.js +1 -1
- package/dist/lib/schema-generator.d.ts +2 -2
- package/dist/lib/schema-generator.d.ts.map +1 -1
- package/dist/lib/schema-generator.js +2 -2
- package/dist/lib/set-master-admin.d.ts.map +1 -1
- package/dist/lib/set-master-admin.js +3 -1
- package/dist/lib/update-sections.d.ts.map +1 -1
- package/dist/lib/update-sections.js +1 -2
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-config.d.ts","sourceRoot":"","sources":["../../src/commands/db-config.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/fix-master-admin.ts"],"names":[],"mappings":"
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-master-admin.d.ts","sourceRoot":"","sources":["../../src/commands/set-master-admin.ts"],"names":[],"mappings":"
|
|
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
|
|
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(
|
|
10
|
-
console.log(
|
|
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(
|
|
14
|
-
console.log(
|
|
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 ${
|
|
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
|
+
}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAIA,wBAAsB,QAAQ,CAAC,GAAG,EAAE,OAAO,iBA8D1C"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
11
|
-
console.log(
|
|
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(
|
|
15
|
-
console.log(
|
|
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 ${
|
|
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
|
-
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../src/commands/update-sections.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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(
|
|
11
|
-
console.log(
|
|
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(
|
|
15
|
-
console.log(
|
|
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 ${
|
|
10
|
+
console.log(chalk.yellow(`Running in ${dev ? 'development' : 'production'} mode`));
|
|
18
11
|
console.log(chalk.gray('--------------------------'));
|
|
19
12
|
console.log(chalk.gray(`.......................................................`));
|
|
20
|
-
|
|
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,QAAA,MAAM,OAAO,SAAgB,CAAA;AAmE7B,eAAe,OAAO,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
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
4
|
const program = new Command();
|
|
12
5
|
program
|
|
13
6
|
.name('nextjs-cms-kit')
|
|
@@ -22,17 +15,48 @@ program
|
|
|
22
15
|
console.log(chalk.yellow(`Running in ${process.env.NODE_ENV} mode`));
|
|
23
16
|
console.log(chalk.gray('--------------------------'));
|
|
24
17
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
program
|
|
29
|
-
|
|
18
|
+
// Lazy-load commands to avoid eager database connection initialization
|
|
19
|
+
// This significantly improves CLI startup time by deferring heavy imports
|
|
20
|
+
// until the specific command is actually invoked
|
|
21
|
+
program
|
|
22
|
+
.command('setup')
|
|
23
|
+
.description('Complete nextjs-cms setup')
|
|
24
|
+
.action(async () => {
|
|
25
|
+
const { runSetup } = await import('./commands/setup.js');
|
|
26
|
+
await runSetup(program.opts().dev ?? false);
|
|
27
|
+
});
|
|
28
|
+
program
|
|
29
|
+
.command('db-config')
|
|
30
|
+
.description('Initialize nextjs-cms database configuration')
|
|
31
|
+
.action(async () => {
|
|
32
|
+
const { runDbConfig } = await import('./commands/db-config.js');
|
|
33
|
+
await runDbConfig(program.opts().dev ?? false);
|
|
34
|
+
});
|
|
35
|
+
program
|
|
36
|
+
.command('set-master-admin')
|
|
37
|
+
.description('Set or update master admin password')
|
|
38
|
+
.action(async () => {
|
|
39
|
+
const { runSetMasterAdmin } = await import('./commands/set-master-admin.js');
|
|
40
|
+
await runSetMasterAdmin(program.opts().dev ?? false);
|
|
41
|
+
});
|
|
42
|
+
program
|
|
43
|
+
.command('fix-master-admin')
|
|
44
|
+
.description('Fix master admin privileges for all sections')
|
|
45
|
+
.action(async () => {
|
|
46
|
+
const { runFixMasterAdmin } = await import('./commands/fix-master-admin.js');
|
|
47
|
+
await runFixMasterAdmin();
|
|
48
|
+
});
|
|
49
|
+
program
|
|
50
|
+
.command('update-sections')
|
|
51
|
+
.description('Update database tables based on current sections and update master admin privileges')
|
|
52
|
+
.action(async () => {
|
|
53
|
+
const { runUpdateSections } = await import('./commands/update-sections.js');
|
|
54
|
+
await runUpdateSections(program.opts().dev ?? false);
|
|
55
|
+
});
|
|
30
56
|
// Handle unknown commands
|
|
31
57
|
program.on('command:*', (operands) => {
|
|
32
58
|
console.error(chalk.red(`Unknown command: ${operands[0]}`));
|
|
33
59
|
console.log(chalk.gray('Run nextjs-cms-kit --help to see available commands'));
|
|
34
60
|
process.exit(1);
|
|
35
61
|
});
|
|
36
|
-
// Parse arguments
|
|
37
|
-
// program.parse()
|
|
38
62
|
export default program;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/lib/actions.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/lib/actions.js
CHANGED
|
@@ -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;
|
|
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":"
|
|
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":"
|
|
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
|
}
|
|
@@ -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;
|
|
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":"
|
|
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":"
|
|
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.
|
|
4
|
+
"version": "0.5.30",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"bin": {
|
|
6
7
|
"nextjs-cms-kit": "./dist/index.js"
|
|
7
8
|
},
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"mysql2": "^3.12.0"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
|
-
"nextjs-cms": "0.5.
|
|
31
|
+
"nextjs-cms": "0.5.30"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/bcrypt": "^6.0.0",
|
|
@@ -36,8 +37,8 @@
|
|
|
36
37
|
"prettier": "^3.3.3",
|
|
37
38
|
"tsx": "^4.20.6",
|
|
38
39
|
"typescript": "^5.9.2",
|
|
39
|
-
"@lzcms/eslint-config": "0.3.0",
|
|
40
40
|
"@lzcms/prettier-config": "0.1.0",
|
|
41
|
+
"@lzcms/eslint-config": "0.3.0",
|
|
41
42
|
"@lzcms/tsconfig": "0.1.0"
|
|
42
43
|
},
|
|
43
44
|
"prettier": "@lzcms/prettier-config",
|