0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

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 <3019731+Princesseuh@users.noreply.github.com>

---------

Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
Emanuele Stoppa 2024-02-27 11:15:27 +00:00 committed by GitHub
parent 9c21a9df6b
commit 2dd00a0024
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
81 changed files with 199 additions and 197 deletions

View file

@ -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 }) {

View file

@ -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();

View file

@ -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

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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(

View file

@ -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,

View file

@ -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';

View file

@ -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';
@ -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);

View file

@ -1,7 +1,7 @@
/* eslint no-console: 'off' */
import { color, say as houston, label, spinner as load } from '@astrojs/cli-kit';
import { align, sleep } from '@astrojs/cli-kit/utils';
import { exec } from 'node:child_process';
/* eslint no-console: 'off' */
import { color, label, say as houston, spinner as load } from '@astrojs/cli-kit';
import { align, sleep } from '@astrojs/cli-kit/utils';
import stripAnsi from 'strip-ansi';
import { shell } from './shell.js';

View file

@ -1,14 +1,14 @@
import type { AstroConfig } from 'astro';
import type { Arguments } from 'yargs-parser';
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 { 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);

View file

@ -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');

View file

@ -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,

View file

@ -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';

View file

@ -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 {
createEmptySnapshot,
getMigrations,
getMigrationStatus,
loadInitialSnapshot,
loadMigration,
MIGRATION_NEEDED,
MIGRATIONS_NOT_INITIALIZED,
MIGRATIONS_UP_TO_DATE,
MIGRATION_NEEDED,
createEmptySnapshot,
getMigrationStatus,
getMigrations,
loadInitialSnapshot,
loadMigration,
} 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;

View file

@ -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);

View file

@ -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,
@ -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);

View file

@ -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 =

View file

@ -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!')}

View file

@ -1,8 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
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';
async function copyFile(toDir: URL, fromUrl: URL, toUrl: URL) {
await fs.promises.mkdir(toDir, { recursive: true });

View file

@ -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 { mkdir, rm, writeFile } from 'fs/promises';
import { DB_PATH } from '../consts.js';
import { createLocalDatabaseClient } from '../../runtime/db-client.js';
import { astroConfigWithDbSchema, type DBTables } from '../types.js';
import { type VitePlugin } from '../utils.js';
import { STUDIO_CONFIG_MISSING_WRITABLE_TABLE_ERROR, UNSAFE_WRITABLE_WARNING } from '../errors.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 { createLocalDatabaseClient } from '../../runtime/db-client.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 { getManagedAppTokenOrExit, type ManagedAppToken } from '../tokens.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 { fileURLIntegration } from './file-url.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;

View file

@ -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\`

View file

@ -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 },

View file

@ -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,

View file

@ -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'));

View file

@ -1,10 +1,10 @@
import { SQLiteAsyncDialect, type SQLiteInsertValue } from 'drizzle-orm/sqlite-core';
import type { InferSelectModel } from 'drizzle-orm';
import { collectionToTable, type SqliteDB, type Table } from '../runtime/index.js';
import { z, type ZodTypeDef } from 'zod';
import { SQL } from 'drizzle-orm';
import { errorMap } from './integration/error-map.js';
import { SQLiteAsyncDialect, type SQLiteInsertValue } from 'drizzle-orm/sqlite-core';
import { type ZodTypeDef, z } from 'zod';
import { type SqliteDB, type Table, collectionToTable } from '../runtime/index.js';
import { SERIALIZED_SQL_KEY, type SerializedSQL } from '../runtime/types.js';
import { errorMap } from './integration/error-map.js';
export type MaybePromise<T> = T | Promise<T>;
export type MaybeArray<T> = T | T[];

View file

@ -1,12 +1,12 @@
import type { InStatement } from '@libsql/client';
import { createClient } from '@libsql/client';
import { type DBTables } from '../core/types.js';
import { getTableName } from 'drizzle-orm';
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
import { drizzle as drizzleLibsql } from 'drizzle-orm/libsql';
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
import { type SQLiteTable } from 'drizzle-orm/sqlite-core';
import { drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
import { z } from 'zod';
import { getTableName } from 'drizzle-orm';
import { type DBTables } from '../core/types.js';
const isWebContainer = !!process.versions?.webcontainer;

View file

@ -1,16 +1,16 @@
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
import { type DBTable, type DBColumn } from '../core/types.js';
import { type ColumnBuilderBaseConfig, type ColumnDataType, sql } from 'drizzle-orm';
import {
type IndexBuilder,
type SQLiteColumnBuilderBase,
customType,
index,
integer,
sqliteTable,
text,
index,
type SQLiteColumnBuilderBase,
type IndexBuilder,
} from 'drizzle-orm/sqlite-core';
import { isSerializedSQL, type SerializedSQL } from './types.js';
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
import { type DBColumn, type DBTable } from '../core/types.js';
import { type SerializedSQL, isSerializedSQL } from './types.js';
export { sql };
export type SqliteDB = SqliteRemoteDatabase;

View file

@ -1,6 +1,6 @@
import type { ColumnDataType, ColumnBaseConfig } from 'drizzle-orm';
import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
import type { DBColumn, ColumnsConfig } from '../core/types.js';
import type { ColumnsConfig, DBColumn } from '../core/types.js';
type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<
ColumnBaseConfig<T, string>,

View file

@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import type { AstroIntegration } from 'astro';
import type { Plugin } from 'vite';
import { resolve } from 'node:path';
interface Options {
/**

View file

@ -1,4 +1,4 @@
import { customElements as litCE, HTMLElement as litShimHTMLElement } from '@lit-labs/ssr-dom-shim';
import { HTMLElement as litShimHTMLElement, customElements as litCE } from '@lit-labs/ssr-dom-shim';
// Something at build time injects document.currentScript = undefined instead of
// document.currentScript = null. This causes Sass build to fail because it

View file

@ -1,4 +1,6 @@
// Separate import from the rest so it doesn't get re-organized after other imports
import './server-shim.js';
import { LitElementRenderer } from '@lit-labs/ssr/lib/lit-element-renderer.js';
import * as parse5 from 'parse5';

View file

@ -1,5 +1,5 @@
import type { AstroIntegration } from 'astro';
import { readFileSync } from 'node:fs';
import type { AstroIntegration } from 'astro';
function getViteConfiguration() {
return {

View file

@ -1,12 +1,12 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Config as MarkdocConfig, Node } from '@markdoc/markdoc';
import Markdoc from '@markdoc/markdoc';
import type { AstroConfig, ContentEntryType } from 'astro';
import { emitESMImage } from 'astro/assets/utils';
import matter from 'gray-matter';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Rollup, ErrorPayload as ViteErrorPayload } from 'vite';
import type { ErrorPayload as ViteErrorPayload, Rollup } from 'vite';
import type { ComponentConfig } from './config.js';
import { htmlTokenTransform } from './html/transform/html-token-transform.js';
import type { MarkdocConfigResult } from './load-config.js';

View file

@ -1,6 +1,6 @@
import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter';
import { unescapeHTML } from 'astro/runtime/server/index.js';
import { Markdoc, type AstroMarkdocConfig } from '../config.js';
import { type AstroMarkdocConfig, Markdoc } from '../config.js';
export default function prism(): AstroMarkdocConfig {
return {

View file

@ -1,9 +1,9 @@
import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro';
import { getContentEntryType } from './content-entry-type.js';
import {
type MarkdocConfigResult,
SUPPORTED_MARKDOC_CONFIG_FILES,
loadMarkdocConfig,
type MarkdocConfigResult,
} from './load-config.js';
import type { MarkdocIntegrationOptions } from './options.js';

View file

@ -1,7 +1,7 @@
import type { AstroConfig } from 'astro';
import { build as esbuild } from 'esbuild';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import type { AstroConfig } from 'astro';
import { build as esbuild } from 'esbuild';
import type { AstroMarkdocConfig } from './config.js';
import { MarkdocError } from './utils.js';

View file

@ -1,9 +1,9 @@
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { markdownConfigDefaults, setVfileFrontmatter } from '@astrojs/markdown-remark';
import type { AstroIntegration, ContentEntryType, HookParameters, SSRError } from 'astro';
import astroJSXRenderer from 'astro/jsx/renderer.js';
import { parse as parseESM } from 'es-module-lexer';
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import type { PluggableList } from 'unified';
import { VFile } from 'vfile';

View file

@ -1,6 +1,6 @@
import type { MarkdownVFile } from '@astrojs/markdown-remark';
import type { Image, Parent } from 'mdast';
import type { MdxJsxFlowElement, MdxjsEsm, MdxJsxAttribute } from 'mdast-util-mdx';
import type { MdxJsxAttribute, MdxJsxFlowElement, MdxjsEsm } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
import { jsToTreeNode } from './utils.js';

View file

@ -1,5 +1,5 @@
import { AstroError } from 'astro/errors';
import type { AstroAdapter, AstroIntegration } from 'astro';
import { AstroError } from 'astro/errors';
import type { Options, UserOptions } from './types.js';
export function getAdapter(options: Options): AstroAdapter {

View file

@ -1,9 +1,9 @@
import os from 'node:os';
import type http from 'node:http';
import https from 'node:https';
import type { AddressInfo } from 'node:net';
import os from 'node:os';
import type { AstroIntegrationLogger } from 'astro';
import type { Options } from './types.js';
import type { AddressInfo } from 'node:net';
export async function logListeningOn(
logger: AstroIntegrationLogger,

View file

@ -1,6 +1,6 @@
import type { NodeApp } from 'astro/app/node';
import { createAppHandler } from './serve-app.js';
import type { RequestHandler } from './types.js';
import type { NodeApp } from 'astro/app/node';
/**
* Creates a middleware that can be used with Express, Connect, etc.

View file

@ -1,9 +1,9 @@
import { fileURLToPath } from 'node:url';
import type { CreatePreviewServer } from 'astro';
import { AstroError } from 'astro/errors';
import { logListeningOn } from './log-listening-on.js';
import { createServer } from './standalone.js';
import type { CreatePreviewServer } from 'astro';
import type { createExports } from './server.js';
import { createServer } from './standalone.js';
type ServerModule = ReturnType<typeof createExports>;
type MaybeServerModule = Partial<ServerModule>;

View file

@ -1,10 +1,10 @@
import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
import path from 'node:path';
import url from 'node:url';
import fs from 'node:fs';
import send from 'send';
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { Options } from './types.js';
import type { NodeApp } from 'astro/app/node';
import send from 'send';
import type { Options } from './types.js';
/**
* Creates a Node.js http listener for static files and prerendered pages.

View file

@ -1,8 +1,8 @@
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
import createMiddleware from './middleware.js';
import { createStandaloneHandler } from './standalone.js';
import startServer from './standalone.js';
import createMiddleware from './middleware.js';
import type { SSRManifest } from 'astro';
import type { Options } from './types.js';
applyPolyfills();

View file

@ -1,13 +1,13 @@
import http from 'node:http';
import https from 'https';
import fs from 'node:fs';
import http from 'node:http';
import type { PreviewServer } from 'astro';
import type { NodeApp } from 'astro/app/node';
import enableDestroy from 'server-destroy';
import { logListeningOn } from './log-listening-on.js';
import { createAppHandler } from './serve-app.js';
import { createStaticHandler } from './serve-static.js';
import { logListeningOn } from './log-listening-on.js';
import type { NodeApp } from 'astro/app/node';
import type { Options } from './types.js';
import type { PreviewServer } from 'astro';
export default function standalone(app: NodeApp, options: Options) {
const port = process.env.PORT ? Number(process.env.PORT) : options.port ?? 8080;

View file

@ -1,6 +1,6 @@
import type { NodeApp } from 'astro/app/node';
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { SSRManifest } from 'astro';
import type { NodeApp } from 'astro/app/node';
export interface UserOptions {
/**

View file

@ -1,11 +1,11 @@
import type { PartytownConfig } from '@builder.io/partytown/integration';
import { partytownSnippet } from '@builder.io/partytown/integration';
import { copyLibFiles, libDirPath } from '@builder.io/partytown/utils';
import type { AstroIntegration } from 'astro';
import { createRequire } from 'module';
import * as fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { PartytownConfig } from '@builder.io/partytown/integration';
import { partytownSnippet } from '@builder.io/partytown/integration';
import { copyLibFiles, libDirPath } from '@builder.io/partytown/utils';
import type { AstroIntegration } from 'astro';
import sirv from './sirv.js';
const resolve = createRequire(import.meta.url).resolve;

View file

@ -32,10 +32,10 @@
import * as fs from 'node:fs';
import { join, normalize, resolve } from 'node:path';
import { URL } from 'node:url';
// import { totalist } from 'totalist/sync';
// import { parse } from '@polka/url';
import { lookup } from 'mrmime';
import { URL } from 'node:url';
const noop = () => {};

View file

@ -1,6 +1,6 @@
import { preact, type PreactPluginOptions as VitePreactPluginOptions } from '@preact/preset-vite';
import type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';
import { fileURLToPath } from 'node:url';
import { type PreactPluginOptions as VitePreactPluginOptions, preact } from '@preact/preset-vite';
import type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';
const babelCwd = new URL('../', import.meta.url);

View file

@ -1,7 +1,7 @@
import type { AstroComponentMetadata } from 'astro';
import { Component as BaseComponent, h, type VNode } from 'preact';
import prepass from 'preact-ssr-prepass';
import { Component as BaseComponent, type VNode, h } from 'preact';
import { render } from 'preact-render-to-string';
import prepass from 'preact-ssr-prepass';
import { getContext } from './context.js';
import { restoreSignalsOnProps, serializeSignals } from './signals.js';
import StaticHtml from './static-html.js';

View file

@ -1,5 +1,5 @@
import { createElement } from 'react';
import { render, hydrate, unmountComponentAtNode } from 'react-dom';
import { hydrate, render, unmountComponentAtNode } from 'react-dom';
import StaticHtml from './static-html.js';
export default (element) =>

View file

@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/server';
import StaticHtml from './static-html.js';
import { incrementId } from './context.js';
import StaticHtml from './static-html.js';
import opts from 'astro:react:opts';
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());

View file

@ -1,5 +1,5 @@
import { parse, DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE } from 'ultrahtml';
import { createElement, Fragment } from 'react';
import { Fragment, createElement } from 'react';
import { DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE, parse } from 'ultrahtml';
let ids = 0;
export default function convert(children) {

View file

@ -1,6 +1,6 @@
import type { AstroConfig, AstroIntegration } from 'astro';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { AstroConfig, AstroIntegration } from 'astro';
import type { EnumChangefreq, LinkItem as LinkItemBase, SitemapItemLoose } from 'sitemap';
import { simpleSitemapAndIndex } from 'sitemap';
import { ZodError } from 'zod';

View file

@ -1,11 +1,11 @@
import {
NoHydration,
Suspense,
createComponent,
generateHydrationScript,
NoHydration,
renderToString,
renderToStringAsync,
ssr,
Suspense,
} from 'solid-js/web';
import { getContext, incrementId } from './context.js';
import type { RendererContext } from './types.js';

View file

@ -1,5 +1,5 @@
import { render } from 'svelte/server';
import { add_snippet_symbol } from 'svelte/internal';
import { render } from 'svelte/server';
// Allow a slot to be rendered as a snippet (dev validation only)
const tagSlotAsSnippet = import.meta.env.DEV ? add_snippet_symbol : (s) => s;

View file

@ -1,7 +1,7 @@
import { fileURLToPath } from 'node:url';
import type { Options } from '@sveltejs/vite-plugin-svelte';
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import type { AstroIntegration, AstroRenderer } from 'astro';
import { fileURLToPath } from 'node:url';
import { VERSION } from 'svelte/compiler';
import type { UserConfig } from 'vite';

View file

@ -1,6 +1,6 @@
import type { AstroIntegrationLogger } from 'astro';
import { relative, relative as relativePath } from 'node:path';
import { relative as relativePath } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { AstroIntegrationLogger } from 'astro';
import { copyFilesToFunction } from './fs.js';
export async function copyDependenciesToFunction(
@ -21,7 +21,7 @@ export async function copyDependenciesToFunction(
cache: object
): Promise<{ handler: string }> {
const entryPath = fileURLToPath(entry);
logger.info(`Bundling function ${relative(fileURLToPath(outDir), entryPath)}`);
logger.info(`Bundling function ${relativePath(fileURLToPath(outDir), entryPath)}`);
// Get root of folder of the system (like C:\ on Windows or / on Linux)
let base = entry;

View file

@ -1,6 +1,6 @@
import nodePath from 'node:path';
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
import type { AstroConfig, RouteData, RoutePart } from 'astro';
import nodePath from 'node:path';
const pathJoin = nodePath.posix.join;

View file

@ -1,3 +1,6 @@
import { existsSync, readFileSync } from 'node:fs';
import { basename } from 'node:path';
import { pathToFileURL } from 'node:url';
import type {
AstroAdapter,
AstroConfig,
@ -7,25 +10,22 @@ import type {
} from 'astro';
import { AstroError } from 'astro/errors';
import glob from 'fast-glob';
import { basename } from 'node:path';
import { pathToFileURL } from 'node:url';
import { existsSync, readFileSync } from 'node:fs';
import {
getAstroImageConfig,
getDefaultImageConfig,
type DevImageService,
type VercelImageConfig,
getAstroImageConfig,
getDefaultImageConfig,
} from '../image/shared.js';
import { removeDir, writeJson } from '../lib/fs.js';
import { copyDependenciesToFunction } from '../lib/nft.js';
import { escapeRegex, getRedirects } from '../lib/redirects.js';
import {
getSpeedInsightsViteConfig,
type VercelSpeedInsightsConfig,
getSpeedInsightsViteConfig,
} from '../lib/speed-insights.js';
import {
getInjectableWebAnalyticsContent,
type VercelWebAnalyticsConfig,
getInjectableWebAnalyticsContent,
} from '../lib/web-analytics.js';
import { generateEdgeMiddleware } from './middleware.js';

View file

@ -1,11 +1,11 @@
import type { SSRManifest } from 'astro';
import { applyPolyfills, NodeApp } from 'astro/app/node';
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
import {
ASTRO_PATH_HEADER,
ASTRO_PATH_PARAM,
ASTRO_LOCALS_HEADER,
ASTRO_MIDDLEWARE_SECRET_HEADER,
ASTRO_PATH_HEADER,
ASTRO_PATH_PARAM,
} from './adapter.js';
applyPolyfills();

View file

@ -1,9 +1,9 @@
import { existsSync } from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { builtinModules } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import {
ASTRO_MIDDLEWARE_SECRET_HEADER,
ASTRO_LOCALS_HEADER,
ASTRO_MIDDLEWARE_SECRET_HEADER,
ASTRO_PATH_HEADER,
NODE_PATH,
} from './adapter.js';

View file

@ -1,21 +1,21 @@
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import {
getAstroImageConfig,
getDefaultImageConfig,
type DevImageService,
type VercelImageConfig,
getAstroImageConfig,
getDefaultImageConfig,
} from '../image/shared.js';
import { emptyDir, writeJson } from '../lib/fs.js';
import { isServerLikeOutput } from '../lib/prerender.js';
import { getRedirects } from '../lib/redirects.js';
import {
getSpeedInsightsViteConfig,
type VercelSpeedInsightsConfig,
getSpeedInsightsViteConfig,
} from '../lib/speed-insights.js';
import {
getInjectableWebAnalyticsContent,
type VercelWebAnalyticsConfig,
getInjectableWebAnalyticsContent,
} from '../lib/web-analytics.js';
const PACKAGE_NAME = '@astrojs/vercel/static';

View file

@ -1,6 +1,6 @@
import { h, createSSRApp, createApp, Suspense } from 'vue';
import { setup } from 'virtual:@astrojs/vue/app';
import { Suspense, createApp, createSSRApp, h } from 'vue';
import StaticHtml from './static-html.js';
import { setup } from 'virtual:@astrojs/vue/app';
export default (element) =>
async (Component, props, slotted, { client }) => {

View file

@ -1,7 +1,7 @@
import { h, createSSRApp } from 'vue';
import { createSSRApp, h } from 'vue';
import { renderToString } from 'vue/server-renderer';
import { setup } from 'virtual:@astrojs/vue/app';
import StaticHtml from './static-html.js';
import { setup } from 'virtual:@astrojs/vue/app';
function check(Component) {
return !!Component['ssrRender'] || !!Component['__ssrInlineRender'];

View file

@ -2,9 +2,9 @@ import path from 'node:path';
import type { Options as VueOptions } from '@vitejs/plugin-vue';
import vue from '@vitejs/plugin-vue';
import type { Options as VueJsxOptions } from '@vitejs/plugin-vue-jsx';
import { MagicString } from '@vue/compiler-sfc';
import type { AstroIntegration, AstroRenderer } from 'astro';
import type { Plugin, UserConfig } from 'vite';
import { MagicString } from '@vue/compiler-sfc';
interface Options extends VueOptions {
jsx?: boolean | VueJsxOptions;

View file

@ -1,4 +1,4 @@
import { h, defineComponent } from 'vue';
import { defineComponent, h } from 'vue';
/**
* Astro passes `children` as a string of HTML, so we need

View file

@ -1,4 +1,4 @@
import type { VFileData as Data, VFile } from 'vfile';
import type { VFile, VFileData as Data } from 'vfile';
import type { MarkdownAstroData } from './types.js';
function isValidAstroData(obj: unknown): obj is MarkdownAstroData {

View file

@ -1,7 +1,7 @@
// This file should be imported as `#import-plugin`
import { resolve as importMetaResolve } from 'import-meta-resolve';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
// This file should be imported as `#import-plugin`
import { resolve as importMetaResolve } from 'import-meta-resolve';
import type * as unified from 'unified';
let cwdUrlStr: string | undefined;

View file

@ -1,5 +1,5 @@
import { visit } from 'unist-util-visit';
import { createShikiHighlighter, type ShikiHighlighter } from './shiki.js';
import { type ShikiHighlighter, createShikiHighlighter } from './shiki.js';
import type { RemarkPlugin, ShikiConfig } from './types.js';
export function remarkShiki(config?: ShikiConfig): ReturnType<RemarkPlugin> {

View file

@ -1,6 +1,6 @@
import type { Properties } from 'hast';
import { bundledLanguages, createCssVariablesTheme, getHighlighter } from 'shikiji';
import { visit } from 'unist-util-visit';
import type { Properties } from 'hast';
import type { ShikiConfig } from './types.js';
export interface ShikiHighlighter {

View file

@ -1,9 +1,9 @@
import dget from 'dlv';
import { dset } from 'dset';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import dget from 'dlv';
import { dset } from 'dset';
export interface ConfigOptions {
name: string;

View file

@ -1,11 +1,11 @@
import { randomBytes } from 'node:crypto';
import { isCI } from 'ci-info';
import debug from 'debug';
import { randomBytes } from 'node:crypto';
import * as KEY from './config-keys.js';
import { GlobalConfig } from './config.js';
import { post } from './post.js';
import { getProjectInfo, type ProjectInfo } from './project-info.js';
import { getSystemInfo, type SystemInfo } from './system-info.js';
import { type ProjectInfo, getProjectInfo } from './project-info.js';
import { type SystemInfo, getSystemInfo } from './system-info.js';
export type AstroTelemetryOptions = { astroVersion: string; viteVersion: string };
export type TelemetryEvent = { eventName: string; payload: Record<string, any> };

View file

@ -1,7 +1,7 @@
import { name as ciName, isCI } from 'ci-info';
import os from 'node:os';
import { isCI, name as ciName } from 'ci-info';
import isDocker from 'is-docker';
import isWSL from 'is-wsl';
import os from 'node:os';
/**
* Astro Telemetry -- System Info

View file

@ -1,5 +1,5 @@
import type { AstroConfig, RouteData, ValidRedirectStatus } from 'astro';
import { posix } from 'node:path';
import type { AstroConfig, RouteData, ValidRedirectStatus } from 'astro';
import { Redirects } from './redirects.js';
const pathJoin = posix.join;

View file

@ -1,6 +1,6 @@
import { pathToFileURL } from 'node:url';
import { prompt } from '@astrojs/cli-kit';
import arg from 'arg';
import { pathToFileURL } from 'node:url';
import detectPackageManager from 'which-pm-runs';
export interface Context {

View file

@ -1,10 +1,10 @@
import type { Context, PackageInfo } from './context.js';
import { color, say } from '@astrojs/cli-kit';
import { random, sleep } from '@astrojs/cli-kit/utils';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { color, say } from '@astrojs/cli-kit';
import { random, sleep } from '@astrojs/cli-kit/utils';
import {
banner,
bye,

View file

@ -1,9 +1,9 @@
import type { Context, PackageInfo } from './context.js';
import { color } from '@astrojs/cli-kit';
import dns from 'node:dns/promises';
import { existsSync } from 'node:fs';
import { readFile } from 'node:fs/promises';
import { color } from '@astrojs/cli-kit';
import semverCoerce from 'semver/functions/coerce.js';
import semverDiff from 'semver/functions/diff.js';
import semverParse from 'semver/functions/parse.js';

View file

@ -2,7 +2,7 @@ import { getContext } from './actions/context.js';
import { help } from './actions/help.js';
import { install } from './actions/install.js';
import { verify, collectPackageInfo } from './actions/verify.js';
import { collectPackageInfo, verify } from './actions/verify.js';
import { setStdout } from './messages.js';
const exit = () => process.exit(0);