nextjs-cms-kit 0.5.30 → 0.5.32
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.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -61
- package/dist/lib/program.d.ts +4 -0
- package/dist/lib/program.d.ts.map +1 -0
- package/dist/lib/program.js +101 -0
- package/package.json +8 -4
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,62 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const program = new Command();
|
|
5
|
-
program
|
|
6
|
-
.name('nextjs-cms-kit')
|
|
7
|
-
.description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
|
|
8
|
-
.version('0.4.0')
|
|
9
|
-
.option('-d, --dev', 'Use development environment file')
|
|
10
|
-
.action(() => {
|
|
11
|
-
console.log(chalk.hex('#E8DCFF').bold(program.name()));
|
|
12
|
-
console.log(program.version());
|
|
13
|
-
console.log(program.description());
|
|
14
|
-
console.log(chalk.gray('--------------------------'));
|
|
15
|
-
console.log(chalk.yellow(`Running in ${process.env.NODE_ENV} mode`));
|
|
16
|
-
console.log(chalk.gray('--------------------------'));
|
|
17
|
-
});
|
|
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
|
-
});
|
|
56
|
-
// Handle unknown commands
|
|
57
|
-
program.on('command:*', (operands) => {
|
|
58
|
-
console.error(chalk.red(`Unknown command: ${operands[0]}`));
|
|
59
|
-
console.log(chalk.gray('Run nextjs-cms-kit --help to see available commands'));
|
|
60
|
-
process.exit(1);
|
|
61
|
-
});
|
|
62
|
-
export default program;
|
|
2
|
+
import program from './lib/program.js';
|
|
3
|
+
program.parse(process.argv);
|
|
@@ -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;AAqDnC,QAAA,MAAM,OAAO,SAAgB,CAAA;AAmE7B,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
function isNextjsCmsApp() {
|
|
6
|
+
const cwd = process.cwd();
|
|
7
|
+
// Check for lz.config.ts file
|
|
8
|
+
const configFile = join(cwd, 'lz.config.ts');
|
|
9
|
+
if (!existsSync(configFile)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// Check for nextjs-cms dependency in package.json
|
|
13
|
+
try {
|
|
14
|
+
const packageJsonPath = join(cwd, 'package.json');
|
|
15
|
+
if (!existsSync(packageJsonPath)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
19
|
+
const allDeps = {
|
|
20
|
+
...(packageJson.dependencies ?? {}),
|
|
21
|
+
...(packageJson.devDependencies ?? {}),
|
|
22
|
+
...(packageJson.peerDependencies ?? {}),
|
|
23
|
+
};
|
|
24
|
+
return 'nextjs-cms' in allDeps;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function validateNextjsCmsApp() {
|
|
31
|
+
if (!isNextjsCmsApp()) {
|
|
32
|
+
console.error(chalk.red('❌ Error: This command must be run in a nextjs-cms application directory.'));
|
|
33
|
+
console.error(chalk.gray('Make sure you have:'));
|
|
34
|
+
console.error(chalk.gray(' - lz.config.ts file'));
|
|
35
|
+
console.error(chalk.gray(' - nextjs-cms as a dependency in package.json'));
|
|
36
|
+
console.error(chalk.gray('To create a new nextjs-cms application, run:'));
|
|
37
|
+
console.error(chalk.gray(' - pnpm create nextjs-cms@latest'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Validate that we're in a nextjs-cms app before proceeding
|
|
42
|
+
validateNextjsCmsApp();
|
|
43
|
+
const program = new Command();
|
|
44
|
+
program
|
|
45
|
+
.name('nextjs-cms-kit')
|
|
46
|
+
.description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
|
|
47
|
+
.version('0.4.0')
|
|
48
|
+
.option('-d, --dev', 'Use development environment file')
|
|
49
|
+
.action(() => {
|
|
50
|
+
console.log(chalk.hex('#E8DCFF').bold(program.name()));
|
|
51
|
+
console.log(program.version());
|
|
52
|
+
console.log(program.description());
|
|
53
|
+
console.log(chalk.gray('--------------------------'));
|
|
54
|
+
console.log(chalk.yellow(`Running in ${process.env.NODE_ENV} mode`));
|
|
55
|
+
console.log(chalk.gray('--------------------------'));
|
|
56
|
+
});
|
|
57
|
+
// Lazy-load commands to avoid eager database connection initialization
|
|
58
|
+
// This significantly improves CLI startup time by deferring heavy imports
|
|
59
|
+
// until the specific command is actually invoked
|
|
60
|
+
program
|
|
61
|
+
.command('setup')
|
|
62
|
+
.description('Complete nextjs-cms setup')
|
|
63
|
+
.action(async () => {
|
|
64
|
+
const { runSetup } = await import('../commands/setup.js');
|
|
65
|
+
await runSetup(Boolean(program.opts().dev));
|
|
66
|
+
});
|
|
67
|
+
program
|
|
68
|
+
.command('db-config')
|
|
69
|
+
.description('Initialize nextjs-cms database configuration')
|
|
70
|
+
.action(async () => {
|
|
71
|
+
const { runDbConfig } = await import('../commands/db-config.js');
|
|
72
|
+
await runDbConfig(Boolean(program.opts().dev));
|
|
73
|
+
});
|
|
74
|
+
program
|
|
75
|
+
.command('set-master-admin')
|
|
76
|
+
.description('Set or update master admin password')
|
|
77
|
+
.action(async () => {
|
|
78
|
+
const { runSetMasterAdmin } = await import('../commands/set-master-admin.js');
|
|
79
|
+
await runSetMasterAdmin(Boolean(program.opts().dev));
|
|
80
|
+
});
|
|
81
|
+
program
|
|
82
|
+
.command('fix-master-admin')
|
|
83
|
+
.description('Fix master admin privileges for all sections')
|
|
84
|
+
.action(async () => {
|
|
85
|
+
const { runFixMasterAdmin } = await import('../commands/fix-master-admin.js');
|
|
86
|
+
await runFixMasterAdmin();
|
|
87
|
+
});
|
|
88
|
+
program
|
|
89
|
+
.command('update-sections')
|
|
90
|
+
.description('Update database tables based on current sections and update master admin privileges')
|
|
91
|
+
.action(async () => {
|
|
92
|
+
const { runUpdateSections } = await import('../commands/update-sections.js');
|
|
93
|
+
await runUpdateSections(Boolean(program.opts().dev));
|
|
94
|
+
});
|
|
95
|
+
// Handle unknown commands
|
|
96
|
+
program.on('command:*', (operands) => {
|
|
97
|
+
console.error(chalk.red(`Unknown command: ${operands[0]}`));
|
|
98
|
+
console.log(chalk.gray('Run nextjs-cms-kit --help to see available commands'));
|
|
99
|
+
process.exit(1);
|
|
100
|
+
});
|
|
101
|
+
export default program;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cms-kit",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.32",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"nextjs-cms-kit": "./dist/index.js"
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./cli": {
|
|
16
|
+
"types": "./dist/lib/program.d.ts",
|
|
17
|
+
"default": "./dist/lib/program.js"
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
@@ -28,7 +32,7 @@
|
|
|
28
32
|
"mysql2": "^3.12.0"
|
|
29
33
|
},
|
|
30
34
|
"peerDependencies": {
|
|
31
|
-
"nextjs-cms": "0.5.
|
|
35
|
+
"nextjs-cms": "0.5.32"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/bcrypt": "^6.0.0",
|
|
@@ -37,9 +41,9 @@
|
|
|
37
41
|
"prettier": "^3.3.3",
|
|
38
42
|
"tsx": "^4.20.6",
|
|
39
43
|
"typescript": "^5.9.2",
|
|
40
|
-
"@lzcms/prettier-config": "0.1.0",
|
|
41
44
|
"@lzcms/eslint-config": "0.3.0",
|
|
42
|
-
"@lzcms/tsconfig": "0.1.0"
|
|
45
|
+
"@lzcms/tsconfig": "0.1.0",
|
|
46
|
+
"@lzcms/prettier-config": "0.1.0"
|
|
43
47
|
},
|
|
44
48
|
"prettier": "@lzcms/prettier-config",
|
|
45
49
|
"scripts": {
|