diff --git a/package.json b/package.json index d8b2e1ee385b5a..d1e8aeb638c086 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,13 @@ "buildci": "lage build test lint type-check --verbose", "builddemo": "yarn build --to public-docsite-resources", "buildto": "lage build --verbose --to", - "buildto:lerna": "node ./scripts/monorepo/src/buildTo.js", + "buildto:lerna": "node ./scripts/executors/buildTo.js", "bundle": "lage bundle --verbose", "bundlesizecollect": "node ./scripts/generators/bundle-size-collect", "change": "beachball change --no-commit", "check:change": "beachball check", "check:modified-files": "node -r ./scripts/ts-node/register ./scripts/executors/check-for-modified-files", - "check:affected-package": "node ./scripts/monorepo/src/checkIfPackagesAffected.js", + "check:affected-package": "node ./scripts/executors/checkIfPackagesAffected.js", "check:installed-dependencies-versions": "satisfied --skip-invalid --ignore \"prettier|angular|lit|sass|@storybook/html|@storybook/mdx2-csf|svelte|@testing-library|vue|@cypress/react|cypress|@swc/wasm|@cactuslab/usepubsub|react-vis|@microsoft/load-themed-styles\"", "clean": "lage clean --verbose", "code-style": "lage code-style --verbose", @@ -50,8 +50,8 @@ "release:fluentui:patch": "node -r ./scripts/ts-node/register ./scripts/fluentui-publish publish-patch", "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/monorepo/src/runPublished.js", - "runto:lerna": "node ./scripts/monorepo/src/runTo.js", + "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 new file mode 100644 index 00000000000000..2f256d756f8efe --- /dev/null +++ b/scripts/executors/buildTo.js @@ -0,0 +1,31 @@ +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/monorepo/src/checkIfPackagesAffected.js b/scripts/executors/checkIfPackagesAffected.js similarity index 75% rename from scripts/monorepo/src/checkIfPackagesAffected.js rename to scripts/executors/checkIfPackagesAffected.js index e63bab7ca0937b..da03b35904499b 100644 --- a/scripts/monorepo/src/checkIfPackagesAffected.js +++ b/scripts/executors/checkIfPackagesAffected.js @@ -1,5 +1,4 @@ -const getAffectedPackages = require('./getAffectedPackages'); -const getNthCommit = require('./getNthCommit'); +const { getAffectedPackages, getNthCommit } = require('@fluentui/scripts-monorepo'); const yargs = require('yargs'); const args = yargs @@ -39,8 +38,12 @@ const isPackageAffected = () => { return false; }; -/** - * In order for pipeline to capture and save the return value from a node script, - * the output needs to be printed. - */ -console.log(isPackageAffected()); +function main() { + /** + * In order for pipeline to capture and save the return value from a node script, + * the output needs to be printed. + */ + console.log(isPackageAffected()); +} + +main(); diff --git a/scripts/monorepo/src/runPublished.js b/scripts/executors/runPublished.js similarity index 96% rename from scripts/monorepo/src/runPublished.js rename to scripts/executors/runPublished.js index 85db66b439aa56..ebf1cb492509fe 100644 --- a/scripts/monorepo/src/runPublished.js +++ b/scripts/executors/runPublished.js @@ -1,6 +1,6 @@ const { spawnSync } = require('child_process'); -const getAllPackageInfo = require('./getAllPackageInfo'); -const isConvergedPackage = require('./isConvergedPackage'); + +const { getAllPackageInfo, isConvergedPackage } = require('@fluentui/scripts-monorepo'); const lageBin = require.resolve('lage/bin/lage.js'); /** diff --git a/scripts/monorepo/src/runPublished.spec.ts b/scripts/executors/runPublished.spec.ts similarity index 100% rename from scripts/monorepo/src/runPublished.spec.ts rename to scripts/executors/runPublished.spec.ts diff --git a/scripts/monorepo/src/runTo.js b/scripts/executors/runTo.js similarity index 91% rename from scripts/monorepo/src/runTo.js rename to scripts/executors/runTo.js index 7c130a8f2501a5..87314390da8b22 100644 --- a/scripts/monorepo/src/runTo.js +++ b/scripts/executors/runTo.js @@ -1,37 +1,16 @@ const { spawnSync } = require('child_process'); const lernaBin = require.resolve('lerna/cli.js'); -const getAllPackageInfo = require('./getAllPackageInfo'); const os = require('os'); -const argv = process.argv.slice(2); +const { getAllPackageInfo } = require('@fluentui/scripts-monorepo'); -if (require.main === module) { - // Display a usage message when there are no projects specified - if (argv.length < 2) { - console.log(`Usage: - - yarn runto