@salesforce/source-tracking 1.1.4 → 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,16 @@
|
|
|
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
|
+
|
|
11
|
+
### [1.1.6](https://github.com/forcedotcom/source-tracking/compare/v1.1.5...v1.1.6) (2022-03-14)
|
|
12
|
+
|
|
13
|
+
### [1.1.5](https://github.com/forcedotcom/source-tracking/compare/v1.1.4...v1.1.5) (2022-03-11)
|
|
14
|
+
|
|
5
15
|
### [1.1.4](https://github.com/forcedotcom/source-tracking/compare/v1.1.3...v1.1.4) (2022-03-07)
|
|
6
16
|
|
|
7
17
|
### Bug Fixes
|
|
@@ -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 (!
|
|
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
|
|
61
|
-
await git.init({ fs
|
|
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
|
|
70
|
-
await
|
|
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
|
-
|
|
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
|
|
99
|
+
fs,
|
|
99
100
|
dir: this.projectPath,
|
|
100
101
|
gitdir: this.gitDir,
|
|
101
102
|
filepaths,
|
|
@@ -173,14 +174,12 @@ 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') {
|
|
@@ -188,20 +187,23 @@ class ShadowRepo {
|
|
|
188
187
|
deletedFiles = deletedFiles.map((filepath) => path.normalize(filepath).split(path.sep).join(path.posix.sep));
|
|
189
188
|
}
|
|
190
189
|
try {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
}
|
|
196
196
|
const sha = await git.commit({
|
|
197
|
-
fs
|
|
197
|
+
fs,
|
|
198
198
|
dir: this.projectPath,
|
|
199
199
|
gitdir: this.gitDir,
|
|
200
200
|
message,
|
|
201
201
|
author: { name: 'sfdx source tracking' },
|
|
202
202
|
});
|
|
203
203
|
// status changed as a result of the commit. This prevents users from having to run getStatus(true) to avoid cache
|
|
204
|
-
|
|
204
|
+
if (needsUpdatedStatus) {
|
|
205
|
+
await this.getStatus(true);
|
|
206
|
+
}
|
|
205
207
|
return sha;
|
|
206
208
|
}
|
|
207
209
|
finally {
|
|
@@ -211,7 +213,7 @@ class ShadowRepo {
|
|
|
211
213
|
async locateIgnoreFiles() {
|
|
212
214
|
// set the gitIgnoreLocations so we only have to do it once
|
|
213
215
|
this.gitIgnoreLocations = (await git.walk({
|
|
214
|
-
fs
|
|
216
|
+
fs,
|
|
215
217
|
dir: this.projectPath,
|
|
216
218
|
gitdir: this.gitDir,
|
|
217
219
|
trees: [git.WORKDIR()],
|
|
@@ -223,11 +225,11 @@ class ShadowRepo {
|
|
|
223
225
|
}
|
|
224
226
|
async stashIgnoreFile() {
|
|
225
227
|
// allSettled allows them to fail (example, the file wasn't where it was expected).
|
|
226
|
-
await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) =>
|
|
228
|
+
await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => fs.promises.rename(originalLocation, originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName))));
|
|
227
229
|
}
|
|
228
230
|
async unStashIgnoreFile() {
|
|
229
231
|
// allSettled allows them to fail (example, the file wasn't where it was expected).
|
|
230
|
-
await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) =>
|
|
232
|
+
await Promise.allSettled(this.gitIgnoreLocations.map((originalLocation) => fs.promises.rename(originalLocation.replace(gitIgnoreFileName, stashedGitIgnoreFileName), originalLocation)));
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
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 (
|
|
102
|
-
await
|
|
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.
|
|
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": "
|
|
49
|
+
"isomorphic-git": "1.14.0",
|
|
50
50
|
"ts-retry-promise": "^0.6.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|