Skip to content

Commit

Permalink
Merge branch 'sm/remove-old-format-support' into sm/no-tracking-when-…
Browse files Browse the repository at this point in the history
…sdr-events-are-not-successful
  • Loading branch information
mshanemc committed Apr 13, 2023
2 parents 380d7f8 + 3b4bcb0 commit 4256d01
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 582 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
module.exports = {
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license'],
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/library'],
// ignore eslint files in NUT test repos
ignorePatterns: ['test/nuts/ebikes-lwc'],
};
18 changes: 1 addition & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- 'yarn test:nuts:tracking:forceignore'
- 'yarn test:nuts:tracking:remote'
- 'yarn test:nuts:tracking:lwc'
- 'yarn test:nuts:deb'
- 'yarn mocha "test/nuts/trackingCommands/mpd-*.nut.ts" --slow 3000 --timeout 600000 --parallel'
with:
packageName: '@salesforce/source-tracking'
Expand Down Expand Up @@ -65,20 +66,3 @@ jobs:
preSwapCommands: 'yarn upgrade @salesforce/source-deploy-retrieve@latest; npx yarn-deduplicate; yarn install'
useCache: false
secrets: inherit

xNuts-source-tracking:
needs: linux-unit-tests
uses: salesforcecli/github-workflows/.github/workflows/externalNut.yml@main
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
command:
- 'yarn test:nuts:tracking'
- 'yarn test:nuts:deb'
with:
packageName: '@salesforce/source-tracking'
externalProjectGitUrl: 'https://github.com/salesforcecli/plugin-source'
command: ${{matrix.command}}
os: ${{matrix.os}}
secrets: inherit
510 changes: 156 additions & 354 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/source-tracking",
"description": "API for tracking local and remote Salesforce metadata changes",
"version": "2.2.28",
"version": "3.0.0",
"author": "Salesforce",
"license": "BSD-3-Clause",
"main": "lib/index.js",
Expand Down Expand Up @@ -68,6 +68,7 @@
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.8.0",
"eslint-plugin-sf-plugin": "^1.14.0",
"husky": "^7.0.4",
"mocha": "^9.2.2",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -157,4 +158,4 @@
"output": []
}
}
}
}
125 changes: 0 additions & 125 deletions src/compatibility.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

export * from './sourceTracking';
export * from './compatibility';
export {
RemoteSyncInput,
ChangeOptionType,
Expand Down
7 changes: 3 additions & 4 deletions src/shared/localShadowRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import * as git from 'isomorphic-git';
import { chunkArray, isLwcLocalOnlyTest, pathIsInFolder } from './functions';

/** returns the full path to where we store the shadow repo */
const getGitDir = (orgId: string, projectPath: string, useSfdxTrackingFiles = false): string =>
path.join(projectPath, useSfdxTrackingFiles ? '.sfdx' : '.sf', 'orgs', orgId, 'localSourceTracking');
const getGitDir = (orgId: string, projectPath: string): string =>
path.join(projectPath, '.sf', 'orgs', orgId, 'localSourceTracking');

// filenames were normalized when read from isogit
const toFilenames = (rows: StatusRow[]): string[] => rows.map((row) => row[FILE]);
Expand All @@ -24,7 +24,6 @@ interface ShadowRepoOptions {
orgId: string;
projectPath: string;
packageDirs: NamedPackageDir[];
hasSfdxTrackingFiles: boolean;
}

// https://isomorphic-git.org/docs/en/statusMatrix#docsNav
Expand Down Expand Up @@ -57,7 +56,7 @@ export class ShadowRepo {
private maxFileAdd: number;

private constructor(options: ShadowRepoOptions) {
this.gitDir = getGitDir(options.orgId, options.projectPath, options.hasSfdxTrackingFiles);
this.gitDir = getGitDir(options.orgId, options.projectPath);
this.projectPath = options.projectPath;
this.packageDirs = options.packageDirs;
this.isWindows = os.type() === 'Windows_NT';
Expand Down
31 changes: 15 additions & 16 deletions src/shared/remoteSourceTrackingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export namespace RemoteSourceTrackingService {
export interface Options extends ConfigFile.Options {
org: Org;
projectPath: string;
useSfdxTrackingFiles: boolean;
}
}

Expand Down Expand Up @@ -107,8 +106,8 @@ export class RemoteSourceTrackingService extends ConfigFile<RemoteSourceTracking
return 'maxRevision.json';
}

public static getFilePath(orgId: string, useSfdxTrackingFiles = false): string {
return path.join(useSfdxTrackingFiles ? '.sfdx' : '.sf', 'orgs', orgId, RemoteSourceTrackingService.getFileName());
public static getFilePath(orgId: string): string {
return path.join('.sf', 'orgs', orgId, RemoteSourceTrackingService.getFileName());
}

/**
Expand All @@ -117,8 +116,8 @@ export class RemoteSourceTrackingService extends ConfigFile<RemoteSourceTracking
* @param orgId
* @returns the path of the deleted source tracking file
*/
public static async delete(orgId: string, useSfdxTrackingFiles = false): Promise<string> {
const fileToDelete = RemoteSourceTrackingService.getFilePath(orgId, useSfdxTrackingFiles);
public static async delete(orgId: string): Promise<string> {
const fileToDelete = RemoteSourceTrackingService.getFilePath(orgId);
// the file might not exist, in which case we don't need to delete it
if (fs.existsSync(fileToDelete)) {
await fs.promises.unlink(fileToDelete);
Expand All @@ -135,7 +134,7 @@ export class RemoteSourceTrackingService extends ConfigFile<RemoteSourceTracking
this.logger = await Logger.child(this.constructor.name);
this.options = {
...this.options,
stateFolder: this.options.useSfdxTrackingFiles ? '.sfdx' : '.sf',
stateFolder: '.sf',
filename: RemoteSourceTrackingService.getFileName(),
filePath: path.join('orgs', this.org.getOrgId()),
};
Expand Down Expand Up @@ -557,7 +556,7 @@ export class RemoteSourceTrackingService extends ConfigFile<RemoteSourceTracking
private async query(query: string, quiet = false): Promise<SourceMember[]> {
if (!(await this.org.tracksSource())) {
Messages.importMessagesDirectory(__dirname);
const messages = Messages.load('@salesforce/source-tracking', 'source', ['NonSourceTrackedOrgError']);
const messages = Messages.loadMessages('@salesforce/source-tracking', 'source');
throw new SfError(messages.getMessage('NonSourceTrackedOrgError'), 'NonSourceTrackedOrgError');
}
if (!quiet) {
Expand All @@ -578,12 +577,12 @@ export class RemoteSourceTrackingService extends ConfigFile<RemoteSourceTracking
* Useful for correcing bundle types where the files show change results with types but aren't resolvable
*/
export const remoteChangeElementToChangeResult = (rce: RemoteChangeElement): ChangeResult => ({
...rce,
...(mappingsForSourceMemberTypesToMetadataType.has(rce.type)
? {
name: rce.name.split('/')[0],
type: mappingsForSourceMemberTypesToMetadataType.get(rce.type),
}
: {}),
origin: 'remote', // we know they're remote
});
...rce,
...(mappingsForSourceMemberTypesToMetadataType.has(rce.type)
? {
name: rce.name.split('/')[0],
type: mappingsForSourceMemberTypesToMetadataType.get(rce.type),
}
: {}),
origin: 'remote', // we know they're remote
});
7 changes: 1 addition & 6 deletions src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
import { sourceComponentGuard } from './shared/guards';
import { supportsPartialDelete, pathIsInFolder, ensureRelative } from './shared/functions';
import { registrySupportsType } from './shared/metadataKeys';
import { hasSfdxTrackingFiles } from './compatibility';
import { populateFilePaths } from './shared/populateFilePaths';
import { populateTypesAndNames } from './shared/populateTypesAndNames';
import { getComponentSets, getGroupedFiles } from './shared/localComponentSetArray';
Expand Down Expand Up @@ -89,7 +88,6 @@ export class SourceTracking extends AsyncCreatable {
private localRepo!: ShadowRepo;
private remoteSourceTrackingService!: RemoteSourceTrackingService;
private forceIgnore!: ForceIgnore;
private hasSfdxTrackingFiles: boolean;
private ignoreConflicts: boolean;
private subscribeSDREvents: boolean;
private ignoreLocalCache: boolean;
Expand All @@ -106,7 +104,6 @@ export class SourceTracking extends AsyncCreatable {
this.ignoreConflicts = options.ignoreConflicts ?? false;
this.ignoreLocalCache = options.ignoreLocalCache ?? false;
this.subscribeSDREvents = options.subscribeSDREvents ?? false;
this.hasSfdxTrackingFiles = hasSfdxTrackingFiles(this.orgId, this.projectPath);
}

// eslint-disable-next-line class-methods-use-this
Expand Down Expand Up @@ -459,7 +456,6 @@ export class SourceTracking extends AsyncCreatable {
orgId: this.orgId,
projectPath: normalize(this.projectPath),
packageDirs: this.packagesDirs,
hasSfdxTrackingFiles: this.hasSfdxTrackingFiles,
});
// loads the status from file so that it's cached
await this.localRepo.getStatus();
Expand All @@ -479,7 +475,6 @@ export class SourceTracking extends AsyncCreatable {
this.remoteSourceTrackingService = await RemoteSourceTrackingService.getInstance({
org: this.org,
projectPath: this.projectPath,
useSfdxTrackingFiles: this.hasSfdxTrackingFiles,
});
if (initializeWithQuery) {
await this.remoteSourceTrackingService.retrieveUpdates();
Expand Down Expand Up @@ -516,7 +511,7 @@ export class SourceTracking extends AsyncCreatable {
* Deletes the remote tracking files
*/
public async clearRemoteTracking(): Promise<string> {
return RemoteSourceTrackingService.delete(this.orgId, this.hasSfdxTrackingFiles);
return RemoteSourceTrackingService.delete(this.orgId);
}

/**
Expand Down
1 change: 0 additions & 1 deletion test/nuts/local/commitPerf.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('perf testing for big commits', () => {
orgId: 'fakeOrgId',
projectPath: session.project.dir,
packageDirs: [{ path: 'force-app', name: 'force-app', fullPath: path.join(session.project.dir, 'force-app') }],
hasSfdxTrackingFiles: false,
});
});

Expand Down
1 change: 0 additions & 1 deletion test/nuts/local/localTrackingScenario.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('end-to-end-test for local tracking', () => {
orgId: 'fakeOrgId',
projectPath: session.project.dir,
packageDirs: [{ path: 'force-app', name: 'force-app', fullPath: path.join(session.project.dir, 'force-app') }],
hasSfdxTrackingFiles: false,
});
// verify the local tracking files/directories
expect(fs.existsSync(repo.gitDir));
Expand Down
2 changes: 0 additions & 2 deletions test/nuts/local/nonTopLevelIgnore.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('handles non-top-level ignore inside project dir', () => {
orgId: 'fakeOrgId2',
projectPath: session.project.dir,
packageDirs: [{ path: 'classes', name: 'classes', fullPath: path.join(session.project.dir, 'classes') }],
hasSfdxTrackingFiles: false,
});
// verify the local tracking files/directories
expect(fs.existsSync(repo.gitDir));
Expand Down Expand Up @@ -62,7 +61,6 @@ describe('handles non-top-level ignore outside project dir', () => {
orgId: 'fakeOrgId2',
projectPath: session.project.dir,
packageDirs: [{ path: 'classes', name: 'classes', fullPath: path.join(session.project.dir, 'classes') }],
hasSfdxTrackingFiles: false,
});
// verify the local tracking files/directories
expect(fs.existsSync(repo.gitDir));
Expand Down
1 change: 0 additions & 1 deletion test/nuts/local/pkgDirMatching.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe('verifies exact match of pkgDirs', () => {
orgId: 'fakeOrgId3',
projectPath: session.project.dir,
packageDirs: [{ path: 'force-app', name: 'force-app', fullPath: path.join(session.project.dir, 'force-app') }],
hasSfdxTrackingFiles: false,
});
// verify the local tracking files/directories
expect(fs.existsSync(repo.gitDir));
Expand Down
1 change: 0 additions & 1 deletion test/nuts/local/relativePkgDirs.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('verifies behavior of relative pkgDirs', () => {
packageDirs: [
{ path: './force-app', name: 'force-app', fullPath: path.join(session.project.dir, './force-app') },
],
hasSfdxTrackingFiles: false,
});
// verify the local tracking files/directories
expect(fs.existsSync(repo.gitDir));
Expand Down
1 change: 0 additions & 1 deletion test/nuts/local/tracking-scale.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe(`verify tracking handles an add of ${classCount.toLocaleString()} class
orgId: 'fakeOrgId',
projectPath: session.project.dir,
packageDirs: [{ path: 'force-app', name: 'force-app', fullPath: path.join(session.project.dir, 'force-app') }],
hasSfdxTrackingFiles: false,
});
});

Expand Down
Loading

0 comments on commit 4256d01

Please sign in to comment.