Skip to content

Commit

Permalink
feat: add storage diff (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 25, 2024
1 parent a064ff0 commit cf8d917
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/commands/diffSnaphots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Command } from '@commander-js/extra-typings';
import { diffReports } from '../reports/diff-reports';
import { readJsonString, readJsonFile } from '../utils/json';
import fs from 'fs';
import { compareStorageLayouts } from '@bgd-labs/js-utils';

export function addCommand(program: Command) {
program
Expand All @@ -21,4 +22,21 @@ export function addCommand(program: Command) {
console.log(content);
}
});

program
.command('diff-storage')
.description('generate a storage diff')
.argument('<from>')
.argument('<to>')
.option('-o, --out <string>', 'output path')
.action(async (_from, _to, options) => {
const from = readJsonFile(_from);
const to = readJsonFile(_to);
const content = await compareStorageLayouts(from, to);
if (options.out) {
fs.writeFileSync(options.out, content);
} else {
console.log(content);
}
});
}

0 comments on commit cf8d917

Please sign in to comment.