From 123f6f855129d2272f8619c685a848ee40fe9535 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 7 Mar 2024 18:16:14 +0000 Subject: [PATCH] [ci] format --- packages/create-astro/src/messages.ts | 2 +- packages/create-astro/test/typescript.test.js | 6 ++-- packages/create-astro/test/utils.js | 2 +- scripts/cmd/build.js | 29 ++++++++++--------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index 966c065f45..0109835c6a 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -67,7 +67,7 @@ export const getVersion = (packageManager: string, packageName: string, fallback redirect: 'follow', }) .then((res) => res.json()) - .catch(() => ({ version: fallback })) + .catch(() => ({ version: fallback })); return resolve(version); }); diff --git a/packages/create-astro/test/typescript.test.js b/packages/create-astro/test/typescript.test.js index b44f6a864e..0eefcf7328 100644 --- a/packages/create-astro/test/typescript.test.js +++ b/packages/create-astro/test/typescript.test.js @@ -124,7 +124,9 @@ describe('typescript: setup package', async () => { ); await setupTypeScript('strictest', { cwd: fileURLToPath(root), install: false }); - const { scripts, dependencies } = JSON.parse(fs.readFileSync(packageJson, { encoding: 'utf-8' })); + const { scripts, dependencies } = JSON.parse( + fs.readFileSync(packageJson, { encoding: 'utf-8' }) + ); assert.deepEqual( Object.keys(scripts), @@ -133,7 +135,7 @@ describe('typescript: setup package', async () => { ); for (const value of Object.values(dependencies)) { - assert.doesNotMatch(value, /undefined$/, 'does not include undefined values') + assert.doesNotMatch(value, /undefined$/, 'does not include undefined values'); } assert.equal(scripts.build, 'astro check && astro build', 'prepends astro check command'); diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js index 62775a2ef9..2c363607d5 100644 --- a/packages/create-astro/test/utils.js +++ b/packages/create-astro/test/utils.js @@ -48,7 +48,7 @@ const resetNotEmptyFixture = async () => { build: 'astro build', preview: 'astro preview', }, - dependencies: undefined + dependencies: undefined, }); return Promise.all([ diff --git a/scripts/cmd/build.js b/scripts/cmd/build.js index 94645c1760..1830cddcf1 100644 --- a/scripts/cmd/build.js +++ b/scripts/cmd/build.js @@ -53,10 +53,7 @@ export default async function build(...args) { const forceCJS = args.includes('--force-cjs'); const copyWASM = args.includes('--copy-wasm'); - const { - type = 'module', - dependencies = {}, - } = await readPackageJSON('./package.json'); + const { type = 'module', dependencies = {} } = await readPackageJSON('./package.json'); config.define = {}; for (const [key, value] of await getDefinedEntries()) { @@ -141,21 +138,23 @@ async function clean(outdir) { }); } -/** - * Contextual `define` values to statically replace in the built JS output. - * Available to all packages, but mostly useful for CLIs like `create-astro`. - */ +/** + * Contextual `define` values to statically replace in the built JS output. + * Available to all packages, but mostly useful for CLIs like `create-astro`. + */ async function getDefinedEntries() { const define = { /** The current version (at the time of building) for the current package, such as `astro` or `@astrojs/sitemap` */ PACKAGE_VERSION: await getInternalPackageVersion('./package.json'), /** The current version (at the time of building) for `astro` */ - ASTRO_VERSION: await getInternalPackageVersion(new URL('../../packages/astro/package.json', import.meta.url)), + ASTRO_VERSION: await getInternalPackageVersion( + new URL('../../packages/astro/package.json', import.meta.url) + ), /** The current version (at the time of building) for `@astrojs/check` */ ASTRO_CHECK_VERSION: await getWorkspacePackageVersion('@astrojs/check'), /** The current version (at the time of building) for `typescript` */ TYPESCRIPT_VERSION: await getWorkspacePackageVersion('typescript'), - } + }; for (const [key, value] of Object.entries(define)) { if (value === undefined) { delete define[key]; @@ -169,15 +168,19 @@ async function readPackageJSON(path) { } async function getInternalPackageVersion(path) { - return readPackageJSON(path).then(res => res.version); + return readPackageJSON(path).then((res) => res.version); } async function getWorkspacePackageVersion(packageName) { - const { dependencies, devDependencies } = await readPackageJSON(new URL('../../package.json', import.meta.url)); + const { dependencies, devDependencies } = await readPackageJSON( + new URL('../../package.json', import.meta.url) + ); const deps = { ...dependencies, ...devDependencies }; const version = deps[packageName]; if (!version) { - throw new Error(`Unable to resolve "${packageName}". Is it a depdendency of the workspace root?`) + throw new Error( + `Unable to resolve "${packageName}". Is it a depdendency of the workspace root?` + ); } return version.replace(/^\D+/, ''); }