cli/new: move default globals to config reading
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -28,14 +28,6 @@ type CollectTemplateParamsOptions = {
|
||||
prefilledParams: Record<string, string | number | boolean>;
|
||||
};
|
||||
|
||||
const defaultParams = {
|
||||
owner: '',
|
||||
license: 'Apache-2.0',
|
||||
scope: '',
|
||||
baseVersion: '0.1.0',
|
||||
private: true,
|
||||
};
|
||||
|
||||
export async function collectTemplateParams(
|
||||
options: CollectTemplateParamsOptions,
|
||||
): Promise<Options> {
|
||||
@@ -67,7 +59,6 @@ export async function collectTemplateParams(
|
||||
>(needsAnswer);
|
||||
|
||||
return {
|
||||
...defaultParams,
|
||||
...config.globals,
|
||||
...prefilledAnswers,
|
||||
...promptAnswers,
|
||||
|
||||
@@ -22,6 +22,12 @@ import { z } from 'zod';
|
||||
import { fromZodError } from 'zod-validation-error';
|
||||
import { ForwardedError } from '@backstage/errors';
|
||||
|
||||
const defaultGlobals = {
|
||||
license: 'Apache-2.0',
|
||||
baseVersion: '0.1.0',
|
||||
private: true,
|
||||
};
|
||||
|
||||
const pkgJsonWithNewConfigSchema = z.object({
|
||||
backstage: z
|
||||
.object({
|
||||
@@ -72,6 +78,10 @@ export async function loadConfig(
|
||||
return {
|
||||
isUsingDefaultTemplates: !newConfig?.templates,
|
||||
templatePointers: newConfig?.templates ?? defaultTemplates,
|
||||
globals: { ...newConfig?.globals, ...options.globalOverrides },
|
||||
globals: {
|
||||
...defaultGlobals,
|
||||
...newConfig?.globals,
|
||||
...options.globalOverrides,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user