Skip to content

Commit 02b2d57

Browse files
committed
style: format files
1 parent a9a32e9 commit 02b2d57

File tree

9 files changed

+34
-34
lines changed

9 files changed

+34
-34
lines changed

packages/cli/src/actions/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default async function start(options: {
7373

7474
try {
7575
await new Promise((resolve, reject) =>
76-
watcher.on("error", reject).on("all", safeSync)
76+
watcher.on("error", reject).on("all", safeSync),
7777
);
7878
} finally {
7979
clearInterval(interval);

packages/cli/src/actions/sync.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { green, cyan, grey, red } from "chalk";
66
function log(
77
type: "error" | "success" | "info" | "debug",
88
alias: string,
9-
message: string
9+
message: string,
1010
) {
1111
const colorize = {
1212
error: red,
@@ -69,7 +69,7 @@ export default async function sync(options: {
6969
}
7070
const driver = drivers[alias];
7171
const accounts = config.accounts[alias].sort(
72-
(a, b) => (b.createDatabase ? 1 : 0) - (a.createDatabase ? 1 : 0)
72+
(a, b) => (b.createDatabase ? 1 : 0) - (a.createDatabase ? 1 : 0),
7373
);
7474
for (const account of accounts) {
7575
log("info", alias, `Syncing ${account.username}`);

packages/cli/src/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ export default () => {
4545
.option(
4646
"-c,--config-path [path]",
4747
"Config path",
48-
"./sql-controller.config.json"
48+
"./sql-controller.config.json",
4949
);
5050
program.command("check").action(
5151
makeAction(async () => {
5252
const globalOptions = getGlobalOptions();
5353
return await check(globalOptions);
54-
})
54+
}),
5555
);
5656
program.command("start").action(
5757
makeAction(async () => {
5858
const globalOptions = getGlobalOptions();
5959
return await start(globalOptions);
60-
})
60+
}),
6161
);
6262
program.command("sync").action(
6363
makeAction(async () => {
6464
const globalOptions = getGlobalOptions();
6565
return await sync(globalOptions);
66-
})
66+
}),
6767
);
6868
return program;
6969
};

packages/cli/src/drivers/DriverAbstract.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ export abstract class DriverAbstract {
5252
abstract createUser(options: CreateUserOptions): Promise<void>;
5353
abstract createDatabase(options: CreateDatabaseOptions): Promise<void>;
5454
abstract createDatabasePermission(
55-
options: CreateDatabasePermissionOptions
55+
options: CreateDatabasePermissionOptions,
5656
): Promise<void>;
5757
abstract checkLogin(options: CheckLoginOptions): Promise<boolean>;
5858
abstract checkDatabase(database: string): Promise<boolean>;
5959
abstract checkDatabasePermission(
60-
options: CheckDatabasePermissionOptions
60+
options: CheckDatabasePermissionOptions,
6161
): Promise<boolean>;
6262
abstract checkUser(username: string): Promise<boolean>;
6363
abstract query(input: string): Promise<unknown>;

packages/cli/src/drivers/MysqlDriver.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export default class MysqlDriver extends DriverAbstract {
1515
const password = await parsePassword(options.password);
1616
const { username } = options;
1717
await this.query(
18-
`CREATE USER '${username}'@'%' IDENTIFIED BY '${password}';`
18+
`CREATE USER '${username}'@'%' IDENTIFIED BY '${password}';`,
1919
);
2020
if (options.root)
2121
await this.query(
22-
`GRANT ALL PRIVILEGES ON *.* TO '${username}'@'%' WITH GRANT OPTION;`
22+
`GRANT ALL PRIVILEGES ON *.* TO '${username}'@'%' WITH GRANT OPTION;`,
2323
);
2424
}
2525

@@ -29,17 +29,17 @@ export default class MysqlDriver extends DriverAbstract {
2929
: "";
3030
const collateExpr = options.collate ? ` COLLATE ${options.collate}` : "";
3131
await this.query(
32-
`CREATE DATABASE ${options.database} ${charsetExpr}${collateExpr};`
32+
`CREATE DATABASE ${options.database} ${charsetExpr}${collateExpr};`,
3333
);
3434
}
3535

3636
override async createDatabasePermission(
37-
options: CreateDatabasePermissionOptions
37+
options: CreateDatabasePermissionOptions,
3838
) {
3939
await this.query(
4040
`GRANT ${options.type?.join(", ") ?? "ALL"} ON ${
4141
options.database
42-
}.* TO '${options.username}'@'${options.host ?? "%"}';`
42+
}.* TO '${options.username}'@'${options.host ?? "%"}';`,
4343
);
4444
}
4545

@@ -65,7 +65,7 @@ export default class MysqlDriver extends DriverAbstract {
6565
database: string,
6666
options?: {
6767
globalOptions?: GlobalOptions;
68-
}
68+
},
6969
) {
7070
const result = await this.query(`SHOW DATABASES LIKE '${database}';`, {
7171
skipColumnNames: true,
@@ -84,14 +84,14 @@ export default class MysqlDriver extends DriverAbstract {
8484
`SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = '${username}') AS 'exists'`,
8585
{
8686
skipColumnNames: true,
87-
}
87+
},
8888
);
8989
const [row] = result.stdout.split(/\r?\n/g);
9090
return row === "1";
9191
}
9292

9393
override async checkDatabasePermission(
94-
options: CheckDatabasePermissionOptions
94+
options: CheckDatabasePermissionOptions,
9595
) {
9696
return await this.checkDatabase(options.database, {
9797
globalOptions: {
@@ -108,7 +108,7 @@ export default class MysqlDriver extends DriverAbstract {
108108
globalOptions?: GlobalOptions;
109109
skipColumnNames?: boolean;
110110
exec?: ExecExtraOptions;
111-
} = {}
111+
} = {},
112112
) {
113113
const globalOptions = options.globalOptions || this.globalOptions;
114114
return await exec(
@@ -129,7 +129,7 @@ export default class MysqlDriver extends DriverAbstract {
129129
log: true,
130130
}),
131131
//logInput: options.exec?.logInput ?? input,
132-
}
132+
},
133133
);
134134
}
135135
}

packages/cli/src/drivers/PostgresDriver.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class PostgresDriver extends DriverAbstract {
1515
const password = await parsePassword(options.password);
1616
const { username } = options;
1717
await this.query(
18-
`CREATE USER "${username}" WITH ENCRYPTED PASSWORD '${password}';`
18+
`CREATE USER "${username}" WITH ENCRYPTED PASSWORD '${password}';`,
1919
);
2020
if (options.root) await this.query(`ALTER ROLE "${username}" SUPERUSER;`);
2121
}
@@ -25,10 +25,10 @@ export default class PostgresDriver extends DriverAbstract {
2525
}
2626

2727
override async createDatabasePermission(
28-
options: CreateDatabasePermissionOptions
28+
options: CreateDatabasePermissionOptions,
2929
) {
3030
await this.query(
31-
`GRANT ALL PRIVILEGES ON DATABASE ${options.database} TO ${options.username};`
31+
`GRANT ALL PRIVILEGES ON DATABASE ${options.database} TO ${options.username};`,
3232
);
3333
}
3434

@@ -55,7 +55,7 @@ export default class PostgresDriver extends DriverAbstract {
5555
database: string,
5656
options?: {
5757
globalOptions?: GlobalOptions;
58-
}
58+
},
5959
) {
6060
const result = await this.query(
6161
`SELECT datname FROM pg_database WHERE datname = '${database}';`,
@@ -66,14 +66,14 @@ export default class PostgresDriver extends DriverAbstract {
6666
throwExitCode: (error, result) =>
6767
!result.stderr.includes("error: connection to server"),
6868
},
69-
}
69+
},
7070
);
7171
const [row] = result.stdout.split(/\r?\n/g);
7272
return row.trim() === database;
7373
}
7474

7575
override async checkDatabasePermission(
76-
options: CheckDatabasePermissionOptions
76+
options: CheckDatabasePermissionOptions,
7777
) {
7878
return await this.checkDatabase(options.database, {
7979
globalOptions: {
@@ -88,7 +88,7 @@ export default class PostgresDriver extends DriverAbstract {
8888
`SELECT usename FROM pg_catalog.pg_user WHERE usename = '${username}'`,
8989
{
9090
skipColumnNames: true,
91-
}
91+
},
9292
);
9393
const [row] = result.stdout.split(/\r?\n/g);
9494
return row.trim() === username;
@@ -101,7 +101,7 @@ export default class PostgresDriver extends DriverAbstract {
101101
globalOptions?: GlobalOptions;
102102
skipColumnNames?: boolean;
103103
exec?: ExecExtraOptions;
104-
} = {}
104+
} = {},
105105
) {
106106
const globalOptions = options.globalOptions || this.globalOptions;
107107

@@ -128,7 +128,7 @@ export default class PostgresDriver extends DriverAbstract {
128128
log: true,
129129
}),
130130
logInput: options.exec?.logInput ?? input,
131-
}
131+
},
132132
);
133133
}
134134
}

packages/cli/src/drivers/createDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PostgresDriver from "./PostgresDriver";
44

55
export function createDriver(
66
name: "mysql" | "postgres",
7-
globalOptions: GlobalOptions
7+
globalOptions: GlobalOptions,
88
) {
99
if (name === "mysql") {
1010
return new MysqlDriver(globalOptions);

packages/cli/src/utils/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export async function exec(
2323
command: string,
2424
args: string[],
2525
options?: SpawnOptions,
26-
extraOptions: ExecExtraOptions = {}
26+
extraOptions: ExecExtraOptions = {},
2727
) {
2828
if (extraOptions.log)
2929
console.log(
3030
"+",
31-
yellow(extraOptions.logInput ?? `${command} ${args.join(" ")}`)
31+
yellow(extraOptions.logInput ?? `${command} ${args.join(" ")}`),
3232
);
3333
return new Promise<{
3434
exitCode: number;
@@ -51,8 +51,8 @@ export async function exec(
5151
{
5252
stdio: ["inherit", "pipe", "pipe"],
5353
} as SpawnOptions,
54-
options
55-
)
54+
options,
55+
),
5656
);
5757
p.stdout?.on("data", (chunk: Buffer) => {
5858
result.stdout += chunk.toString();

packages/cli/src/utils/self/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parseJsonFile } from "../fs";
22
import Ajv from "ajv";
3-
import { JSONSchema7 } from "json-schema";
3+
import type { JSONSchema7 } from "json-schema";
44

55
const ajv = new Ajv();
66

0 commit comments

Comments
 (0)