@salesforce/source-tracking 7.4.10-dev.0 → 7.5.0

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.
Files changed (35) hide show
  1. package/lib/index.js +13 -4
  2. package/lib/shared/conflicts.js +13 -4
  3. package/lib/shared/functions.d.ts +3 -2
  4. package/lib/shared/functions.js +14 -6
  5. package/lib/shared/guards.d.ts +1 -3
  6. package/lib/shared/guards.js +14 -9
  7. package/lib/shared/local/functions.d.ts +0 -1
  8. package/lib/shared/local/functions.js +15 -8
  9. package/lib/shared/local/localShadowRepo.js +16 -31
  10. package/lib/shared/local/moveDetection.d.ts +1 -4
  11. package/lib/shared/local/moveDetection.js +18 -18
  12. package/lib/shared/local/types.js +13 -4
  13. package/lib/shared/localComponentSetArray.js +14 -5
  14. package/lib/shared/metadataKeys.d.ts +3 -3
  15. package/lib/shared/metadataKeys.js +25 -19
  16. package/lib/shared/populateFilePaths.js +13 -4
  17. package/lib/shared/populateTypesAndNames.js +13 -4
  18. package/lib/shared/remote/expectedSourceMembers.d.ts +3 -2
  19. package/lib/shared/remote/expectedSourceMembers.js +16 -6
  20. package/lib/shared/remote/fileOperations.d.ts +1 -2
  21. package/lib/shared/remote/fileOperations.js +50 -9
  22. package/lib/shared/remote/orgQueries.d.ts +0 -1
  23. package/lib/shared/remote/orgQueries.js +16 -8
  24. package/lib/shared/remote/remoteSourceTrackingService.d.ts +6 -4
  25. package/lib/shared/remote/remoteSourceTrackingService.js +75 -26
  26. package/lib/shared/remote/types.js +13 -4
  27. package/lib/shared/remoteChangeIgnoring.d.ts +2 -2
  28. package/lib/shared/remoteChangeIgnoring.js +5 -15
  29. package/lib/shared/types.d.ts +2 -1
  30. package/lib/shared/types.js +13 -4
  31. package/lib/sourceTracking.d.ts +2 -0
  32. package/lib/sourceTracking.js +56 -26
  33. package/lib/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +21 -11
  35. package/LICENSE +0 -29
package/lib/index.js CHANGED
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2021, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
3
+ * Copyright 2025, Salesforce, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
7
16
  */
8
17
  Object.defineProperty(exports, "__esModule", { value: true });
9
18
  exports.deleteCustomLabels = exports.getKeyFromObject = exports.SourceConflictError = exports.SourceTracking = void 0;
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDedupedConflictsFromChanges = exports.findConflictsInComponentSet = exports.throwIfConflicts = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Copyright 2025, Salesforce, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
9
18
  */
10
19
  const node_path_1 = require("node:path");
11
20
  const types_1 = require("./types");
@@ -18,7 +18,7 @@ export declare const pathIsInFolder: (folder: string) => (filePath: string) => b
18
18
  export declare const folderContainsPath: (filePath: string) => (folder: string) => boolean;
19
19
  export declare const chunkArray: <T>(arr: T[], size: number) => T[][];
20
20
  export declare const ensureRelative: (projectPath: string) => (filePath: string) => string;
21
- export type ParsedCustomLabels = {
21
+ type ParsedCustomLabels = {
22
22
  CustomLabels: {
23
23
  labels: Array<{
24
24
  fullName: string;
@@ -40,5 +40,6 @@ export declare const sourceComponentHasFullNameAndType: (input: SourceComponent)
40
40
  export declare const getAllFiles: (sc: SourceComponent) => string[];
41
41
  export declare const remoteChangeToMetadataMember: (cr: ChangeResult) => MetadataMember;
42
42
  export declare const FileResponseSuccessToRemoteSyncInput: (fr: FileResponseSuccess) => RemoteSyncInput;
43
- export declare const changeResultToMetadataComponent: (registry?: RegistryAccess) => (cr: ChangeResultWithNameAndType) => MetadataComponent;
43
+ export declare const changeResultToMetadataComponent: (registry: RegistryAccess) => (cr: ChangeResultWithNameAndType) => MetadataComponent;
44
44
  export declare const uniqueArrayConcat: <T>(arr1: T[] | Set<T>, arr2: T[] | Set<T>) => T[];
45
+ export {};
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2020, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
3
+ * Copyright 2025, Salesforce, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
7
16
  */
8
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -13,7 +22,6 @@ exports.uniqueArrayConcat = exports.changeResultToMetadataComponent = exports.Fi
13
22
  const node_path_1 = require("node:path");
14
23
  const node_fs_1 = __importDefault(require("node:fs"));
15
24
  const ts_types_1 = require("@salesforce/ts-types");
16
- const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
17
25
  const fast_xml_parser_1 = require("fast-xml-parser");
18
26
  const kit_1 = require("@salesforce/kit");
19
27
  const remoteChangeIgnoring_1 = require("./remoteChangeIgnoring");
@@ -136,7 +144,7 @@ exports.remoteChangeToMetadataMember = remoteChangeToMetadataMember;
136
144
  // weird, right? This is for oclif.table which allows types but not interfaces. In this case, they are equivalent
137
145
  const FileResponseSuccessToRemoteSyncInput = (fr) => fr;
138
146
  exports.FileResponseSuccessToRemoteSyncInput = FileResponseSuccessToRemoteSyncInput;
139
- const changeResultToMetadataComponent = (registry = new source_deploy_retrieve_1.RegistryAccess()) => (cr) => ({
147
+ const changeResultToMetadataComponent = (registry) => (cr) => ({
140
148
  fullName: cr.name,
141
149
  type: registry.getTypeByName(cr.type),
142
150
  });
@@ -1,8 +1,6 @@
1
- import { MetadataMember, FileResponse, FileResponseFailure, FileResponseSuccess } from '@salesforce/source-deploy-retrieve';
1
+ import { FileResponse, FileResponseSuccess } from '@salesforce/source-deploy-retrieve';
2
2
  import { ChangeResult } from './types';
3
3
  import { ChangeResultWithNameAndType } from './types';
4
- export declare const metadataMemberGuard: (input: MetadataMember | undefined | Partial<MetadataMember>) => input is MetadataMember;
5
- export declare const isSdrFailure: (fileResponse: FileResponse) => fileResponse is FileResponseFailure;
6
4
  export declare const isSdrSuccess: (fileResponse: FileResponse) => fileResponse is FileResponseSuccess;
7
5
  export declare const FileResponseIsDeleted: (fileResponse: FileResponse) => boolean;
8
6
  export declare const FileResponseIsNotDeleted: (fileResponse: FileResponse) => boolean;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDefined = exports.isChangeResultWithNameAndType = exports.FileResponseHasPath = exports.FileResponseIsNotDeleted = exports.FileResponseIsDeleted = exports.isSdrSuccess = exports.isSdrFailure = exports.metadataMemberGuard = void 0;
3
+ exports.isDefined = exports.isChangeResultWithNameAndType = exports.FileResponseHasPath = exports.FileResponseIsNotDeleted = exports.FileResponseIsDeleted = exports.isSdrSuccess = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Copyright 2025, Salesforce, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
9
18
  */
10
19
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
11
- const metadataMemberGuard = (input) => input !== undefined && typeof input.fullName === 'string' && typeof input.type === 'string';
12
- exports.metadataMemberGuard = metadataMemberGuard;
13
- const isSdrFailure = (fileResponse) => fileResponse.state === source_deploy_retrieve_1.ComponentStatus.Failed;
14
- exports.isSdrFailure = isSdrFailure;
15
20
  const isSdrSuccess = (fileResponse) => fileResponse.state !== source_deploy_retrieve_1.ComponentStatus.Failed;
16
21
  exports.isSdrSuccess = isSdrSuccess;
17
22
  const FileResponseIsDeleted = (fileResponse) => fileResponse.state === source_deploy_retrieve_1.ComponentStatus.Deleted;
@@ -3,7 +3,6 @@ export declare const IS_WINDOWS: boolean;
3
3
  export declare const toFilenames: (rows: StatusRow[]) => string[];
4
4
  export declare const isDeleted: (status: StatusRow) => boolean;
5
5
  export declare const isAdded: (status: StatusRow) => boolean;
6
- export declare const ensureWindows: (filepath: string) => string;
7
6
  export declare const ensurePosix: (filepath: string) => string;
8
7
  export declare const FILE = 0;
9
8
  export declare const HEAD = 1;
@@ -33,15 +33,24 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.WORKDIR = exports.HEAD = exports.FILE = exports.ensurePosix = exports.ensureWindows = exports.isAdded = exports.isDeleted = exports.toFilenames = exports.IS_WINDOWS = void 0;
36
+ exports.WORKDIR = exports.HEAD = exports.FILE = exports.ensurePosix = exports.isAdded = exports.isDeleted = exports.toFilenames = exports.IS_WINDOWS = void 0;
37
37
  /*
38
- * Copyright (c) 2023, salesforce.com, inc.
39
- * All rights reserved.
40
- * Licensed under the BSD 3-Clause license.
41
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
38
+ * Copyright 2025, Salesforce, Inc.
39
+ *
40
+ * Licensed under the Apache License, Version 2.0 (the "License");
41
+ * you may not use this file except in compliance with the License.
42
+ * You may obtain a copy of the License at
43
+ *
44
+ * http://www.apache.org/licenses/LICENSE-2.0
45
+ *
46
+ * Unless required by applicable law or agreed to in writing, software
47
+ * distributed under the License is distributed on an "AS IS" BASIS,
48
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
+ * See the License for the specific language governing permissions and
50
+ * limitations under the License.
42
51
  */
43
- const os = __importStar(require("node:os"));
44
52
  const path = __importStar(require("node:path"));
53
+ const os = __importStar(require("node:os"));
45
54
  exports.IS_WINDOWS = os.type() === 'Windows_NT'; // array members for status results
46
55
  // filenames were normalized when read from isogit
47
56
  const toFilenames = (rows) => rows.map((row) => row[exports.FILE]);
@@ -50,8 +59,6 @@ const isDeleted = (status) => status[exports.WORKDIR] === 0;
50
59
  exports.isDeleted = isDeleted;
51
60
  const isAdded = (status) => status[exports.HEAD] === 0 && status[exports.WORKDIR] === 2;
52
61
  exports.isAdded = isAdded;
53
- const ensureWindows = (filepath) => path.win32.normalize(filepath);
54
- exports.ensureWindows = ensureWindows;
55
62
  const ensurePosix = (filepath) => filepath.split(path.sep).join(path.posix.sep);
56
63
  exports.ensurePosix = ensurePosix;
57
64
  // We don't use STAGE (StatusRow[3]). Changes are added and committed in one step
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2020, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
3
+ * Copyright 2025, Salesforce, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
7
16
  */
8
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
18
  if (k2 === undefined) k2 = k;
@@ -48,9 +57,7 @@ const os = __importStar(require("node:os"));
48
57
  const fs = __importStar(require("graceful-fs"));
49
58
  const core_1 = require("@salesforce/core");
50
59
  const kit_1 = require("@salesforce/kit");
51
- // @ts-expect-error isogit has both ESM and CJS exports but node16 module/resolution identifies it as ESM
52
60
  const isomorphic_git_1 = __importDefault(require("isomorphic-git"));
53
- const performance_1 = require("@oclif/core/performance");
54
61
  const functions_1 = require("../functions");
55
62
  const moveDetection_1 = require("./moveDetection");
56
63
  const functions_2 = require("./functions");
@@ -65,7 +72,7 @@ const redirectToCliRepoError = (e) => {
65
72
  }
66
73
  throw e;
67
74
  };
68
- /** do not try to add more than this many files at a time through isogit. You'll hit EMFILE: too many open files even with graceful-fs */
75
+ /** do not try to add more than this many files at a time through isogit. You'll hit EMFILE: too many open files */
69
76
  const MAX_FILE_ADD = kit_1.env.getNumber('SF_SOURCE_TRACKING_BATCH_SIZE', kit_1.env.getNumber('SFDX_SOURCE_TRACKING_BATCH_SIZE', functions_2.IS_WINDOWS ? 8000 : 15_000));
70
77
  class ShadowRepo {
71
78
  static instanceMap = new Map();
@@ -124,12 +131,7 @@ class ShadowRepo {
124
131
  * @returns the deleted directory
125
132
  */
126
133
  async delete() {
127
- if (typeof fs.promises.rm === 'function') {
128
- await fs.promises.rm(this.gitDir, { recursive: true, force: true });
129
- }
130
- else {
131
- await fs.promises.rm(this.gitDir, { recursive: true });
132
- }
134
+ await fs.promises.rm(this.gitDir, { recursive: true, force: true });
133
135
  return this.gitDir;
134
136
  }
135
137
  /**
@@ -143,7 +145,6 @@ class ShadowRepo {
143
145
  async getStatus(noCache = false) {
144
146
  this.logger.trace(`start: getStatus (noCache = ${noCache})`);
145
147
  if (!this.status || noCache) {
146
- const marker = performance_1.Performance.mark('@salesforce/source-tracking', 'localShadowRepo.getStatus#withoutCache');
147
148
  try {
148
149
  // status hasn't been initialized yet
149
150
  this.status = await isomorphic_git_1.default.statusMatrix({
@@ -170,7 +171,6 @@ class ShadowRepo {
170
171
  catch (e) {
171
172
  redirectToCliRepoError(e);
172
173
  }
173
- marker?.stop();
174
174
  }
175
175
  this.logger.trace(`done: getStatus (noCache = ${noCache})`);
176
176
  return this.status;
@@ -234,10 +234,6 @@ class ShadowRepo {
234
234
  // this is valid, might not be an error
235
235
  return 'no files to commit';
236
236
  }
237
- const marker = performance_1.Performance.mark('@salesforce/source-tracking', 'localShadowRepo.commitChanges', {
238
- deployedFiles: deployedFiles.length,
239
- deletedFiles: deletedFiles.length,
240
- });
241
237
  if (deployedFiles.length) {
242
238
  const chunks = (0, functions_1.chunkArray)(
243
239
  // these are stored in posix/style/path format. We have to convert inbound stuff from windows
@@ -275,9 +271,6 @@ class ShadowRepo {
275
271
  if (deletedFiles.length) {
276
272
  // Using a cache here speeds up the performance by ~24.4%
277
273
  let cache = {};
278
- const deleteMarker = performance_1.Performance.mark('@salesforce/source-tracking', 'localShadowRepo.commitChanges#delete', {
279
- deletedFiles: deletedFiles.length,
280
- });
281
274
  for (const filepath of [...new Set(functions_2.IS_WINDOWS ? deletedFiles.map(normalize).map(functions_2.ensurePosix) : deletedFiles)]) {
282
275
  try {
283
276
  // these need to be done sequentially because isogit manages file locking. Isogit remove does not support multiple files at once
@@ -290,7 +283,6 @@ class ShadowRepo {
290
283
  }
291
284
  // clear cache
292
285
  cache = {};
293
- deleteMarker?.stop();
294
286
  }
295
287
  try {
296
288
  this.logger.trace('start: commitChanges git.commit');
@@ -311,29 +303,22 @@ class ShadowRepo {
311
303
  catch (e) {
312
304
  redirectToCliRepoError(e);
313
305
  }
314
- marker?.stop();
315
306
  }
316
307
  async detectMovedFiles() {
317
308
  // get status will return os-specific paths
318
309
  const matchingFiles = (0, moveDetection_1.getMatches)(await this.getStatus());
319
310
  if (!matchingFiles.added.size || !matchingFiles.deleted.size)
320
311
  return;
321
- const movedFilesMarker = performance_1.Performance.mark('@salesforce/source-tracking', 'localShadowRepo.detectMovedFiles');
322
312
  const matches = await (0, moveDetection_1.filenameMatchesToMap)(this.registry)(this.projectPath)(this.gitDir)(matchingFiles);
323
313
  if (matches.deleteOnly.size === 0 && matches.fullMatches.size === 0)
324
- return movedFilesMarker?.stop();
314
+ return;
325
315
  this.logger.debug((0, moveDetection_1.getLogMessage)(matches));
326
- movedFilesMarker?.addDetails({
327
- filesMoved: matches.fullMatches.size,
328
- filesMovedAndEdited: matches.deleteOnly.size,
329
- });
330
316
  // Commit the moved files and refresh the status
331
317
  await this.commitChanges({
332
318
  deletedFiles: [...matches.fullMatches.values(), ...matches.deleteOnly.values()],
333
319
  deployedFiles: [...matches.fullMatches.keys()],
334
320
  message: 'Committing moved files',
335
321
  });
336
- movedFilesMarker?.stop();
337
322
  }
338
323
  }
339
324
  exports.ShadowRepo = ShadowRepo;
@@ -1,5 +1,5 @@
1
1
  import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
2
- import { DetectionFileInfoWithType, StatusRow, StringMap } from './types';
2
+ import { StatusRow, StringMap } from './types';
3
3
  type AddedAndDeletedFilenames = {
4
4
  added: Set<string>;
5
5
  deleted: Set<string>;
@@ -15,7 +15,4 @@ export declare const filenameMatchesToMap: (registry: RegistryAccess) => (projec
15
15
  /** compare delete and adds from git.status, matching basenames of the files. returns early when there's nothing to match */
16
16
  export declare const getMatches: (status: StatusRow[]) => AddedAndDeletedFilenames;
17
17
  export declare const getLogMessage: (matches: StringMapsForMatches) => string;
18
- /** returns a map of <hash+basename, filepath>. If two items result in the same hash+basename, return that in the ignore bucket */
19
- export declare const buildMap: (info: DetectionFileInfoWithType[]) => StringMap[];
20
- export declare const toKey: (input: DetectionFileInfoWithType) => string;
21
18
  export {};
@@ -36,21 +36,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.toKey = exports.buildMap = exports.getLogMessage = exports.getMatches = exports.filenameMatchesToMap = void 0;
39
+ exports.getLogMessage = exports.getMatches = exports.filenameMatchesToMap = void 0;
40
40
  /*
41
- * Copyright (c) 2023, salesforce.com, inc.
42
- * All rights reserved.
43
- * Licensed under the BSD 3-Clause license.
44
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
41
+ * Copyright 2025, Salesforce, Inc.
42
+ *
43
+ * Licensed under the Apache License, Version 2.0 (the "License");
44
+ * you may not use this file except in compliance with the License.
45
+ * You may obtain a copy of the License at
46
+ *
47
+ * http://www.apache.org/licenses/LICENSE-2.0
48
+ *
49
+ * Unless required by applicable law or agreed to in writing, software
50
+ * distributed under the License is distributed on an "AS IS" BASIS,
51
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52
+ * See the License for the specific language governing permissions and
53
+ * limitations under the License.
45
54
  */
46
55
  const node_path_1 = __importDefault(require("node:path"));
47
56
  const node_os_1 = require("node:os");
57
+ const fs = __importStar(require("graceful-fs"));
48
58
  const core_1 = require("@salesforce/core");
49
59
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
50
- // @ts-expect-error isogit has both ESM and CJS exports but node16 module/resolution identifies it as ESM
51
60
  const isomorphic_git_1 = __importDefault(require("isomorphic-git"));
52
- const fs = __importStar(require("graceful-fs"));
53
- const performance_1 = require("@oclif/core/performance");
54
61
  const guards_1 = require("../guards");
55
62
  const functions_1 = require("../functions");
56
63
  const functions_2 = require("./functions");
@@ -102,8 +109,8 @@ const getLogMessage = (matches) => [
102
109
  exports.getLogMessage = getLogMessage;
103
110
  /** build maps of the add/deletes with filenames, returning the matches Logs if we can't make a match because buildMap puts them in the ignored bucket */
104
111
  const buildMaps = async ({ addedInfo, deletedInfo }) => {
105
- const [addedMap, addedIgnoredMap] = (0, exports.buildMap)(addedInfo);
106
- const [deletedMap, deletedIgnoredMap] = (0, exports.buildMap)(deletedInfo);
112
+ const [addedMap, addedIgnoredMap] = buildMap(addedInfo);
113
+ const [deletedMap, deletedIgnoredMap] = buildMap(deletedInfo);
107
114
  // If we detected any files that have the same basename and hash, emit a warning and send telemetry
108
115
  // These files will still show up as expected in the `sf project deploy preview` output
109
116
  // We could add more logic to determine and display filepaths that we ignored...
@@ -152,16 +159,11 @@ const compareHashes = ({ addedMap, deletedMap }) => {
152
159
  /** enrich the filenames with basename and oid (hash) */
153
160
  const toFileInfo = async ({ projectPath, gitDir, added, deleted, }) => {
154
161
  // Track how long it takes to gather the oid information from the git trees
155
- const getInfoMarker = performance_1.Performance.mark('@salesforce/source-tracking', 'localShadowRepo.detectMovedFiles#toFileInfo', {
156
- addedFiles: added.size,
157
- deletedFiles: deleted.size,
158
- });
159
162
  const headRef = await isomorphic_git_1.default.resolveRef({ fs, dir: projectPath, gitdir: gitDir, ref: 'HEAD' });
160
163
  const [addedInfo, deletedInfo] = await Promise.all([
161
164
  await Promise.all(Array.from(added).map(getHashForAddedFile(projectPath))),
162
165
  await Promise.all(Array.from(deleted).map(getHashFromActualFileContents(gitDir)(projectPath)(headRef))),
163
166
  ]);
164
- getInfoMarker?.stop();
165
167
  return { addedInfo, deletedInfo };
166
168
  };
167
169
  /** returns a map of <hash+basename, filepath>. If two items result in the same hash+basename, return that in the ignore bucket */
@@ -169,7 +171,7 @@ const buildMap = (info) => {
169
171
  const map = new Map();
170
172
  const ignore = new Map();
171
173
  info.map((i) => {
172
- const key = (0, exports.toKey)(i);
174
+ const key = toKey(i);
173
175
  // If we find a duplicate key, we need to remove it and ignore it in the future.
174
176
  // Finding duplicate hash#basename means that we cannot accurately determine where it was moved to or from
175
177
  if (map.has(key) || ignore.has(key)) {
@@ -182,7 +184,6 @@ const buildMap = (info) => {
182
184
  });
183
185
  return [map, ignore];
184
186
  };
185
- exports.buildMap = buildMap;
186
187
  const getHashForAddedFile = (projectPath) => async (filepath) => ({
187
188
  filename: filepath,
188
189
  basename: node_path_1.default.basename(filepath),
@@ -209,7 +210,6 @@ const getHashFromActualFileContents = (gitdir) => (projectPath) => (oid) => asyn
209
210
  hash: (await isomorphic_git_1.default.readBlob({ fs, dir: projectPath, gitdir, filepath: functions_2.IS_WINDOWS ? (0, functions_2.ensurePosix)(filepath) : filepath, oid })).oid,
210
211
  });
211
212
  const toKey = (input) => [input.hash, input.basename, input.type, input.type, input.parentType ?? '', input.parentFullName ?? ''].join(JOIN_CHAR);
212
- exports.toKey = toKey;
213
213
  const removeHashFromEntry = ([k, v]) => [removeHashFromKey(k), v];
214
214
  const removeHashFromKey = (hash) => hash.split(JOIN_CHAR).splice(1).join(JOIN_CHAR);
215
215
  /** resolve the metadata types (and possibly parent components) */
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2023, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
3
+ * Copyright 2025, Salesforce, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
7
16
  */
8
17
  Object.defineProperty(exports, "__esModule", { value: true });
9
18
  //# sourceMappingURL=types.js.map
@@ -5,10 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getComponentSets = exports.getGroupedFiles = void 0;
7
7
  /*
8
- * Copyright (c) 2020, salesforce.com, inc.
9
- * All rights reserved.
10
- * Licensed under the BSD 3-Clause license.
11
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ * Copyright 2025, Salesforce, Inc.
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
12
21
  */
13
22
  const node_fs_1 = __importDefault(require("node:fs"));
14
23
  const node_path_1 = require("node:path");
@@ -53,7 +62,7 @@ const getNonSequential = ({ packageDirs, nonDeletes: nonDeletes, deletes: delete
53
62
  path: packageDirs.map((dir) => dir.name).join(';'),
54
63
  },
55
64
  ];
56
- const getComponentSets = ({ groupings, sourceApiVersion, registry = new source_deploy_retrieve_1.RegistryAccess(), }) => {
65
+ const getComponentSets = ({ groupings, sourceApiVersion, registry, }) => {
57
66
  const logger = core_1.Logger.childFromRoot('localComponentSetArray');
58
67
  // optimistic resolution...some files may not be possible to resolve
59
68
  const resolverForNonDeletes = new source_deploy_retrieve_1.MetadataResolver(registry);
@@ -1,5 +1,5 @@
1
1
  import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
2
2
  import { RemoteSyncInput } from './types';
3
- export declare const getMetadataKeyFromFileResponse: (fileResponse: RemoteSyncInput) => string[];
4
- export declare const mappingsForSourceMemberTypesToMetadataType: Map<string, string>;
5
- export declare const registrySupportsType: (registry?: RegistryAccess) => (type: string) => boolean;
3
+ export declare const getMetadataKeyFromFileResponse: (registry: RegistryAccess) => (fileResponse: RemoteSyncInput) => string[];
4
+ export declare const getMappingsForSourceMemberTypesToMetadataType: (registry: RegistryAccess) => Map<string, string>;
5
+ export declare const registrySupportsType: (registry: RegistryAccess) => (type: string) => boolean;
@@ -1,11 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registrySupportsType = exports.mappingsForSourceMemberTypesToMetadataType = exports.getMetadataKeyFromFileResponse = void 0;
3
+ exports.registrySupportsType = exports.getMappingsForSourceMemberTypesToMetadataType = exports.getMetadataKeyFromFileResponse = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Copyright 2025, Salesforce, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
9
18
  */
10
19
  const node_path_1 = require("node:path");
11
20
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
@@ -16,16 +25,11 @@ const functions_1 = require("./functions");
16
25
  const pathAfterFullName = (fileResponse) => fileResponse?.filePath
17
26
  ? (0, node_path_1.join)((0, node_path_1.dirname)(fileResponse.filePath).substring((0, node_path_1.dirname)(fileResponse.filePath).lastIndexOf(fileResponse.fullName)), (0, node_path_1.basename)(fileResponse.filePath)).replace(/\\/gi, '/')
18
27
  : '';
19
- const registryAccess = new source_deploy_retrieve_1.RegistryAccess();
20
- // only compute once
21
- const aliasTypes = registryAccess
22
- .getAliasTypes()
23
- // allow assertion because aliasTypes are defined as having that property
24
- .map((aliasType) => [aliasType.name, registryAccess.getTypeByName(aliasType.aliasFor).name]);
25
- const reverseAliasTypes = new Map(aliasTypes.map(([alias, type]) => [type, alias]));
28
+ const getAliasTypes = (registry) => registry.getAliasTypes().map((aliasType) => [aliasType.name, registry.getTypeByName(aliasType.aliasFor).name]);
29
+ const reverseStringMap = (original) => new Map(original.map(([k, v]) => [v, k]));
26
30
  // handle all "weird" type/name translation between SourceMember and SDR FileResponse
27
31
  // These get de-duplicated in a set later, so it's ok to have one per file
28
- const getMetadataKeyFromFileResponse = (fileResponse) => {
32
+ const getMetadataKeyFromFileResponse = (registry) => (fileResponse) => {
29
33
  // also create an element for the parent object
30
34
  if (fileResponse.type === 'CustomField' && fileResponse.filePath) {
31
35
  const splits = (0, node_path_1.normalize)(fileResponse.filePath).split(node_path_1.sep);
@@ -55,24 +59,26 @@ const getMetadataKeyFromFileResponse = (fileResponse) => {
55
59
  .toArray()
56
60
  .flatMap((component) => component.getChildren().map((child) => (0, functions_1.getMetadataKey)('CustomLabel', child.fullName)));
57
61
  }
62
+ const reverseAliasTypesResult = reverseStringMap(getAliasTypes(registry));
58
63
  // if we've aliased a type, we'll have to possibly sync both types--you can't tell from the sourceComponent retrieved which way it was stored on the server
59
- if (reverseAliasTypes.has(fileResponse.type)) {
64
+ if (reverseAliasTypesResult.has(fileResponse.type)) {
60
65
  return [
61
66
  (0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName),
62
- (0, functions_1.getMetadataKey)(reverseAliasTypes.get(fileResponse.type), fileResponse.fullName),
67
+ (0, functions_1.getMetadataKey)(reverseAliasTypesResult.get(fileResponse.type), fileResponse.fullName),
63
68
  ];
64
69
  }
65
70
  // standard key for everything else
66
71
  return [(0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName)];
67
72
  };
68
73
  exports.getMetadataKeyFromFileResponse = getMetadataKeyFromFileResponse;
69
- exports.mappingsForSourceMemberTypesToMetadataType = new Map([
70
- ...aliasTypes,
74
+ const getMappingsForSourceMemberTypesToMetadataType = (registry) => new Map([
75
+ ...getAliasTypes(registry),
71
76
  ['AuraDefinition', 'AuraDefinitionBundle'],
72
77
  ['LightningComponentResource', 'LightningComponentBundle'],
73
78
  ]);
74
- const registrySupportsType = (registry = new source_deploy_retrieve_1.RegistryAccess()) => (type) => {
75
- if (exports.mappingsForSourceMemberTypesToMetadataType.has(type)) {
79
+ exports.getMappingsForSourceMemberTypesToMetadataType = getMappingsForSourceMemberTypesToMetadataType;
80
+ const registrySupportsType = (registry) => (type) => {
81
+ if ((0, exports.getMappingsForSourceMemberTypesToMetadataType)(registry).has(type)) {
76
82
  return true;
77
83
  }
78
84
  if (type === 'PicklistValue') {
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.populateFilePaths = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Copyright 2025, Salesforce, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
9
18
  */
10
19
  const node_os_1 = require("node:os");
11
20
  const logger_1 = require("@salesforce/core/logger");
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.populateTypesAndNames = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
5
+ * Copyright 2025, Salesforce, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
9
18
  */
10
19
  const logger_1 = require("@salesforce/core/logger");
11
20
  const ts_types_1 = require("@salesforce/ts-types");