From 4e9da9de010fb595e170cb5cfd6901d7857a38f1 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 20 Mar 2025 17:02:51 +0100 Subject: [PATCH 1/3] cli: allow multiple --require Signed-off-by: Vincenzo Scamporlino --- packages/cli/src/commands/index.ts | 5 ++++- packages/cli/src/lib/runner/runBackend.ts | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 9a76711d08..969fba7c25 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -86,7 +86,10 @@ export function registerScriptCommand(program: Command) { '--inspect-brk [host]', 'Enable debugger in Node.js environments, breaking before code starts', ) - .option('--require ', 'Add a --require argument to the node process') + .option( + '--require ', + 'Add a --require argument to the node process', + ) .option('--link ', 'Link an external workspace for module resolution') .action(lazy(() => import('./start'), 'command')); diff --git a/packages/cli/src/lib/runner/runBackend.ts b/packages/cli/src/lib/runner/runBackend.ts index fb8fdd9d55..c085e183f1 100644 --- a/packages/cli/src/lib/runner/runBackend.ts +++ b/packages/cli/src/lib/runner/runBackend.ts @@ -39,7 +39,7 @@ export type RunBackendOptions = { /** Whether to forward the --inspect-brk flag to the node process */ inspectBrkEnabled: boolean; /** Additional module to require via the --require flag to the node process */ - require?: string; + require?: string | string[]; /** An external linked workspace to override module resolution towards */ linkedWorkspace?: string; }; @@ -107,7 +107,10 @@ export async function runBackend(options: RunBackendOptions) { optionArgs.push(inspect); } if (options.require) { - optionArgs.push(`--require=${options.require}`); + const requires = [options.require].flat(); + for (const r of requires) { + optionArgs.push(`--require=${r}`); + } } const userArgs = process.argv From d83f3f461c48ea227cfbb9f30369bd4cdcd92835 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 20 Mar 2025 17:05:13 +0100 Subject: [PATCH 2/3] cli: --require changeset Signed-off-by: Vincenzo Scamporlino --- .changeset/thin-snails-judge.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-snails-judge.md diff --git a/.changeset/thin-snails-judge.md b/.changeset/thin-snails-judge.md new file mode 100644 index 0000000000..c2328ed64f --- /dev/null +++ b/.changeset/thin-snails-judge.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Resolved a problem where the `start` command did not correctly handle multiple `--require` flags, ensuring all specified modules are now properly loaded. From 71665b739cb7780de1196953e8da063bfb494f1c Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 20 Mar 2025 17:08:30 +0100 Subject: [PATCH 3/3] cli: api-reports --require option Signed-off-by: Vincenzo Scamporlino --- packages/cli/cli-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 32918caad2..3c2e01a08e 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -272,7 +272,7 @@ Options: --check --inspect [host] --inspect-brk [host] - --require + --require --link -h, --help ```