2022-03-08 16:46:11 -05:00
|
|
|
/** @file Remove all smoke tests and may remove extra smoke-test dependencies from `pnpm-lock.yaml`. */
|
2022-02-15 10:51:12 -05:00
|
|
|
|
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
import { execa } from 'execa';
|
|
|
|
import { promises as fs } from 'node:fs';
|
2023-07-27 11:24:39 -05:00
|
|
|
import { fileURLToPath } from 'node:url';
|
2022-02-15 10:51:12 -05:00
|
|
|
|
|
|
|
/* Configuration
|
|
|
|
/* ========================================================================== */
|
|
|
|
|
|
|
|
/** URL directory containing this current script. */
|
|
|
|
const scriptDir = new URL('./', import.meta.url);
|
|
|
|
|
|
|
|
/** URL directory containing the entire project. */
|
|
|
|
const rootDir = new URL('../../', import.meta.url);
|
|
|
|
|
|
|
|
/* Application
|
|
|
|
/* ========================================================================== */
|
|
|
|
|
|
|
|
/** Runs all smoke tests. */
|
|
|
|
async function run() {
|
2022-02-15 10:52:31 -05:00
|
|
|
const dirs = await getChildDirectories(scriptDir);
|
2022-02-15 10:51:12 -05:00
|
|
|
|
|
|
|
if (dirs.length) {
|
2022-02-15 10:52:31 -05:00
|
|
|
console.log();
|
2022-02-15 10:51:12 -05:00
|
|
|
|
|
|
|
for (const dir of await getChildDirectories(scriptDir)) {
|
|
|
|
console.log('🤖', 'Removing', dir.pathname.split('/').at(-1));
|
|
|
|
|
2022-02-15 10:52:31 -05:00
|
|
|
fs.rm(dir, { force: true, recursive: true });
|
2022-02-15 10:51:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 10:52:31 -05:00
|
|
|
console.log();
|
2022-02-15 10:51:12 -05:00
|
|
|
|
2022-03-08 16:46:11 -05:00
|
|
|
console.log('🤖', 'Resetting', 'pnpm');
|
2022-02-15 10:51:12 -05:00
|
|
|
|
2022-03-08 16:46:11 -05:00
|
|
|
await execa('pnpm', ['install'], { cwd: fileURLToPath(rootDir), stdout: 'inherit', stderr: 'inherit' });
|
2022-02-15 10:51:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Functionality
|
|
|
|
/* ========================================================================== */
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Execution
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
run();
|