Skip to content

Commit

Permalink
fix: after Pierre's review
Browse files Browse the repository at this point in the history
  • Loading branch information
davlgd committed Jan 30, 2025
1 parent fbf9bf5 commit 2dee3a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/commands/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as application from '@clevercloud/client/esm/api/v2/application.js';

export async function list (params) {
const { alias, app: appIdOrName, 'add-export': addExportsOption, format } = params.options;
console.log(params.options);
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
const [envFromApp, envFromAddons, envFromDeps] = await Promise.all([
application.getAllEnvVars({ id: ownerId, appId }).then(sendToApi),
Expand Down
15 changes: 7 additions & 8 deletions src/commands/ssh-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export async function add (params) {
const { 'ssh-key-name': keyName, 'ssh-key-path': filePath } = params.namedArgs;

if (!existsSync(filePath)) {
Logger.error(`File ${filePath} does not exist`);
return;
throw new Error(`File ${filePath} does not exist`);
}

const fileContent = readFileSync(filePath, 'utf8').trim();
Expand All @@ -50,7 +49,7 @@ export async function add (params) {
*/
export async function remove (params) {
const { 'ssh-key-name': keyName } = params.namedArgs;
executeCommand(removeKey, [keyName]);
await executeCommand(removeKey, [keyName]);
}

/**
Expand Down Expand Up @@ -95,20 +94,20 @@ function printKeysHuman (keys) {
}

if (keys.length === 1) {
Logger.println(`🔐 Current user have 1 SSH key: ${keys[0].name} (${keys[0].fingerprint})`);
Logger.println(`🔐 Current user has 1 SSH key: ${keys[0].name} (${keys[0].fingerprint})`);
return;
}

Logger.println(`🔐 Current user have ${keys.length} SSH keys:`);
Logger.println(`🔐 Current user has ${keys.length} SSH keys:`);
keys.forEach((k) => {
Logger.println(` ${colors.blue(k.name)}`, colors.grey(`(${k.fingerprint})`));
Logger.println(` ${colors.blue(k.name)}`, colors.grey(`(${k.fingerprint})`));
});
}

/**
* Open the SSH keys management page of the Console in your browser
* @returns {Promise<void>} A promise that resolves when the page is opened
*/
export async function openConsole () {
openBrowser('https://console.clever-cloud.com/users/me/ssh-keys', 'Opening the SSH keys management page in your browser');
export function openConsole () {
return openBrowser('https://console.clever-cloud.com/users/me/ssh-keys', 'Opening the SSH keys management page in your browser');
}
9 changes: 2 additions & 7 deletions src/models/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ export class Deferred {
* @throws {Error} If the command execution fails
*/
export async function executeCommand (fn, params) {
try {
const result = await fn(...params);
Logger.println(result.message);
}
catch (e) {
Logger.error(e.message);
}
const result = await fn(...params);
Logger.println(result.message);
}

/**
Expand Down

0 comments on commit 2dee3a2

Please sign in to comment.