Files
react-native-devtools-frontend/scripts/check_esbuild_versions.js
T
Alex Rudenko 2e05f8f1b9 Move devDependencies to package.json
it gives the following benefits:

- go/sk-npm-audit-mirror can perform periodic audits for repo
and auto-file bugs.
- Dev dependencies are declared in a typical location for npm projects.
- allows simplifying manage_node_deps.py the installation by running one `npm install` instead of installing packages one by one.

Bug: chromium:331331303
Change-Id: I7a5486acb89e174be5277c7696cb287a668d2ed7
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5423233
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
2024-04-05 06:22:21 +00:00

52 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
// Copyright 2022 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.
'use strict';
const path = require('path');
const fs = require('fs');
const {
devtoolsRootPath,
} = require('./devtools_paths.js');
function bail(message) {
console.error(message);
process.exit(1);
}
function findVersionFromDepsFile() {
const filePath = path.join(devtoolsRootPath(), 'DEPS');
const contents = fs.readFileSync(filePath, 'utf8').split('\n');
const esbuildPackageLine = contents.findIndex(line => line.match(/infra\/3pp\/tools\/esbuild/));
if (esbuildPackageLine === -1) {
bail('Could not find ESBuild within DEPS file.');
}
const esbuildVersionLine = contents[esbuildPackageLine + 1];
const result = /@(\d{1,2}\.\d{1,2}\.\d{1,2})/.exec(esbuildVersionLine)?.[1];
if (!result) {
bail('Could not parse out ESBuild version from DEPS');
}
return result;
}
function findVersionFromPackageJsonFile() {
const filePath = path.join(devtoolsRootPath(), 'package.json');
const contents = fs.readFileSync(filePath, 'utf8');
const result = /"esbuild": "([0-9\.]+)"/.exec(contents)?.[1];
if (!result) {
bail('Could not parse out ESBuild version from package.json');
}
return result;
}
const nodeDepsVersion = findVersionFromPackageJsonFile();
const depsVersion = findVersionFromDepsFile();
if (nodeDepsVersion !== depsVersion) {
bail(`Found mismatching esbuild versions in DEPS vs package.json:
package.json: ${nodeDepsVersion}
DEPS: ${depsVersion}\n`);
}