Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include deleted files in FileResponses for retrieves #296

Merged
merged 7 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 142 additions & 307 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
],
"dependencies": {
"@salesforce/core": "^3.32.12",
"@salesforce/kit": "^1.8.1",
"@salesforce/source-deploy-retrieve": "^7.5.22",
"@salesforce/kit": "^1.8.3",
"@salesforce/source-deploy-retrieve": "^7.7.3",
"graceful-fs": "^4.2.10",
"isomorphic-git": "1.17.0",
"ts-retry-promise": "^0.7.0"
Expand Down
9 changes: 8 additions & 1 deletion src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,14 @@ export class SourceTracking extends AsyncCreatable {
await Promise.all([
this.updateLocalTracking({
// assertion allowed because it's filtering out undefined
files: successes.map((fileResponse) => fileResponse.filePath as string).filter(Boolean),
files: successes
.filter((fileResponse) => fileResponse.state !== ComponentStatus.Deleted)
.map((fileResponse) => fileResponse.filePath as string)
.filter(Boolean),
deletedFiles: successes
shetzel marked this conversation as resolved.
Show resolved Hide resolved
.filter((fileResponse) => fileResponse.state === ComponentStatus.Deleted)
.map((fileResponse) => fileResponse.filePath as string)
.filter(Boolean),
}),
this.updateRemoteTracking(
successes.map(({ state, fullName, type, filePath }) => ({ state, fullName, type, filePath })),
Expand Down
4 changes: 2 additions & 2 deletions test/nuts/mpd.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import * as fs from 'fs';
import { TestSession } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
import { Org, SfProject } from '@salesforce/core';
import { getString } from '@salesforce/ts-types';
import { SourceTracking } from '../../src/sourceTracking';

const getSTLInstance = async (session: TestSession): Promise<SourceTracking> =>
SourceTracking.create({
org: await Org.create({ aliasOrUsername: getString(session, 'setup[0].result.username') }),
org: await Org.create({ aliasOrUsername: session.orgs.get('default')?.username }),
project: await SfProject.resolve(session.project.dir),
});

Expand All @@ -35,6 +34,7 @@ describe('sourceTracking: localChangesAsComponentSet', () => {
setDefault: true,
},
],
devhubAuthStrategy: 'AUTO',
});
stl = await getSTLInstance(session);
// these 2 lines help debug path issues in
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "@salesforce/dev-config/tsconfig-test",
"include": ["./**/*.ts"],
"compilerOptions": {
"skipLibCheck": true
"skipLibCheck": true,
"strictNullChecks": true
}
}
16 changes: 10 additions & 6 deletions test/unit/conflicts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import { ForceIgnore, ComponentSet } from '@salesforce/source-deploy-retrieve';
import { findConflictsInComponentSet, getDedupedConflictsFromChanges } from '../../src/shared/conflicts';
import { ChangeResult } from '../../src/shared/types';

const clsFullName = 'MyClass';
const clsType = 'ApexClass';
const file1cls = 'foo/classes/MyClass.cls';
const file1meta = 'foo/classes/MyClass.cls-meta.xml';
const class1Local: ChangeResult = {
origin: 'local',
name: 'MyClass',
type: 'ApexClass',
filenames: ['foo/classes/MyClass.cls', 'foo/classes/MyClass.cls-meta.xml'],
name: clsFullName,
type: clsType,
filenames: [file1cls, file1meta],
};

describe('conflicts functions', () => {
Expand All @@ -28,16 +32,16 @@ describe('conflicts functions', () => {

describe('filter component set', () => {
it('matches a conflict in a component set', () => {
const cs = new ComponentSet([{ fullName: class1Local.name, type: class1Local.type }]);
const cs = new ComponentSet([{ fullName: clsFullName, type: clsType }]);
expect(findConflictsInComponentSet(cs, [class1Local])).to.deep.equal([
{
filePath: path.join(__dirname, '..', '..', class1Local.filenames[0]),
filePath: path.join(__dirname, '..', '..', file1cls),
fullName: class1Local.name,
state: 'Conflict',
type: class1Local.type,
},
{
filePath: path.join(__dirname, '..', '..', class1Local.filenames[1]),
filePath: path.join(__dirname, '..', '..', file1meta),
fullName: class1Local.name,
state: 'Conflict',
type: class1Local.type,
Expand Down
10 changes: 7 additions & 3 deletions test/unit/expectedSourceMembers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ describe('expectedSourceMembers', () => {
const result = calculateExpectedSourceMembers(input);
expect(result.size).to.equal(1);
// fields return object, field for their keys
expect(result.get(getMetadataKeyFromFileResponse(input[2]).find((f) => f.startsWith('CustomField')))).to.deep.equal(
input[2]
);
const input2 = getMetadataKeyFromFileResponse(input[2]);
const mdKey = input2.find((f) => f.startsWith('CustomField'));
if (mdKey) {
expect(result.get(mdKey)).to.deep.equal(input[2]);
} else {
expect(false, 'CustomField metadata not found');
}
});

it('omits aura xml types', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/localShadowRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ afterEach(() => {

describe('localShadowRepo', () => {
it('does not add same file multiple times', async () => {
let projectDir: string;
let projectDir!: string;
try {
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));
fs.mkdirSync(path.join(projectDir, 'force-app'));
Expand Down
2 changes: 2 additions & 0 deletions test/unit/remoteSourceTracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ describe('remoteSourceTrackingService', () => {
describe('init', () => {
it('should set initial state of contents', async () => {
$$.SANDBOX.stub(remoteSourceTrackingService, 'getContents').returns({
// @ts-ignore
serverMaxRevisionCounter: null,
// @ts-ignore
sourceMembers: null,
}) as SinonStub;
// @ts-ignore
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./node_modules/@salesforce/dev-config/tsconfig-strict",
"compilerOptions": {
"outDir": "./lib",
"skipLibCheck": true
"skipLibCheck": true,
"strictNullChecks": true
},
"include": ["src/**/*.ts"]
}
Loading