fix format (#2736)

This commit is contained in:
Fred K. Schott 2022-03-08 15:20:04 -08:00 committed by GitHub
parent 0ae96bb749
commit 240d88aefe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1869 additions and 1921 deletions

View file

@ -13,6 +13,15 @@ jobs:
uses: actions/checkout@v2
with:
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
run: pnpm install
env:

View file

@ -2,7 +2,7 @@
# Also, be sure to remove "pluginSearchDirs" from config
**/*.astro
# Config
# Deep Directories
**/dist
**/smoke
**/node_modules
@ -11,6 +11,11 @@
**/.vercel
examples/docs/**/*.md
examples/blog/**/*.md
# Directories
.github
.changeset
# Files
README.md
packages/webapi/mod.d.ts

View file

@ -1,3 +1,3 @@
packages:
- "packages/**/*"
- "demo"
- 'packages/**/*'
- 'demo'

View file

@ -7,9 +7,7 @@
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ (
{
// Set "renderers" to "[]" to disable all default, builtin component support.
renderers: [],
}
);
export default /** @type {import('astro').AstroUserConfig} */ ({
// Set "renderers" to "[]" to disable all default, builtin component support.
renderers: [],
});

View file

@ -7,13 +7,6 @@
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ (
{
renderers: [
"@astrojs/renderer-preact",
"@astrojs/renderer-react",
"@astrojs/renderer-svelte",
"@astrojs/renderer-vue",
],
}
);
export default /** @type {import('astro').AstroUserConfig} */ ({
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'],
});

View file

@ -38,10 +38,14 @@ export default async function dev(config: AstroConfig, options: DevOptions = { l
const viteServer = await vite.createServer(viteConfig);
await viteServer.listen(config.devOptions.port);
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
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 {
address,

View file

@ -13,8 +13,8 @@ export function emoji(char: string, fallback: string) {
export function getLocalAddress(serverAddress: string, configHostname: string): string {
if (configHostname === 'localhost' || serverAddress === '127.0.0.1' || serverAddress === '0.0.0.0') {
return 'localhost'
return 'localhost';
} else {
return serverAddress
return serverAddress;
}
}
}

View file

@ -35,7 +35,6 @@ export const defaultLogDestination = new Writable({
dest = process.stdout;
}
let type = event.type;
if (type) {
// hide timestamp when type is undefined

View file

@ -23,12 +23,26 @@ export function reload({ url, reqTime }: { url: string; reqTime: number }): stri
}
/** 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
const pkgVersion = process.env.PACKAGE_VERSION;
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 = [
``,
`${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)))}`,
`Network: ${bold(cyan(toDisplayUrl(networkAddress)))}`,
``,
]
return messages.join('\n')
];
return messages.join('\n');
}
/** Display dev server host */

View file

@ -128,7 +128,7 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
httpServer = server.listen(port, hostname, async () => {
if (!showedListenMsg) {
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 }));
}

View file

@ -35,7 +35,7 @@ async function importJSXRenderers(config: AstroConfig): Promise<Map<string, Rend
return import(resolveDependency(name, config)).then(({ default: renderer }) => {
if (!renderer.jsxImportSource) return;
renderers.set(renderer.jsxImportSource, renderer);
})
});
})
);
return renderers;

View file

@ -19,11 +19,11 @@ describe('astro cli', () => {
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 () => {
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);
let stdout = '';

View file

@ -1,87 +1,12 @@
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'
export { pathToPosix } from './lib/utils'
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';
export { pathToPosix } from './lib/utils';
export declare const polyfill: {
(target: any, options?: PolyfillOptions | undefined): any
internals(target: any, name: string): any
}
(target: any, options?: PolyfillOptions | undefined): any;
internals(target: any, name: string): any;
};
interface PolyfillOptions {
exclude?: string | string[]
override?: Record<
string,
{
(...args: any[]): any
}
>
}
exclude?: string | string[];
override?: Record<string, {
(...args: any[]): any;
}>;
}

View file

@ -20,8 +20,18 @@ const readFile = (/** @type {string} */ id) =>
readFileCache[id] || (readFileCache[id] = nodeReadFile(id, 'utf8'))
const pathToDOMException = path.resolve('src', 'lib', 'DOMException.js')
const pathToEventTargetShim = path.resolve('node_modules', 'event-target-shim', 'index.mjs')
const pathToStructuredClone = path.resolve('node_modules', '@ungap', 'structured-clone', 'esm', 'index.js')
const pathToEventTargetShim = path.resolve(
'node_modules',
'event-target-shim',
'index.mjs'
)
const pathToStructuredClone = path.resolve(
'node_modules',
'@ungap',
'structured-clone',
'esm',
'index.js'
)
const plugins = [
typescript({

View file

@ -1,4 +1,4 @@
declare module "node:*"
declare module 'node:*'
declare module '@ungap/structured-clone/esm/index.js'
declare module '@ungap/structured-clone/esm/deserialize.js'
declare module '@ungap/structured-clone/esm/serialize.js'

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
packages:
- "packages/**/*"
- "examples/**/*"
- "smoke/**/*"
- "scripts"
- 'packages/**/*'
- 'examples/**/*'
- 'smoke/**/*'
- 'scripts'

View file

@ -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 })))));
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) };
const format = type === 'module' ? 'esm' : 'cjs';
const outdir = 'dist';

View file

@ -2,13 +2,8 @@
"baseBranch": "origin/main",
"pipeline": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"**/dist/**",
"!**/vendor/**"
]
"dependsOn": ["^build"],
"outputs": ["**/dist/**", "!**/vendor/**"]
},
"dev": {
"cache": false
@ -20,9 +15,7 @@
"outputs": []
},
"benchmark": {
"dependsOn": [
"^build"
],
"dependsOn": ["^build"],
"outputs": []
},
"lint": {