Skip to content

Commit 1d7afbb

Browse files
committed
feat: Remove resetConfig, change update logic CF-2031
Update will be called on startup, but check for hardcoded CLI version is moved to update and it will prevent calling `cli update`, not the entire function. This ensures `cli config reset` will be called when project opens/starts.
1 parent a5e980d commit 1d7afbb

4 files changed

Lines changed: 5 additions & 28 deletions

File tree

src/cli/CodacyCli.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ export abstract class CodacyCli {
3939

4040
public abstract configDiscover(filePath: string): Promise<void>
4141

42-
public abstract configReset(): Promise<void>
43-
4442
public getCliCommand(): string {
4543
return this._cliCommand
4644
}

src/cli/MacCodacyCli.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ export class MacCodacyCli extends CodacyCli {
2323

2424
if (fs.existsSync(fullPath)) {
2525
this.setCliCommand(this._cliVersion ? `CODACY_CLI_V2_VERSION=${this._cliVersion} ${localPath}` : localPath)
26-
2726
// CLI found, update it if necessary
28-
if (!this._cliVersion) {
29-
await this.update()
30-
}
31-
32-
return
27+
return await this.update()
3328
}
3429

3530
// CLI not found, attempt to install it
@@ -133,7 +128,10 @@ export class MacCodacyCli extends CodacyCli {
133128
Logger.debug('CLI mode is remote and no identification parameters provided. Skipping update and config reset.')
134129
return
135130
}
136-
await this.execAsync(updateCommand)
131+
//Call Update if CLI version is not set
132+
if (!this._cliVersion) {
133+
await this.execAsync(updateCommand)
134+
}
137135
await this.execAsync(resetCommand, resetParams)
138136

139137
// Initialize codacy-cli after update
@@ -276,16 +274,4 @@ export class MacCodacyCli extends CodacyCli {
276274
}
277275
}
278276
}
279-
280-
public async configReset(): Promise<void> {
281-
const resetCommand = `${this.getCliCommand()} config reset`
282-
const resetParams = this.getIdentificationParameters()
283-
284-
const hasIdentificationParams = await this.validateIdentificationParameters(resetParams)
285-
if (!hasIdentificationParams) {
286-
Logger.debug('CLI mode is remote and no identification parameters provided. Skipping update and config reset.')
287-
return
288-
}
289-
await this.execAsync(resetCommand, resetParams)
290-
}
291277
}

src/cli/WinCodacyCli.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,4 @@ export class WinCodacyCli extends CodacyCli {
3535
public configDiscover(_filePath: string): Promise<void> {
3636
throw new Error(NOT_SUPPORTED)
3737
}
38-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
39-
public configReset(): Promise<void> {
40-
throw new Error(NOT_SUPPORTED)
41-
}
4238
}

src/cli/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ export class Cli {
8383

8484
// set Cli command if found
8585
await this.cliInstance.preflightCodacyCli(false)
86-
87-
// check for an already installed CLI to update tools config
88-
await this.cliInstance.configReset()
8986

9087
return this.cliInstance
9188
}

0 commit comments

Comments
 (0)