@salesforce/packaging 2.3.8 → 2.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ export declare class PackageProfileApi extends AsyncCreatable<ProfileApiOptions>
7
7
  constructor(options: ProfileApiOptions);
8
8
  init(): Promise<void>;
9
9
  /**
10
- * For any profile present in the workspace, this function generates a subset of data that only contains references
11
- * to items in the manifest.
10
+ * For any profile present in the project package directories, this function generates a subset of data that only
11
+ * contains references to items in the manifest.
12
12
  *
13
13
  * return a list of profile file locations that need to be removed from the package because they are empty
14
14
  *
@@ -18,10 +18,12 @@ export declare class PackageProfileApi extends AsyncCreatable<ProfileApiOptions>
18
18
  */
19
19
  generateProfiles(destPath: string, manifestTypes: PackageXml['types'], excludedDirectories?: string[]): string[];
20
20
  /**
21
- * Filter out all profiles in the manifest and if any profiles exists in the workspace, add them to the manifest.
21
+ * Filter out all profiles in the manifest and if any profiles exist in the project package directories, add them to the manifest.
22
22
  *
23
23
  * @param typesArr array of objects { name[], members[] } that represent package types JSON.
24
24
  * @param excludedDirectories Direcotires not to generate profiles for
25
25
  */
26
26
  filterAndGenerateProfilesForManifest(typesArr: PackageXml['types'], excludedDirectories?: string[]): PackageXml['types'];
27
+ private findAllProfiles;
28
+ private getProfilesWithNamesAndPaths;
27
29
  }
@@ -16,9 +16,9 @@ const profileRewriter_1 = require("./profileRewriter");
16
16
  core_1.Messages.importMessagesDirectory(__dirname);
17
17
  const profileApiMessages = core_1.Messages.loadMessages('@salesforce/packaging', 'profile_api');
18
18
  /*
19
- * This class provides functions used to re-write .profiles in the workspace when creating a package2 version.
20
- * All profiles found in the workspaces are extracted out and then re-written to only include metadata in the profile
21
- * that is relevant to the source in the package directory being packaged.
19
+ * This class provides functions used to re-write .profiles in the project package directories when creating a package2 version.
20
+ * All profiles found in the project package directories are extracted out and then re-written to only include metadata in the
21
+ * profile that is relevant to the source in the package directory being packaged.
22
22
  */
23
23
  class PackageProfileApi extends kit_1.AsyncCreatable {
24
24
  constructor(options) {
@@ -30,8 +30,8 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
30
30
  // eslint-disable-next-line class-methods-use-this,@typescript-eslint/no-empty-function
31
31
  async init() { }
32
32
  /**
33
- * For any profile present in the workspace, this function generates a subset of data that only contains references
34
- * to items in the manifest.
33
+ * For any profile present in the project package directories, this function generates a subset of data that only
34
+ * contains references to items in the manifest.
35
35
  *
36
36
  * return a list of profile file locations that need to be removed from the package because they are empty
37
37
  *
@@ -41,10 +41,7 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
41
41
  */
42
42
  generateProfiles(destPath, manifestTypes, excludedDirectories = []) {
43
43
  const logger = core_1.Logger.childFromRoot('PackageProfileApi');
44
- return (getProfilesWithNamesAndPaths({
45
- projectPath: this.project.getPath(),
46
- excludedDirectories,
47
- })
44
+ return (this.getProfilesWithNamesAndPaths(excludedDirectories)
48
45
  .map(({ profilePath, name: profileName }) => {
49
46
  const originalProfile = (0, profileRewriter_1.profileStringToProfile)(fs.readFileSync(profilePath, 'utf-8'));
50
47
  const adjustedProfile = (0, profileRewriter_1.profileRewriter)(originalProfile, (0, profileRewriter_1.manifestTypesToMap)(manifestTypes), this.includeUserLicenses);
@@ -74,31 +71,36 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
74
71
  .map(({ xmlFileLocation }) => xmlFileLocation.replace(/(.*)(\.profile)/, '$1')));
75
72
  }
76
73
  /**
77
- * Filter out all profiles in the manifest and if any profiles exists in the workspace, add them to the manifest.
74
+ * Filter out all profiles in the manifest and if any profiles exist in the project package directories, add them to the manifest.
78
75
  *
79
76
  * @param typesArr array of objects { name[], members[] } that represent package types JSON.
80
77
  * @param excludedDirectories Direcotires not to generate profiles for
81
78
  */
82
79
  filterAndGenerateProfilesForManifest(typesArr, excludedDirectories = []) {
83
- const profilePathsWithNames = getProfilesWithNamesAndPaths({
84
- projectPath: this.project.getPath(),
85
- excludedDirectories,
86
- });
80
+ const profilePathsWithNames = this.getProfilesWithNamesAndPaths(excludedDirectories);
87
81
  // Filter all profiles, and add back the ones we found names for
88
82
  return typesArr
89
83
  .filter((kvp) => kvp.name !== 'Profile')
90
84
  .concat([{ name: 'Profile', members: profilePathsWithNames.map((i) => i.name) }]);
91
85
  }
86
+ // Look for profiles in all package directories
87
+ findAllProfiles(excludedDirectories = []) {
88
+ const pkgDirs = this.project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
89
+ return pkgDirs
90
+ .map((pDir) => glob.sync(path.join(pDir, '**', '*.profile-meta.xml'), {
91
+ ignore: excludedDirectories.map((dir) => `**/${dir}/**`),
92
+ }))
93
+ .flat();
94
+ }
95
+ getProfilesWithNamesAndPaths(excludedDirectories) {
96
+ return this.findAllProfiles(excludedDirectories)
97
+ .map((profilePath) => ({ profilePath, name: profilePathToName(profilePath) }))
98
+ .filter(isProfilePathWithName);
99
+ }
92
100
  }
93
101
  exports.PackageProfileApi = PackageProfileApi;
94
- const findAllProfiles = ({ projectPath, excludedDirectories = [], }) => glob.sync(path.join(projectPath, '**', '*.profile-meta.xml'), {
95
- ignore: excludedDirectories.map((dir) => `**/${dir}/**`),
96
- });
97
102
  const isProfilePathWithName = (profilePathWithName) => typeof profilePathWithName.name === 'string';
98
103
  const profilePathToName = (profilePath) => profilePath.match(/([^/]+)\.profile-meta.xml/)?.[1];
99
- const getProfilesWithNamesAndPaths = ({ projectPath, excludedDirectories, }) => findAllProfiles({ projectPath, excludedDirectories })
100
- .map((profilePath) => ({ profilePath, name: profilePathToName(profilePath) }))
101
- .filter(isProfilePathWithName);
102
104
  const getXmlFileLocation = (destPath, profilePath) => path.join(destPath, path.basename(profilePath).replace(/(.*)(-meta.xml)/, '$1'));
103
105
  const getRemovedSettings = (originalProfile, adjustedProfile) => {
104
106
  const originalProfileSettings = Object.keys(originalProfile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "2.3.8",
3
+ "version": "2.3.10",
4
4
  "description": "Packaging library for the Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -45,7 +45,7 @@
45
45
  "@salesforce/core": "^5.2.5",
46
46
  "@salesforce/kit": "^3.0.9",
47
47
  "@salesforce/schemas": "^1.6.0",
48
- "@salesforce/source-deploy-retrieve": "^9.7.10",
48
+ "@salesforce/source-deploy-retrieve": "^9.7.13",
49
49
  "@salesforce/ts-types": "^2.0.6",
50
50
  "fast-xml-parser": "^4.2.5",
51
51
  "globby": "^11",
@@ -65,7 +65,7 @@
65
65
  "@types/jszip": "^3.4.1",
66
66
  "@typescript-eslint/eslint-plugin": "^5.62.0",
67
67
  "@typescript-eslint/parser": "^5.62.0",
68
- "chai": "^4.3.7",
68
+ "chai": "^4.3.8",
69
69
  "eslint": "^8.49.0",
70
70
  "eslint-config-prettier": "^8.10.0",
71
71
  "eslint-config-salesforce": "^2.0.2",
@@ -74,7 +74,7 @@
74
74
  "eslint-plugin-header": "3.1.1",
75
75
  "eslint-plugin-import": "^2.28.1",
76
76
  "eslint-plugin-jsdoc": "^44.2.7",
77
- "eslint-plugin-sf-plugin": "^1.16.2",
77
+ "eslint-plugin-sf-plugin": "^1.16.5",
78
78
  "husky": "^8.0.3",
79
79
  "mocha": "^10.2.0",
80
80
  "nyc": "^15.1.0",
@@ -84,7 +84,7 @@
84
84
  "sinon": "14.0.2",
85
85
  "ts-node": "^10.9.1",
86
86
  "typescript": "4.9.5",
87
- "wireit": "^0.10.0"
87
+ "wireit": "^0.14.0"
88
88
  },
89
89
  "publishConfig": {
90
90
  "access": "public"