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
11 changes: 11 additions & 0 deletions src/commands/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ import {
createSnapshotMissionControl,
deleteSnapshotMissionControl,
downloadSnapshotMissionControl,
listSnapshotMissionControl,
restoreSnapshotMissionControl,
uploadSnapshotMissionControl
} from '../services/modules/snapshot/snapshot.mission-control.services';
import {
createSnapshotOrbiter,
deleteSnapshotOrbiter,
downloadSnapshotOrbiter,
listSnapshotOrbiter,
restoreSnapshotOrbiter,
uploadSnapshotOrbiter
} from '../services/modules/snapshot/snapshot.orbiter.services';
import {
createSnapshotSatellite,
deleteSnapshotSatellite,
downloadSnapshotSatellite,
listSnapshotSatellite,
restoreSnapshotSatellite,
uploadSnapshotSatellite
} from '../services/modules/snapshot/snapshot.satellite.services';
Expand All @@ -44,6 +47,14 @@ export const snapshot = async (args?: string[]) => {
orbiterFn: restoreSnapshotOrbiter
});
break;
case 'list':
await executeSnapshotFn({
args,
satelliteFn: listSnapshotSatellite,
missionControlFn: listSnapshotMissionControl,
orbiterFn: listSnapshotOrbiter
});
break;
case 'delete':
await executeSnapshotFn({
args,
Expand Down
1 change: 1 addition & 0 deletions src/help/snapshot.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Subcommands:
${magenta('create')} Create a snapshot of your current state.
${magenta('delete')} Delete an existing snapshot.
${magenta('download')} Download a snapshot to offline files.
${magenta('list')} List the existing snapshot.
${magenta('upload')} ${SNAPSHOT_UPLOAD_DESCRIPTION}
${magenta('restore')} Restore a previously created snapshot.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createSnapshot,
deleteSnapshot,
downloadSnapshot,
listSnapshot,
restoreSnapshot,
uploadSnapshot
} from './snapshot.services';
Expand All @@ -22,6 +23,12 @@ export const restoreSnapshotMissionControl = async () => {
});
};

export const listSnapshotMissionControl = async () => {
await executeSnapshotFn({
fn: listSnapshot
});
};

export const deleteSnapshotMissionControl = async () => {
await executeSnapshotFn({
fn: deleteSnapshot
Expand Down
7 changes: 7 additions & 0 deletions src/services/modules/snapshot/snapshot.orbiter.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createSnapshot,
deleteSnapshot,
downloadSnapshot,
listSnapshot,
restoreSnapshot,
uploadSnapshot
} from './snapshot.services';
Expand All @@ -20,6 +21,12 @@ export const restoreSnapshotOrbiter = async () => {
});
};

export const listSnapshotOrbiter = async () => {
await executeSnapshotFn({
fn: listSnapshot
});
};

export const deleteSnapshotOrbiter = async () => {
await executeSnapshotFn({
fn: deleteSnapshot
Expand Down
7 changes: 7 additions & 0 deletions src/services/modules/snapshot/snapshot.satellite.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createSnapshot,
deleteSnapshot,
downloadSnapshot,
listSnapshot,
restoreSnapshot,
uploadSnapshot
} from './snapshot.services';
Expand All @@ -23,6 +24,12 @@ export const restoreSnapshotSatellite = async () => {
});
};

export const listSnapshotSatellite = async () => {
await executeSnapshotFn({
fn: listSnapshot
});
};

export const deleteSnapshotSatellite = async () => {
await executeSnapshotFn({
fn: deleteSnapshot
Expand Down
20 changes: 20 additions & 0 deletions src/services/modules/snapshot/snapshot.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ export const restoreSnapshot = async ({
});
};

export const listSnapshot = async ({
canisterId: cId,
segment
}: {
canisterId: string;
segment: AssetKey;
}) => {
const canisterId = Principal.fromText(cId);

const result = await loadSnapshotAndAssertExist({canisterId, segment});

if (result.result === 'not_found') {
return;
}

const {snapshotId: existingSnapshotId} = result;

console.log(`🪣 Snapshot found: 0x${encodeSnapshotId(existingSnapshotId)}`);
};

export const deleteSnapshot = async ({
canisterId: cId,
segment
Expand Down
Loading