Skip to content

Commit dc8dd28

Browse files
committed
wip
1 parent 1bba3ee commit dc8dd28

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

packages/cli/src/commands/migrate/deps.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getPgEnvOptions } from 'pg-env';
55
import { Logger } from '@launchql/logger';
66
import { join } from 'path';
77
import { existsSync } from 'fs';
8-
import { parsePlanFile, getChangesInOrder } from '@launchql/migrate';
8+
import { parsePlanFile } from '@launchql/migrate';
99
import { getTargetDatabase } from '../../utils/database';
1010

1111
const log = new Logger('migrate-deps');
@@ -22,8 +22,15 @@ export default async (argv: Partial<ParsedArgs>, prompter: Inquirerer, options:
2222
// Get specific change to analyze
2323
let changeName = argv._?.[0] || argv.change;
2424

25-
const plan = parsePlanFile(planPath);
26-
const allChanges = getChangesInOrder(planPath);
25+
const planResult = parsePlanFile(planPath);
26+
27+
if (!planResult.data || planResult.errors.length > 0) {
28+
log.error('Failed to parse plan file:', planResult.errors);
29+
process.exit(1);
30+
}
31+
32+
const plan = planResult.data;
33+
const allChanges = plan.changes;
2734

2835
// If no change specified, prompt
2936
if (!changeName && !argv.all) {

packages/cli/src/commands/migrate/list.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getPgEnvOptions } from 'pg-env';
55
import { Logger } from '@launchql/logger';
66
import { join } from 'path';
77
import { existsSync } from 'fs';
8-
import { parsePlanFile, getChangesInOrder } from '@launchql/migrate';
8+
import { parsePlanFile } from '@launchql/migrate';
99
import { getTargetDatabase } from '../../utils/database';
1010

1111
const log = new Logger('migrate-list');
@@ -35,8 +35,15 @@ export default async (argv: Partial<ParsedArgs>, prompter: Inquirerer, options:
3535

3636
try {
3737
// Get all changes from plan file
38-
const plan = parsePlanFile(planPath);
39-
const allChanges = getChangesInOrder(planPath);
38+
const planResult = parsePlanFile(planPath);
39+
40+
if (!planResult.data || planResult.errors.length > 0) {
41+
log.error('Failed to parse plan file:', planResult.errors);
42+
process.exit(1);
43+
}
44+
45+
const plan = planResult.data;
46+
const allChanges = plan.changes;
4047

4148
// Get deployed changes from database
4249
const deployedChanges = await client.getDeployedChanges(targetDatabase, plan.project);

packages/cli/src/commands/migrate/status.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ export default async (argv: Partial<ParsedArgs>, prompter: Inquirerer, options:
3434

3535
try {
3636
// Parse plan file to get project name
37-
const plan = parsePlanFile(planPath);
37+
const planResult = parsePlanFile(planPath);
38+
39+
if (!planResult.data || planResult.errors.length > 0) {
40+
log.error('Failed to parse plan file:', planResult.errors);
41+
process.exit(1);
42+
}
43+
44+
const plan = planResult.data;
3845

3946
// Switch to target database
4047
const targetClient = new LaunchQLMigrate({

0 commit comments

Comments
 (0)