From 0a2039302f8c237616e0ba48de97a2b1de89ec88 Mon Sep 17 00:00:00 2001 From: David Legrand <1110600+davlgd@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:35:04 +0100 Subject: [PATCH 1/2] feat(create): make app name optional (use current directory name if not specified) --- bin/clever.js | 5 ++++- src/commands/create.js | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/clever.js b/bin/clever.js index 1b11500..9022617 100755 --- a/bin/clever.js +++ b/bin/clever.js @@ -90,7 +90,10 @@ function run () { description: 'Application ID (or name, if unambiguous)', parser: Parsers.appIdOrName, }), - appNameCreation: cliparse.argument('app-name', { description: 'Application name' }), + appNameCreation: cliparse.argument('app-name', { + description: 'Application name (optional, current directory name is used if not specified)', + default: '', + }), backupId: cliparse.argument('backup-id', { description: 'A Database backup ID (format: UUID)' }), databaseId: cliparse.argument('database-id', { description: 'Any database ID (format: addon_UUID, postgresql_UUID, mysql_UUID, ...)' }), drainId: cliparse.argument('drain-id', { description: 'Drain ID' }), diff --git a/src/commands/create.js b/src/commands/create.js index ea8c6b3..37f508e 100644 --- a/src/commands/create.js +++ b/src/commands/create.js @@ -1,15 +1,19 @@ 'use strict'; +const path = require('path'); const Application = require('../models/application.js'); const AppConfig = require('../models/app_configuration.js'); const Logger = require('../logger.js'); async function create (params) { const { type: typeName } = params.options; - const [name] = params.args; + const [rawName] = params.args; const { org: orgaIdOrName, alias, region, github: githubOwnerRepo, format } = params.options; const { apps } = await AppConfig.loadApplicationConf(); + // Application name is optionnal, use current directory name if not specified (empty string) + const name = (rawName !== '') ? rawName : getCurrentDirectoryName(); + AppConfig.checkAlreadyLinked(apps, name, alias); const github = getGithubDetails(githubOwnerRepo); @@ -41,4 +45,8 @@ function getGithubDetails (githubOwnerRepo) { } } +function getCurrentDirectoryName () { + return path.basename(process.cwd()); +} + module.exports = { create }; From 1a3eb9ea9acf44aebc431b617cbf7d522b27d880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20SABLONNI=C3=88RE?= Date: Fri, 16 Feb 2024 09:56:39 +0100 Subject: [PATCH 2/2] feat(create): display name once app (or add-on) is created --- src/commands/addon.js | 3 ++- src/commands/create.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/addon.js b/src/commands/addon.js index 93de6d2..6a168b3 100644 --- a/src/commands/addon.js +++ b/src/commands/addon.js @@ -84,8 +84,8 @@ function displayAddon (format, addon, message) { case 'json': { Logger.printJson({ id: addon.id, - name: addon.name, realId: addon.realId, + name: addon.name, }); break; } @@ -96,6 +96,7 @@ function displayAddon (format, addon, message) { message, `ID: ${addon.id}`, `Real ID: ${addon.realId}`, + `Name: ${addon.name}`, ].join('\n')); } } diff --git a/src/commands/create.js b/src/commands/create.js index 37f508e..53e7d4e 100644 --- a/src/commands/create.js +++ b/src/commands/create.js @@ -35,6 +35,7 @@ async function create (params) { default: Logger.println('Application created successfully!'); Logger.println(`ID: ${app.id}`); + Logger.println(`Name: ${name}`); } };