mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
fix format (#2736)
This commit is contained in:
parent
0ae96bb749
commit
240d88aefe
19 changed files with 1869 additions and 1921 deletions
9
.github/workflows/format.yml
vendored
9
.github/workflows/format.yml
vendored
|
@ -13,6 +13,15 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Setup PNPM
|
||||||
|
uses: pnpm/action-setup@v2.0.1
|
||||||
|
with:
|
||||||
|
version: 6.23.6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
cache: 'pnpm'
|
||||||
- name: Install NPM Dependencies
|
- name: Install NPM Dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Also, be sure to remove "pluginSearchDirs" from config
|
# Also, be sure to remove "pluginSearchDirs" from config
|
||||||
**/*.astro
|
**/*.astro
|
||||||
|
|
||||||
# Config
|
# Deep Directories
|
||||||
**/dist
|
**/dist
|
||||||
**/smoke
|
**/smoke
|
||||||
**/node_modules
|
**/node_modules
|
||||||
|
@ -11,6 +11,11 @@
|
||||||
**/.vercel
|
**/.vercel
|
||||||
examples/docs/**/*.md
|
examples/docs/**/*.md
|
||||||
examples/blog/**/*.md
|
examples/blog/**/*.md
|
||||||
|
|
||||||
|
# Directories
|
||||||
.github
|
.github
|
||||||
.changeset
|
.changeset
|
||||||
|
|
||||||
|
# Files
|
||||||
README.md
|
README.md
|
||||||
|
packages/webapi/mod.d.ts
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
packages:
|
packages:
|
||||||
- "packages/**/*"
|
- 'packages/**/*'
|
||||||
- "demo"
|
- 'demo'
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
// You can disable this by removing "@ts-check" and `@type` comments below.
|
// You can disable this by removing "@ts-check" and `@type` comments below.
|
||||||
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
export default /** @type {import('astro').AstroUserConfig} */ (
|
export default /** @type {import('astro').AstroUserConfig} */ ({
|
||||||
{
|
// Set "renderers" to "[]" to disable all default, builtin component support.
|
||||||
// Set "renderers" to "[]" to disable all default, builtin component support.
|
renderers: [],
|
||||||
renderers: [],
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
|
@ -7,13 +7,6 @@
|
||||||
// You can disable this by removing "@ts-check" and `@type` comments below.
|
// You can disable this by removing "@ts-check" and `@type` comments below.
|
||||||
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
export default /** @type {import('astro').AstroUserConfig} */ (
|
export default /** @type {import('astro').AstroUserConfig} */ ({
|
||||||
{
|
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'],
|
||||||
renderers: [
|
});
|
||||||
"@astrojs/renderer-preact",
|
|
||||||
"@astrojs/renderer-react",
|
|
||||||
"@astrojs/renderer-svelte",
|
|
||||||
"@astrojs/renderer-vue",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
|
@ -38,10 +38,14 @@ export default async function dev(config: AstroConfig, options: DevOptions = { l
|
||||||
const viteServer = await vite.createServer(viteConfig);
|
const viteServer = await vite.createServer(viteConfig);
|
||||||
await viteServer.listen(config.devOptions.port);
|
await viteServer.listen(config.devOptions.port);
|
||||||
const address = viteServer.httpServer!.address() as AddressInfo;
|
const address = viteServer.httpServer!.address() as AddressInfo;
|
||||||
const localAddress = getLocalAddress(address.address, config.devOptions.hostname)
|
const localAddress = getLocalAddress(address.address, config.devOptions.hostname);
|
||||||
// Log to console
|
// Log to console
|
||||||
const site = config.buildOptions.site ? new URL(config.buildOptions.site) : undefined;
|
const site = config.buildOptions.site ? new URL(config.buildOptions.site) : undefined;
|
||||||
info(options.logging, null, msg.devStart({ startupTime: performance.now() - devStart, port: address.port, localAddress, networkAddress: address.address, site, https: !!viteUserConfig.server?.https }));
|
info(
|
||||||
|
options.logging,
|
||||||
|
null,
|
||||||
|
msg.devStart({ startupTime: performance.now() - devStart, port: address.port, localAddress, networkAddress: address.address, site, https: !!viteUserConfig.server?.https })
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
address,
|
address,
|
||||||
|
|
|
@ -13,8 +13,8 @@ export function emoji(char: string, fallback: string) {
|
||||||
|
|
||||||
export function getLocalAddress(serverAddress: string, configHostname: string): string {
|
export function getLocalAddress(serverAddress: string, configHostname: string): string {
|
||||||
if (configHostname === 'localhost' || serverAddress === '127.0.0.1' || serverAddress === '0.0.0.0') {
|
if (configHostname === 'localhost' || serverAddress === '127.0.0.1' || serverAddress === '0.0.0.0') {
|
||||||
return 'localhost'
|
return 'localhost';
|
||||||
} else {
|
} else {
|
||||||
return serverAddress
|
return serverAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ export const defaultLogDestination = new Writable({
|
||||||
dest = process.stdout;
|
dest = process.stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let type = event.type;
|
let type = event.type;
|
||||||
if (type) {
|
if (type) {
|
||||||
// hide timestamp when type is undefined
|
// hide timestamp when type is undefined
|
||||||
|
|
|
@ -23,12 +23,26 @@ export function reload({ url, reqTime }: { url: string; reqTime: number }): stri
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Display dev server host and startup time */
|
/** Display dev server host and startup time */
|
||||||
export function devStart({ startupTime, port, localAddress, networkAddress, https, site }: { startupTime: number; port: number; localAddress: string; networkAddress: string; https: boolean; site: URL | undefined }): string {
|
export function devStart({
|
||||||
|
startupTime,
|
||||||
|
port,
|
||||||
|
localAddress,
|
||||||
|
networkAddress,
|
||||||
|
https,
|
||||||
|
site,
|
||||||
|
}: {
|
||||||
|
startupTime: number;
|
||||||
|
port: number;
|
||||||
|
localAddress: string;
|
||||||
|
networkAddress: string;
|
||||||
|
https: boolean;
|
||||||
|
site: URL | undefined;
|
||||||
|
}): string {
|
||||||
// PACAKGE_VERSION is injected at build-time
|
// PACAKGE_VERSION is injected at build-time
|
||||||
const pkgVersion = process.env.PACKAGE_VERSION;
|
const pkgVersion = process.env.PACKAGE_VERSION;
|
||||||
|
|
||||||
const rootPath = site ? site.pathname : '/';
|
const rootPath = site ? site.pathname : '/';
|
||||||
const toDisplayUrl = (hostname: string) => `${https ? 'https' : 'http'}://${hostname}:${port}${rootPath}`
|
const toDisplayUrl = (hostname: string) => `${https ? 'https' : 'http'}://${hostname}:${port}${rootPath}`;
|
||||||
const messages = [
|
const messages = [
|
||||||
``,
|
``,
|
||||||
`${emoji('🚀 ', '')}${magenta(`astro ${pkgVersion}`)} ${dim(`started in ${Math.round(startupTime)}ms`)}`,
|
`${emoji('🚀 ', '')}${magenta(`astro ${pkgVersion}`)} ${dim(`started in ${Math.round(startupTime)}ms`)}`,
|
||||||
|
@ -36,8 +50,8 @@ export function devStart({ startupTime, port, localAddress, networkAddress, http
|
||||||
`Local: ${bold(cyan(toDisplayUrl(localAddress)))}`,
|
`Local: ${bold(cyan(toDisplayUrl(localAddress)))}`,
|
||||||
`Network: ${bold(cyan(toDisplayUrl(networkAddress)))}`,
|
`Network: ${bold(cyan(toDisplayUrl(networkAddress)))}`,
|
||||||
``,
|
``,
|
||||||
]
|
];
|
||||||
return messages.join('\n')
|
return messages.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Display dev server host */
|
/** Display dev server host */
|
||||||
|
|
|
@ -128,7 +128,7 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
|
||||||
httpServer = server.listen(port, hostname, async () => {
|
httpServer = server.listen(port, hostname, async () => {
|
||||||
if (!showedListenMsg) {
|
if (!showedListenMsg) {
|
||||||
const { address: networkAddress } = server.address() as AddressInfo;
|
const { address: networkAddress } = server.address() as AddressInfo;
|
||||||
const localAddress = getLocalAddress(networkAddress, hostname)
|
const localAddress = getLocalAddress(networkAddress, hostname);
|
||||||
|
|
||||||
info(logging, null, msg.devStart({ startupTime: performance.now() - timerStart, port, localAddress, networkAddress, https: false, site: baseURL }));
|
info(logging, null, msg.devStart({ startupTime: performance.now() - timerStart, port, localAddress, networkAddress, https: false, site: baseURL }));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ async function importJSXRenderers(config: AstroConfig): Promise<Map<string, Rend
|
||||||
return import(resolveDependency(name, config)).then(({ default: renderer }) => {
|
return import(resolveDependency(name, config)).then(({ default: renderer }) => {
|
||||||
if (!renderer.jsxImportSource) return;
|
if (!renderer.jsxImportSource) return;
|
||||||
renderers.set(renderer.jsxImportSource, renderer);
|
renderers.set(renderer.jsxImportSource, renderer);
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return renderers;
|
return renderers;
|
||||||
|
|
|
@ -19,11 +19,11 @@ describe('astro cli', () => {
|
||||||
expect(proc.stdout).to.equal(pkgVersion);
|
expect(proc.stdout).to.equal(pkgVersion);
|
||||||
});
|
});
|
||||||
|
|
||||||
[undefined, '0.0.0.0', '127.0.0.1'].forEach(hostname => {
|
[undefined, '0.0.0.0', '127.0.0.1'].forEach((hostname) => {
|
||||||
it(`astro dev --hostname=${hostname}`, async () => {
|
it(`astro dev --hostname=${hostname}`, async () => {
|
||||||
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
|
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
|
||||||
|
|
||||||
const hostnameArgs = hostname ? ['--hostname', hostname] : []
|
const hostnameArgs = hostname ? ['--hostname', hostname] : [];
|
||||||
const proc = cli('dev', '--project-root', fileURLToPath(projectRootURL), ...hostnameArgs);
|
const proc = cli('dev', '--project-root', fileURLToPath(projectRootURL), ...hostnameArgs);
|
||||||
|
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
|
|
95
packages/webapi/mod.d.ts
vendored
95
packages/webapi/mod.d.ts
vendored
|
@ -1,87 +1,12 @@
|
||||||
export {
|
export { AbortController, AbortSignal, Blob, ByteLengthQueuingStrategy, CanvasRenderingContext2D, CharacterData, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, DOMException, Document, DocumentFragment, Element, Event, EventTarget, File, FormData, HTMLDocument, HTMLElement, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Headers, IntersectionObserver, Image, ImageData, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, ResizeObserver, Response, ShadowRoot, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, Window, alert, atob, btoa, cancelAnimationFrame, cancelIdleCallback, clearTimeout, fetch, requestAnimationFrame, requestIdleCallback, setTimeout, structuredClone, } from './mod.js';
|
||||||
AbortController,
|
export { pathToPosix } from './lib/utils';
|
||||||
AbortSignal,
|
|
||||||
Blob,
|
|
||||||
ByteLengthQueuingStrategy,
|
|
||||||
CanvasRenderingContext2D,
|
|
||||||
CharacterData,
|
|
||||||
Comment,
|
|
||||||
CountQueuingStrategy,
|
|
||||||
CSSStyleSheet,
|
|
||||||
CustomElementRegistry,
|
|
||||||
CustomEvent,
|
|
||||||
DOMException,
|
|
||||||
Document,
|
|
||||||
DocumentFragment,
|
|
||||||
Element,
|
|
||||||
Event,
|
|
||||||
EventTarget,
|
|
||||||
File,
|
|
||||||
FormData,
|
|
||||||
HTMLDocument,
|
|
||||||
HTMLElement,
|
|
||||||
HTMLBodyElement,
|
|
||||||
HTMLCanvasElement,
|
|
||||||
HTMLDivElement,
|
|
||||||
HTMLHeadElement,
|
|
||||||
HTMLHtmlElement,
|
|
||||||
HTMLImageElement,
|
|
||||||
HTMLSpanElement,
|
|
||||||
HTMLStyleElement,
|
|
||||||
HTMLTemplateElement,
|
|
||||||
HTMLUnknownElement,
|
|
||||||
Headers,
|
|
||||||
IntersectionObserver,
|
|
||||||
Image,
|
|
||||||
ImageData,
|
|
||||||
MediaQueryList,
|
|
||||||
MutationObserver,
|
|
||||||
Node,
|
|
||||||
NodeFilter,
|
|
||||||
NodeIterator,
|
|
||||||
OffscreenCanvas,
|
|
||||||
ReadableByteStreamController,
|
|
||||||
ReadableStream,
|
|
||||||
ReadableStreamBYOBReader,
|
|
||||||
ReadableStreamBYOBRequest,
|
|
||||||
ReadableStreamDefaultController,
|
|
||||||
ReadableStreamDefaultReader,
|
|
||||||
Request,
|
|
||||||
ResizeObserver,
|
|
||||||
Response,
|
|
||||||
ShadowRoot,
|
|
||||||
StyleSheet,
|
|
||||||
Text,
|
|
||||||
TransformStream,
|
|
||||||
TreeWalker,
|
|
||||||
URLPattern,
|
|
||||||
WritableStream,
|
|
||||||
WritableStreamDefaultController,
|
|
||||||
WritableStreamDefaultWriter,
|
|
||||||
Window,
|
|
||||||
alert,
|
|
||||||
atob,
|
|
||||||
btoa,
|
|
||||||
cancelAnimationFrame,
|
|
||||||
cancelIdleCallback,
|
|
||||||
clearTimeout,
|
|
||||||
fetch,
|
|
||||||
requestAnimationFrame,
|
|
||||||
requestIdleCallback,
|
|
||||||
setTimeout,
|
|
||||||
structuredClone,
|
|
||||||
} from './mod.js'
|
|
||||||
export { pathToPosix } from './lib/utils'
|
|
||||||
export declare const polyfill: {
|
export declare const polyfill: {
|
||||||
(target: any, options?: PolyfillOptions | undefined): any
|
(target: any, options?: PolyfillOptions | undefined): any;
|
||||||
internals(target: any, name: string): any
|
internals(target: any, name: string): any;
|
||||||
}
|
};
|
||||||
interface PolyfillOptions {
|
interface PolyfillOptions {
|
||||||
exclude?: string | string[]
|
exclude?: string | string[];
|
||||||
override?: Record<
|
override?: Record<string, {
|
||||||
string,
|
(...args: any[]): any;
|
||||||
{
|
}>;
|
||||||
(...args: any[]): any
|
}
|
||||||
}
|
|
||||||
>
|
|
||||||
}
|
|
|
@ -20,8 +20,18 @@ const readFile = (/** @type {string} */ id) =>
|
||||||
readFileCache[id] || (readFileCache[id] = nodeReadFile(id, 'utf8'))
|
readFileCache[id] || (readFileCache[id] = nodeReadFile(id, 'utf8'))
|
||||||
|
|
||||||
const pathToDOMException = path.resolve('src', 'lib', 'DOMException.js')
|
const pathToDOMException = path.resolve('src', 'lib', 'DOMException.js')
|
||||||
const pathToEventTargetShim = path.resolve('node_modules', 'event-target-shim', 'index.mjs')
|
const pathToEventTargetShim = path.resolve(
|
||||||
const pathToStructuredClone = path.resolve('node_modules', '@ungap', 'structured-clone', 'esm', 'index.js')
|
'node_modules',
|
||||||
|
'event-target-shim',
|
||||||
|
'index.mjs'
|
||||||
|
)
|
||||||
|
const pathToStructuredClone = path.resolve(
|
||||||
|
'node_modules',
|
||||||
|
'@ungap',
|
||||||
|
'structured-clone',
|
||||||
|
'esm',
|
||||||
|
'index.js'
|
||||||
|
)
|
||||||
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
typescript({
|
typescript({
|
||||||
|
|
2
packages/webapi/src/types.d.ts
vendored
2
packages/webapi/src/types.d.ts
vendored
|
@ -1,4 +1,4 @@
|
||||||
declare module "node:*"
|
declare module 'node:*'
|
||||||
declare module '@ungap/structured-clone/esm/index.js'
|
declare module '@ungap/structured-clone/esm/index.js'
|
||||||
declare module '@ungap/structured-clone/esm/deserialize.js'
|
declare module '@ungap/structured-clone/esm/deserialize.js'
|
||||||
declare module '@ungap/structured-clone/esm/serialize.js'
|
declare module '@ungap/structured-clone/esm/serialize.js'
|
||||||
|
|
3568
pnpm-lock.yaml
3568
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
packages:
|
packages:
|
||||||
- "packages/**/*"
|
- 'packages/**/*'
|
||||||
- "examples/**/*"
|
- 'examples/**/*'
|
||||||
- "smoke/**/*"
|
- 'smoke/**/*'
|
||||||
- "scripts"
|
- 'scripts'
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default async function build(...args) {
|
||||||
let entryPoints = [].concat(...(await Promise.all(patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true })))));
|
let entryPoints = [].concat(...(await Promise.all(patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true })))));
|
||||||
|
|
||||||
const { type = 'module', version, dependencies = {} } = await fs.readFile('./package.json').then((res) => JSON.parse(res.toString()));
|
const { type = 'module', version, dependencies = {} } = await fs.readFile('./package.json').then((res) => JSON.parse(res.toString()));
|
||||||
// expose PACKAGE_VERSION on process.env for CLI utils
|
// expose PACKAGE_VERSION on process.env for CLI utils
|
||||||
config.define = { 'process.env.PACKAGE_VERSION': JSON.stringify(version) };
|
config.define = { 'process.env.PACKAGE_VERSION': JSON.stringify(version) };
|
||||||
const format = type === 'module' ? 'esm' : 'cjs';
|
const format = type === 'module' ? 'esm' : 'cjs';
|
||||||
const outdir = 'dist';
|
const outdir = 'dist';
|
||||||
|
|
13
turbo.json
13
turbo.json
|
@ -2,13 +2,8 @@
|
||||||
"baseBranch": "origin/main",
|
"baseBranch": "origin/main",
|
||||||
"pipeline": {
|
"pipeline": {
|
||||||
"build": {
|
"build": {
|
||||||
"dependsOn": [
|
"dependsOn": ["^build"],
|
||||||
"^build"
|
"outputs": ["**/dist/**", "!**/vendor/**"]
|
||||||
],
|
|
||||||
"outputs": [
|
|
||||||
"**/dist/**",
|
|
||||||
"!**/vendor/**"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"dev": {
|
"dev": {
|
||||||
"cache": false
|
"cache": false
|
||||||
|
@ -20,9 +15,7 @@
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
"benchmark": {
|
"benchmark": {
|
||||||
"dependsOn": [
|
"dependsOn": ["^build"],
|
||||||
"^build"
|
|
||||||
],
|
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
|
|
Loading…
Reference in a new issue