diff --git a/src/utils/deploy.ts b/src/utils/deploy.ts index ac4a5ee2..bedc5cea 100644 --- a/src/utils/deploy.ts +++ b/src/utils/deploy.ts @@ -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'; @@ -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'); @@ -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'), diff --git a/test/nuts/deploy/metadata.nut.ts b/test/nuts/deploy/metadata.nut.ts index dfa818f8..bba4bd67 100644 --- a/test/nuts/deploy/metadata.nut.ts +++ b/test/nuts/deploy/metadata.nut.ts @@ -5,13 +5,23 @@ * 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 = ` + + 59.0 + +`; + describe('deploy metadata NUTs', () => { let testkit: SourceTestkit; + const packageFile = 'package.xml'; + let xmlPath: string | undefined; before(async () => { testkit = await SourceTestkit.create({ @@ -19,12 +29,23 @@ describe('deploy metadata NUTs', () => { 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);