Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"packageManager": "pnpm@8.10.2",
"dependencies": {
"@rushstack/ts-command-line": "^4.12.2",
"@rushstack/ts-command-line": "^5.3.3",
"emittery": "^0.13.0",
"pony-cause": "^2.1.4",
"tinyglobby": "^0.2.13",
Expand Down
133 changes: 83 additions & 50 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 8 additions & 22 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class UpAction extends cli.CommandLineAction {
summary: 'Applies pending migrations',
documentation: 'Performs all migrations. See --help for more options',
})
this._params = UpAction._defineParameters(this)
}

private static _defineParameters(action: UpAction) {
Expand Down Expand Up @@ -39,11 +40,7 @@ export class UpAction extends cli.CommandLineAction {
}
}

onDefineParameters(): void {
this._params = UpAction._defineParameters(this)
}

async onExecute(): Promise<void> {
async onExecuteAsync(): Promise<void> {
const {
to: {value: to},
step: {value: step},
Expand Down Expand Up @@ -86,6 +83,7 @@ export class DownAction extends cli.CommandLineAction {
documentation:
'Undoes previously-applied migrations. By default, undoes the most recent migration only. Use --help for more options. Useful in development to start from a clean slate. Use with care in production!',
})
this._params = DownAction._defineParameters(this)
}

private static _defineParameters(action: DownAction) {
Expand Down Expand Up @@ -115,11 +113,7 @@ export class DownAction extends cli.CommandLineAction {
}
}

onDefineParameters(): void {
this._params = DownAction._defineParameters(this)
}

async onExecute(): Promise<void> {
async onExecuteAsync(): Promise<void> {
const {
to: {value: to},
step: {value: step},
Expand Down Expand Up @@ -169,6 +163,7 @@ export class ListAction extends cli.CommandLineAction {
summary: `Lists ${action} migrations`,
documentation: `Prints migrations returned by \`umzug.${action}()\`. By default, prints migration names one per line.`,
})
this._params = ListAction._defineParameters(this)
}

private static _defineParameters(action: cli.CommandLineAction) {
Expand All @@ -182,11 +177,7 @@ export class ListAction extends cli.CommandLineAction {
}
}

onDefineParameters(): void {
this._params = ListAction._defineParameters(this)
}

async onExecute(): Promise<void> {
async onExecuteAsync(): Promise<void> {
const migrations = await this.umzug[this.action]()
const formatted = this._params.json.value
? JSON.stringify(migrations, null, 2)
Expand All @@ -206,6 +197,7 @@ export class CreateAction extends cli.CommandLineAction {
documentation:
'Generates a placeholder migration file using a timestamp as a prefix. By default, mimics the last existing migration, or guesses where to generate the file if no migration exists yet.',
})
this._params = CreateAction._defineParameters(this)
}

private static _defineParameters(action: cli.CommandLineAction) {
Expand Down Expand Up @@ -251,11 +243,7 @@ export class CreateAction extends cli.CommandLineAction {
}
}

onDefineParameters(): void {
this._params = CreateAction._defineParameters(this)
}

async onExecute(): Promise<void> {
async onExecuteAsync(): Promise<void> {
await this.umzug
.create({
name: this._params.name.value,
Expand Down Expand Up @@ -299,6 +287,4 @@ export class UmzugCLI extends cli.CommandLineParser {
this.addAction(new ListAction('executed', umzug))
this.addAction(new CreateAction(umzug))
}

onDefineParameters(): void {}
}
2 changes: 1 addition & 1 deletion src/umzug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class Umzug<Ctx extends object = object> extends emittery<UmzugEvents<Ctx
*/
async runAsCLI(argv?: string[]): Promise<boolean> {
const cli = this.getCli()
return cli.execute(argv)
return cli.executeAsync(argv)
}

/** Get the list of migrations which have already been applied */
Expand Down
Loading
Loading