@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
@@ -1,16 +1,55 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.SourceTracking = void 0;
7
37
  /*
8
- * Copyright (c) 2021, 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
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.
12
51
  */
13
- const node_fs_1 = __importDefault(require("node:fs"));
52
+ const fs = __importStar(require("node:fs"));
14
53
  const node_path_1 = require("node:path");
15
54
  const core_1 = require("@salesforce/core");
16
55
  const kit_1 = require("@salesforce/kit");
@@ -18,7 +57,6 @@ const ts_types_1 = require("@salesforce/ts-types");
18
57
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
19
58
  // this is not exported by SDR (see the comments in SDR regarding its limitations)
20
59
  const filePathGenerator_1 = require("@salesforce/source-deploy-retrieve/lib/src/utils/filePathGenerator");
21
- const performance_1 = require("@oclif/core/performance");
22
60
  const remoteSourceTrackingService_1 = require("./shared/remote/remoteSourceTrackingService");
23
61
  const localShadowRepo_1 = require("./shared/local/localShadowRepo");
24
62
  const conflicts_1 = require("./shared/conflicts");
@@ -63,7 +101,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
63
101
  this.ignoreConflicts = options.ignoreConflicts ?? false;
64
102
  this.ignoreLocalCache = options.ignoreLocalCache ?? false;
65
103
  this.subscribeSDREvents = options.subscribeSDREvents ?? false;
66
- this.registry = new source_deploy_retrieve_1.RegistryAccess(undefined, this.projectPath);
104
+ this.registry = options.registry ?? new source_deploy_retrieve_1.RegistryAccess(undefined, this.projectPath);
67
105
  }
68
106
  async init() {
69
107
  await this.maybeSubscribeLifecycleEvents();
@@ -117,7 +155,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
117
155
  const componentSet = new source_deploy_retrieve_1.ComponentSet(applyIgnore ? sourceBackedComponents.filter(noFileIsIgnored(this.forceIgnore)) : sourceBackedComponents, this.registry);
118
156
  // there may be remote adds not in the SBC. So we add those manually
119
157
  (applyIgnore
120
- ? (0, remoteChangeIgnoring_1.removeIgnored)(changeResults, this.forceIgnore, this.project.getDefaultPackage().fullPath)
158
+ ? (0, remoteChangeIgnoring_1.removeIgnored)(changeResults, this.forceIgnore, this.project.getDefaultPackage().fullPath, this.registry)
121
159
  : changeResults.map(functions_1.remoteChangeToMetadataMember)).map((mm) => {
122
160
  componentSet.add(mm);
123
161
  });
@@ -194,11 +232,11 @@ class SourceTracking extends kit_1.AsyncCreatable {
194
232
  // skip any remote types not in the registry. Will emit warnings
195
233
  .filter((rce) => (0, metadataKeys_1.registrySupportsType)(this.registry)(rce.type));
196
234
  if (options.format === 'ChangeResult') {
197
- return filteredChanges.map(remoteSourceTrackingService_1.remoteChangeElementToChangeResult);
235
+ return filteredChanges.map((0, remoteSourceTrackingService_1.remoteChangeElementToChangeResult)(this.registry));
198
236
  }
199
237
  if (options.format === 'ChangeResultWithPaths') {
200
238
  return (0, populateFilePaths_1.populateFilePaths)({
201
- elements: filteredChanges.map(remoteSourceTrackingService_1.remoteChangeElementToChangeResult),
239
+ elements: filteredChanges.map((0, remoteSourceTrackingService_1.remoteChangeElementToChangeResult)(this.registry)),
202
240
  packageDirPaths: this.project.getPackageDirectories().map((pkgDir) => pkgDir.fullPath),
203
241
  registry: this.registry,
204
242
  });
@@ -256,7 +294,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
256
294
  // delete the files
257
295
  await Promise.all(filenames.map((filename) => sourceComponentByFileName.get(filename)?.type.id === 'customlabel' && nonDecomposedLabels
258
296
  ? (0, functions_2.deleteCustomLabels)(filename, changesToDelete.filter(functions_3.sourceComponentIsCustomLabel))
259
- : node_fs_1.default.promises.unlink(filename)));
297
+ : fs.promises.unlink(filename)));
260
298
  // update the tracking files. We're simulating SDR-style fileResponse
261
299
  await Promise.all([
262
300
  this.updateLocalTracking({ deletedFiles: filenames }),
@@ -276,8 +314,6 @@ class SourceTracking extends kit_1.AsyncCreatable {
276
314
  */
277
315
  async updateLocalTracking(options) {
278
316
  this.logger.trace('start: updateLocalTracking', options);
279
- const marker = performance_1.Performance.mark('@salesforce/source-tracking', 'SourceTracking.updateLocalTracking');
280
- marker?.addDetails({ nonDeletes: options.files?.length ?? 0, deletes: options.deletedFiles?.length ?? 0 });
281
317
  await this.ensureLocalTracking();
282
318
  this.logger.trace('files', options.files);
283
319
  // relative paths make smaller trees AND isogit wants them relative
@@ -304,7 +340,6 @@ class SourceTracking extends kit_1.AsyncCreatable {
304
340
  deletedFiles: relativeOptions.deletedFiles.concat((await this.localRepo.getDeleteFilenames()).filter((deployedFile) => bundlesWithDeletedFiles.some((0, functions_2.folderContainsPath)(deployedFile)) &&
305
341
  !relativeOptions.files.includes(deployedFile))),
306
342
  });
307
- marker?.stop();
308
343
  this.logger.trace('done: updateLocalTracking', options);
309
344
  }
310
345
  /**
@@ -312,16 +347,13 @@ class SourceTracking extends kit_1.AsyncCreatable {
312
347
  * Optional skip polling for the SourceMembers to exist on the server and be updated in local files
313
348
  */
314
349
  async updateRemoteTracking(fileResponses, skipPolling = false) {
315
- const marker = performance_1.Performance.mark('@salesforce/source-tracking', 'SourceTracking.updateRemoteTracking');
316
- marker?.addDetails({ fileResponseCount: fileResponses.length, skipPolling });
317
350
  // false to explicitly NOT query until we do the polling
318
351
  await this.ensureRemoteTracking(false);
319
352
  if (!skipPolling) {
320
353
  // poll to make sure we have the updates before syncing the ones from metadataKeys
321
- await this.remoteSourceTrackingService.pollForSourceTracking(fileResponses);
354
+ await this.remoteSourceTrackingService.pollForSourceTracking(this.registry, fileResponses);
322
355
  }
323
- await this.remoteSourceTrackingService.syncSpecifiedElements(fileResponses);
324
- marker?.stop();
356
+ await this.remoteSourceTrackingService.syncSpecifiedElements(this.registry, fileResponses);
325
357
  }
326
358
  async reReadLocalTrackingCache() {
327
359
  await this.localRepo.getStatus(true);
@@ -408,7 +440,6 @@ class SourceTracking extends kit_1.AsyncCreatable {
408
440
  * Compares local and remote changes to detect conflicts
409
441
  */
410
442
  async getConflicts() {
411
- const marker = performance_1.Performance.mark('@salesforce/source-tracking', 'SourceTracking.getConflicts');
412
443
  // we're going to need have both initialized
413
444
  await Promise.all([this.ensureRemoteTracking(), this.ensureLocalTracking()]);
414
445
  // Strategy: check local changes first (since it'll be faster) to avoid callout
@@ -438,7 +469,6 @@ class SourceTracking extends kit_1.AsyncCreatable {
438
469
  forceIgnore: this.forceIgnore,
439
470
  registry: this.registry,
440
471
  });
441
- marker?.stop();
442
472
  return result;
443
473
  }
444
474
  /**
@@ -541,7 +571,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
541
571
  // reserve the right to do something more sophisticated in the future
542
572
  // via async for figuring out hypothetical filenames (ex: getting default packageDir)
543
573
  // eslint-disable-next-line @typescript-eslint/require-await
544
- async remoteChangesToOutputRows(input, registry = new source_deploy_retrieve_1.RegistryAccess()) {
574
+ async remoteChangesToOutputRows(input) {
545
575
  this.logger.debug('converting ChangeResult to a row', input);
546
576
  this.forceIgnore ??= source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().path);
547
577
  const baseObject = {
@@ -561,7 +591,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
561
591
  // when the file doesn't exist locally, there are no filePaths
562
592
  // SDR can generate the hypothetical place it *would* go and check that
563
593
  if ((0, guards_1.isChangeResultWithNameAndType)(input)) {
564
- const ignored = (0, filePathGenerator_1.filePathsFromMetadataComponent)((0, functions_1.changeResultToMetadataComponent)(registry)(input)).some((0, functions_2.forceIgnoreDenies)(this.forceIgnore));
594
+ const ignored = (0, filePathGenerator_1.filePathsFromMetadataComponent)((0, functions_1.changeResultToMetadataComponent)(this.registry)(input)).some((0, functions_2.forceIgnoreDenies)(this.forceIgnore));
565
595
  return [
566
596
  {
567
597
  ...baseObject,