mirror of
https://github.com/withastro/astro.git
synced 2025-02-24 22:46:02 -05:00
feat: remove unsafeDisableStudio
This commit is contained in:
parent
4f8e2754fa
commit
89365064b4
4 changed files with 4 additions and 34 deletions
|
@ -1,10 +1,6 @@
|
|||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import {
|
||||
MISSING_EXECUTE_PATH_ERROR,
|
||||
FILE_NOT_FOUND_ERROR,
|
||||
UNSAFE_DISABLE_STUDIO_WARNING,
|
||||
} from '../../../errors.js';
|
||||
import { MISSING_EXECUTE_PATH_ERROR, FILE_NOT_FOUND_ERROR } from '../../../errors.js';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { getManagedAppTokenOrExit } from '../../../tokens.js';
|
||||
import { tablesSchema } from '../../../types.js';
|
||||
|
@ -25,16 +21,6 @@ export async function cmd({ config, flags }: { config: AstroConfig; flags: Argum
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
if (config.db?.unsafeDisableStudio) {
|
||||
console.warn(UNSAFE_DISABLE_STUDIO_WARNING);
|
||||
await executeFile({
|
||||
connectToStudio: false,
|
||||
fileUrl,
|
||||
tables,
|
||||
root: config.root,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const appToken = await getManagedAppTokenOrExit(flags.token);
|
||||
|
||||
await executeFile({
|
||||
|
|
|
@ -10,12 +10,6 @@ export const MISSING_PROJECT_ID_ERROR = `${red('▶ Directory not linked.')}
|
|||
To link this directory to an Astro Studio project, run
|
||||
${cyan('astro db link')}\n`;
|
||||
|
||||
export const UNSAFE_DISABLE_STUDIO_WARNING = `${yellow(
|
||||
'unsafeDisableStudio'
|
||||
)} option is enabled and you are deploying your database without Studio.
|
||||
Redeploying your app may result in wiping away your database.
|
||||
I hope you know what you are doing.\n`;
|
||||
|
||||
export const MIGRATIONS_NOT_INITIALIZED = `${yellow(
|
||||
'▶ No migrations found!'
|
||||
)}\n\n To scaffold your migrations folder, run\n ${cyan('astro db sync')}\n`;
|
||||
|
|
|
@ -39,26 +39,17 @@ function astroDBIntegration(): AstroIntegration {
|
|||
|
||||
let dbPlugin: VitePlugin | undefined = undefined;
|
||||
|
||||
const unsafeDisableStudio =
|
||||
config.db?.unsafeDisableStudio ?? process.env.ASTRO_DB_TEST_ENV === '1';
|
||||
|
||||
if (unsafeDisableStudio) {
|
||||
logger.warn(UNSAFE_DISABLE_STUDIO_WARNING);
|
||||
}
|
||||
|
||||
connectToStudio = command === 'build' && !unsafeDisableStudio;
|
||||
|
||||
if (connectToStudio) {
|
||||
if (command === 'build') {
|
||||
appToken = await getManagedAppTokenOrExit();
|
||||
dbPlugin = vitePluginDb({
|
||||
connectToStudio,
|
||||
connectToStudio: true,
|
||||
appToken: appToken.token,
|
||||
schemas,
|
||||
root: config.root,
|
||||
});
|
||||
} else {
|
||||
dbPlugin = vitePluginDb({
|
||||
connectToStudio,
|
||||
connectToStudio: false,
|
||||
schemas,
|
||||
root: config.root,
|
||||
shouldSeed: command === 'dev',
|
||||
|
|
|
@ -240,7 +240,6 @@ export type DBSnapshot = {
|
|||
|
||||
export const dbConfigSchema = z.object({
|
||||
tables: tablesSchema.optional(),
|
||||
unsafeDisableStudio: z.boolean().optional().default(false),
|
||||
});
|
||||
|
||||
export type DBUserConfig = z.input<typeof dbConfigSchema>;
|
||||
|
|
Loading…
Add table
Reference in a new issue