mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
feat: Utils to do bindLan and have ipv4 and ipv6 if need be
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { setupActions } from "../../actions/setupActions";
|
||||
import { EmVer } from "../../emverLite/mod";
|
||||
import { GenericManifest } from "../../manifest/ManifestTypes";
|
||||
import { ExpectedExports } from "../../types";
|
||||
import { once } from "../../util/once";
|
||||
import { Migration } from "./Migration";
|
||||
import { setupActions } from "../../actions/setupActions"
|
||||
import { EmVer } from "../../emverLite/mod"
|
||||
import { GenericManifest } from "../../manifest/ManifestTypes"
|
||||
import { ExpectedExports } from "../../types"
|
||||
import { once } from "../../util/once"
|
||||
import { Migration } from "./Migration"
|
||||
|
||||
export class Migrations {
|
||||
private constructor(
|
||||
@@ -13,27 +13,27 @@ export class Migrations {
|
||||
private sortedMigrations = once(() => {
|
||||
const migrationsAsVersions = (this.migrations as Array<Migration<any>>).map(
|
||||
(x) => [EmVer.parse(x.options.version), x] as const,
|
||||
);
|
||||
migrationsAsVersions.sort((a, b) => a[0].compareForSort(b[0]));
|
||||
return migrationsAsVersions;
|
||||
});
|
||||
private currentVersion = once(() => EmVer.parse(this.manifest.version));
|
||||
)
|
||||
migrationsAsVersions.sort((a, b) => a[0].compareForSort(b[0]))
|
||||
return migrationsAsVersions
|
||||
})
|
||||
private currentVersion = once(() => EmVer.parse(this.manifest.version))
|
||||
static of<Migrations extends Array<Migration<any>>>(
|
||||
manifest: GenericManifest,
|
||||
...migrations: EnsureUniqueId<Migrations>
|
||||
) {
|
||||
return new Migrations(manifest, migrations as Array<Migration<any>>);
|
||||
return new Migrations(manifest, migrations as Array<Migration<any>>)
|
||||
}
|
||||
async init({
|
||||
effects,
|
||||
previousVersion,
|
||||
}: Parameters<ExpectedExports.init>[0]) {
|
||||
if (!!previousVersion) {
|
||||
const previousVersionEmVer = EmVer.parse(previousVersion);
|
||||
const previousVersionEmVer = EmVer.parse(previousVersion)
|
||||
for (const [_, migration] of this.sortedMigrations()
|
||||
.filter((x) => x[0].greaterThan(previousVersionEmVer))
|
||||
.filter((x) => x[0].lessThanOrEqual(this.currentVersion()))) {
|
||||
await migration.up({ effects });
|
||||
await migration.up({ effects })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,12 +42,12 @@ export class Migrations {
|
||||
nextVersion,
|
||||
}: Parameters<ExpectedExports.uninit>[0]) {
|
||||
if (!!nextVersion) {
|
||||
const nextVersionEmVer = EmVer.parse(nextVersion);
|
||||
const reversed = [...this.sortedMigrations()].reverse();
|
||||
const nextVersionEmVer = EmVer.parse(nextVersion)
|
||||
const reversed = [...this.sortedMigrations()].reverse()
|
||||
for (const [_, migration] of reversed
|
||||
.filter((x) => x[0].greaterThan(nextVersionEmVer))
|
||||
.filter((x) => x[0].lessThanOrEqual(this.currentVersion()))) {
|
||||
await migration.down({ effects });
|
||||
await migration.down({ effects })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ export function setupMigrations<Migrations extends Array<Migration<any>>>(
|
||||
manifest: GenericManifest,
|
||||
...migrations: EnsureUniqueId<Migrations>
|
||||
) {
|
||||
return Migrations.of(manifest, ...migrations);
|
||||
return Migrations.of(manifest, ...migrations)
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
|
||||
Reference in New Issue
Block a user