Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const packagesDir = path.join(repoRoot, "packages");
|
||||
const failures = [];
|
||||
|
||||
function walk(dir) {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
const files = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".vitest") {
|
||||
continue;
|
||||
}
|
||||
const absolutePath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
files.push(...walk(absolutePath));
|
||||
} else {
|
||||
files.push(absolutePath);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
for (const packageName of fs.readdirSync(packagesDir).sort()) {
|
||||
const packageDir = path.join(packagesDir, packageName);
|
||||
const packageJsonPath = path.join(packageDir, "package.json");
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const hasTests = walk(packageDir).some((filePath) => /\.(?:test|spec)\.[cm]?[tj]sx?$/.test(filePath));
|
||||
if (!hasTests) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
if (typeof packageJson.scripts?.test !== "string" || packageJson.scripts.test.trim().length === 0) {
|
||||
failures.push(`${path.relative(repoRoot, packageJsonPath)} has test files but no scripts.test`);
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
process.stderr.write(`FAIL package test script verification\n${failures.map((failure) => `- ${failure}`).join("\n")}\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.stdout.write("PASS package test script verification\n");
|
||||
Reference in new issue
Block a user