File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# @compass-aiden/migrate-cli
22
3- > 数据库迁移工具 - 支持PostgreSQL、MySQL等多种数据库的版本管理CLI工具
3+ > 数据库迁移工具 - 支持多种数据库的版本管理CLI工具
44
55## 功能特性
66
Original file line number Diff line number Diff line change 11{
22 "name" : " @compass-aiden/migrate-cli" ,
3- "description" : " DB迁移工具 " ,
3+ "description" : " 数据库迁移工具 - 支持多种数据库的版本管理CLI工具 " ,
44 "version" : " 0.0.3" ,
55 "type" : " module" ,
66 "main" : " index.js" ,
1111 " dist" ,
1212 " index.js"
1313 ],
14- "author" : " " ,
15- "repository" : " " ,
14+ "author" : " Aiden <aiden_jin@outlook.com>" ,
15+ "repository" : " https://github.com/Aiden-FE/migrate-cli" ,
16+ "homepage" : " https://github.com/Aiden-FE/migrate-cli/blob/master/README.md" ,
1617 "license" : " MIT" ,
1718 "publishConfig" : {
1819 "registry" : " https://registry.npmjs.org/" ,
1920 "access" : " public"
2021 },
2122 "keywords" : [
22- " commander" ,
23- " command-line" ,
24- " commandline" ,
23+ " nodejs" ,
2524 " terminal" ,
26- " cli"
25+ " mysql" ,
26+ " schema-migrations" ,
27+ " postgres" ,
28+ " command-line" ,
29+ " database-migrations" ,
30+ " cli-tool" ,
31+ " database-versioning"
2732 ],
2833 "scripts" : {
2934 "dev" : " rollup -w -c rollup.config.js" ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export type DBConnectorOptions = PostgresConnectorOptions | MySQLConnectorOption
1616export abstract class BaseClient {
1717 abstract connect ( ) : Promise < void > ;
1818 abstract disconnect ( ) : Promise < void > ;
19- abstract execute ( sql : string , params ?: any [ ] ) : Promise < any > ;
19+ abstract query ( sql : string , params ?: any [ ] ) : Promise < any > ;
2020 abstract transaction ( callback : ( client : unknown ) => Promise < void > ) : Promise < void > ;
2121 abstract checkMigrationsTable ( ) : Promise < void > ;
2222 abstract checkTaskExecuted ( taskName : string ) : Promise < boolean > ;
Original file line number Diff line number Diff line change 11import { Command } from 'commander' ;
22import figlet from 'figlet' ;
33import chalk from 'chalk' ;
4- import { readFileSync } from 'fs' ;
4+ import { readFileSync } from 'node:fs' ;
5+ import path from 'node:path' ;
56import * as allCommands from './commands' ;
67import { Logger } from './utils' ;
8+ import { fileURLToPath } from 'node:url' ;
9+ import { dirname } from 'node:path' ;
710
8- const pkg = JSON . parse ( readFileSync ( './package.json' , 'utf8' ) ) ;
9-
11+ const filename = fileURLToPath ( import . meta. url ) ;
12+ const currentDirname = dirname ( filename ) ;
13+ const pkg = JSON . parse ( readFileSync ( path . resolve ( currentDirname , '../package.json' ) , 'utf8' ) ) ;
1014export default ( ) => {
1115 const program = new Command ( ) ;
1216
@@ -15,7 +19,7 @@ export default () => {
1519
1620 program
1721 . version ( `v${ pkg . version } ` , '-v, --version' )
18- . description ( 'Command line interfaces ' )
22+ . description ( '数据库迁移工具 - 支持多种数据库的版本管理CLI工具 ' )
1923 . usage ( '<command> [option]' )
2024 . on ( '--help' , ( ) => {
2125 Logger . log ( `\r\n${ figlet . textSync ( pkg . name ) } ` ) ;
Original file line number Diff line number Diff line change @@ -49,8 +49,8 @@ export default class MySQLConnector extends Client {
4949 await this . client . end ( ) ;
5050 }
5151
52- async execute ( sql : string , params ?: any [ ] ) : Promise < any > {
53- return this . client . execute ( sql , params ) ;
52+ async query ( sql : string , params ?: any [ ] ) : Promise < any > {
53+ return this . client . query ( sql , params ) ;
5454 }
5555
5656 async transaction ( callback : ( connection : Connection ) => Promise < void > ) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export default class PostgresConnector extends Client {
1919 await this . client . end ( ) ;
2020 }
2121
22- async execute ( sql : string , params ?: any [ ] ) : Promise < any > {
22+ async query ( sql : string , params ?: any [ ] ) : Promise < any > {
2323 return this . client . query ( sql , params ) ;
2424 }
2525
You can’t perform that action at this time.
0 commit comments