← All procedures

snapshot.diff

Compare current state against a snapshot

CLI
Package
@procedures/snapshot · README
Path
["snapshot","diff"]
CLI
mark snapshot diff --id <string> --bucket <string>
As data
{"$proc":["snapshot","diff"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/snapshot"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["snapshot","diff"], { id: "<id>", bucket: "<bucket>" });
console.log(JSON.stringify(result));

From the command line

$ mark snapshot diff --id <string> --bucket <string>

As data, in a program

{
  "$proc": ["snapshot", "diff"],
  "input": { "id": "<id>", "bucket": "<bucket>" }
}

Input

FieldTypeRequiredDefaultDescription
idstringyesSnapshot ID to compare against
bucketstringyesS3 bucket containing snapshot
pathsstring[]noSpecific paths to compare (default: all)

Output

FieldTypeRequiredDefaultDescription
snapshotMetadataobjectyesThe metadata of the snapshot
repositoriesobject[]yesThe differences of each repository
summaryobjectyesThe summary
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "description": "Snapshot ID to compare against"
      },
      "bucket": {
        "type": "string",
        "description": "S3 bucket containing snapshot"
      },
      "paths": {
        "description": "Specific paths to compare (default: all)",
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "id",
      "bucket"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "snapshotMetadata": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The snapshot id"
          },
          "name": {
            "description": "The name of the snapshot",
            "type": "string"
          },
          "preset": {
            "description": "The preset: light, medium or heavy",
            "type": "string"
          },
          "createdAt": {
            "description": "The time of the snapshot (ISO 8601)",
            "type": "string"
          },
          "environment": {
            "description": "The environment of the snapshot",
            "type": "object",
            "properties": {
              "os": {
                "description": "The operating system",
                "type": "string"
              },
              "nodeVersion": {
                "description": "The Node.js version",
                "type": "string"
              },
              "pnpmVersion": {
                "description": "The pnpm version",
                "type": "string"
              },
              "username": {
                "description": "The user who made the snapshot",
                "type": "string"
              },
              "hostname": {
                "description": "The host name",
                "type": "string"
              }
            },
            "additionalProperties": {}
          },
          "repositories": {
            "description": "The repositories in the snapshot",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "description": "The repository folder, relative to the snapshot root",
                  "type": "string"
                },
                "name": {
                  "description": "The package name",
                  "type": "string"
                },
                "branch": {
                  "description": "The branch at the time of the snapshot",
                  "type": "string"
                },
                "commit": {
                  "description": "The HEAD commit at the time of the snapshot",
                  "type": "string"
                },
                "dirty": {
                  "description": "True when the working tree had changes",
                  "type": "boolean"
                },
                "stashCount": {
                  "description": "The number of stashes",
                  "type": "number"
                },
                "remoteUrl": {
                  "description": "The remote URL",
                  "type": "string"
                },
                "ahead": {
                  "description": "The commits that the remote did not have",
                  "type": "number"
                },
                "behind": {
                  "description": "The commits of the remote that the branch did not have",
                  "type": "number"
                }
              },
              "additionalProperties": {}
            }
          },
          "checksum": {
            "description": "The SHA-256 checksum of the archive",
            "type": "string"
          },
          "archiveSize": {
            "description": "The size of the compressed archive, in bytes",
            "type": "number"
          },
          "description": {
            "description": "The description",
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": {},
        "description": "The metadata of the snapshot"
      },
      "repositories": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "path": {
              "type": "string",
              "description": "The repository folder"
            },
            "branchDiff": {
              "description": "The branch now and in the snapshot, when they differ",
              "type": "object",
              "properties": {
                "current": {
                  "type": "string",
                  "description": "The value now"
                },
                "snapshot": {
                  "type": "string",
                  "description": "The value in the snapshot"
                }
              },
              "required": [
                "current",
                "snapshot"
              ],
              "additionalProperties": {}
            },
            "commitDiff": {
              "description": "The commit now and in the snapshot, when they differ",
              "type": "object",
              "properties": {
                "current": {
                  "type": "string",
                  "description": "The value now"
                },
                "snapshot": {
                  "type": "string",
                  "description": "The value in the snapshot"
                }
              },
              "required": [
                "current",
                "snapshot"
              ],
              "additionalProperties": {}
            },
            "filesChanged": {
              "type": "number",
              "description": "The files changed since the snapshot"
            },
            "newStashes": {
              "type": "number",
              "description": "The stashes made since the snapshot"
            }
          },
          "required": [
            "path",
            "filesChanged",
            "newStashes"
          ],
          "additionalProperties": {}
        },
        "description": "The differences of each repository"
      },
      "summary": {
        "type": "object",
        "properties": {
          "reposChanged": {
            "type": "number",
            "description": "The repositories with differences"
          },
          "totalFilesChanged": {
            "type": "number",
            "description": "The files changed in all repositories"
          },
          "isMatch": {
            "type": "boolean",
            "description": "True when the current state matches the snapshot"
          }
        },
        "required": [
          "reposChanged",
          "totalFilesChanged",
          "isMatch"
        ],
        "additionalProperties": {},
        "description": "The summary"
      }
    },
    "required": [
      "snapshotMetadata",
      "repositories",
      "summary"
    ],
    "additionalProperties": {}
  }
}