Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and run format command #2736

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Setup PNPM
uses: pnpm/[email protected]
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:
Expand Down
7 changes: 6 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Also, be sure to remove "pluginSearchDirs" from config
**/*.astro

# Config
# Deep Directories
**/dist
**/smoke
**/node_modules
Expand All @@ -11,6 +11,11 @@
**/.vercel
examples/docs/**/*.md
examples/blog/**/*.md

# Directories
.github
.changeset

# Files
README.md
packages/webapi/mod.d.ts
4 changes: 2 additions & 2 deletions examples/component/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
- "packages/**/*"
- "demo"
- 'packages/**/*'
- 'demo'
10 changes: 4 additions & 6 deletions examples/starter/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
});
13 changes: 3 additions & 10 deletions examples/with-markdown/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
});
8 changes: 6 additions & 2 deletions packages/astro/src/core/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/core/dev/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
1 change: 0 additions & 1 deletion packages/astro/src/core/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const defaultLogDestination = new Writable({
dest = process.stdout;
}


let type = event.type;
if (type) {
// hide timestamp when type is undefined
Expand Down
22 changes: 18 additions & 4 deletions packages/astro/src/core/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,35 @@ 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`)}`,
``,
`Local: ${bold(cyan(toDisplayUrl(localAddress)))}`,
`Network: ${bold(cyan(toDisplayUrl(networkAddress)))}`,
``,
]
return messages.join('\n')
];
return messages.join('\n');
}

/** Display dev server host */
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-jsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
95 changes: 10 additions & 85 deletions packages/webapi/mod.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}>;
}
14 changes: 12 additions & 2 deletions packages/webapi/run/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/webapi/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Loading