Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sm/remove-jsforce
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 7, 2023
2 parents 4abe1d1 + 3ddbe62 commit 39274dd
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 40 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"dependencies": {
"@oclif/core": "^2.15.0",
"@salesforce/apex-node": "^2.1.0",
"@salesforce/core": "^5.3.16",
"@salesforce/core": "^5.3.18",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^3.1.22",
"@salesforce/source-deploy-retrieve": "^9.8.1",
"@salesforce/source-tracking": "^4.2.20",
"@salesforce/source-deploy-retrieve": "^9.8.4",
"@salesforce/source-tracking": "^4.3.0",
"chalk": "^4.1.2",
"tslib": "^2"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.12",
"@salesforce/cli-plugins-testkit": "^4.4.12",
"@salesforce/cli-plugins-testkit": "^5.0.2",
"@salesforce/dev-scripts": "^6.0.3",
"@salesforce/plugin-command-reference": "^3.0.40",
"@salesforce/plugin-settings": "^1.4.37",
Expand All @@ -29,7 +29,7 @@
"@salesforce/ts-types": "^2.0.8",
"@swc/core": "1.3.39",
"cross-env": "^7.0.3",
"eslint-plugin-sf-plugin": "^1.16.13",
"eslint-plugin-sf-plugin": "^1.16.14",
"oclif": "^3.16.0",
"shx": "0.3.4",
"ts-node": "^10.9.1",
Expand Down
19 changes: 10 additions & 9 deletions test/nuts/delete/source.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('CustomLabels', () => {
scratchOrgs: [{ setDefault: true, config: path.join('config', 'project-scratch-def.json') }],
devhubAuthStrategy: 'AUTO',
});
execCmd('force:source:deploy --sourcepath force-app', { ensureExitCode: 0 });
execCmd('project:deploy:start --source-dir force-app', { ensureExitCode: 0 });
});

after(async () => {
Expand Down Expand Up @@ -101,8 +101,9 @@ describe('project delete source NUTs', () => {
const pathToClass = path.join(testkit.projectDir, output, `${apexName}.cls`);
execCmd(`force:apex:class:create --classname ${apexName} --outputdir ${output} --api-version 58.0`, {
ensureExitCode: 0,
cli: 'sf',
});
execCmd(`force:source:deploy -m ApexClass:${apexName}`, { ensureExitCode: 0 });
execCmd(`project:deploy:start -m ApexClass:${apexName}`, { ensureExitCode: 0 });
return { apexName, output, pathToClass };
};

Expand All @@ -111,7 +112,7 @@ describe('project delete source NUTs', () => {
nut: __filename,
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
});
execCmd('force:source:deploy --sourcepath force-app', { ensureExitCode: 0 });
execCmd('project:deploy:start --source-dir force-app', { ensureExitCode: 0 });
});

after(async () => {
Expand Down Expand Up @@ -184,8 +185,8 @@ describe('project delete source NUTs', () => {
const { apexName, pathToClass } = createApexClass();
const query = () =>
execCmd<{ records: Array<{ IsNameObsolete: boolean }> }>(
`sf data:query -q "SELECT IsNameObsolete FROM SourceMember WHERE MemberType='ApexClass' AND MemberName='${apexName}' LIMIT 1" -t --json`,
{ silent: true, cli: 'sf' }
`data:query -q "SELECT IsNameObsolete FROM SourceMember WHERE MemberType='ApexClass' AND MemberName='${apexName}' LIMIT 1" -t --json`,
{ silent: true, cli: 'sf', ensureExitCode: 0 }
);

let soql = query().jsonOutput?.result;
Expand Down Expand Up @@ -238,7 +239,7 @@ describe('project delete source NUTs', () => {
// use the brokerCard LWC
const lwcPath = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc', 'brokerCard', 'helper.js');
fs.writeFileSync(lwcPath, '//', { encoding: 'utf8' });
execCmd(`force:source:deploy -p ${lwcPath}`);
execCmd(`project:deploy:start --source-dir ${lwcPath}`, { cli: 'sf', ensureExitCode: 0 });
const deleteResult = execCmd<{ deletedSource: [FileResponse] }>(
`project:delete:source -p ${lwcPath} --no-prompt --json`
).jsonOutput?.result;
Expand All @@ -258,7 +259,7 @@ describe('project delete source NUTs', () => {
const lwcPath2 = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc', 'daysOnMarket', 'helper.js');
fs.writeFileSync(lwcPath1, '//', { encoding: 'utf8' });
fs.writeFileSync(lwcPath2, '//', { encoding: 'utf8' });
execCmd(`force:source:deploy -p ${lwcPath1},${lwcPath2}`);
execCmd(`project:deploy:start --source-dir ${lwcPath1} --source-dir ${lwcPath2}`);
// delete both helper.js files at the same time
const deleteResult = execCmd<{ deletedSource: FileResponse[] }>(
// eslint-disable-next-line sf-plugin/no-execcmd-double-quotes
Expand All @@ -283,8 +284,8 @@ describe('project delete source NUTs', () => {
it('should delete an entire LWC', async () => {
const lwcPath = path.join(testkit.projectDir, 'force-app', 'main', 'default', 'lwc');
const mylwcPath = path.join(lwcPath, 'mylwc');
execCmd(`force:lightning:component:create -n mylwc --type lwc -d ${lwcPath}`);
execCmd(`force:source:deploy -p ${mylwcPath}`);
execCmd(`force:lightning:component:create -n mylwc --type lwc -d ${lwcPath}`, { cli: 'sf', ensureExitCode: 0 });
execCmd(`project:deploy:start --source-dir ${mylwcPath}`);
expect(await isNameObsolete(testkit.username, 'LightningComponentBundle', 'mylwc')).to.be.false;
const deleteResult = execCmd<{ deletedSource: [FileResponse] }>(
`project:delete:source -p ${mylwcPath} --no-prompt --json`
Expand Down
1 change: 1 addition & 0 deletions test/nuts/destructive/destructiveChanges.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('project deploy start --destructive NUTs', () => {
const pathToClass = path.join(testkit.projectDir, output, `${apexName}.cls`);
execCmd(`force:apex:class:create --classname ${apexName} --outputdir ${output} --api-version 58.0`, {
ensureExitCode: 0,
cli: 'sf',
});
execCmd(`project:deploy:start -m ApexClass:${apexName}`, { ensureExitCode: 0 });
return { apexName, output, pathToClass };
Expand Down
10 changes: 10 additions & 0 deletions test/nuts/tracking/basics.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('detects the initial metadata status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
assert(Array.isArray(result));
// the fields should be populated
Expand Down Expand Up @@ -92,11 +93,13 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes (all were committed from push), but profile updated in remote', () => {
const localResult = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localResult?.filter(filterIgnored)).to.deep.equal([]);

const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.some((item) => item.type === 'Profile')).to.equal(true);
});
Expand All @@ -110,6 +113,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sf sees no remote changes (all were committed from push) except Profile', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.some((item) => item.type === 'Profile')).to.equal(true);
});
Expand All @@ -127,6 +131,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local or remote changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter((r) => r.type === 'Profile').filter(filterIgnored), JSON.stringify(result)).to.have.length(
0
Expand Down Expand Up @@ -155,6 +160,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
]);
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored)).to.deep.equal([
{
Expand Down Expand Up @@ -199,6 +205,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('does not see any change in remote status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.filter((r) => r.fullName === 'TestOrderController'),
Expand All @@ -224,6 +231,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored), JSON.stringify(result)).to.be.an.instanceof(Array).with.length(0);
});
Expand All @@ -243,6 +251,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
assert(hubUsername, 'hubUsername should be defined');
const failure = execCmd(`force:source:status -u ${hubUsername} --remote --json`, {
ensureExitCode: 1,
cli: 'sf',
}).jsonOutput as unknown as { name: string };
// command5 is removing `Error` from the end of the error names.
expect(failure.name).to.include('NonSourceTrackedOrg');
Expand Down Expand Up @@ -281,6 +290,7 @@ describe('end-to-end-test for tracking with an org (single packageDir)', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored), JSON.stringify(result)).to.be.an.instanceof(Array).with.length(2);
});
Expand Down
2 changes: 2 additions & 0 deletions test/nuts/tracking/conflicts.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('conflict detection and resolution', () => {
});
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.filter((r) => r.type === 'CustomApplication'),
Expand All @@ -99,6 +100,7 @@ describe('conflict detection and resolution', () => {
it('can see the conflict in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result.filter((app) => app.type === 'CustomApplication');
// json is not sorted. This relies on the implementation of getConflicts()
expect(result).to.deep.equal([
Expand Down
3 changes: 2 additions & 1 deletion test/nuts/tracking/deleteResetTracking.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('reset and clear tracking', () => {
it('runs status to start tracking', () => {
const result = execCmd('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result).to.have.length.greaterThan(100); // ebikes is big
});
Expand Down Expand Up @@ -109,7 +110,7 @@ describe('reset and clear tracking', () => {
}
});
// gets tracking files from server
execCmd('force:source:status --json --remote', { ensureExitCode: 0 });
execCmd('force:source:status --json --remote', { ensureExitCode: 0, cli: 'sf' });
const revisions = await getRevisionsAsArray();
const revisionFile = JSON.parse(
await fs.promises.readFile(path.join(trackingFileFolder, 'maxRevision.json'), 'utf8')
Expand Down
6 changes: 4 additions & 2 deletions test/nuts/tracking/forceIgnore.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('forceignore changes', () => {
});

execCmd(`force:apex:class:create -n IgnoreTest --outputdir ${classdir} --api-version 58.0`, {
cli: 'sfdx',
ensureExitCode: 0,
cli: 'sf',
});
originalForceIgnore = await fs.promises.readFile(path.join(session.project.dir, '.forceignore'), 'utf8');
conn = await Connection.create({
Expand Down Expand Up @@ -72,6 +72,7 @@ describe('forceignore changes', () => {
it('shows the file in status as ignored', () => {
const output = execCmd<StatusResult>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(output, JSON.stringify(output)).to.deep.include({
state: 'Local Add',
Expand Down Expand Up @@ -106,7 +107,7 @@ describe('forceignore changes', () => {
await fs.promises.writeFile(path.join(session.project.dir, '.forceignore'), newForceIgnore);

// add a file in the local source
execCmd(`sfdx force:apex:class:create -n UnIgnoreTest --outputdir ${classdir} --api-version 58.0`, {
execCmd(`force:apex:class:create -n UnIgnoreTest --outputdir ${classdir} --api-version 58.0`, {
cwd: session.project.dir,
silent: true,
cli: 'sf',
Expand Down Expand Up @@ -157,6 +158,7 @@ describe('forceignore changes', () => {
// gets file into source tracking
const statusOutput = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(statusOutput?.some((result) => result.fullName === 'CreatedClass')).to.equal(true);
});
Expand Down
6 changes: 6 additions & 0 deletions test/nuts/tracking/lwc.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('lwc', () => {
);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.find((r) => r.filePath === cssPathRelative)).to.have.property('actualState', 'Changed');
});
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('lwc', () => {
it('sfdx sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand All @@ -106,6 +108,7 @@ describe('lwc', () => {
await fs.promises.rm(cssPathAbsolute);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter(filterIgnored)
.find((r) => r.filePath === cssPathRelative);
Expand Down Expand Up @@ -137,6 +140,7 @@ describe('lwc', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand Down Expand Up @@ -167,6 +171,7 @@ describe('lwc', () => {
);
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result.filter((r) => r.origin === 'Local');
assert(result);
expect(result.filter(filterIgnored)).to.have.length(4);
Expand All @@ -190,6 +195,7 @@ describe('lwc', () => {
it('sees no local changes', () => {
const result = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
cli: 'sf',
})
.jsonOutput?.result.filter((r) => r.origin === 'Local')
.filter(filterIgnored);
Expand Down
8 changes: 8 additions & 0 deletions test/nuts/tracking/remoteChanges.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('remote changes', () => {
it('sees no local changes (all were committed from deploy)', () => {
const localResult = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localResult?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('remote changes', () => {
it('sfdx can see the delete in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
// it shows up as one class on the server, but 2 files when pulled
expect(
Expand All @@ -125,6 +127,7 @@ describe('remote changes', () => {
it('sfdx does not see any change in local status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(result?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -159,11 +162,13 @@ describe('remote changes', () => {
it('sees correct local and remote status', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(remoteResult?.filter((r) => r.state.includes('Remote Deleted'))).to.deep.equal([]);

const localStatus = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localStatus?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down Expand Up @@ -197,6 +202,7 @@ describe('remote changes', () => {
it('can see the add in status', () => {
const result = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
result?.some((r) => r.fullName === className),
Expand Down Expand Up @@ -224,6 +230,7 @@ describe('remote changes', () => {
it('sfdx sees correct remote status', () => {
const remoteResult = execCmd<StatusResult[]>('force:source:status --json --remote', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(
remoteResult?.filter((r) => r.fullName === className),
Expand All @@ -233,6 +240,7 @@ describe('remote changes', () => {
it('sfdx sees correct local status', () => {
const localStatus = execCmd<StatusResult[]>('force:source:status --json --local', {
ensureExitCode: 0,
cli: 'sf',
}).jsonOutput?.result;
expect(localStatus?.filter(filterIgnored)).to.deep.equal([]);
});
Expand Down
Loading

0 comments on commit 39274dd

Please sign in to comment.