Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored and astrobot-houston committed Sep 3, 2024
1 parent cc820c5 commit 5705200
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
7 changes: 6 additions & 1 deletion packages/db/src/core/cli/commands/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { createRemoteDatabaseClient } from '../../../../runtime/index.js';
import { safeFetch } from '../../../../runtime/utils.js';
import { MIGRATION_VERSION } from '../../../consts.js';
import type { DBConfig, DBSnapshot } from '../../../types.js';
import { type RemoteDatabaseInfo, type Result, getManagedRemoteToken, getRemoteDatabaseInfo } from '../../../utils.js';
import {
type RemoteDatabaseInfo,
type Result,
getManagedRemoteToken,
getRemoteDatabaseInfo,
} from '../../../utils.js';
import {
createCurrentSnapshot,
createEmptySnapshot,
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/cli/commands/verify/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { AstroConfig } from 'astro';
import type { Arguments } from 'yargs-parser';
import type { DBConfig } from '../../../types.js';
import { getManagedRemoteToken, getRemoteDatabaseInfo } from '../../../utils.js';
import {
createCurrentSnapshot,
createEmptySnapshot,
formatDataLossMessage,
getMigrationQueries,
getProductionCurrentSnapshot,
} from '../../migration-queries.js';
import { getManagedRemoteToken, getRemoteDatabaseInfo } from '../../../utils.js';

export async function cmd({
dbConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function astroDBIntegration(): AstroIntegration {
await executeSeedFile({ fileUrl, viteServer: tempViteServer! });
};
},
'astro:build:done': async ({ }) => {
'astro:build:done': async ({}) => {
await appToken?.destroy();
await tempViteServer?.close();
},
Expand Down
9 changes: 6 additions & 3 deletions packages/db/src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAstroStudioEnv, getManagedAppTokenOrExit, type ManagedAppToken } from '@astrojs/studio';
import { type ManagedAppToken, getAstroStudioEnv, getManagedAppTokenOrExit } from '@astrojs/studio';
import type { AstroConfig, AstroIntegration } from 'astro';
import { loadEnv } from 'vite';
import './types.js';
Expand Down Expand Up @@ -37,11 +37,14 @@ export function getRemoteDatabaseInfo(): RemoteDatabaseInfo {
};
}

export function getManagedRemoteToken(token?: string, dbInfo?: RemoteDatabaseInfo): Promise<ManagedAppToken> {
export function getManagedRemoteToken(
token?: string,
dbInfo?: RemoteDatabaseInfo,
): Promise<ManagedAppToken> {
dbInfo ??= getRemoteDatabaseInfo();

if (dbInfo.type === 'studio') {
return getManagedAppTokenOrExit(token)
return getManagedAppTokenOrExit(token);
}

const astroEnv = getAstroEnv();
Expand Down
16 changes: 9 additions & 7 deletions packages/db/test/unit/remote-info.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test, { after, beforeEach, describe } from "node:test";
import assert from "node:assert";
import { getRemoteDatabaseInfo, getManagedRemoteToken } from '../../dist/core/utils.js';
import { clearEnvironment } from "../test-utils.js";
import assert from 'node:assert';
import test, { after, beforeEach, describe } from 'node:test';
import { getManagedRemoteToken, getRemoteDatabaseInfo } from '../../dist/core/utils.js';
import { clearEnvironment } from '../test-utils.js';

describe('RemoteDatabaseInfo', () => {
beforeEach(() => {
Expand Down Expand Up @@ -53,10 +53,12 @@ describe('RemoteManagedToken', () => {
// Avoid conflicts with other tests
beforeEach(() => {
clearEnvironment();
process.env.ASTRO_STUDIO_APP_TOKEN = 'studio token'
process.env.ASTRO_DB_APP_TOKEN = 'db token'
process.env.ASTRO_STUDIO_APP_TOKEN = 'studio token';
process.env.ASTRO_DB_APP_TOKEN = 'db token';
});
after(() => {
clearEnvironment();
});
after(() => { clearEnvironment(); });

test('given token for default remote', async () => {
const { token } = await getManagedRemoteToken('given token');
Expand Down

0 comments on commit 5705200

Please sign in to comment.