From 414379b5fa2ca3ea00d57bedc328a3b66fe3b021 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Wed, 3 Jan 2024 12:10:48 +0100 Subject: [PATCH 1/5] chore(srcipts-executors): remove scripts that use lerna to run task which are redundant and replaced by nx --- package.json | 3 -- scripts/executors/buildTo.js | 31 ----------- scripts/executors/runTo.js | 101 ----------------------------------- 3 files changed, 135 deletions(-) delete mode 100644 scripts/executors/buildTo.js delete mode 100644 scripts/executors/runTo.js diff --git a/package.json b/package.json index 057639a2066a11..e3e68660a761a9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "buildci": "lage build test lint type-check test-ssr verify-packaging --verbose", "builddemo": "yarn build --to public-docsite-resources", "buildto": "lage build --verbose --to", - "buildto:lerna": "node ./scripts/executors/buildTo.js", "bundle": "lage bundle --verbose", "change": "beachball change --no-commit", "check:change": "beachball check", @@ -36,7 +35,6 @@ "generate-version-files": "node -r ./scripts/ts-node/register ./scripts/generators/generate-version-files", "lint": "lage lint --verbose", "lint:log": "FORCE_COLOR=0 yarn lint > lint.log 2>&1", - "lint:log:lerna": "FORCE_COLOR=0 lerna run lint --stream --no-bail > lint.log 2>&1", "perf": "yarn workspace @fluentui/perf perf:test", "perf:debug": "yarn workspace @fluentui/perf perf:test:debug", "postinstall": "node ./scripts/package-manager/postinstall.js", @@ -50,7 +48,6 @@ "release:fluentui:post-validation": "node -r ./scripts/ts-node/register ./scripts/fluentui-publish post-publish", "rename-package": "node -r ./scripts/ts-node/register ./scripts/generators/rename-package.ts", "run:published": "node ./scripts/executors/runPublished.js", - "runto:lerna": "node ./scripts/executors/runTo.js", "scrub": "node ./scripts/executors/scrub.js", "start": "node ./scripts/executors/start.js", "start:northstar": "yarn workspace @fluentui/docs start", diff --git a/scripts/executors/buildTo.js b/scripts/executors/buildTo.js deleted file mode 100644 index 2f256d756f8efe..00000000000000 --- a/scripts/executors/buildTo.js +++ /dev/null @@ -1,31 +0,0 @@ -const { runTo } = require('./runTo'); - -const isExecutedFromCli = require.main === module; - -function main() { - const argv = process.argv.slice(2); - - // Display a usage message when there are no projects specified - if (argv.length < 1) { - console.log(`Usage: - - yarn buildto [ ...] [] - -This command builds all packages up to and including "packagename1" (and "packagename2" etc). -The package name can be a substring. -If multiple packages match a pattern, they will all be built (along with their dependencies). -`); - - process.exit(0); - } - - const restIndex = argv.findIndex(arg => arg.startsWith('--')); - const projects = restIndex === -1 ? argv : argv.slice(0, restIndex); - const rest = restIndex === -1 ? [] : argv.slice(argv[restIndex] === '--' ? restIndex + 1 : restIndex); - - runTo('build', projects, rest); -} - -if (isExecutedFromCli) { - main(); -} diff --git a/scripts/executors/runTo.js b/scripts/executors/runTo.js deleted file mode 100644 index 87314390da8b22..00000000000000 --- a/scripts/executors/runTo.js +++ /dev/null @@ -1,101 +0,0 @@ -const { spawnSync } = require('child_process'); -const lernaBin = require.resolve('lerna/cli.js'); -const os = require('os'); - -const { getAllPackageInfo } = require('@fluentui/scripts-monorepo'); - -const isExecutedFromCli = require.main === module; - -/** - * @param {string} script - Script to run - * @param {string[]} projects - Projects to run in - * @param {string[]} rest - Args to pass on - * @returns {void} - */ -function runTo(script, projects, rest) { - // This script matches substrings of the input for one more many projects - const allPackages = getAllPackageInfo(); - - const foundProjects = /** @type {string[]} */ ([]); - - for (const project of projects) { - if (allPackages[project]) { - foundProjects.push(project); - } else { - const packagesForProject = Object.keys(allPackages).filter(name => name.includes(project)); - if (packagesForProject.length === 0) { - console.log(`There is no project matching "${project}" in this repo`); - } else if (packagesForProject.length > 1) { - console.log(`More than one project matched: "${packagesForProject.join('", "')}"`); - } else { - console.log(`Found a matching project named "${packagesForProject[0]}"`); - } - foundProjects.push(...packagesForProject); - } - } - - /** - * @type {string[]} - */ - const scopes = []; - foundProjects.forEach(projectName => { - // --scope limits build to a specified package - scopes.push('--scope'); - scopes.push(projectName); - }); - - // --include-filtered-Dependencies makes the build include dependencies - // --stream allows the build to proceed in parallel but still in order - const result = spawnSync( - process.execPath, - [ - lernaBin, - 'run', - script, - ...scopes, - '--include-filtered-dependencies', // makes the build include dependencies - '--stream', // run in parallel but still in order - // Except when running in PR/CI, reduce concurrency so the computer is usable while building - ...(process.env.TF_BUILD ? [] : ['--concurrency=' + (os.cpus().length - 2)]), - '--', - ...rest, - ], - { - stdio: 'inherit', - }, - ); - - if (result.status !== 0) { - process.exit(result.status ?? undefined); - } -} - -function main() { - const argv = process.argv.slice(2); - // Display a usage message when there are no projects specified - if (argv.length < 2) { - console.log(`Usage: - - yarn runto