summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2022-04-02 14:15:41 -0600
committerGravatar GitHub <noreply@github.com> 2022-04-02 14:15:41 -0600
commit1335797903a57716e9a02b0ffd8ca636b3883c62 (patch)
treed8835124fec7ab80bfbf25c6d9c5a57039a1c56d /scripts
parentd63213f1198293e72bb9d9734bf4ec8309c515d4 (diff)
downloadastro-1335797903a57716e9a02b0ffd8ca636b3883c62.tar.gz
astro-1335797903a57716e9a02b0ffd8ca636b3883c62.tar.zst
astro-1335797903a57716e9a02b0ffd8ca636b3883c62.zip
update prettier width (#2968)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cmd/build.js16
-rw-r--r--scripts/cmd/copy.js4
-rw-r--r--scripts/memory/index.js8
-rwxr-xr-xscripts/notify/index.js29
-rw-r--r--scripts/stats/index.js18
-rw-r--r--scripts/utils/svelte-plugin.js15
6 files changed, 72 insertions, 18 deletions
diff --git a/scripts/cmd/build.js b/scripts/cmd/build.js
index 3a182c656..b2d402890 100644
--- a/scripts/cmd/build.js
+++ b/scripts/cmd/build.js
@@ -26,9 +26,17 @@ export default async function build(...args) {
const patterns = args
.filter((f) => !!f) // remove empty args
.map((f) => f.replace(/^'/, '').replace(/'$/, '')); // Needed for Windows: glob strings contain surrounding string chars??? remove these
- 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
config.define = { 'process.env.PACKAGE_VERSION': JSON.stringify(version) };
const format = type === 'module' ? 'esm' : 'cjs';
@@ -56,7 +64,9 @@ export default async function build(...args) {
console.error(dim(`[${date}] `) + red(error || result.errors.join('\n')));
} else {
if (result.warnings.length) {
- console.log(dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n')));
+ console.log(
+ dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n'))
+ );
}
console.log(dim(`[${date}] `) + green('✔ updated'));
}
diff --git a/scripts/cmd/copy.js b/scripts/cmd/copy.js
index 925990fe4..1700e56c4 100644
--- a/scripts/cmd/copy.js
+++ b/scripts/cmd/copy.js
@@ -63,7 +63,9 @@ export default async function copy() {
await Promise.all(
files.map((file) => {
const dest = resolve(file.replace(/^[^/]+/, 'dist'));
- return fs.mkdir(dirname(dest), { recursive: true }).then(() => fs.copyFile(resolve(file), dest));
+ return fs
+ .mkdir(dirname(dest), { recursive: true })
+ .then(() => fs.copyFile(resolve(file), dest));
})
);
}
diff --git a/scripts/memory/index.js b/scripts/memory/index.js
index a1e34e144..da55acb71 100644
--- a/scripts/memory/index.js
+++ b/scripts/memory/index.js
@@ -35,7 +35,9 @@ const startSize = v8.getHeapStatistics().used_heap_size;
// HUMAN mode: Runs forever. Optimized for accurate results on each snapshot Slower than CI.
if (!isCI) {
- console.log(`Greetings, human. This test will run forever. Run with the "--ci" flag to finish with a result.`);
+ console.log(
+ `Greetings, human. This test will run forever. Run with the "--ci" flag to finish with a result.`
+ );
let i = 1;
while (i++) {
await run();
@@ -62,7 +64,9 @@ const TEST_THRESHOLD = 1.5;
const isPass = percentage < TEST_THRESHOLD;
console.log(``);
console.log(`Result: ${isPass ? 'PASS' : 'FAIL'} (${percentage * 100}%)`);
-console.log(`Memory usage began at ${prettyBytes(startSize)} and finished at ${prettyBytes(endSize)}.`);
+console.log(
+ `Memory usage began at ${prettyBytes(startSize)} and finished at ${prettyBytes(endSize)}.`
+);
console.log(`The threshold for a probable memory leak is ${TEST_THRESHOLD * 100}%`);
console.log(``);
console.log(`Exiting...`);
diff --git a/scripts/notify/index.js b/scripts/notify/index.js
index a0505c9ae..fa699372a 100755
--- a/scripts/notify/index.js
+++ b/scripts/notify/index.js
@@ -5,7 +5,16 @@ import { readFile } from 'node:fs/promises';
const baseUrl = new URL('https://github.com/withastro/astro/blob/main/');
const emojis = ['🎉', '🥳', '🚀', '🧑‍🚀', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
-const descriptors = ['new releases', 'hot and fresh updates', 'shiny updates', 'exciting changes', 'package updates', 'awesome updates', 'bug fixes and features', 'updates'];
+const descriptors = [
+ 'new releases',
+ 'hot and fresh updates',
+ 'shiny updates',
+ 'exciting changes',
+ 'package updates',
+ 'awesome updates',
+ 'bug fixes and features',
+ 'updates',
+];
const verbs = [
'just went out!',
'just launched!',
@@ -47,7 +56,9 @@ const plurals = new Map([
]);
function pluralize(text) {
- return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) => (plurals.has(match) ? plurals.get(match) : `${match}s`));
+ return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) =>
+ plurals.has(match) ? plurals.get(match) : `${match}s`
+ );
}
function singularlize(text) {
@@ -57,7 +68,9 @@ function singularlize(text) {
const packageMap = new Map();
async function generatePackageMap() {
const packageRoot = new URL('../../packages/', import.meta.url);
- const packages = await glob(['*/package.json', '*/*/package.json'], { cwd: fileURLToPath(packageRoot) });
+ const packages = await glob(['*/package.json', '*/*/package.json'], {
+ cwd: fileURLToPath(packageRoot),
+ });
await Promise.all(
packages.map(async (pkg) => {
const pkgFile = fileURLToPath(new URL(pkg, packageRoot));
@@ -77,7 +90,11 @@ async function run() {
if (!p) {
throw new Error(`Unable to find entrypoint for "${name}"!`);
}
- return { name, version, url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString() };
+ return {
+ name,
+ version,
+ url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString(),
+ };
})
);
@@ -87,7 +104,9 @@ async function run() {
if (packages.length === 1) {
const { name, version, url } = packages[0];
- console.log(`${emoji} \`${name}@${version}\` ${singularlize(verb)}\nRead the [release notes →](<${url}>)`);
+ console.log(
+ `${emoji} \`${name}@${version}\` ${singularlize(verb)}\nRead the [release notes →](<${url}>)`
+ );
} else {
console.log(`${emoji} Some ${descriptor} ${pluralize(verb)}\n`);
for (const { name, version, url } of packages) {
diff --git a/scripts/stats/index.js b/scripts/stats/index.js
index 435bb5c56..659df2f2b 100644
--- a/scripts/stats/index.js
+++ b/scripts/stats/index.js
@@ -78,12 +78,21 @@ export async function run() {
per_page: 100,
since: twentyFourHoursAgo.toISOString(),
});
- const issuesLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && !iss.pull_request);
- const pullsLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && iss.pull_request);
+ const issuesLastTwentyFourHours = allIssuesLastTwentyFourHours.filter(
+ (iss) => new Date(iss.created_at) > twentyFourHoursAgo && !iss.pull_request
+ );
+ const pullsLastTwentyFourHours = allIssuesLastTwentyFourHours.filter(
+ (iss) => new Date(iss.created_at) > twentyFourHoursAgo && iss.pull_request
+ );
const entry = [
// Date (Human Readable)
- `"${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}"`,
+ `"${new Date().toLocaleDateString('en-US', {
+ weekday: 'long',
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ })}"`,
// Commits in last 24 hours
(await countCommits(twentyFourHoursAgo)).length,
// New Issues(All) in last 24 hours
@@ -103,7 +112,8 @@ export async function run() {
// Bugs: Needs Triage
(await countCards(COLUMN_ID_BUGS_NEEDS_TRIAGE)).length,
// Bugs: Accepted
- (await countCards(COLUMN_ID_BUGS_ACCEPTED)).length + (await countCards(COLUMN_ID_BUGS_PRIORITIZED)).length,
+ (await countCards(COLUMN_ID_BUGS_ACCEPTED)).length +
+ (await countCards(COLUMN_ID_BUGS_PRIORITIZED)).length,
// RFC: In Progress
0, // (await countCards(COLUMN_ID_RFCS_IN_PROGRESS)).length,
// RFC: Accepted
diff --git a/scripts/utils/svelte-plugin.js b/scripts/utils/svelte-plugin.js
index 29e60c2d5..4bbd8cdaf 100644
--- a/scripts/utils/svelte-plugin.js
+++ b/scripts/utils/svelte-plugin.js
@@ -26,7 +26,12 @@ const handleLoad = async (args, generate, { isDev }) => {
let { js, warnings } = compile(source, { ...compileOptions, filename });
let contents = js.code + `\n//# sourceMappingURL=` + js.map.toUrl();
- return { loader: 'js', contents, resolveDir: dirname(path), warnings: warnings.map((w) => convertMessage(w)) };
+ return {
+ loader: 'js',
+ contents,
+ resolveDir: dirname(path),
+ warnings: warnings.map((w) => convertMessage(w)),
+ };
} catch (e) {
return { errors: [convertMessage(e)] };
}
@@ -54,8 +59,12 @@ export default function sveltePlugin({ isDev = false }) {
};
}
});
- build.onLoad({ filter: /.*/, namespace: 'svelte:client' }, (args) => handleLoad(args, 'dom', { isDev }));
- build.onLoad({ filter: /.*/, namespace: 'svelte:server' }, (args) => handleLoad(args, 'ssr', { isDev }));
+ build.onLoad({ filter: /.*/, namespace: 'svelte:client' }, (args) =>
+ handleLoad(args, 'dom', { isDev })
+ );
+ build.onLoad({ filter: /.*/, namespace: 'svelte:server' }, (args) =>
+ handleLoad(args, 'ssr', { isDev })
+ );
},
};
}