@salesforce/source-tracking 1.1.6 → 1.1.7

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.7](https://github.com/forcedotcom/source-tracking/compare/v1.1.6...v1.1.7) (2022-03-16)
6
+
7
+ ### Bug Fixes
8
+
9
+ - use isogit multiple add ([0845df8](https://github.com/forcedotcom/source-tracking/commit/0845df81845f07bd2bece444118497b2ef72e7aa))
10
+
5
11
  ### [1.1.6](https://github.com/forcedotcom/source-tracking/compare/v1.1.5...v1.1.6) (2022-03-14)
6
12
 
7
13
  ### [1.1.5](https://github.com/forcedotcom/source-tracking/compare/v1.1.4...v1.1.5) (2022-03-11)
@@ -9,6 +9,7 @@ interface CommitRequest {
9
9
  deployedFiles?: string[];
10
10
  deletedFiles?: string[];
11
11
  message?: string;
12
+ needsUpdatedStatus?: boolean;
12
13
  }
13
14
  export declare class ShadowRepo {
14
15
  private static instanceMap;
@@ -74,7 +75,7 @@ export declare class ShadowRepo {
74
75
  *
75
76
  * @returns sha (string)
76
77
  */
77
- commitChanges({ deployedFiles, deletedFiles, message, }?: CommitRequest): Promise<string>;
78
+ commitChanges({ deployedFiles, deletedFiles, message, needsUpdatedStatus, }?: CommitRequest): Promise<string>;
78
79
  private locateIgnoreFiles;
79
80
  private stashIgnoreFile;
80
81
  private unStashIgnoreFile;
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.ShadowRepo = void 0;
11
11
  const path = require("path");
12
12
  const os = require("os");
13
+ const fs = require("fs");
13
14
  const core_1 = require("@salesforce/core");
14
15
  const git = require("isomorphic-git");
15
16
  const functions_1 = require("./functions");
@@ -46,7 +47,7 @@ class ShadowRepo {
46
47
  async init() {
47
48
  this.logger = await core_1.Logger.child('ShadowRepo');
48
49
  // initialize the shadow repo if it doesn't exist
49
- if (!core_1.fs.existsSync(this.gitDir)) {
50
+ if (!fs.existsSync(this.gitDir)) {
50
51
  this.logger.debug('initializing git repo');
51
52
  await this.gitInit();
52
53
  }
@@ -57,8 +58,8 @@ class ShadowRepo {
57
58
  *
58
59
  */
59
60
  async gitInit() {
60
- await core_1.fs.promises.mkdir(this.gitDir, { recursive: true });
61
- await git.init({ fs: core_1.fs, dir: this.projectPath, gitdir: this.gitDir, defaultBranch: 'main' });
61
+ await fs.promises.mkdir(this.gitDir, { recursive: true });
62
+ await git.init({ fs, dir: this.projectPath, gitdir: this.gitDir, defaultBranch: 'main' });
62
63
  }
63
64
  /**
64
65
  * Delete the local tracking files
@@ -66,12 +67,12 @@ class ShadowRepo {
66
67
  * @returns the deleted directory
67
68
  */
68
69
  async delete() {
69
- if (typeof core_1.fs.promises.rm === 'function') {
70
- await core_1.fs.promises.rm(this.gitDir, { recursive: true, force: true });
70
+ if (typeof fs.promises.rm === 'function') {
71
+ await fs.promises.rm(this.gitDir, { recursive: true, force: true });
71
72
  }
72
73
  else {
73
74
  // when node 12 support is over, switch to promise version
74
- core_1.fs.rmdirSync(this.gitDir, { recursive: true });
75
+ fs.rmdirSync(this.gitDir, { recursive: true });
75
76
  }
76
77
  return this.gitDir;
77
78
  }
@@ -95,7 +96,7 @@ class ShadowRepo {
95
96
  : this.packageDirs.map((dir) => dir.path);
96
97
  // status hasn't been initalized yet
97
98
  this.status = await git.statusMatrix({
98
- fs: core_1.fs,
99
+ fs,
99
100
  dir: this.projectPath,
100
101
  gitdir: this.gitDir,
101
102
  filepaths,
@@ -173,37 +174,36 @@ class ShadowRepo {
173
174
  *
174
175
  * @returns sha (string)
175
176
  */
176
- async commitChanges({ deployedFiles = [], deletedFiles = [], message = 'sfdx source tracking', } = {}) {
177
+ async commitChanges({ deployedFiles = [], deletedFiles = [], message = 'sfdx source tracking', needsUpdatedStatus = true, } = {}) {
177
178
  // if no files are specified, commit all changes
178
179
  if (deployedFiles.length === 0 && deletedFiles.length === 0) {
179
180
  // this is valid, might not be an error
180
181
  return 'no files to commit';
181
182
  }
182
- this.logger.debug('changes are', deployedFiles);
183
- this.logger.debug('deletes are', deletedFiles);
184
183
  await this.stashIgnoreFile();
185
184
  // these are stored in posix/style/path format. We have to convert inbound stuff from windows
186
185
  if (os.type() === 'Windows_NT') {
187
186
  deployedFiles = deployedFiles.map((filepath) => path.normalize(filepath).split(path.sep).join(path.posix.sep));
188
187
  deletedFiles = deletedFiles.map((filepath) => path.normalize(filepath).split(path.sep).join(path.posix.sep));
189
188
  }
190
- const uniqueDeployedFiles = Array.from(new Set(deployedFiles));
191
- const uniqueDeletedFiles = Array.from(new Set(deletedFiles));
192
189
  try {
193
- // stage changes
194
- await Promise.all([
195
- ...uniqueDeployedFiles.map((filepath) => git.add({ fs: core_1.fs, dir: this.projectPath, gitdir: this.gitDir, filepath })),
196
- ...uniqueDeletedFiles.map((filepath) => git.remove({ fs: core_1.fs, dir: this.projectPath, gitdir: this.gitDir, filepath })),
197
- ]);
190
+ if (deployedFiles.length) {
191
+ await git.add({ fs, dir: this.projectPath, gitdir: this.gitDir, filepath: [...new Set(deployedFiles)] });
192
+ }
193
+ for (const filepath of [...new Set(deletedFiles)]) {
194
+ await git.remove({ fs, dir: this.projectPath, gitdir: this.gitDir, filepath });
195
+ }
198
196
  const sha = await git.commit({
199
- fs: core_1.fs,
197
+ fs,
200
198
  dir: this.projectPath,
201
199
  gitdir: this.gitDir,
202
200
  message,
203
201
  author: { name: 'sfdx source tracking' },
204
202
  });
205
203
  // status changed as a result of the commit. This prevents users from having to run getStatus(true) to avoid cache
206
- await this.getStatus(true);
204
+ if (needsUpdatedStatus) {
205
+ await this.getStatus(true);
206
+ }
207
207
  return sha;
208
208
  }
209
209
  finally {
@@ -213,7 +213,7 @@ class ShadowRepo {
213
213
  async locateIgnoreFiles() {
214
214
  // set the gitIgnoreLocations so we only have to do it once
215
215
  this.gitIgnoreLocations = (await git.walk({
216
- fs: core_1.fs,
216
+ fs,
217
217
  dir: this.projectPath,
218
218
  gitdir: this.gitDir,
219
219
  trees: [git.WORKDIR()],
@@ -225,11 +225,11 @@ class ShadowRepo {
225
225
  }
226
226
  async stashIgnoreFile() {
227
227
  // allSettled allows them to fail (example, the file wasn't where it was expected).
228
- await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => core_1.fs.promises.rename(originalLocation, originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName))));
228
+ await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => fs.promises.rename(originalLocation, originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName))));
229
229
  }
230
230
  async unStashIgnoreFile() {
231
231
  // allSettled allows them to fail (example, the file wasn't where it was expected).
232
- await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => core_1.fs.promises.rename(originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName), originalLocation)));
232
+ await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => fs.promises.rename(originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName), originalLocation)));
233
233
  }
234
234
  }
235
235
  exports.ShadowRepo = ShadowRepo;
@@ -11,6 +11,7 @@ var _a;
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.remoteChangeElementToChangeResult = exports.RemoteSourceTrackingService = void 0;
13
13
  const path = require("path");
14
+ const fs = require("fs");
14
15
  const ts_retry_promise_1 = require("ts-retry-promise");
15
16
  const core_1 = require("@salesforce/core");
16
17
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
@@ -98,8 +99,8 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
98
99
  static async delete(orgId) {
99
100
  const fileToDelete = RemoteSourceTrackingService.getFilePath(orgId);
100
101
  // the file might not exist, in which case we don't need to delete it
101
- if (core_1.fs.existsSync(fileToDelete)) {
102
- await core_1.fs.promises.unlink(fileToDelete);
102
+ if (fs.existsSync(fileToDelete)) {
103
+ await fs.promises.unlink(fileToDelete);
103
104
  }
104
105
  return path.isAbsolute(fileToDelete) ? fileToDelete : path.join(process.cwd(), fileToDelete);
105
106
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/source-tracking",
3
3
  "description": "API for tracking local and remote Salesforce metadata changes",
4
- "version": "1.1.6",
4
+ "version": "1.1.7",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",
@@ -46,7 +46,7 @@
46
46
  "@salesforce/core": "^2.33.1",
47
47
  "@salesforce/kit": "^1.5.17",
48
48
  "@salesforce/source-deploy-retrieve": "^5.9.4",
49
- "isomorphic-git": "^1.9.2",
49
+ "isomorphic-git": "1.14.0",
50
50
  "ts-retry-promise": "^0.6.0"
51
51
  },
52
52
  "devDependencies": {