Skip to content

Commit

Permalink
feat(restart): support --app argument
Browse files Browse the repository at this point in the history
  • Loading branch information
pdesoyres-cc committed Jun 21, 2024
1 parent dd0219c commit 1ac6074
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/clever.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ function run () {
const restart = lazyRequirePromiseModule('../src/commands/restart.js');
const restartCommand = cliparse.command('restart', {
description: 'Start or restart an application',
options: [opts.alias, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs],
options: [opts.alias, opts.appIdOrName, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs],
}, restart('restart'));

// SCALE COMMAND
Expand Down
12 changes: 8 additions & 4 deletions src/commands/restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const colors = require('colors/safe');

const AppConfig = require('../models/app_configuration.js');
const Application = require('../models/application.js');
const git = require('../models/git.js');
const Log = require('../models/log-v4.js');
Expand All @@ -11,17 +10,22 @@ const Logger = require('../logger.js');
// Once the API call to redeploy() has been triggerred successfully,
// the rest (waiting for deployment state to evolve and displaying logs) is done with auto retry (resilient to network pb)
async function restart (params) {
const { alias, quiet, commit, 'without-cache': withoutCache, follow } = params.options;
const { alias, app: appIdOrName, quiet, commit, 'without-cache': withoutCache, follow } = params.options;

const { ownerId, appId, name: appName } = await AppConfig.getAppDetails({ alias });
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
const fullCommitId = await git.resolveFullCommitId(commit);
const app = await Application.get(ownerId, appId);

if (app == null) {
throw new Error('The application doesn\'t exist');
}

const remoteCommitId = app.commitId;

const commitId = fullCommitId || remoteCommitId;
if (commitId != null) {
const cacheSuffix = withoutCache ? ' without using cache' : '';
Logger.println(`Restarting ${appName} on commit ${colors.green(commitId)}${cacheSuffix}`);
Logger.println(`Restarting ${app.name} on commit ${colors.green(commitId)}${cacheSuffix}`);
}

// This should be handled by the API when a deployment ID is set but we'll do this for now
Expand Down

0 comments on commit 1ac6074

Please sign in to comment.