Skip to content

Commit

Permalink
Stop checking for very old, long-removed commands
Browse files Browse the repository at this point in the history
Change-type: major
  • Loading branch information
myarmolinsky committed Sep 26, 2024
1 parent 2dd0fd0 commit 6176329
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/preparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,9 @@ export function checkDeletedCommand(argvSlice: string[]): void {
if (argvSlice[0] === 'help') {
argvSlice = argvSlice.slice(1);
}
function replaced(
oldCmd: string,
alternative: string,
version: string,
verb = 'replaced',
) {
function replaced(oldCmd: string, alternative: string, version: string) {
throw new ExpectedError(`\
Note: the command "balena ${oldCmd}" was ${verb} in CLI version ${version}.
Note: the command "balena ${oldCmd}" was replaced in CLI version ${version}.
Please use "balena ${alternative}" instead.`);
}
function removed(oldCmd: string, alternative: string, version: string) {
Expand All @@ -127,30 +122,17 @@ Please use "balena ${alternative}" instead.`);
}
throw new ExpectedError(msg);
}
const stopAlternative =
'Please use "balena device ssh -s" to access the host OS, then use `balena-engine stop`.';
const cmds: { [cmd: string]: [(...args: any) => void, ...string[]] } = {
sync: [replaced, 'push', 'v11.0.0', 'removed'],
'local logs': [replaced, 'logs', 'v11.0.0'],
'local push': [replaced, 'push', 'v11.0.0'],
'local scan': [replaced, 'scan', 'v11.0.0'],
'local ssh': [replaced, 'ssh', 'v11.0.0'],
'local stop': [removed, stopAlternative, 'v11.0.0'],
app: [replaced, 'fleet', 'v13.0.0'],
apps: [replaced, 'fleets', 'v13.0.0'],
'app purge': [replaced, 'fleet purge', 'v13.0.0'],
'app rename': [replaced, 'fleet rename', 'v13.0.0'],
'app restart': [replaced, 'fleet restart', 'v13.0.0'],
'app rm': [replaced, 'fleet rm', 'v13.0.0'],
};
const cmds: { [cmd: string]: ['replaced' | 'removed', string, string] } = {};
let cmd: string | undefined;
if (argvSlice.length > 1) {
cmd = [argvSlice[0], argvSlice[1]].join(' ');
} else if (argvSlice.length > 0) {
cmd = argvSlice[0];
}
if (cmd && Object.getOwnPropertyNames(cmds).includes(cmd)) {
cmds[cmd][0](cmd, ...cmds[cmd].slice(1));
const changeType = cmds[cmd][0];
const changeTypeFn = changeType === 'replaced' ? replaced : removed;
changeTypeFn(cmd, cmds[cmd][1], cmds[cmd][2]);
}
}

Expand Down

0 comments on commit 6176329

Please sign in to comment.