mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 21:57:51 +00:00
Stop checking for very old, long-removed commands
Change-type: major
This commit is contained in:
parent
12923c9b84
commit
de1821d7ac
@ -110,14 +110,9 @@ export function checkDeletedCommand(argvSlice: string[]): void {
|
|||||||
if (argvSlice[0] === 'help') {
|
if (argvSlice[0] === 'help') {
|
||||||
argvSlice = argvSlice.slice(1);
|
argvSlice = argvSlice.slice(1);
|
||||||
}
|
}
|
||||||
function replaced(
|
function replaced(oldCmd: string, alternative: string, version: string) {
|
||||||
oldCmd: string,
|
|
||||||
alternative: string,
|
|
||||||
version: string,
|
|
||||||
verb = 'replaced',
|
|
||||||
) {
|
|
||||||
throw new ExpectedError(`\
|
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.`);
|
Please use "balena ${alternative}" instead.`);
|
||||||
}
|
}
|
||||||
function removed(oldCmd: string, alternative: string, version: string) {
|
function removed(oldCmd: string, alternative: string, version: string) {
|
||||||
@ -127,22 +122,7 @@ Please use "balena ${alternative}" instead.`);
|
|||||||
}
|
}
|
||||||
throw new ExpectedError(msg);
|
throw new ExpectedError(msg);
|
||||||
}
|
}
|
||||||
const stopAlternative =
|
const cmds: { [cmd: string]: ['replaced' | 'removed', string, string] } = {};
|
||||||
'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'],
|
|
||||||
};
|
|
||||||
let cmd: string | undefined;
|
let cmd: string | undefined;
|
||||||
if (argvSlice.length > 1) {
|
if (argvSlice.length > 1) {
|
||||||
cmd = [argvSlice[0], argvSlice[1]].join(' ');
|
cmd = [argvSlice[0], argvSlice[1]].join(' ');
|
||||||
@ -150,7 +130,9 @@ Please use "balena ${alternative}" instead.`);
|
|||||||
cmd = argvSlice[0];
|
cmd = argvSlice[0];
|
||||||
}
|
}
|
||||||
if (cmd && Object.getOwnPropertyNames(cmds).includes(cmd)) {
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user