mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
f76038ac7d
* feat: add @astrojs/telemetry * feat: add telemetry events, add queueing system * feat(telemetry): record CLI events * chore: add note * feat: support generic TELEMETRY_DISABLED env var * Fix test script * shim telemetry in tests * Shim telemetry in other commands * Stub telemetry in the memory leak test * Disable telemetry in smoke tests * Adds a changeset * Run the formatter * few updates * Include config keys * Add shallow viteKeys array: : * Add vite keys and tests Co-authored-by: Nate Moore <nate@skypack.dev>
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
/** @file Runs all smoke tests and may add extra smoke-test dependencies to `pnpm-lock.yaml`. */
|
|
|
|
// @ts-check
|
|
|
|
import { execa } from 'execa';
|
|
import { polyfill } from '@astrojs/webapi';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { promises as fs } from 'node:fs';
|
|
|
|
polyfill(globalThis, { exclude: 'window document' });
|
|
|
|
/** URL directory containing the entire project. */
|
|
const rootDir = new URL('../../', import.meta.url);
|
|
|
|
/** URL directory containing the example subdirectories. */
|
|
const exampleDir = new URL('examples/', rootDir);
|
|
const smokeDir = new URL('smoke/', rootDir);
|
|
|
|
/** Returns all child directories of the given directory. */
|
|
const getChildDirectories = async (/** @type {URL} */ dir) => {
|
|
/** @type {URL[]} */
|
|
const dirs = [];
|
|
|
|
for await (const dirent of await fs.opendir(dir)) {
|
|
if (dirent.isDirectory()) {
|
|
dirs.push(new URL(dirent.name, dir));
|
|
}
|
|
}
|
|
|
|
return dirs;
|
|
};
|
|
|
|
/** Runs all smoke tests. */
|
|
async function run() {
|
|
console.log('');
|
|
|
|
const directories = [...(await getChildDirectories(smokeDir)), ...(await getChildDirectories(exampleDir))];
|
|
|
|
console.log('🤖', 'Preparing', 'pnpm');
|
|
|
|
await execa('pnpm', ['install', '--frozen-lockfile=false'], { cwd: fileURLToPath(rootDir), stdio: 'inherit' });
|
|
|
|
for (const directory of directories) {
|
|
const name = directory.pathname.split('/').at(-1) ?? "";
|
|
const isExternal = directory.pathname.includes(smokeDir.pathname);
|
|
console.log('🤖', 'Testing', name);
|
|
|
|
try {
|
|
await execa('pnpm', ['install', '--ignore-scripts', '--frozen-lockfile=false', isExternal ? '--shamefully-hoist' : ''].filter(x => x), { cwd: fileURLToPath(directory), stdio: 'inherit' });
|
|
await execa('pnpm', ['astro', 'telemetry', 'disable']);
|
|
await execa('pnpm', ['run', 'build'], { cwd: fileURLToPath(directory), stdio: 'inherit' });
|
|
} catch (err) {
|
|
console.log(err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
run();
|