2023-12-14 11:48:22 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as fs from 'node:fs/promises';
|
|
|
|
import {dirname} from 'path';
|
|
|
|
import {fileURLToPath} from 'url';
|
|
|
|
import signedsource from 'signedsource';
|
2024-06-26 01:24:08 -07:00
|
|
|
import {glob} from 'glob';
|
2023-12-14 11:48:22 -08:00
|
|
|
|
2024-06-26 01:24:08 -07:00
|
|
|
const yogaRootDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
2023-12-14 11:48:22 -08:00
|
|
|
|
2024-06-26 01:24:08 -07:00
|
|
|
const filesToValidate = await glob(
|
|
|
|
[
|
|
|
|
'tests/generated/**/*.{h,cpp}',
|
|
|
|
'javascript/tests/generated/**/*.test.ts',
|
|
|
|
'java/tests/com/facebook/yoga/**/*.java',
|
|
|
|
],
|
|
|
|
{
|
|
|
|
cwd: yogaRootDir,
|
|
|
|
},
|
|
|
|
);
|
2023-12-14 11:48:22 -08:00
|
|
|
|
2024-06-26 01:24:08 -07:00
|
|
|
console.log(`Found ${filesToValidate.length} files to validate`);
|
|
|
|
|
|
|
|
for (const file of filesToValidate) {
|
|
|
|
const content = await fs.readFile(`${yogaRootDir}/${file}`, 'utf8');
|
|
|
|
if (signedsource.isSigned(content)) {
|
|
|
|
console.log(`Checking ${file}`);
|
|
|
|
const validSignature = signedsource.verifySignature(content);
|
|
|
|
if (!validSignature) {
|
|
|
|
console.error(`Invalid signature "${file}"`);
|
|
|
|
process.exitCode = 1;
|
2023-12-14 11:48:22 -08:00
|
|
|
}
|
2024-06-26 01:24:08 -07:00
|
|
|
} else {
|
|
|
|
console.log(`Skipped ${file}`);
|
2023-12-14 11:48:22 -08:00
|
|
|
}
|
|
|
|
}
|