Skip to content

Commit 70ced3a

Browse files
authored
Merge pull request #408 from pharindoko/feat/add-cli-output-feat
feat(cli): add userfriendly output for create-stack or update-stack
2 parents ce6edef + 9ae0a7d commit 70ced3a

File tree

3 files changed

+56
-25
lines changed

3 files changed

+56
-25
lines changed

packages/cli/src/actions/helpers.ts

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ export class Helpers {
212212
return true;
213213
}
214214

215-
static createCLIOutput(slsinfo: string, apiAuth: boolean) {
215+
static createCLIOutput(
216+
slsinfo: string,
217+
apiAuth: boolean,
218+
enableSwagger: boolean
219+
) {
220+
216221
const rows = JSON.stringify(slsinfo).split('\\n') as any[];
217222
const createKeyValues = rows.map((x, i, rows) => {
218223
if (x.startsWith(' ANY -')) {
@@ -293,28 +298,42 @@ export class Helpers {
293298
console.log();
294299
console.log();
295300

296-
cli.table(
297-
[
298-
{
299-
text: `${chalk.blueBright('Swagger UI')}`,
300-
link: outputJson.endpoints + '/ui',
301-
},
302-
{
303-
text: `${chalk.blueBright('GraphiQL')}`,
304-
link: outputJson.endpoints + '/graphql',
305-
},
306-
{
307-
text: `${chalk.blueBright('Swagger Specification')}`,
308-
link: outputJson.endpoints + '/api-spec',
309-
},
310-
{
311-
text: `${chalk.blueBright('API Routes')}`,
312-
link: outputJson.endpoints + '/api/{routes}',
313-
},
314-
],
315-
{ text: { minWidth: 30 }, link: { minWidth: 20 } },
316-
{ 'no-header': true }
317-
);
301+
if (enableSwagger) {
302+
cli.table(
303+
[
304+
{
305+
text: `${chalk.blueBright('Swagger UI')}`,
306+
link: outputJson.endpoints + '/ui',
307+
},
308+
{
309+
text: `${chalk.blueBright('GraphiQL')}`,
310+
link: outputJson.endpoints + '/graphql',
311+
},
312+
{
313+
text: `${chalk.blueBright('Swagger Specification')}`,
314+
link: outputJson.endpoints + '/api-spec',
315+
},
316+
{
317+
text: `${chalk.blueBright('API Routes')}`,
318+
link: outputJson.endpoints + '/api/{routes}',
319+
},
320+
],
321+
{ text: { minWidth: 30 }, link: { minWidth: 20 } },
322+
{ 'no-header': true }
323+
);
324+
} else {
325+
cli.table(
326+
[
327+
{
328+
text: `${chalk.blueBright('API Routes')}`,
329+
link: outputJson.endpoints + '/api/{routes}',
330+
},
331+
],
332+
{ text: { minWidth: 30 }, link: { minWidth: 20 } },
333+
{ 'no-header': true }
334+
);
335+
}
336+
318337
console.log();
319338
console.log();
320339
}

packages/cli/src/commands/create-stack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ export class CreateStackCommand extends Command {
221221
const appConfig = JSON.parse(
222222
fs.readFileSync(stackFolder + '/config/appconfig.json', 'UTF-8')
223223
) as AppConfig;
224-
Helpers.createCLIOutput(slsinfo, appConfig.enableApiKeyAuth);
224+
225+
Helpers.createCLIOutput(
226+
slsinfo,
227+
appConfig.enableApiKeyAuth,
228+
appConfig.enableSwagger
229+
);
230+
225231
} catch (error) {
226232
this.log(`${chalk.red(error.message)}`);
227233
this.log(slsinfo);

packages/cli/src/commands/update-stack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ export class UpdateStackCommand extends Command {
184184
const appConfig = JSON.parse(
185185
fs.readFileSync(stackFolder + '/config/appconfig.json', 'UTF-8')
186186
) as AppConfig;
187-
Helpers.createCLIOutput(slsinfo, appConfig.enableApiKeyAuth);
187+
188+
Helpers.createCLIOutput(
189+
slsinfo,
190+
appConfig.enableApiKeyAuth,
191+
appConfig.enableSwagger
192+
);
193+
188194
} catch (error) {
189195
this.log(`${chalk.red(error.message)}`);
190196
this.log(slsinfo);

0 commit comments

Comments
 (0)