nextjs-cms-kit 0.5.32 → 0.5.34

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.
@@ -1 +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"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAqE3C,QAAA,MAAM,OAAO,SAAgB,CAAA;AAoE7B,eAAe,OAAO,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Command } from 'commander';
1
+ import { Command, Option } from 'commander';
2
2
  import chalk from 'chalk';
3
3
  import { existsSync, readFileSync } from 'fs';
4
4
  import { join } from 'path';
@@ -27,7 +27,19 @@ function isNextjsCmsApp() {
27
27
  return false;
28
28
  }
29
29
  }
30
+ function shouldSkipValidation() {
31
+ const args = process.argv.slice(2); // Remove 'node' and script path
32
+ return (args.includes('-h') ||
33
+ args.includes('--help') ||
34
+ args.includes('-V') ||
35
+ args.includes('--version') ||
36
+ args.includes('-v'));
37
+ }
30
38
  function validateNextjsCmsApp() {
39
+ // Skip validation for help and version commands
40
+ if (shouldSkipValidation()) {
41
+ return;
42
+ }
31
43
  if (!isNextjsCmsApp()) {
32
44
  console.error(chalk.red('❌ Error: This command must be run in a nextjs-cms application directory.'));
33
45
  console.error(chalk.gray('Make sure you have:'));
@@ -43,23 +55,16 @@ validateNextjsCmsApp();
43
55
  const program = new Command();
44
56
  program
45
57
  .name('nextjs-cms-kit')
58
+ .option('-d, --dev', 'use development environment file, use -d/--dev before any command to use the development environment file (e.g. nextjs-cms-kit -d setup)', false)
46
59
  .description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
47
60
  .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
61
+ // Include -v option to show the version number
62
+ .addOption(new Option('-v').hideHelp())
63
+ .enablePositionalOptions();
60
64
  program
61
65
  .command('setup')
62
66
  .description('Complete nextjs-cms setup')
67
+ .passThroughOptions()
63
68
  .action(async () => {
64
69
  const { runSetup } = await import('../commands/setup.js');
65
70
  await runSetup(Boolean(program.opts().dev));
@@ -67,6 +72,7 @@ program
67
72
  program
68
73
  .command('db-config')
69
74
  .description('Initialize nextjs-cms database configuration')
75
+ .passThroughOptions()
70
76
  .action(async () => {
71
77
  const { runDbConfig } = await import('../commands/db-config.js');
72
78
  await runDbConfig(Boolean(program.opts().dev));
@@ -74,6 +80,7 @@ program
74
80
  program
75
81
  .command('set-master-admin')
76
82
  .description('Set or update master admin password')
83
+ .passThroughOptions()
77
84
  .action(async () => {
78
85
  const { runSetMasterAdmin } = await import('../commands/set-master-admin.js');
79
86
  await runSetMasterAdmin(Boolean(program.opts().dev));
@@ -81,6 +88,7 @@ program
81
88
  program
82
89
  .command('fix-master-admin')
83
90
  .description('Fix master admin privileges for all sections')
91
+ .passThroughOptions()
84
92
  .action(async () => {
85
93
  const { runFixMasterAdmin } = await import('../commands/fix-master-admin.js');
86
94
  await runFixMasterAdmin();
@@ -88,14 +96,15 @@ program
88
96
  program
89
97
  .command('update-sections')
90
98
  .description('Update database tables based on current sections and update master admin privileges')
99
+ .passThroughOptions()
91
100
  .action(async () => {
92
101
  const { runUpdateSections } = await import('../commands/update-sections.js');
93
102
  await runUpdateSections(Boolean(program.opts().dev));
94
103
  });
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);
104
+ program.showHelpAfterError('(add --help for additional information)');
105
+ // Show the version number when the -v option is used
106
+ program.on('option:v', () => {
107
+ console.log(program.version());
108
+ process.exit();
100
109
  });
101
110
  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.32",
4
+ "version": "0.5.34",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "nextjs-cms-kit": "./dist/index.js"
@@ -23,7 +23,7 @@
23
23
  "LICENSE"
24
24
  ],
25
25
  "dependencies": {
26
- "@clack/prompts": "^0.10.0",
26
+ "@clack/prompts": "^0.11.0",
27
27
  "bcrypt": "^6.0.0",
28
28
  "chalk": "^5.4.1",
29
29
  "commander": "^14.0.2",
@@ -32,7 +32,7 @@
32
32
  "mysql2": "^3.12.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "nextjs-cms": "0.5.32"
35
+ "nextjs-cms": "0.5.34"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/bcrypt": "^6.0.0",
@@ -42,14 +42,14 @@
42
42
  "tsx": "^4.20.6",
43
43
  "typescript": "^5.9.2",
44
44
  "@lzcms/eslint-config": "0.3.0",
45
- "@lzcms/tsconfig": "0.1.0",
46
- "@lzcms/prettier-config": "0.1.0"
45
+ "@lzcms/prettier-config": "0.1.0",
46
+ "@lzcms/tsconfig": "0.1.0"
47
47
  },
48
48
  "prettier": "@lzcms/prettier-config",
49
49
  "scripts": {
50
50
  "build": "tsc",
51
51
  "clean": "git clean -xdf .cache .turbo dist node_modules",
52
- "dev": "tsc",
52
+ "dev": "tsc --watch",
53
53
  "format": "prettier --check . --ignore-path ../../.gitignore",
54
54
  "lint": "eslint",
55
55
  "typecheck": "tsc --noEmit --emitDeclarationOnly false",