@backstage/cli-node
Advanced tools
| 'use strict'; | ||
| var os = require('node:os'); | ||
| function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } | ||
| var os__default = /*#__PURE__*/_interopDefaultCompat(os); | ||
| const defaultConcurrency = Math.max(Math.ceil(os__default.default.cpus().length / 2), 1); | ||
| const CONCURRENCY_ENV_VAR = "BACKSTAGE_CLI_CONCURRENCY"; | ||
| const DEPRECATED_CONCURRENCY_ENV_VAR = "BACKSTAGE_CLI_BUILD_PARALLEL"; | ||
| function parseConcurrencyOption(value) { | ||
| if (value === void 0 || value === null) { | ||
| return defaultConcurrency; | ||
| } else if (typeof value === "boolean") { | ||
| return value ? defaultConcurrency : 1; | ||
| } else if (typeof value === "number" && Number.isInteger(value)) { | ||
| if (value < 1) { | ||
| return 1; | ||
| } | ||
| return value; | ||
| } else if (typeof value === "string") { | ||
| if (value === "true") { | ||
| return parseConcurrencyOption(true); | ||
| } else if (value === "false") { | ||
| return parseConcurrencyOption(false); | ||
| } | ||
| const parsed = Number(value); | ||
| if (Number.isInteger(parsed)) { | ||
| return parseConcurrencyOption(parsed); | ||
| } | ||
| } | ||
| throw Error( | ||
| `Concurrency option value '${value}' is not a boolean or integer` | ||
| ); | ||
| } | ||
| let hasWarnedDeprecation = false; | ||
| function getEnvironmentConcurrency() { | ||
| if (process.env[CONCURRENCY_ENV_VAR] !== void 0) { | ||
| return parseConcurrencyOption(process.env[CONCURRENCY_ENV_VAR]); | ||
| } | ||
| if (process.env[DEPRECATED_CONCURRENCY_ENV_VAR] !== void 0) { | ||
| if (!hasWarnedDeprecation) { | ||
| hasWarnedDeprecation = true; | ||
| console.warn( | ||
| `The ${DEPRECATED_CONCURRENCY_ENV_VAR} environment variable is deprecated, use ${CONCURRENCY_ENV_VAR} instead` | ||
| ); | ||
| } | ||
| return parseConcurrencyOption(process.env[DEPRECATED_CONCURRENCY_ENV_VAR]); | ||
| } | ||
| return defaultConcurrency; | ||
| } | ||
| exports.getEnvironmentConcurrency = getEnvironmentConcurrency; | ||
| //# sourceMappingURL=concurrency.cjs.js.map |
| {"version":3,"file":"concurrency.cjs.js","sources":["../../src/concurrency/concurrency.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport os from 'node:os';\n\nconst defaultConcurrency = Math.max(Math.ceil(os.cpus().length / 2), 1);\n\nconst CONCURRENCY_ENV_VAR = 'BACKSTAGE_CLI_CONCURRENCY';\nconst DEPRECATED_CONCURRENCY_ENV_VAR = 'BACKSTAGE_CLI_BUILD_PARALLEL';\n\ntype ConcurrencyOption = boolean | string | number | null | undefined;\n\nfunction parseConcurrencyOption(value: ConcurrencyOption): number {\n if (value === undefined || value === null) {\n return defaultConcurrency;\n } else if (typeof value === 'boolean') {\n return value ? defaultConcurrency : 1;\n } else if (typeof value === 'number' && Number.isInteger(value)) {\n if (value < 1) {\n return 1;\n }\n return value;\n } else if (typeof value === 'string') {\n if (value === 'true') {\n return parseConcurrencyOption(true);\n } else if (value === 'false') {\n return parseConcurrencyOption(false);\n }\n const parsed = Number(value);\n if (Number.isInteger(parsed)) {\n return parseConcurrencyOption(parsed);\n }\n }\n\n throw Error(\n `Concurrency option value '${value}' is not a boolean or integer`,\n );\n}\n\nlet hasWarnedDeprecation = false;\n\n/** @internal */\nexport function getEnvironmentConcurrency() {\n if (process.env[CONCURRENCY_ENV_VAR] !== undefined) {\n return parseConcurrencyOption(process.env[CONCURRENCY_ENV_VAR]);\n }\n if (process.env[DEPRECATED_CONCURRENCY_ENV_VAR] !== undefined) {\n if (!hasWarnedDeprecation) {\n hasWarnedDeprecation = true;\n console.warn(\n `The ${DEPRECATED_CONCURRENCY_ENV_VAR} environment variable is deprecated, use ${CONCURRENCY_ENV_VAR} instead`,\n );\n }\n return parseConcurrencyOption(process.env[DEPRECATED_CONCURRENCY_ENV_VAR]);\n }\n return defaultConcurrency;\n}\n"],"names":["os"],"mappings":";;;;;;;;AAkBA,MAAM,kBAAA,GAAqB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,IAAA,CAAKA,mBAAA,CAAG,IAAA,EAAK,CAAE,MAAA,GAAS,CAAC,CAAA,EAAG,CAAC,CAAA;AAEtE,MAAM,mBAAA,GAAsB,2BAAA;AAC5B,MAAM,8BAAA,GAAiC,8BAAA;AAIvC,SAAS,uBAAuB,KAAA,EAAkC;AAChE,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,IAAA,EAAM;AACzC,IAAA,OAAO,kBAAA;AAAA,EACT,CAAA,MAAA,IAAW,OAAO,KAAA,KAAU,SAAA,EAAW;AACrC,IAAA,OAAO,QAAQ,kBAAA,GAAqB,CAAA;AAAA,EACtC,WAAW,OAAO,KAAA,KAAU,YAAY,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,EAAG;AAC/D,IAAA,IAAI,QAAQ,CAAA,EAAG;AACb,MAAA,OAAO,CAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,MAAA,IAAW,OAAO,KAAA,KAAU,QAAA,EAAU;AACpC,IAAA,IAAI,UAAU,MAAA,EAAQ;AACpB,MAAA,OAAO,uBAAuB,IAAI,CAAA;AAAA,IACpC,CAAA,MAAA,IAAW,UAAU,OAAA,EAAS;AAC5B,MAAA,OAAO,uBAAuB,KAAK,CAAA;AAAA,IACrC;AACA,IAAA,MAAM,MAAA,GAAS,OAAO,KAAK,CAAA;AAC3B,IAAA,IAAI,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA,EAAG;AAC5B,MAAA,OAAO,uBAAuB,MAAM,CAAA;AAAA,IACtC;AAAA,EACF;AAEA,EAAA,MAAM,KAAA;AAAA,IACJ,6BAA6B,KAAK,CAAA,6BAAA;AAAA,GACpC;AACF;AAEA,IAAI,oBAAA,GAAuB,KAAA;AAGpB,SAAS,yBAAA,GAA4B;AAC1C,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,mBAAmB,CAAA,KAAM,MAAA,EAAW;AAClD,IAAA,OAAO,sBAAA,CAAuB,OAAA,CAAQ,GAAA,CAAI,mBAAmB,CAAC,CAAA;AAAA,EAChE;AACA,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,8BAA8B,CAAA,KAAM,MAAA,EAAW;AAC7D,IAAA,IAAI,CAAC,oBAAA,EAAsB;AACzB,MAAA,oBAAA,GAAuB,IAAA;AACvB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,CAAA,IAAA,EAAO,8BAA8B,CAAA,yCAAA,EAA4C,mBAAmB,CAAA,QAAA;AAAA,OACtG;AAAA,IACF;AACA,IAAA,OAAO,sBAAA,CAAuB,OAAA,CAAQ,GAAA,CAAI,8BAA8B,CAAC,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,kBAAA;AACT;;;;"} |
| 'use strict'; | ||
| var concurrency = require('./concurrency.cjs.js'); | ||
| async function runConcurrentTasks(options) { | ||
| const { concurrencyFactor = 1, items, worker } = options; | ||
| const concurrency$1 = concurrency.getEnvironmentConcurrency(); | ||
| const sharedIterator = items[Symbol.iterator](); | ||
| const sharedIterable = { | ||
| [Symbol.iterator]: () => sharedIterator | ||
| }; | ||
| const workerCount = Math.max(Math.floor(concurrencyFactor * concurrency$1), 1); | ||
| await Promise.all( | ||
| Array(workerCount).fill(0).map(async () => { | ||
| for (const value of sharedIterable) { | ||
| await worker(value); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| exports.runConcurrentTasks = runConcurrentTasks; | ||
| //# sourceMappingURL=runConcurrentTasks.cjs.js.map |
| {"version":3,"file":"runConcurrentTasks.cjs.js","sources":["../../src/concurrency/runConcurrentTasks.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getEnvironmentConcurrency } from './concurrency';\n\n/**\n * Options for {@link runConcurrentTasks}.\n *\n * @public\n */\nexport type ConcurrentTasksOptions<TItem> = {\n /**\n * Decides the number of concurrent workers by multiplying\n * this with the configured concurrency.\n *\n * Defaults to 1.\n */\n concurrencyFactor?: number;\n items: Iterable<TItem>;\n worker: (item: TItem) => Promise<void>;\n};\n\n/**\n * Runs items through a worker function concurrently across multiple async workers.\n *\n * @public\n */\nexport async function runConcurrentTasks<TItem>(\n options: ConcurrentTasksOptions<TItem>,\n): Promise<void> {\n const { concurrencyFactor = 1, items, worker } = options;\n const concurrency = getEnvironmentConcurrency();\n\n const sharedIterator = items[Symbol.iterator]();\n const sharedIterable = {\n [Symbol.iterator]: () => sharedIterator,\n };\n\n const workerCount = Math.max(Math.floor(concurrencyFactor * concurrency), 1);\n await Promise.all(\n Array(workerCount)\n .fill(0)\n .map(async () => {\n for (const value of sharedIterable) {\n await worker(value);\n }\n }),\n );\n}\n"],"names":["concurrency","getEnvironmentConcurrency"],"mappings":";;;;AAwCA,eAAsB,mBACpB,OAAA,EACe;AACf,EAAA,MAAM,EAAE,iBAAA,GAAoB,CAAA,EAAG,KAAA,EAAO,QAAO,GAAI,OAAA;AACjD,EAAA,MAAMA,gBAAcC,qCAAA,EAA0B;AAE9C,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,MAAA,CAAO,QAAQ,CAAA,EAAE;AAC9C,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,CAAC,MAAA,CAAO,QAAQ,GAAG,MAAM;AAAA,GAC3B;AAEA,EAAA,MAAM,WAAA,GAAc,KAAK,GAAA,CAAI,IAAA,CAAK,MAAM,iBAAA,GAAoBD,aAAW,GAAG,CAAC,CAAA;AAC3E,EAAA,MAAM,OAAA,CAAQ,GAAA;AAAA,IACZ,MAAM,WAAW,CAAA,CACd,KAAK,CAAC,CAAA,CACN,IAAI,YAAY;AACf,MAAA,KAAA,MAAW,SAAS,cAAA,EAAgB;AAClC,QAAA,MAAM,OAAO,KAAK,CAAA;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,GACL;AACF;;;;"} |
| 'use strict'; | ||
| var node_worker_threads = require('node:worker_threads'); | ||
| var concurrency = require('./concurrency.cjs.js'); | ||
| async function runWorkerQueueThreads(options) { | ||
| const items = Array.from(options.items); | ||
| const workerFactory = options.workerFactory; | ||
| const workerData = options.context; | ||
| const threadCount = Math.min(concurrency.getEnvironmentConcurrency(), items.length); | ||
| const iterator = items[Symbol.iterator](); | ||
| const results = new Array(); | ||
| let itemIndex = 0; | ||
| await Promise.all( | ||
| Array(threadCount).fill(0).map(async () => { | ||
| const thread = new node_worker_threads.Worker(`(${workerQueueThread})(${workerFactory})`, { | ||
| eval: true, | ||
| workerData | ||
| }); | ||
| return new Promise((resolve, reject) => { | ||
| thread.on("message", (message) => { | ||
| if (message.type === "start" || message.type === "result") { | ||
| if (message.type === "result") { | ||
| results[message.index] = message.result; | ||
| } | ||
| const { value, done } = iterator.next(); | ||
| if (done) { | ||
| thread.postMessage({ type: "done" }); | ||
| } else { | ||
| thread.postMessage({ | ||
| type: "item", | ||
| index: itemIndex, | ||
| item: value | ||
| }); | ||
| itemIndex += 1; | ||
| } | ||
| } else if (message.type === "error") { | ||
| const error = new Error(message.error.message); | ||
| error.name = message.error.name; | ||
| error.stack = message.error.stack; | ||
| reject(error); | ||
| } | ||
| }); | ||
| thread.on("error", reject); | ||
| thread.on("exit", (code) => { | ||
| if (code !== 0) { | ||
| reject(new Error(`Worker thread exited with code ${code}`)); | ||
| } else { | ||
| resolve(); | ||
| } | ||
| }); | ||
| }); | ||
| }) | ||
| ); | ||
| return { results }; | ||
| } | ||
| function workerQueueThread(workerFuncFactory) { | ||
| const { parentPort, workerData } = require("node:worker_threads"); | ||
| Promise.resolve().then(() => workerFuncFactory(workerData)).then( | ||
| (workerFunc) => { | ||
| parentPort.on("message", async (message) => { | ||
| if (message.type === "done") { | ||
| parentPort.close(); | ||
| return; | ||
| } | ||
| if (message.type === "item") { | ||
| try { | ||
| const result = await workerFunc(message.item); | ||
| parentPort.postMessage({ | ||
| type: "result", | ||
| index: message.index, | ||
| result | ||
| }); | ||
| } catch (error) { | ||
| parentPort.postMessage({ type: "error", error }); | ||
| } | ||
| } | ||
| }); | ||
| parentPort.postMessage({ type: "start" }); | ||
| }, | ||
| (error) => parentPort.postMessage({ type: "error", error }) | ||
| ); | ||
| } | ||
| exports.runWorkerQueueThreads = runWorkerQueueThreads; | ||
| //# sourceMappingURL=runWorkerQueueThreads.cjs.js.map |
| {"version":3,"file":"runWorkerQueueThreads.cjs.js","sources":["../../src/concurrency/runWorkerQueueThreads.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorLike } from '@backstage/errors';\nimport { Worker } from 'node:worker_threads';\nimport { getEnvironmentConcurrency } from './concurrency';\n\ntype WorkerThreadMessage =\n | {\n type: 'done';\n }\n | {\n type: 'item';\n index: number;\n item: unknown;\n }\n | {\n type: 'start';\n }\n | {\n type: 'result';\n index: number;\n result: unknown;\n }\n | {\n type: 'error';\n error: ErrorLike;\n };\n\n/**\n * Options for {@link runWorkerQueueThreads}.\n *\n * @public\n */\nexport type WorkerQueueThreadsOptions<TItem, TResult, TContext> = {\n /** The items to process */\n items: Iterable<TItem>;\n /**\n * A function that will be called within each worker thread at startup,\n * which should return the worker function that will be called for each item.\n *\n * This function must be defined as an arrow function or using the\n * function keyword, and must be entirely self contained, not referencing\n * any variables outside of its scope. This is because the function source\n * is stringified and evaluated in the worker thread.\n *\n * To pass data to the worker, use the `context` option and `items`, but\n * note that they are both copied by value into the worker thread, except for\n * types that are explicitly shareable across threads, such as `SharedArrayBuffer`.\n */\n workerFactory: (\n context: TContext,\n ) =>\n | ((item: TItem) => Promise<TResult>)\n | Promise<(item: TItem) => Promise<TResult>>;\n /** Context data supplied to each worker factory */\n context?: TContext;\n};\n\n/**\n * Spawns one or more worker threads using the `worker_threads` module.\n * Each thread processes one item at a time from the provided `options.items`.\n *\n * @public\n */\nexport async function runWorkerQueueThreads<TItem, TResult, TContext>(\n options: WorkerQueueThreadsOptions<TItem, TResult, TContext>,\n): Promise<{ results: TResult[] }> {\n const items = Array.from(options.items);\n const workerFactory = options.workerFactory;\n const workerData = options.context;\n const threadCount = Math.min(getEnvironmentConcurrency(), items.length);\n\n const iterator = items[Symbol.iterator]();\n const results = new Array<TResult>();\n let itemIndex = 0;\n\n await Promise.all(\n Array(threadCount)\n .fill(0)\n .map(async () => {\n const thread = new Worker(`(${workerQueueThread})(${workerFactory})`, {\n eval: true,\n workerData,\n });\n\n return new Promise<void>((resolve, reject) => {\n thread.on('message', (message: WorkerThreadMessage) => {\n if (message.type === 'start' || message.type === 'result') {\n if (message.type === 'result') {\n results[message.index] = message.result as TResult;\n }\n const { value, done } = iterator.next();\n if (done) {\n thread.postMessage({ type: 'done' });\n } else {\n thread.postMessage({\n type: 'item',\n index: itemIndex,\n item: value,\n });\n itemIndex += 1;\n }\n } else if (message.type === 'error') {\n const error = new Error(message.error.message);\n error.name = message.error.name;\n error.stack = message.error.stack;\n reject(error);\n }\n });\n\n thread.on('error', reject);\n thread.on('exit', (code: number) => {\n if (code !== 0) {\n reject(new Error(`Worker thread exited with code ${code}`));\n } else {\n resolve();\n }\n });\n });\n }),\n );\n\n return { results };\n}\n\n/* istanbul ignore next */\nfunction workerQueueThread(\n workerFuncFactory: (\n data: unknown,\n ) => Promise<(item: unknown) => Promise<unknown>>,\n) {\n const { parentPort, workerData } = require('node:worker_threads');\n\n Promise.resolve()\n .then(() => workerFuncFactory(workerData))\n .then(\n workerFunc => {\n parentPort.on('message', async (message: WorkerThreadMessage) => {\n if (message.type === 'done') {\n parentPort.close();\n return;\n }\n if (message.type === 'item') {\n try {\n const result = await workerFunc(message.item);\n parentPort.postMessage({\n type: 'result',\n index: message.index,\n result,\n });\n } catch (error) {\n parentPort.postMessage({ type: 'error', error });\n }\n }\n });\n\n parentPort.postMessage({ type: 'start' });\n },\n error => parentPort.postMessage({ type: 'error', error }),\n );\n}\n"],"names":["getEnvironmentConcurrency","Worker"],"mappings":";;;;;AA8EA,eAAsB,sBACpB,OAAA,EACiC;AACjC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AACtC,EAAA,MAAM,gBAAgB,OAAA,CAAQ,aAAA;AAC9B,EAAA,MAAM,aAAa,OAAA,CAAQ,OAAA;AAC3B,EAAA,MAAM,cAAc,IAAA,CAAK,GAAA,CAAIA,qCAAA,EAA0B,EAAG,MAAM,MAAM,CAAA;AAEtE,EAAA,MAAM,QAAA,GAAW,KAAA,CAAM,MAAA,CAAO,QAAQ,CAAA,EAAE;AACxC,EAAA,MAAM,OAAA,GAAU,IAAI,KAAA,EAAe;AACnC,EAAA,IAAI,SAAA,GAAY,CAAA;AAEhB,EAAA,MAAM,OAAA,CAAQ,GAAA;AAAA,IACZ,MAAM,WAAW,CAAA,CACd,KAAK,CAAC,CAAA,CACN,IAAI,YAAY;AACf,MAAA,MAAM,SAAS,IAAIC,0BAA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AAED,MAAA,UAAA,CAAW,WAAA,CAAY,EAAE,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,IAC1C,CAAA;AAAA,IACA,WAAS,UAAA,CAAW,WAAA,CAAY,EAAE,IAAA,EAAM,OAAA,EAAS,OAAO;AAAA,GAC1D;AACJ;;;;"} |
+11
-0
| # @backstage/cli-node | ||
| ## 0.2.19-next.0 | ||
| ### Patch Changes | ||
| - 06c2015: Added `runConcurrentTasks` and `runWorkerQueueThreads` utilities, moved from the `@backstage/cli` internal code. | ||
| - 70fc178: Migrated from deprecated `findPaths` to `targetPaths` and `findOwnPaths` from `@backstage/cli-common`. | ||
| - Updated dependencies | ||
| - @backstage/cli-common@0.2.0-next.0 | ||
| - @backstage/errors@1.2.7 | ||
| - @backstage/types@1.2.2 | ||
| ## 0.2.18 | ||
@@ -4,0 +15,0 @@ |
| 'use strict'; | ||
| var errors = require('@backstage/errors'); | ||
| var paths = require('../paths.cjs.js'); | ||
| var cliCommon = require('@backstage/cli-common'); | ||
@@ -10,3 +9,3 @@ | ||
| const stdout = await cliCommon.runOutput(["git", ...args], { | ||
| cwd: paths.paths.targetRoot | ||
| cwd: cliCommon.targetPaths.rootDir | ||
| }); | ||
@@ -59,3 +58,3 @@ return stdout.trim().split(/\r\n|\r|\n/); | ||
| const stdout = await cliCommon.runOutput(["git", "show", `${showRef}:${path}`], { | ||
| cwd: paths.paths.targetRoot | ||
| cwd: cliCommon.targetPaths.rootDir | ||
| }); | ||
@@ -62,0 +61,0 @@ return stdout; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"GitUtils.cjs.js","sources":["../../src/git/GitUtils.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assertError, ForwardedError } from '@backstage/errors';\nimport { paths } from '../paths';\nimport { runOutput } from '@backstage/cli-common';\n\n/**\n * Run a git command, trimming the output splitting it into lines.\n */\nexport async function runGit(...args: string[]) {\n try {\n const stdout = await runOutput(['git', ...args], {\n cwd: paths.targetRoot,\n });\n return stdout.trim().split(/\\r\\n|\\r|\\n/);\n } catch (error) {\n assertError(error);\n if (\n 'code' in error &&\n typeof (error as { code?: number }).code === 'number'\n ) {\n const code = (error as { code?: number }).code;\n const stderr = (error as { stderr?: string }).stderr;\n const msg = stderr?.trim() ?? `with exit code ${code}`;\n throw new Error(`git ${args[0]} failed, ${msg}`);\n }\n throw new ForwardedError('Unknown execution error', error);\n }\n}\n\n/**\n * Utilities for working with git.\n *\n * @public\n */\nexport class GitUtils {\n /**\n * Returns a sorted list of all files that have changed since the merge base\n * of the provided `ref` and HEAD, as well as all files that are not tracked by git.\n */\n static async listChangedFiles(ref: string) {\n if (!ref) {\n throw new Error('ref is required');\n }\n\n let diffRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n diffRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const tracked = await runGit('diff', '--name-only', diffRef);\n const untracked = await runGit(\n 'ls-files',\n '--others',\n '--exclude-standard',\n );\n\n return Array.from(new Set([...tracked, ...untracked]));\n }\n\n /**\n * Returns the contents of a file at a specific ref.\n */\n static async readFileAtRef(path: string, ref: string) {\n let showRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n showRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const stdout = await runOutput(['git', 'show', `${showRef}:${path}`], {\n cwd: paths.targetRoot,\n });\n return stdout;\n }\n}\n"],"names":["runOutput","paths","assertError","ForwardedError"],"mappings":";;;;;;AAuBA,eAAsB,UAAU,IAAA,EAAgB;A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AC3D,IAAA,MAAM,YAAY,MAAM,MAAA;AAAA,MACtB,UAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,OAAA,EAAS,GAAG,SAAS,CAAC,CAAC,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,aAAA,CAAc,IAAA,EAAc,GAAA,EAAa;AACpD,IAAA,IAAI,OAAA,GAAU,GAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,CAAC,IAAI,CAAA,GAAI,MAAM,MAAA,CAAO,YAAA,EAAc,QAAQ,GAAG,CAAA;AACrD,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ,CAAA,CAAA,MAAQ;AAAA,IAER;AAEA,IAAA,MAAM,MAAA,GAAS,MAAMH,mBAAA,CAAU,CAAC,KAAA,EAAO,MAAA,EAAQ,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA,EAAG;AAAA,MACpE,KAAKC,WAAA,CAAM;AAAA,KACZ,CAAA;AACD,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;;"} | ||
| {"version":3,"file":"GitUtils.cjs.js","sources":["../../src/git/GitUtils.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assertError, ForwardedError } from '@backstage/errors';\nimport { targetPaths } from '@backstage/cli-common';\nimport { runOutput } from '@backstage/cli-common';\n\n/**\n * Run a git command, trimming the output splitting it into lines.\n */\nexport async function runGit(...args: string[]) {\n try {\n const stdout = await runOutput(['git', ...args], {\n cwd: targetPaths.rootDir,\n });\n return stdout.trim().split(/\\r\\n|\\r|\\n/);\n } catch (error) {\n assertError(error);\n if (\n 'code' in error &&\n typeof (error as { code?: number }).code === 'number'\n ) {\n const code = (error as { code?: number }).code;\n const stderr = (error as { stderr?: string }).stderr;\n const msg = stderr?.trim() ?? `with exit code ${code}`;\n throw new Error(`git ${args[0]} failed, ${msg}`);\n }\n throw new ForwardedError('Unknown execution error', error);\n }\n}\n\n/**\n * Utilities for working with git.\n *\n * @public\n */\nexport class GitUtils {\n /**\n * Returns a sorted list of all files that have changed since the merge base\n * of the provided `ref` and HEAD, as well as all files that are not tracked by git.\n */\n static async listChangedFiles(ref: string) {\n if (!ref) {\n throw new Error('ref is required');\n }\n\n let diffRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n diffRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const tracked = await runGit('diff', '--name-only', diffRef);\n const untracked = await runGit(\n 'ls-files',\n '--others',\n '--exclude-standard',\n );\n\n return Array.from(new Set([...tracked, ...untracked]));\n }\n\n /**\n * Returns the contents of a file at a specific ref.\n */\n static async readFileAtRef(path: string, ref: string) {\n let showRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n showRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const stdout = await runOutput(['git', 'show', `${showRef}:${path}`], {\n cwd: targetPaths.rootDir,\n });\n return stdout;\n }\n}\n"],"names":["runOutput","targetPaths","assertError","ForwardedError"],"mappings":";;;;;AAuBA,eAAsB,UAAU,IAAA,EAAgB;AAC9C,EAAA,IAAI;AACF,IAAA,MAAM,SAAS,MAAMA,mBAAA,CAAU,CAAC,KAAA,EAAO,GAAG,IAAI,CAAA,EAAG;AAAA,MAC/C,KAAKC,qBAAA,CAAY;AAAA,KAClB,CAAA;AACD,IAAA,OAAO,MAAA,CAAO,IAAA,E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CAAC,CAAC,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,aAAA,CAAc,IAAA,EAAc,GAAA,EAAa;AACpD,IAAA,IAAI,OAAA,GAAU,GAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,CAAC,IAAI,CAAA,GAAI,MAAM,MAAA,CAAO,YAAA,EAAc,QAAQ,GAAG,CAAA;AACrD,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ,CAAA,CAAA,MAAQ;AAAA,IAER;AAEA,IAAA,MAAM,MAAA,GAAS,MAAMH,mBAAA,CAAU,CAAC,KAAA,EAAO,MAAA,EAAQ,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA,EAAG;AAAA,MACpE,KAAKC,qBAAA,CAAY;AAAA,KAClB,CAAA;AACD,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;;"} |
@@ -7,2 +7,4 @@ 'use strict'; | ||
| var Lockfile = require('./monorepo/Lockfile.cjs.js'); | ||
| var runConcurrentTasks = require('./concurrency/runConcurrentTasks.cjs.js'); | ||
| var runWorkerQueueThreads = require('./concurrency/runWorkerQueueThreads.cjs.js'); | ||
| var PackageRoles = require('./roles/PackageRoles.cjs.js'); | ||
@@ -17,3 +19,5 @@ | ||
| exports.Lockfile = Lockfile.Lockfile; | ||
| exports.runConcurrentTasks = runConcurrentTasks.runConcurrentTasks; | ||
| exports.runWorkerQueueThreads = runWorkerQueueThreads.runWorkerQueueThreads; | ||
| exports.PackageRoles = PackageRoles.PackageRoles; | ||
| //# sourceMappingURL=index.cjs.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"} |
+60
-2
@@ -311,3 +311,61 @@ import { Package } from '@manypkg/get-packages'; | ||
| export { GitUtils, Lockfile, PackageGraph, PackageRoles, isMonoRepo, packageFeatureType }; | ||
| export type { BackstagePackage, BackstagePackageFeatureType, BackstagePackageJson, LockfileDiff, LockfileDiffEntry, LockfileQueryEntry, PackageGraphNode, PackageOutputType, PackagePlatform, PackageRole, PackageRoleInfo }; | ||
| /** | ||
| * Options for {@link runConcurrentTasks}. | ||
| * | ||
| * @public | ||
| */ | ||
| type ConcurrentTasksOptions<TItem> = { | ||
| /** | ||
| * Decides the number of concurrent workers by multiplying | ||
| * this with the configured concurrency. | ||
| * | ||
| * Defaults to 1. | ||
| */ | ||
| concurrencyFactor?: number; | ||
| items: Iterable<TItem>; | ||
| worker: (item: TItem) => Promise<void>; | ||
| }; | ||
| /** | ||
| * Runs items through a worker function concurrently across multiple async workers. | ||
| * | ||
| * @public | ||
| */ | ||
| declare function runConcurrentTasks<TItem>(options: ConcurrentTasksOptions<TItem>): Promise<void>; | ||
| /** | ||
| * Options for {@link runWorkerQueueThreads}. | ||
| * | ||
| * @public | ||
| */ | ||
| type WorkerQueueThreadsOptions<TItem, TResult, TContext> = { | ||
| /** The items to process */ | ||
| items: Iterable<TItem>; | ||
| /** | ||
| * A function that will be called within each worker thread at startup, | ||
| * which should return the worker function that will be called for each item. | ||
| * | ||
| * This function must be defined as an arrow function or using the | ||
| * function keyword, and must be entirely self contained, not referencing | ||
| * any variables outside of its scope. This is because the function source | ||
| * is stringified and evaluated in the worker thread. | ||
| * | ||
| * To pass data to the worker, use the `context` option and `items`, but | ||
| * note that they are both copied by value into the worker thread, except for | ||
| * types that are explicitly shareable across threads, such as `SharedArrayBuffer`. | ||
| */ | ||
| workerFactory: (context: TContext) => ((item: TItem) => Promise<TResult>) | Promise<(item: TItem) => Promise<TResult>>; | ||
| /** Context data supplied to each worker factory */ | ||
| context?: TContext; | ||
| }; | ||
| /** | ||
| * Spawns one or more worker threads using the `worker_threads` module. | ||
| * Each thread processes one item at a time from the provided `options.items`. | ||
| * | ||
| * @public | ||
| */ | ||
| declare function runWorkerQueueThreads<TItem, TResult, TContext>(options: WorkerQueueThreadsOptions<TItem, TResult, TContext>): Promise<{ | ||
| results: TResult[]; | ||
| }>; | ||
| export { GitUtils, Lockfile, PackageGraph, PackageRoles, isMonoRepo, packageFeatureType, runConcurrentTasks, runWorkerQueueThreads }; | ||
| export type { BackstagePackage, BackstagePackageFeatureType, BackstagePackageJson, ConcurrentTasksOptions, LockfileDiff, LockfileDiffEntry, LockfileQueryEntry, PackageGraphNode, PackageOutputType, PackagePlatform, PackageRole, PackageRoleInfo, WorkerQueueThreadsOptions }; |
| 'use strict'; | ||
| var paths = require('../paths.cjs.js'); | ||
| var cliCommon = require('@backstage/cli-common'); | ||
| var fs = require('fs-extra'); | ||
@@ -11,3 +11,3 @@ | ||
| async function isMonoRepo() { | ||
| const rootPackageJsonPath = paths.paths.resolveTargetRoot("package.json"); | ||
| const rootPackageJsonPath = cliCommon.targetPaths.resolveRoot("package.json"); | ||
| try { | ||
@@ -14,0 +14,0 @@ const pkg = await fs__default.default.readJson(rootPackageJsonPath); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"isMonoRepo.cjs.js","sources":["../../src/monorepo/isMonoRepo.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { paths } from '../paths';\nimport fs from 'fs-extra';\n\n/**\n * Returns try if the current project is a monorepo.\n *\n * @public\n */\nexport async function isMonoRepo(): Promise<boolean> {\n const rootPackageJsonPath = paths.resolveTargetRoot('package.json');\n try {\n const pkg = await fs.readJson(rootPackageJsonPath);\n return Boolean(pkg?.workspaces?.packages);\n } catch (error) {\n return false;\n }\n}\n"],"names":["paths","fs"],"mappings":";;;;;;;;;AAwBA,eAAsB,UAAA,GAA+B;AACnD,EAAA,MAAM,mBAAA,GAAsBA,WAAA,CAAM,iBAAA,CAAkB,cAAc,CAAA;AAClE,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAMC,mBAAA,CAAG,QAAA,CAAS,mBAAmB,CAAA;AACjD,IAAA,OAAO,OAAA,CAAQ,GAAA,EAAK,UAAA,EAAY,QAAQ,CAAA;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;"} | ||
| {"version":3,"file":"isMonoRepo.cjs.js","sources":["../../src/monorepo/isMonoRepo.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { targetPaths } from '@backstage/cli-common';\nimport fs from 'fs-extra';\n\n/**\n * Returns try if the current project is a monorepo.\n *\n * @public\n */\nexport async function isMonoRepo(): Promise<boolean> {\n const rootPackageJsonPath = targetPaths.resolveRoot('package.json');\n try {\n const pkg = await fs.readJson(rootPackageJsonPath);\n return Boolean(pkg?.workspaces?.packages);\n } catch (error) {\n return false;\n }\n}\n"],"names":["targetPaths","fs"],"mappings":";;;;;;;;;AAwBA,eAAsB,UAAA,GAA+B;AACnD,EAAA,MAAM,mBAAA,GAAsBA,qBAAA,CAAY,WAAA,CAAY,cAAc,CAAA;AAClE,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAMC,mBAAA,CAAG,QAAA,CAAS,mBAAmB,CAAA;AACjD,IAAA,OAAO,OAAA,CAAQ,GAAA,EAAK,UAAA,EAAY,QAAQ,CAAA;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;"} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
| var getPackages = require('@manypkg/get-packages'); | ||
| var paths = require('../paths.cjs.js'); | ||
| var cliCommon = require('@backstage/cli-common'); | ||
| var GitUtils = require('../git/GitUtils.cjs.js'); | ||
@@ -25,3 +25,3 @@ var Lockfile = require('./Lockfile.cjs.js'); | ||
| static async listTargetPackages() { | ||
| const { packages } = await getPackages.getPackages(paths.paths.targetDir); | ||
| const { packages } = await getPackages.getPackages(cliCommon.targetPaths.dir); | ||
| return packages; | ||
@@ -137,3 +137,3 @@ } | ||
| // relative from root, convert to posix, and add a / at the end | ||
| path__default.default.relative(paths.paths.targetRoot, pkg.dir).split(path__default.default.sep).join(path__default.default.posix.sep) + path__default.default.posix.sep, | ||
| path__default.default.relative(cliCommon.targetPaths.rootDir, pkg.dir).split(path__default.default.sep).join(path__default.default.posix.sep) + path__default.default.posix.sep, | ||
| pkg | ||
@@ -164,3 +164,3 @@ ]) | ||
| thisLockfile = await Lockfile.Lockfile.load( | ||
| paths.paths.resolveTargetRoot("yarn.lock") | ||
| cliCommon.targetPaths.resolveRoot("yarn.lock") | ||
| ); | ||
@@ -167,0 +167,0 @@ otherLockfile = Lockfile.Lockfile.parse( |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"PackageGraph.cjs.js","sources":["../../src/monorepo/PackageGraph.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from 'node:path';\nimport { getPackages, Package } from '@manypkg/get-packages';\nimport { paths } from '../paths';\nimport { PackageRole } from '../roles';\nimport { GitUtils } from '../git';\nimport { Lockfile } from './Lockfile';\nimport { JsonValue } from '@backstage/types';\n\n/**\n * A list of the feature types we want to extract from the project\n * and include in the metadata\n *\n * @public\n */\nexport const packageFeatureType = [\n '@backstage/BackendFeature',\n '@backstage/BackstagePlugin',\n '@backstage/FrontendPlugin',\n '@backstage/FrontendModule',\n] as const;\n\n/**\n * @public\n */\nexport type BackstagePackageFeatureType = (typeof packageFeatureType)[number];\n\n/**\n * Known fields in Backstage package.json files.\n *\n * @public\n */\nexport interface BackstagePackageJson {\n name: string;\n version: string;\n private?: boolean;\n\n main?: string;\n module?: string;\n types?: string;\n\n scripts?: {\n [key: string]: string;\n };\n // The `bundled` field is a field known within Backstage, it means\n // that the package bundles all of its dependencies in its build output.\n bundled?: boolean;\n\n type?: 'module' | 'commonjs';\n\n backstage?: {\n role?: PackageRole;\n moved?: string;\n\n /**\n * If set to `true`, the package will be treated as an internal package\n * where any imports will be inlined into the consuming package.\n *\n * When set to `true`, the top-level `private` field must be set to `true`\n * as well.\n */\n inline?: boolean;\n\n /**\n * The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages. A `null` value means that the package is explicitly not a plugin package.\n */\n pluginId?: string | null;\n\n /**\n * The parent plugin package of a module. Must always and only be set for module packages.\n */\n pluginPackage?: string;\n\n /**\n * All packages that are part of the plugin. Must always and only be set for plugin packages and plugin library packages.\n */\n pluginPackages?: string[];\n\n /**\n * Module packages that should be installed alongside this plugin for cross-plugin integrations.\n * If the peer module's target plugin is present, you should have the peer module installed.\n */\n peerModules?: string[];\n\n /**\n * The feature types exported from the package, indexed by path.\n */\n features?: Record<string, BackstagePackageFeatureType>;\n };\n\n exports?: JsonValue;\n typesVersions?: Record<string, Record<string, string[]>>;\n\n files?: string[];\n\n publishConfig?: {\n access?: 'public' | 'restricted';\n directory?: string;\n registry?: string;\n };\n\n repository?:\n | string\n | {\n type: string;\n url: string;\n directory: string;\n };\n\n dependencies?: {\n [key: string]: string;\n };\n peerDependencies?: {\n [key: string]: string;\n };\n devDependencies?: {\n [key: string]: string;\n };\n optionalDependencies?: {\n [key: string]: string;\n };\n}\n\n/**\n * A local Backstage monorepo package\n *\n * @public\n */\nexport type BackstagePackage = {\n dir: string;\n packageJson: BackstagePackageJson;\n};\n\n/**\n * A local package in the monorepo package graph.\n *\n * @public\n */\nexport type PackageGraphNode = {\n /** The name of the package */\n name: string;\n /** The directory of the package */\n dir: string;\n /** The package data of the package itself */\n packageJson: BackstagePackageJson;\n\n /** All direct local dependencies of the package */\n allLocalDependencies: Map<string, PackageGraphNode>;\n /** All direct local dependencies that will be present in the published package */\n publishedLocalDependencies: Map<string, PackageGraphNode>;\n /** Local dependencies */\n localDependencies: Map<string, PackageGraphNode>;\n /** Local devDependencies */\n localDevDependencies: Map<string, PackageGraphNode>;\n /** Local optionalDependencies */\n localOptionalDependencies: Map<string, PackageGraphNode>;\n\n /** All direct incoming local dependencies of the package */\n allLocalDependents: Map<string, PackageGraphNode>;\n /** All direct incoming local dependencies that will be present in the published package */\n publishedLocalDependents: Map<string, PackageGraphNode>;\n /** Incoming local dependencies */\n localDependents: Map<string, PackageGraphNode>;\n /** Incoming local devDependencies */\n localDevDependents: Map<string, PackageGraphNode>;\n /** Incoming local optionalDependencies */\n localOptionalDependents: Map<string, PackageGraphNode>;\n};\n\n/**\n * Represents a local Backstage monorepo package graph.\n *\n * @public\n */\nexport class PackageGraph extends Map<string, PackageGraphNode> {\n /**\n * Lists all local packages in a monorepo.\n */\n static async listTargetPackages(): Promise<BackstagePackage[]> {\n const { packages } = await getPackages(paths.targetDir);\n\n return packages as BackstagePackage[];\n }\n\n /**\n * Creates a package graph from a list of local packages.\n */\n static fromPackages(packages: Package[]): PackageGraph {\n const graph = new PackageGraph();\n\n // Add all local packages to the graph\n for (const pkg of packages) {\n const name = pkg.packageJson.name;\n const existingPkg = graph.get(name);\n if (existingPkg) {\n throw new Error(\n `Duplicate package name '${name}' at ${pkg.dir} and ${existingPkg.dir}`,\n );\n }\n\n graph.set(name, {\n name,\n dir: pkg.dir,\n packageJson: pkg.packageJson as BackstagePackageJson,\n\n allLocalDependencies: new Map(),\n publishedLocalDependencies: new Map(),\n localDependencies: new Map(),\n localDevDependencies: new Map(),\n localOptionalDependencies: new Map(),\n\n allLocalDependents: new Map(),\n publishedLocalDependents: new Map(),\n localDependents: new Map(),\n localDevDependents: new Map(),\n localOptionalDependents: new Map(),\n });\n }\n\n // Populate the local dependency structure\n for (const node of graph.values()) {\n for (const depName of Object.keys(node.packageJson.dependencies || {})) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.publishedLocalDependencies.set(depName, depPkg);\n node.localDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.publishedLocalDependents.set(node.name, node);\n depPkg.localDependents.set(node.name, node);\n }\n }\n for (const depName of Object.keys(\n node.packageJson.devDependencies || {},\n )) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.localDevDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.localDevDependents.set(node.name, node);\n }\n }\n for (const depName of Object.keys(\n node.packageJson.optionalDependencies || {},\n )) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.publishedLocalDependencies.set(depName, depPkg);\n node.localOptionalDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.publishedLocalDependents.set(node.name, node);\n depPkg.localOptionalDependents.set(node.name, node);\n }\n }\n }\n\n return graph;\n }\n\n /**\n * Traverses the package graph and collects a set of package names.\n *\n * The traversal starts at the provided list names, and continues\n * throughout all the names returned by the `collectFn`, which is\n * called once for each seen package.\n */\n collectPackageNames(\n startingPackageNames: string[],\n collectFn: (pkg: PackageGraphNode) => Iterable<string> | undefined,\n ): Set<string> {\n const targets = new Set<string>();\n const searchNames = startingPackageNames.slice();\n\n while (searchNames.length) {\n const name = searchNames.pop()!;\n\n if (targets.has(name)) {\n continue;\n }\n\n const node = this.get(name);\n if (!node) {\n throw new Error(`Package '${name}' not found`);\n }\n\n targets.add(name);\n\n const collected = collectFn(node);\n if (collected) {\n searchNames.push(...collected);\n }\n }\n\n return targets;\n }\n\n /**\n * Lists all packages that have changed since a given git ref.\n *\n * @remarks\n *\n * If the `analyzeLockfile` option is set to true, the change detection will\n * also consider changes to the dependency management lockfile.\n */\n async listChangedPackages(options: {\n ref: string;\n analyzeLockfile?: boolean;\n }) {\n const changedFiles = await GitUtils.listChangedFiles(options.ref);\n\n const dirMap = new Map(\n Array.from(this.values()).map(pkg => [\n // relative from root, convert to posix, and add a / at the end\n path\n .relative(paths.targetRoot, pkg.dir)\n .split(path.sep)\n .join(path.posix.sep) + path.posix.sep,\n pkg,\n ]),\n );\n const packageDirs = Array.from(dirMap.keys());\n\n const result = new Array<PackageGraphNode>();\n let searchIndex = 0;\n\n changedFiles.sort();\n packageDirs.sort();\n\n for (const packageDir of packageDirs) {\n // Skip through changes that appear before our package dir\n while (\n searchIndex < changedFiles.length &&\n changedFiles[searchIndex] < packageDir\n ) {\n searchIndex += 1;\n }\n\n // Check if we arrived at a match, otherwise we move on to the next package dir\n if (changedFiles[searchIndex]?.startsWith(packageDir)) {\n searchIndex += 1;\n\n result.push(dirMap.get(packageDir)!);\n\n // Skip through the rest of the changed files for the same package\n while (changedFiles[searchIndex]?.startsWith(packageDir)) {\n searchIndex += 1;\n }\n }\n }\n\n if (changedFiles.includes('yarn.lock') && options.analyzeLockfile) {\n // Load the lockfile in the working tree and the one at the ref and diff them\n let thisLockfile: Lockfile;\n let otherLockfile: Lockfile;\n try {\n thisLockfile = await Lockfile.load(\n paths.resolveTargetRoot('yarn.lock'),\n );\n otherLockfile = Lockfile.parse(\n await GitUtils.readFileAtRef('yarn.lock', options.ref),\n );\n } catch (error) {\n console.warn(\n `Failed to read lockfiles, assuming all packages have changed, ${error}`,\n );\n return Array.from(this.values());\n }\n const diff = thisLockfile.diff(otherLockfile);\n\n // Create a simplified dependency graph only keeps track of package names\n const graph = thisLockfile.createSimplifiedDependencyGraph();\n\n // Merge the dependency graph from the other lockfile into this one in\n // order to be able to detect removals accurately.\n {\n const otherGraph = thisLockfile.createSimplifiedDependencyGraph();\n for (const [name, dependencies] of otherGraph) {\n const node = graph.get(name);\n if (node) {\n dependencies.forEach(d => node.add(d));\n } else {\n graph.set(name, dependencies);\n }\n }\n }\n\n // The check is simplified by only considering the package names rather\n // than the exact version range queries that were changed.\n // TODO(Rugvip): Use a more exact check\n const changedPackages = new Set(\n [...diff.added, ...diff.changed, ...diff.removed].map(e => e.name),\n );\n\n // Starting with our set of changed packages from the diff, we loop through\n // the full graph and add any package that has a dependency on a changed package.\n // We keep looping until all transitive dependencies have been detected.\n let changed = false;\n do {\n changed = false;\n for (const [name, dependencies] of graph) {\n if (changedPackages.has(name)) {\n continue;\n }\n for (const dep of dependencies) {\n if (changedPackages.has(dep)) {\n changed = true;\n changedPackages.add(name);\n break;\n }\n }\n }\n } while (changed);\n\n // Add all local packages that had a transitive dependency change to the result set\n for (const node of this.values()) {\n if (changedPackages.has(node.name) && !result.includes(node)) {\n result.push(node);\n }\n }\n }\n\n return result;\n }\n}\n"],"names":["getPackages","paths","GitUtils","path","Lockfile"],"mappings":";;;;;;;;;;;;AA8BO,MAAM,kBAAA,GAAqB;AAAA,EAChC,2BAAA;AAAA,EACA,4BAAA;AAAA,EACA,2BAAA;AAAA,EACA;AACF;AA0JO,MAAM,qBAAqB,GAAA,CAA8B;AAAA;AAAA;AAAA;AAAA,EAI9D,aAAa,kBAAA,GAAkD;AAC7D,IAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAMA,uBAAA,CAAYC,YAAM,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ourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from 'node:path';\nimport { getPackages, Package } from '@manypkg/get-packages';\nimport { targetPaths } from '@backstage/cli-common';\nimport { PackageRole } from '../roles';\nimport { GitUtils } from '../git';\nimport { Lockfile } from './Lockfile';\nimport { JsonValue } from '@backstage/types';\n\n/**\n * A list of the feature types we want to extract from the project\n * and include in the metadata\n *\n * @public\n */\nexport const packageFeatureType = [\n '@backstage/BackendFeature',\n '@backstage/BackstagePlugin',\n '@backstage/FrontendPlugin',\n '@backstage/FrontendModule',\n] as const;\n\n/**\n * @public\n */\nexport type BackstagePackageFeatureType = (typeof packageFeatureType)[number];\n\n/**\n * Known fields in Backstage package.json files.\n *\n * @public\n */\nexport interface BackstagePackageJson {\n name: string;\n version: string;\n private?: boolean;\n\n main?: string;\n module?: string;\n types?: string;\n\n scripts?: {\n [key: string]: string;\n };\n // The `bundled` field is a field known within Backstage, it means\n // that the package bundles all of its dependencies in its build output.\n bundled?: boolean;\n\n type?: 'module' | 'commonjs';\n\n backstage?: {\n role?: PackageRole;\n moved?: string;\n\n /**\n * If set to `true`, the package will be treated as an internal package\n * where any imports will be inlined into the consuming package.\n *\n * When set to `true`, the top-level `private` field must be set to `true`\n * as well.\n */\n inline?: boolean;\n\n /**\n * The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages. A `null` value means that the package is explicitly not a plugin package.\n */\n pluginId?: string | null;\n\n /**\n * The parent plugin package of a module. Must always and only be set for module packages.\n */\n pluginPackage?: string;\n\n /**\n * All packages that are part of the plugin. Must always and only be set for plugin packages and plugin library packages.\n */\n pluginPackages?: string[];\n\n /**\n * Module packages that should be installed alongside this plugin for cross-plugin integrations.\n * If the peer module's target plugin is present, you should have the peer module installed.\n */\n peerModules?: string[];\n\n /**\n * The feature types exported from the package, indexed by path.\n */\n features?: Record<string, BackstagePackageFeatureType>;\n };\n\n exports?: JsonValue;\n typesVersions?: Record<string, Record<string, string[]>>;\n\n files?: string[];\n\n publishConfig?: {\n access?: 'public' | 'restricted';\n directory?: string;\n registry?: string;\n };\n\n repository?:\n | string\n | {\n type: string;\n url: string;\n directory: string;\n };\n\n dependencies?: {\n [key: string]: string;\n };\n peerDependencies?: {\n [key: string]: string;\n };\n devDependencies?: {\n [key: string]: string;\n };\n optionalDependencies?: {\n [key: string]: string;\n };\n}\n\n/**\n * A local Backstage monorepo package\n *\n * @public\n */\nexport type BackstagePackage = {\n dir: string;\n packageJson: BackstagePackageJson;\n};\n\n/**\n * A local package in the monorepo package graph.\n *\n * @public\n */\nexport type PackageGraphNode = {\n /** The name of the package */\n name: string;\n /** The directory of the package */\n dir: string;\n /** The package data of the package itself */\n packageJson: BackstagePackageJson;\n\n /** All direct local dependencies of the package */\n allLocalDependencies: Map<string, PackageGraphNode>;\n /** All direct local dependencies that will be present in the published package */\n publishedLocalDependencies: Map<string, PackageGraphNode>;\n /** Local dependencies */\n localDependencies: Map<string, PackageGraphNode>;\n /** Local devDependencies */\n localDevDependencies: Map<string, PackageGraphNode>;\n /** Local optionalDependencies */\n localOptionalDependencies: Map<string, PackageGraphNode>;\n\n /** All direct incoming local dependencies of the package */\n allLocalDependents: Map<string, PackageGraphNode>;\n /** All direct incoming local dependencies that will be present in the published package */\n publishedLocalDependents: Map<string, PackageGraphNode>;\n /** Incoming local dependencies */\n localDependents: Map<string, PackageGraphNode>;\n /** Incoming local devDependencies */\n localDevDependents: Map<string, PackageGraphNode>;\n /** Incoming local optionalDependencies */\n localOptionalDependents: Map<string, PackageGraphNode>;\n};\n\n/**\n * Represents a local Backstage monorepo package graph.\n *\n * @public\n */\nexport class PackageGraph extends Map<string, PackageGraphNode> {\n /**\n * Lists all local packages in a monorepo.\n */\n static async listTargetPackages(): Promise<BackstagePackage[]> {\n const { packages } = await getPackages(targetPaths.dir);\n\n return packages as BackstagePackage[];\n }\n\n /**\n * Creates a package graph from a list of local packages.\n */\n static fromPackages(packages: Package[]): PackageGraph {\n const graph = new PackageGraph();\n\n // Add all local packages to the graph\n for (const pkg of packages) {\n const name = pkg.packageJson.name;\n const existingPkg = graph.get(name);\n if (existingPkg) {\n throw new Error(\n `Duplicate package name '${name}' at ${pkg.dir} and ${existingPkg.dir}`,\n );\n }\n\n graph.set(name, {\n name,\n dir: pkg.dir,\n packageJson: pkg.packageJson as BackstagePackageJson,\n\n allLocalDependencies: new Map(),\n publishedLocalDependencies: new Map(),\n localDependencies: new Map(),\n localDevDependencies: new Map(),\n localOptionalDependencies: new Map(),\n\n allLocalDependents: new Map(),\n publishedLocalDependents: new Map(),\n localDependents: new Map(),\n localDevDependents: new Map(),\n localOptionalDependents: new Map(),\n });\n }\n\n // Populate the local dependency structure\n for (const node of graph.values()) {\n for (const depName of Object.keys(node.packageJson.dependencies || {})) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.publishedLocalDependencies.set(depName, depPkg);\n node.localDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.publishedLocalDependents.set(node.name, node);\n depPkg.localDependents.set(node.name, node);\n }\n }\n for (const depName of Object.keys(\n node.packageJson.devDependencies || {},\n )) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.localDevDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.localDevDependents.set(node.name, node);\n }\n }\n for (const depName of Object.keys(\n node.packageJson.optionalDependencies || {},\n )) {\n const depPkg = graph.get(depName);\n if (depPkg) {\n node.allLocalDependencies.set(depName, depPkg);\n node.publishedLocalDependencies.set(depName, depPkg);\n node.localOptionalDependencies.set(depName, depPkg);\n\n depPkg.allLocalDependents.set(node.name, node);\n depPkg.publishedLocalDependents.set(node.name, node);\n depPkg.localOptionalDependents.set(node.name, node);\n }\n }\n }\n\n return graph;\n }\n\n /**\n * Traverses the package graph and collects a set of package names.\n *\n * The traversal starts at the provided list names, and continues\n * throughout all the names returned by the `collectFn`, which is\n * called once for each seen package.\n */\n collectPackageNames(\n startingPackageNames: string[],\n collectFn: (pkg: PackageGraphNode) => Iterable<string> | undefined,\n ): Set<string> {\n const targets = new Set<string>();\n const searchNames = startingPackageNames.slice();\n\n while (searchNames.length) {\n const name = searchNames.pop()!;\n\n if (targets.has(name)) {\n continue;\n }\n\n const node = this.get(name);\n if (!node) {\n throw new Error(`Package '${name}' not found`);\n }\n\n targets.add(name);\n\n const collected = collectFn(node);\n if (collected) {\n searchNames.push(...collected);\n }\n }\n\n return targets;\n }\n\n /**\n * Lists all packages that have changed since a given git ref.\n *\n * @remarks\n *\n * If the `analyzeLockfile` option is set to true, the change detection will\n * also consider changes to the dependency management lockfile.\n */\n async listChangedPackages(options: {\n ref: string;\n analyzeLockfile?: boolean;\n }) {\n const changedFiles = await GitUtils.listChangedFiles(options.ref);\n\n const dirMap = new Map(\n Array.from(this.values()).map(pkg => [\n // relative from root, convert to posix, and add a / at the end\n path\n .relative(targetPaths.rootDir, pkg.dir)\n .split(path.sep)\n .join(path.posix.sep) + path.posix.sep,\n pkg,\n ]),\n );\n const packageDirs = Array.from(dirMap.keys());\n\n const result = new Array<PackageGraphNode>();\n let searchIndex = 0;\n\n changedFiles.sort();\n packageDirs.sort();\n\n for (const packageDir of packageDirs) {\n // Skip through changes that appear before our package dir\n while (\n searchIndex < changedFiles.length &&\n changedFiles[searchIndex] < packageDir\n ) {\n searchIndex += 1;\n }\n\n // Check if we arrived at a match, otherwise we move on to the next package dir\n if (changedFiles[searchIndex]?.startsWith(packageDir)) {\n searchIndex += 1;\n\n result.push(dirMap.get(packageDir)!);\n\n // Skip through the rest of the changed files for the same package\n while (changedFiles[searchIndex]?.startsWith(packageDir)) {\n searchIndex += 1;\n }\n }\n }\n\n if (changedFiles.includes('yarn.lock') && options.analyzeLockfile) {\n // Load the lockfile in the working tree and the one at the ref and diff them\n let thisLockfile: Lockfile;\n let otherLockfile: Lockfile;\n try {\n thisLockfile = await Lockfile.load(\n targetPaths.resolveRoot('yarn.lock'),\n );\n otherLockfile = Lockfile.parse(\n await GitUtils.readFileAtRef('yarn.lock', options.ref),\n );\n } catch (error) {\n console.warn(\n `Failed to read lockfiles, assuming all packages have changed, ${error}`,\n );\n return Array.from(this.values());\n }\n const diff = thisLockfile.diff(otherLockfile);\n\n // Create a simplified dependency graph only keeps track of package names\n const graph = thisLockfile.createSimplifiedDependencyGraph();\n\n // Merge the dependency graph from the other lockfile into this one in\n // order to be able to detect removals accurately.\n {\n const otherGraph = thisLockfile.createSimplifiedDependencyGraph();\n for (const [name, dependencies] of otherGraph) {\n const node = graph.get(name);\n if (node) {\n dependencies.forEach(d => node.add(d));\n } else {\n graph.set(name, dependencies);\n }\n }\n }\n\n // The check is simplified by only considering the package names rather\n // than the exact version range queries that were changed.\n // TODO(Rugvip): Use a more exact check\n const changedPackages = new Set(\n [...diff.added, ...diff.changed, ...diff.removed].map(e => e.name),\n );\n\n // Starting with our set of changed packages from the diff, we loop through\n // the full graph and add any package that has a dependency on a changed package.\n // We keep looping until all transitive dependencies have been detected.\n let changed = false;\n do {\n changed = false;\n for (const [name, dependencies] of graph) {\n if (changedPackages.has(name)) {\n continue;\n }\n for (const dep of dependencies) {\n if (changedPackages.has(dep)) {\n changed = true;\n changedPackages.add(name);\n break;\n }\n }\n }\n } while (changed);\n\n // Add all local packages that had a transitive dependency change to the result set\n for (const node of this.values()) {\n if (changedPackages.has(node.name) && !result.includes(node)) {\n result.push(node);\n }\n }\n }\n\n return result;\n }\n}\n"],"names":["getPackages","targetPaths","GitUtils","path","Lockfile"],"mappings":";;;;;;;;;;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AAA,CAAK,IAAI,KAAK,CAAC,MAAA,CAAO,QAAA,CAAS,IAAI,CAAA,EAAG;AAC5D,UAAA,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;;"} |
+7
-7
| { | ||
| "name": "@backstage/cli-node", | ||
| "version": "0.2.18", | ||
| "version": "0.2.19-next.0", | ||
| "description": "Node.js library for Backstage CLIs", | ||
@@ -34,5 +34,5 @@ "backstage": { | ||
| "dependencies": { | ||
| "@backstage/cli-common": "^0.1.18", | ||
| "@backstage/errors": "^1.2.7", | ||
| "@backstage/types": "^1.2.2", | ||
| "@backstage/cli-common": "0.2.0-next.0", | ||
| "@backstage/errors": "1.2.7", | ||
| "@backstage/types": "1.2.2", | ||
| "@manypkg/get-packages": "^1.1.3", | ||
@@ -45,5 +45,5 @@ "@yarnpkg/parsers": "^3.0.0", | ||
| "devDependencies": { | ||
| "@backstage/backend-test-utils": "^1.11.0", | ||
| "@backstage/cli": "^0.35.4", | ||
| "@backstage/test-utils": "^1.7.15" | ||
| "@backstage/backend-test-utils": "1.11.1-next.0", | ||
| "@backstage/cli": "0.35.5-next.0", | ||
| "@backstage/test-utils": "1.7.16-next.0" | ||
| }, | ||
@@ -50,0 +50,0 @@ "typesVersions": { |
| 'use strict'; | ||
| var cliCommon = require('@backstage/cli-common'); | ||
| const paths = cliCommon.findPaths(__dirname); | ||
| exports.paths = paths; | ||
| //# sourceMappingURL=paths.cjs.js.map |
| {"version":3,"file":"paths.cjs.js","sources":["../src/paths.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { findPaths } from '@backstage/cli-common';\n\n/* eslint-disable-next-line no-restricted-syntax */\nexport const paths = findPaths(__dirname);\n"],"names":["findPaths"],"mappings":";;;;AAmBO,MAAM,KAAA,GAAQA,oBAAU,SAAS;;;;"} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
117552
23.45%22
22.22%1160
21.72%6
200%+ Added
+ Added
- Removed
- Removed
Updated
Updated