Skip to content

Commit

Permalink
chore: import sort source code, exception for the astro package (#1…
Browse files Browse the repository at this point in the history
…0242)

* chore: import sort source code, exception for the `astro` package

* fix import sorting bug

* Update packages/integrations/lit/server.js

Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>

---------

Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
  • Loading branch information
ematipico and Princesseuh authored Feb 27, 2024
1 parent 9c21a9d commit 2dd00a0
Show file tree
Hide file tree
Showing 81 changed files with 193 additions and 191 deletions.
2 changes: 1 addition & 1 deletion benchmark/packages/timer/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CreatePreviewServer } from 'astro';
import { createServer } from 'node:http';
import type { CreatePreviewServer } from 'astro';
import enableDestroy from 'server-destroy';

const preview: CreatePreviewServer = async function ({ serverEntrypoint, host, port }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/packages/timer/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
import type { IncomingMessage, ServerResponse } from 'node:http';

applyPolyfills();

Expand Down
4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"files": {
"include": ["test/**", "e2e/**"],
"ignore": ["vendor"]
"include": ["test/**", "e2e/**", "packages/**"],
"ignore": ["vendor", "dist/**", "packages/astro/**"]
},
"organizeImports": {
"enabled": true
Expand Down
6 changes: 3 additions & 3 deletions packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { prompt, type Task } from '@astrojs/cli-kit';
import os from 'node:os';
import { type Task, prompt } from '@astrojs/cli-kit';
import { random } from '@astrojs/cli-kit/utils';
import arg from 'arg';
import os from 'node:os';

import { getName, getVersion } from '../messages.js';
import getSeasonalData from '../data/seasonal.js';
import { getName, getVersion } from '../messages.js';

export interface Context {
help: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { color } from '@astrojs/cli-kit';
import fs from 'node:fs';
import path from 'node:path';
import { color } from '@astrojs/cli-kit';
import { error, info, title } from '../messages.js';
import { shell } from '../shell.js';
import type { Context } from './context.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/project-name.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Context } from './context.js';

import { color, generateProjectName } from '@astrojs/cli-kit';
import path from 'node:path';
import { color, generateProjectName } from '@astrojs/cli-kit';
import { info, log, title } from '../messages.js';

import { isEmpty, toValidName } from './shared.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/actions/template.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Context } from './context.js';

import { color } from '@astrojs/cli-kit';
import { downloadTemplate } from 'giget';
import fs from 'node:fs';
import path from 'node:path';
import { color } from '@astrojs/cli-kit';
import { downloadTemplate } from 'giget';
import { error, info, title } from '../messages.js';

export async function template(
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/actions/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Context } from './context.js';
import { color } from '@astrojs/cli-kit';
import { readFile, rm, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { color } from '@astrojs/cli-kit';
import stripJsonComments from 'strip-json-comments';
import { error, getVersion, info, title, typescriptByDefault } from '../messages.js';
import type { Context } from './context.js';

type PickedTypeScriptContext = Pick<
Context,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/verify.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Context } from './context.js';

import { color } from '@astrojs/cli-kit';
import dns from 'node:dns/promises';
import { color } from '@astrojs/cli-kit';
import { bannerAbort, error, info, log } from '../messages.js';
import { getTemplateTarget } from './template.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getContext } from './actions/context.js';

import { tasks } from '@astrojs/cli-kit';
import { dependencies } from './actions/dependencies.js';
import { git } from './actions/git.js';
import { help } from './actions/help.js';
Expand All @@ -10,7 +11,6 @@ import { template } from './actions/template.js';
import { setupTypeScript, typescript } from './actions/typescript.js';
import { verify } from './actions/verify.js';
import { setStdout } from './messages.js';
import { tasks } from '@astrojs/cli-kit';

const exit = () => process.exit(0);
process.on('SIGINT', exit);
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exec } from 'node:child_process';
/* eslint no-console: 'off' */
import { color, say as houston, label, spinner as load } from '@astrojs/cli-kit';
import { color, label, say as houston, spinner as load } from '@astrojs/cli-kit';
import { align, sleep } from '@astrojs/cli-kit/utils';
import { exec } from 'node:child_process';
import stripAnsi from 'strip-ansi';
import { shell } from './shell.js';

Expand Down
6 changes: 3 additions & 3 deletions packages/db/src/core/cli/commands/gen/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { writeFile } from 'node:fs/promises';
import type { AstroConfig } from 'astro';
import { bgRed, red, reset } from 'kleur/colors';
import type { Arguments } from 'yargs-parser';
import { writeFile } from 'node:fs/promises';
import { getMigrationQueries } from '../../migration-queries.js';
import {
MIGRATIONS_CREATED,
MIGRATIONS_UP_TO_DATE,
getMigrationStatus,
initializeMigrationsDirectory,
} from '../../migrations.js';
import { getMigrationQueries } from '../../migration-queries.js';
import { bgRed, red, reset } from 'kleur/colors';

export async function cmd({ config }: { config: AstroConfig; flags: Arguments }) {
const migration = await getMigrationStatus(config);
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/core/cli/commands/link/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { AstroConfig } from 'astro';
import { mkdir, writeFile } from 'node:fs/promises';
import type { AstroConfig } from 'astro';
import { bgRed, cyan } from 'kleur/colors';
import prompts from 'prompts';
import type { Arguments } from 'yargs-parser';
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
import { PROJECT_ID_FILE, getSessionIdFromFile } from '../../../tokens.js';
import { getAstroStudioUrl } from '../../../utils.js';
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';

export async function cmd({ flags }: { config: AstroConfig; flags: Arguments }) {
const linkUrl = new URL(getAstroStudioUrl() + '/auth/cli/link');
Expand Down
8 changes: 4 additions & 4 deletions packages/db/src/core/cli/commands/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { AstroConfig } from 'astro';
import { cyan } from 'kleur/colors';
import { mkdir, writeFile } from 'node:fs/promises';
import { createServer } from 'node:http';
import type { AstroConfig } from 'astro';
import { cyan } from 'kleur/colors';
import open from 'open';
import ora from 'ora';
import type { Arguments } from 'yargs-parser';
import { getAstroStudioUrl } from '../../../utils.js';
import open from 'open';
import { SESSION_LOGIN_FILE } from '../../../tokens.js';
import { getAstroStudioUrl } from '../../../utils.js';

function serveAndResolveSession(): Promise<string> {
let resolve: (value: string | PromiseLike<string>) => void,
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/cli/commands/logout/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AstroConfig } from 'astro';
import { unlink } from 'node:fs/promises';
import type { AstroConfig } from 'astro';
import type { Arguments } from 'yargs-parser';
import { SESSION_LOGIN_FILE } from '../../../tokens.js';

Expand Down
16 changes: 8 additions & 8 deletions packages/db/src/core/cli/commands/push/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { createClient, type InStatement } from '@libsql/client';
import { type InStatement, createClient } from '@libsql/client';
import type { AstroConfig } from 'astro';
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
import { drizzle as drizzleLibsql } from 'drizzle-orm/libsql';
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
import { red } from 'kleur/colors';
import prompts from 'prompts';
import type { Arguments } from 'yargs-parser';
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
import { recreateTables, seedData } from '../../../queries.js';
import { getManagedAppTokenOrExit } from '../../../tokens.js';
import { tablesSchema, type AstroConfigWithDB, type DBSnapshot } from '../../../types.js';
import { type AstroConfigWithDB, type DBSnapshot, tablesSchema } from '../../../types.js';
import { getRemoteDatabaseUrl } from '../../../utils.js';
import { getMigrationQueries } from '../../migration-queries.js';
import {
MIGRATIONS_NOT_INITIALIZED,
MIGRATIONS_UP_TO_DATE,
MIGRATION_NEEDED,
createEmptySnapshot,
getMigrations,
getMigrationStatus,
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({ config, flags }: { config: AstroConfig; flags: Arguments }) {
const isDryRun = flags.dryRun;
Expand Down
6 changes: 3 additions & 3 deletions packages/db/src/core/cli/commands/verify/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { AstroConfig } from 'astro';
import type { Arguments } from 'yargs-parser';
import { getMigrationQueries } from '../../migration-queries.js';
import {
getMigrationStatus,
MIGRATION_NEEDED,
MIGRATIONS_NOT_INITIALIZED,
MIGRATIONS_UP_TO_DATE,
MIGRATION_NEEDED,
getMigrationStatus,
} from '../../migrations.js';
import { getMigrationQueries } from '../../migration-queries.js';

export async function cmd({ config, flags }: { config: AstroConfig; flags: Arguments }) {
const status = await getMigrationStatus(config);
Expand Down
36 changes: 18 additions & 18 deletions packages/db/src/core/cli/migration-queries.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import * as color from 'kleur/colors';
import deepDiff from 'deep-diff';
import {
columnSchema,
type BooleanColumn,
type DBTable,
type DBTables,
type DBColumn,
type DBColumns,
type DBSnapshot,
type DateColumn,
type ColumnType,
type Indexes,
type JsonColumn,
type NumberColumn,
type TextColumn,
} from '../types.js';
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
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,
Expand All @@ -26,8 +13,21 @@ import {
hasDefault,
schemaTypeToSqlType,
} from '../queries.js';
import { hasPrimaryKey } from '../../runtime/index.js';
import { isSerializedSQL } from '../../runtime/types.js';
import {
type BooleanColumn,
type ColumnType,
type DBColumn,
type DBColumns,
type DBSnapshot,
type DBTable,
type DBTables,
type DateColumn,
type Indexes,
type JsonColumn,
type NumberColumn,
type TextColumn,
columnSchema,
} from '../types.js';

const sqlite = new SQLiteAsyncDialect();
const genTempTableName = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10);
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/core/cli/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AstroConfig } from 'astro';
import deepDiff from 'deep-diff';
import { mkdir, readFile, readdir, writeFile } from 'fs/promises';
import { tablesSchema, type DBSnapshot } from '../types.js';
import type { AstroConfig } from 'astro';
import { cyan, green, yellow } from 'kleur/colors';
import { type DBSnapshot, tablesSchema } from '../types.js';
const { applyChange, diff: generateDiff } = deepDiff;

export type MigrationStatus =
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cyan, bold, red, green, yellow } from 'kleur/colors';
import { bold, cyan, green, red, yellow } from 'kleur/colors';

export const MISSING_SESSION_ID_ERROR = `${red('▶ Login required!')}
Expand Down
6 changes: 3 additions & 3 deletions packages/db/src/core/integration/file-url.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AstroConfig, AstroIntegration } from 'astro';
import type { VitePlugin } from '../utils.js';
import fs from 'node:fs';
import { pathToFileURL } from 'node:url';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import type { AstroConfig, AstroIntegration } from 'astro';
import type { VitePlugin } from '../utils.js';

async function copyFile(toDir: URL, fromUrl: URL, toUrl: URL) {
await fs.promises.mkdir(toDir, { recursive: true });
Expand Down
24 changes: 12 additions & 12 deletions packages/db/src/core/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type { AstroIntegration } from 'astro';
import { vitePluginDb } from './vite-plugin-db.js';
import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js';
import { typegen } from './typegen.js';
import { existsSync } from 'fs';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import type { AstroIntegration } from 'astro';
import { mkdir, rm, writeFile } from 'fs/promises';
import { DB_PATH } from '../consts.js';
import { blue, yellow } from 'kleur/colors';
import { createLocalDatabaseClient } from '../../runtime/db-client.js';
import { astroConfigWithDbSchema, type DBTables } from '../types.js';
import { type VitePlugin } from '../utils.js';
import { DB_PATH } from '../consts.js';
import { STUDIO_CONFIG_MISSING_WRITABLE_TABLE_ERROR, UNSAFE_WRITABLE_WARNING } from '../errors.js';
import { recreateTables, seedData } from '../queries.js';
import { type ManagedAppToken, getManagedAppTokenOrExit } from '../tokens.js';
import { type DBTables, astroConfigWithDbSchema } from '../types.js';
import { type VitePlugin } from '../utils.js';
import { errorMap } from './error-map.js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { blue, yellow } from 'kleur/colors';
import { fileURLIntegration } from './file-url.js';
import { recreateTables, seedData } from '../queries.js';
import { getManagedAppTokenOrExit, type ManagedAppToken } from '../tokens.js';
import { typegen } from './typegen.js';
import { vitePluginDb } from './vite-plugin-db.js';
import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js';

function astroDBIntegration(): AstroIntegration {
let connectedToRemote = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/integration/typegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync } from 'node:fs';
import { mkdir, writeFile } from 'node:fs/promises';
import type { DBTable, DBTables } from '../types.js';
import { DB_TYPES_FILE, RUNTIME_DRIZZLE_IMPORT, RUNTIME_IMPORT } from '../consts.js';
import type { DBTable, DBTables } from '../types.js';

export async function typegen({ tables, root }: { tables: DBTables; root: URL }) {
const content = `// This file is generated by \`studio sync\`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { existsSync } from 'node:fs';
import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { AstroIntegrationLogger } from 'astro';
import { bold, cyan } from 'kleur/colors';
import { normalizePath } from 'vite';
import { DB_TYPES_FILE } from '../consts.js';
import type { VitePlugin } from '../utils.js';
import type { AstroIntegrationLogger } from 'astro';

export function vitePluginInjectEnvTs(
{ srcDir, root }: { srcDir: URL; root: URL },
Expand Down
12 changes: 6 additions & 6 deletions packages/db/src/core/queries.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { AstroIntegrationLogger } from 'astro';
import { type SQL, getTableName, sql } from 'drizzle-orm';
import { SQLiteAsyncDialect, type SQLiteInsert } from 'drizzle-orm/sqlite-core';
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
import { bold } from 'kleur/colors';
import {
type BooleanColumn,
type ColumnType,
type DBColumn,
type DBTable,
type DBTables,
type DBColumn,
type DateColumn,
type ColumnType,
type JsonColumn,
type NumberColumn,
type TextColumn,
} from '../core/types.js';
import { bold } from 'kleur/colors';
import { type SQL, sql, getTableName } from 'drizzle-orm';
import { SQLiteAsyncDialect, type SQLiteInsert } from 'drizzle-orm/sqlite-core';
import type { AstroIntegrationLogger } from 'astro';
import type {
ColumnsConfig,
DBUserConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { readFile } from 'node:fs/promises';
import { homedir } from 'node:os';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { getAstroStudioEnv, getAstroStudioUrl } from './utils.js';
import { MISSING_PROJECT_ID_ERROR, MISSING_SESSION_ID_ERROR } from './errors.js';
import { getAstroStudioEnv, getAstroStudioUrl } from './utils.js';

export const SESSION_LOGIN_FILE = pathToFileURL(join(homedir(), '.astro', 'session-token'));
export const PROJECT_ID_FILE = pathToFileURL(join(process.cwd(), '.astro', 'link'));
Expand Down
Loading

0 comments on commit 2dd00a0

Please sign in to comment.