Socket
Socket
Sign inDemoInstall

@salesforce/source-deploy-retrieve

Package Overview
Dependencies
Maintainers
47
Versions
453
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/source-deploy-retrieve - npm Package Compare versions

Comparing version 12.5.1 to 12.6.0

2

lib/src/client/index.d.ts
export { MetadataApiDeploy, MetadataApiDeployOptions, DeployResult, ScopedPreDeploy, ScopedPostDeploy, } from './metadataApiDeploy';
export { MetadataApiRetrieve, RetrieveResult, ScopedPostRetrieve, ScopedPreRetrieve } from './metadataApiRetrieve';
export { ComponentDeployment, ComponentRetrieval, ComponentDiagnostic, FileResponse, FileResponseFailure, FileResponseSuccess, AsyncResult, RequestStatus, MetadataRequestStatus, RetrieveFailure, RetrieveSuccess, MetadataApiDeployStatus, DeployDetails, RunTestResult, CodeCoverage, LocationsNotCovered, CodeCoverageWarnings, Failures, Successes, DeployMessage, RetrieveRequest, RetrieveMessage, FileProperties, ComponentStatus, MetadataApiRetrieveStatus, PackageOption, PackageOptions, RetrieveOptions, DeployVersionData, RetrieveVersionData, MetadataApiRetrieveOptions, } from './types';
export { ComponentDeployment, ComponentRetrieval, ComponentDiagnostic, FileResponse, FileResponseFailure, FileResponseSuccess, AsyncResult, RequestStatus, MetadataRequestStatus, RetrieveFailure, RetrieveSuccess, MetadataApiDeployStatus, DeployDetails, RunTestResult, CodeCoverage, LocationsNotCovered, CodeCoverageWarnings, Failures, Successes, DeployMessage, RetrieveRequest, RetrieveMessage, FileProperties, ComponentStatus, MetadataApiRetrieveStatus, PackageOption, PackageOptions, RetrieveOptions, DeployVersionData, DeployZipData, RetrieveVersionData, MetadataApiRetrieveOptions, } from './types';

@@ -9,4 +9,11 @@ import { RegistryAccess } from '../registry/registryAccess';

readonly replacements: Map<string, string[]>;
readonly zipMeta?: {
zipSize: number;
zipFileCount?: number;
} | undefined;
private fileResponses?;
constructor(response: MetadataApiDeployStatus, components?: ComponentSet | undefined, replacements?: Map<string, string[]>);
constructor(response: MetadataApiDeployStatus, components?: ComponentSet | undefined, replacements?: Map<string, string[]>, zipMeta?: {
zipSize: number;
zipFileCount?: number;
} | undefined);
getFileResponses(): FileResponse[];

@@ -33,2 +40,4 @@ }

private readonly registry;
private zipSize?;
private zipFileCount?;
constructor(options: MetadataApiDeployOptions);

@@ -35,0 +44,0 @@ /**

@@ -32,7 +32,9 @@ "use strict";

replacements;
zipMeta;
fileResponses;
constructor(response, components, replacements = new Map()) {
constructor(response, components, replacements = new Map(), zipMeta) {
this.response = response;
this.components = components;
this.replacements = replacements;
this.zipMeta = zipMeta;
}

@@ -70,2 +72,4 @@ getFileResponses() {

registry;
zipSize;
zipFileCount;
constructor(options) {

@@ -165,3 +169,6 @@ super(options);

}));
const [zipBuffer] = await Promise.all([this.getZipBuffer(), this.maybeSaveTempDirectory('metadata')]);
const [{ zipBuffer, zipFileCount }] = await Promise.all([
this.getZipBuffer(),
this.maybeSaveTempDirectory('metadata'),
]);
// SDR modifies what the mdapi expects by adding a rest param

@@ -175,3 +182,12 @@ const { rest, ...optionsWithoutRest } = this.options.apiOptions ?? {};

this.logger.debug(debugMsg);
// Event and Debug output for the zip file used for deploy
this.zipSize = zipBuffer.byteLength;
let zipMessage = `Deployment zip file size = ${this.zipSize} Bytes`;
if (zipFileCount) {
this.zipFileCount = zipFileCount;
zipMessage += ` containing ${zipFileCount} files`;
}
this.logger.debug(zipMessage);
await LifecycleInstance.emit('apiVersionDeploy', { webService, manifestVersion, apiVersion });
await LifecycleInstance.emit('deployZipData', { zipSize: this.zipSize, zipFileCount });
return this.isRestDeploy

@@ -223,2 +239,4 @@ ? connection.metadata.deployRest(zipBuffer, optionsWithoutRest)

filesWithReplacementsQuantity: this.replacements.size ?? 0,
zipSize: this.zipSize ?? 0,
zipFileCount: this.zipFileCount ?? 0,
});

@@ -230,3 +248,3 @@ }

}
const deployResult = new DeployResult(result, this.components, new Map(Array.from(this.replacements).map(([k, v]) => [k, Array.from(v)])));
const deployResult = new DeployResult(result, this.components, new Map(Array.from(this.replacements).map(([k, v]) => [k, Array.from(v)])), { zipSize: this.zipSize ?? 0, zipFileCount: this.zipFileCount });
// only do event hooks if source, (NOT a metadata format) deploy

@@ -245,2 +263,3 @@ if (this.options.components) {

const mdapiPath = this.options.mdapiPath;
// Zip a directory of metadata format source
if (mdapiPath) {

@@ -251,2 +270,3 @@ if (!graceful_fs_1.default.existsSync(mdapiPath) || !graceful_fs_1.default.lstatSync(mdapiPath).isDirectory()) {

const zip = (0, jszip_1.default)();
let zipFileCount = 0;
const zipDirRecursive = (dir) => {

@@ -265,2 +285,3 @@ const dirents = graceful_fs_1.default.readdirSync(dir, { withFileTypes: true });

zip.file(relPosixPath, graceful_fs_1.default.createReadStream(fullPath));
zipFileCount++;
}

@@ -271,9 +292,12 @@ }

zipDirRecursive(mdapiPath);
return zip.generateAsync({
type: 'nodebuffer',
compression: 'DEFLATE',
compressionOptions: { level: 9 },
});
return {
zipBuffer: await zip.generateAsync({
type: 'nodebuffer',
compression: 'DEFLATE',
compressionOptions: { level: 9 },
}),
zipFileCount,
};
}
// read the zip into a buffer
// Read a zip of metadata format source into a buffer
if (this.options.zipPath) {

@@ -284,11 +308,12 @@ if (!graceful_fs_1.default.existsSync(this.options.zipPath)) {

// does encoding matter for zip files? I don't know
return graceful_fs_1.default.promises.readFile(this.options.zipPath);
return { zipBuffer: await graceful_fs_1.default.promises.readFile(this.options.zipPath) };
}
// Convert a ComponentSet of metadata in source format and zip
if (this.options.components && this.components) {
const converter = new metadataConverter_1.MetadataConverter(this.registry);
const { zipBuffer } = await converter.convert(this.components, 'metadata', { type: 'zip' });
const { zipBuffer, zipFileCount } = await converter.convert(this.components, 'metadata', { type: 'zip' });
if (!zipBuffer) {
throw new core_1.SfError(messages.getMessage('zipBufferError'));
}
return zipBuffer;
return { zipBuffer, zipFileCount };
}

@@ -295,0 +320,0 @@ throw new Error('Options should include components, zipPath, or mdapiPath');

@@ -320,2 +320,9 @@ import { RegistryAccess } from '../registry/registryAccess';

};
/**
* Data about a deployment zip file being sent to the Metadata API.
*/
export type DeployZipData = {
zipSize: number;
zipFileCount: number;
};
export type RetrieveVersionData = {

@@ -322,0 +329,0 @@ apiVersion: string;

@@ -68,3 +68,3 @@ "use strict";

if (!packagePath) {
return { packagePath, zipBuffer: buffer };
return { packagePath, zipBuffer: buffer, zipFileCount: writer.fileCount };
}

@@ -71,0 +71,0 @@ else if (buffer) {

@@ -7,2 +7,3 @@ import { Transform, Readable } from 'node:stream';

* Otherwise, you'll get the original readable stream
* Ignore binary files, they will get corrupted in the replacement process
*/

@@ -9,0 +10,0 @@ export declare const getReplacementStreamForReadable: (component: SourceComponent, path: SourcePath) => Readable | ReplacementStream;

@@ -17,9 +17,15 @@ "use strict";

const ts_types_1 = require("@salesforce/ts-types");
const isbinaryfile_1 = require("isbinaryfile");
;
const messages = new core_1.Messages('@salesforce/source-deploy-retrieve', 'sdr', new Map([["md_request_fail", "Metadata API request failed: %s"], ["error_convert_invalid_format", "Invalid conversion format '%s'"], ["error_could_not_infer_type", "%s: Could not infer a metadata type"], ["error_unexpected_child_type", "Unexpected child metadata [%s] found for parent type [%s]"], ["noParent", "Could not find parent type for %s (%s)"], ["error_expected_source_files", "%s: Expected source files for type '%s'"], ["error_failed_convert", "Component conversion failed: %s"], ["error_merge_metadata_target_unsupported", "Merge convert for metadata target format currently unsupported"], ["error_missing_adapter", "Missing adapter '%s' for metadata type '%s'"], ["error_missing_transformer", "Missing transformer '%s' for metadata type '%s'"], ["error_missing_type_definition", "Missing metadata type definition in registry for id '%s'."], ["error_missing_child_type_definition", "Type %s does not have a child type definition %s."], ["noChildTypes", "No child types found in registry for %s (reading %s at %s)"], ["error_no_metadata_xml_ignore", "Metadata xml file %s is forceignored but is required for %s."], ["noSourceIgnore", "%s metadata types require source files, but %s is forceignored."], ["noSourceIgnore.actions", "- Metadata types with content are composed of two files: a content file (ie MyApexClass.cls) and a -meta.xml file (i.e MyApexClass.cls-meta.xml). You must include both files in your .forceignore file. Or try appending \u201C\\*\u201D to your existing .forceignore entry.\n\nSee <https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm> for examples"], ["error_path_not_found", "%s: File or folder not found"], ["noContentFound", "SourceComponent %s (metadata type = %s) is missing its content file."], ["noContentFound.actions", ["Ensure the content file exists in the expected location.", "If the content file is in your .forceignore file, ensure the meta-xml file is also ignored to completely exclude it."]], ["error_parsing_xml", "SourceComponent %s (metadata type = %s) does not have an associated metadata xml to parse"], ["error_expected_file_path", "%s: path is to a directory, expected a file"], ["error_expected_directory_path", "%s: path is to a file, expected a directory"], ["error_directory_not_found_or_not_directory", "%s: path is not a directory"], ["error_no_directory_stream", "%s doesn't support readable streams on directories."], ["error_no_source_to_deploy", "No source-backed components present in the package."], ["error_no_components_to_retrieve", "No components in the package to retrieve."], ["error_static_resource_expected_archive_type", "A StaticResource directory must have a content type of application/zip or application/jar - found %s for %s."], ["error_static_resource_missing_resource_file", "A StaticResource must have an associated .resource file, missing %s.resource-meta.xml"], ["error_no_job_id", "The %s operation is missing a job ID. Initialize an operation with an ID, or start a new job."], ["missingApiVersion", "Could not determine an API version to use for the generated manifest. Tried looking for sourceApiVersion in sfdx-project.json, apiVersion from config vars, and the highest apiVersion from the APEX REST endpoint. Using API version 58.0 as a last resort."], ["invalid_xml_parsing", "error parsing %s due to:\\n message: %s\\n line: %s\\n code: %s"], ["zipBufferError", "Zip buffer was not created during conversion"], ["undefinedComponentSet", "Unable to construct a componentSet. Check the logs for more information."], ["replacementsFileNotRead", "The file \"%s\" specified in the \"replacements\" property of sfdx-project.json could not be read."], ["unsupportedBundleType", "Unsupported Bundle Type: %s"], ["filePathGeneratorNoTypeSupport", "Type not supported for filepath generation: %s"], ["missingFolderType", "The registry has %s as is inFolder but it does not have a folderType"], ["tooManyFiles", "Multiple files found for path: %s."], ["cantGetName", "Unable to calculate fullName from path: %s (%s)"], ["missingMetaFileSuffix", "The metadata registry is configured incorrectly for %s. Expected a metaFileSuffix."], ["uniqueIdElementNotInRegistry", "No uniqueIdElement found in registry for %s (reading %s at %s)."], ["uniqueIdElementNotInChild", "The uniqueIdElement %s was not found the child (reading %s at %s)."], ["suggest_type_header", "A metadata type lookup for \"%s\" found the following close matches:"], ["suggest_type_did_you_mean", "-- Did you mean \".%s%s\" instead for the \"%s\" metadata type?"], ["suggest_type_more_suggestions", "Additional suggestions:\nConfirm the file name, extension, and directory names are correct. Validate against the registry at:\n<https://github.com/forcedotcom/source-deploy-retrieve/blob/main/src/registry/metadataRegistry.json>\n\nIf the type is not listed in the registry, check that it has Metadata API support via the Metadata Coverage Report:\n<https://developer.salesforce.com/docs/metadata-coverage>\n\nIf the type is available via Metadata API but not in the registry\n\n- Open an issue <https://github.com/forcedotcom/cli/issues>\n- Add the type via PR. Instructions: <https://github.com/forcedotcom/source-deploy-retrieve/blob/main/contributing/metadata.md>"], ["type_name_suggestions", "Confirm the metadata type name is correct. Validate against the registry at:\n<https://github.com/forcedotcom/source-deploy-retrieve/blob/main/src/registry/metadataRegistry.json>\n\nIf the type is not listed in the registry, check that it has Metadata API support via the Metadata Coverage Report:\n<https://developer.salesforce.com/docs/metadata-coverage>\n\nIf the type is available via Metadata API but not in the registry\n\n- Open an issue <https://github.com/forcedotcom/cli/issues>\n- Add the type via PR. Instructions: <https://github.com/forcedotcom/source-deploy-retrieve/blob/main/contributing/metadata.md>"]]));
const fileContentsCache = new Map();
// First do a quick check for common text extensions
// If that fails, confirm that it is not a binary file
const textExtensions = new Set(['.cls', '.xml', '.json', '.js', '.css', '.html', '.htm', '.txt', '.md']);
const isTextFile = (path) => textExtensions.has((0, node_path_1.extname)(path)) || !(0, isbinaryfile_1.isBinaryFileSync)(path);
/** If a component has replacements, you get it piped through the replacementStream
* Otherwise, you'll get the original readable stream
* Ignore binary files, they will get corrupted in the replacement process
*/
const getReplacementStreamForReadable = (component, path) => component.replacements?.[path]
const getReplacementStreamForReadable = (component, path) => component.replacements?.[path] && isTextFile(path)
? component.tree.stream(path).pipe(new ReplacementStream(component.replacements?.[path]))

@@ -26,0 +32,0 @@ : component.tree.stream(path);

@@ -42,2 +42,6 @@ import { pipeline as cbPipeline, Readable, Stream, Transform, Writable } from 'node:stream';

export declare class ZipWriter extends ComponentWriter {
/**
* Count of files (not directories) added to the zip file.
*/
fileCount: number;
private zip;

@@ -44,0 +48,0 @@ private zipBuffer?;

@@ -173,2 +173,6 @@ "use strict";

class ZipWriter extends ComponentWriter {
/**
* Count of files (not directories) added to the zip file.
*/
fileCount = 0;
zip = (0, jszip_1.default)();

@@ -222,2 +226,3 @@ zipBuffer;

this.zip.file(posixPath, contents);
this.fileCount++;
}

@@ -224,0 +229,0 @@ }

@@ -94,2 +94,6 @@ import { Readable } from 'node:stream';

/**
* When a zip buffer is created, this is the number of files in the zip.
*/
zipFileCount?: number;
/**
* Converted source components. Not set if archiving the package.

@@ -96,0 +100,0 @@ */

@@ -1,2 +0,2 @@

export { MetadataApiDeploy, MetadataApiDeployOptions, DeployResult, ScopedPreDeploy, ScopedPostDeploy, ScopedPreRetrieve, ScopedPostRetrieve, MetadataApiRetrieve, MetadataApiRetrieveOptions, RetrieveResult, ComponentDeployment, ComponentRetrieval, ComponentDiagnostic, FileResponse, FileResponseFailure, FileResponseSuccess, AsyncResult, RequestStatus, MetadataRequestStatus, RetrieveFailure, RetrieveSuccess, MetadataApiDeployStatus, DeployDetails, RunTestResult, CodeCoverage, LocationsNotCovered, CodeCoverageWarnings, Failures, Successes, DeployMessage, RetrieveRequest, RetrieveMessage, FileProperties, ComponentStatus, MetadataApiRetrieveStatus, PackageOption, PackageOptions, RetrieveOptions, DeployVersionData, RetrieveVersionData, } from './client';
export { MetadataApiDeploy, MetadataApiDeployOptions, DeployResult, ScopedPreDeploy, ScopedPostDeploy, ScopedPreRetrieve, ScopedPostRetrieve, MetadataApiRetrieve, MetadataApiRetrieveOptions, RetrieveResult, ComponentDeployment, ComponentRetrieval, ComponentDiagnostic, FileResponse, FileResponseFailure, FileResponseSuccess, AsyncResult, RequestStatus, MetadataRequestStatus, RetrieveFailure, RetrieveSuccess, MetadataApiDeployStatus, DeployDetails, RunTestResult, CodeCoverage, LocationsNotCovered, CodeCoverageWarnings, Failures, Successes, DeployMessage, RetrieveRequest, RetrieveMessage, FileProperties, ComponentStatus, MetadataApiRetrieveStatus, PackageOption, PackageOptions, RetrieveOptions, DeployVersionData, DeployZipData, RetrieveVersionData, } from './client';
export { MetadataConverter, WriteInfo, WriterFormat, DirectoryConfig, ZipConfig, MergeConfig, MetadataTransformer, SfdxFileFormat, ConvertOutputConfig, ConvertResult, } from './convert';

@@ -3,0 +3,0 @@ export { MetadataResolver, ManifestResolver, ConnectionResolver, TreeContainer, NodeFSTreeContainer, VirtualTreeContainer, ZipTreeContainer, SourceComponent, MetadataComponent, MetadataMember, ComponentLike, MetadataXml, VirtualFile, VirtualDirectory, SourceAdapter, ForceIgnore, } from './resolve';

{
"name": "@salesforce/source-deploy-retrieve",
"version": "12.5.1",
"version": "12.6.0",
"description": "JavaScript library to run Salesforce metadata deploys and retrieves",

@@ -36,2 +36,3 @@ "main": "lib/src/index.js",

"ignore": "^5.3.2",
"isbinaryfile": "^5.0.2",
"jszip": "^3.10.1",

@@ -38,0 +39,0 @@ "mime": "2.6.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc