Skip to content

Commit 0944970

Browse files
fix: added type def for boilerplates and updated a comment
1 parent 3093c0f commit 0944970

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/commands/app/create.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from "@contentstack/cli-utilities";
2626

2727
import { BaseCommand } from "../../base-command";
28-
import { AppManifest, AppType } from "../../types";
28+
import { AppManifest, AppType, BoilerplateAppType } from "../../types";
2929
import { appCreate, commonMsg } from "../../messages";
3030
import {
3131
getOrg,
@@ -97,23 +97,18 @@ export default class Create extends BaseCommand<typeof Create> {
9797
message: this.messages.CONFIRM_CLONE_BOILERPLATE,
9898
}))
9999
) {
100-
const boilerplate = await selectedBoilerplate();
100+
const boilerplate: BoilerplateAppType = await selectedBoilerplate();
101101

102-
if (boilerplate && boilerplate?.link) {
103-
this.sharedConfig.boilerplateName = boilerplate.name
104-
.toLowerCase()
105-
.replace(/ /g, "-");
102+
if (boilerplate) {
103+
if (boilerplate.name) {
104+
this.sharedConfig.boilerplateName = boilerplate.name
105+
.toLowerCase()
106+
.replace(/ /g, "-");
107+
}
106108
this.sharedConfig.appBoilerplateGithubUrl = boilerplate.link;
107109
this.sharedConfig.appName = await getAppName(
108110
this.sharedConfig.boilerplateName
109111
);
110-
111-
// Handle case where user does not provide a new name
112-
if (!this.sharedConfig.appName) {
113-
console.error("App name is required.");
114-
process.exit(1);
115-
}
116-
117112
await this.boilerplateFlow();
118113
}
119114
} else {
@@ -139,7 +134,7 @@ export default class Create extends BaseCommand<typeof Create> {
139134
await this.unZipBoilerplate(await this.cloneBoilerplate());
140135
tmp.setGracefulCleanup(); // NOTE If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit
141136

142-
// Update the sharedConfig.appName with the actual folder name
137+
// To remove the default app name from flag and replace it with the actual folder name
143138
this.sharedConfig.appName =
144139
this.sharedConfig.folderPath.split("/").pop() ||
145140
this.sharedConfig.appName;
@@ -254,10 +249,6 @@ export default class Create extends BaseCommand<typeof Create> {
254249
reject(error);
255250
});
256251
});
257-
// Update the app name and folder path
258-
this.sharedConfig.appName =
259-
this.sharedConfig.folderPath.split("/").pop() ||
260-
this.sharedConfig.appName;
261252
}
262253

263254
/**

src/types/app.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,12 @@ export interface LaunchProjectRes {
140140
environmentUid: any;
141141
developerHubAppUid: any;
142142
}
143+
144+
export interface BoilerplateAppType {
145+
name?: string;
146+
description?: string;
147+
link: string;
148+
tags?: string[];
149+
created_at?: string;
150+
updated_at?: string;
151+
}

0 commit comments

Comments
 (0)