Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"dependencies": {
"@jsforce/jsforce-node": "^3.10.16",
"@salesforce/core": "^8.31.1",
"@salesforce/core": "^8.31.2",
"@salesforce/kit": "^3.2.6",
"@salesforce/schemas": "^1.10.3",
"@salesforce/source-deploy-retrieve": "^12.36.2",
Expand Down
5 changes: 4 additions & 1 deletion src/package/packageProfileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export class PackageProfileApi extends AsyncCreatable<ProfileApiOptions> {

// Look for profiles in all package directories
private findAllProfiles(excludedDirectories: string[] = []): string[] {
const ignore = excludedDirectories.map((dir) => `**/${dir.split(path.sep).join(path.posix.sep)}/**`);
const ignore = excludedDirectories.map((dir) => {
const normalized = path.normalize(dir).split(path.sep).filter(Boolean).join(path.posix.sep);
return `**/${normalized}/**`;
});
const patterns = this.project
.getUniquePackageDirectories()
.map((pDir) => pDir.fullPath)
Expand Down
3 changes: 2 additions & 1 deletion src/package/packageVersionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,10 @@ export class PackageVersionCreate {
profileExcludeDirs
);

const excludedProfileNames = excludedProfiles?.map((p) => path.basename(p));
packageXmlAsJson.types = typesArr.map((type) => {
if (type.name !== 'Profile') return type;
return { ...type, members: type.members.filter((m) => !excludedProfiles?.includes(m)) };
return { ...type, members: type.members.filter((m) => !excludedProfileNames?.includes(m)) };
});

const xml = packageXmlJsonToXmlString(packageXmlAsJson);
Expand Down
60 changes: 60 additions & 0 deletions test/package/packageVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,66 @@ describe('Package Version Create', () => {
expect(pkgTypeMembers[1].members).to.deep.equal(['Test Profile']);
});

it('should include profiles from all package directories when scopeProfiles is false', async () => {
project.getSfProjectJson().set('packageDirectories', [
{ path: './src-access-management', package: 'ACCESS', versionName: 'ver 0.1', versionNumber: '0.1.0.NEXT' },
{ path: 'force-app', package: 'TEST', versionName: 'ver 0.1', versionNumber: '0.1.0.NEXT', default: true },
]);
await project.getSfProjectJson().write();

const siblingDir = path.join(project.getPath(), 'src-access-management');
await fs.promises.mkdir(siblingDir, { recursive: true });
const fileContents = '<?xml version="1.0" encoding="UTF-8"?>';
await fs.promises.writeFile(path.join(siblingDir, 'Sibling Profile.profile-meta.xml'), fileContents);
await fs.promises.writeFile(
path.join(project.getPath(), 'force-app', 'Target Profile.profile-meta.xml'),
fileContents
);

const pkgProfileApi = await PackageProfileApi.create({ project, includeUserLicenses: false });
const types = [
{ name: 'Layout', members: ['Test Layout'] },
{ name: 'Profile', members: ['Sibling Profile', 'Target Profile'] },
];

// With no excludedDirectories (scopeProfiles=false), all profiles from all dirs are included
const pkgTypeMembers = pkgProfileApi.filterAndGenerateProfilesForManifest(types);
expect(pkgTypeMembers.find((t) => t.name === 'Profile')?.members).to.deep.equal([
'Sibling Profile',
'Target Profile',
]);
});

it('should exclude profiles from ./-prefixed sibling package directories when scopeProfiles is true', async () => {
// Configure a multi-directory project where sibling uses ./ prefix in path
project.getSfProjectJson().set('packageDirectories', [
{ path: './src-access-management', package: 'ACCESS', versionName: 'ver 0.1', versionNumber: '0.1.0.NEXT' },
{ path: 'force-app', package: 'TEST', versionName: 'ver 0.1', versionNumber: '0.1.0.NEXT', default: true },
]);
await project.getSfProjectJson().write();

const siblingDir = path.join(project.getPath(), 'src-access-management');
await fs.promises.mkdir(siblingDir, { recursive: true });
const fileContents = '<?xml version="1.0" encoding="UTF-8"?>';
await fs.promises.writeFile(path.join(siblingDir, 'Sibling Profile.profile-meta.xml'), fileContents);
await fs.promises.writeFile(
path.join(project.getPath(), 'force-app', 'Target Profile.profile-meta.xml'),
fileContents
);

const pkgProfileApi = await PackageProfileApi.create({ project, includeUserLicenses: false });
const types = [
{ name: 'Layout', members: ['Test Layout'] },
{ name: 'Profile', members: ['Sibling Profile', 'Target Profile'] },
];

// When scopeProfiles is true, packageVersionCreate passes sibling package dir paths
// as excludedDirectories. These retain the ./ prefix from sfdx-project.json.
const excludedDirectories = ['./src-access-management'];
const pkgTypeMembers = pkgProfileApi.filterAndGenerateProfilesForManifest(types, excludedDirectories);
expect(pkgTypeMembers.find((t) => t.name === 'Profile')?.members).to.deep.equal(['Target Profile']);
});

describe('validateAncestorId', () => {
it('should throw if the explicitUseNoAncestor is true and highestReleasedVersion is not undefined', () => {
const ancestorId = 'ancestorId';
Expand Down
27 changes: 26 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.8.1"

"@salesforce/core@^8.23.1", "@salesforce/core@^8.30.3", "@salesforce/core@^8.31.0", "@salesforce/core@^8.31.1":
"@salesforce/core@^8.23.1", "@salesforce/core@^8.30.3", "@salesforce/core@^8.31.0":
version "8.31.1"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.31.1.tgz#a0057e46568b5aeb6d838c461d7c98105ec11dc2"
integrity sha512-dnBfLI0v/Ucsh/QrpYPGeo39qsvvglWMRSifx1lmAwLc9QAnL3Hhp9zUxJyX5icD9jj1uMftsAtIOGyjC2+KXA==
Expand All @@ -576,6 +576,31 @@
ts-retry-promise "^0.8.1"
zod "^4.1.12"

"@salesforce/core@^8.31.2":
version "8.31.2"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.31.2.tgz#968448f423b553f726f42c27da6b55c4ec7eb93a"
integrity sha512-naqnq7Z+gbl1LdnyNvrGrNUoeMUQtCOsnrS6DfqeuLMJTFqcL9Dq0/od+xcuqi0+l7HTyH0/gU1BQitWpd1rag==
dependencies:
"@jsforce/jsforce-node" "^3.10.13"
"@salesforce/kit" "^3.2.4"
"@salesforce/ts-types" "^2.0.12"
ajv "^8.18.0"
change-case "^4.1.2"
fast-levenshtein "^3.0.0"
faye "^1.4.1"
form-data "^4.0.5"
js2xmlparser "^4.0.1"
jsonwebtoken "9.0.3"
jszip "3.10.1"
memfs "4.38.1"
pino "^9.7.0"
pino-abstract-transport "^1.2.0"
pino-pretty "^11.3.0"
proper-lockfile "^4.1.2"
semver "^7.8.0"
ts-retry-promise "^0.8.1"
zod "^4.1.12"

"@salesforce/dev-config@^4.3.1":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@salesforce/dev-config/-/dev-config-4.3.2.tgz#10047e2b8d289c93f157ab4243a1b1de57f2d6a2"
Expand Down
Loading