[Ops] Create SO migration snapshot comparion script (#168623)

## Summary
Continuation on: #167980 

Now that we have the snapshots created for merges, we can compare the
existing snapshots.
This PR creates a CLI for grabbing and comparing these snapshots.

The CLI looks like this: 
```
  node scripts/snapshot_plugin_types compare --from <rev|filename|url> --to <rev|filename|url> [--outputPath <outputPath>]

  Compares two Saved Object snapshot files based on hashes, filenames or urls.

  Options:
    --from            The source snapshot to compare from. Can be a revision, filename or url.
    --to              The target snapshot to compare to. Can be a revision, filename or url.
    --outputPath      The path to write the comparison report to. If omitted, raw JSON will be output to stdout.
    --verbose, -v      Log verbosely
```
This commit is contained in:
Alex Szabo 2023-10-27 11:29:24 +02:00 committed by GitHub
parent 5945ca8ad7
commit 227d7acae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 356 additions and 42 deletions

View file

@ -7,4 +7,31 @@
*/
require('../src/setup_node_env');
require('../src/dev/so_migration/so_migration_cli');
var command = process.argv[2];
switch (command) {
case 'snapshot':
require('../src/dev/so_migration/so_migration_snapshot_cli');
break;
case 'compare':
require('../src/dev/so_migration/so_migration_compare_cli');
break;
default:
printHelp();
break;
}
function printHelp() {
var scriptName = process.argv[1].replace(/^.*scripts\//, 'scripts/');
console.log(`
Usage: node ${scriptName} <command>
Commands:
snapshot - Create a snapshot of the current Saved Object types
compare - Compare two snapshots to reveal changes in Saved Object types
`);
process.exit(0);
}