From 540995076a18b0f3297a214b53787f8c792923df Mon Sep 17 00:00:00 2001 From: Min Kim Date: Tue, 7 Jan 2025 16:00:06 -0500 Subject: [PATCH] Simplify resolvePackageName Signed-off-by: Min Kim --- packages/cli/src/lib/new/utils.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/lib/new/utils.ts b/packages/cli/src/lib/new/utils.ts index 84723352a7..4fea5774b4 100644 --- a/packages/cli/src/lib/new/utils.ts +++ b/packages/cli/src/lib/new/utils.ts @@ -31,20 +31,16 @@ export const resolvePackageName = (options: { scope?: string; plugin: boolean; }) => { - const { baseName, scope: _scope, plugin } = options; - if (_scope) { - const scope = _scope.replace(/@/g, ''); + const { baseName, scope, plugin } = options; + if (scope) { + const scopeSanitized = scope.replace(/[@/]/g, ''); if (plugin) { - const pluginName = scope.startsWith('backstage') + const pluginPrefix = scopeSanitized.startsWith('backstage') ? 'plugin' : 'backstage-plugin'; - return scope.includes('/') - ? `@${scope}${pluginName}-${baseName}` - : `@${scope}/${pluginName}-${baseName}`; + return `@${scopeSanitized}/${pluginPrefix}-${baseName}`; } - return scope.includes('/') - ? `@${scope}${baseName}` - : `@${scope}/${baseName}`; + return `@${scopeSanitized}/${baseName}`; } return plugin ? `backstage-plugin-${baseName}` : baseName;