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: don't cast opts to boolean #862

Merged
merged 3 commits into from
Jan 5, 2024
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
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
21 changes: 21 additions & 0 deletions test/nuts/deploy/metadata.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,47 @@
* 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 { 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 () => {
try {
await testkit.deploy({ args: '--manifest package.xml --dry-run', json: true, exitCode: 1 });
} catch (e) {
const err = e as Error;
expect(err.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