Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(applications): use current directory as default create name #634

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/clever.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand Down
3 changes: 2 additions & 1 deletion src/commands/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -96,6 +96,7 @@ function displayAddon (format, addon, message) {
message,
`ID: ${addon.id}`,
`Real ID: ${addon.realId}`,
`Name: ${addon.name}`,
].join('\n'));
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/commands/create.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -31,6 +35,7 @@ async function create (params) {
default:
Logger.println('Application created successfully!');
Logger.println(`ID: ${app.id}`);
Logger.println(`Name: ${name}`);
}
};

Expand All @@ -41,4 +46,8 @@ function getGithubDetails (githubOwnerRepo) {
}
}

function getCurrentDirectoryName () {
return path.basename(process.cwd());
}

module.exports = { create };
Loading