diff options
142 files changed, 402 insertions, 855 deletions
diff --git a/.changeset/icy-stars-begin.md b/.changeset/icy-stars-begin.md new file mode 100644 index 000000000..4ab54c397 --- /dev/null +++ b/.changeset/icy-stars-begin.md @@ -0,0 +1,22 @@ +--- +'@astrojs/cloudflare': patch +'@astrojs/web-vitals': patch +'@astrojs/alpinejs': patch +'@astrojs/markdoc': patch +'@astrojs/netlify': patch +'@astrojs/sitemap': patch +'@astrojs/underscore-redirects': patch +'@astrojs/preact': patch +'@astrojs/vercel': patch +'@astrojs/solid-js': patch +'@astrojs/node': patch +'@astrojs/mdx': patch +'create-astro': patch +'@astrojs/telemetry': patch +'@astrojs/upgrade': patch +'@astrojs/studio': patch +'astro': patch +'@astrojs/db': patch +--- + +Removes unused code diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17d609981..a3a556196 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,8 @@ jobs: run: pnpm install - name: Build Packages - run: pnpm run build + # The cache doesn't contain prebuild files and causes knip to fail + run: pnpm run build --force - name: Lint source code run: pnpm run lint:ci diff --git a/benchmark/make-project/_template.js b/benchmark/make-project/_template.js index dd392138e..a99c52428 100644 --- a/benchmark/make-project/_template.js +++ b/benchmark/make-project/_template.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ /** * Create a new project in the `projectDir` directory. Make sure to clean up the * previous artifacts here before generating files. diff --git a/biome.jsonc b/biome.jsonc index 83c559f4d..588d8f5f1 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -32,9 +32,9 @@ "noConsoleLog": "warn" }, "correctness": { - "noUnusedVariables": "info", - "noUnusedFunctionParameters": "info", - "noUnusedImports": "warn" + "noUnusedVariables": "error", + "noUnusedFunctionParameters": "error", + "noUnusedImports": "error" } } }, diff --git a/eslint.config.js b/eslint.config.js index c5fbf3fbc..c7a454ea5 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,6 +23,7 @@ export default [ 'packages/**/*.min.js', 'packages/**/dist/', 'packages/**/fixtures/', + 'packages/**/_temp-fixtures/', 'packages/astro/vendor/vite/', 'benchmark/**/dist/', 'examples/', @@ -54,7 +55,18 @@ export default [ 'no-console': 'off', // Todo: do we want these? - '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], '@typescript-eslint/array-type': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/class-literal-property-style': 'off', diff --git a/knip.js b/knip.js new file mode 100644 index 000000000..5f543e1bd --- /dev/null +++ b/knip.js @@ -0,0 +1,77 @@ +// @ts-check +const testEntry = 'test/**/*.test.js'; + +/** @type {import('knip').KnipConfig} */ +export default { + ignore: ['**/test/**/{fixtures,_temp-fixtures}/**', '.github/scripts/**'], + tags: ['-lintignore'], + ignoreWorkspaces: [ + 'examples/**', + '**/{test,e2e}/**/{fixtures,_temp-fixtures}/**', + 'benchmark/**', + ], + workspaces: { + '.': { + ignoreDependencies: [ + '@astrojs/check', // Used by the build script but not as a standard module import + ], + // In smoke tests, we checkout to the docs repo so those binaries are not present in this project + ignoreBinaries: ['docgen', 'docgen:errors', 'playwright'], + }, + 'packages/*': { + entry: [testEntry], + }, + 'packages/astro': { + entry: [ + // Can't be detected automatically since it's only in package.json#files + 'templates/**/*', + testEntry, + 'test/types/**/*', + 'e2e/**/*.test.js', + 'test/units/teardown.js', + ], + ignore: ['**/e2e/**/{fixtures,_temp-fixtures}/**', 'performance/**/*'], + // Those deps are used in tests but only referenced as strings + ignoreDependencies: [ + 'rehype-autolink-headings', + 'rehype-slug', + 'rehype-toc', + 'remark-code-titles', + ], + }, + 'packages/integrations/*': { + entry: [testEntry], + }, + 'packages/integrations/cloudflare': { + entry: [testEntry], + // False positive because of cloudflare:workers + ignoreDependencies: ['cloudflare'], + }, + 'packages/integrations/mdx': { + entry: [testEntry], + // Required but not imported directly + ignoreDependencies: ['@types/*'], + }, + 'packages/integrations/netlify': { + entry: [testEntry], + ignore: ['test/hosted/**'], + }, + 'packages/integrations/solid': { + entry: [testEntry], + // It's an optional peer dep (triggers a warning) but it's fine in this case + ignoreDependencies: ['solid-devtools'], + }, + 'packages/integrations/vercel': { + entry: [testEntry, 'test/test-image-service.js'], + ignore: ['test/hosted/**'], + }, + 'packages/markdown/remark': { + entry: [testEntry], + // package.json#imports are not resolved at the moment + ignore: ['src/import-plugin-browser.ts'], + }, + 'packages/upgrade': { + entry: ['src/index.ts', testEntry], + }, + }, +}; diff --git a/package.json b/package.json index bf86b365d..145078de4 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,13 @@ "test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match", "test:e2e:hosts": "turbo run test:hosted", "benchmark": "astro-benchmark", - "lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn", - "lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn", + "lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn && knip", + "lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn && knip", "lint:fix": "biome lint --write --unsafe", "publint": "pnpm -r --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --no-bail exec publint", "version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format", - "preinstall": "npx only-allow pnpm" + "preinstall": "npx only-allow pnpm", + "knip": "knip" }, "workspaces": [ "packages/markdown/*", @@ -58,10 +59,11 @@ "@biomejs/biome": "1.9.4", "@changesets/changelog-github": "^0.5.1", "@changesets/cli": "^2.28.1", - "@types/node": "^18.17.8", + "@types/node": "^18.19.50", "esbuild": "^0.25.0", "eslint": "^9.24.0", "eslint-plugin-regexp": "^2.7.0", + "knip": "5.50.5", "only-allow": "^1.2.1", "prettier": "^3.5.3", "prettier-plugin-astro": "^0.14.1", diff --git a/packages/astro/e2e/test-utils.js b/packages/astro/e2e/test-utils.js index a2728f962..d2858db0a 100644 --- a/packages/astro/e2e/test-utils.js +++ b/packages/astro/e2e/test-utils.js @@ -4,10 +4,6 @@ import { fileURLToPath } from 'node:url'; import { expect, test as testBase } from '@playwright/test'; import { loadFixture as baseLoadFixture } from '../test/test-utils.js'; -export const isWindows = process.platform === 'win32'; - -export { silentLogging } from '../test/test-utils.js'; - // Get all test files in directory, assign unique port for each of them so they don't conflict const testFiles = await fs.readdir(new URL('.', import.meta.url)); const testFileToPort = new Map(); diff --git a/packages/astro/package.json b/packages/astro/package.json index f263aef19..32a484d74 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -47,10 +47,7 @@ "./compiler-runtime": "./dist/runtime/compiler/index.js", "./runtime/*": "./dist/runtime/*", "./config": "./dist/config/entrypoint.js", - "./container": { - "types": "./dist/container/index.d.ts", - "default": "./dist/container/index.js" - }, + "./container": "./dist/container/index.js", "./app": "./dist/core/app/index.js", "./app/node": "./dist/core/app/node.js", "./client/*": "./dist/runtime/client/*", @@ -76,10 +73,7 @@ "default": "./zod.mjs" }, "./errors": "./dist/core/errors/userError.js", - "./middleware": { - "types": "./dist/core/middleware/index.d.ts", - "default": "./dist/core/middleware/index.js" - }, + "./middleware": "./dist/core/middleware/index.js", "./virtual-modules/*": "./dist/virtual-modules/*" }, "bin": { diff --git a/packages/astro/src/assets/fonts/config.ts b/packages/astro/src/assets/fonts/config.ts index 1f837862a..5377fd755 100644 --- a/packages/astro/src/assets/fonts/config.ts +++ b/packages/astro/src/assets/fonts/config.ts @@ -69,7 +69,7 @@ const fallbacksSchema = z.object({ optimizedFallbacks: z.boolean().optional(), }); -export const requiredFamilyAttributesSchema = z.object({ +const requiredFamilyAttributesSchema = z.object({ /** * The font family name, as identified by your font provider. */ diff --git a/packages/astro/src/assets/fonts/utils.ts b/packages/astro/src/assets/fonts/utils.ts index e715580bc..627a60b0e 100644 --- a/packages/astro/src/assets/fonts/utils.ts +++ b/packages/astro/src/assets/fonts/utils.ts @@ -26,7 +26,7 @@ export function renderFontFace(properties: Record<string, string | undefined>) { return `@font-face {\n\t${toCSS(properties)}\n}\n`; } -export function unifontFontFaceDataToProperties( +function unifontFontFaceDataToProperties( font: Partial<unifont.FontFaceData>, ): Record<string, string | undefined> { return { diff --git a/packages/astro/src/assets/services/service.ts b/packages/astro/src/assets/services/service.ts index 4bb643a9c..7fa062188 100644 --- a/packages/astro/src/assets/services/service.ts +++ b/packages/astro/src/assets/services/service.ts @@ -81,7 +81,7 @@ interface SharedServiceProps<T extends Record<string, any> = Record<string, any> export type ExternalImageService<T extends Record<string, any> = Record<string, any>> = SharedServiceProps<T>; -export type LocalImageTransform = { +type LocalImageTransform = { src: string; [key: string]: any; }; diff --git a/packages/astro/src/assets/utils/etag.ts b/packages/astro/src/assets/utils/etag.ts index 78d208b90..d1650b8c0 100644 --- a/packages/astro/src/assets/utils/etag.ts +++ b/packages/astro/src/assets/utils/etag.ts @@ -8,7 +8,7 @@ * Simplified, optimized and add modified for 52 bit, which provides a larger hash space * and still making use of Javascript's 53-bit integer space. */ -export const fnv1a52 = (str: string) => { +const fnv1a52 = (str: string) => { const len = str.length; let i = 0, t0 = 0, diff --git a/packages/astro/src/assets/utils/vendor/image-size/lookup.ts b/packages/astro/src/assets/utils/vendor/image-size/lookup.ts index d3283e72e..d3fd3fe19 100644 --- a/packages/astro/src/assets/utils/vendor/image-size/lookup.ts +++ b/packages/astro/src/assets/utils/vendor/image-size/lookup.ts @@ -1,16 +1,7 @@ -import type { imageType } from './types/index.js' import { typeHandlers } from './types/index.js' import { detector } from './detector.js' import type { ISizeCalculationResult } from './types/interface.ts' -type Options = { - disabledTypes: imageType[] -} - -const globalOptions: Options = { - disabledTypes: [], -} - /** * Return size information based on an Uint8Array * @@ -22,10 +13,6 @@ export function lookup(input: Uint8Array): ISizeCalculationResult { const type = detector(input) if (typeof type !== 'undefined') { - if (globalOptions.disabledTypes.includes(type)) { - throw new TypeError('disabled file type: ' + type) - } - // find an appropriate handler for this file type const size = typeHandlers.get(type)!.calculate(input) if (size !== undefined) { @@ -37,7 +24,3 @@ export function lookup(input: Uint8Array): ISizeCalculationResult { // throw up, if we don't understand the file throw new TypeError('unsupported file type: ' + type) } - -export const disableTypes = (types: imageType[]): void => { - globalOptions.disabledTypes = types -} diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index 693db9cb7..11f598554 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -503,11 +503,7 @@ function addVitePlugin(mod: ProxifiedModule<any>, pluginId: string, packageName: } } -export function setAdapter( - mod: ProxifiedModule<any>, - adapter: IntegrationInfo, - exportName: string, -) { +function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo, exportName: string) { const config = getDefaultExportOptions(mod); const adapterId = toIdent(adapter.id); diff --git a/packages/astro/src/cli/info/index.ts b/packages/astro/src/cli/info/index.ts index aca66ad71..554c89608 100644 --- a/packages/astro/src/cli/info/index.ts +++ b/packages/astro/src/cli/info/index.ts @@ -52,7 +52,7 @@ export async function printInfo({ flags }: InfoOptions) { await copyToClipboard(output, flags.copy); } -export async function copyToClipboard(text: string, force?: boolean) { +async function copyToClipboard(text: string, force?: boolean) { text = text.trim(); const system = platform(); let command = ''; diff --git a/packages/astro/src/cli/preferences/index.ts b/packages/astro/src/cli/preferences/index.ts index c31841d24..7824f0688 100644 --- a/packages/astro/src/cli/preferences/index.ts +++ b/packages/astro/src/cli/preferences/index.ts @@ -26,7 +26,7 @@ const PREFERENCES_SUBCOMMANDS = [ 'reset', 'list', ] as const; -export type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number]; +type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number]; type AnnotatedValue = { annotation: string; value: string | number | boolean }; type AnnotatedValues = Record<string, AnnotatedValue>; diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 6559d4594..5c92c47a0 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -124,10 +124,6 @@ export type AddClientRenderer = { entrypoint: string; }; -type ContainerImportRendererFn = ( - containerRenderer: ContainerRenderer, -) => Promise<SSRLoadedRenderer>; - function createManifest( manifest?: AstroContainerManifest, renderers?: SSRLoadedRenderer[], @@ -269,12 +265,6 @@ export class experimental_AstroContainer { */ #withManifest = false; - /** - * Internal function responsible for importing a renderer - * @private - */ - #getRenderer: ContainerImportRendererFn | undefined; - private constructor({ streaming = false, manifest, @@ -414,7 +404,7 @@ export class experimental_AstroContainer { } // NOTE: we keep this private via TS instead via `#` so it's still available on the surface, so we can play with it. - // @ematipico: I plan to use it for a possible integration that could help people + // @ts-expect-error @ematipico: I plan to use it for a possible integration that could help people private static async createFromManifest( manifest: SSRManifest, ): Promise<experimental_AstroContainer> { diff --git a/packages/astro/src/content/content-layer.ts b/packages/astro/src/content/content-layer.ts index 10879f2b5..1992e7706 100644 --- a/packages/astro/src/content/content-layer.ts +++ b/packages/astro/src/content/content-layer.ts @@ -26,7 +26,7 @@ import { } from './utils.js'; import { type WrappedWatcher, createWatcherWrapper } from './watcher.js'; -export interface ContentLayerOptions { +interface ContentLayerOptions { store: MutableDataStore; settings: AstroSettings; logger: Logger; @@ -39,7 +39,7 @@ type CollectionLoader<TData> = () => | Record<string, Record<string, unknown>> | Promise<Record<string, Record<string, unknown>>>; -export class ContentLayer { +class ContentLayer { #logger: Logger; #store: MutableDataStore; #settings: AstroSettings; @@ -342,7 +342,7 @@ export class ContentLayer { } } -export async function simpleLoader<TData extends { id: string }>( +async function simpleLoader<TData extends { id: string }>( handler: CollectionLoader<TData>, context: LoaderContext, ) { diff --git a/packages/astro/src/content/index.ts b/packages/astro/src/content/index.ts index 2aef23e85..9161a5fe9 100644 --- a/packages/astro/src/content/index.ts +++ b/packages/astro/src/content/index.ts @@ -1,7 +1,6 @@ -export { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from './consts.js'; export { attachContentServerListeners } from './server-listeners.js'; export { createContentTypesGenerator } from './types-generator.js'; -export { contentObservable, getContentPaths, hasAssetPropagationFlag } from './utils.js'; +export { getContentPaths, hasAssetPropagationFlag } from './utils.js'; export { astroContentAssetPropagationPlugin } from './vite-plugin-content-assets.js'; export { astroContentImportPlugin } from './vite-plugin-content-imports.js'; export { astroContentVirtualModPlugin } from './vite-plugin-content-virtual-mod.js'; diff --git a/packages/astro/src/content/loaders/file.ts b/packages/astro/src/content/loaders/file.ts index c37998a76..f64679bb1 100644 --- a/packages/astro/src/content/loaders/file.ts +++ b/packages/astro/src/content/loaders/file.ts @@ -4,7 +4,7 @@ import yaml from 'js-yaml'; import { posixRelative } from '../utils.js'; import type { Loader, LoaderContext } from './types.js'; -export interface FileOptions { +interface FileOptions { /** * the parsing function to use for this data * @default JSON.parse or yaml.load, depending on the extension of the file diff --git a/packages/astro/src/content/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts index 9727ccc08..cb6faa059 100644 --- a/packages/astro/src/content/loaders/glob.ts +++ b/packages/astro/src/content/loaders/glob.ts @@ -10,7 +10,7 @@ import type { RenderedContent } from '../data-store.js'; import { getContentEntryIdAndSlug, posixRelative } from '../utils.js'; import type { Loader } from './types.js'; -export interface GenerateIdOptions { +interface GenerateIdOptions { /** The path to the entry file, relative to the base directory. */ entry: string; @@ -20,7 +20,7 @@ export interface GenerateIdOptions { data: Record<string, unknown>; } -export interface GlobOptions { +interface GlobOptions { /** The glob pattern to match files, relative to the base directory */ pattern: string | Array<string>; /** The base directory to resolve the glob pattern from. Relative to the root directory, or an absolute file URL. Defaults to `.` */ diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index b08ea252e..a319dfd29 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -17,7 +17,7 @@ import type { AstroSettings } from '../types/astro.js'; import type { AstroConfig } from '../types/public/config.js'; import type { ContentEntryType, DataEntryType } from '../types/public/content.js'; import { - CONTENT_FLAGS, + type CONTENT_FLAGS, CONTENT_LAYER_TYPE, CONTENT_MODULE_FLAG, DEFERRED_MODULE, @@ -495,15 +495,6 @@ export function safeParseFrontmatter(source: string, id?: string) { */ export const globalContentConfigObserver = contentObservable({ status: 'init' }); -export function hasAnyContentFlag(viteId: string): boolean { - const flags = new URLSearchParams(viteId.split('?')[1] ?? ''); - const flag = Array.from(flags.keys()).at(0); - if (typeof flag !== 'string') { - return false; - } - return CONTENT_FLAGS.includes(flag as any); -} - export function hasContentFlag(viteId: string, flag: (typeof CONTENT_FLAGS)[number]): boolean { const flags = new URLSearchParams(viteId.split('?')[1] ?? ''); return flags.has(flag); @@ -542,7 +533,7 @@ async function loadContentConfig({ } } -export async function autogenerateCollections({ +async function autogenerateCollections({ config, settings, fs, @@ -679,7 +670,7 @@ type Observable<C> = { export type ContentObservable = Observable<ContentCtx>; -export function contentObservable(initialCtx: ContentCtx): ContentObservable { +function contentObservable(initialCtx: ContentCtx): ContentObservable { type Subscriber = (ctx: ContentCtx) => void; const subscribers = new Set<Subscriber>(); let ctx = initialCtx; @@ -809,7 +800,7 @@ export function globWithUnderscoresIgnored(relContentDir: string, exts: string[] /** * Convert a platform path to a posix path. */ -export function posixifyPath(filePath: string) { +function posixifyPath(filePath: string) { return filePath.split(path.sep).join('/'); } diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts index df84eed5c..ff0435844 100644 --- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts +++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts @@ -198,7 +198,7 @@ export function astroContentVirtualModPlugin({ }; } -export async function generateContentEntryFile({ +async function generateContentEntryFile({ settings, lookupMap, isClient, @@ -258,7 +258,7 @@ export async function generateContentEntryFile({ * This is used internally to resolve entry imports when using `getEntry()`. * @see `templates/content/module.mjs` */ -export async function generateLookupMap({ +async function generateLookupMap({ settings, fs, }: { diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index ce7990b64..6bb166e6b 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -122,7 +122,7 @@ export class App { // to return the host 404 if the user doesn't provide a custom 404 ensure404Route(this.#manifestData); this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#manifest.base); - this.#pipeline = this.#createPipeline(this.#manifestData, streaming); + this.#pipeline = this.#createPipeline(streaming); this.#adapterLogger = new AstroIntegrationLogger( this.#logger.options, this.#manifest.adapterName, @@ -136,12 +136,11 @@ export class App { /** * Creates a pipeline by reading the stored manifest * - * @param manifestData * @param streaming * @private */ - #createPipeline(manifestData: RoutesList, streaming = false) { - return AppPipeline.create(manifestData, { + #createPipeline(streaming = false) { + return AppPipeline.create({ logger: this.#logger, manifest: this.#manifest, runtimeMode: 'production', diff --git a/packages/astro/src/core/app/pipeline.ts b/packages/astro/src/core/app/pipeline.ts index fe9b6257d..632c26710 100644 --- a/packages/astro/src/core/app/pipeline.ts +++ b/packages/astro/src/core/app/pipeline.ts @@ -1,4 +1,4 @@ -import type { ComponentInstance, RoutesList } from '../../types/astro.js'; +import type { ComponentInstance } from '../../types/astro.js'; import type { RewritePayload } from '../../types/public/common.js'; import type { RouteData, SSRElement, SSRResult } from '../../types/public/internal.js'; import { Pipeline, type TryRewriteResult } from '../base-pipeline.js'; @@ -8,31 +8,26 @@ import { createModuleScriptElement, createStylesheetElementSet } from '../render import { findRouteToRewrite } from '../routing/rewrite.js'; export class AppPipeline extends Pipeline { - #manifestData: RoutesList | undefined; - - static create( - manifestData: RoutesList, - { - logger, - manifest, - runtimeMode, - renderers, - resolve, - serverLike, - streaming, - defaultRoutes, - }: Pick< - AppPipeline, - | 'logger' - | 'manifest' - | 'runtimeMode' - | 'renderers' - | 'resolve' - | 'serverLike' - | 'streaming' - | 'defaultRoutes' - >, - ) { + static create({ + logger, + manifest, + runtimeMode, + renderers, + resolve, + serverLike, + streaming, + defaultRoutes, + }: Pick< + AppPipeline, + | 'logger' + | 'manifest' + | 'runtimeMode' + | 'renderers' + | 'resolve' + | 'serverLike' + | 'streaming' + | 'defaultRoutes' + >) { const pipeline = new AppPipeline( logger, manifest, @@ -51,7 +46,6 @@ export class AppPipeline extends Pipeline { undefined, defaultRoutes, ); - pipeline.#manifestData = manifestData; return pipeline; } diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 9339f2384..90e4be871 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -12,7 +12,7 @@ import type { } from '../../types/public/internal.js'; import type { SinglePageBuiltModule } from '../build/types.js'; -export type ComponentPath = string; +type ComponentPath = string; export type StylesheetAsset = | { type: 'inline'; content: string } @@ -35,7 +35,7 @@ export type SerializedRouteInfo = Omit<RouteInfo, 'routeData'> & { routeData: SerializedRouteData; }; -export type ImportComponentInstance = () => Promise<SinglePageBuiltModule>; +type ImportComponentInstance = () => Promise<SinglePageBuiltModule>; export type AssetsPrefix = | string diff --git a/packages/astro/src/core/build/consts.ts b/packages/astro/src/core/build/consts.ts index 2926d1e86..bf3162fc4 100644 --- a/packages/astro/src/core/build/consts.ts +++ b/packages/astro/src/core/build/consts.ts @@ -1,2 +1 @@ export const CHUNKS_PATH = 'chunks/'; -export const CONTENT_PATH = 'content/'; diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 9a90daf9d..76e56d3d0 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -33,7 +33,7 @@ import { staticBuild, viteBuild } from './static-build.js'; import type { StaticBuildOptions } from './types.js'; import { getTimeStat } from './util.js'; -export interface BuildOptions { +interface BuildOptions { /** * Output a development-based build similar to code transformed in `astro dev`. This * can be useful to test build-only issues with additional debugging information included. diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts index 78271d4e9..7d69b7235 100644 --- a/packages/astro/src/core/build/page-data.ts +++ b/packages/astro/src/core/build/page-data.ts @@ -7,13 +7,13 @@ import { debug } from '../logger/core.js'; import { DEFAULT_COMPONENTS } from '../routing/default.js'; import { makePageDataKey } from './plugins/util.js'; -export interface CollectPagesDataOptions { +interface CollectPagesDataOptions { settings: AstroSettings; logger: Logger; manifest: RoutesList; } -export interface CollectPagesDataResult { +interface CollectPagesDataResult { assets: Record<string, string>; allPages: AllPagesData; } diff --git a/packages/astro/src/core/build/plugin.ts b/packages/astro/src/core/build/plugin.ts index f16b5a1d9..33b1b722f 100644 --- a/packages/astro/src/core/build/plugin.ts +++ b/packages/astro/src/core/build/plugin.ts @@ -9,7 +9,7 @@ export type BuildTarget = 'server' | 'client'; type MutateChunk = (chunk: OutputChunk, targets: BuildTarget[], newCode: string) => void; -export interface BuildBeforeHookResult { +interface BuildBeforeHookResult { enforce?: 'after-user-plugins'; vitePlugin: VitePlugin | VitePlugin[] | undefined; } diff --git a/packages/astro/src/core/build/plugins/plugin-analyzer.ts b/packages/astro/src/core/build/plugins/plugin-analyzer.ts index 2b64d3383..5b949c841 100644 --- a/packages/astro/src/core/build/plugins/plugin-analyzer.ts +++ b/packages/astro/src/core/build/plugins/plugin-analyzer.ts @@ -9,7 +9,7 @@ import { } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; -export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin { +function vitePluginAnalyzer(internals: BuildInternals): VitePlugin { return { name: '@astro/rollup-plugin-astro-analyzer', async generateBundle() { diff --git a/packages/astro/src/core/build/plugins/plugin-chunks.ts b/packages/astro/src/core/build/plugins/plugin-chunks.ts index 3348e126c..f281386e5 100644 --- a/packages/astro/src/core/build/plugins/plugin-chunks.ts +++ b/packages/astro/src/core/build/plugins/plugin-chunks.ts @@ -2,7 +2,7 @@ import type { Plugin as VitePlugin } from 'vite'; import type { AstroBuildPlugin } from '../plugin.js'; import { extendManualChunks } from './util.js'; -export function vitePluginChunks(): VitePlugin { +function vitePluginChunks(): VitePlugin { return { name: 'astro:chunks', outputOptions(outputOptions) { diff --git a/packages/astro/src/core/build/plugins/plugin-component-entry.ts b/packages/astro/src/core/build/plugins/plugin-component-entry.ts index d7fc8aa5e..ec614f508 100644 --- a/packages/astro/src/core/build/plugins/plugin-component-entry.ts +++ b/packages/astro/src/core/build/plugins/plugin-component-entry.ts @@ -2,14 +2,14 @@ import type { Plugin as VitePlugin } from 'vite'; import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; -export const astroEntryPrefix = '\0astro-entry:'; +const astroEntryPrefix = '\0astro-entry:'; /** * When adding hydrated or client:only components as Rollup inputs, sometimes we're not using all * of the export names, e.g. `import { Counter } from './ManyComponents.jsx'`. This plugin proxies * entries to re-export only the names the user is using. */ -export function vitePluginComponentEntry(internals: BuildInternals): VitePlugin { +function vitePluginComponentEntry(internals: BuildInternals): VitePlugin { const componentToExportNames = new Map<string, string[]>(); mergeComponentExportNames(internals.discoveredHydratedComponents); diff --git a/packages/astro/src/core/build/plugins/plugin-internals.ts b/packages/astro/src/core/build/plugins/plugin-internals.ts index 01d524515..2d4dfc360 100644 --- a/packages/astro/src/core/build/plugins/plugin-internals.ts +++ b/packages/astro/src/core/build/plugins/plugin-internals.ts @@ -3,7 +3,7 @@ import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; import { normalizeEntryId } from './plugin-component-entry.js'; -export function vitePluginInternals(input: Set<string>, internals: BuildInternals): VitePlugin { +function vitePluginInternals(input: Set<string>, internals: BuildInternals): VitePlugin { return { name: '@astro/plugin-build-internals', diff --git a/packages/astro/src/core/build/plugins/plugin-renderers.ts b/packages/astro/src/core/build/plugins/plugin-renderers.ts index 1b4b8105a..4ef4342dd 100644 --- a/packages/astro/src/core/build/plugins/plugin-renderers.ts +++ b/packages/astro/src/core/build/plugins/plugin-renderers.ts @@ -6,7 +6,7 @@ import type { StaticBuildOptions } from '../types.js'; export const RENDERERS_MODULE_ID = '@astro-renderers'; export const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`; -export function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin { +function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin { return { name: '@astro/plugin-renderers', diff --git a/packages/astro/src/core/build/plugins/plugin-scripts.ts b/packages/astro/src/core/build/plugins/plugin-scripts.ts index e41d1fe44..022f3716d 100644 --- a/packages/astro/src/core/build/plugins/plugin-scripts.ts +++ b/packages/astro/src/core/build/plugins/plugin-scripts.ts @@ -6,7 +6,7 @@ import { shouldInlineAsset } from './util.js'; /** * Inline scripts from Astro files directly into the HTML. */ -export function vitePluginScripts(internals: BuildInternals): VitePlugin { +function vitePluginScripts(internals: BuildInternals): VitePlugin { let assetInlineLimit: NonNullable<BuildOptions['assetsInlineLimit']>; return { diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index fdc05026f..649bdc39e 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -13,7 +13,7 @@ import { ASTRO_PAGE_MODULE_ID } from './plugin-pages.js'; import { RENDERERS_MODULE_ID } from './plugin-renderers.js'; import { getVirtualModulePageName } from './util.js'; -export const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry'; +const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry'; export const RESOLVED_SSR_VIRTUAL_MODULE_ID = '\0' + SSR_VIRTUAL_MODULE_ID; const ADAPTER_VIRTUAL_MODULE_ID = '@astrojs-ssr-adapter'; diff --git a/packages/astro/src/core/build/plugins/util.ts b/packages/astro/src/core/build/plugins/util.ts index c636928d0..63200d9e9 100644 --- a/packages/astro/src/core/build/plugins/util.ts +++ b/packages/astro/src/core/build/plugins/util.ts @@ -46,7 +46,7 @@ export function extendManualChunks(outputOptions: OutputOptions, hooks: ExtendMa export const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@'; // This is an arbitrary string that we use to make a pageData key // Has to be a invalid character for a route, to avoid conflicts. -export const ASTRO_PAGE_KEY_SEPARATOR = '&'; +const ASTRO_PAGE_KEY_SEPARATOR = '&'; /** * Generate a unique key to identify each page in the build process. @@ -103,10 +103,7 @@ export function getPagesFromVirtualModulePageName( * @param virtualModulePrefix The prefix at the beginning of the virtual module * @param id Virtual module name */ -export function getComponentFromVirtualModulePageName( - virtualModulePrefix: string, - id: string, -): string { +function getComponentFromVirtualModulePageName(virtualModulePrefix: string, id: string): string { return id.slice(virtualModulePrefix.length).replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.'); } diff --git a/packages/astro/src/core/build/types.ts b/packages/astro/src/core/build/types.ts index f647e053a..4c3e0136f 100644 --- a/packages/astro/src/core/build/types.ts +++ b/packages/astro/src/core/build/types.ts @@ -6,7 +6,7 @@ import type { RuntimeMode } from '../../types/public/config.js'; import type { RouteData, SSRLoadedRenderer } from '../../types/public/internal.js'; import type { Logger } from '../logger/core.js'; -export type ComponentPath = string; +type ComponentPath = string; export type ViteID = string; export type StylesheetAsset = diff --git a/packages/astro/src/core/config/config.ts b/packages/astro/src/core/config/config.ts index ae15805ff..9a371e994 100644 --- a/packages/astro/src/core/config/config.ts +++ b/packages/astro/src/core/config/config.ts @@ -26,7 +26,7 @@ export function resolveRoot(cwd?: string | URL): string { // Config paths to search for. In order of likely appearance // to speed up the check. -export const configPaths = Object.freeze([ +const configPaths = Object.freeze([ 'astro.config.mjs', 'astro.config.js', 'astro.config.ts', diff --git a/packages/astro/src/core/config/index.ts b/packages/astro/src/core/config/index.ts index f5449d4ff..00832e847 100644 --- a/packages/astro/src/core/config/index.ts +++ b/packages/astro/src/core/config/index.ts @@ -1,11 +1,9 @@ export { - configPaths, resolveConfig, resolveConfigPath, resolveRoot, } from './config.js'; export { createNodeLogger } from './logging.js'; export { mergeConfig } from './merge.js'; -export type { AstroConfigType } from './schemas/index.js'; export { createSettings } from './settings.js'; export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js'; diff --git a/packages/astro/src/core/config/schemas/base.ts b/packages/astro/src/core/config/schemas/base.ts index 5d2c0196a..f33b2f9e5 100644 --- a/packages/astro/src/core/config/schemas/base.ts +++ b/packages/astro/src/core/config/schemas/base.ts @@ -31,6 +31,7 @@ import type { AstroUserConfig, ViteUserConfig } from '../../../types/public/conf // Also, make sure to not index the complexified type, as it would return a simplified value type, which goes // back to the issue again. The complexified type should be the base representation that we want to expose. +/** @lintignore */ // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface ComplexifyUnionObj {} @@ -42,6 +43,7 @@ type ShikiTheme = ComplexifyWithUnion<NonNullable<ShikiConfig['theme']>>; type ShikiTransformer = ComplexifyWithUnion<NonNullable<ShikiConfig['transformers']>[number]>; type RehypePlugin = ComplexifyWithUnion<_RehypePlugin>; type RemarkPlugin = ComplexifyWithUnion<_RemarkPlugin>; +/** @lintignore */ export type RemarkRehype = ComplexifyWithOmit<_RemarkRehype>; export const ASTRO_CONFIG_DEFAULTS = { diff --git a/packages/astro/src/core/config/timer.ts b/packages/astro/src/core/config/timer.ts index d41009b11..d9e47ab21 100644 --- a/packages/astro/src/core/config/timer.ts +++ b/packages/astro/src/core/config/timer.ts @@ -1,7 +1,7 @@ import fs from 'node:fs'; // Type used by `bench-memory.js` -export interface Stat { +interface Stat { elapsedTime: number; heapUsedChange: number; heapUsedTotal: number; diff --git a/packages/astro/src/core/config/tsconfig.ts b/packages/astro/src/core/config/tsconfig.ts index 03d89e30c..6a165a490 100644 --- a/packages/astro/src/core/config/tsconfig.ts +++ b/packages/astro/src/core/config/tsconfig.ts @@ -169,7 +169,7 @@ function deepMergeObjects<T extends Record<string, any>>(a: T, b: T): T { // https://github.com/unjs/pkg-types/blob/78328837d369d0145a8ddb35d7fe1fadda4bfadf/src/types/tsconfig.ts // See https://github.com/unjs/pkg-types/blob/78328837d369d0145a8ddb35d7fe1fadda4bfadf/LICENSE for license information -export type StripEnums<T extends Record<string, any>> = { +type StripEnums<T extends Record<string, any>> = { [K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string diff --git a/packages/astro/src/core/constants.ts b/packages/astro/src/core/constants.ts index dc09a1f69..8b304aa12 100644 --- a/packages/astro/src/core/constants.ts +++ b/packages/astro/src/core/constants.ts @@ -47,11 +47,6 @@ export const ROUTE_TYPE_HEADER = 'X-Astro-Route-Type'; export const DEFAULT_404_COMPONENT = 'astro-default-404.astro'; /** - * The value of the `component` field of the default 500 page, which is used when there is no user-provided 404.astro page. - */ -export const DEFAULT_500_COMPONENT = 'astro-default-500.astro'; - -/** * A response with one of these status codes will create a redirect response. */ export const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308, 300, 304] as const; diff --git a/packages/astro/src/core/cookies/index.ts b/packages/astro/src/core/cookies/index.ts index 1ac732f1b..f837acf48 100644 --- a/packages/astro/src/core/cookies/index.ts +++ b/packages/astro/src/core/cookies/index.ts @@ -2,6 +2,5 @@ export { AstroCookies } from './cookies.js'; export { attachCookiesToResponse, getSetCookiesFromResponse, - responseHasCookies, } from './response.js'; export type { AstroCookieSetOptions, AstroCookieGetOptions } from './cookies.js'; diff --git a/packages/astro/src/core/cookies/response.ts b/packages/astro/src/core/cookies/response.ts index 288bb3e93..8b94ed5f2 100644 --- a/packages/astro/src/core/cookies/response.ts +++ b/packages/astro/src/core/cookies/response.ts @@ -6,10 +6,6 @@ export function attachCookiesToResponse(response: Response, cookies: AstroCookie Reflect.set(response, astroCookiesSymbol, cookies); } -export function responseHasCookies(response: Response): boolean { - return Reflect.has(response, astroCookiesSymbol); -} - export function getCookiesFromResponse(response: Response): AstroCookies | undefined { let cookies = Reflect.get(response, astroCookiesSymbol); if (cookies != null) { diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts index c984fae7d..5da3f0c39 100644 --- a/packages/astro/src/core/dev/container.ts +++ b/packages/astro/src/core/dev/container.ts @@ -30,7 +30,7 @@ export interface Container { close: () => Promise<void>; } -export interface CreateContainerParams { +interface CreateContainerParams { logger: Logger; settings: AstroSettings; inlineConfig?: AstroInlineConfig; diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index 47de19bde..bf68dd926 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -1,3 +1,3 @@ -export { createContainer, startContainer } from './container.js'; +export { startContainer } from './container.js'; export { default } from './dev.js'; export { createContainerWithAutomaticRestart } from './restart.js'; diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index 4aa1e2b74..7138055ec 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -103,7 +103,7 @@ async function restartContainer(container: Container): Promise<Container | Error } } -export interface CreateContainerWithAutomaticRestart { +interface CreateContainerWithAutomaticRestart { inlineConfig?: AstroInlineConfig; fs: typeof nodeFs; } diff --git a/packages/astro/src/core/encryption.ts b/packages/astro/src/core/encryption.ts index 253e5f3c9..5f72e7367 100644 --- a/packages/astro/src/core/encryption.ts +++ b/packages/astro/src/core/encryption.ts @@ -26,7 +26,7 @@ const ENVIRONMENT_KEY_NAME = 'ASTRO_KEY' as const; /** * Get the encoded value of the ASTRO_KEY env var. */ -export function getEncodedEnvironmentKey(): string { +function getEncodedEnvironmentKey(): string { return process.env[ENVIRONMENT_KEY_NAME] || ''; } @@ -52,14 +52,6 @@ export async function getEnvironmentKey(): Promise<CryptoKey> { } /** - * Takes a key that has been serialized to an array of bytes and returns a CryptoKey - */ -export async function importKey(bytes: Uint8Array): Promise<CryptoKey> { - const key = await crypto.subtle.importKey('raw', bytes, ALGORITHM, true, ['encrypt', 'decrypt']); - return key; -} - -/** * Encodes a CryptoKey to base64 string, so that it can be embedded in JSON / JavaScript */ export async function encodeKey(key: CryptoKey) { diff --git a/packages/astro/src/core/errors/index.ts b/packages/astro/src/core/errors/index.ts index 1889a72c6..df948d664 100644 --- a/packages/astro/src/core/errors/index.ts +++ b/packages/astro/src/core/errors/index.ts @@ -8,7 +8,6 @@ export { MarkdownError, isAstroError, } from './errors.js'; -export type { ErrorLocation, ErrorWithMetadata } from './errors.js'; -export { codeFrame } from './printer.js'; +export type { ErrorWithMetadata } from './errors.js'; export { createSafeError, positionAt } from './utils.js'; export { errorMap } from './zod-error-map.js'; diff --git a/packages/astro/src/core/logger/core.ts b/packages/astro/src/core/logger/core.ts index 9d8c7e357..76a0f29d7 100644 --- a/packages/astro/src/core/logger/core.ts +++ b/packages/astro/src/core/logger/core.ts @@ -11,7 +11,7 @@ export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // sam * rather than specific to a single command, function, use, etc. The label will be * shown in the log message to the user, so it should be relevant. */ -export type LoggerLabel = +type LoggerLabel = | 'add' | 'build' | 'check' @@ -53,6 +53,7 @@ export interface LogOptions { // Here be the dragons we've slain: // https://github.com/withastro/astro/issues/2625 // https://github.com/withastro/astro/issues/3309 +/** @lintignore */ export const dateTimeFormat = new Intl.DateTimeFormat([], { hour: '2-digit', minute: '2-digit', @@ -76,7 +77,7 @@ export const levels: Record<LoggerLevel, number> = { }; /** Full logging API */ -export function log( +function log( opts: LogOptions, level: LoggerLevel, label: string | null, @@ -105,17 +106,17 @@ export function isLogLevelEnabled(configuredLogLevel: LoggerLevel, level: Logger } /** Emit a user-facing message. Useful for UI and other console messages. */ -export function info(opts: LogOptions, label: string | null, message: string, newLine = true) { +function info(opts: LogOptions, label: string | null, message: string, newLine = true) { return log(opts, 'info', label, message, newLine); } /** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */ -export function warn(opts: LogOptions, label: string | null, message: string, newLine = true) { +function warn(opts: LogOptions, label: string | null, message: string, newLine = true) { return log(opts, 'warn', label, message, newLine); } /** Emit a error message, Useful when Astro can't recover from some error. */ -export function error(opts: LogOptions, label: string | null, message: string, newLine = true) { +function error(opts: LogOptions, label: string | null, message: string, newLine = true) { return log(opts, 'error', label, message, newLine); } diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index ca2dcfae4..5a2b510ae 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -1,7 +1,6 @@ import { bgCyan, bgGreen, - bgRed, bgWhite, bgYellow, black, @@ -203,16 +202,6 @@ export function success(message: string, tip?: string) { .join('\n'); } -export function failure(message: string, tip?: string) { - const badge = bgRed(black(` error `)); - const headline = red(message); - const footer = tip ? `\n â–¶ ${tip}` : undefined; - return ['', `${badge} ${headline}`, footer] - .filter((v) => v !== undefined) - .map((msg) => ` ${msg}`) - .join('\n'); -} - export function actionRequired(message: string) { const badge = bgYellow(black(` action required `)); const headline = yellow(message); diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index 814566161..50c8405f2 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -8,7 +8,7 @@ import * as msg from '../messages.js'; import { getResolvedHostForHttpServer } from './util.js'; import { vitePluginAstroPreview } from './vite-plugin-astro-preview.js'; -export interface PreviewServer { +interface PreviewServer { host?: string; port: number; server: http.Server; diff --git a/packages/astro/src/core/redirects/index.ts b/packages/astro/src/core/redirects/index.ts index 321195cbd..f979b30dd 100644 --- a/packages/astro/src/core/redirects/index.ts +++ b/packages/astro/src/core/redirects/index.ts @@ -1,4 +1,3 @@ export { RedirectComponentInstance, RedirectSinglePageBuiltModule } from './component.js'; export { routeIsRedirect } from './helpers.js'; export { getRedirectLocationOrThrow } from './validate.js'; -export { renderRedirect } from './render.js'; diff --git a/packages/astro/src/core/render/index.ts b/packages/astro/src/core/render/index.ts index b56a2eaf2..bc6d2c6f4 100644 --- a/packages/astro/src/core/render/index.ts +++ b/packages/astro/src/core/render/index.ts @@ -1,22 +1,4 @@ -import type { ComponentInstance } from '../../types/astro.js'; -import type { RouteData } from '../../types/public/internal.js'; -import type { Pipeline } from '../base-pipeline.js'; export { Pipeline } from '../base-pipeline.js'; export { getParams, getProps } from './params-and-props.js'; export { loadRenderer } from './renderer.js'; export { Slots } from './slots.js'; - -export interface SSROptions { - /** The pipeline instance */ - pipeline: Pipeline; - /** location of file on disk */ - filePath: URL; - /** the web request (needed for dynamic routes) */ - pathname: string; - /** The runtime component instance */ - preload: ComponentInstance; - /** Request */ - request: Request; - /** optional, in case we need to render something outside a dev server */ - route: RouteData; -} diff --git a/packages/astro/src/core/render/ssr-element.ts b/packages/astro/src/core/render/ssr-element.ts index 7b5cac844..074e01851 100644 --- a/packages/astro/src/core/render/ssr-element.ts +++ b/packages/astro/src/core/render/ssr-element.ts @@ -14,7 +14,7 @@ export function createAssetLink(href: string, base?: string, assetsPrefix?: Asse } } -export function createStylesheetElement( +function createStylesheetElement( stylesheet: StylesheetAsset, base?: string, assetsPrefix?: AssetsPrefix, @@ -60,7 +60,7 @@ export function createModuleScriptElement( } } -export function createModuleScriptElementWithSrc( +function createModuleScriptElementWithSrc( src: string, base?: string, assetsPrefix?: AssetsPrefix, diff --git a/packages/astro/src/core/request.ts b/packages/astro/src/core/request.ts index 5e646bb89..e2c79211e 100644 --- a/packages/astro/src/core/request.ts +++ b/packages/astro/src/core/request.ts @@ -3,7 +3,7 @@ import type { Logger } from './logger/core.js'; type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders; -export interface CreateRequestOptions { +interface CreateRequestOptions { url: URL | string; clientAddress?: string | undefined; headers: HeaderType; diff --git a/packages/astro/src/core/routing/3xx.ts b/packages/astro/src/core/routing/3xx.ts index 4b800b55f..e2a48ae56 100644 --- a/packages/astro/src/core/routing/3xx.ts +++ b/packages/astro/src/core/routing/3xx.ts @@ -1,4 +1,4 @@ -export type RedirectTemplate = { +type RedirectTemplate = { from?: string; absoluteLocation: string | URL; status: number; diff --git a/packages/astro/src/core/routing/astro-designed-error-pages.ts b/packages/astro/src/core/routing/astro-designed-error-pages.ts index 6cca57a59..0adade6e9 100644 --- a/packages/astro/src/core/routing/astro-designed-error-pages.ts +++ b/packages/astro/src/core/routing/astro-designed-error-pages.ts @@ -1,7 +1,7 @@ import notFoundTemplate from '../../template/4xx.js'; import type { ComponentInstance, RoutesList } from '../../types/astro.js'; import type { RouteData } from '../../types/public/internal.js'; -import { DEFAULT_404_COMPONENT, DEFAULT_500_COMPONENT } from '../constants.js'; +import { DEFAULT_404_COMPONENT } from '../constants.js'; export const DEFAULT_404_ROUTE: RouteData = { component: DEFAULT_404_COMPONENT, @@ -18,21 +18,6 @@ export const DEFAULT_404_ROUTE: RouteData = { origin: 'internal', }; -export const DEFAULT_500_ROUTE: RouteData = { - component: DEFAULT_500_COMPONENT, - generate: () => '', - params: [], - pattern: /\/500/, - prerender: false, - pathname: '/500', - segments: [[{ content: '500', dynamic: false, spread: false }]], - type: 'page', - route: '/500', - fallbackRoutes: [], - isIndex: false, - origin: 'internal', -}; - export function ensure404Route(manifest: RoutesList) { if (!manifest.routes.some((route) => route.route === '/404')) { manifest.routes.push(DEFAULT_404_ROUTE); diff --git a/packages/astro/src/core/routing/index.ts b/packages/astro/src/core/routing/index.ts index 1267d67e7..663d184c2 100644 --- a/packages/astro/src/core/routing/index.ts +++ b/packages/astro/src/core/routing/index.ts @@ -1,4 +1,3 @@ export { createRoutesList } from './manifest/create.js'; -export { deserializeRouteData, serializeRouteData } from './manifest/serialization.js'; -export { matchAllRoutes, matchRoute } from './match.js'; -export { validateDynamicRouteModule, validateGetStaticPathsResult } from './validation.js'; +export { serializeRouteData } from './manifest/serialization.js'; +export { matchAllRoutes } from './match.js'; diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 45566cf9c..8b7a97eb9 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -47,7 +47,7 @@ interface Item { const ROUTE_DYNAMIC_SPLIT = /\[(.+?\(.+?\)|.+?)\]/; const ROUTE_SPREAD = /^\.{3}.+$/; -export function getParts(part: string, file: string) { +function getParts(part: string, file: string) { const result: RoutePart[] = []; part.split(ROUTE_DYNAMIC_SPLIT).map((str, i) => { if (!str) return; @@ -102,7 +102,7 @@ function isSemanticallyEqualSegment(segmentA: RoutePart[], segmentB: RoutePart[] return true; } -export interface CreateRouteManifestParams { +interface CreateRouteManifestParams { /** Astro Settings object */ settings: AstroSettings; /** Current working directory */ diff --git a/packages/astro/src/core/routing/request.ts b/packages/astro/src/core/routing/request.ts index f7e917a53..0a801b233 100644 --- a/packages/astro/src/core/routing/request.ts +++ b/packages/astro/src/core/routing/request.ts @@ -3,7 +3,7 @@ */ // Parses multiple header and returns first value if available. -export function getFirstForwardedValue(multiValueHeader?: string | string[] | null) { +function getFirstForwardedValue(multiValueHeader?: string | string[] | null) { return multiValueHeader ?.toString() ?.split(',') diff --git a/packages/astro/src/core/routing/rewrite.ts b/packages/astro/src/core/routing/rewrite.ts index 2e92c6e12..5a8bf4b9a 100644 --- a/packages/astro/src/core/routing/rewrite.ts +++ b/packages/astro/src/core/routing/rewrite.ts @@ -14,7 +14,7 @@ import { import { createRequest } from '../request.js'; import { DEFAULT_404_ROUTE } from './astro-designed-error-pages.js'; -export type FindRouteToRewrite = { +type FindRouteToRewrite = { payload: RewritePayload; routes: RouteData[]; request: Request; @@ -23,7 +23,7 @@ export type FindRouteToRewrite = { base: AstroConfig['base']; }; -export interface FindRouteToRewriteResult { +interface FindRouteToRewriteResult { routeData: RouteData; newUrl: URL; pathname: string; diff --git a/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts b/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts index 8cfbd6996..7c719c2ca 100644 --- a/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts +++ b/packages/astro/src/core/server-islands/vite-plugin-server-islands.ts @@ -4,7 +4,7 @@ import type { AstroPluginOptions } from '../../types/astro.js'; import type { AstroPluginMetadata } from '../../vite-plugin-astro/index.js'; export const VIRTUAL_ISLAND_MAP_ID = '@astro-server-islands'; -export const RESOLVED_VIRTUAL_ISLAND_MAP_ID = '\0' + VIRTUAL_ISLAND_MAP_ID; +const RESOLVED_VIRTUAL_ISLAND_MAP_ID = '\0' + VIRTUAL_ISLAND_MAP_ID; const serverIslandPlaceholder = "'$$server-islands$$'"; export function vitePluginServerIslands({ settings, logger }: AstroPluginOptions): VitePlugin { diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index b6e0c9591..77e7c0b6f 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -36,7 +36,7 @@ import { createRoutesList } from '../routing/index.js'; import { ensureProcessNodeEnv } from '../util.js'; import { normalizePath } from '../viteUtils.js'; -export type SyncOptions = { +type SyncOptions = { mode: string; /** * @internal only used for testing diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index 22be8d0ba..9269bf17d 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -100,7 +100,7 @@ export function viteID(filePath: URL): string { } export const VALID_ID_PREFIX = `/@id/`; -export const NULL_BYTE_PLACEHOLDER = `__x00__`; +const NULL_BYTE_PLACEHOLDER = `__x00__`; // Strip valid id prefix and replace null byte placeholder. Both are prepended to resolved ids // as they are not valid browser import specifiers (by the Vite's importAnalysis plugin) diff --git a/packages/astro/src/events/session.ts b/packages/astro/src/events/session.ts index 513afaf63..8bc400d74 100644 --- a/packages/astro/src/events/session.ts +++ b/packages/astro/src/events/session.ts @@ -17,7 +17,7 @@ type ConfigInfoRecord = Record<string, ConfigInfoValue>; type ConfigInfoBase = { [alias in keyof AstroUserConfig]: ConfigInfoValue | ConfigInfoRecord; }; -export interface ConfigInfo extends ConfigInfoBase { +interface ConfigInfo extends ConfigInfoBase { build: ConfigInfoRecord; image: ConfigInfoRecord; markdown: ConfigInfoRecord; diff --git a/packages/astro/src/integrations/features-validation.ts b/packages/astro/src/integrations/features-validation.ts index 9383c76b2..0edcb7bb9 100644 --- a/packages/astro/src/integrations/features-validation.ts +++ b/packages/astro/src/integrations/features-validation.ts @@ -96,7 +96,7 @@ export function validateSupportedFeatures( return validationResult; } -export function unwrapSupportKind(supportKind?: AdapterSupport): AdapterSupportsKind | undefined { +function unwrapSupportKind(supportKind?: AdapterSupport): AdapterSupportsKind | undefined { if (!supportKind) { return undefined; } @@ -104,7 +104,7 @@ export function unwrapSupportKind(supportKind?: AdapterSupport): AdapterSupports return typeof supportKind === 'object' ? supportKind.support : supportKind; } -export function getSupportMessage(supportKind: AdapterSupport): string | undefined { +function getSupportMessage(supportKind: AdapterSupport): string | undefined { return typeof supportKind === 'object' ? supportKind.message : undefined; } diff --git a/packages/astro/src/preferences/index.ts b/packages/astro/src/preferences/index.ts index e34486739..eaedb1ed9 100644 --- a/packages/astro/src/preferences/index.ts +++ b/packages/astro/src/preferences/index.ts @@ -16,13 +16,13 @@ type DotKeys<T> = T extends object }[keyof T] : never; -export type GetDotKey< +type GetDotKey< T extends Record<string | number, any>, K extends string, > = K extends `${infer U}.${infer Rest}` ? GetDotKey<T[U], Rest> : T[K]; -export type PreferenceLocation = 'global' | 'project'; -export interface PreferenceOptions { +type PreferenceLocation = 'global' | 'project'; +interface PreferenceOptions { location?: PreferenceLocation; /** * If `true`, the server will be reloaded after setting the preference. @@ -40,7 +40,7 @@ type DeepPartial<T> = T extends object : T; export type PreferenceKey = DotKeys<Preferences>; -export interface PreferenceList extends Record<PreferenceLocation, DeepPartial<PublicPreferences>> { +interface PreferenceList extends Record<PreferenceLocation, DeepPartial<PublicPreferences>> { fromAstroConfig: DeepPartial<Preferences>; defaults: PublicPreferences; } diff --git a/packages/astro/src/type-utils.ts b/packages/astro/src/type-utils.ts index 1aa816aad..206d38dfd 100644 --- a/packages/astro/src/type-utils.ts +++ b/packages/astro/src/type-utils.ts @@ -21,14 +21,6 @@ export type OmitPreservingIndexSignature<T, K extends PropertyKey> = { [P in keyof T as Exclude<P, K>]: T[P]; }; -// Transform a string into its kebab case equivalent (camelCase -> kebab-case). Useful for CSS-in-JS to CSS. -export type Kebab<T extends string, A extends string = ''> = T extends `${infer F}${infer R}` - ? Kebab<R, `${A}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`> - : A; - -// Transform every key of an object to its kebab case equivalent using the above utility -export type KebabKeys<T> = { [K in keyof T as K extends string ? Kebab<K> : K]: T[K] }; - // Similar to `keyof`, gets the type of all the values of an object export type ValueOf<T> = T[keyof T]; diff --git a/packages/astro/src/types/typed-emitter.ts b/packages/astro/src/types/typed-emitter.ts index 43139bd4e..771907bf0 100644 --- a/packages/astro/src/types/typed-emitter.ts +++ b/packages/astro/src/types/typed-emitter.ts @@ -4,7 +4,7 @@ * https://github.com/andywer/typed-emitter/blob/9a139b6fa0ec6b0db6141b5b756b784e4f7ef4e4/LICENSE */ -export type EventMap = { +type EventMap = { [key: string]: (...args: any[]) => void; }; diff --git a/packages/astro/src/vite-plugin-astro-server/controller.ts b/packages/astro/src/vite-plugin-astro-server/controller.ts index 9ba345d69..06c8796e7 100644 --- a/packages/astro/src/vite-plugin-astro-server/controller.ts +++ b/packages/astro/src/vite-plugin-astro-server/controller.ts @@ -16,7 +16,7 @@ export interface DevServerController { onHMRError: LoaderEvents['hmr-error']; } -export type CreateControllerParams = +type CreateControllerParams = | { loader: ModuleLoader; } @@ -84,7 +84,7 @@ function createLoaderController(loader: ModuleLoader): DevServerController { return controller; } -export interface RunWithErrorHandlingParams { +interface RunWithErrorHandlingParams { controller: DevServerController; pathname: string; run: () => Promise<any>; diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 88b8b0a81..3e64b560a 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -26,7 +26,7 @@ import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; import { trailingSlashMiddleware } from './trailing-slash.js'; -export interface AstroPluginOptions { +interface AstroPluginOptions { settings: AstroSettings; logger: Logger; fs: typeof fs; diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index ac7883c60..a1747c2dd 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -1,29 +1,11 @@ import type http from 'node:http'; import { Http2ServerResponse } from 'node:http2'; -import type { ErrorWithMetadata } from '../core/errors/index.js'; -import type { ModuleLoader } from '../core/module-loader/index.js'; - import { Readable } from 'node:stream'; import { getSetCookiesFromResponse } from '../core/cookies/index.js'; import { getViteErrorPayload } from '../core/errors/dev/index.js'; +import type { ErrorWithMetadata } from '../core/errors/index.js'; +import type { ModuleLoader } from '../core/module-loader/index.js'; import { redirectTemplate } from '../core/routing/3xx.js'; -import notFoundTemplate from '../template/4xx.js'; - -export async function handle404Response( - origin: string, - req: http.IncomingMessage, - res: http.ServerResponse, -) { - const pathname = decodeURI(new URL(origin + req.url).pathname); - - const html = notFoundTemplate({ - statusCode: 404, - title: 'Not found', - tabTitle: '404: Not Found', - pathname, - }); - writeHtmlResponse(res, 404, html); -} export async function handle500Response( loader: ModuleLoader, diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index cbaa768c4..8c52ed4dc 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -30,7 +30,7 @@ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends ( ? R : any; -export interface MatchedRoute { +interface MatchedRoute { route: RouteData; filePath: URL; resolvedPathname: string; diff --git a/packages/astro/src/vite-plugin-astro-server/server-state.ts b/packages/astro/src/vite-plugin-astro-server/server-state.ts index 94f1fe8a5..5e6c13111 100644 --- a/packages/astro/src/vite-plugin-astro-server/server-state.ts +++ b/packages/astro/src/vite-plugin-astro-server/server-state.ts @@ -1,6 +1,6 @@ -export type ErrorState = 'fresh' | 'error'; +type ErrorState = 'fresh' | 'error'; -export interface RouteState { +interface RouteState { state: ErrorState; error?: Error; } @@ -18,10 +18,6 @@ export function createServerState(): ServerState { }; } -export function hasAnyFailureState(serverState: ServerState) { - return serverState.state !== 'fresh'; -} - export function setRouteError(serverState: ServerState, pathname: string, error: Error) { if (serverState.routes.has(pathname)) { const routeState = serverState.routes.get(pathname)!; diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 93fecc7aa..1dd09d143 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -3,7 +3,7 @@ import type { Logger } from '../core/logger/core.js'; import type { CompileMetadata } from './types.js'; import { frontmatterRE } from './utils.js'; -export interface HandleHotUpdateOptions { +interface HandleHotUpdateOptions { logger: Logger; astroFileToCompileMetadata: Map<string, CompileMetadata>; } diff --git a/packages/astro/src/vite-plugin-astro/query.ts b/packages/astro/src/vite-plugin-astro/query.ts index c9829de3f..266657d69 100644 --- a/packages/astro/src/vite-plugin-astro/query.ts +++ b/packages/astro/src/vite-plugin-astro/query.ts @@ -1,4 +1,4 @@ -export interface AstroQuery { +interface AstroQuery { astro?: boolean; src?: boolean; type?: 'script' | 'template' | 'style' | 'custom'; @@ -7,7 +7,7 @@ export interface AstroQuery { raw?: boolean; } -export interface ParsedRequestResult { +interface ParsedRequestResult { filename: string; query: AstroQuery; } diff --git a/packages/astro/src/vite-plugin-astro/types.ts b/packages/astro/src/vite-plugin-astro/types.ts index d85fd6483..09d2e8b52 100644 --- a/packages/astro/src/vite-plugin-astro/types.ts +++ b/packages/astro/src/vite-plugin-astro/types.ts @@ -2,7 +2,7 @@ import type { HoistedScript, TransformResult } from '@astrojs/compiler'; import type { CompileCssResult } from '../core/compile/types.js'; import type { PropagationHint } from '../types/public/internal.js'; -export interface PageOptions { +interface PageOptions { prerender?: boolean; } diff --git a/packages/astro/src/vite-plugin-load-fallback/index.ts b/packages/astro/src/vite-plugin-load-fallback/index.ts index f7cc9cd1c..02385207d 100644 --- a/packages/astro/src/vite-plugin-load-fallback/index.ts +++ b/packages/astro/src/vite-plugin-load-fallback/index.ts @@ -6,7 +6,7 @@ import { cleanUrl } from '../vite-plugin-utils/index.js'; type NodeFileSystemModule = typeof nodeFs; -export interface LoadFallbackPluginParams { +interface LoadFallbackPluginParams { fs?: NodeFileSystemModule; root: URL; } diff --git a/packages/astro/src/vite-plugin-scanner/index.ts b/packages/astro/src/vite-plugin-scanner/index.ts index a86205484..4f1700dfe 100644 --- a/packages/astro/src/vite-plugin-scanner/index.ts +++ b/packages/astro/src/vite-plugin-scanner/index.ts @@ -9,7 +9,7 @@ import { isEndpoint, isPage } from '../core/util.js'; import { normalizePath, rootRelativePath } from '../core/viteUtils.js'; import type { AstroSettings, RoutesList } from '../types/astro.js'; -export interface AstroPluginScannerOptions { +interface AstroPluginScannerOptions { settings: AstroSettings; logger: Logger; routesList: RoutesList; diff --git a/packages/astro/templates/env.mjs b/packages/astro/templates/env.mjs index 652603351..c314b4392 100644 --- a/packages/astro/templates/env.mjs +++ b/packages/astro/templates/env.mjs @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ // @ts-check import { schema } from 'virtual:astro:env/internal'; import { diff --git a/packages/astro/test/test-image-service.js b/packages/astro/test/test-image-service.js index de076425c..290ba5f19 100644 --- a/packages/astro/test/test-image-service.js +++ b/packages/astro/test/test-image-service.js @@ -12,7 +12,10 @@ export function testImageService(config = {}) { }; } -/** @type {import("../dist/types/public/index.js").LocalImageService} */ +/** + * @type {import("../dist/types/public/index.js").LocalImageService} + * @lintignore + * */ export default { ...baseService, propertiesToHash: [...baseService.propertiesToHash, 'data-custom'], diff --git a/packages/astro/test/test-remote-image-service.js b/packages/astro/test/test-remote-image-service.js index 2534b4085..5bec90615 100644 --- a/packages/astro/test/test-remote-image-service.js +++ b/packages/astro/test/test-remote-image-service.js @@ -12,7 +12,10 @@ export function testRemoteImageService(config = {}) { }; } -/** @type {import("../dist/types/public/index.js").LocalImageService} */ +/** + * @type {import("../dist/types/public/index.js").LocalImageService} + * @lintignore + * */ export default { ...baseService, propertiesToHash: [...baseService.propertiesToHash, 'data-custom'], @@ -23,4 +26,4 @@ export default { } return baseService.getHTMLAttributes(options); }, -}; +};
\ No newline at end of file diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index e0afb4cc0..32e575cac 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -12,7 +12,6 @@ import { globalContentConfigObserver } from '../dist/content/utils.js'; import build from '../dist/core/build/index.js'; import { mergeConfig, resolveConfig } from '../dist/core/config/index.js'; import { dev, preview } from '../dist/core/index.js'; -import { nodeLogDestination } from '../dist/core/logger/node.js'; import sync from '../dist/core/sync/index.js'; // Disable telemetry when running tests @@ -69,18 +68,6 @@ process.env.ASTRO_TELEMETRY_DISABLED = true; * ``` */ -/** @type {import('../src/core/logger/core').LogOptions} */ -export const defaultLogging = { - dest: nodeLogDestination, - level: 'error', -}; - -/** @type {import('../src/core/logger/core').LogOptions} */ -export const silentLogging = { - dest: nodeLogDestination, - level: 'silent', -}; - /** * Load Astro fixture * @param {AstroInlineConfig} inlineConfig Astro config partial (note: must specify `root`) @@ -376,7 +363,6 @@ export async function cliServerLogSetup(flags = [], cmd = 'dev') { return { local, network }; } -export const isLinux = os.platform() === 'linux'; export const isMacOS = os.platform() === 'darwin'; export const isWindows = os.platform() === 'win32'; diff --git a/packages/astro/test/types/call-action.ts b/packages/astro/test/types/call-action.ts index e1f282d10..9d419b9de 100644 --- a/packages/astro/test/types/call-action.ts +++ b/packages/astro/test/types/call-action.ts @@ -15,8 +15,9 @@ describe('Astro.callAction', () => { return { name }; }, }); - const result = await context.callAction(action, { name: 'Ben' }); - expectTypeOf<typeof result>().toEqualTypeOf<ActionReturnType<typeof action>>(); + expectTypeOf(await context.callAction(action, { name: 'Ben' })).toEqualTypeOf< + ActionReturnType<typeof action> + >(); }); it('Infers form action result on callAction', async () => { @@ -30,8 +31,9 @@ describe('Astro.callAction', () => { return { name }; }, }); - const result = await context.callAction(action, new FormData()); - expectTypeOf<typeof result>().toEqualTypeOf<ActionReturnType<typeof action>>(); + expectTypeOf(await context.callAction(action, new FormData())).toEqualTypeOf< + ActionReturnType<typeof action> + >(); }); it('Infers orThrow action result on callAction', async () => { @@ -45,7 +47,8 @@ describe('Astro.callAction', () => { return { name }; }, }); - const result = await context.callAction(action.orThrow, new FormData()); - expectTypeOf<typeof result>().toEqualTypeOf<ActionReturnType<(typeof action)['orThrow']>>(); + expectTypeOf(await context.callAction(action.orThrow, new FormData())).toEqualTypeOf< + ActionReturnType<(typeof action)['orThrow']> + >(); }); }); diff --git a/packages/astro/test/units/logger/locale.test.js b/packages/astro/test/units/logger/locale.test.js index c427d022a..994726872 100644 --- a/packages/astro/test/units/logger/locale.test.js +++ b/packages/astro/test/units/logger/locale.test.js @@ -13,7 +13,7 @@ describe('logger - dateTimeFormat', () => { LOCALES.forEach((locale, i) => { it(`works with process.env.LANG="${locale}"`, async () => { process.env.LANG = locale; - const { dateTimeFormat } = await import('../../../dist/core/logger/core.js?cachebust=' + i); + const { dateTimeFormat } = await import(`../../../dist/core/logger/core.js?cachebust=${i}`); assert.doesNotThrow(() => { dateTimeFormat.format(new Date()); }); diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js index 9d4804a1a..6132a2a43 100644 --- a/packages/astro/test/units/test-utils.js +++ b/packages/astro/test/units/test-utils.js @@ -19,12 +19,6 @@ export const defaultLogger = new Logger({ level: 'error', }); -/** @type {import('../../src/core/logger/core').LogOptions} */ -export const silentLogging = { - dest: nodeLogDestination, - level: 'error', -}; - const tempFixturesDir = fileURLToPath(new URL('./_temp-fixtures/', import.meta.url)); /** @@ -69,7 +63,7 @@ export function createRequestAndResponse(reqOptions = {}) { return { req, res, done, json, text }; } -export function toPromise(res) { +function toPromise(res) { return new Promise((resolve) => { // node-mocks-http doesn't correctly handle non-Buffer typed arrays, // so override the write method to fix it. @@ -90,7 +84,7 @@ export function toPromise(res) { }); } -export function buffersToString(buffers) { +function buffersToString(buffers) { let decoder = new TextDecoder(); let str = ''; for (const buffer of buffers) { diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 04c91deb2..0dac5802e 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -36,8 +36,7 @@ }, "devDependencies": { "arg": "^5.0.2", - "astro-scripts": "workspace:*", - "strip-json-comments": "^5.0.1" + "astro-scripts": "workspace:*" }, "engines": { "node": "^18.17.1 || ^20.3.0 || >=22.0.0" diff --git a/packages/create-astro/src/actions/shared.ts b/packages/create-astro/src/actions/shared.ts index 4bd852529..da19677d0 100644 --- a/packages/create-astro/src/actions/shared.ts +++ b/packages/create-astro/src/actions/shared.ts @@ -41,7 +41,7 @@ export function isEmpty(dirPath: string) { return conflicts.length === 0; } -export function isValidName(projectName: string) { +function isValidName(projectName: string) { return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName); } diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index 9aadb8128..cf58d90a8 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -94,7 +94,7 @@ export function getTemplateTarget(tmpl: string, ref = 'latest') { } } -export default async function copyTemplate(tmpl: string, ctx: Context) { +async function copyTemplate(tmpl: string, ctx: Context) { const templateTarget = getTemplateTarget(tmpl, ctx.ref); // Copy if (!ctx.dryRun) { diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index 898c9c728..17fffbed7 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -1,7 +1,7 @@ import { exec } from 'node:child_process'; import { stripVTControlCharacters } from 'node:util'; /* eslint no-console: 'off' */ -import { color, say as houston, label, spinner as load } from '@astrojs/cli-kit'; +import { color, say as houston, label } from '@astrojs/cli-kit'; import { align, sleep } from '@astrojs/cli-kit/utils'; import { shell } from './shell.js'; @@ -34,15 +34,6 @@ export async function say(messages: string | string[], { clear = false, hat = '' return houston(messages, { clear, hat, tie, stdout }); } -export async function spinner(args: { - start: string; - end: string; - onError?: (error: any) => void; - while: (...args: any) => Promise<any>; -}) { - await load(args, { stdout }); -} - export const title = (text: string) => align(label(text), 'end', 7) + ' '; export const getName = () => @@ -99,12 +90,6 @@ export const error = async (prefix: string, text: string) => { } }; -export const typescriptByDefault = async () => { - await info(`No worries!`, 'TypeScript is supported in Astro by default,'); - log(`${' '.repeat(9)}${color.dim('but you are free to continue writing JavaScript instead.')}`); - await sleep(1000); -}; - export const nextSteps = async ({ projectDir, devCmd }: { projectDir: string; devCmd: string }) => { const max = stdout.columns; const prefix = max < 80 ? ' ' : ' '.repeat(9); diff --git a/packages/create-astro/src/shell.ts b/packages/create-astro/src/shell.ts index 7c3e22622..253097c4a 100644 --- a/packages/create-astro/src/shell.ts +++ b/packages/create-astro/src/shell.ts @@ -6,12 +6,12 @@ import type { Readable } from 'node:stream'; import { spawn } from 'node:child_process'; import { text as textFromStream } from 'node:stream/consumers'; -export interface ExecaOptions { +interface ExecaOptions { cwd?: string | URL; stdio?: StdioOptions; timeout?: number; } -export interface Output { +interface Output { stdout: string; stderr: string; exitCode: number; diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js index dfae93c33..20063ec53 100644 --- a/packages/create-astro/test/utils.js +++ b/packages/create-astro/test/utils.js @@ -1,4 +1,3 @@ -import fs from 'node:fs'; import { before, beforeEach } from 'node:test'; import { stripVTControlCharacters } from 'node:util'; import { setStdout } from '../dist/index.js'; @@ -31,33 +30,3 @@ export function setup() { }, }; } - -const resetEmptyFixture = () => - fs.promises.rm(new URL('./fixtures/empty/tsconfig.json', import.meta.url)); - -const resetNotEmptyFixture = async () => { - const packagePath = new URL('./fixtures/not-empty/package.json', import.meta.url); - const tsconfigPath = new URL('./fixtures/not-empty/tsconfig.json', import.meta.url); - - const packageJsonData = JSON.parse( - await fs.promises.readFile(packagePath, { encoding: 'utf-8' }), - ); - const overriddenPackageJson = Object.assign(packageJsonData, { - scripts: { - dev: 'astro dev', - build: 'astro build', - preview: 'astro preview', - }, - dependencies: undefined, - }); - - return Promise.all([ - fs.promises.writeFile(packagePath, JSON.stringify(overriddenPackageJson, null, 2), { - encoding: 'utf-8', - }), - fs.promises.writeFile(tsconfigPath, '{}', { encoding: 'utf-8' }), - ]); -}; - -export const resetFixtures = () => - Promise.allSettled([resetEmptyFixture(), resetNotEmptyFixture()]); diff --git a/packages/db/src/core/cli/commands/link/index.ts b/packages/db/src/core/cli/commands/link/index.ts index bd07b7824..4a105df9d 100644 --- a/packages/db/src/core/cli/commands/link/index.ts +++ b/packages/db/src/core/cli/commands/link/index.ts @@ -114,7 +114,7 @@ async function promptWorkspace(sessionToken: string) { return workspaceId; } -export async function createNewProject({ +async function createNewProject({ workspaceId, name, region, @@ -157,7 +157,7 @@ export async function createNewProject({ return { id: data.id, idName: data.idName }; } -export async function promptExistingProjectName({ workspaceId }: { workspaceId: string }) { +async function promptExistingProjectName({ workspaceId }: { workspaceId: string }) { const linkUrl = new URL(getAstroStudioUrl() + '/api/cli/projects.list'); const response = await safeFetch( linkUrl, @@ -205,7 +205,7 @@ export async function promptExistingProjectName({ workspaceId }: { workspaceId: return selectedProjectData; } -export async function promptBegin(): Promise<void> { +async function promptBegin(): Promise<void> { // Get the current working directory relative to the user's home directory const prettyCwd = process.cwd().replace(homedir(), '~'); @@ -226,7 +226,7 @@ export async function promptBegin(): Promise<void> { * Ask the user if they want to link to an existing Astro Studio project. * @returns A `Promise` for the user’s answer: `true` if they answer yes, otherwise `false`. */ -export async function promptLinkExisting(): Promise<boolean> { +async function promptLinkExisting(): Promise<boolean> { // prompt const { linkExisting } = await prompts({ type: 'confirm', @@ -242,7 +242,7 @@ export async function promptLinkExisting(): Promise<boolean> { * **Exits the process if they answer no.** * @returns A `Promise` for the user’s answer: `true` if they answer yes. */ -export async function promptLinkNew(): Promise<boolean> { +async function promptLinkNew(): Promise<boolean> { // prompt const { linkNew } = await prompts({ type: 'confirm', @@ -257,7 +257,7 @@ export async function promptLinkNew(): Promise<boolean> { return true; } -export async function promptNewProjectName(): Promise<string> { +async function promptNewProjectName(): Promise<string> { const { newProjectName } = await prompts({ type: 'text', name: 'newProjectName', @@ -272,7 +272,7 @@ export async function promptNewProjectName(): Promise<string> { return newProjectName; } -export async function promptNewProjectRegion(): Promise<string> { +async function promptNewProjectRegion(): Promise<string> { const { newProjectRegion } = await prompts({ type: 'select', name: 'newProjectRegion', diff --git a/packages/db/src/core/cli/types.ts b/packages/db/src/core/cli/types.ts deleted file mode 100644 index 4294c3fb0..000000000 --- a/packages/db/src/core/cli/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface Arguments { - _: Array<string | number>; - '--'?: Array<string | number>; - [argName: string]: any; -} diff --git a/packages/db/src/core/consts.ts b/packages/db/src/core/consts.ts index 703a91dca..8b8ccaf2d 100644 --- a/packages/db/src/core/consts.ts +++ b/packages/db/src/core/consts.ts @@ -1,6 +1,6 @@ import { readFileSync } from 'node:fs'; -export const PACKAGE_NAME = JSON.parse( +const PACKAGE_NAME = JSON.parse( readFileSync(new URL('../../package.json', import.meta.url), 'utf8'), ).name; @@ -8,8 +8,6 @@ export const RUNTIME_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime`); export const RUNTIME_VIRTUAL_IMPORT = JSON.stringify(`${PACKAGE_NAME}/dist/runtime/virtual.js`); -export const DB_TYPES_FILE = 'db-types.d.ts'; - export const VIRTUAL_MODULE_ID = 'astro:db'; export const DB_PATH = '.astro/content.db'; diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts index 80919144d..410d49157 100644 --- a/packages/db/src/core/integration/vite-plugin-db.ts +++ b/packages/db/src/core/integration/vite-plugin-db.ts @@ -16,7 +16,7 @@ import { getRemoteDatabaseInfo, } from '../utils.js'; -export const resolved = { +const resolved = { module: '\0' + VIRTUAL_MODULE_ID, importedFromSeedFile: '\0' + VIRTUAL_MODULE_ID + ':seed', }; diff --git a/packages/db/src/core/queries.ts b/packages/db/src/core/queries.ts index e77578ac2..8fba4f6f9 100644 --- a/packages/db/src/core/queries.ts +++ b/packages/db/src/core/queries.ts @@ -66,7 +66,7 @@ export function getCreateIndexQueries(tableName: string, table: Pick<DBTable, 'i return queries; } -export function getCreateForeignKeyQueries(tableName: string, table: DBTable) { +function getCreateForeignKeyQueries(tableName: string, table: DBTable) { let queries: string[] = []; for (const foreignKey of table.foreignKeys ?? []) { const columns = asArray(foreignKey.columns); diff --git a/packages/db/src/runtime/errors.ts b/packages/db/src/runtime/errors.ts index e15044261..67961b1b5 100644 --- a/packages/db/src/runtime/errors.ts +++ b/packages/db/src/runtime/errors.ts @@ -23,7 +23,3 @@ export const REFERENCE_DNE_ERROR = (columnName: string) => { columnName, )} references a table that does not exist. Did you apply the referenced table to the \`tables\` object in your db config?`; }; - -export const SEED_DEFAULT_EXPORT_ERROR = (fileName: string) => { - return `Missing default function export in ${bold(fileName)}`; -}; diff --git a/packages/db/src/runtime/types.ts b/packages/db/src/runtime/types.ts index 08ab16a0c..5f1a0185e 100644 --- a/packages/db/src/runtime/types.ts +++ b/packages/db/src/runtime/types.ts @@ -7,7 +7,7 @@ type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick< 'name' | 'tableName' | 'notNull' | 'hasDefault' >; -export type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn< +type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn< T & { data: string; dataType: 'string'; @@ -18,7 +18,7 @@ export type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn< } >; -export type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn< +type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn< T & { data: Date; dataType: 'custom'; @@ -29,7 +29,7 @@ export type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn< } >; -export type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn< +type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn< T & { data: boolean; dataType: 'boolean'; @@ -40,7 +40,7 @@ export type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn< } >; -export type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn< +type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn< T & { data: number; dataType: 'number'; @@ -51,7 +51,7 @@ export type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn< } >; -export type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn< +type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn< T & { data: unknown; dataType: 'custom'; @@ -62,7 +62,7 @@ export type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn< } >; -export type Column<T extends DBColumn['type'], S extends GeneratedConfig> = T extends 'boolean' +type Column<T extends DBColumn['type'], S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> diff --git a/packages/integrations/alpinejs/test/test-utils.js b/packages/integrations/alpinejs/test/test-utils.js index 38ae4bd5b..dbc133ec3 100644 --- a/packages/integrations/alpinejs/test/test-utils.js +++ b/packages/integrations/alpinejs/test/test-utils.js @@ -1,11 +1,9 @@ import fs from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { expect, test as testBase } from '@playwright/test'; +import { test as testBase } from '@playwright/test'; import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; -export const isWindows = process.platform === 'win32'; - // Get all test files in directory, assign unique port for each of them so they don't conflict const testFiles = await fs.readdir(new URL('.', import.meta.url)); const testFileToPort = new Map(); @@ -16,7 +14,7 @@ for (let i = 0; i < testFiles.length; i++) { } } -export function loadFixture(inlineConfig) { +function loadFixture(inlineConfig) { if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }"); // resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath @@ -30,7 +28,7 @@ export function loadFixture(inlineConfig) { }); } -export function testFactory(inlineConfig) { +function testFactory(inlineConfig) { let fixture; const test = testBase.extend({ @@ -47,52 +45,6 @@ export function testFactory(inlineConfig) { return test; } -/** - * - * @param {string} page - * @returns {Promise<{message: string, hint: string, absoluteFileLocation: string, fileLocation: string}>} - */ -export async function getErrorOverlayContent(page) { - const overlay = await page.waitForSelector('vite-error-overlay', { - strict: true, - timeout: 10 * 1000, - }); - - expect(overlay).toBeTruthy(); - - const message = await overlay.$$eval('#message-content', (m) => m[0].textContent); - const hint = await overlay.$$eval('#hint-content', (m) => m[0].textContent); - const [absoluteFileLocation, fileLocation] = await overlay.$$eval('#code header h2', (m) => [ - m[0].title, - m[0].textContent, - ]); - return { message, hint, absoluteFileLocation, fileLocation }; -} - -/** - * Wait for `astro-island` that contains the `el` to hydrate - * @param {import('@playwright/test').Page} page - * @param {import('@playwright/test').Locator} el - */ -export async function waitForHydrate(page, el) { - const astroIsland = page.locator('astro-island', { has: el }); - const astroIslandId = await astroIsland.last().getAttribute('uid'); - await page.waitForFunction( - (selector) => document.querySelector(selector)?.hasAttribute('ssr') === false, - `astro-island[uid="${astroIslandId}"]`, - ); -} - -/** - * Scroll to element manually without making sure the `el` is stable - * @param {import('@playwright/test').Locator} el - */ -export async function scrollToElement(el) { - await el.evaluate((node) => { - node.scrollIntoView({ behavior: 'auto' }); - }); -} - export function prepareTestFactory(opts) { const test = testFactory(opts); diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 650bf801a..babe5eea1 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,10 +37,6 @@ "@astrojs/internal-helpers": "workspace:*", "@astrojs/underscore-redirects": "workspace:*", "@cloudflare/workers-types": "^4.20250327.0", - "esbuild": "^0.25.0", - "estree-walker": "^3.0.3", - "magic-string": "^0.30.17", - "miniflare": "^4.20250321.1", "tinyglobby": "^0.2.12", "vite": "^6.2.6", "wrangler": "^4.5.1" @@ -54,8 +50,7 @@ "cheerio": "1.0.0", "devalue": "^5.1.1", "execa": "^8.0.1", - "rollup": "^4.35.0", - "strip-ansi": "^7.1.0" + "rollup": "^4.35.0" }, "publishConfig": { "provenance": true diff --git a/packages/integrations/cloudflare/src/utils/assets.ts b/packages/integrations/cloudflare/src/utils/assets.ts index 21ba28690..2e6094aa8 100644 --- a/packages/integrations/cloudflare/src/utils/assets.ts +++ b/packages/integrations/cloudflare/src/utils/assets.ts @@ -4,7 +4,7 @@ import type { AstroConfig, ImageMetadata, RemotePattern } from 'astro'; export function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata { return typeof src === 'object'; } -export function matchHostname(url: URL, hostname?: string, allowWildcard?: boolean) { +function matchHostname(url: URL, hostname?: string, allowWildcard?: boolean) { if (!hostname) { return true; } @@ -26,13 +26,13 @@ export function matchHostname(url: URL, hostname?: string, allowWildcard?: boole return false; } -export function matchPort(url: URL, port?: string) { +function matchPort(url: URL, port?: string) { return !port || port === url.port; } -export function matchProtocol(url: URL, protocol?: string) { +function matchProtocol(url: URL, protocol?: string) { return !protocol || protocol === url.protocol.slice(0, -1); } -export function matchPathname(url: URL, pathname?: string, allowWildcard?: boolean) { +function matchPathname(url: URL, pathname?: string, allowWildcard?: boolean) { if (!pathname) { return true; } @@ -54,7 +54,7 @@ export function matchPathname(url: URL, pathname?: string, allowWildcard?: boole return false; } -export function matchPattern(url: URL, remotePattern: RemotePattern) { +function matchPattern(url: URL, remotePattern: RemotePattern) { return ( matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && @@ -77,6 +77,3 @@ export function isRemoteAllowed( remotePatterns.some((remotePattern) => matchPattern(url, remotePattern)) ); } -export function isString(path: unknown): path is string { - return typeof path === 'string' || path instanceof String; -} diff --git a/packages/integrations/cloudflare/src/utils/cloudflare-module-loader.ts b/packages/integrations/cloudflare/src/utils/cloudflare-module-loader.ts index 7017acd57..15e9f1a8b 100644 --- a/packages/integrations/cloudflare/src/utils/cloudflare-module-loader.ts +++ b/packages/integrations/cloudflare/src/utils/cloudflare-module-loader.ts @@ -9,7 +9,7 @@ export interface CloudflareModulePluginExtra { afterBuildCompleted(config: AstroConfig): Promise<void>; } -export type ModuleType = 'CompiledWasm' | 'Text' | 'Data'; +type ModuleType = 'CompiledWasm' | 'Text' | 'Data'; /** * Enables support for various non-standard extensions in module imports that cloudflare workers supports. diff --git a/packages/integrations/cloudflare/src/utils/non-server-chunk-detector.ts b/packages/integrations/cloudflare/src/utils/non-server-chunk-detector.ts deleted file mode 100644 index 16ba2aed9..000000000 --- a/packages/integrations/cloudflare/src/utils/non-server-chunk-detector.ts +++ /dev/null @@ -1,85 +0,0 @@ -import type { OutputBundle } from 'rollup'; -import type { PluginOption } from 'vite'; - -/** - * A Vite bundle analyzer that identifies chunks that are not used for server rendering. - * - * The chunks injected by Astro for prerendering are flagged as non-server chunks. - * Any chunks that is only used by a non-server chunk are also flagged as non-server chunks. - * This continues transitively until all non-server chunks are found. - */ -export class NonServerChunkDetector { - private nonServerChunks?: string[]; - - public getPlugin(): PluginOption { - return { - name: 'non-server-chunk-detector', - generateBundle: (_, bundle) => { - // Skip if we bundle for client - if (!bundle['index.js']) return; - this.processBundle(bundle); - }, - }; - } - - private processBundle(bundle: OutputBundle) { - const chunkNamesToFiles = new Map<string, string>(); - - const entryChunks: string[] = []; - const chunkToDependencies = new Map<string, string[]>(); - - for (const chunk of Object.values(bundle)) { - if (chunk.type !== 'chunk') continue; - - // Construct a mapping from a chunk name to its file name - chunkNamesToFiles.set(chunk.name, chunk.fileName); - // Construct a mapping from a chunk file to all the modules it imports - chunkToDependencies.set(chunk.fileName, [...chunk.imports, ...chunk.dynamicImports]); - - if (chunk.isEntry) { - // Entry chunks should always be kept around since they are to be imported by the runtime - entryChunks.push(chunk.fileName); - } - } - - const chunkDecisions = new Map<string, boolean>(); - - for (const entry of entryChunks) { - // Entry chunks are used on the server - chunkDecisions.set(entry, true); - } - - for (const chunk of ['prerender', 'prerender@_@astro']) { - // Prerender chunks are not used on the server - const fileName = chunkNamesToFiles.get(chunk); - if (fileName) { - chunkDecisions.set(fileName, false); - } - } - - // Start a stack of chunks that are used on the server - const chunksToWalk = [...entryChunks]; - - // Iterate over the chunks, traversing the transitive dependencies of the chunks used on the server - for (let chunk = chunksToWalk.pop(); chunk; chunk = chunksToWalk.pop()) { - for (const dep of chunkToDependencies.get(chunk) ?? []) { - // Skip dependencies already flagged, dependencies may be repeated and/or circular - if (chunkDecisions.has(dep)) continue; - - // A dependency of a module used on the server is also used on the server - chunkDecisions.set(dep, true); - // Add the dependency to the stack so its own dependencies are also flagged - chunksToWalk.push(dep); - } - } - - // Any chunk not flagged as used on the server is a non-server chunk - this.nonServerChunks = Array.from(chunkToDependencies.keys()).filter( - (chunk) => !chunkDecisions.get(chunk), - ); - } - - public getNonServerChunks(): string[] { - return this.nonServerChunks ?? []; - } -} diff --git a/packages/integrations/cloudflare/test/routes-json.test.js b/packages/integrations/cloudflare/test/routes-json.test.js index cf7f6d0d6..547739fea 100644 --- a/packages/integrations/cloudflare/test/routes-json.test.js +++ b/packages/integrations/cloudflare/test/routes-json.test.js @@ -3,9 +3,9 @@ import { before, describe, it } from 'node:test'; import cloudflare from '../dist/index.js'; import { loadFixture } from './_test-utils.js'; -/** @type {import('./test-utils.js').Fixture} */ describe('_routes.json generation', () => { describe('of on-demand and prerenderd', () => { + /** @type {import('../../../astro/test/test-utils').Fixture} */ let fixture; before(async () => { diff --git a/packages/integrations/cloudflare/test/with-base-path.js b/packages/integrations/cloudflare/test/with-base-path.js deleted file mode 100644 index 904af09c0..000000000 --- a/packages/integrations/cloudflare/test/with-base-path.js +++ /dev/null @@ -1,21 +0,0 @@ -// @ts-check -import * as assert from 'node:assert/strict'; -import { promises as fs, existsSync } from 'node:fs'; -import { before, describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; -import { astroCli } from './_test-utils.js'; - -const root = new URL('./fixtures/with-base/', import.meta.url); - -describe('With base', () => { - before(async () => { - await fs.rm(new URL('dist/', root), { recursive: true, force: true }); - await astroCli(fileURLToPath(root), 'build'); - }); - - it('generates platform files in the correct directory', async () => { - for (const file of ['_redirects', '_routes.json', 'blog/static/index.html']) { - assert.ok(existsSync(new URL(`dist/${file}`, root))); - } - }); -}); diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts index 4c1174c3c..f1fbb4618 100644 --- a/packages/integrations/markdoc/components/TreeNode.ts +++ b/packages/integrations/markdoc/components/TreeNode.ts @@ -14,7 +14,7 @@ import { unescapeHTML, } from 'astro/runtime/server/index.js'; -export type TreeNode = +type TreeNode = // Markdoc `if` tag often returns an array of nodes in the AST, which gets translated // here as an array of `TreeNode`s, which we'll render all without a wrapper. | TreeNode[] diff --git a/packages/integrations/markdoc/src/html/index.ts b/packages/integrations/markdoc/src/html/index.ts deleted file mode 100644 index 3f947736c..000000000 --- a/packages/integrations/markdoc/src/html/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { htmlTag } from './tagdefs/html.tag.js'; -export { htmlTokenTransform } from './transform/html-token-transform.js'; diff --git a/packages/integrations/markdoc/src/utils.ts b/packages/integrations/markdoc/src/utils.ts index 3f2aed633..dc9c9023f 100644 --- a/packages/integrations/markdoc/src/utils.ts +++ b/packages/integrations/markdoc/src/utils.ts @@ -60,20 +60,6 @@ export function isValidUrl(str: string): boolean { } } -/** - * Identifies Astro components with propagated assets - * @see 'packages/astro/src/content/consts.ts' - */ -export const PROPAGATED_ASSET_FLAG = 'astroPropagatedAssets'; - -/** - * @see 'packages/astro/src/content/utils.ts' - */ -export function hasContentFlag(viteId: string, flag: string): boolean { - const flags = new URLSearchParams(viteId.split('?')[1] ?? ''); - return flags.has(flag); -} - /** Identifier for components imports passed as `tags` or `nodes` configuration. */ export const componentConfigSymbol = Symbol.for('@astrojs/markdoc/component-config'); diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index 8c6844aae..bc76e1bd4 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -61,7 +61,6 @@ "linkedom": "^0.18.9", "mdast-util-mdx": "^3.0.0", "mdast-util-mdx-jsx": "^3.2.0", - "mdast-util-to-string": "^4.0.0", "rehype-mathjax": "^7.1.0", "rehype-pretty-code": "^0.14.1", "remark-math": "^6.0.0", diff --git a/packages/integrations/mdx/test/remark-imgattr.test.js b/packages/integrations/mdx/test/remark-imgattr.test.js index ebd9207b2..067d18e23 100644 --- a/packages/integrations/mdx/test/remark-imgattr.test.js +++ b/packages/integrations/mdx/test/remark-imgattr.test.js @@ -6,11 +6,11 @@ import { loadFixture } from '../../../astro/test/test-utils.js'; const FIXTURE_ROOT = new URL('./fixtures/image-remark-imgattr/', import.meta.url); describe('Testing remark plugins for image processing', () => { - /** @type {import('./test-utils').Fixture} */ + /** @type {import('../../../astro/test/test-utils.js').Fixture} */ let fixture; describe('start dev server', () => { - /** @type {import('./test-utils').DevServer} */ + /** @type {import('../../../astro/test/test-utils.js').DevServer} */ let devServer; before(async () => { diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 4a0860647..23c8d4ede 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -50,15 +50,11 @@ "astro": "^5.3.0" }, "devDependencies": { - "@netlify/edge-functions": "^2.11.1", - "@netlify/edge-handler-types": "^0.34.1", "@types/node": "^22.10.6", "astro": "workspace:*", "astro-scripts": "workspace:*", "cheerio": "1.0.0", "devalue": "^5.1.1", - "execa": "^8.0.1", - "strip-ansi": "^7.1.0", "typescript": "^5.8.2" }, "astro": { diff --git a/packages/integrations/netlify/test/test-utils.js b/packages/integrations/netlify/test/test-utils.js deleted file mode 100644 index 7c012e86a..000000000 --- a/packages/integrations/netlify/test/test-utils.js +++ /dev/null @@ -1,12 +0,0 @@ -import { execa } from 'execa'; - -/** Returns a process running the Astro CLI. */ -export function cli(/** @type {string[]} */ ...args) { - const spawned = execa('npx', ['astro', ...args], { - env: { ASTRO_TELEMETRY_DISABLED: true }, - }); - - spawned.stdout.setEncoding('utf8'); - - return spawned; -} diff --git a/packages/integrations/node/src/log-listening-on.ts b/packages/integrations/node/src/log-listening-on.ts index b7a9f0bf9..805f568ab 100644 --- a/packages/integrations/node/src/log-listening-on.ts +++ b/packages/integrations/node/src/log-listening-on.ts @@ -45,7 +45,7 @@ interface NetworkAddressOpt { } // this code from vite https://github.com/vitejs/vite/blob/d09bbd093a4b893e78f0bbff5b17c7cf7821f403/packages/vite/src/node/utils.ts#L892-L914 -export function getNetworkAddress( +function getNetworkAddress( protocol: 'http' | 'https' = 'http', hostname: string | undefined, port: number, diff --git a/packages/integrations/node/src/types.ts b/packages/integrations/node/src/types.ts index 010053de5..37773e24c 100644 --- a/packages/integrations/node/src/types.ts +++ b/packages/integrations/node/src/types.ts @@ -1,6 +1,5 @@ import type { IncomingMessage, ServerResponse } from 'node:http'; import type { SSRManifest } from 'astro'; -import type { NodeApp } from 'astro/app/node'; export interface UserOptions { /** @@ -21,17 +20,8 @@ export interface Options extends UserOptions { trailingSlash?: SSRManifest['trailingSlash']; } -export interface CreateServerOptions { - app: NodeApp; - assets: string; - client: URL; - port: number; - host: string | undefined; - removeBase: (pathname: string) => string; -} - export type RequestHandler = (...args: RequestHandlerParams) => void | Promise<void>; -export type RequestHandlerParams = [ +type RequestHandlerParams = [ req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void, diff --git a/packages/integrations/node/test/test-utils.js b/packages/integrations/node/test/test-utils.js index 53b1a690c..b7720d690 100644 --- a/packages/integrations/node/test/test-utils.js +++ b/packages/integrations/node/test/test-utils.js @@ -38,7 +38,7 @@ export function createRequestAndResponse(reqOptions) { return { req, res, done, text }; } -export function toPromise(res) { +function toPromise(res) { return new Promise((resolve) => { // node-mocks-http doesn't correctly handle non-Buffer typed arrays, // so override the write method to fix it. @@ -56,7 +56,7 @@ export function toPromise(res) { }); } -export function buffersToString(buffers) { +function buffersToString(buffers) { const decoder = new TextDecoder(); let str = ''; for (const buffer of buffers) { diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index 6d7a9dc96..ab22b54b1 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -35,11 +35,8 @@ "dev": "astro-scripts dev \"src/**/*.ts\"" }, "dependencies": { - "@babel/plugin-transform-react-jsx": "^7.25.9", - "@babel/plugin-transform-react-jsx-development": "^7.25.9", "@preact/preset-vite": "^2.10.1", "@preact/signals": "^2.0.2", - "babel-plugin-transform-hook-names": "^1.0.2", "preact-render-to-string": "^6.5.13", "vite": "^6.2.6" }, diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index 9aaf546bf..db0c97096 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -38,7 +38,6 @@ "zod": "^3.24.2" }, "devDependencies": { - "@astrojs/node": "workspace:*", "astro": "workspace:*", "astro-scripts": "workspace:*", "xml2js": "0.6.2" diff --git a/packages/integrations/sitemap/src/utils/is-object-empty.ts b/packages/integrations/sitemap/src/utils/is-object-empty.ts deleted file mode 100644 index 0d6181069..000000000 --- a/packages/integrations/sitemap/src/utils/is-object-empty.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @internal -export const isObjectEmpty = (o: any) => { - if (!o) { - return true; - } - if (Array.isArray(o)) { - return o.length === 0; - } - return Object.keys(o).length === 0 && Object.getPrototypeOf(o) === Object.prototype; -}; diff --git a/packages/integrations/sitemap/src/utils/is-valid-url.ts b/packages/integrations/sitemap/src/utils/is-valid-url.ts deleted file mode 100644 index 1a456da93..000000000 --- a/packages/integrations/sitemap/src/utils/is-valid-url.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @internal -export const isValidUrl = (s: any) => { - if (typeof s !== 'string' || !s) { - return false; - } - try { - new URL(s); - return true; - } catch { - return false; - } -}; diff --git a/packages/integrations/sitemap/test/fixtures/ssr/package.json b/packages/integrations/sitemap/test/fixtures/ssr/package.json index 4c4c68285..4b5e6848d 100644 --- a/packages/integrations/sitemap/test/fixtures/ssr/package.json +++ b/packages/integrations/sitemap/test/fixtures/ssr/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", + "@astrojs/node": "workspace:*", "@astrojs/sitemap": "workspace:*" } } diff --git a/packages/integrations/solid/package.json b/packages/integrations/solid/package.json index f8005dfdd..839e13e67 100644 --- a/packages/integrations/solid/package.json +++ b/packages/integrations/solid/package.json @@ -21,7 +21,6 @@ "homepage": "https://docs.astro.build/en/guides/integrations-guide/solid-js/", "exports": { ".": "./dist/index.js", - "./*": "./*", "./client.js": "./dist/client.js", "./server.js": "./dist/server.js", "./package.json": "./package.json" diff --git a/packages/integrations/vercel/src/image/shared.ts b/packages/integrations/vercel/src/image/shared.ts index 52c319417..4a89208da 100644 --- a/packages/integrations/vercel/src/image/shared.ts +++ b/packages/integrations/vercel/src/image/shared.ts @@ -56,7 +56,7 @@ export type VercelImageConfig = { contentSecurityPolicy?: string; }; -export const qualityTable: Record<ImageQualityPreset, number> = { +const qualityTable: Record<ImageQualityPreset, number> = { low: 25, mid: 50, high: 80, diff --git a/packages/integrations/vercel/src/lib/searchRoot.ts b/packages/integrations/vercel/src/lib/searchRoot.ts index e630c8b43..c770fddb4 100644 --- a/packages/integrations/vercel/src/lib/searchRoot.ts +++ b/packages/integrations/vercel/src/lib/searchRoot.ts @@ -22,7 +22,7 @@ const ROOT_FILES = [ 'lerna.json', ]; -export function tryStatSync(file: string): fs.Stats | undefined { +function tryStatSync(file: string): fs.Stats | undefined { try { // The "throwIfNoEntry" is a performance optimization for cases where the file does not exist return fs.statSync(file, { throwIfNoEntry: false }); @@ -31,7 +31,7 @@ export function tryStatSync(file: string): fs.Stats | undefined { } } -export function isFileReadable(filename: string): boolean { +function isFileReadable(filename: string): boolean { if (!tryStatSync(filename)) { return false; } @@ -73,7 +73,7 @@ function hasPackageJSON(root: string) { /** * Search up for the nearest `package.json` */ -export function searchForPackageRoot(current: string, root = current): string { +function searchForPackageRoot(current: string, root = current): string { if (hasPackageJSON(current)) return current; const dir = dirname(current); diff --git a/packages/integrations/vercel/test/test-image-service.js b/packages/integrations/vercel/test/test-image-service.js index e3c5b4b6e..31540409d 100644 --- a/packages/integrations/vercel/test/test-image-service.js +++ b/packages/integrations/vercel/test/test-image-service.js @@ -29,4 +29,4 @@ export default { format: transform.format, }; }, -}; +};
\ No newline at end of file diff --git a/packages/integrations/vercel/test/test-utils.js b/packages/integrations/vercel/test/test-utils.js index a1d22e048..8e70e9a1c 100644 --- a/packages/integrations/vercel/test/test-utils.js +++ b/packages/integrations/vercel/test/test-utils.js @@ -1,5 +1,4 @@ import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; -export { fixLineEndings } from '../../../astro/test/test-utils.js'; export function loadFixture(config) { if (config?.root) { diff --git a/packages/integrations/web-vitals/src/schemas.ts b/packages/integrations/web-vitals/src/schemas.ts index 6dcdbe0cc..9b2fbf78a 100644 --- a/packages/integrations/web-vitals/src/schemas.ts +++ b/packages/integrations/web-vitals/src/schemas.ts @@ -1,6 +1,6 @@ import { z } from 'astro/zod'; -export const RatingSchema = z.enum(['good', 'needs-improvement', 'poor']); +const RatingSchema = z.enum(['good', 'needs-improvement', 'poor']); const MetricTypeSchema = z.enum(['CLS', 'INP', 'LCP', 'FCP', 'FID', 'TTFB']); /** `web-vitals` generated ID, transformed to reduce data resolution. */ diff --git a/packages/studio/package.json b/packages/studio/package.json index c56435585..cd79b5c40 100644 --- a/packages/studio/package.json +++ b/packages/studio/package.json @@ -39,7 +39,6 @@ "yocto-spinner": "^0.2.1" }, "devDependencies": { - "astro": "workspace:*", "astro-scripts": "workspace:*", "typescript": "^5.8.3", "vite": "^6.2.6" diff --git a/packages/telemetry/src/config.ts b/packages/telemetry/src/config.ts index 5f25e2a9d..359b1e11f 100644 --- a/packages/telemetry/src/config.ts +++ b/packages/telemetry/src/config.ts @@ -5,7 +5,7 @@ import process from 'node:process'; import dget from 'dlv'; import { dset } from 'dset'; -export interface ConfigOptions { +interface ConfigOptions { name: string; } diff --git a/packages/underscore-redirects/readme.md b/packages/underscore-redirects/README.md index 8eb29603b..8eb29603b 100644 --- a/packages/underscore-redirects/readme.md +++ b/packages/underscore-redirects/README.md diff --git a/packages/upgrade/src/messages.ts b/packages/upgrade/src/messages.ts index fb70215ee..fea4131b9 100644 --- a/packages/upgrade/src/messages.ts +++ b/packages/upgrade/src/messages.ts @@ -79,7 +79,7 @@ export const bye = [ 'See you around, astronaut.', ]; -export const log = (message: string) => stdout.write(message + '\n'); +const log = (message: string) => stdout.write(message + '\n'); export const newline = () => stdout.write('\n'); diff --git a/packages/upgrade/src/shell.ts b/packages/upgrade/src/shell.ts index cd16e0d02..a795b2c6c 100644 --- a/packages/upgrade/src/shell.ts +++ b/packages/upgrade/src/shell.ts @@ -6,12 +6,12 @@ import type { Readable } from 'node:stream'; import { spawn } from 'node:child_process'; import { text as textFromStream } from 'node:stream/consumers'; -export interface ExecaOptions { +interface ExecaOptions { cwd?: string | URL; stdio?: StdioOptions; timeout?: number; } -export interface Output { +interface Output { stdout: string; stderr: string; exitCode: number; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a7d3290eb..dfce421e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,7 +25,7 @@ importers: specifier: ^2.28.1 version: 2.28.1 '@types/node': - specifier: ^18.17.8 + specifier: ^18.19.50 version: 18.19.50 esbuild: specifier: ^0.25.0 @@ -36,6 +36,9 @@ importers: eslint-plugin-regexp: specifier: ^2.7.0 version: 2.7.0(eslint@9.24.0(jiti@2.4.2)) + knip: + specifier: 5.50.5 + version: 5.50.5(@types/node@18.19.50)(typescript@5.8.3) only-allow: specifier: ^1.2.1 version: 1.2.1 @@ -4294,9 +4297,6 @@ importers: astro-scripts: specifier: workspace:* version: link:../../scripts - strip-json-comments: - specifier: ^5.0.1 - version: 5.0.1 packages/create-astro/test/fixtures/not-empty: {} @@ -4579,18 +4579,6 @@ importers: '@cloudflare/workers-types': specifier: ^4.20250327.0 version: 4.20250327.0 - esbuild: - specifier: ^0.25.0 - version: 0.25.0 - estree-walker: - specifier: ^3.0.3 - version: 3.0.3 - magic-string: - specifier: ^0.30.17 - version: 0.30.17 - miniflare: - specifier: ^4.20250321.1 - version: 4.20250321.1 tinyglobby: specifier: ^0.2.12 version: 0.2.12 @@ -4619,9 +4607,6 @@ importers: rollup: specifier: ^4.35.0 version: 4.38.0 - strip-ansi: - specifier: ^7.1.0 - version: 7.1.0 packages/integrations/cloudflare/test/fixtures/astro-dev-platform: dependencies: @@ -5032,9 +5017,6 @@ importers: mdast-util-mdx-jsx: specifier: ^3.2.0 version: 3.2.0 - mdast-util-to-string: - specifier: ^4.0.0 - version: 4.0.0 rehype-mathjax: specifier: ^7.1.0 version: 7.1.0 @@ -5246,12 +5228,6 @@ importers: specifier: ^6.2.6 version: 6.2.6(@types/node@22.13.1)(jiti@2.4.2)(lightningcss@1.29.2)(sass@1.86.3)(yaml@2.5.1) devDependencies: - '@netlify/edge-functions': - specifier: ^2.11.1 - version: 2.11.1 - '@netlify/edge-handler-types': - specifier: ^0.34.1 - version: 0.34.1 '@types/node': specifier: ^22.10.6 version: 22.13.1 @@ -5267,12 +5243,6 @@ importers: devalue: specifier: ^5.1.1 version: 5.1.1 - execa: - specifier: ^8.0.1 - version: 8.0.1 - strip-ansi: - specifier: ^7.1.0 - version: 7.1.0 typescript: specifier: ^5.8.2 version: 5.8.3 @@ -5525,21 +5495,12 @@ importers: packages/integrations/preact: dependencies: - '@babel/plugin-transform-react-jsx': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.10) - '@babel/plugin-transform-react-jsx-development': - specifier: ^7.25.9 - version: 7.25.9(@babel/core@7.26.10) '@preact/preset-vite': specifier: ^2.10.1 version: 2.10.1(@babel/core@7.26.10)(preact@10.26.5)(vite@6.2.6(@types/node@22.13.1)(jiti@2.4.2)(lightningcss@1.29.2)(sass@1.86.3)(yaml@2.5.1)) '@preact/signals': specifier: ^2.0.2 version: 2.0.3(preact@10.26.5) - babel-plugin-transform-hook-names: - specifier: ^1.0.2 - version: 1.0.2(@babel/core@7.26.10) preact-render-to-string: specifier: ^6.5.13 version: 6.5.13(preact@10.26.5) @@ -5624,9 +5585,6 @@ importers: specifier: ^3.24.2 version: 3.24.2 devDependencies: - '@astrojs/node': - specifier: workspace:* - version: link:../node astro: specifier: workspace:* version: link:../../astro @@ -5648,6 +5606,9 @@ importers: packages/integrations/sitemap/test/fixtures/ssr: dependencies: + '@astrojs/node': + specifier: workspace:* + version: link:../../../../node '@astrojs/sitemap': specifier: workspace:* version: link:../../.. @@ -6180,9 +6141,6 @@ importers: specifier: ^0.2.1 version: 0.2.1 devDependencies: - astro: - specifier: workspace:* - version: link:../astro astro-scripts: specifier: workspace:* version: link:../../scripts @@ -6278,9 +6236,6 @@ importers: p-limit: specifier: ^6.2.0 version: 6.2.0 - tinyexec: - specifier: ^0.3.2 - version: 0.3.2 tinyglobby: specifier: ^0.2.12 version: 0.2.12 @@ -7598,12 +7553,6 @@ packages: resolution: {integrity: sha512-7Dg3PzArvQ0Owq4wpkLECC9iaDBOxuWUN2uwbQtUF6tZssyez2QN+eO0CjuIhhZUivbw+X9bwsyiEjWkdJnv/A==} engines: {node: ^14.16.0 || >=16.0.0} - '@netlify/edge-functions@2.11.1': - resolution: {integrity: sha512-pyQOTZ8a+ge5lZlE+H/UAHyuqQqtL5gE0pXrHT9mOykr3YQqnkB2hZMtx12odatZ87gHg4EA+UPyMZUbLfnXvw==} - - '@netlify/edge-handler-types@0.34.1': - resolution: {integrity: sha512-YTwn8cw89M4lRTmoUhl9s8ljSGMDt7FOIsxsrx7YrRz/RZlbh4Yuh4RU13DDafDRBEVuRbjGo93cnN621ZfBjA==} - '@netlify/functions@3.0.4': resolution: {integrity: sha512-Ox8+ABI+nsLK+c4/oC5dpquXuEIjzfTlJrdQKgQijCsDQoje7inXFAtKDLvvaGvuvE+PVpMLwQcIUL6P9Ob1hQ==} engines: {node: '>=18.0.0'} @@ -8770,6 +8719,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + clone@2.1.2: resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==} engines: {node: '>=0.8'} @@ -9003,6 +8956,9 @@ packages: resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==} engines: {node: '>=18'} + defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + define-lazy-prop@3.0.0: resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} engines: {node: '>=12'} @@ -9199,6 +9155,9 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + easy-table@1.2.0: + resolution: {integrity: sha512-OFzVOv03YpvtcWGe5AayU5G2hgybsg3iqA6drU8UaoZyB9jLGMTrz9+asnLp/E+6qPh88yEI1gvyZFZ41dmgww==} + ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} @@ -9993,6 +9952,14 @@ packages: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} + knip@5.50.5: + resolution: {integrity: sha512-I3mfebuG5x8i/mJJA41xjnmHMbLw75ymbDxlS7HMP+4CjY+jXEDSJyP3A2xmI5JF5/o47Fr8D7Pq3BVT0/nQPw==} + engines: {node: '>=18.18.0'} + hasBin: true + peerDependencies: + '@types/node': '>=18' + typescript: '>=5.0.4' + kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} @@ -10002,6 +9969,7 @@ packages: libsql@0.5.4: resolution: {integrity: sha512-GEFeWca4SDAQFxjHWJBE6GK52LEtSskiujbG3rqmmeTO9t4sfSBKIURNLLpKDDF7fb7jmTuuRkDAn9BZGITQNw==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lightningcss-darwin-arm64@1.29.2: @@ -10522,6 +10490,7 @@ packages: node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead node-fetch-native@1.6.6: resolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==} @@ -12250,6 +12219,9 @@ packages: typescript: optional: true + wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + web-namespaces@2.0.1: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} @@ -12439,6 +12411,12 @@ packages: typescript: ^4.9.4 || ^5.0.2 zod: ^3 + zod-validation-error@3.4.0: + resolution: {integrity: sha512-ZOPR9SVY6Pb2qqO5XHt+MkkTRxGXb4EVtnjc9JpXUOtUB1T9Ru7mZOT361AN3MsetVe7R0a1KZshJDZdgp9miQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + zod: ^3.18.0 + zod@3.22.3: resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} @@ -13780,12 +13758,6 @@ snapshots: '@netlify/blobs@8.1.1': {} - '@netlify/edge-functions@2.11.1': {} - - '@netlify/edge-handler-types@0.34.1': - dependencies: - web-streams-polyfill: 3.3.3 - '@netlify/functions@3.0.4': dependencies: '@netlify/serverless-functions-api': 1.36.0 @@ -14250,7 +14222,7 @@ snapshots: '@types/prompts@2.4.9': dependencies: - '@types/node': 22.13.1 + '@types/node': 18.19.50 kleur: 3.0.3 '@types/prop-types@15.7.12': {} @@ -14266,18 +14238,18 @@ snapshots: '@types/sax@1.2.7': dependencies: - '@types/node': 22.13.1 + '@types/node': 18.19.50 '@types/semver@7.7.0': {} '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 22.13.1 + '@types/node': 18.19.50 '@types/server-destroy@1.0.4': dependencies: - '@types/node': 22.13.1 + '@types/node': 18.19.50 '@types/trusted-types@2.0.7': {} @@ -14291,11 +14263,11 @@ snapshots: '@types/ws@8.5.12': dependencies: - '@types/node': 22.13.1 + '@types/node': 18.19.50 '@types/xml2js@0.4.14': dependencies: - '@types/node': 22.13.1 + '@types/node': 18.19.50 '@types/yargs-parser@21.0.3': {} @@ -15053,6 +15025,9 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + clone@1.0.4: + optional: true + clone@2.1.2: {} clsx@2.1.1: {} @@ -15238,6 +15213,11 @@ snapshots: bundle-name: 4.1.0 default-browser-id: 5.0.0 + defaults@1.0.4: + dependencies: + clone: 1.0.4 + optional: true + define-lazy-prop@3.0.0: {} defu@6.1.4: {} @@ -15324,6 +15304,12 @@ snapshots: eastasianwidth@0.2.0: {} + easy-table@1.2.0: + dependencies: + ansi-regex: 5.0.1 + optionalDependencies: + wcwidth: 1.0.1 + ee-first@1.1.1: {} electron-to-chromium@1.5.112: {} @@ -16309,6 +16295,25 @@ snapshots: kleur@4.1.5: {} + knip@5.50.5(@types/node@18.19.50)(typescript@5.8.3): + dependencies: + '@nodelib/fs.walk': 1.2.8 + '@types/node': 18.19.50 + easy-table: 1.2.0 + enhanced-resolve: 5.18.1 + fast-glob: 3.3.3 + jiti: 2.4.2 + js-yaml: 4.1.0 + minimist: 1.2.8 + picocolors: 1.1.1 + picomatch: 4.0.2 + pretty-ms: 9.2.0 + smol-toml: 1.3.1 + strip-json-comments: 5.0.1 + typescript: 5.8.3 + zod: 3.24.2 + zod-validation-error: 3.4.0(zod@3.24.2) + kolorist@1.8.0: {} levn@0.4.1: @@ -19020,6 +19025,11 @@ snapshots: optionalDependencies: typescript: 5.8.3 + wcwidth@1.0.1: + dependencies: + defaults: 1.0.4 + optional: true + web-namespaces@2.0.1: {} web-streams-polyfill@3.3.3: {} @@ -19210,6 +19220,10 @@ snapshots: typescript: 5.8.3 zod: 3.24.2 + zod-validation-error@3.4.0(zod@3.24.2): + dependencies: + zod: 3.24.2 + zod@3.22.3: {} zod@3.24.2: {} diff --git a/scripts/package.json b/scripts/package.json index 5232ce7e5..fe83e2e4a 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -11,7 +11,6 @@ "esbuild": "^0.25.0", "kleur": "^4.1.5", "p-limit": "^6.2.0", - "tinyexec": "^0.3.2", "tinyglobby": "^0.2.12", "tsconfck": "^3.1.5" } diff --git a/scripts/smoke/cleanup.js b/scripts/smoke/cleanup.js deleted file mode 100644 index e901556ec..000000000 --- a/scripts/smoke/cleanup.js +++ /dev/null @@ -1,65 +0,0 @@ -/** @file Remove all smoke tests and may remove extra smoke-test dependencies from `pnpm-lock.yaml`. */ - -// @ts-check - -import { exec } from 'tinyexec'; -import { promises as fs } from 'node:fs'; -import { fileURLToPath } from 'node:url'; - -/* Configuration -/* ========================================================================== */ - -/** URL directory containing this current script. */ -const scriptDir = new URL('./', import.meta.url); - -/** URL directory containing the entire project. */ -const rootDir = new URL('../../', import.meta.url); - -/* Application -/* ========================================================================== */ - -/** Runs all smoke tests. */ -async function run() { - const dirs = await getChildDirectories(scriptDir); - - if (dirs.length) { - console.log(); - - for (const dir of await getChildDirectories(scriptDir)) { - console.log('🤖', 'Removing', dir.pathname.split('/').at(-1)); - - fs.rm(dir, { force: true, recursive: true }); - } - } - - console.log(); - - console.log('🤖', 'Resetting', 'pnpm'); - - await exec('pnpm', ['install'], { - nodeOptions: { cwd: fileURLToPath(rootDir), stdio: ['pipe', 'inherit', 'inherit'] }, - throwOnError: true - }); -} - -/* Functionality -/* ========================================================================== */ - -/** Returns all child directories of the given directory. */ -const getChildDirectories = async (/** @type {URL} */ dir) => { - /** @type {URL[]} */ - const dirs = []; - - for await (const dirent of await fs.opendir(dir)) { - if (dirent.isDirectory()) { - dirs.push(new URL(dirent.name, dir)); - } - } - - return dirs; -}; - -/* Execution -/* -------------------------------------------------------------------------- */ - -run(); diff --git a/scripts/smoke/index.js b/scripts/smoke/index.js deleted file mode 100644 index 1d9651c59..000000000 --- a/scripts/smoke/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** @file Runs all smoke tests and may add extra smoke-test dependencies to `pnpm-lock.yaml`. */ - -// @ts-check - -import { exec } from 'tinyexec'; -import { promises as fs } from 'node:fs'; -import { fileURLToPath } from 'node:url'; - -/** URL directory containing the entire project. */ -const rootDir = new URL('../../', import.meta.url); - -/** URL directory containing the example subdirectories. */ -const exampleDir = new URL('examples/', rootDir); -const smokeDir = new URL('smoke/', rootDir); - -/** Returns all child directories of the given directory. */ -const getChildDirectories = async (/** @type {URL} */ dir) => { - /** @type {URL[]} */ - const dirs = []; - - for await (const dirent of await fs.opendir(dir)) { - if (dirent.isDirectory()) { - dirs.push(new URL(dirent.name, dir)); - } - } - - return dirs; -}; - -/** Runs all smoke tests. */ -async function run() { - console.log(''); - - const directories = [...(await getChildDirectories(smokeDir)), ...(await getChildDirectories(exampleDir))]; - /** @type {Partial<import('tinyexec').Options>} */ - const execOptions = { - nodeOptions: { cwd: fileURLToPath(rootDir), stdio: 'inherit' }, - throwOnError: true, - }; - - console.log('🤖', 'Preparing', 'pnpm'); - - await exec('pnpm', ['install', '--frozen-lockfile=false'], execOptions); - - for (const directory of directories) { - const name = directory.pathname.split('/').at(-1) ?? ""; - const isExternal = directory.pathname.includes(smokeDir.pathname); - console.log('🤖', 'Testing', name); - - try { - await exec('pnpm', ['install', '--ignore-scripts', '--frozen-lockfile=false'], execOptions); - await exec('pnpm', ['astro', 'telemetry', 'disable']); - await exec('pnpm', ['run', 'build'], execOptions); - } catch (err) { - console.log(err); - process.exit(1); - } - } -} - -run(); diff --git a/tsconfig.base.json b/tsconfig.base.json index d800f2f51..432d3c353 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -10,6 +10,8 @@ "esModuleInterop": true, "skipLibCheck": true, "verbatimModuleSyntax": true, - "stripInternal": true + "stripInternal": true, + "noUnusedLocals": true, + "noUnusedParameters": true } } |