From 25fe5bd04047d741a1ca726999fedde9650a34ef Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Sat, 2 Mar 2024 00:31:00 +0000 Subject: [PATCH] [ci] format --- .../db/src/core/cli/commands/execute/index.ts | 8 +++--- .../db/src/core/cli/commands/gen/index.ts | 10 +++---- .../db/src/core/cli/commands/push/index.ts | 12 ++++---- .../db/src/core/cli/commands/shell/index.ts | 2 +- .../db/src/core/cli/commands/verify/index.ts | 2 +- packages/db/src/core/cli/migration-queries.ts | 2 +- packages/db/src/core/cli/migrations.ts | 2 +- packages/db/src/core/integration/index.ts | 14 +++++----- .../db/src/core/integration/vite-plugin-db.ts | 4 +-- packages/db/src/core/load-file.ts | 6 ++-- packages/db/src/runtime/index.ts | 2 +- packages/db/src/runtime/queries.ts | 28 +++++++++---------- packages/db/test/fixtures/basics/db/config.ts | 2 +- packages/db/test/fixtures/basics/db/seed.ts | 4 +-- packages/db/test/fixtures/basics/db/theme.ts | 2 +- .../db/test/fixtures/recipes/db/config.ts | 2 +- packages/db/test/fixtures/recipes/db/seed.ts | 2 +- .../fixtures/ticketing-example/db/config.ts | 2 +- packages/db/test/unit/column-queries.test.js | 4 +-- packages/db/test/unit/index-queries.test.js | 2 +- .../db/test/unit/reference-queries.test.js | 2 +- 21 files changed, 57 insertions(+), 57 deletions(-) diff --git a/packages/db/src/core/cli/commands/execute/index.ts b/packages/db/src/core/cli/commands/execute/index.ts index a81696702f62..1863691e706e 100644 --- a/packages/db/src/core/cli/commands/execute/index.ts +++ b/packages/db/src/core/cli/commands/execute/index.ts @@ -1,11 +1,11 @@ +import { existsSync } from 'node:fs'; 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 { FILE_NOT_FOUND_ERROR, MISSING_EXECUTE_PATH_ERROR } from '../../../errors.js'; +import { getStudioVirtualModContents } from '../../../integration/vite-plugin-db.js'; +import { bundleFile, importBundledFile } from '../../../load-file.js'; 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, diff --git a/packages/db/src/core/cli/commands/gen/index.ts b/packages/db/src/core/cli/commands/gen/index.ts index c28f697d86e6..be157d4a5545 100644 --- a/packages/db/src/core/cli/commands/gen/index.ts +++ b/packages/db/src/core/cli/commands/gen/index.ts @@ -1,8 +1,11 @@ -import { fileURLToPath } from 'node:url'; import { writeFile } from 'node:fs/promises'; +import { relative } from 'node:path'; +import { fileURLToPath } from 'node:url'; import type { AstroConfig } from 'astro'; -import { bold, bgRed, red, reset } from 'kleur/colors'; +import { bgRed, bold, red, reset } from 'kleur/colors'; import type { Arguments } from 'yargs-parser'; +import type { DBConfig } from '../../../types.js'; +import { getMigrationsDirectoryUrl } from '../../../utils.js'; import { getMigrationQueries } from '../../migration-queries.js'; import { MIGRATIONS_CREATED, @@ -10,9 +13,6 @@ import { getMigrationStatus, initializeMigrationsDirectory, } from '../../migrations.js'; -import { getMigrationsDirectoryUrl } from '../../../utils.js'; -import type { DBConfig } from '../../../types.js'; -import { relative } from 'node:path'; export async function cmd({ astroConfig, diff --git a/packages/db/src/core/cli/commands/push/index.ts b/packages/db/src/core/cli/commands/push/index.ts index b6bd773e2f03..81d232cb2904 100644 --- a/packages/db/src/core/cli/commands/push/index.ts +++ b/packages/db/src/core/cli/commands/push/index.ts @@ -2,22 +2,22 @@ import type { AstroConfig } from 'astro'; import { red } from 'kleur/colors'; import prompts from 'prompts'; import type { Arguments } from 'yargs-parser'; +import { MISSING_SESSION_ID_ERROR } from '../../../errors.js'; import { getManagedAppTokenOrExit } from '../../../tokens.js'; import { type DBConfig, type DBSnapshot } from '../../../types.js'; import { getMigrationsDirectoryUrl, getRemoteDatabaseUrl } from '../../../utils.js'; import { getMigrationQueries } from '../../migration-queries.js'; import { + INITIAL_SNAPSHOT, + MIGRATIONS_NOT_INITIALIZED, + MIGRATIONS_UP_TO_DATE, + MIGRATION_NEEDED, createEmptySnapshot, - getMigrations, getMigrationStatus, - INITIAL_SNAPSHOT, + getMigrations, loadInitialSnapshot, loadMigration, - MIGRATION_NEEDED, - MIGRATIONS_NOT_INITIALIZED, - MIGRATIONS_UP_TO_DATE, } from '../../migrations.js'; -import { MISSING_SESSION_ID_ERROR } from '../../../errors.js'; export async function cmd({ astroConfig, diff --git a/packages/db/src/core/cli/commands/shell/index.ts b/packages/db/src/core/cli/commands/shell/index.ts index 7d8f13437bbd..ef54b6b70db2 100644 --- a/packages/db/src/core/cli/commands/shell/index.ts +++ b/packages/db/src/core/cli/commands/shell/index.ts @@ -3,8 +3,8 @@ import { sql } from 'drizzle-orm'; import type { Arguments } from 'yargs-parser'; import { createRemoteDatabaseClient } from '../../../../runtime/db-client.js'; import { getManagedAppTokenOrExit } from '../../../tokens.js'; -import { getRemoteDatabaseUrl } from '../../../utils.js'; import type { DBConfigInput } from '../../../types.js'; +import { getRemoteDatabaseUrl } from '../../../utils.js'; export async function cmd({ flags, diff --git a/packages/db/src/core/cli/commands/verify/index.ts b/packages/db/src/core/cli/commands/verify/index.ts index ff182fc53c86..3b95835f7a64 100644 --- a/packages/db/src/core/cli/commands/verify/index.ts +++ b/packages/db/src/core/cli/commands/verify/index.ts @@ -1,5 +1,6 @@ import type { AstroConfig } from 'astro'; import type { Arguments } from 'yargs-parser'; +import type { DBConfig } from '../../../types.js'; import { getMigrationQueries } from '../../migration-queries.js'; import { MIGRATIONS_NOT_INITIALIZED, @@ -7,7 +8,6 @@ import { MIGRATION_NEEDED, getMigrationStatus, } from '../../migrations.js'; -import type { DBConfig } from '../../../types.js'; export async function cmd({ astroConfig, diff --git a/packages/db/src/core/cli/migration-queries.ts b/packages/db/src/core/cli/migration-queries.ts index aa9d7e316805..4265f36e424a 100644 --- a/packages/db/src/core/cli/migration-queries.ts +++ b/packages/db/src/core/cli/migration-queries.ts @@ -4,7 +4,6 @@ import * as color from 'kleur/colors'; import { customAlphabet } from 'nanoid'; import prompts from 'prompts'; import { hasPrimaryKey } from '../../runtime/index.js'; -import { isSerializedSQL } from '../../runtime/types.js'; import { getCreateIndexQueries, getCreateTableQuery, @@ -13,6 +12,7 @@ import { hasDefault, schemaTypeToSqlType, } from '../../runtime/queries.js'; +import { isSerializedSQL } from '../../runtime/types.js'; import { type BooleanColumn, type ColumnType, diff --git a/packages/db/src/core/cli/migrations.ts b/packages/db/src/core/cli/migrations.ts index 455ebc984fc7..514d4e798a11 100644 --- a/packages/db/src/core/cli/migrations.ts +++ b/packages/db/src/core/cli/migrations.ts @@ -1,7 +1,7 @@ import deepDiff from 'deep-diff'; import { mkdir, readFile, readdir, writeFile } from 'fs/promises'; -import { type DBSnapshot, type DBConfig } from '../types.js'; import { cyan, green, yellow } from 'kleur/colors'; +import { type DBConfig, type DBSnapshot } from '../types.js'; import { getMigrationsDirectoryUrl } from '../utils.js'; const { applyChange, diff: generateDiff } = deepDiff; diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index 2b476a4d3f95..4361ddfe7f67 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -1,18 +1,18 @@ import { existsSync } from 'fs'; -import { CONFIG_FILE_NAMES, DB_PATH } from '../consts.js'; -import { dbConfigSchema, type DBConfig } from '../types.js'; -import { getDbDirectoryUrl, type VitePlugin } from '../utils.js'; -import { errorMap } from './error-map.js'; import { dirname } from 'path'; import { fileURLToPath } from 'url'; import type { AstroIntegration } from 'astro'; import { mkdir, rm, writeFile } from 'fs/promises'; import { blue, yellow } from 'kleur/colors'; -import { fileURLIntegration } from './file-url.js'; -import { getManagedAppTokenOrExit, type ManagedAppToken } from '../tokens.js'; +import { CONFIG_FILE_NAMES, DB_PATH } from '../consts.js'; import { loadDbConfigFile } from '../load-file.js'; -import { vitePluginDb, type LateTables } from './vite-plugin-db.js'; +import { type ManagedAppToken, getManagedAppTokenOrExit } from '../tokens.js'; +import { type DBConfig, dbConfigSchema } from '../types.js'; +import { type VitePlugin, getDbDirectoryUrl } from '../utils.js'; +import { errorMap } from './error-map.js'; +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'; function astroDBIntegration(): AstroIntegration { diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts index ff97d2b21bf1..65a9fa6a03b6 100644 --- a/packages/db/src/core/integration/vite-plugin-db.ts +++ b/packages/db/src/core/integration/vite-plugin-db.ts @@ -1,4 +1,5 @@ import { fileURLToPath } from 'node:url'; +import { normalizePath } from 'vite'; import { SEED_DEV_FILE_NAME } from '../../runtime/queries.js'; import { DB_PATH, @@ -8,8 +9,7 @@ import { VIRTUAL_MODULE_ID, } from '../consts.js'; import type { DBTables } from '../types.js'; -import { getDbDirectoryUrl, getRemoteDatabaseUrl, type VitePlugin } from '../utils.js'; -import { normalizePath } from 'vite'; +import { type VitePlugin, getDbDirectoryUrl, getRemoteDatabaseUrl } from '../utils.js'; const LOCAL_DB_VIRTUAL_MODULE_ID = 'astro:local'; diff --git a/packages/db/src/core/load-file.ts b/packages/db/src/core/load-file.ts index 591ffa3906d3..cc1b23c014b2 100644 --- a/packages/db/src/core/load-file.ts +++ b/packages/db/src/core/load-file.ts @@ -1,9 +1,9 @@ +import { existsSync } from 'node:fs'; +import { unlink, writeFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; import { build as esbuild } from 'esbuild'; import { CONFIG_FILE_NAMES, VIRTUAL_MODULE_ID } from './consts.js'; -import { fileURLToPath } from 'node:url'; import { getConfigVirtualModContents } from './integration/vite-plugin-db.js'; -import { writeFile, unlink } from 'node:fs/promises'; -import { existsSync } from 'node:fs'; import { getDbDirectoryUrl } from './utils.js'; export async function loadDbConfigFile( diff --git a/packages/db/src/runtime/index.ts b/packages/db/src/runtime/index.ts index d68521f43511..501ae7a22233 100644 --- a/packages/db/src/runtime/index.ts +++ b/packages/db/src/runtime/index.ts @@ -1,5 +1,5 @@ -import type { LibSQLDatabase } from 'drizzle-orm/libsql'; import { type ColumnBuilderBaseConfig, type ColumnDataType, sql } from 'drizzle-orm'; +import type { LibSQLDatabase } from 'drizzle-orm/libsql'; import { type IndexBuilder, type SQLiteColumnBuilderBase, diff --git a/packages/db/src/runtime/queries.ts b/packages/db/src/runtime/queries.ts index b81b06edbe7f..4341fd1237ab 100644 --- a/packages/db/src/runtime/queries.ts +++ b/packages/db/src/runtime/queries.ts @@ -1,27 +1,27 @@ +import { LibsqlError } from '@libsql/client'; +import { type SQL, sql } from 'drizzle-orm'; +import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core'; +import { bold } from 'kleur/colors'; +import { + FOREIGN_KEY_DNE_ERROR, + FOREIGN_KEY_REFERENCES_EMPTY_ERROR, + FOREIGN_KEY_REFERENCES_LENGTH_ERROR, + REFERENCE_DNE_ERROR, + SEED_ERROR, +} from '../core/errors.js'; import type { BooleanColumn, + ColumnType, + DBColumn, DBTable, DBTables, - DBColumn, DateColumn, - ColumnType, JsonColumn, NumberColumn, TextColumn, } from '../core/types.js'; -import { bold } from 'kleur/colors'; -import { type SQL, sql } from 'drizzle-orm'; -import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core'; -import { hasPrimaryKey, type SqliteDB } from './index.js'; +import { type SqliteDB, hasPrimaryKey } from './index.js'; import { isSerializedSQL } from './types.js'; -import { - FOREIGN_KEY_REFERENCES_LENGTH_ERROR, - FOREIGN_KEY_REFERENCES_EMPTY_ERROR, - REFERENCE_DNE_ERROR, - FOREIGN_KEY_DNE_ERROR, - SEED_ERROR, -} from '../core/errors.js'; -import { LibsqlError } from '@libsql/client'; const sqlite = new SQLiteAsyncDialect(); diff --git a/packages/db/test/fixtures/basics/db/config.ts b/packages/db/test/fixtures/basics/db/config.ts index b2ed2066f1e1..f216caab6e45 100644 --- a/packages/db/test/fixtures/basics/db/config.ts +++ b/packages/db/test/fixtures/basics/db/config.ts @@ -1,5 +1,5 @@ -import { defineDB, defineTable, column } from 'astro:db'; import { Themes } from './theme'; +import { column, defineDB, defineTable } from 'astro:db'; const Author = defineTable({ columns: { diff --git a/packages/db/test/fixtures/basics/db/seed.ts b/packages/db/test/fixtures/basics/db/seed.ts index c1b61e0996db..33d82d523782 100644 --- a/packages/db/test/fixtures/basics/db/seed.ts +++ b/packages/db/test/fixtures/basics/db/seed.ts @@ -1,6 +1,6 @@ -import { db, Author } from 'astro:db'; -import { Themes as ThemesConfig } from './theme'; import { asDrizzleTable } from '@astrojs/db/utils'; +import { Themes as ThemesConfig } from './theme'; +import { Author, db } from 'astro:db'; const Themes = asDrizzleTable('Themes', ThemesConfig); diff --git a/packages/db/test/fixtures/basics/db/theme.ts b/packages/db/test/fixtures/basics/db/theme.ts index d3b89b68c4b8..aecc67f7d5ae 100644 --- a/packages/db/test/fixtures/basics/db/theme.ts +++ b/packages/db/test/fixtures/basics/db/theme.ts @@ -1,4 +1,4 @@ -import { defineTable, column, NOW, sql } from 'astro:db'; +import { NOW, column, defineTable, sql } from 'astro:db'; export const Themes = defineTable({ columns: { diff --git a/packages/db/test/fixtures/recipes/db/config.ts b/packages/db/test/fixtures/recipes/db/config.ts index 1cbcaa96e1a6..6334ba8edcfa 100644 --- a/packages/db/test/fixtures/recipes/db/config.ts +++ b/packages/db/test/fixtures/recipes/db/config.ts @@ -1,4 +1,4 @@ -import { defineTable, defineDB, column } from 'astro:db'; +import { column, defineDB, defineTable } from 'astro:db'; const Recipe = defineTable({ columns: { diff --git a/packages/db/test/fixtures/recipes/db/seed.ts b/packages/db/test/fixtures/recipes/db/seed.ts index b30c708fa43e..7a4892376fde 100644 --- a/packages/db/test/fixtures/recipes/db/seed.ts +++ b/packages/db/test/fixtures/recipes/db/seed.ts @@ -1,4 +1,4 @@ -import { db, Recipe, Ingredient } from 'astro:db'; +import { Ingredient, Recipe, db } from 'astro:db'; const pancakes = await db .insert(Recipe) diff --git a/packages/db/test/fixtures/ticketing-example/db/config.ts b/packages/db/test/fixtures/ticketing-example/db/config.ts index 28a50b769674..f8148eaed305 100644 --- a/packages/db/test/fixtures/ticketing-example/db/config.ts +++ b/packages/db/test/fixtures/ticketing-example/db/config.ts @@ -1,4 +1,4 @@ -import { defineDB, defineTable, column } from 'astro:db'; +import { column, defineDB, defineTable } from 'astro:db'; const Event = defineTable({ columns: { diff --git a/packages/db/test/unit/column-queries.test.js b/packages/db/test/unit/column-queries.test.js index 96c9c687a140..c4d60d5c6f37 100644 --- a/packages/db/test/unit/column-queries.test.js +++ b/packages/db/test/unit/column-queries.test.js @@ -4,10 +4,10 @@ import { getCollectionChangeQueries, getMigrationQueries, } from '../../dist/core/cli/migration-queries.js'; -import { getCreateTableQuery } from '../../dist/runtime/queries.js'; -import { column, defineTable } from '../../dist/runtime/config.js'; import { tableSchema } from '../../dist/core/types.js'; +import { column, defineTable } from '../../dist/runtime/config.js'; import { NOW } from '../../dist/runtime/index.js'; +import { getCreateTableQuery } from '../../dist/runtime/queries.js'; const TABLE_NAME = 'Users'; diff --git a/packages/db/test/unit/index-queries.test.js b/packages/db/test/unit/index-queries.test.js index 5e9b2130d960..ad588959d173 100644 --- a/packages/db/test/unit/index-queries.test.js +++ b/packages/db/test/unit/index-queries.test.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js'; -import { column } from '../../dist/runtime/config.js'; import { tableSchema } from '../../dist/core/types.js'; +import { column } from '../../dist/runtime/config.js'; const userInitial = tableSchema.parse({ columns: { diff --git a/packages/db/test/unit/reference-queries.test.js b/packages/db/test/unit/reference-queries.test.js index 561879f438e4..a4b0bdd2d923 100644 --- a/packages/db/test/unit/reference-queries.test.js +++ b/packages/db/test/unit/reference-queries.test.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js'; -import { column, defineTable } from '../../dist/runtime/config.js'; import { tablesSchema } from '../../dist/core/types.js'; +import { column, defineTable } from '../../dist/runtime/config.js'; const BaseUser = defineTable({ columns: {