@salesforce/source-tracking 0.2.2 → 0.4.2
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 +78 -0
- package/README.md +6 -6
- package/lib/compatibility.d.ts +4 -2
- package/lib/compatibility.js +7 -4
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -0
- package/lib/shared/filenamesToVirtualTree.d.ts +1 -0
- package/lib/shared/filenamesToVirtualTree.js +1 -0
- package/lib/shared/functions.d.ts +3 -0
- package/lib/shared/functions.js +21 -0
- package/lib/shared/guards.d.ts +3 -0
- package/lib/shared/guards.js +19 -0
- package/lib/shared/localShadowRepo.d.ts +4 -4
- package/lib/shared/localShadowRepo.js +36 -25
- package/lib/shared/metadataKeys.js +6 -6
- package/lib/shared/remoteSourceTrackingService.d.ts +6 -20
- package/lib/shared/remoteSourceTrackingService.js +30 -13
- package/lib/shared/types.d.ts +47 -1
- package/lib/sourceTracking.d.ts +28 -34
- package/lib/sourceTracking.js +229 -92
- package/package.json +5 -8
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
### [0.4.2](https://github.com/forcedotcom/source-tracking/compare/v0.4.1...v0.4.2) (2021-10-28)
|
|
6
|
+
|
|
7
|
+
### [0.4.1](https://github.com/forcedotcom/source-tracking/compare/v0.4.0...v0.4.1) (2021-10-28)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* better conflict handling (can match filenames or type/name) ([4441a0a](https://github.com/forcedotcom/source-tracking/commit/4441a0abd70c7f8f315e1c638b4cef7fcf3e2e68))
|
|
13
|
+
* gitignore stashing location ([5145545](https://github.com/forcedotcom/source-tracking/commit/5145545eeee6c800986014327479d20e943143e5))
|
|
14
|
+
* polling exclusion logic for aura meta.xml was wrong ([2d40b2e](https://github.com/forcedotcom/source-tracking/commit/2d40b2ef65ef9a3145d0c75cd4943e4325d5745c))
|
|
15
|
+
|
|
16
|
+
## 0.4.0 (2021-10-22)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### ⚠ BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* remove retrieve simplifier
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add commitlint and sample circleci config ([43e7fa4](https://github.com/forcedotcom/source-tracking/commit/43e7fa4a44dbcb9da37d21618678687f4edda644))
|
|
26
|
+
* add new tests and upadte readme ([6a7ad54](https://github.com/forcedotcom/source-tracking/commit/6a7ad542f42ce75275ebacc78d50ee4dc0ab6f32))
|
|
27
|
+
* add option to get remoteChanges with filePaths, use for Conflicts ([350a0d6](https://github.com/forcedotcom/source-tracking/commit/350a0d60599cfce2c432c223f4523c25a4f53c81))
|
|
28
|
+
* basic using isogit ([f39e6c5](https://github.com/forcedotcom/source-tracking/commit/f39e6c5e305fcb2fdb6a27b343d9dc20800202c9))
|
|
29
|
+
* conflict detection ([3e22774](https://github.com/forcedotcom/source-tracking/commit/3e22774d8949a1aa4302e62d8580b69c4b35aab5))
|
|
30
|
+
* consolidate conflict handling, return data in error ([45178c7](https://github.com/forcedotcom/source-tracking/commit/45178c7b13ed61e657f9a07ea5b40f49f73f651a))
|
|
31
|
+
* delete handling public for pull ([eb87eb7](https://github.com/forcedotcom/source-tracking/commit/eb87eb7dfa81ba5256735af7f2b8bc29dfb1e16b))
|
|
32
|
+
* finish status, add clear/reset ([c71e66f](https://github.com/forcedotcom/source-tracking/commit/c71e66f7f7a3dc20d2c965349b5e01e15edabf36))
|
|
33
|
+
* handle status ignore marking from STL ([2ec6fad](https://github.com/forcedotcom/source-tracking/commit/2ec6fad4b4f4f2e124da7e4f53cf8e534354d342))
|
|
34
|
+
* ignorewarnings flag for push ([b13fd05](https://github.com/forcedotcom/source-tracking/commit/b13fd0534930fb063075c39e6f75ea46ab9d3be8))
|
|
35
|
+
* migrate messages/descriptions ([8fea6e5](https://github.com/forcedotcom/source-tracking/commit/8fea6e5242c50865dd635412d7592164ab57fec4))
|
|
36
|
+
* most of sourceStatus logic, code cleanup ([f100cb8](https://github.com/forcedotcom/source-tracking/commit/f100cb83f220b3724284ae69301712a08b14376d))
|
|
37
|
+
* non-delete push works ([487a20e](https://github.com/forcedotcom/source-tracking/commit/487a20e48c428a02ef315b58db24b714d2de0416))
|
|
38
|
+
* push supporting bundle types ([639d459](https://github.com/forcedotcom/source-tracking/commit/639d459101cd4990fa217f657b99d64517611383))
|
|
39
|
+
* remote and conflicts ([f98ecf1](https://github.com/forcedotcom/source-tracking/commit/f98ecf17fc6cbe386d8edae6994500388b7e0ed6))
|
|
40
|
+
* remote tracknig with UT ([cb805e5](https://github.com/forcedotcom/source-tracking/commit/cb805e5745020be9a266a261f584979713e4b351))
|
|
41
|
+
* source tracking from toolbelt ([6c2ebb4](https://github.com/forcedotcom/source-tracking/commit/6c2ebb444ce5518eaa81402b685fe00f1090e437))
|
|
42
|
+
* sourcemember polling like toolbelt ([abdd7b3](https://github.com/forcedotcom/source-tracking/commit/abdd7b3ad275ea4739673a6e1b1a99853f1de2da))
|
|
43
|
+
* spinners while waiting on pull ([dfe5aea](https://github.com/forcedotcom/source-tracking/commit/dfe5aeae0a5f9a30eddfe96852e0dab025972e1e))
|
|
44
|
+
* status result sorting ([b7b109c](https://github.com/forcedotcom/source-tracking/commit/b7b109cf3e7bcad60507618099873c717ff31f61))
|
|
45
|
+
* sync customObj when their fields sync ([3ded96d](https://github.com/forcedotcom/source-tracking/commit/3ded96dbd7a7ea45cb8f97719b98bae294905c05))
|
|
46
|
+
* throws if "old" source files are present ([4b868d8](https://github.com/forcedotcom/source-tracking/commit/4b868d8232769eec5e227052bf823a35baedd288))
|
|
47
|
+
* typed push ([6e76812](https://github.com/forcedotcom/source-tracking/commit/6e7681263b81d3b692d002a3ce5deb8ef00bbd13))
|
|
48
|
+
* virtualTree for deletes ([b425d77](https://github.com/forcedotcom/source-tracking/commit/b425d77b4fca5c6fbab2faab7490e3516bf3f547))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* again with the promises ([ad9dec5](https://github.com/forcedotcom/source-tracking/commit/ad9dec50336c61996456d48ee489426393c62329))
|
|
54
|
+
* another attempt at node12 support ([c8736d0](https://github.com/forcedotcom/source-tracking/commit/c8736d0bbe53756d1b5572e00402e55af94003c1))
|
|
55
|
+
* case of empty orgId dir ([1cb6333](https://github.com/forcedotcom/source-tracking/commit/1cb6333d14cfcee02b27711b6db273d5db31fc8e))
|
|
56
|
+
* case on formatter filename ([02adf22](https://github.com/forcedotcom/source-tracking/commit/02adf22419d2bf81fb070d7d7d90f7d996bd1ada))
|
|
57
|
+
* casing on imports ([d4425d9](https://github.com/forcedotcom/source-tracking/commit/d4425d9ee2ad77c4e28d32333025e59a3c7e3af9))
|
|
58
|
+
* correct statusCommand description ([b834a2f](https://github.com/forcedotcom/source-tracking/commit/b834a2fa0213fbc72dbc6dc3a563cd92f413d222))
|
|
59
|
+
* don't commit empty changelists ([67b9772](https://github.com/forcedotcom/source-tracking/commit/67b9772eccd6d2d4850322eb80f5a6113aac18e6))
|
|
60
|
+
* export compatibility ([c6e5f7c](https://github.com/forcedotcom/source-tracking/commit/c6e5f7cba68ed6a7739b237adb027fda2442e8c4))
|
|
61
|
+
* fix vscode image in readme ([441c15f](https://github.com/forcedotcom/source-tracking/commit/441c15f79dbaf4a97c84d9d6ddc923eae59bca34))
|
|
62
|
+
* handle org:create's single tracking file ([008793d](https://github.com/forcedotcom/source-tracking/commit/008793d0fa15210ffb263cc5d179a0be8dcb05ff))
|
|
63
|
+
* handle stash failures ([09dacc9](https://github.com/forcedotcom/source-tracking/commit/09dacc9484e48f3cba4813f3d733c66d2a30cd6b))
|
|
64
|
+
* leif .yml merge [skip-validate-pr] ([ff10f84](https://github.com/forcedotcom/source-tracking/commit/ff10f84ec15757df55657ba73cc6976c5892595c))
|
|
65
|
+
* local ST uses graceful via core2 ([3ba883f](https://github.com/forcedotcom/source-tracking/commit/3ba883ff2b02e27b0eb01a709f6c1e03ef91bb73))
|
|
66
|
+
* match server subfiles with forward slash ([c2489a6](https://github.com/forcedotcom/source-tracking/commit/c2489a62c244a64fe0938e0eecdc087f4529b5ad))
|
|
67
|
+
* normalize windows paths on commit, too ([4339e46](https://github.com/forcedotcom/source-tracking/commit/4339e46a1cb9cbeb4cc652572e340b60e3b5bc68))
|
|
68
|
+
* one more fs/promises fixed for node12 ([71bafcf](https://github.com/forcedotcom/source-tracking/commit/71bafcf7738e60d8b86150199ef8d0687167a010))
|
|
69
|
+
* path normalizing for metadata keys ([6190590](https://github.com/forcedotcom/source-tracking/commit/6190590df2c2e7cc9a25eab0fa8891e3b8df9057))
|
|
70
|
+
* path normalizing from iso-git ([b8cddaf](https://github.com/forcedotcom/source-tracking/commit/b8cddaf40930bedd18f3edec578a030220454627))
|
|
71
|
+
* status output on windows uses backslash ([78ac398](https://github.com/forcedotcom/source-tracking/commit/78ac3988d3d04e956f17f35c67de4d1144062fcb))
|
|
72
|
+
* support windows path on commits with \\ ([5712af4](https://github.com/forcedotcom/source-tracking/commit/5712af4447ee03e30d7a5a769fc5ba58f6913552))
|
|
73
|
+
* there could be nested LWC templates ([d833981](https://github.com/forcedotcom/source-tracking/commit/d8339810bf76c0ab75824faee7aef59ff9a2d89e))
|
|
74
|
+
* turns bundle parts of SourceMembers into real MDtypes ([5646042](https://github.com/forcedotcom/source-tracking/commit/564604269be7d56499963699b51920b81227297f))
|
|
75
|
+
* use correct var name ([0708312](https://github.com/forcedotcom/source-tracking/commit/0708312c5b4f11cb94539416d0a10b5432850310))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
* remove retrieve simplifier ([bd71eef](https://github.com/forcedotcom/source-tracking/commit/bd71eef784bc7c7efd1999ba11193e632aef3d47))
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ const tracking = await SourceTracking.create({
|
|
|
20
20
|
|
|
21
21
|
Any calls to methods on your instance of `tracking` will check to make sure that the appropriate remote/local files are up to date and loaded.
|
|
22
22
|
|
|
23
|
-
If you know you need to access remote or local, you can `ensure` them so that the FS and API operations don't happen multiple time (useful before calling operations
|
|
23
|
+
If you know you need to access remote or local, you can `ensure` them so that the FS and API operations don't happen multiple time (useful before calling operations that run in parallel)
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
await tracking.ensureRemoteTracking(); // pass `true` if you know you need to force a re-query.
|
|
@@ -29,17 +29,17 @@ await tracking.ensureRemoteTracking(); // pass `true` if you know you need to fo
|
|
|
29
29
|
await tracking.ensureLocalTracking();
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
## Use cases
|
|
33
33
|
|
|
34
34
|
1. push,pull,status: `getConflicts()`, `getChanges()`
|
|
35
35
|
1. deploy/retrieve: `updateLocalTracking()`,`updateRemoteTracking`
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
### Deploy
|
|
38
38
|
|
|
39
39
|
1. Once your SDR-based deploy finishes, you need to update the client's tracking files for both local (because local files went to the server) AND remote (because your deployment will result in new SourceMembers that need to be synced to the client).
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
-
// send
|
|
42
|
+
// send in two arrays of Files (nonDeletes and Deletes)
|
|
43
43
|
await tracking.updateLocalTracking({
|
|
44
44
|
deployedFiles: ['force-app/main/default/classes/MyClass.cls', 'force-app/main/default/classes/MyClass.cls-meta.xml'],
|
|
45
45
|
deletedFiles: [],
|
|
@@ -63,7 +63,7 @@ await tracking.updateRemoteTracking([
|
|
|
63
63
|
]);
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### Retrieve
|
|
67
67
|
|
|
68
68
|
Once your retrieve finishes, use the same updateLocalTracking as you did for deploy to commit the file changes to local and remote changes.
|
|
69
69
|
|
|
@@ -93,7 +93,7 @@ await tracking.updateRemoteTracking(
|
|
|
93
93
|
NUT for tracking file compatibility check logic
|
|
94
94
|
pollSourceMembers should better handle aggregated types. ex:
|
|
95
95
|
|
|
96
|
-
```
|
|
96
|
+
```txt
|
|
97
97
|
DEBUG Could not find 2 SourceMembers (using ebikes): AuraDefinition__pageTemplate_2_7_3/pageTemplate_2_7_3.cmp-meta.xml,[object Object],CustomObject__Account,[object Object]
|
|
98
98
|
```
|
|
99
99
|
|
package/lib/compatibility.d.ts
CHANGED
|
@@ -3,11 +3,14 @@ declare type TrackingFileVersion = 'plugin-source' | 'toolbelt' | 'none';
|
|
|
3
3
|
/**
|
|
4
4
|
* A project can have "old" (toolbelt), "new" (plugin-source) or "none" tracking files
|
|
5
5
|
*
|
|
6
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
6
7
|
*/
|
|
7
8
|
export declare const getTrackingFileVersion: (org: Org, projectPath: string) => TrackingFileVersion;
|
|
8
9
|
/**
|
|
9
10
|
* Convenient wrapper for throwing errors with helpful messages so commands don't have to
|
|
10
11
|
*
|
|
12
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
13
|
+
*
|
|
11
14
|
* @param org: an Org, typically from a command's this.org
|
|
12
15
|
* @param project: the project path, typically from this.project.
|
|
13
16
|
* @param toValidate: whether your command lives in 'toolbelt' or 'plugin-source'
|
|
@@ -20,11 +23,10 @@ export declare const throwIfInvalid: ({ org, projectPath, toValidate, command, }
|
|
|
20
23
|
command: string;
|
|
21
24
|
}) => void;
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
26
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
24
27
|
* @param input the string that might contain things that would be replaced
|
|
25
28
|
* @param reverse use the mappings backward
|
|
26
29
|
* @returns string
|
|
27
30
|
*/
|
|
28
31
|
export declare const replaceRenamedCommands: (input: string, reverse?: boolean) => string;
|
|
29
|
-
export declare const renames: Map<string, string>;
|
|
30
32
|
export {};
|
package/lib/compatibility.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.replaceRenamedCommands = exports.throwIfInvalid = exports.getTrackingFileVersion = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -15,6 +15,7 @@ const messages = core_1.Messages.loadMessages('@salesforce/source-tracking', 'co
|
|
|
15
15
|
/**
|
|
16
16
|
* A project can have "old" (toolbelt), "new" (plugin-source) or "none" tracking files
|
|
17
17
|
*
|
|
18
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
18
19
|
*/
|
|
19
20
|
const getTrackingFileVersion = (org, projectPath) => {
|
|
20
21
|
const orgsDir = path.join(projectPath, '.sfdx', 'orgs');
|
|
@@ -38,6 +39,8 @@ exports.getTrackingFileVersion = getTrackingFileVersion;
|
|
|
38
39
|
/**
|
|
39
40
|
* Convenient wrapper for throwing errors with helpful messages so commands don't have to
|
|
40
41
|
*
|
|
42
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
43
|
+
*
|
|
41
44
|
* @param org: an Org, typically from a command's this.org
|
|
42
45
|
* @param project: the project path, typically from this.project.
|
|
43
46
|
* @param toValidate: whether your command lives in 'toolbelt' or 'plugin-source'
|
|
@@ -65,19 +68,19 @@ const throwIfInvalid = ({ org, projectPath, toValidate, command, }) => {
|
|
|
65
68
|
};
|
|
66
69
|
exports.throwIfInvalid = throwIfInvalid;
|
|
67
70
|
/**
|
|
68
|
-
*
|
|
71
|
+
* @deprecated use only during transition to new source-tracking commands
|
|
69
72
|
* @param input the string that might contain things that would be replaced
|
|
70
73
|
* @param reverse use the mappings backward
|
|
71
74
|
* @returns string
|
|
72
75
|
*/
|
|
73
76
|
const replaceRenamedCommands = (input, reverse = false) => {
|
|
74
|
-
|
|
77
|
+
renames.forEach((value, key) => {
|
|
75
78
|
input = reverse ? input.replace(value, key) : input.replace(key, value);
|
|
76
79
|
});
|
|
77
80
|
return input;
|
|
78
81
|
};
|
|
79
82
|
exports.replaceRenamedCommands = replaceRenamedCommands;
|
|
80
|
-
|
|
83
|
+
const renames = new Map([
|
|
81
84
|
['force:source:status', 'force:source:beta:status'],
|
|
82
85
|
['force:source:push', 'force:source:beta:push'],
|
|
83
86
|
['force:source:pull', 'force:source:beta:pull'],
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './sourceTracking';
|
|
2
2
|
export * from './compatibility';
|
|
3
|
-
export { RemoteSyncInput } from './shared/types';
|
|
3
|
+
export { RemoteSyncInput, ChangeOptionType, ChangeOptions, LocalUpdateOptions, ChangeResult, ConflictError, StatusOutputRow, } from './shared/types';
|
|
4
|
+
export { getKeyFromObject } from './shared/functions';
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.getKeyFromObject = void 0;
|
|
19
20
|
__exportStar(require("./sourceTracking"), exports);
|
|
20
21
|
__exportStar(require("./compatibility"), exports);
|
|
22
|
+
var functions_1 = require("./shared/functions");
|
|
23
|
+
Object.defineProperty(exports, "getKeyFromObject", { enumerable: true, get: function () { return functions_1.getKeyFromObject; } });
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VirtualTreeContainer } from '@salesforce/source-deploy-retrieve';
|
|
2
2
|
/**
|
|
3
|
+
* @deprecated this is moving to SDR
|
|
3
4
|
* Designed for recreating virtual files from deleted files where the only information we have is the file's former location
|
|
4
5
|
* Any use of MetadataResolver was trying to access the non-existent files and throwing
|
|
5
6
|
*
|
|
@@ -10,6 +10,7 @@ exports.filenamesToVirtualTree = void 0;
|
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
12
12
|
/**
|
|
13
|
+
* @deprecated this is moving to SDR
|
|
13
14
|
* Designed for recreating virtual files from deleted files where the only information we have is the file's former location
|
|
14
15
|
* Any use of MetadataResolver was trying to access the non-existent files and throwing
|
|
15
16
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getKeyFromObject = exports.getMetadataKey = void 0;
|
|
10
|
+
const getMetadataKey = (metadataType, metadataName) => {
|
|
11
|
+
return `${metadataType}__${metadataName}`;
|
|
12
|
+
};
|
|
13
|
+
exports.getMetadataKey = getMetadataKey;
|
|
14
|
+
const getKeyFromObject = (element) => {
|
|
15
|
+
if (element.type && element.name) {
|
|
16
|
+
return (0, exports.getMetadataKey)(element.type, element.name);
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`unable to complete key from ${JSON.stringify(element)}`);
|
|
19
|
+
};
|
|
20
|
+
exports.getKeyFromObject = getKeyFromObject;
|
|
21
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceComponentGuard = exports.stringGuard = void 0;
|
|
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
|
|
9
|
+
*/
|
|
10
|
+
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
11
|
+
const stringGuard = (input) => {
|
|
12
|
+
return typeof input === 'string';
|
|
13
|
+
};
|
|
14
|
+
exports.stringGuard = stringGuard;
|
|
15
|
+
const sourceComponentGuard = (input) => {
|
|
16
|
+
return input instanceof source_deploy_retrieve_1.SourceComponent;
|
|
17
|
+
};
|
|
18
|
+
exports.sourceComponentGuard = sourceComponentGuard;
|
|
19
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AsyncCreatable } from '@salesforce/kit';
|
|
2
1
|
import { NamedPackageDir } from '@salesforce/core';
|
|
3
2
|
interface ShadowRepoOptions {
|
|
4
3
|
orgId: string;
|
|
@@ -11,14 +10,15 @@ interface CommitRequest {
|
|
|
11
10
|
deletedFiles?: string[];
|
|
12
11
|
message?: string;
|
|
13
12
|
}
|
|
14
|
-
export declare class ShadowRepo
|
|
13
|
+
export declare class ShadowRepo {
|
|
14
|
+
private static instance;
|
|
15
15
|
gitDir: string;
|
|
16
16
|
projectPath: string;
|
|
17
17
|
private packageDirs;
|
|
18
18
|
private status;
|
|
19
19
|
private logger;
|
|
20
|
-
private
|
|
21
|
-
|
|
20
|
+
private constructor();
|
|
21
|
+
static getInstance(options: ShadowRepoOptions): Promise<ShadowRepo>;
|
|
22
22
|
init(): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Initialize a new source tracking shadow repo. Think of git init
|
|
@@ -10,9 +10,10 @@ 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 kit_1 = require("@salesforce/kit");
|
|
14
13
|
const core_1 = require("@salesforce/core");
|
|
15
14
|
const git = require("isomorphic-git");
|
|
15
|
+
const gitIgnoreFileName = '.gitignore';
|
|
16
|
+
const stashedGitIgnoreFileName = '.BAK.gitignore';
|
|
16
17
|
/**
|
|
17
18
|
* returns the full path to where we store the shadow repo
|
|
18
19
|
*/
|
|
@@ -25,17 +26,21 @@ const toFilenames = (rows) => rows.map((row) => row[FILE]);
|
|
|
25
26
|
const FILE = 0;
|
|
26
27
|
const HEAD = 1;
|
|
27
28
|
const WORKDIR = 2;
|
|
28
|
-
class ShadowRepo
|
|
29
|
+
class ShadowRepo {
|
|
29
30
|
constructor(options) {
|
|
30
|
-
super(options);
|
|
31
|
-
this.options = options;
|
|
32
31
|
this.gitDir = getGitDir(options.orgId, options.projectPath);
|
|
33
32
|
this.projectPath = options.projectPath;
|
|
34
33
|
this.packageDirs = options.packageDirs;
|
|
35
34
|
}
|
|
35
|
+
static async getInstance(options) {
|
|
36
|
+
if (!ShadowRepo.instance) {
|
|
37
|
+
ShadowRepo.instance = new ShadowRepo(options);
|
|
38
|
+
await ShadowRepo.instance.init();
|
|
39
|
+
}
|
|
40
|
+
return ShadowRepo.instance;
|
|
41
|
+
}
|
|
36
42
|
async init() {
|
|
37
43
|
this.logger = await core_1.Logger.child('ShadowRepo');
|
|
38
|
-
this.logger.debug('options for constructor are', this.options);
|
|
39
44
|
// initialize the shadow repo if it doesn't exist
|
|
40
45
|
if (!core_1.fs.existsSync(this.gitDir)) {
|
|
41
46
|
this.logger.debug('initializing git repo');
|
|
@@ -75,21 +80,25 @@ class ShadowRepo extends kit_1.AsyncCreatable {
|
|
|
75
80
|
*/
|
|
76
81
|
async getStatus(noCache = false) {
|
|
77
82
|
if (!this.status || noCache) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
try {
|
|
84
|
+
await this.stashIgnoreFile();
|
|
85
|
+
// status hasn't been initalized yet
|
|
86
|
+
this.status = await git.statusMatrix({
|
|
87
|
+
fs: core_1.fs,
|
|
88
|
+
dir: this.projectPath,
|
|
89
|
+
gitdir: this.gitDir,
|
|
90
|
+
filepaths: this.packageDirs.map((dir) => dir.path),
|
|
91
|
+
// filter out hidden files and __tests__ patterns, regardless of gitignore
|
|
92
|
+
filter: (f) => !f.includes(`${path.sep}.`) && !f.includes('__tests__'),
|
|
93
|
+
});
|
|
94
|
+
// isomorphic-git stores things in unix-style tree. Convert to windows-style if necessary
|
|
95
|
+
if (os.type() === 'Windows_NT') {
|
|
96
|
+
this.status = this.status.map((row) => [path.normalize(row[FILE]), row[HEAD], row[WORKDIR], row[3]]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
await this.unStashIgnoreFile();
|
|
91
101
|
}
|
|
92
|
-
await this.unStashIgnoreFile();
|
|
93
102
|
}
|
|
94
103
|
return this.status;
|
|
95
104
|
}
|
|
@@ -149,8 +158,8 @@ class ShadowRepo extends kit_1.AsyncCreatable {
|
|
|
149
158
|
async commitChanges({ deployedFiles = [], deletedFiles = [], message = 'sfdx source tracking', } = {}) {
|
|
150
159
|
// if no files are specified, commit all changes
|
|
151
160
|
if (deployedFiles.length === 0 && deletedFiles.length === 0) {
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
// this is valid, might not be an error
|
|
162
|
+
return 'no files to commit';
|
|
154
163
|
}
|
|
155
164
|
this.logger.debug('changes are', deployedFiles);
|
|
156
165
|
this.logger.debug('deletes are', deletedFiles);
|
|
@@ -173,6 +182,8 @@ class ShadowRepo extends kit_1.AsyncCreatable {
|
|
|
173
182
|
message,
|
|
174
183
|
author: { name: 'sfdx source tracking' },
|
|
175
184
|
});
|
|
185
|
+
// status changed as a result of the commit. This prevents users from having to run getStatus(true) to avoid cache
|
|
186
|
+
await this.getStatus(true);
|
|
176
187
|
return sha;
|
|
177
188
|
}
|
|
178
189
|
finally {
|
|
@@ -180,17 +191,17 @@ class ShadowRepo extends kit_1.AsyncCreatable {
|
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
async stashIgnoreFile() {
|
|
183
|
-
const originalLocation = path.join(this.projectPath,
|
|
194
|
+
const originalLocation = path.join(this.projectPath, gitIgnoreFileName);
|
|
184
195
|
// another process may have already stashed the file
|
|
185
196
|
if (core_1.fs.existsSync(originalLocation)) {
|
|
186
|
-
await core_1.fs.promises.rename(originalLocation, path.join(this.projectPath,
|
|
197
|
+
await core_1.fs.promises.rename(originalLocation, path.join(this.projectPath, stashedGitIgnoreFileName));
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
200
|
async unStashIgnoreFile() {
|
|
190
|
-
const stashedLocation = path.join(this.projectPath,
|
|
201
|
+
const stashedLocation = path.join(this.projectPath, stashedGitIgnoreFileName);
|
|
191
202
|
// another process may have already un-stashed the file
|
|
192
203
|
if (core_1.fs.existsSync(stashedLocation)) {
|
|
193
|
-
await core_1.fs.promises.rename(stashedLocation, path.join(this.projectPath,
|
|
204
|
+
await core_1.fs.promises.rename(stashedLocation, path.join(this.projectPath, gitIgnoreFileName));
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
207
|
}
|
|
@@ -8,7 +8,7 @@ exports.getMetadataKeyFromFileResponse = void 0;
|
|
|
8
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
9
|
*/
|
|
10
10
|
const path = require("path");
|
|
11
|
-
const
|
|
11
|
+
const functions_1 = require("./functions");
|
|
12
12
|
// LWC can have child folders (ex: dynamic templates like /templates/noDataIllustration.html
|
|
13
13
|
const pathAfterFullName = (fileResponse) => fileResponse && fileResponse.filePath
|
|
14
14
|
? fileResponse.filePath.substr(fileResponse.filePath.indexOf(fileResponse.fullName)).replace(/\\/gi, '/')
|
|
@@ -21,25 +21,25 @@ const getMetadataKeyFromFileResponse = (fileResponse) => {
|
|
|
21
21
|
const splits = path.normalize(fileResponse.filePath).split(path.sep);
|
|
22
22
|
const objectFolderIndex = splits.indexOf('objects');
|
|
23
23
|
return [
|
|
24
|
-
(0,
|
|
25
|
-
(0,
|
|
24
|
+
(0, functions_1.getMetadataKey)('CustomObject', splits[objectFolderIndex + 1]),
|
|
25
|
+
(0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName),
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
28
|
// Aura/LWC need to have both the bundle level and file level keys
|
|
29
29
|
if (fileResponse.type === 'LightningComponentBundle' && fileResponse.filePath) {
|
|
30
30
|
return [
|
|
31
31
|
`LightningComponentResource__${pathAfterFullName(fileResponse)}`,
|
|
32
|
-
(0,
|
|
32
|
+
(0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName),
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
if (fileResponse.type === 'AuraDefinitionBundle' && fileResponse.filePath) {
|
|
36
36
|
return [
|
|
37
37
|
`AuraDefinition__${pathAfterFullName(fileResponse)}`,
|
|
38
|
-
(0,
|
|
38
|
+
(0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName),
|
|
39
39
|
];
|
|
40
40
|
}
|
|
41
41
|
// standard key
|
|
42
|
-
return [(0,
|
|
42
|
+
return [(0, functions_1.getMetadataKey)(fileResponse.type, fileResponse.fullName)];
|
|
43
43
|
};
|
|
44
44
|
exports.getMetadataKeyFromFileResponse = getMetadataKeyFromFileResponse;
|
|
45
45
|
//# sourceMappingURL=metadataKeys.js.map
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import { ConfigFile, Logger } from '@salesforce/core';
|
|
2
|
-
import { RemoteSyncInput } from '
|
|
3
|
-
export declare type MemberRevision = {
|
|
4
|
-
serverRevisionCounter: number;
|
|
5
|
-
lastRetrievedFromServer: number | null;
|
|
6
|
-
memberType: string;
|
|
7
|
-
isNameObsolete: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare type SourceMember = {
|
|
10
|
-
MemberType: string;
|
|
11
|
-
MemberName: string;
|
|
12
|
-
IsNameObsolete: boolean;
|
|
13
|
-
RevisionCounter: number;
|
|
14
|
-
};
|
|
15
|
-
export declare type RemoteChangeElement = {
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
deleted?: boolean;
|
|
19
|
-
modified?: boolean;
|
|
20
|
-
};
|
|
2
|
+
import { ChangeResult, RemoteChangeElement, SourceMember, RemoteSyncInput } from './types';
|
|
21
3
|
export declare namespace RemoteSourceTrackingService {
|
|
22
4
|
interface Options extends ConfigFile.Options {
|
|
23
5
|
orgId: string;
|
|
@@ -25,7 +7,6 @@ export declare namespace RemoteSourceTrackingService {
|
|
|
25
7
|
username: string;
|
|
26
8
|
}
|
|
27
9
|
}
|
|
28
|
-
export declare const getMetadataKey: (metadataType: string, metadataName: string) => string;
|
|
29
10
|
/**
|
|
30
11
|
* This service handles source tracking of metadata between a local project and an org.
|
|
31
12
|
* Source tracking state is persisted to .sfdx/orgs/<orgId>/maxRevision.json.
|
|
@@ -143,3 +124,8 @@ export declare class RemoteSourceTrackingService extends ConfigFile<RemoteSource
|
|
|
143
124
|
private querySourceMembersTo;
|
|
144
125
|
private query;
|
|
145
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* pass in an RCE, and this will return a pullable ChangeResult.
|
|
129
|
+
* Useful for correcing bundle types where the files show change results with types but aren't resolvable
|
|
130
|
+
*/
|
|
131
|
+
export declare const remoteChangeElementToChangeResult: (rce: RemoteChangeElement) => ChangeResult;
|
|
@@ -8,18 +8,14 @@
|
|
|
8
8
|
/* eslint-disable no-underscore-dangle */
|
|
9
9
|
/* eslint-disable @typescript-eslint/member-ordering */
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
11
|
+
exports.remoteChangeElementToChangeResult = exports.RemoteSourceTrackingService = void 0;
|
|
12
12
|
const path = require("path");
|
|
13
|
-
const fs = require("fs");
|
|
14
13
|
const ts_retry_promise_1 = require("ts-retry-promise");
|
|
15
14
|
const core_1 = require("@salesforce/core");
|
|
16
15
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
17
16
|
const kit_1 = require("@salesforce/kit");
|
|
18
17
|
const metadataKeys_1 = require("./metadataKeys");
|
|
19
|
-
const
|
|
20
|
-
return `${metadataType}__${metadataName}`;
|
|
21
|
-
};
|
|
22
|
-
exports.getMetadataKey = getMetadataKey;
|
|
18
|
+
const functions_1 = require("./functions");
|
|
23
19
|
/**
|
|
24
20
|
* This service handles source tracking of metadata between a local project and an org.
|
|
25
21
|
* Source tracking state is persisted to .sfdx/orgs/<orgId>/maxRevision.json.
|
|
@@ -89,8 +85,8 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
89
85
|
static async delete(orgId) {
|
|
90
86
|
const fileToDelete = RemoteSourceTrackingService.getFilePath(orgId);
|
|
91
87
|
// the file might not exist, in which case we don't need to delete it
|
|
92
|
-
if (fs.existsSync(fileToDelete)) {
|
|
93
|
-
await fs.promises.unlink(fileToDelete);
|
|
88
|
+
if (core_1.fs.existsSync(fileToDelete)) {
|
|
89
|
+
await core_1.fs.promises.unlink(fileToDelete);
|
|
94
90
|
}
|
|
95
91
|
return path.isAbsolute(fileToDelete) ? fileToDelete : path.join(process.cwd(), fileToDelete);
|
|
96
92
|
}
|
|
@@ -211,7 +207,7 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
211
207
|
members = await this.querySourceMembersFrom({ fromRevision: 0 });
|
|
212
208
|
}
|
|
213
209
|
await this.trackSourceMembers(members, true);
|
|
214
|
-
return members.map((member) => (0,
|
|
210
|
+
return members.map((member) => (0, functions_1.getMetadataKey)(member.MemberType, member.MemberName));
|
|
215
211
|
}
|
|
216
212
|
//
|
|
217
213
|
// * * * * * P R I V A T E M E T H O D S * * * * *
|
|
@@ -259,7 +255,7 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
259
255
|
sourceMembers.forEach((change) => {
|
|
260
256
|
// try accessing the sourceMembers object at the index of the change's name
|
|
261
257
|
// if it exists, we'll update the fields - if it doesn't, we'll create and insert it
|
|
262
|
-
const key = (0,
|
|
258
|
+
const key = (0, functions_1.getMetadataKey)(change.MemberType, change.MemberName);
|
|
263
259
|
let sourceMember = this.getSourceMember(key);
|
|
264
260
|
if (sourceMember) {
|
|
265
261
|
// We are already tracking this element so we'll update it
|
|
@@ -360,13 +356,13 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
360
356
|
// filter known Source tracking issues
|
|
361
357
|
expectedMembers
|
|
362
358
|
.filter((fileResponse) => {
|
|
363
|
-
var _a
|
|
359
|
+
var _a;
|
|
364
360
|
// unchanged files will never be in the sourceMembers. Not really sure why SDR returns them.
|
|
365
361
|
return fileResponse.state !== source_deploy_retrieve_1.ComponentStatus.Unchanged &&
|
|
366
362
|
// if a listView is the only change inside an object, the object won't have a sourceMember change. We won't wait for those to be found
|
|
367
363
|
fileResponse.type !== 'CustomObject' &&
|
|
368
364
|
// aura meta.xml aren't tracked as SourceMembers
|
|
369
|
-
!((
|
|
365
|
+
!((_a = fileResponse.filePath) === null || _a === void 0 ? void 0 : _a.endsWith('.cmp-meta.xml'));
|
|
370
366
|
})
|
|
371
367
|
.map((member) => {
|
|
372
368
|
(0, metadataKeys_1.getMetadataKeyFromFileResponse)(member).map((key) => outstandingSourceMembers.set(key, member));
|
|
@@ -386,7 +382,7 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
386
382
|
});
|
|
387
383
|
// remove anything returned from the query list
|
|
388
384
|
queriedMembers.map((member) => {
|
|
389
|
-
outstandingSourceMembers.delete((0,
|
|
385
|
+
outstandingSourceMembers.delete((0, functions_1.getMetadataKey)(member.MemberType, member.MemberName));
|
|
390
386
|
});
|
|
391
387
|
this.logger.debug(`[${pollAttempts}] Found ${originalSize - outstandingSourceMembers.size} of ${originalSize} SourceMembers`);
|
|
392
388
|
// update but don't sync
|
|
@@ -474,4 +470,25 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
474
470
|
}
|
|
475
471
|
exports.RemoteSourceTrackingService = RemoteSourceTrackingService;
|
|
476
472
|
RemoteSourceTrackingService.remoteSourceTrackingServiceDictionary = {};
|
|
473
|
+
/**
|
|
474
|
+
* pass in an RCE, and this will return a pullable ChangeResult.
|
|
475
|
+
* Useful for correcing bundle types where the files show change results with types but aren't resolvable
|
|
476
|
+
*/
|
|
477
|
+
const remoteChangeElementToChangeResult = (rce) => {
|
|
478
|
+
return {
|
|
479
|
+
...rce,
|
|
480
|
+
...(mappingsForSourceMemberTypesToMetadataType.has(rce.type)
|
|
481
|
+
? {
|
|
482
|
+
name: rce.name.split('/')[0],
|
|
483
|
+
type: mappingsForSourceMemberTypesToMetadataType.get(rce.type),
|
|
484
|
+
}
|
|
485
|
+
: {}),
|
|
486
|
+
origin: 'remote', // we know they're remote
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
exports.remoteChangeElementToChangeResult = remoteChangeElementToChangeResult;
|
|
490
|
+
const mappingsForSourceMemberTypesToMetadataType = new Map([
|
|
491
|
+
['AuraDefinition', 'AuraDefinitionBundle'],
|
|
492
|
+
['LightningComponentResource', 'LightningComponentBundle'],
|
|
493
|
+
]);
|
|
477
494
|
//# sourceMappingURL=remoteSourceTrackingService.js.map
|