mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 17:27:22 +08:00
In a follow-up CL we will be porting the license header check to ESLint. This allows us to add missing license headers for TypeScript-authored files. The script found some missing license headers already, which this CL adds. Change-Id: Id5041813281d2a7151297f9ed29baabc1cfd85af Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2097991 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const utils = require('../utils');
|
|
|
|
const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end');
|
|
|
|
const modules = [];
|
|
for (const dir of fs.readdirSync(FRONTEND_PATH)) {
|
|
if (!utils.isDir(path.resolve(FRONTEND_PATH, dir))) {
|
|
continue;
|
|
}
|
|
if (utils.isFile(path.resolve(FRONTEND_PATH, dir, 'module.json'))) {
|
|
modules.push(dir);
|
|
}
|
|
}
|
|
|
|
const Ajv = require('ajv');
|
|
const ajv = new Ajv({schemaId: 'id'});
|
|
// This seems to be the most widely supported version of the schema.
|
|
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
|
|
const schema = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'module.schema.json')));
|
|
const validate = ajv.compile(schema);
|
|
|
|
let totalErrors = 0;
|
|
for (const module of modules) {
|
|
const moduleObject = JSON.parse(fs.readFileSync(path.resolve(FRONTEND_PATH, module, 'module.json')));
|
|
const valid = validate(moduleObject);
|
|
if (!valid) {
|
|
console.log('Issue with ./front_end/' + module + '/module.json:');
|
|
totalErrors++;
|
|
validate.errors.sort((a, b) => b.dataPath.length - a.dataPath.length);
|
|
const error = validate.errors[0];
|
|
console.log(' ', error.dataPath, error.message, error.params);
|
|
console.log('');
|
|
}
|
|
}
|
|
if (totalErrors) {
|
|
console.log('module.json errors:', totalErrors);
|
|
}
|
|
process.exit(totalErrors);
|