diff --git a/src/commands/diffSnaphots.ts b/src/commands/diffSnaphots.ts index 40ff7d8..2a06b90 100644 --- a/src/commands/diffSnaphots.ts +++ b/src/commands/diffSnaphots.ts @@ -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 @@ -21,4 +22,21 @@ export function addCommand(program: Command) { console.log(content); } }); + + program + .command('diff-storage') + .description('generate a storage diff') + .argument('') + .argument('') + .option('-o, --out ', '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); + } + }); }