Skip to content

Commit

Permalink
fix: cli defaults function flag to external references
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoudy91 committed Apr 18, 2024
1 parent 6d456ac commit 59772ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/contentful--create-contentful-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ async function initProject(appName: string, options: CLIOptions) {
}

if (!isInteractive && isContentfulTemplate(templateSource) && normalizedOptions.function) {
// If function flag is specified, but no function name is provided, we default to external-references
// for legacy support.
if (normalizedOptions.function === true) {
normalizedOptions.function = 'external-references';
}

await cloneFunction(
fullAppFolder,
!!normalizedOptions.javascript,
Expand Down Expand Up @@ -194,7 +200,7 @@ async function initProject(appName: string, options: CLIOptions) {
].join('\n')
)
.option('-a, --action', 'include a hosted app action in the ts or js template')
.option('-f, --function <function-template-name>', 'include the specified function template')
.option('-f, --function [function-template-name]', 'include the specified function template')
.action(initProject);
await program.parseAsync();
})();
2 changes: 1 addition & 1 deletion packages/contentful--create-contentful-app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type CLIOptions = Partial<{
source: string;
example: string;
action: boolean;
function: string;
function: string | boolean;
}>;

export const ContentfulExample = {
Expand Down

0 comments on commit 59772ec

Please sign in to comment.