[ci] format
This commit is contained in:
parent
13b271bc7d
commit
6a1a40eef8
14 changed files with 29 additions and 33 deletions
|
@ -681,7 +681,7 @@ export interface AstroIntegration {
|
||||||
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
||||||
'astro:server:done'?: () => void | Promise<void>;
|
'astro:server:done'?: () => void | Promise<void>;
|
||||||
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
|
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
|
||||||
'astro:build:setup'?: (options: { vite: ViteConfigWithSSR, target: 'client' | 'server' }) => void;
|
'astro:build:setup'?: (options: { vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void;
|
||||||
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class App {
|
||||||
#encoder = new TextEncoder();
|
#encoder = new TextEncoder();
|
||||||
#logging: LogOptions = {
|
#logging: LogOptions = {
|
||||||
dest: consoleLogDestination,
|
dest: consoleLogDestination,
|
||||||
level: 'info'
|
level: 'info',
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(manifest: Manifest) {
|
constructor(manifest: Manifest) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
server: viteConfig.server,
|
server: viteConfig.server,
|
||||||
base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
|
base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
|
||||||
ssr: viteConfig.ssr,
|
ssr: viteConfig.ssr,
|
||||||
resolve: viteConfig.resolve
|
resolve: viteConfig.resolve,
|
||||||
} as ViteConfigWithSSR;
|
} as ViteConfigWithSSR;
|
||||||
|
|
||||||
await runHookBuildSetup({ config: astroConfig, vite: viteBuildConfig, target: 'server' });
|
await runHookBuildSetup({ config: astroConfig, vite: viteBuildConfig, target: 'server' });
|
||||||
|
|
|
@ -85,8 +85,8 @@ export async function createVite(commandConfig: ViteConfigWithSSR, { astroConfig
|
||||||
alias: {
|
alias: {
|
||||||
// This is needed for Deno compatibility, as the non-browser version
|
// This is needed for Deno compatibility, as the non-browser version
|
||||||
// of this module depends on Node `crypto`
|
// of this module depends on Node `crypto`
|
||||||
'randombytes': 'randombytes/browser'
|
randombytes: 'randombytes/browser',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
|
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
|
||||||
ssr: {
|
ssr: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { AstroConfig } from '../../@types/astro';
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
import { bold, dim } from 'kleur/colors';
|
import { bold, dim } from 'kleur/colors';
|
||||||
import stringWidth from 'string-width';
|
import stringWidth from 'string-width';
|
||||||
|
|
||||||
interface LogWritable<T> {
|
interface LogWritable<T> {
|
||||||
|
@ -90,7 +90,7 @@ export function table(opts: LogOptions, columns: number[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function debug(...args: any[]) {
|
export function debug(...args: any[]) {
|
||||||
if('_astroGlobalDebug' in globalThis) {
|
if ('_astroGlobalDebug' in globalThis) {
|
||||||
(globalThis as any)._astroGlobalDebug(...args);
|
(globalThis as any)._astroGlobalDebug(...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ function padStr(str: string, len: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export let defaultLogLevel: LoggerLevel;
|
export let defaultLogLevel: LoggerLevel;
|
||||||
if(typeof process !== 'undefined') {
|
if (typeof process !== 'undefined') {
|
||||||
if (process.argv.includes('--verbose')) {
|
if (process.argv.includes('--verbose')) {
|
||||||
defaultLogLevel = 'debug';
|
defaultLogLevel = 'debug';
|
||||||
} else if (process.argv.includes('--silent')) {
|
} else if (process.argv.includes('--silent')) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ type ConsoleStream = Writable & {
|
||||||
fd: 1 | 2;
|
fd: 1 | 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let lastMessage: string;
|
let lastMessage: string;
|
||||||
let lastMessageCount = 1;
|
let lastMessageCount = 1;
|
||||||
export const nodeLogDestination = new Writable({
|
export const nodeLogDestination = new Writable({
|
||||||
|
@ -125,7 +124,6 @@ export const logger = {
|
||||||
error: error.bind(null, nodeLogOptions),
|
error: error.bind(null, nodeLogOptions),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export function enableVerboseLogging() {
|
export function enableVerboseLogging() {
|
||||||
//debugPackage.enable('*,-babel');
|
//debugPackage.enable('*,-babel');
|
||||||
debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"');
|
debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"');
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// Vendored from https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl
|
// Vendored from https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl
|
||||||
/** Basic stylesheet for RSS feeds */
|
/** Basic stylesheet for RSS feeds */
|
||||||
export const PRETTY_FEED_V3 = `<?xml version="1.0" encoding="utf-8"?>
|
export const PRETTY_FEED_V3 = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -92,7 +92,7 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig, vite: ViteConfigWithSSR, target: 'server' | 'client' }) {
|
export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig; vite: ViteConfigWithSSR; target: 'server' | 'client' }) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration.hooks['astro:build:setup']) {
|
if (integration.hooks['astro:build:setup']) {
|
||||||
await integration.hooks['astro:build:setup']({ vite, target });
|
await integration.hooks['astro:build:setup']({ vite, target });
|
||||||
|
|
|
@ -74,7 +74,7 @@ export async function loadFixture(inlineConfig) {
|
||||||
/** @type {import('../src/core/logger/core').LogOptions} */
|
/** @type {import('../src/core/logger/core').LogOptions} */
|
||||||
const logging = {
|
const logging = {
|
||||||
dest: nodeLogDestination,
|
dest: nodeLogDestination,
|
||||||
level: 'error'
|
level: 'error',
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export function getAdapter(args?: Options): AstroAdapter {
|
||||||
name: '@astrojs/deno',
|
name: '@astrojs/deno',
|
||||||
serverEntrypoint: '@astrojs/deno/server.js',
|
serverEntrypoint: '@astrojs/deno/server.js',
|
||||||
args: args ?? {},
|
args: args ?? {},
|
||||||
exports: ['stop', 'handle']
|
exports: ['stop', 'handle'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
||||||
setAdapter(getAdapter(args));
|
setAdapter(getAdapter(args));
|
||||||
},
|
},
|
||||||
'astro:build:setup': ({ vite, target }) => {
|
'astro:build:setup': ({ vite, target }) => {
|
||||||
if(target === 'server') {
|
if (target === 'server') {
|
||||||
vite.ssr = {
|
vite.ssr = {
|
||||||
noExternal: true
|
noExternal: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import './shim.js';
|
||||||
import type { SSRManifest } from 'astro';
|
import type { SSRManifest } from 'astro';
|
||||||
import { App } from 'astro/app';
|
import { App } from 'astro/app';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Server } from "https://deno.land/std@0.132.0/http/server.ts";
|
import { Server } from 'https://deno.land/std@0.132.0/http/server.ts';
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
port?: number;
|
port?: number;
|
||||||
|
@ -14,7 +14,7 @@ let _server: Server | undefined = undefined;
|
||||||
let _startPromise: Promise<void> | undefined = undefined;
|
let _startPromise: Promise<void> | undefined = undefined;
|
||||||
|
|
||||||
export function start(manifest: SSRManifest, options: Options) {
|
export function start(manifest: SSRManifest, options: Options) {
|
||||||
if(options.start === false) {
|
if (options.start === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,26 +26,26 @@ export function start(manifest: SSRManifest, options: Options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
_server = new Server({
|
_server = new Server({
|
||||||
port: options.port ?? 8085,
|
port: options.port ?? 8085,
|
||||||
hostname: options.hostname ?? "0.0.0.0",
|
hostname: options.hostname ?? '0.0.0.0',
|
||||||
handler,
|
handler,
|
||||||
//onError: options.onError,
|
//onError: options.onError,
|
||||||
});
|
});
|
||||||
|
|
||||||
_startPromise = _server.listenAndServe();
|
_startPromise = _server.listenAndServe();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createExports(manifest: SSRManifest) {
|
export function createExports(manifest: SSRManifest) {
|
||||||
const app = new App(manifest);
|
const app = new App(manifest);
|
||||||
return {
|
return {
|
||||||
async stop() {
|
async stop() {
|
||||||
if(_server) {
|
if (_server) {
|
||||||
_server.close();
|
_server.close();
|
||||||
}
|
}
|
||||||
await Promise.resolve(_startPromise);
|
await Promise.resolve(_startPromise);
|
||||||
},
|
},
|
||||||
async handle(request: Request) {
|
async handle(request: Request) {
|
||||||
return app.render(request);
|
return app.render(request);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
(globalThis as any).process = {
|
(globalThis as any).process = {
|
||||||
argv: [],
|
argv: [],
|
||||||
env: {}
|
env: {},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,5 +10,5 @@ Deno.test({
|
||||||
const html = await resp.text();
|
const html = await resp.text();
|
||||||
assert(html);
|
assert(html);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ const dir = new URL('./', import.meta.url);
|
||||||
export async function runBuild(fixturePath) {
|
export async function runBuild(fixturePath) {
|
||||||
let proc = Deno.run({
|
let proc = Deno.run({
|
||||||
cmd: ['node', '../../../../../astro/astro.js', 'build', '--silent'],
|
cmd: ['node', '../../../../../astro/astro.js', 'build', '--silent'],
|
||||||
cwd: fromFileUrl(new URL(fixturePath, dir))
|
cwd: fromFileUrl(new URL(fixturePath, dir)),
|
||||||
});
|
});
|
||||||
await proc.status();
|
await proc.status();
|
||||||
return async () => await proc.close();
|
return async () => await proc.close();
|
||||||
|
|
Loading…
Reference in a new issue