nextjs-cms-kit 0.5.32 → 0.5.33

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;AA+D3C,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,15 @@ 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') || args.includes('--help') || args.includes('-V') || args.includes('--version');
33
+ }
30
34
  function validateNextjsCmsApp() {
35
+ // Skip validation for help and version commands
36
+ if (shouldSkipValidation()) {
37
+ return;
38
+ }
31
39
  if (!isNextjsCmsApp()) {
32
40
  console.error(chalk.red('❌ Error: This command must be run in a nextjs-cms application directory.'));
33
41
  console.error(chalk.gray('Make sure you have:'));
@@ -43,23 +51,16 @@ validateNextjsCmsApp();
43
51
  const program = new Command();
44
52
  program
45
53
  .name('nextjs-cms-kit')
54
+ .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
55
  .description(chalk.green('nextjs-cms CLI toolkit for managing your nextjs-cms application'))
47
56
  .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
57
+ // Include -v option to show the version number
58
+ .addOption(new Option('-v').hideHelp())
59
+ .enablePositionalOptions();
60
60
  program
61
61
  .command('setup')
62
62
  .description('Complete nextjs-cms setup')
63
+ .passThroughOptions()
63
64
  .action(async () => {
64
65
  const { runSetup } = await import('../commands/setup.js');
65
66
  await runSetup(Boolean(program.opts().dev));
@@ -67,6 +68,7 @@ program
67
68
  program
68
69
  .command('db-config')
69
70
  .description('Initialize nextjs-cms database configuration')
71
+ .passThroughOptions()
70
72
  .action(async () => {
71
73
  const { runDbConfig } = await import('../commands/db-config.js');
72
74
  await runDbConfig(Boolean(program.opts().dev));
@@ -74,6 +76,7 @@ program
74
76
  program
75
77
  .command('set-master-admin')
76
78
  .description('Set or update master admin password')
79
+ .passThroughOptions()
77
80
  .action(async () => {
78
81
  const { runSetMasterAdmin } = await import('../commands/set-master-admin.js');
79
82
  await runSetMasterAdmin(Boolean(program.opts().dev));
@@ -81,6 +84,7 @@ program
81
84
  program
82
85
  .command('fix-master-admin')
83
86
  .description('Fix master admin privileges for all sections')
87
+ .passThroughOptions()
84
88
  .action(async () => {
85
89
  const { runFixMasterAdmin } = await import('../commands/fix-master-admin.js');
86
90
  await runFixMasterAdmin();
@@ -88,14 +92,15 @@ program
88
92
  program
89
93
  .command('update-sections')
90
94
  .description('Update database tables based on current sections and update master admin privileges')
95
+ .passThroughOptions()
91
96
  .action(async () => {
92
97
  const { runUpdateSections } = await import('../commands/update-sections.js');
93
98
  await runUpdateSections(Boolean(program.opts().dev));
94
99
  });
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
+ program.showHelpAfterError('(add --help for additional information)');
101
+ // Show the version number when the -v option is used
102
+ program.on('option:v', () => {
103
+ console.log(program.version());
104
+ process.exit();
100
105
  });
101
106
  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.33",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "nextjs-cms-kit": "./dist/index.js"
@@ -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.33"
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",