-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: no more readable / writable * fix: table typegen * wip: move data seeding * chore: add scripts to basics * feat: data() -> seed file * refactor: ensure precedence of file name * feat: db execute command * fix: test imports * chore: remove old readable error tests * feat: support local db with `db execute` * refactor: remove integrations from test for now * chore: stray comment * chore: remove `table` config object * feat: `db.batch`! * refactor: move migrations/ inside db/ * fix: move ticketing-example to seed file * fix: disable foreign keys when recreating tables * refactor: standardize migrations dir * feat: move to db/config.ts * feat: file watching for db/config.ts dependencies * feat: remove unsafeDisableStudio * chroe: remove bad import * feat: parse config.ts from cli * chore: remove async from localDatabaseClient * fix: update recipes config and seed * chore: update unit tests * chore: update tests to dev server * refactor: collectionToTable -> asDrizzleTable * chore: tidy up collection -> table error states * refactor: regexp -> endsWith * feat: pretty error inserting into table * refactor: try/catch -> catch() * feat: expose utils for integration seed files * fix: add config import to db client modules * fix: just use generic "seeding database" error * chore: remove unused link args * fix: migration queries im,port * chore: remove irrelevant glob/ example * feat: format migration file path * feat: support all config file names * chore: remove db.batch() for now * chore: remove `db` object * core: remove unused integration file * chore: changeset * fix: foreign key empty error message * chore: remove old TODO * fix: bad context reference * refactor: seedDev -> seedLocal * wip: throw some console logs at github * wip: avoid seeding astro:db imported by seed file * wip: use anything in db/ * refactor: only seed when loaded within srcDir * refactor: avoid resolution when not seeding * chore: remove logs * refactor: seed within create local db client * refactor: use normalizePath * wip: logs * wip: logs * refactor: early return * chore: more logs * refactor: no batch * fix: use beforeAll * refactor: move all tests to base block * wip: log dev server starting * chore: remove logs * wip: demo ready * chore: remove duplicate recreateTables() call * Revert "wip: demo ready" This reverts commit 37585ce. * refactor: beforeEach to isolate dev servers * chore: remove useBundledDbUrl * refactor: naming and seed scope * chore: remove stray console logs * wip: fix windows file import * wip: try fileURLToPath * Revert "wip: try fileURLToPath" This reverts commit 46fd65d. * Revert "wip: fix windows file import" This reverts commit 1a669ea. * refactor: dir -> directory * refactor: move execute file to cli * refactor: remove seed.dev convention * wip: attempt fileURLToPath * wip: debug the file exists * fix: use mjs?? * chore: remove duplicate seedLocal * chore: remove log check * refactor: use in memory db for tests * chore: clean up test comment * fix: avoid file writes for db setup on in memory db * chore: bump db changeset to minor --------- Co-authored-by: Nate Moore <nate@astro.build>
- Loading branch information
1 parent
4b6e2fb
commit 3488be9
Showing
58 changed files
with
1,096 additions
and
1,239 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"astro": patch | ||
"@astrojs/db": minor | ||
--- | ||
|
||
Finalize db API to a shared db/ directory. |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/// <reference types="./config-augment.d.ts" /> | ||
export * from './dist/index.js'; | ||
export { default } from './dist/index.js'; | ||
export { default, cli } from './dist/index.js'; | ||
|
||
declare module 'astro:db' { | ||
export { defineTable, defineDB, column, sql, NOW, TRUE, FALSE } from './dist/index.js'; | ||
} |
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,40 @@ | ||
import type { AstroConfig } from 'astro'; | ||
import type { Arguments } from 'yargs-parser'; | ||
import { MISSING_EXECUTE_PATH_ERROR, FILE_NOT_FOUND_ERROR } from '../../../errors.js'; | ||
import { existsSync } from 'node:fs'; | ||
import { getManagedAppTokenOrExit } from '../../../tokens.js'; | ||
import { type DBConfig } from '../../../types.js'; | ||
import { bundleFile, importBundledFile } from '../../../load-file.js'; | ||
import { getStudioVirtualModContents } from '../../../integration/vite-plugin-db.js'; | ||
|
||
export async function cmd({ | ||
astroConfig, | ||
dbConfig, | ||
flags, | ||
}: { | ||
astroConfig: AstroConfig; | ||
dbConfig: DBConfig; | ||
flags: Arguments; | ||
}) { | ||
const filePath = flags._[4]; | ||
if (typeof filePath !== 'string') { | ||
console.error(MISSING_EXECUTE_PATH_ERROR); | ||
process.exit(1); | ||
} | ||
|
||
const fileUrl = new URL(filePath, astroConfig.root); | ||
if (!existsSync(fileUrl)) { | ||
console.error(FILE_NOT_FOUND_ERROR(filePath)); | ||
process.exit(1); | ||
} | ||
|
||
const appToken = await getManagedAppTokenOrExit(flags.token); | ||
|
||
const virtualModContents = getStudioVirtualModContents({ | ||
tables: dbConfig.tables ?? {}, | ||
appToken: appToken.token, | ||
}); | ||
const { code } = await bundleFile({ virtualModContents, root: astroConfig.root, fileUrl }); | ||
// Executable files use top-level await. Importing will run the file. | ||
await importBundledFile({ code, root: astroConfig.root }); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import { unlink } from 'node:fs/promises'; | ||
import type { AstroConfig } from 'astro'; | ||
import type { Arguments } from 'yargs-parser'; | ||
import { SESSION_LOGIN_FILE } from '../../../tokens.js'; | ||
|
||
export async function cmd({}: { config: AstroConfig; flags: Arguments }) { | ||
export async function cmd() { | ||
await unlink(SESSION_LOGIN_FILE); | ||
console.log('Successfully logged out of Astro Studio.'); | ||
} |
Oops, something went wrong.