@neupgroup/mapper 1.5.0 → 1.5.3

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.
@@ -2,10 +2,28 @@
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  const args = process.argv.slice(2);
5
+ if (args.includes('--help') || args.includes('-h')) {
6
+ console.log(`
7
+ Usage: npm run create-connection <connectionName> [type]
8
+
9
+ Arguments:
10
+ connectionName Name for your connection (e.g., 'primary_db')
11
+ type Database type (default: 'api').
12
+ Supported types: mysql, sqlite, postgres, mongodb, api
13
+
14
+ Options:
15
+ --help, -h Show this help message
16
+
17
+ Example:
18
+ npm run create-connection my_db mysql
19
+ `);
20
+ process.exit(0);
21
+ }
5
22
  const connectionName = args[0];
6
23
  const type = args[1] || 'api';
7
24
  if (!connectionName) {
8
- console.error('Usage: npm run create-connection <connectionName> [type]');
25
+ console.error('Error: Connection name is required.');
26
+ console.log('Usage: npm run create-connection <connectionName> [type]');
9
27
  process.exit(1);
10
28
  }
11
29
  const connectionDir = path.resolve(process.cwd(), 'src/connection');
@@ -2,10 +2,27 @@
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  const args = process.argv.slice(2);
5
+ if (args.includes('--help') || args.includes('-h')) {
6
+ console.log(`
7
+ Usage: npm run create-migration <tableName> [remarks]
8
+
9
+ Arguments:
10
+ tableName The name of the database table (will be used for schema and migration file)
11
+ remarks Optional description of the migration (e.g., 'add_index')
12
+
13
+ Options:
14
+ --help, -h Show this help message
15
+
16
+ Example:
17
+ npm run create-migration users initial_schema
18
+ `);
19
+ process.exit(0);
20
+ }
5
21
  const tableName = args[0];
6
22
  const remarks = args[1] || '';
7
23
  if (!tableName) {
8
- console.error('Usage: npm run create-migration <tableName> [remarks]');
24
+ console.error('Error: Table name is required.');
25
+ console.log('Usage: npm run create-migration <tableName> [remarks]');
9
26
  process.exit(1);
10
27
  }
11
28
  // Ensure directories exist
@@ -28,8 +45,10 @@ import { Mapper, TableMigrator } from '@neupgroup/mapper';
28
45
 
29
46
  export async function up() {
30
47
  // const table = Mapper.schemas().table('${tableName}');
31
- // table.addColumn('id').type('int').isPrimary().autoIncrement().exec();
48
+ // table.useConnection('default');
49
+ // table.addColumn('id').type('int').isPrimary().autoIncrement();
32
50
  // ... add more columns
51
+ // await table.exec();
33
52
  console.log('Migrating up: ${tableName}');
34
53
  }
35
54
 
@@ -2,6 +2,24 @@
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  const args = process.argv.slice(2);
5
+ if (args.includes('--help') || args.includes('-h')) {
6
+ console.log(`
7
+ Usage: npm run migrate [command]
8
+
9
+ Commands:
10
+ up Run all pending migrations (default)
11
+ down Roll back the last completed migration
12
+
13
+ Options:
14
+ --help, -h Show this help message
15
+
16
+ Description:
17
+ This command will look for migration files in src/migration,
18
+ load database connections from src/connection, and execute
19
+ pending changes on your database while updating local schema files.
20
+ `);
21
+ process.exit(0);
22
+ }
5
23
  const command = args[0] || 'up'; // 'up' or 'down'
6
24
  const migrationDir = path.resolve(process.cwd(), 'src/migration');
7
25
  const indexFilePath = path.join(migrationDir, 'index.ts');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neupgroup/mapper",
3
- "version": "1.5.0",
4
3
  "description": "Neup.Mapper core library for schema and mapping utilities",
4
+ "version": "1.5.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",