From 78d6158b7772b029a486a40be4e56673aa56fcb3 Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Wed, 28 Jan 2026 16:57:49 -0800 Subject: [PATCH 1/3] feat: add --generate-dev-zip flag to version create --- messages/package_version_create.md | 8 ++++++++ src/commands/package/version/create.ts | 5 +++++ yarn.lock | 17 +---------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/messages/package_version_create.md b/messages/package_version_create.md index d510a399..91964a9a 100644 --- a/messages/package_version_create.md +++ b/messages/package_version_create.md @@ -145,6 +145,14 @@ Return a new package version before completing package validations. Specifying async validation returns the package version earlier in the process, allowing you to install and test the new version right away. If your development team is using continuous integration (CI) scripts, async validation can reduce your overall CI run time. +# flags.generate-pkg-zip.summary + +Request the package zip file for development use. + +# flags.generate-pkg-zip.description + +When set to true, generates a package zip file for development use. This file can be used for debugging or examining the package contents. + # flags.skip-ancestor-check.summary Overrides ancestry requirements, which allows you to specify a package ancestor that isn’t the highest released package version. diff --git a/src/commands/package/version/create.ts b/src/commands/package/version/create.ts index c8dd23b8..027c753b 100644 --- a/src/commands/package/version/create.ts +++ b/src/commands/package/version/create.ts @@ -142,6 +142,11 @@ export class PackageVersionCreateCommand extends SfCommand Date: Wed, 28 Jan 2026 17:05:50 -0800 Subject: [PATCH 2/3] test: dev-zip flag test on managed package chore: update snapshot chore: add flag in correct place of command-snapshot chore: correct placement of flag chore: move flag to version:create flags chore: update docs from TW feedback chore: remove description prop from flag test: nut for create version with flag and md retrieve test: use packageId instead of name for version creation test: try NUTS again after packaging changes merged test: use existing managed package for --generate-pkg-zip test chore: update dependencies test: establish auth with TestSession first test: add debugging log to see if flag set on request test: fix package name for CI dh --- command-snapshot.json | 3 +- messages/package_version_create.md | 8 +- src/commands/package/version/create.ts | 1 - .../packageVersionCreateManaged.nut.ts | 134 ++++++++++++++++++ yarn.lock | 8 +- 5 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 test/commands/package/packageVersionCreateManaged.nut.ts diff --git a/command-snapshot.json b/command-snapshot.json index 9c077e54..d5a270c9 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -432,7 +432,8 @@ "version-description", "version-name", "version-number", - "wait" + "wait", + "generate-pkg-zip" ], "plugin": "@salesforce/plugin-packaging" }, diff --git a/messages/package_version_create.md b/messages/package_version_create.md index 91964a9a..fb6e0b93 100644 --- a/messages/package_version_create.md +++ b/messages/package_version_create.md @@ -147,15 +147,11 @@ Specifying async validation returns the package version earlier in the process, # flags.generate-pkg-zip.summary -Request the package zip file for development use. - -# flags.generate-pkg-zip.description - -When set to true, generates a package zip file for development use. This file can be used for debugging or examining the package contents. +Generate a package ZIP file that you can use for debugging or to examine the package contents. # flags.skip-ancestor-check.summary -Overrides ancestry requirements, which allows you to specify a package ancestor that isn’t the highest released package version. +Override ancestry requirements, which allows you to specify a package ancestor that isn’t the highest released package version. # flags.post-install-url.summary diff --git a/src/commands/package/version/create.ts b/src/commands/package/version/create.ts index 027c753b..40b42376 100644 --- a/src/commands/package/version/create.ts +++ b/src/commands/package/version/create.ts @@ -144,7 +144,6 @@ export class PackageVersionCreateCommand extends SfCommand { + let session: TestSession; + let managedPackageId: string; + + before('setup managed package', async function () { + this.timeout(Duration.minutes(5).milliseconds); + + session = await TestSession.create({ + devhubAuthStrategy: 'AUTO', + project: { name: 'managed-pkg-test' }, + }); + + devHubOrg = await Org.create({ aliasOrUsername: session.hubOrg.username }); + + // Query for existing managed package + const existingPkgQuery = ` + SELECT Id, Name, NamespacePrefix + FROM Package2 + WHERE ContainerOptions = 'Managed' + AND IsDeprecated = false + AND Name = 'pnhmanaged' + LIMIT 1 + `; + const existingPkgRecords = ( + await devHubOrg + .getConnection() + .tooling.query<{ Id: string; Name: string; NamespacePrefix: string }>(existingPkgQuery) + ).records; + + managedPackageId = existingPkgRecords[0].Id; + + // Create minimal source structure for a custom object + const objectName = 'TestObject__c'; + const objectDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'objects', objectName); + fs.mkdirSync(objectDir, { recursive: true }); + + fs.writeFileSync( + path.join(objectDir, `${objectName}.object-meta.xml`), + ` + + Deployed + + + + Text + + Test Objects + ReadWrite +` + ); + + // Configure the project for the managed package + const project = await SfProject.resolve(session.project.dir); + const projectJson = project.getSfProjectJson(); + const namespacePrefix = existingPkgRecords[0].NamespacePrefix; + packageName = existingPkgRecords[0].Name; + + const packageDirectory = { + path: 'force-app', + package: existingPkgRecords[0].Name, + versionNumber: '1.0.0.NEXT', + ancestorVersion: 'NONE', + versionName: 'v1', + default: true, + }; + + projectJson.set('packageDirectories', [packageDirectory]); + projectJson.set('packageAliases', { [packageName]: managedPackageId }); + projectJson.set('namespace', namespacePrefix); + projectJson.writeSync(); + }); + + after(async () => { + await session?.clean(); + }); + + it('should create a managed package version with --generate-pkg-zip flag and retrieve the metadata', async function () { + this.timeout(Duration.minutes(25).milliseconds); + + const createResult = execCmd( + `package:version:create --package ${packageName} --wait 20 -x --generate-pkg-zip --version-description "Test pkg zip" --json --skip-ancestor-check`, + { ensureExitCode: 0, timeout: Duration.minutes(20).milliseconds } + ).jsonOutput?.result; + + // Debug: verify the flag was actually set + const pvcRequestId = createResult?.Id; + const verifyQuery = `SELECT Id, IsDevUsePkgZipRequested FROM Package2VersionCreateRequest WHERE Id = '${pvcRequestId}'`; + const verifyResult = await devHubOrg + .getConnection() + .tooling.query<{ Id: string; IsDevUsePkgZipRequested: boolean }>(verifyQuery); + // eslint-disable-next-line no-console + console.log('IsDevUsePkgZipRequested:', verifyResult.records[0]?.IsDevUsePkgZipRequested); + + expect(createResult?.Status).to.equal('Success'); + const subscriberPkgVersionId = createResult?.SubscriberPackageVersionId; + expect(subscriberPkgVersionId).to.match(/04t.{15}/); + + const retrieveOutputDir = 'pkg-zip-test-output'; + const retrieveResult = execCmd( + `package:version:retrieve --package ${subscriberPkgVersionId} --output-dir ${retrieveOutputDir} --json`, + { ensureExitCode: 0 } + ).jsonOutput?.result; + + expect(retrieveResult).to.be.an('array'); + expect(retrieveResult?.length).to.be.greaterThan(0); + }); +}); diff --git a/yarn.lock b/yarn.lock index d0c7100a..42a36633 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2023,16 +2023,16 @@ terminal-link "^3.0.0" "@salesforce/source-deploy-retrieve@^12.31.9": - version "12.31.10" - resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-12.31.10.tgz#612886356d81c87eb9053bbc9173546556fd5f36" - integrity sha512-kUdJicJUd3/lzNQOvDW1Sc5iBl8PVv2Tz7L59YA/Le0fzZCYM72oyKwdbl/f6kc+MzJpMVia2+AxrvVZir8oJw== + version "12.31.9" + resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-12.31.9.tgz#69592e0b1564157fce8b7c66b33412460fa62b6e" + integrity sha512-UVRmLVl+Es1jLGnSx4G2xxTNHR7L6v5uzOpBFbg1ADMOQ4b1v8cDwZO9noJa9xAG+MLJJ7zDkcqywgFxU/3mmQ== dependencies: "@salesforce/core" "^8.24.0" "@salesforce/kit" "^3.2.4" "@salesforce/ts-types" "^2.0.12" "@salesforce/types" "^1.6.0" fast-levenshtein "^3.0.0" - fast-xml-parser "^5.3.4" + fast-xml-parser "^4.5.3" got "^11.8.6" graceful-fs "^4.2.11" ignore "^5.3.2" From 039814e67151966e361c40dfac1667b9f32dd5af Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Thu, 5 Feb 2026 14:35:25 -0800 Subject: [PATCH 3/3] test: skip NUTS test for now --- .../package/packageVersionCreateManaged.nut.ts | 2 ++ yarn.lock | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/test/commands/package/packageVersionCreateManaged.nut.ts b/test/commands/package/packageVersionCreateManaged.nut.ts index 235b3ae5..882fef04 100644 --- a/test/commands/package/packageVersionCreateManaged.nut.ts +++ b/test/commands/package/packageVersionCreateManaged.nut.ts @@ -30,6 +30,8 @@ describe('package:version:create with managed package (--generate-pkg-zip)', () let managedPackageId: string; before('setup managed package', async function () { + // TODO: Remove once 260 is released to instance the CI dev hub is running on + this.skip(); this.timeout(Duration.minutes(5).milliseconds); session = await TestSession.create({ diff --git a/yarn.lock b/yarn.lock index 42a36633..228241be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4767,6 +4767,13 @@ fast-xml-parser@5.2.5: dependencies: strnum "^2.1.0" +fast-xml-parser@^4.5.3: + version "4.5.3" + resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.5.3.tgz#c54d6b35aa0f23dc1ea60b6c884340c006dc6efb" + integrity sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig== + dependencies: + strnum "^1.1.1" + fast-xml-parser@^5.3.4: version "5.3.4" resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-5.3.4.tgz#06f39aafffdbc97bef0321e626c7ddd06a043ecf" @@ -8361,6 +8368,11 @@ strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +strnum@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.1.2.tgz#57bca4fbaa6f271081715dbc9ed7cee5493e28e4" + integrity sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA== + strnum@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/strnum/-/strnum-2.1.1.tgz#cf2a6e0cf903728b8b2c4b971b7e36b4e82d46ab"