fix(cli): emit migrate-storage invocation event
This commit is contained in:
parent
e50ce95d0e
commit
58eb015dfc
|
|
@ -52,6 +52,28 @@ describe("ao migrate-storage — activity events", () => {
|
|||
consoleLogSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("emits cli.migration_invoked before migration work starts", async () => {
|
||||
mockMigrateStorage.mockImplementation(async () => {
|
||||
expect(recordedEvents()).toContainEqual(
|
||||
expect.objectContaining({
|
||||
kind: "cli.migration_invoked",
|
||||
source: "cli",
|
||||
level: "info",
|
||||
data: expect.objectContaining({
|
||||
rollback: false,
|
||||
dryRun: true,
|
||||
force: true,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
return { projects: 1 };
|
||||
});
|
||||
|
||||
await program.parseAsync(["node", "ao", "migrate-storage", "--dry-run", "--force"]);
|
||||
|
||||
expect(mockMigrateStorage).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("emits cli.migration_failed when migrateStorage throws", async () => {
|
||||
mockMigrateStorage.mockRejectedValue(new Error("disk full"));
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,18 @@ export function registerMigrateStorage(program: Command): void {
|
|||
.option("--rollback", "Reverse a previous migration (restores .migrated directories)")
|
||||
.action(
|
||||
async (opts: { dryRun?: boolean; force?: boolean; rollback?: boolean }) => {
|
||||
recordActivityEvent({
|
||||
source: "cli",
|
||||
kind: "cli.migration_invoked",
|
||||
level: "info",
|
||||
summary: `storage ${opts.rollback ? "rollback" : "migration"} invoked`,
|
||||
data: {
|
||||
rollback: opts.rollback === true,
|
||||
dryRun: opts.dryRun === true,
|
||||
force: opts.force === true,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
if (opts.rollback) {
|
||||
await rollbackStorage({
|
||||
|
|
|
|||
Loading…
Reference in New Issue