-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added source reordering support (#97)
- Loading branch information
Showing
25 changed files
with
1,299 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import useSourcesDatabase from '../dao/sources' | ||
|
||
export async function boot() { | ||
const sourcesDb = useSourcesDatabase() | ||
await sourcesDb.normalizeOrder() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { z } from 'zod' | ||
import { Database } from '../services/database' | ||
|
||
export async function migrate() { | ||
const OldModel = z.object({ | ||
order: z.number().nonnegative().finite().optional(), | ||
title: z.string().min(1), | ||
image: z.string().min(1).nullable() | ||
}) | ||
|
||
const sourcesDb = new Database('sources', OldModel) | ||
const sources = await sourcesDb.all() | ||
await Promise.all( | ||
sources.map(async (source, order) => { | ||
await sourcesDb.update({ order, ...source }) | ||
}) | ||
) | ||
|
||
await sourcesDb.close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { basename } from 'node:path' | ||
import Logger from 'electron-log' | ||
import { z } from 'zod' | ||
|
||
const BootModule = z.object({ | ||
boot: z.function(z.tuple([]), z.unknown()) | ||
}) | ||
|
||
export default function useBootOperations() { | ||
Logger.debug('Loading boot modules') | ||
const bootModules = import.meta.glob('../boot/**/*', { eager: true }) | ||
return async function boot() { | ||
Logger.debug('Starting boot up') | ||
for (const [name, module] of Object.entries(bootModules)) { | ||
const bootable = BootModule.parse(module) | ||
Logger.debug(`Attempting boot: ${basename(name, '.ts')}`) | ||
// eslint-disable-next-line no-await-in-loop -- Design to allow serialization. | ||
await bootable.boot() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.