Merge pull request #31771 from elaine-mattos/fix/cli-new-scope-arg-value
Fix `backstage-cli` new scope arg value
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Fixes an issue where using the `backstage-cli new --scope` command with a scope that already includes the `@` symbol (e.g., `@backstage-community`) would result in a double `@@` prefix in the generated package name, causing invalid `package.json` files.
|
||||
@@ -23,6 +23,8 @@ describe.each([
|
||||
[undefined, undefined, undefined],
|
||||
['internal', '@internal/', 'backstage-plugin-'],
|
||||
['internal/', '@internal/', 'backstage-plugin-'],
|
||||
['@internal', '@internal/', 'backstage-plugin-'],
|
||||
['@internal/', '@internal/', 'backstage-plugin-'],
|
||||
['acme-backstage', '@acme-backstage/', 'plugin-'],
|
||||
['acme-backstage/', '@acme-backstage/', 'plugin-'],
|
||||
['acme-backstage-plugins', '@acme-backstage-plugins/', 'plugin-'],
|
||||
|
||||
@@ -42,7 +42,10 @@ export default async (opts: ArgOptions) => {
|
||||
let pluginInfix: string | undefined = undefined;
|
||||
let packagePrefix: string | undefined = undefined;
|
||||
if (scope) {
|
||||
packagePrefix = scope.includes('/') ? `@${scope}` : `@${scope}/`;
|
||||
const normalizedScope = scope.startsWith('@') ? scope : `@${scope}`;
|
||||
packagePrefix = normalizedScope.includes('/')
|
||||
? normalizedScope
|
||||
: `${normalizedScope}/`;
|
||||
pluginInfix = scope.includes('backstage') ? 'plugin-' : 'backstage-plugin-';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user