Skip to content

Commit 1169a1c

Browse files
committed
fix(update): 修复版本检查工具不正确的问题
1 parent a4e7093 commit 1169a1c

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @compass-aiden/migrate-cli
22

3-
> 数据库迁移工具 - 支持PostgreSQL、MySQL等多种数据库的版本管理CLI工具
3+
> 数据库迁移工具 - 支持多种数据库的版本管理CLI工具
44
55
## 功能特性
66

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",
@@ -11,19 +11,24 @@
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",

src/interfaces/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type DBConnectorOptions = PostgresConnectorOptions | MySQLConnectorOption
1616
export 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>;

src/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { Command } from 'commander';
22
import figlet from 'figlet';
33
import chalk from 'chalk';
4-
import { readFileSync } from 'fs';
4+
import { readFileSync } from 'node:fs';
5+
import path from 'node:path';
56
import * as allCommands from './commands';
67
import { 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'));
1014
export 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)}`);

src/utils/connectors/mysql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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>) {

src/utils/connectors/postgres.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)