Fix package name plugin infix with yarn new
Signed-off-by: solimant <solimant@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Fix inconsistent behavior in the `new` command for the `@internal` scope: it now consistently defaults to the `backstage-plugin-` infix whether the `--scope` option is not set or it's set to `internal`.
|
||||
@@ -196,7 +196,7 @@ describe('loadPortableTemplateConfig', () => {
|
||||
private: true,
|
||||
version: '0.1.0',
|
||||
packageNamePrefix: '@internal/',
|
||||
packageNamePluginInfix: 'plugin-',
|
||||
packageNamePluginInfix: 'backstage-plugin-',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -316,7 +316,7 @@ describe('loadPortableTemplateConfig', () => {
|
||||
version: '0.1.0',
|
||||
private: true,
|
||||
packageNamePrefix: '@internal/',
|
||||
packageNamePluginInfix: 'plugin-',
|
||||
packageNamePluginInfix: 'backstage-plugin-',
|
||||
});
|
||||
|
||||
await expect(
|
||||
@@ -333,7 +333,7 @@ describe('loadPortableTemplateConfig', () => {
|
||||
version: '0.1.0',
|
||||
private: true,
|
||||
packageNamePrefix: '@internal/',
|
||||
packageNamePluginInfix: 'plugin-',
|
||||
packageNamePluginInfix: 'backstage-plugin-',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,6 +70,21 @@ type LoadConfigOptions = {
|
||||
overrides?: Partial<PortableTemplateConfig>;
|
||||
};
|
||||
|
||||
function computePackageNamePluginInfix(
|
||||
packageNamePrefix: string,
|
||||
namePluginInfix?: string,
|
||||
) {
|
||||
const packageNamePluginInfix =
|
||||
namePluginInfix ??
|
||||
(packageNamePrefix.includes('backstage')
|
||||
? defaults.packageNamePluginInfix
|
||||
: 'backstage-plugin-');
|
||||
|
||||
return {
|
||||
packageNamePluginInfix,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadPortableTemplateConfig(
|
||||
options: LoadConfigOptions = {},
|
||||
): Promise<PortableTemplateConfig> {
|
||||
@@ -116,6 +131,16 @@ export async function loadPortableTemplateConfig(
|
||||
templateNameConflicts.set(pointer.name, rawPointer);
|
||||
}
|
||||
|
||||
const packageNamePrefix =
|
||||
overrides.packageNamePrefix ??
|
||||
config?.globals?.namePrefix ??
|
||||
defaults.packageNamePrefix;
|
||||
|
||||
const { packageNamePluginInfix } = computePackageNamePluginInfix(
|
||||
packageNamePrefix,
|
||||
overrides.packageNamePluginInfix ?? config?.globals?.namePluginInfix,
|
||||
);
|
||||
|
||||
return {
|
||||
isUsingDefaultTemplates: !config?.templates,
|
||||
templatePointers: templatePointerEntries.map(({ pointer }) => pointer),
|
||||
@@ -126,14 +151,8 @@ export async function loadPortableTemplateConfig(
|
||||
overrides.publishRegistry ??
|
||||
config?.globals?.publishRegistry ??
|
||||
defaults.publishRegistry,
|
||||
packageNamePrefix:
|
||||
overrides.packageNamePrefix ??
|
||||
config?.globals?.namePrefix ??
|
||||
defaults.packageNamePrefix,
|
||||
packageNamePluginInfix:
|
||||
overrides.packageNamePluginInfix ??
|
||||
config?.globals?.namePluginInfix ??
|
||||
defaults.packageNamePluginInfix,
|
||||
packageNamePrefix,
|
||||
packageNamePluginInfix,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user