diff options
author | 2024-03-07 13:38:43 -0500 | |
---|---|---|
committer | 2024-03-07 13:38:43 -0500 | |
commit | 06fe94e29de97290cb41c4f862ab88f48cda3d4a (patch) | |
tree | 2081ae73b962114cca2fa0a4594d6147c6617ae1 /packages/db/src/core/integration/index.ts | |
parent | 123f6f855129d2272f8619c685a848ee40fe9535 (diff) | |
download | astro-06fe94e29de97290cb41c4f862ab88f48cda3d4a.tar.gz astro-06fe94e29de97290cb41c4f862ab88f48cda3d4a.tar.zst astro-06fe94e29de97290cb41c4f862ab88f48cda3d4a.zip |
Add `--remote` flag for remote connection (#10352)
* feat: check for --remote
* chore: remove bad ticketing example cols
* fix: get seed file working with build
* Revert "fix: get seed file working with build"
This reverts commit 92830a106164b0997c820a3e0bf2a582018084a0.
* fix: seed from build instead of runtime
* refactor: move recreateTables out of runtime
* Revert "refactor: move recreateTables out of runtime"
This reverts commit d01a802ad7915fabc4c4ac35b2d907eae0538d95.
* fix: in-memory db for test fixture
* chore: changeset
* refactor: generate random db name instead
* refactor: use yargs-parser for flag
* chore: remove in-memory db logi
* refactor: rename random id flag for clarity
* feat: support --remote in dev
* feat: support --remote on shell
* refactor: inline db client
* feat: support --remote on db execute
* chore: stray console log
* chore: remove recreateTables from runtime
* chore: update seeding for new signature
* chore: remove unused error imports
Diffstat (limited to 'packages/db/src/core/integration/index.ts')
-rw-r--r-- | packages/db/src/core/integration/index.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index 4361ddfe7..844c684a5 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -14,6 +14,7 @@ import { fileURLIntegration } from './file-url.js'; import { typegen } from './typegen.js'; import { type LateTables, vitePluginDb } from './vite-plugin-db.js'; import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js'; +import parseArgs from 'yargs-parser'; function astroDBIntegration(): AstroIntegration { let connectToStudio = false; @@ -40,7 +41,8 @@ function astroDBIntegration(): AstroIntegration { if (command === 'preview') return; let dbPlugin: VitePlugin | undefined = undefined; - connectToStudio = command === 'build'; + const args = parseArgs(process.argv.slice(3)); + connectToStudio = args['remote']; if (connectToStudio) { appToken = await getManagedAppTokenOrExit(); @@ -68,6 +70,8 @@ function astroDBIntegration(): AstroIntegration { }); }, 'astro:config:done': async ({ config }) => { + if (command === 'preview') return; + // TODO: refine where we load tables // @matthewp: may want to load tables by path at runtime const { mod, dependencies } = await loadDbConfigFile(config.root); @@ -78,7 +82,7 @@ function astroDBIntegration(): AstroIntegration { // TODO: resolve integrations here? tables.get = () => dbConfig.tables ?? {}; - if (!connectToStudio && !process.env.TEST_IN_MEMORY_DB) { + if (!connectToStudio) { const dbUrl = new URL(DB_PATH, config.root); if (existsSync(dbUrl)) { await rm(dbUrl); |