MCPcopy Index your code
hub / github.com/QwikDev/qwik / validateBuild

Function validateBuild

scripts/validate-build.ts:15–147  ·  view source on GitHub ↗
(config: BuildConfig)

Source from the content-addressed store, hash-verified

13 * build files to npm.
14 */
15export async function validateBuild(config: BuildConfig) {
16 console.log('🕵️ validating build...');
17 const pkgPath = join(config.distQwikPkgDir, 'package.json');
18 const pkg: PackageJSON = JSON.parse(await readFile(pkgPath, 'utf-8'));
19 const errors: string[] = [];
20 const require = createRequire(import.meta.url);
21
22 // triple checks these package files all exist and parse
23 const pkgFiles = [...pkg.files!, 'LICENSE', 'README.md', 'package.json'];
24 const expectedFiles = pkgFiles.map((f) => join(config.distQwikPkgDir, f));
25
26 const dependencies = ['csstype', 'vite'];
27 const pkgDependencies = Object.keys(pkg.dependencies!);
28 if (pkgDependencies.length !== dependencies.length) {
29 errors.push(
30 `Expected ${dependencies.length} dependencies, but found ${pkgDependencies.length}.`
31 );
32 } else {
33 for (const dep of dependencies) {
34 if (!pkgDependencies.includes(dep)) {
35 errors.push(`Expected ${dep} to be a dependency.`);
36 }
37 }
38 }
39
40 for (const filePath of expectedFiles) {
41 try {
42 // loop through each file and ensure it's built correct
43 const ext = extname(filePath);
44
45 switch (ext) {
46 case '.cjs':
47 const f = basename(filePath);
48 if (f !== 'qwik.cjs') {
49 require(filePath);
50 console.log(`✅ ${filePath}`);
51 }
52 break;
53 case '.mjs':
54 if (config.esmNode) {
55 await import(pathToFileURL(filePath).href);
56 console.log(`✅ ${filePath}`);
57 break;
58 }
59 case '.ts':
60 validateTypeScriptFile(config, filePath);
61 console.log(`✅ ${filePath}`);
62 break;
63 case '.json':
64 JSON.parse(readFileSync(filePath, 'utf-8'));
65 console.log(`✅ ${filePath}`);
66 break;
67 case '.map':
68 JSON.parse(readFileSync(filePath, 'utf-8'));
69 console.log(`✅ ${filePath}`);
70 break;
71 default:
72 if (existsSync(filePath)) {

Callers 2

publishFunction · 0.90
buildFunction · 0.90

Calls 12

readFileFunction · 0.90
panicFunction · 0.90
joinFunction · 0.85
extnameFunction · 0.85
requireFunction · 0.85
validateTypeScriptFileFunction · 0.85
validatePackageJsonFunction · 0.85
validateModuleTreeshakeFunction · 0.85
getFilesFunction · 0.70
parseMethod · 0.65
joinMethod · 0.65
basenameFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…