Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/components/MigrationRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MAX_SETTLED = 500;
export type SettleStatus = 'created' | 'synced' | 'skipped' | 'failed';

export type ProgressBarStats = {
created: number;
saved: number;
skipped: number;
failed: number;
retrying?: number;
Expand Down Expand Up @@ -48,9 +48,9 @@ type ViewState = {

function renderBarLine(state: ViewState): string {
const { value, total, stats, eta, columns } = state;
const { created, skipped, failed, retrying } = stats;
const { saved, skipped, failed, retrying } = stats;
const pct = total === 0 ? 0 : Math.round((value / total) * 100);
const suffixPlain = ` ${value}/${total} · ${pct}% · ✓ ${created} ⚠ ${skipped} ✗ ${failed} ⏳ ${retrying} · ETA ${eta}`;
const suffixPlain = ` ${value}/${total} · ${pct}% · ✓ ${saved} ⚠ ${skipped} ✗ ${failed} ⏳ ${retrying} · ETA ${eta}`;
const barWidth = Math.max(5, Math.min(30, columns - suffixPlain.length - 4));
const filled =
total === 0
Expand All @@ -65,7 +65,7 @@ function renderBarLine(state: ViewState): string {
chalk.yellow(`${pct}%`) +
chalk.gray(' · ') +
chalk.green('✓') +
` ${created} ` +
` ${saved} ` +
chalk.yellow('⚠') +
` ${skipped} ` +
chalk.red('✗') +
Expand Down Expand Up @@ -130,7 +130,7 @@ export function migrationRunner(opts: {
total: opts.total,
subheader: opts.subheader,
value: 0,
stats: { created: 0, skipped: 0, failed: 0, retrying: 0 },
stats: { saved: 0, skipped: 0, failed: 0, retrying: 0 },
currentFlag: null,
currentText: '',
settled: [],
Expand Down
10 changes: 5 additions & 5 deletions src/eppo/migrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ async function confirmMigration(
// Local non-null alias so downstream code doesn't need `!` on every call.
const activeRunner: MigrationRunnerHandle = runner;
const settleStats = (): {
created: number;
saved: number;
skipped: number;
failed: number;
} => ({ created, skipped, failed: errored });
} => ({ saved: created + synced, skipped, failed: errored });
const doSkip = (key: string, message: string, reason: string): void => {
skippedFlags.push({ key, reason });
skipped++;
Expand Down Expand Up @@ -669,7 +669,7 @@ async function confirmMigration(
doSync(
dryRun
? `${chalk.dim('[dry run]')} Would sync ${chalk.cyan(flag.key)} (${syncTags.length} tag(s)${variantLabel})`
: `Synced ${chalk.cyan(flag.key)} (${syncTags.length} tag(s)${variantLabel})`,
: `${chalk.green('✓')} Synced ${chalk.cyan(flag.key)} (${syncTags.length} tag(s)${variantLabel})`,
);
continue;
}
Expand Down Expand Up @@ -863,7 +863,7 @@ async function confirmMigration(
const enableLabel =
enabledCount > 0 ? `, enabled in ${enabledCount} env(s)` : '';
doSync(
`Synced ${chalk.cyan(flag.key)} (${syncedAllocCount} targeting filter(s)${syncedRuleLabel}${variantLabel}${tagLabel}${enableLabel})`,
`${chalk.green('✓')} Synced ${chalk.cyan(flag.key)} (${syncedAllocCount} targeting filter(s)${syncedRuleLabel}${variantLabel}${tagLabel}${enableLabel})`,
);
} catch (err) {
const error = formatAxiosError(err);
Expand Down Expand Up @@ -976,7 +976,7 @@ async function confirmMigration(
const enableLabel =
enabledCount > 0 ? `, enabled in ${enabledCount} env(s)` : '';
doCreate(
`Created ${chalk.cyan(flag.key)} (${allFilterLabel}${allRuleLabel}${enableLabel})`,
`${chalk.green('✓')} Created ${chalk.cyan(flag.key)} (${allFilterLabel}${allRuleLabel}${enableLabel})`,
);
} catch (err) {
const error = formatAxiosError(err);
Expand Down
10 changes: 5 additions & 5 deletions src/launchdarkly/migrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,10 @@ async function executeMigration(
});
const activeRunner: MigrationRunnerHandle = runner;
const settleStats = (): {
created: number;
saved: number;
skipped: number;
failed: number;
} => ({ created, skipped, failed: errored });
} => ({ saved: created + synced, skipped, failed: errored });
const doSkip = (key: string, message: string, reason: string): void => {
skippedFlags.push({ key, reason });
skipped++;
Expand Down Expand Up @@ -1330,7 +1330,7 @@ async function executeMigration(
doSync(
dryRun
? `${chalk.dim('[dry run]')} Would sync ${chalk.cyan(flag.key)} (${tagLabel}${variantLabel}${policyLabel})`
: `Synced ${chalk.cyan(flag.key)} (${tagLabel}${variantLabel}${policyLabel})`,
: `${chalk.green('✓')} Synced ${chalk.cyan(flag.key)} (${tagLabel}${variantLabel}${policyLabel})`,
);
continue;
}
Expand Down Expand Up @@ -1546,7 +1546,7 @@ async function executeMigration(
enabledCount > 0 ? `, enabled in ${enabledCount} env(s)` : '';
syncedFlagKeys.push(flag.key);
doSync(
`Synced ${chalk.cyan(flag.key)} (${syncedAllocCount} targeting filter(s)${syncedRuleLabel}${variantLabel}${tagLabel}${enableLabel})`,
`${chalk.green('✓')} Synced ${chalk.cyan(flag.key)} (${syncedAllocCount} targeting filter(s)${syncedRuleLabel}${variantLabel}${tagLabel}${enableLabel})`,
);
} catch (err) {
const error = formatAxiosError(err);
Expand Down Expand Up @@ -1667,7 +1667,7 @@ async function executeMigration(
const enableLabel =
enabledCount > 0 ? `, enabled in ${enabledCount} env(s)` : '';
doCreate(
`Created ${chalk.cyan(ddKey)} (${allFilterLabel}${allRuleLabel}${enableLabel})`,
`${chalk.green('✓')} Created ${chalk.cyan(ddKey)} (${allFilterLabel}${allRuleLabel}${enableLabel})`,
);
} catch (err) {
const error = formatAxiosError(err);
Expand Down
4 changes: 2 additions & 2 deletions tests/migration-runner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ describe('migrationRunner (non-TTY)', () => {
runner.settleFlag({
status: 'created',
message: 'Created foo',
stats: { created: 1, skipped: 0, failed: 0 },
stats: { saved: 1, skipped: 0, failed: 0 },
});
runner.settleFlag({
status: 'failed',
message: 'Failed bar',
stats: { created: 1, skipped: 0, failed: 1 },
stats: { saved: 1, skipped: 0, failed: 1 },
});
expect(writeSpy).toHaveBeenCalledWith('Created foo\n');
expect(writeSpy).toHaveBeenCalledWith('Failed bar\n');
Expand Down