diff --git a/scripts/generate-phab-tag-removal-script.js b/scripts/generate-phab-tag-removal-script.js index b83bf63bf..0d215ef44 100755 --- a/scripts/generate-phab-tag-removal-script.js +++ b/scripts/generate-phab-tag-removal-script.js @@ -1,70 +1,70 @@ -// @flow +/* eslint-disable flowtype/require-valid-file-annotation */ const { execSync } = require('child_process'); const fs = require('fs'); const { request } = require('gaxios'); const PHABRICATOR_API_TOKEN = process.env.PHABRICATOR_API_TOKEN; if (!PHABRICATOR_API_TOKEN) { console.log('ERROR: Unable to retrieve PHABRICATOR_API_TOKEN.'); process.exit(1); } const getDifferentialDataFromPhabricator = async () => { return await request({ url: 'https://phab.comm.dev/api/differential.query', params: { 'api.token': PHABRICATOR_API_TOKEN, }, }); }; const getRevisionsToBeRemoved = differentialData => { const revisionsToBeRemoved = []; for (const diff of differentialData.data['result']) { if ( diff['statusName'] === 'Abandonded' || diff['statusName'] === 'Closed' ) { revisionsToBeRemoved.push(...diff['diffs']); } } return revisionsToBeRemoved; }; const getRemoteGitTags = () => { const remoteGitTags = execSync('git tag'); return new Set(remoteGitTags.toString().split('\n')); }; const getGitTagsToBeRemoved = (remoteGitTags, revisionsToBeRemoved) => { const gitTagsToBeRemoved = []; for (const revisionID of revisionsToBeRemoved) { gitTagsToBeRemoved.push(`phabricator/base/${revisionID}`); gitTagsToBeRemoved.push(`phabricator/diff/${revisionID}`); } return gitTagsToBeRemoved.filter(tag => remoteGitTags.has(tag)); }; const getGitCommandsToBeRun = gitTagsToBeRemoved => { return gitTagsToBeRemoved.map(tag => `git push --delete origin tag ${tag}`); }; const writeGitCommandsScriptToDisk = gitCommandsToBeRun => { fs.writeFileSync('tag_removal_script.sh', gitCommandsToBeRun.join('\n')); }; async function main() { const differentialData = await getDifferentialDataFromPhabricator(); const remoteGitTags = getRemoteGitTags(); const revisionsToBeRemoved = getRevisionsToBeRemoved(differentialData); const gitTagsToBeRemoved = getGitTagsToBeRemoved( remoteGitTags, revisionsToBeRemoved, ); const gitCommandsToBeRun = getGitCommandsToBeRun(gitTagsToBeRemoved); writeGitCommandsScriptToDisk(gitCommandsToBeRun); process.exit(0); } main(); diff --git a/scripts/get-cargo-path.js b/scripts/get-cargo-path.js index 11f6e694d..9294621e9 100644 --- a/scripts/get-cargo-path.js +++ b/scripts/get-cargo-path.js @@ -1,12 +1,12 @@ -// @flow +/* eslint-disable flowtype/require-valid-file-annotation */ const findUp = require('find-up'); // finds the path to the parent directory containing a Cargo.toml file for the // given path. Returns null if no Cargo.toml file is found. function findRustProjectPath(path) { const cargoTomlPath = findUp.sync('Cargo.toml', { cwd: path }); return cargoTomlPath ? cargoTomlPath.replace('/Cargo.toml', '') : null; } module.exports = { findRustProjectPath }; diff --git a/scripts/get-clang-paths-cli.js b/scripts/get-clang-paths-cli.js index 5d51afb8b..81225ccf7 100644 --- a/scripts/get-clang-paths-cli.js +++ b/scripts/get-clang-paths-cli.js @@ -1,20 +1,20 @@ -// @flow +/* eslint-disable flowtype/require-valid-file-annotation */ const { clangPaths } = require('./get-clang-paths.js'); (() => { let command = '('; clangPaths.forEach(pathItem => { const { path, extensions, excludes } = pathItem; command += `find ${path} `; command += extensions .map(extension => `-name '*.${extension}' `) .join('-o '); if (excludes) { command += `| grep -v '${excludes.map(exclude => exclude).join('\\|')}'`; } command += '; '; }); command += ')'; console.log(command); })(); diff --git a/scripts/get-clang-paths.js b/scripts/get-clang-paths.js index badff86da..f32b17c0c 100644 --- a/scripts/get-clang-paths.js +++ b/scripts/get-clang-paths.js @@ -1,45 +1,45 @@ -// @flow +/* eslint-disable flowtype/require-valid-file-annotation */ const clangPaths = [ { path: 'native/cpp/CommonCpp', extensions: ['h', 'cpp'], excludes: ['_generated'], }, { path: 'native/android/app/src/cpp', extensions: ['cpp', 'h'], }, { path: 'native/ios/Comm', extensions: ['h', 'm', 'mm'], }, { path: 'native/ios/CommTests', extensions: ['mm'], }, { path: 'native/ios/NotificationService', extensions: ['h', 'm', 'mm'], }, { path: 'native/android/app/src/main/java/app/comm', extensions: ['java'], excludes: ['generated'], }, { path: 'native/native_rust_library', extensions: ['cpp', 'h'], excludes: ['target', 'lib.rs.h', 'cxx.h'], }, { path: 'web/cpp', extensions: ['cpp', 'h'], }, ]; function getClangPaths() { return clangPaths.map(pathItem => pathItem.path); } module.exports = { getClangPaths, clangPaths };