mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
chore: New sdk things
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ok } from "../util";
|
||||
import * as T from "../types";
|
||||
|
||||
export const DEFAULT_OPTIONS: T.BackupOptions = {
|
||||
@@ -41,7 +40,7 @@ export class Backups {
|
||||
|
||||
constructor(
|
||||
private options = DEFAULT_OPTIONS,
|
||||
private backupSet = [] as BackupSet[]
|
||||
private backupSet = [] as BackupSet[],
|
||||
) {}
|
||||
static volumes(...volumeNames: string[]) {
|
||||
return new Backups().addSets(
|
||||
@@ -50,7 +49,7 @@ export class Backups {
|
||||
srcPath: "./",
|
||||
dstPath: `./${srcVolume}/`,
|
||||
dstVolume: Backups.BACKUP,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
static addSets(...options: BackupSet[]) {
|
||||
@@ -73,12 +72,12 @@ export class Backups {
|
||||
srcPath: "./",
|
||||
dstPath: `./${srcVolume}/`,
|
||||
dstVolume: Backups.BACKUP,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
addSets(...options: BackupSet[]) {
|
||||
options.forEach((x) =>
|
||||
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } })
|
||||
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }),
|
||||
);
|
||||
return this;
|
||||
}
|
||||
@@ -99,7 +98,7 @@ export class Backups {
|
||||
.map((x) => x.dstPath)
|
||||
.map((x) => x.replace(/\.\/([^]*)\//, "$1"));
|
||||
const filteredItems = previousItems.filter(
|
||||
(x) => backupPaths.indexOf(x) === -1
|
||||
(x) => backupPaths.indexOf(x) === -1,
|
||||
);
|
||||
for (const itemToRemove of filteredItems) {
|
||||
effects.error(`Trying to remove ${itemToRemove}`);
|
||||
@@ -112,7 +111,7 @@ export class Backups {
|
||||
effects.removeFile({
|
||||
volumeId: Backups.BACKUP,
|
||||
path: itemToRemove,
|
||||
})
|
||||
}),
|
||||
)
|
||||
.catch(() => {
|
||||
effects.warn(`Failed to remove ${itemToRemove} from backup volume`);
|
||||
@@ -135,7 +134,7 @@ export class Backups {
|
||||
})
|
||||
.wait();
|
||||
}
|
||||
return ok;
|
||||
return;
|
||||
};
|
||||
const restoreBackup: T.ExpectedExports.restoreBackup = async ({
|
||||
effects,
|
||||
@@ -160,7 +159,7 @@ export class Backups {
|
||||
})
|
||||
.wait();
|
||||
}
|
||||
return ok;
|
||||
return;
|
||||
};
|
||||
return { createBackup, restoreBackup };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user