@salesforce/packaging
Version:
Packaging library for the Salesforce packaging platform
53 lines • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPackageDirEntry = createPackageDirEntry;
exports.createBundle = createBundle;
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const core_1 = require("@salesforce/core");
const bundleUtils_1 = require("../utils/bundleUtils");
core_1.Messages.importMessagesDirectory(__dirname);
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_create');
function createPackageDirEntry(project, options) {
return {
versionName: 'ver 0.1',
versionNumber: '0.1',
name: options.BundleName,
versionDescription: options.Description,
};
}
async function createBundle(connection, project, options) {
const request = { BundleName: options.BundleName, Description: options.Description };
let createResult;
try {
createResult = await connection.tooling.sobject('PackageBundle').create(request);
}
catch (err) {
const error = err instanceof Error
? err
: new Error(typeof err === 'string' ? err : messages.getMessage('failedToCreatePackageBundle'));
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
}
if (!createResult?.success) {
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(new Error(messages.getMessage('failedToCreatePackageBundle'))));
}
const bundleEntry = createPackageDirEntry(project, options);
project.getSfProjectJson().addPackageBundle(bundleEntry);
project.getSfProjectJson().addPackageBundleAlias(bundleEntry.name, createResult.id);
await project.getSfProjectJson().write();
return { Id: createResult.id };
}
//# sourceMappingURL=packageBundleCreate.js.map