[ci] npm run format

This commit is contained in:
matthewp 2021-03-30 13:24:54 +00:00 committed by GitHub Actions
parent a79f7d4077
commit dbd764bdeb
4 changed files with 43 additions and 41 deletions

View file

@ -31,8 +31,10 @@ async function* recurseFiles(root: URL): AsyncGenerator<URL, void, unknown> {
}
async function allPages(root: URL) {
const api = new fdir().filter(p => /\.(astro|md)$/.test(p))
.withFullPaths().crawl(root.pathname);
const api = new fdir()
.filter((p) => /\.(astro|md)$/.test(p))
.withFullPaths()
.crawl(root.pathname);
const files = await api.withPromise();
return files as string[];
}
@ -73,7 +75,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> {
const runtime = await createRuntime(astroConfig, { logging: runtimeLogging });
const { runtimeConfig } = runtime;
const { snowpack } = runtimeConfig;
const resolve = (pkgName: string) => snowpack.getUrlForPackage(pkgName)
const resolve = (pkgName: string) => snowpack.getUrlForPackage(pkgName);
const imports = new Set<string>();
const statics = new Set<string>();
@ -117,7 +119,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> {
const pub = astroConfig.public;
const publicFiles = (await new fdir().withFullPaths().crawl(pub.pathname).withPromise()) as string[];
for (const filepath of publicFiles) {
const fileUrl = new URL(`file://${filepath}`)
const fileUrl = new URL(`file://${filepath}`);
const rel = pathRelative(pub.pathname, fileUrl.pathname);
const outUrl = new URL('./' + rel, dist);

View file

@ -51,7 +51,7 @@ function compileExpressionSafe(raw: string): string {
const defaultExtensions: Readonly<Record<string, ValidExtensionPlugins>> = {
'.jsx': 'react',
'.svelte': 'svelte',
'.vue': 'vue'
'.vue': 'vue',
};
export async function collectDynamicImports(filename: URL, astroConfig: AstroConfig, resolve: (s: string) => Promise<string>) {
@ -65,7 +65,7 @@ export async function collectDynamicImports(filename: URL, astroConfig: AstroCon
const extensions = astroConfig.extensions || defaultExtensions;
const source = await readFile(filename, 'utf-8');
const ast = parse(source, {
filename
filename,
});
if (!ast.module) {
@ -73,7 +73,7 @@ export async function collectDynamicImports(filename: URL, astroConfig: AstroCon
}
const componentImports: ImportDeclaration[] = [];
const components: Record<string, { plugin: ValidExtensionPlugins; type: string; specifier: string; }> = {};
const components: Record<string, { plugin: ValidExtensionPlugins; type: string; specifier: string }> = {};
const plugins = new Set<ValidExtensionPlugins>();
const program = babelParser.parse(ast.module.content, {
@ -174,7 +174,7 @@ export async function collectDynamicImports(filename: URL, astroConfig: AstroCon
break;
}
}
}
},
});
return imports;
@ -189,7 +189,7 @@ interface BundleOptions {
export async function bundle(imports: Set<string>, { runtime, dist }: BundleOptions) {
const ROOT = 'astro:root';
const root = `
${[...imports].map(url => `import '${url}';`).join('\n')}
${[...imports].map((url) => `import '${url}';`).join('\n')}
`;
const inputOptions: InputOptions = {
@ -224,10 +224,10 @@ export async function bundle(imports: Set<string>, { runtime, dist }: BundleOpti
}
return result.contents.toString('utf-8');
}
}
]
}
},
},
],
};
const build = await rollup(inputOptions);
@ -237,7 +237,7 @@ export async function bundle(imports: Set<string>, { runtime, dist }: BundleOpti
exports: 'named',
entryFileNames(chunk) {
return chunk.facadeModuleId!.substr(1);
}
},
};
await build.write(outputOptions);

View file

@ -12,7 +12,7 @@ export function collectStatics(html: string) {
return;
}
statics.add(value);
}
};
$('link[href]').each((i, el) => {
append(el, 'href');

View file

@ -127,7 +127,7 @@ export async function createRuntime(astroConfig: AstroConfig, { logging }: Runti
extensions?: Record<string, string>;
} = {
extensions,
resolve: async (pkgName: string) => snowpack.getUrlForPackage(pkgName)
resolve: async (pkgName: string) => snowpack.getUrlForPackage(pkgName),
};
const snowpackConfig = await loadConfiguration({