-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: finish status, add clear/reset
- Loading branch information
Showing
9 changed files
with
320 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const warning = | ||
'WARNING: This command deletes or overwrites all existing source tracking files. Use with extreme caution.'; | ||
|
||
module.exports = { | ||
resetDescription: `reset local and remote source tracking | ||
${warning} | ||
Resets local and remote source tracking so that the CLI no longer registers differences between your local files and those in the org. When you next run force:source:status, the CLI returns no results, even though conflicts might actually exist. The CLI then resumes tracking new source changes as usual. | ||
Use the --revision parameter to reset source tracking to a specific revision number of an org source member. To get the revision number, query the SourceMember Tooling API object with the force:data:soql:query command. For example: | ||
$ sfdx force:data:soql:query -q "SELECT MemberName, MemberType, RevisionCounter FROM SourceMember" -t`, | ||
|
||
clearDescription: `clear all local source tracking information | ||
${warning} | ||
Clears all local source tracking information. When you next run force:source:status, the CLI displays all local and remote files as changed, and any files with the same name are listed as conflicts.`, | ||
|
||
nopromptDescription: 'do not prompt for source tracking override confirmation', | ||
revisionDescription: 'reset to a specific SourceMember revision counter number', | ||
promptMessage: | ||
'WARNING: This operation will modify all your local source tracking files. The operation can have unintended consequences on all the force:source commands. Are you sure you want to proceed (y/n)?', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command'; | ||
import { Messages, Org, SfdxProject } from '@salesforce/core'; | ||
import * as chalk from 'chalk'; | ||
import { SourceTracking } from '../../../sourceTracking'; | ||
|
||
Messages.importMessagesDirectory(__dirname); | ||
const messages: Messages = Messages.loadMessages('@salesforce/source-tracking', 'source_tracking'); | ||
|
||
export type SourceTrackingClearResult = { | ||
clearedFiles: string[]; | ||
}; | ||
|
||
export class SourceTrackingClearCommand extends SfdxCommand { | ||
public static readonly description = messages.getMessage('clearDescription'); | ||
|
||
public static readonly requiresProject = true; | ||
public static readonly requiresUsername = true; | ||
|
||
public static readonly flagsConfig: FlagsConfig = { | ||
noprompt: flags.boolean({ | ||
char: 'p', | ||
description: messages.getMessage('nopromptDescription'), | ||
required: false, | ||
}), | ||
}; | ||
|
||
// valid assertions with ! because requiresProject and requiresUsername | ||
protected org!: Org; | ||
protected project!: SfdxProject; | ||
|
||
public async run(): Promise<SourceTrackingClearResult> { | ||
let clearedFiles: string[] = []; | ||
if (this.flags.noprompt || (await this.ux.confirm(chalk.dim(messages.getMessage('promptMessage'))))) { | ||
const sourceTracking = new SourceTracking({ project: this.project, org: this.org }); | ||
clearedFiles = await Promise.all([sourceTracking.clearLocalTracking(), sourceTracking.clearRemoteTracking()]); | ||
this.ux.log('Cleared local tracking files.'); | ||
} | ||
return { clearedFiles }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command'; | ||
import { Messages, Org, SfdxProject } from '@salesforce/core'; | ||
import * as chalk from 'chalk'; | ||
import { SourceTracking } from '../../../sourceTracking'; | ||
|
||
Messages.importMessagesDirectory(__dirname); | ||
const messages: Messages = Messages.loadMessages('@salesforce/source-tracking', 'source_tracking'); | ||
|
||
export type SourceTrackingResetResult = { | ||
sourceMembersSynced: number; | ||
localPathsSynced: number; | ||
}; | ||
|
||
export class SourceTrackingResetCommand extends SfdxCommand { | ||
public static readonly description = messages.getMessage('resetDescription'); | ||
|
||
public static readonly requiresProject = true; | ||
public static readonly requiresUsername = true; | ||
|
||
public static readonly flagsConfig: FlagsConfig = { | ||
revision: flags.integer({ | ||
char: 'r', | ||
description: messages.getMessage('revisionDescription'), | ||
min: 0, | ||
}), | ||
noprompt: flags.boolean({ | ||
char: 'p', | ||
description: messages.getMessage('nopromptDescription'), | ||
}), | ||
}; | ||
|
||
// valid assertions with ! because requiresProject and requiresUsername | ||
protected org!: Org; | ||
protected project!: SfdxProject; | ||
|
||
public async run(): Promise<SourceTrackingResetResult> { | ||
if (this.flags.noprompt || (await this.ux.confirm(chalk.dim(messages.getMessage('promptMessage'))))) { | ||
const sourceTracking = new SourceTracking({ project: this.project, org: this.org }); | ||
|
||
const [remoteResets, localResets] = await Promise.all([ | ||
sourceTracking.resetRemoteTracking(this.flags.revision as number), | ||
sourceTracking.resetLocalTracking(), | ||
]); | ||
|
||
this.ux.log( | ||
`Reset local tracking files${this.flags.revision ? ` to revision ${this.flags.revision as number}` : ''}.` | ||
); | ||
|
||
return { | ||
sourceMembersSynced: remoteResets, | ||
localPathsSynced: localResets.length, | ||
}; | ||
} | ||
|
||
return { | ||
sourceMembersSynced: 0, | ||
localPathsSynced: 0, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.