diff --git a/scripts/run-registry.ts b/scripts/run-registry.ts index 6735e9811a0b..9184e885b4d6 100755 --- a/scripts/run-registry.ts +++ b/scripts/run-registry.ts @@ -9,7 +9,7 @@ import pLimit from 'p-limit'; import type { Server } from 'http'; import { mkdir } from 'fs/promises'; import { PACKS_DIRECTORY } from './utils/constants'; -// @ts-expect-error (Converted from ts-ignore) + import { maxConcurrentTasks } from './utils/concurrency'; import { listOfPackages } from './utils/list-packages'; diff --git a/scripts/utils/concurrency.js b/scripts/utils/concurrency.js deleted file mode 100644 index 6745f3649014..000000000000 --- a/scripts/utils/concurrency.js +++ /dev/null @@ -1,27 +0,0 @@ -const os = require('os'); - -/** - * The maximum number of concurrent tasks we want to have on some CLI and CI tasks. - * The amount of CPUS minus one, arbitrary limited to 15 to not overload CI executors. - * @type {number} - */ -const maxConcurrentTasks = Math.min(Math.max(1, os.cpus().length - 1), 15); - -/** - * Use a simple round robin to filter input data according to the CI node currently running the script - * @param {Array} arrayOfData An array of anything you want - * @returns {Array} An array containing only the data that shoud be used by current CI node. - */ -function filterDataForCurrentCircleCINode(arrayOfData) { - const nodeIndex = +process.env.CIRCLE_NODE_INDEX || 0; - const numberOfNodes = +process.env.CIRCLE_NODE_TOTAL || 1; - - return arrayOfData.filter((_, index) => { - return index % numberOfNodes === nodeIndex; - }); -} - -module.exports = { - maxConcurrentTasks, - filterDataForCurrentCircleCINode, -}; diff --git a/scripts/utils/concurrency.ts b/scripts/utils/concurrency.ts new file mode 100644 index 000000000000..ab49dc41e8f5 --- /dev/null +++ b/scripts/utils/concurrency.ts @@ -0,0 +1,9 @@ +const os = require('os'); + +/** + * The maximum number of concurrent tasks we want to have on some CLI and CI tasks. + * The amount of CPUS minus one, arbitrary limited to 15 to not overload CI executors. + * @type {number} + */ +export const maxConcurrentTasks = Math.min(Math.max(1, os.cpus().length - 1), 15); +