Skip to content

Commit 5e0ea9f

Browse files
authored
fix: upgrade command should always check when manually ran (#897)
Been bugging me, so we deprecate the force `flag`
1 parent 27c7bc1 commit 5e0ea9f

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

docs/reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ USAGE
3737
$ apify upgrade [-f] [--version <value>]
3838

3939
FLAGS
40-
-f, --force Whether to skip checking the locally cached latest version of the CLI and fetch it from the internet
41-
instead.
40+
-f, --force [DEPRECATED] This flag is now ignored, as running the command manually will always check for the latest
41+
version.
4242
--version=<value> The version of the CLI to upgrade to. If not provided, the latest version will be used.
4343
```
4444

src/commands/cli-management/upgrade.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const UPDATE_COMMANDS: Record<InstallMethod, (version: string, entrypoint: strin
2727
};
2828

2929
// TODO: update this once we bump the CLI version and release it with this command available
30-
const MINIMUM_VERSION_FOR_UPGRADE_COMMAND = '0.21.8';
30+
const MINIMUM_VERSION_FOR_UPGRADE_COMMAND = '1.0.1';
3131

3232
/**
3333
* The link to the upgrade script needed for windows when upgrading CLI bundles (as a fallback for when the script is missing)
@@ -48,7 +48,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {
4848
static override flags = {
4949
force: Flags.boolean({
5050
description:
51-
'Whether to skip checking the locally cached latest version of the CLI and fetch it from the internet instead.',
51+
'[DEPRECATED] This flag is now ignored, as running the command manually will always check for the latest version.',
5252
required: false,
5353
char: 'f',
5454
}),
@@ -73,7 +73,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {
7373
return;
7474
}
7575

76-
const result = await useCLIVersionCheck(this.flags.force);
76+
const result = await useCLIVersionCheck(!this.flags.internalAutomaticCall);
7777
const { installMethod } = useCLIMetadata();
7878

7979
if (!result.shouldUpdate || result.currentVersion === DEVELOPMENT_VERSION_MARKER) {

src/entrypoints/_shared.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ export async function runCLI(entrypoint: string) {
193193
const instance = new FinalCommand(
194194
entrypoint,
195195
hasSubcommand ? `${baseCommand.name} ${maybeSubcommandName}` : baseCommand.name,
196+
commandName,
197+
hasSubcommand ? maybeSubcommandName : undefined,
196198
);
197199

198200
// eslint-disable-next-line dot-notation

src/lib/command-framework/apify-command.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,19 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
198198

199199
protected commandString: string;
200200

201+
protected aliasUsed: string;
202+
203+
protected subcommandAliasUsed?: string;
204+
201205
protected skipTelemetry = false;
202206

203-
public constructor(entrypoint: string, commandString: string) {
207+
public constructor(entrypoint: string, commandString: string, aliasUsed: string, subcommandAliasUsed?: string) {
204208
this.entrypoint = entrypoint;
205209
this.commandString = commandString;
206210

211+
this.aliasUsed = aliasUsed;
212+
this.subcommandAliasUsed = subcommandAliasUsed;
213+
207214
const metadata = useCLIMetadata();
208215

209216
this.telemetryData.installMethod = metadata.installMethod;
@@ -866,7 +873,7 @@ export async function internalRunCommand<Cmd extends typeof BuiltApifyCommand>(
866873
}
867874
}
868875

869-
const instance = new (command as typeof BuiltApifyCommand)(entrypoint, command.name);
876+
const instance = new (command as typeof BuiltApifyCommand)(entrypoint, command.name, command.name);
870877

871878
// eslint-disable-next-line dot-notation
872879
instance['skipTelemetry'] = true;

website/versioned_docs/version-1.1.0/reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ USAGE
3737
$ apify upgrade [-f] [--version <value>]
3838

3939
FLAGS
40-
-f, --force Whether to skip checking the locally cached latest version of the CLI and fetch it from the internet
41-
instead.
40+
-f, --force [DEPRECATED] This flag is now ignored, as running the command manually will always check for the latest
41+
version.
4242
--version=<value> The version of the CLI to upgrade to. If not provided, the latest version will be used.
4343
```
4444

0 commit comments

Comments
 (0)