Skip to content

Commit

Permalink
fix: don't cast opts to boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jan 2, 2024
1 parent 5cb4d0f commit 2bc7ea7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/



import { ConfigAggregator, Messages, Org, SfError, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { Nullable } from '@salesforce/ts-types';
Expand All @@ -26,7 +24,7 @@ import { DEPLOY_STATUS_CODES } from './errorCodes.js';
import { DeployCache } from './deployCache.js';
import { writeManifest } from './manifestCache.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
export const cacheMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'cache');

const deployMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');
Expand Down Expand Up @@ -156,7 +154,7 @@ export async function executeDeploy(
});
componentSet = await buildComponentSet(opts, stl);
if (componentSet.size === 0) {
if (Boolean(opts['source-dir']) ?? Boolean(opts.manifest) ?? Boolean(opts.metadata) ?? throwOnEmpty) {
if (opts['source-dir'] ?? opts.manifest ?? opts.metadata ?? throwOnEmpty) {
// the user specified something to deploy, but there isn't anything
throw new SfError(
deployMessages.getMessage('error.nothingToDeploy'),
Expand Down
20 changes: 20 additions & 0 deletions test/nuts/deploy/metadata.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,46 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { join } from 'node:path';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { expect } from 'chai';
import { SourceTestkit } from '@salesforce/source-testkit';
import { SfError } from '@salesforce/core';
import { DeployResultJson } from '../../../src/utils/types.js';

const packageXml = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>59.0</version>
</Package>
`;

describe('deploy metadata NUTs', () => {
let testkit: SourceTestkit;
const packageFile = 'package.xml';
let xmlPath: string | undefined;

before(async () => {
testkit = await SourceTestkit.create({
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
nut: fileURLToPath(import.meta.url),
});
await testkit.deploy({ args: '--source-dir force-app', exitCode: 0 });
xmlPath = join(testkit.projectDir, packageFile);
await fs.promises.writeFile(xmlPath, packageXml);
});

after(async () => {
await testkit?.clean();
});

it('should throw if component set is empty', async () => {
const response = await testkit.deploy({ args: '' });
expect(response?.status).to.equal(1);
const result = response?.result as unknown as SfError;
expect(result.name).to.equal('NothingToDeploy');
});

it('should deploy ApexClasses from wildcard match (single character)', async () => {
const response = await testkit.deploy({ args: '--metadata "ApexClass:P*"' });
expect(response?.status).to.equal(0);
Expand Down

0 comments on commit 2bc7ea7

Please sign in to comment.