Skip to content

Commit 3e7f9dd

Browse files
fix: added manifest.json, used httpClient instead of axios
1 parent 1e24352 commit 3e7f9dd

File tree

5 files changed

+124
-12
lines changed

5 files changed

+124
-12
lines changed

src/commands/app/create.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,22 @@ export default class Create extends BaseCommand<typeof Create> {
9898
}))
9999
) {
100100
const boilerplate = await selectedBoilerplate();
101-
if (boilerplate) {
101+
102+
if (boilerplate && boilerplate.name && boilerplate.link) {
102103
this.sharedConfig.boilerplateName = boilerplate.name
103104
.toLowerCase()
104105
.replace(/ /g, "-");
105106
this.sharedConfig.appBoilerplateGithubUrl = boilerplate.link;
106-
this.sharedConfig.appName = this.sharedConfig.boilerplateName;
107+
this.sharedConfig.appName = await getAppName(
108+
this.sharedConfig.boilerplateName
109+
);
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+
107117
await this.boilerplateFlow();
108118
}
109119
} else {
@@ -258,10 +268,7 @@ export default class Create extends BaseCommand<typeof Create> {
258268
*/
259269
manageManifestToggeling() {
260270
// NOTE Use boilerplate manifest if exist
261-
const manifestPath = resolve(
262-
this.sharedConfig.folderPath,
263-
`${this.sharedConfig.folderPath}/manifest.json`
264-
);
271+
const manifestPath = resolve(this.sharedConfig.folderPath, "manifest.json");
265272

266273
if (existsSync(manifestPath)) {
267274
this.sharedConfig.manifestPath = manifestPath;

src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { resolve } from "path";
22

33
const config = {
44
defaultAppName: "app-boilerplate",
5-
manifestPath: resolve(__dirname, ""),
5+
manifestPath: resolve(__dirname, "manifest.json"),
66
boilerplateName: "marketplace-app-boilerplate-main",
77
developerHubBaseUrl: "",
88
appBoilerplateGithubUrl:

src/config/manifest.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"description": "",
3+
"icon": "",
4+
"name": "",
5+
"organization_uid": "",
6+
"target_type": "stack",
7+
"visibility": "private",
8+
"uid": "",
9+
"ui_location": {
10+
"signed": false,
11+
"base_url": "http://localhost:3000",
12+
"locations": [
13+
{
14+
"type": "cs.cm.stack.custom_field",
15+
"meta": [
16+
{
17+
"multiple": false,
18+
"path": "/#/custom-field",
19+
"signed": false,
20+
"enabled": true,
21+
"data_type": "json"
22+
}
23+
]
24+
},
25+
{
26+
"type": "cs.cm.stack.dashboard",
27+
"meta": [
28+
{
29+
"path": "/#/stack-dashboard",
30+
"signed": false,
31+
"enabled": true,
32+
"default_width": "half"
33+
}
34+
]
35+
},
36+
{
37+
"type": "cs.cm.stack.asset_sidebar",
38+
"meta": [
39+
{
40+
"blur": false,
41+
"path": "/#/asset-sidebar",
42+
"signed": false,
43+
"enabled": true,
44+
"width": 500
45+
}
46+
]
47+
},
48+
{
49+
"type": "cs.cm.stack.sidebar",
50+
"meta": [
51+
{
52+
"path": "/#/entry-sidebar",
53+
"signed": false,
54+
"enabled": true
55+
}
56+
]
57+
},
58+
{
59+
"type": "cs.cm.stack.full_page",
60+
"meta": [
61+
{
62+
"path": "/#/full-page",
63+
"signed": false,
64+
"enabled": true
65+
}
66+
]
67+
},
68+
{
69+
"type": "cs.cm.stack.field_modifier",
70+
"meta": [
71+
{
72+
"path": "/#/field-modifier",
73+
"signed": false,
74+
"enabled": true,
75+
"allowed_types": ["$all"]
76+
}
77+
]
78+
},
79+
{
80+
"type": "cs.cm.stack.config",
81+
"meta": [
82+
{
83+
"path": "/#/app-configuration",
84+
"signed": false,
85+
"enabled": true
86+
}
87+
]
88+
},
89+
{
90+
"type": "cs.cm.stack.rte",
91+
"meta": [
92+
{
93+
"path": "/json-rte.js",
94+
"signed": false,
95+
"enabled": true
96+
}
97+
]
98+
}
99+
]
100+
},
101+
"hosting": {
102+
"provider": "external",
103+
"deployment_url": "http://localhost:3000"
104+
}
105+
}

src/util/common-utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
cliux,
88
Stack,
99
FsUtility,
10+
HttpClient,
1011
} from "@contentstack/cli-utilities";
1112
import { projectsQuery } from "../graphql/queries";
1213
import { apiRequestHandler } from "./api-request-handler";
@@ -20,7 +21,6 @@ import {
2021
import { askProjectName } from "./inquirer";
2122
import { deployAppMsg } from "../messages";
2223
import config from "../config";
23-
import axios from "axios";
2424

2525
export type CommonOptions = {
2626
log: LogFn;
@@ -401,8 +401,9 @@ const handleProjectNameConflict = async (
401401
async function fetchBoilerplateDetails(): Promise<Record<string, any>[]> {
402402
try {
403403
const url = config.boilerplatesUrl;
404-
const content = await axios.get(url);
405-
return content.data.templates
404+
const client = new HttpClient();
405+
const content = await client.get(url);
406+
return content?.data?.templates ?? [];
406407
} catch (error) {
407408
throw error;
408409
}

src/util/inquirer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function inquireRequireValidation(input: any): string | boolean {
389389
const selectedBoilerplate = async (): Promise<any> => {
390390
const boilerplates = await fetchBoilerplateDetails();
391391

392-
const response = await cliux
392+
return await cliux
393393
.inquire({
394394
type: "search-list",
395395
name: "App",
@@ -399,7 +399,6 @@ const selectedBoilerplate = async (): Promise<any> => {
399399
.then((name) => {
400400
return find(boilerplates, (boilerplate) => boilerplate.name === name);
401401
});
402-
return response;
403402
};
404403

405404
export {

0 commit comments

Comments
 (0)