Skip to content

Commit 2dd00a0

Browse files
chore: import sort source code, exception for the astro package (#10242)
* chore: import sort source code, exception for the `astro` package * fix import sorting bug * Update packages/integrations/lit/server.js Co-authored-by: Erika <[email protected]> --------- Co-authored-by: Erika <[email protected]>
1 parent 9c21a9d commit 2dd00a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+193
-191
lines changed

benchmark/packages/timer/src/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CreatePreviewServer } from 'astro';
21
import { createServer } from 'node:http';
2+
import type { CreatePreviewServer } from 'astro';
33
import enableDestroy from 'server-destroy';
44

55
const preview: CreatePreviewServer = async function ({ serverEntrypoint, host, port }) {

benchmark/packages/timer/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { IncomingMessage, ServerResponse } from 'node:http';
12
import type { SSRManifest } from 'astro';
23
import { NodeApp, applyPolyfills } from 'astro/app/node';
3-
import type { IncomingMessage, ServerResponse } from 'node:http';
44

55
applyPolyfills();
66

biome.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
33
"files": {
4-
"include": ["test/**", "e2e/**"],
5-
"ignore": ["vendor"]
4+
"include": ["test/**", "e2e/**", "packages/**"],
5+
"ignore": ["vendor", "dist/**", "packages/astro/**"]
66
},
77
"organizeImports": {
88
"enabled": true

packages/create-astro/src/actions/context.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { prompt, type Task } from '@astrojs/cli-kit';
1+
import os from 'node:os';
2+
import { type Task, prompt } from '@astrojs/cli-kit';
23
import { random } from '@astrojs/cli-kit/utils';
34
import arg from 'arg';
4-
import os from 'node:os';
55

6-
import { getName, getVersion } from '../messages.js';
76
import getSeasonalData from '../data/seasonal.js';
7+
import { getName, getVersion } from '../messages.js';
88

99
export interface Context {
1010
help: boolean;

packages/create-astro/src/actions/dependencies.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { color } from '@astrojs/cli-kit';
21
import fs from 'node:fs';
32
import path from 'node:path';
3+
import { color } from '@astrojs/cli-kit';
44
import { error, info, title } from '../messages.js';
55
import { shell } from '../shell.js';
66
import type { Context } from './context.js';

packages/create-astro/src/actions/project-name.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Context } from './context.js';
22

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

77
import { isEmpty, toValidName } from './shared.js';

packages/create-astro/src/actions/template.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Context } from './context.js';
22

3-
import { color } from '@astrojs/cli-kit';
4-
import { downloadTemplate } from 'giget';
53
import fs from 'node:fs';
64
import path from 'node:path';
5+
import { color } from '@astrojs/cli-kit';
6+
import { downloadTemplate } from 'giget';
77
import { error, info, title } from '../messages.js';
88

99
export async function template(

packages/create-astro/src/actions/typescript.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { Context } from './context.js';
2-
import { color } from '@astrojs/cli-kit';
31
import { readFile, rm, writeFile } from 'node:fs/promises';
42
import path from 'node:path';
3+
import { color } from '@astrojs/cli-kit';
54
import stripJsonComments from 'strip-json-comments';
65
import { error, getVersion, info, title, typescriptByDefault } from '../messages.js';
6+
import type { Context } from './context.js';
77

88
type PickedTypeScriptContext = Pick<
99
Context,

packages/create-astro/src/actions/verify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Context } from './context.js';
22

3-
import { color } from '@astrojs/cli-kit';
43
import dns from 'node:dns/promises';
4+
import { color } from '@astrojs/cli-kit';
55
import { bannerAbort, error, info, log } from '../messages.js';
66
import { getTemplateTarget } from './template.js';
77

packages/create-astro/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getContext } from './actions/context.js';
22

3+
import { tasks } from '@astrojs/cli-kit';
34
import { dependencies } from './actions/dependencies.js';
45
import { git } from './actions/git.js';
56
import { help } from './actions/help.js';
@@ -10,7 +11,6 @@ import { template } from './actions/template.js';
1011
import { setupTypeScript, typescript } from './actions/typescript.js';
1112
import { verify } from './actions/verify.js';
1213
import { setStdout } from './messages.js';
13-
import { tasks } from '@astrojs/cli-kit';
1414

1515
const exit = () => process.exit(0);
1616
process.on('SIGINT', exit);

packages/create-astro/src/messages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { exec } from 'node:child_process';
12
/* eslint no-console: 'off' */
2-
import { color, say as houston, label, spinner as load } from '@astrojs/cli-kit';
3+
import { color, label, say as houston, spinner as load } from '@astrojs/cli-kit';
34
import { align, sleep } from '@astrojs/cli-kit/utils';
4-
import { exec } from 'node:child_process';
55
import stripAnsi from 'strip-ansi';
66
import { shell } from './shell.js';
77

packages/db/src/core/cli/commands/gen/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { writeFile } from 'node:fs/promises';
12
import type { AstroConfig } from 'astro';
3+
import { bgRed, red, reset } from 'kleur/colors';
24
import type { Arguments } from 'yargs-parser';
3-
import { writeFile } from 'node:fs/promises';
5+
import { getMigrationQueries } from '../../migration-queries.js';
46
import {
57
MIGRATIONS_CREATED,
68
MIGRATIONS_UP_TO_DATE,
79
getMigrationStatus,
810
initializeMigrationsDirectory,
911
} from '../../migrations.js';
10-
import { getMigrationQueries } from '../../migration-queries.js';
11-
import { bgRed, red, reset } from 'kleur/colors';
1212

1313
export async function cmd({ config }: { config: AstroConfig; flags: Arguments }) {
1414
const migration = await getMigrationStatus(config);

packages/db/src/core/cli/commands/link/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { AstroConfig } from 'astro';
21
import { mkdir, writeFile } from 'node:fs/promises';
2+
import type { AstroConfig } from 'astro';
33
import { bgRed, cyan } from 'kleur/colors';
44
import prompts from 'prompts';
55
import type { Arguments } from 'yargs-parser';
6+
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
67
import { PROJECT_ID_FILE, getSessionIdFromFile } from '../../../tokens.js';
78
import { getAstroStudioUrl } from '../../../utils.js';
8-
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
99

1010
export async function cmd({ flags }: { config: AstroConfig; flags: Arguments }) {
1111
const linkUrl = new URL(getAstroStudioUrl() + '/auth/cli/link');

packages/db/src/core/cli/commands/login/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { AstroConfig } from 'astro';
2-
import { cyan } from 'kleur/colors';
31
import { mkdir, writeFile } from 'node:fs/promises';
42
import { createServer } from 'node:http';
3+
import type { AstroConfig } from 'astro';
4+
import { cyan } from 'kleur/colors';
5+
import open from 'open';
56
import ora from 'ora';
67
import type { Arguments } from 'yargs-parser';
7-
import { getAstroStudioUrl } from '../../../utils.js';
8-
import open from 'open';
98
import { SESSION_LOGIN_FILE } from '../../../tokens.js';
9+
import { getAstroStudioUrl } from '../../../utils.js';
1010

1111
function serveAndResolveSession(): Promise<string> {
1212
let resolve: (value: string | PromiseLike<string>) => void,

packages/db/src/core/cli/commands/logout/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { AstroConfig } from 'astro';
21
import { unlink } from 'node:fs/promises';
2+
import type { AstroConfig } from 'astro';
33
import type { Arguments } from 'yargs-parser';
44
import { SESSION_LOGIN_FILE } from '../../../tokens.js';
55

packages/db/src/core/cli/commands/push/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { createClient, type InStatement } from '@libsql/client';
1+
import { type InStatement, createClient } from '@libsql/client';
22
import type { AstroConfig } from 'astro';
3-
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
43
import { drizzle as drizzleLibsql } from 'drizzle-orm/libsql';
54
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
5+
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
66
import { red } from 'kleur/colors';
77
import prompts from 'prompts';
88
import type { Arguments } from 'yargs-parser';
9+
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
910
import { recreateTables, seedData } from '../../../queries.js';
1011
import { getManagedAppTokenOrExit } from '../../../tokens.js';
11-
import { tablesSchema, type AstroConfigWithDB, type DBSnapshot } from '../../../types.js';
12+
import { type AstroConfigWithDB, type DBSnapshot, tablesSchema } from '../../../types.js';
1213
import { getRemoteDatabaseUrl } from '../../../utils.js';
1314
import { getMigrationQueries } from '../../migration-queries.js';
1415
import {
16+
MIGRATIONS_NOT_INITIALIZED,
17+
MIGRATIONS_UP_TO_DATE,
18+
MIGRATION_NEEDED,
1519
createEmptySnapshot,
16-
getMigrations,
1720
getMigrationStatus,
21+
getMigrations,
1822
loadInitialSnapshot,
1923
loadMigration,
20-
MIGRATION_NEEDED,
21-
MIGRATIONS_NOT_INITIALIZED,
22-
MIGRATIONS_UP_TO_DATE,
2324
} from '../../migrations.js';
24-
import { MISSING_SESSION_ID_ERROR } from '../../../errors.js';
2525

2626
export async function cmd({ config, flags }: { config: AstroConfig; flags: Arguments }) {
2727
const isDryRun = flags.dryRun;

packages/db/src/core/cli/commands/verify/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { AstroConfig } from 'astro';
22
import type { Arguments } from 'yargs-parser';
3+
import { getMigrationQueries } from '../../migration-queries.js';
34
import {
4-
getMigrationStatus,
5-
MIGRATION_NEEDED,
65
MIGRATIONS_NOT_INITIALIZED,
76
MIGRATIONS_UP_TO_DATE,
7+
MIGRATION_NEEDED,
8+
getMigrationStatus,
89
} from '../../migrations.js';
9-
import { getMigrationQueries } from '../../migration-queries.js';
1010

1111
export async function cmd({ config, flags }: { config: AstroConfig; flags: Arguments }) {
1212
const status = await getMigrationStatus(config);

packages/db/src/core/cli/migration-queries.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
import * as color from 'kleur/colors';
21
import deepDiff from 'deep-diff';
3-
import {
4-
columnSchema,
5-
type BooleanColumn,
6-
type DBTable,
7-
type DBTables,
8-
type DBColumn,
9-
type DBColumns,
10-
type DBSnapshot,
11-
type DateColumn,
12-
type ColumnType,
13-
type Indexes,
14-
type JsonColumn,
15-
type NumberColumn,
16-
type TextColumn,
17-
} from '../types.js';
182
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
3+
import * as color from 'kleur/colors';
194
import { customAlphabet } from 'nanoid';
205
import prompts from 'prompts';
6+
import { hasPrimaryKey } from '../../runtime/index.js';
7+
import { isSerializedSQL } from '../../runtime/types.js';
218
import {
229
getCreateIndexQueries,
2310
getCreateTableQuery,
@@ -26,8 +13,21 @@ import {
2613
hasDefault,
2714
schemaTypeToSqlType,
2815
} from '../queries.js';
29-
import { hasPrimaryKey } from '../../runtime/index.js';
30-
import { isSerializedSQL } from '../../runtime/types.js';
16+
import {
17+
type BooleanColumn,
18+
type ColumnType,
19+
type DBColumn,
20+
type DBColumns,
21+
type DBSnapshot,
22+
type DBTable,
23+
type DBTables,
24+
type DateColumn,
25+
type Indexes,
26+
type JsonColumn,
27+
type NumberColumn,
28+
type TextColumn,
29+
columnSchema,
30+
} from '../types.js';
3131

3232
const sqlite = new SQLiteAsyncDialect();
3333
const genTempTableName = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10);

packages/db/src/core/cli/migrations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import type { AstroConfig } from 'astro';
12
import deepDiff from 'deep-diff';
23
import { mkdir, readFile, readdir, writeFile } from 'fs/promises';
3-
import { tablesSchema, type DBSnapshot } from '../types.js';
4-
import type { AstroConfig } from 'astro';
54
import { cyan, green, yellow } from 'kleur/colors';
5+
import { type DBSnapshot, tablesSchema } from '../types.js';
66
const { applyChange, diff: generateDiff } = deepDiff;
77

88
export type MigrationStatus =

packages/db/src/core/errors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cyan, bold, red, green, yellow } from 'kleur/colors';
1+
import { bold, cyan, green, red, yellow } from 'kleur/colors';
22

33
export const MISSING_SESSION_ID_ERROR = `${red('▶ Login required!')}
44

packages/db/src/core/integration/file-url.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { AstroConfig, AstroIntegration } from 'astro';
2-
import type { VitePlugin } from '../utils.js';
31
import fs from 'node:fs';
4-
import { pathToFileURL } from 'node:url';
52
import path from 'node:path';
3+
import { pathToFileURL } from 'node:url';
4+
import type { AstroConfig, AstroIntegration } from 'astro';
5+
import type { VitePlugin } from '../utils.js';
66

77
async function copyFile(toDir: URL, fromUrl: URL, toUrl: URL) {
88
await fs.promises.mkdir(toDir, { recursive: true });

packages/db/src/core/integration/index.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import type { AstroIntegration } from 'astro';
2-
import { vitePluginDb } from './vite-plugin-db.js';
3-
import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js';
4-
import { typegen } from './typegen.js';
51
import { existsSync } from 'fs';
2+
import { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
import type { AstroIntegration } from 'astro';
65
import { mkdir, rm, writeFile } from 'fs/promises';
7-
import { DB_PATH } from '../consts.js';
6+
import { blue, yellow } from 'kleur/colors';
87
import { createLocalDatabaseClient } from '../../runtime/db-client.js';
9-
import { astroConfigWithDbSchema, type DBTables } from '../types.js';
10-
import { type VitePlugin } from '../utils.js';
8+
import { DB_PATH } from '../consts.js';
119
import { STUDIO_CONFIG_MISSING_WRITABLE_TABLE_ERROR, UNSAFE_WRITABLE_WARNING } from '../errors.js';
10+
import { recreateTables, seedData } from '../queries.js';
11+
import { type ManagedAppToken, getManagedAppTokenOrExit } from '../tokens.js';
12+
import { type DBTables, astroConfigWithDbSchema } from '../types.js';
13+
import { type VitePlugin } from '../utils.js';
1214
import { errorMap } from './error-map.js';
13-
import { dirname } from 'path';
14-
import { fileURLToPath } from 'url';
15-
import { blue, yellow } from 'kleur/colors';
1615
import { fileURLIntegration } from './file-url.js';
17-
import { recreateTables, seedData } from '../queries.js';
18-
import { getManagedAppTokenOrExit, type ManagedAppToken } from '../tokens.js';
16+
import { typegen } from './typegen.js';
17+
import { vitePluginDb } from './vite-plugin-db.js';
18+
import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js';
1919

2020
function astroDBIntegration(): AstroIntegration {
2121
let connectedToRemote = false;

packages/db/src/core/integration/typegen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync } from 'node:fs';
22
import { mkdir, writeFile } from 'node:fs/promises';
3-
import type { DBTable, DBTables } from '../types.js';
43
import { DB_TYPES_FILE, RUNTIME_DRIZZLE_IMPORT, RUNTIME_IMPORT } from '../consts.js';
4+
import type { DBTable, DBTables } from '../types.js';
55

66
export async function typegen({ tables, root }: { tables: DBTables; root: URL }) {
77
const content = `// This file is generated by \`studio sync\`

packages/db/src/core/integration/vite-plugin-inject-env-ts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { existsSync } from 'node:fs';
22
import { readFile, writeFile } from 'node:fs/promises';
33
import path from 'node:path';
44
import { fileURLToPath } from 'node:url';
5+
import type { AstroIntegrationLogger } from 'astro';
56
import { bold, cyan } from 'kleur/colors';
67
import { normalizePath } from 'vite';
78
import { DB_TYPES_FILE } from '../consts.js';
89
import type { VitePlugin } from '../utils.js';
9-
import type { AstroIntegrationLogger } from 'astro';
1010

1111
export function vitePluginInjectEnvTs(
1212
{ srcDir, root }: { srcDir: URL; root: URL },

packages/db/src/core/queries.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
import type { AstroIntegrationLogger } from 'astro';
2+
import { type SQL, getTableName, sql } from 'drizzle-orm';
3+
import { SQLiteAsyncDialect, type SQLiteInsert } from 'drizzle-orm/sqlite-core';
14
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
5+
import { bold } from 'kleur/colors';
26
import {
37
type BooleanColumn,
8+
type ColumnType,
9+
type DBColumn,
410
type DBTable,
511
type DBTables,
6-
type DBColumn,
712
type DateColumn,
8-
type ColumnType,
913
type JsonColumn,
1014
type NumberColumn,
1115
type TextColumn,
1216
} from '../core/types.js';
13-
import { bold } from 'kleur/colors';
14-
import { type SQL, sql, getTableName } from 'drizzle-orm';
15-
import { SQLiteAsyncDialect, type SQLiteInsert } from 'drizzle-orm/sqlite-core';
16-
import type { AstroIntegrationLogger } from 'astro';
1717
import type {
1818
ColumnsConfig,
1919
DBUserConfig,

packages/db/src/core/tokens.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { readFile } from 'node:fs/promises';
22
import { homedir } from 'node:os';
33
import { join } from 'node:path';
44
import { pathToFileURL } from 'node:url';
5-
import { getAstroStudioEnv, getAstroStudioUrl } from './utils.js';
65
import { MISSING_PROJECT_ID_ERROR, MISSING_SESSION_ID_ERROR } from './errors.js';
6+
import { getAstroStudioEnv, getAstroStudioUrl } from './utils.js';
77

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

0 commit comments

Comments
 (0)