@salesforce/source-tracking 0.4.0 → 0.4.4
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 +77 -53
- package/lib/shared/guards.d.ts +2 -1
- package/lib/shared/guards.js +5 -1
- package/lib/shared/localShadowRepo.js +6 -4
- package/lib/shared/remoteSourceTrackingService.js +2 -2
- package/lib/sourceTracking.d.ts +2 -3
- package/lib/sourceTracking.js +57 -40
- package/oclif.manifest.json +1 -0
- package/package.json +14 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,66 +2,90 @@
|
|
|
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
|
-
|
|
5
|
+
### [0.4.4](https://github.com/forcedotcom/source-tracking/compare/v0.4.3...v0.4.4) (2021-12-01)
|
|
6
6
|
|
|
7
|
+
### Features
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- update version of core and sdr ([977ab56](https://github.com/forcedotcom/source-tracking/commit/977ab56deb9fa610cb21b26bfef6d30a1f9f8f58))
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
### [0.4.3](https://github.com/forcedotcom/source-tracking/compare/v0.4.2...v0.4.3) (2021-11-11)
|
|
11
12
|
|
|
12
13
|
### Features
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* handle status ignore marking from STL ([2ec6fad](https://github.com/forcedotcom/source-tracking/commit/2ec6fad4b4f4f2e124da7e4f53cf8e534354d342))
|
|
23
|
-
* ignorewarnings flag for push ([b13fd05](https://github.com/forcedotcom/source-tracking/commit/b13fd0534930fb063075c39e6f75ea46ab9d3be8))
|
|
24
|
-
* migrate messages/descriptions ([8fea6e5](https://github.com/forcedotcom/source-tracking/commit/8fea6e5242c50865dd635412d7592164ab57fec4))
|
|
25
|
-
* most of sourceStatus logic, code cleanup ([f100cb8](https://github.com/forcedotcom/source-tracking/commit/f100cb83f220b3724284ae69301712a08b14376d))
|
|
26
|
-
* non-delete push works ([487a20e](https://github.com/forcedotcom/source-tracking/commit/487a20e48c428a02ef315b58db24b714d2de0416))
|
|
27
|
-
* push supporting bundle types ([639d459](https://github.com/forcedotcom/source-tracking/commit/639d459101cd4990fa217f657b99d64517611383))
|
|
28
|
-
* remote and conflicts ([f98ecf1](https://github.com/forcedotcom/source-tracking/commit/f98ecf17fc6cbe386d8edae6994500388b7e0ed6))
|
|
29
|
-
* remote tracknig with UT ([cb805e5](https://github.com/forcedotcom/source-tracking/commit/cb805e5745020be9a266a261f584979713e4b351))
|
|
30
|
-
* source tracking from toolbelt ([6c2ebb4](https://github.com/forcedotcom/source-tracking/commit/6c2ebb444ce5518eaa81402b685fe00f1090e437))
|
|
31
|
-
* sourcemember polling like toolbelt ([abdd7b3](https://github.com/forcedotcom/source-tracking/commit/abdd7b3ad275ea4739673a6e1b1a99853f1de2da))
|
|
32
|
-
* spinners while waiting on pull ([dfe5aea](https://github.com/forcedotcom/source-tracking/commit/dfe5aeae0a5f9a30eddfe96852e0dab025972e1e))
|
|
33
|
-
* status result sorting ([b7b109c](https://github.com/forcedotcom/source-tracking/commit/b7b109cf3e7bcad60507618099873c717ff31f61))
|
|
34
|
-
* sync customObj when their fields sync ([3ded96d](https://github.com/forcedotcom/source-tracking/commit/3ded96dbd7a7ea45cb8f97719b98bae294905c05))
|
|
35
|
-
* throws if "old" source files are present ([4b868d8](https://github.com/forcedotcom/source-tracking/commit/4b868d8232769eec5e227052bf823a35baedd288))
|
|
36
|
-
* typed push ([6e76812](https://github.com/forcedotcom/source-tracking/commit/6e7681263b81d3b692d002a3ce5deb8ef00bbd13))
|
|
37
|
-
* virtualTree for deletes ([b425d77](https://github.com/forcedotcom/source-tracking/commit/b425d77b4fca5c6fbab2faab7490e3516bf3f547))
|
|
15
|
+
- emit warnings for types not pulled ([fdeabbf](https://github.com/forcedotcom/source-tracking/commit/fdeabbfb11bb4ba1fd17931adedc49f9cb5ae658))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- don't pull remote changes where type isn't in SDR registry ([46250ee](https://github.com/forcedotcom/source-tracking/commit/46250eef09e29dfa0d06af984bbfcc3e88765968))
|
|
20
|
+
- don't pull things not in the registry ([38136bb](https://github.com/forcedotcom/source-tracking/commit/38136bbbf1e44c8e58bc06621957819913273b4e))
|
|
21
|
+
|
|
22
|
+
### [0.4.2](https://github.com/forcedotcom/source-tracking/compare/v0.4.1...v0.4.2) (2021-10-28)
|
|
38
23
|
|
|
24
|
+
### [0.4.1](https://github.com/forcedotcom/source-tracking/compare/v0.4.0...v0.4.1) (2021-10-28)
|
|
39
25
|
|
|
40
26
|
### Bug Fixes
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
28
|
+
- better conflict handling (can match filenames or type/name) ([4441a0a](https://github.com/forcedotcom/source-tracking/commit/4441a0abd70c7f8f315e1c638b4cef7fcf3e2e68))
|
|
29
|
+
- gitignore stashing location ([5145545](https://github.com/forcedotcom/source-tracking/commit/5145545eeee6c800986014327479d20e943143e5))
|
|
30
|
+
- polling exclusion logic for aura meta.xml was wrong ([2d40b2e](https://github.com/forcedotcom/source-tracking/commit/2d40b2ef65ef9a3145d0c75cd4943e4325d5745c))
|
|
31
|
+
|
|
32
|
+
## 0.4.0 (2021-10-22)
|
|
33
|
+
|
|
34
|
+
### ⚠ BREAKING CHANGES
|
|
35
|
+
|
|
36
|
+
- remove retrieve simplifier
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
- add commitlint and sample circleci config ([43e7fa4](https://github.com/forcedotcom/source-tracking/commit/43e7fa4a44dbcb9da37d21618678687f4edda644))
|
|
41
|
+
- add new tests and upadte readme ([6a7ad54](https://github.com/forcedotcom/source-tracking/commit/6a7ad542f42ce75275ebacc78d50ee4dc0ab6f32))
|
|
42
|
+
- add option to get remoteChanges with filePaths, use for Conflicts ([350a0d6](https://github.com/forcedotcom/source-tracking/commit/350a0d60599cfce2c432c223f4523c25a4f53c81))
|
|
43
|
+
- basic using isogit ([f39e6c5](https://github.com/forcedotcom/source-tracking/commit/f39e6c5e305fcb2fdb6a27b343d9dc20800202c9))
|
|
44
|
+
- conflict detection ([3e22774](https://github.com/forcedotcom/source-tracking/commit/3e22774d8949a1aa4302e62d8580b69c4b35aab5))
|
|
45
|
+
- consolidate conflict handling, return data in error ([45178c7](https://github.com/forcedotcom/source-tracking/commit/45178c7b13ed61e657f9a07ea5b40f49f73f651a))
|
|
46
|
+
- delete handling public for pull ([eb87eb7](https://github.com/forcedotcom/source-tracking/commit/eb87eb7dfa81ba5256735af7f2b8bc29dfb1e16b))
|
|
47
|
+
- finish status, add clear/reset ([c71e66f](https://github.com/forcedotcom/source-tracking/commit/c71e66f7f7a3dc20d2c965349b5e01e15edabf36))
|
|
48
|
+
- handle status ignore marking from STL ([2ec6fad](https://github.com/forcedotcom/source-tracking/commit/2ec6fad4b4f4f2e124da7e4f53cf8e534354d342))
|
|
49
|
+
- ignorewarnings flag for push ([b13fd05](https://github.com/forcedotcom/source-tracking/commit/b13fd0534930fb063075c39e6f75ea46ab9d3be8))
|
|
50
|
+
- migrate messages/descriptions ([8fea6e5](https://github.com/forcedotcom/source-tracking/commit/8fea6e5242c50865dd635412d7592164ab57fec4))
|
|
51
|
+
- most of sourceStatus logic, code cleanup ([f100cb8](https://github.com/forcedotcom/source-tracking/commit/f100cb83f220b3724284ae69301712a08b14376d))
|
|
52
|
+
- non-delete push works ([487a20e](https://github.com/forcedotcom/source-tracking/commit/487a20e48c428a02ef315b58db24b714d2de0416))
|
|
53
|
+
- push supporting bundle types ([639d459](https://github.com/forcedotcom/source-tracking/commit/639d459101cd4990fa217f657b99d64517611383))
|
|
54
|
+
- remote and conflicts ([f98ecf1](https://github.com/forcedotcom/source-tracking/commit/f98ecf17fc6cbe386d8edae6994500388b7e0ed6))
|
|
55
|
+
- remote tracknig with UT ([cb805e5](https://github.com/forcedotcom/source-tracking/commit/cb805e5745020be9a266a261f584979713e4b351))
|
|
56
|
+
- source tracking from toolbelt ([6c2ebb4](https://github.com/forcedotcom/source-tracking/commit/6c2ebb444ce5518eaa81402b685fe00f1090e437))
|
|
57
|
+
- sourcemember polling like toolbelt ([abdd7b3](https://github.com/forcedotcom/source-tracking/commit/abdd7b3ad275ea4739673a6e1b1a99853f1de2da))
|
|
58
|
+
- spinners while waiting on pull ([dfe5aea](https://github.com/forcedotcom/source-tracking/commit/dfe5aeae0a5f9a30eddfe96852e0dab025972e1e))
|
|
59
|
+
- status result sorting ([b7b109c](https://github.com/forcedotcom/source-tracking/commit/b7b109cf3e7bcad60507618099873c717ff31f61))
|
|
60
|
+
- sync customObj when their fields sync ([3ded96d](https://github.com/forcedotcom/source-tracking/commit/3ded96dbd7a7ea45cb8f97719b98bae294905c05))
|
|
61
|
+
- throws if "old" source files are present ([4b868d8](https://github.com/forcedotcom/source-tracking/commit/4b868d8232769eec5e227052bf823a35baedd288))
|
|
62
|
+
- typed push ([6e76812](https://github.com/forcedotcom/source-tracking/commit/6e7681263b81d3b692d002a3ce5deb8ef00bbd13))
|
|
63
|
+
- virtualTree for deletes ([b425d77](https://github.com/forcedotcom/source-tracking/commit/b425d77b4fca5c6fbab2faab7490e3516bf3f547))
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
- again with the promises ([ad9dec5](https://github.com/forcedotcom/source-tracking/commit/ad9dec50336c61996456d48ee489426393c62329))
|
|
68
|
+
- another attempt at node12 support ([c8736d0](https://github.com/forcedotcom/source-tracking/commit/c8736d0bbe53756d1b5572e00402e55af94003c1))
|
|
69
|
+
- case of empty orgId dir ([1cb6333](https://github.com/forcedotcom/source-tracking/commit/1cb6333d14cfcee02b27711b6db273d5db31fc8e))
|
|
70
|
+
- case on formatter filename ([02adf22](https://github.com/forcedotcom/source-tracking/commit/02adf22419d2bf81fb070d7d7d90f7d996bd1ada))
|
|
71
|
+
- casing on imports ([d4425d9](https://github.com/forcedotcom/source-tracking/commit/d4425d9ee2ad77c4e28d32333025e59a3c7e3af9))
|
|
72
|
+
- correct statusCommand description ([b834a2f](https://github.com/forcedotcom/source-tracking/commit/b834a2fa0213fbc72dbc6dc3a563cd92f413d222))
|
|
73
|
+
- don't commit empty changelists ([67b9772](https://github.com/forcedotcom/source-tracking/commit/67b9772eccd6d2d4850322eb80f5a6113aac18e6))
|
|
74
|
+
- export compatibility ([c6e5f7c](https://github.com/forcedotcom/source-tracking/commit/c6e5f7cba68ed6a7739b237adb027fda2442e8c4))
|
|
75
|
+
- fix vscode image in readme ([441c15f](https://github.com/forcedotcom/source-tracking/commit/441c15f79dbaf4a97c84d9d6ddc923eae59bca34))
|
|
76
|
+
- handle org:create's single tracking file ([008793d](https://github.com/forcedotcom/source-tracking/commit/008793d0fa15210ffb263cc5d179a0be8dcb05ff))
|
|
77
|
+
- handle stash failures ([09dacc9](https://github.com/forcedotcom/source-tracking/commit/09dacc9484e48f3cba4813f3d733c66d2a30cd6b))
|
|
78
|
+
- leif .yml merge [skip-validate-pr] ([ff10f84](https://github.com/forcedotcom/source-tracking/commit/ff10f84ec15757df55657ba73cc6976c5892595c))
|
|
79
|
+
- local ST uses graceful via core2 ([3ba883f](https://github.com/forcedotcom/source-tracking/commit/3ba883ff2b02e27b0eb01a709f6c1e03ef91bb73))
|
|
80
|
+
- match server subfiles with forward slash ([c2489a6](https://github.com/forcedotcom/source-tracking/commit/c2489a62c244a64fe0938e0eecdc087f4529b5ad))
|
|
81
|
+
- normalize windows paths on commit, too ([4339e46](https://github.com/forcedotcom/source-tracking/commit/4339e46a1cb9cbeb4cc652572e340b60e3b5bc68))
|
|
82
|
+
- one more fs/promises fixed for node12 ([71bafcf](https://github.com/forcedotcom/source-tracking/commit/71bafcf7738e60d8b86150199ef8d0687167a010))
|
|
83
|
+
- path normalizing for metadata keys ([6190590](https://github.com/forcedotcom/source-tracking/commit/6190590df2c2e7cc9a25eab0fa8891e3b8df9057))
|
|
84
|
+
- path normalizing from iso-git ([b8cddaf](https://github.com/forcedotcom/source-tracking/commit/b8cddaf40930bedd18f3edec578a030220454627))
|
|
85
|
+
- status output on windows uses backslash ([78ac398](https://github.com/forcedotcom/source-tracking/commit/78ac3988d3d04e956f17f35c67de4d1144062fcb))
|
|
86
|
+
- support windows path on commits with \\ ([5712af4](https://github.com/forcedotcom/source-tracking/commit/5712af4447ee03e30d7a5a769fc5ba58f6913552))
|
|
87
|
+
- there could be nested LWC templates ([d833981](https://github.com/forcedotcom/source-tracking/commit/d8339810bf76c0ab75824faee7aef59ff9a2d89e))
|
|
88
|
+
- turns bundle parts of SourceMembers into real MDtypes ([5646042](https://github.com/forcedotcom/source-tracking/commit/564604269be7d56499963699b51920b81227297f))
|
|
89
|
+
- use correct var name ([0708312](https://github.com/forcedotcom/source-tracking/commit/0708312c5b4f11cb94539416d0a10b5432850310))
|
|
90
|
+
|
|
91
|
+
- remove retrieve simplifier ([bd71eef](https://github.com/forcedotcom/source-tracking/commit/bd71eef784bc7c7efd1999ba11193e632aef3d47))
|
package/lib/shared/guards.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
1
|
+
import { SourceComponent, MetadataMember } from '@salesforce/source-deploy-retrieve';
|
|
2
2
|
export declare const stringGuard: (input: string | undefined) => input is string;
|
|
3
3
|
export declare const sourceComponentGuard: (input: SourceComponent | undefined) => input is SourceComponent;
|
|
4
|
+
export declare const metadataMemberGuard: (input: MetadataMember | undefined) => input is MetadataMember;
|
package/lib/shared/guards.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sourceComponentGuard = exports.stringGuard = void 0;
|
|
3
|
+
exports.metadataMemberGuard = exports.sourceComponentGuard = exports.stringGuard = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -16,4 +16,8 @@ const sourceComponentGuard = (input) => {
|
|
|
16
16
|
return input instanceof source_deploy_retrieve_1.SourceComponent;
|
|
17
17
|
};
|
|
18
18
|
exports.sourceComponentGuard = sourceComponentGuard;
|
|
19
|
+
const metadataMemberGuard = (input) => {
|
|
20
|
+
return input !== undefined && typeof input.fullName === 'string' && typeof input.type === 'string';
|
|
21
|
+
};
|
|
22
|
+
exports.metadataMemberGuard = metadataMemberGuard;
|
|
19
23
|
//# sourceMappingURL=guards.js.map
|
|
@@ -12,6 +12,8 @@ const path = require("path");
|
|
|
12
12
|
const os = require("os");
|
|
13
13
|
const core_1 = require("@salesforce/core");
|
|
14
14
|
const git = require("isomorphic-git");
|
|
15
|
+
const gitIgnoreFileName = '.gitignore';
|
|
16
|
+
const stashedGitIgnoreFileName = '.BAK.gitignore';
|
|
15
17
|
/**
|
|
16
18
|
* returns the full path to where we store the shadow repo
|
|
17
19
|
*/
|
|
@@ -189,17 +191,17 @@ class ShadowRepo {
|
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
async stashIgnoreFile() {
|
|
192
|
-
const originalLocation = path.join(this.projectPath,
|
|
194
|
+
const originalLocation = path.join(this.projectPath, gitIgnoreFileName);
|
|
193
195
|
// another process may have already stashed the file
|
|
194
196
|
if (core_1.fs.existsSync(originalLocation)) {
|
|
195
|
-
await core_1.fs.promises.rename(originalLocation, path.join(this.projectPath,
|
|
197
|
+
await core_1.fs.promises.rename(originalLocation, path.join(this.projectPath, stashedGitIgnoreFileName));
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
async unStashIgnoreFile() {
|
|
199
|
-
const stashedLocation = path.join(this.projectPath,
|
|
201
|
+
const stashedLocation = path.join(this.projectPath, stashedGitIgnoreFileName);
|
|
200
202
|
// another process may have already un-stashed the file
|
|
201
203
|
if (core_1.fs.existsSync(stashedLocation)) {
|
|
202
|
-
await core_1.fs.promises.rename(stashedLocation, path.join(this.projectPath,
|
|
204
|
+
await core_1.fs.promises.rename(stashedLocation, path.join(this.projectPath, gitIgnoreFileName));
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
}
|
|
@@ -356,13 +356,13 @@ class RemoteSourceTrackingService extends core_1.ConfigFile {
|
|
|
356
356
|
// filter known Source tracking issues
|
|
357
357
|
expectedMembers
|
|
358
358
|
.filter((fileResponse) => {
|
|
359
|
-
var _a
|
|
359
|
+
var _a;
|
|
360
360
|
// unchanged files will never be in the sourceMembers. Not really sure why SDR returns them.
|
|
361
361
|
return fileResponse.state !== source_deploy_retrieve_1.ComponentStatus.Unchanged &&
|
|
362
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
|
|
363
363
|
fileResponse.type !== 'CustomObject' &&
|
|
364
364
|
// aura meta.xml aren't tracked as SourceMembers
|
|
365
|
-
!((
|
|
365
|
+
!((_a = fileResponse.filePath) === null || _a === void 0 ? void 0 : _a.endsWith('.cmp-meta.xml'));
|
|
366
366
|
})
|
|
367
367
|
.map((member) => {
|
|
368
368
|
(0, metadataKeys_1.getMetadataKeyFromFileResponse)(member).map((key) => outstandingSourceMembers.set(key, member));
|
package/lib/sourceTracking.d.ts
CHANGED
|
@@ -21,11 +21,10 @@ export declare class SourceTracking extends AsyncCreatable {
|
|
|
21
21
|
private packagesDirs;
|
|
22
22
|
private username;
|
|
23
23
|
private logger;
|
|
24
|
+
private registry;
|
|
24
25
|
private localRepo;
|
|
25
26
|
private remoteSourceTrackingService;
|
|
26
27
|
private forceIgnore;
|
|
27
|
-
private registry;
|
|
28
|
-
private transformerFactory;
|
|
29
28
|
constructor(options: SourceTrackingOptions);
|
|
30
29
|
init(): Promise<void>;
|
|
31
30
|
localChangesAsComponentSet(): Promise<ComponentSet>;
|
|
@@ -109,6 +108,7 @@ export declare class SourceTracking extends AsyncCreatable {
|
|
|
109
108
|
*/
|
|
110
109
|
private populateTypesAndNames;
|
|
111
110
|
private getLocalStatusRows;
|
|
111
|
+
private registrySupportsType;
|
|
112
112
|
/**
|
|
113
113
|
* uses SDR to translate remote metadata records into local file paths
|
|
114
114
|
*/
|
|
@@ -117,5 +117,4 @@ export declare class SourceTracking extends AsyncCreatable {
|
|
|
117
117
|
private getLocalChangesAsFilenames;
|
|
118
118
|
private localChangesToOutputRow;
|
|
119
119
|
private remoteChangesToOutputRows;
|
|
120
|
-
private filesPathFromNonLocalSourceComponent;
|
|
121
120
|
}
|
package/lib/sourceTracking.js
CHANGED
|
@@ -9,12 +9,11 @@ exports.SourceTracking = void 0;
|
|
|
9
9
|
*/
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const path = require("path");
|
|
12
|
+
const os_1 = require("os");
|
|
12
13
|
const core_1 = require("@salesforce/core");
|
|
13
14
|
const kit_1 = require("@salesforce/kit");
|
|
14
15
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
16
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
16
|
-
const metadataTransformerFactory_1 = require("@salesforce/source-deploy-retrieve/lib/src/convert/transformers/metadataTransformerFactory");
|
|
17
|
-
const convertContext_1 = require("@salesforce/source-deploy-retrieve/lib/src/convert/convertContext");
|
|
18
17
|
const remoteSourceTrackingService_1 = require("./shared/remoteSourceTrackingService");
|
|
19
18
|
const localShadowRepo_1 = require("./shared/localShadowRepo");
|
|
20
19
|
const filenamesToVirtualTree_1 = require("./shared/filenamesToVirtualTree");
|
|
@@ -29,6 +28,7 @@ const functions_1 = require("./shared/functions");
|
|
|
29
28
|
class SourceTracking extends kit_1.AsyncCreatable {
|
|
30
29
|
constructor(options) {
|
|
31
30
|
super(options);
|
|
31
|
+
this.registry = new source_deploy_retrieve_1.RegistryAccess();
|
|
32
32
|
this.orgId = options.org.getOrgId();
|
|
33
33
|
this.username = options.org.getUsername();
|
|
34
34
|
this.projectPath = options.project.getPath();
|
|
@@ -148,7 +148,10 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
148
148
|
await this.ensureRemoteTracking();
|
|
149
149
|
const remoteChanges = await this.remoteSourceTrackingService.retrieveUpdates();
|
|
150
150
|
this.logger.debug('remoteChanges', remoteChanges);
|
|
151
|
-
const filteredChanges = remoteChanges
|
|
151
|
+
const filteredChanges = remoteChanges
|
|
152
|
+
.filter(remoteFilterByState[options.state])
|
|
153
|
+
// skip any remote types not in the registry. Will emit node warnings
|
|
154
|
+
.filter((rce) => this.registrySupportsType(rce.type));
|
|
152
155
|
if (options.format === 'ChangeResult') {
|
|
153
156
|
return filteredChanges.map((change) => (0, remoteSourceTrackingService_1.remoteChangeElementToChangeResult)(change));
|
|
154
157
|
}
|
|
@@ -338,22 +341,34 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
338
341
|
if (remoteChanges.length === 0) {
|
|
339
342
|
return [];
|
|
340
343
|
}
|
|
341
|
-
// index
|
|
344
|
+
// index the remoteChanges by filename
|
|
342
345
|
const fileNameIndex = new Map();
|
|
346
|
+
const metadataKeyIndex = new Map();
|
|
343
347
|
remoteChanges.map((change) => {
|
|
344
348
|
var _a;
|
|
349
|
+
if (change.name && change.type) {
|
|
350
|
+
metadataKeyIndex.set((0, functions_1.getMetadataKey)(change.name, change.type), change);
|
|
351
|
+
}
|
|
345
352
|
(_a = change.filenames) === null || _a === void 0 ? void 0 : _a.map((filename) => {
|
|
346
353
|
fileNameIndex.set(filename, change);
|
|
347
354
|
});
|
|
348
355
|
});
|
|
349
356
|
const conflicts = new Set();
|
|
350
|
-
localChanges.map((change) => {
|
|
357
|
+
this.populateTypesAndNames({ elements: localChanges, excludeUnresolvable: true }).map((change) => {
|
|
351
358
|
var _a;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
}
|
|
359
|
+
const metadataKey = (0, functions_1.getMetadataKey)(change.name, change.type);
|
|
360
|
+
// option 1: name and type match
|
|
361
|
+
if (metadataKeyIndex.has(metadataKey)) {
|
|
362
|
+
conflicts.add({ ...metadataKeyIndex.get(metadataKey) });
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
// option 2: some of the filenames match
|
|
366
|
+
(_a = change.filenames) === null || _a === void 0 ? void 0 : _a.map((filename) => {
|
|
367
|
+
if (fileNameIndex.has(filename)) {
|
|
368
|
+
conflicts.add({ ...fileNameIndex.get(filename) });
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
357
372
|
});
|
|
358
373
|
// deeply de-dupe
|
|
359
374
|
return Array.from(conflicts);
|
|
@@ -400,9 +415,10 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
400
415
|
if ((matchingComponent === null || matchingComponent === void 0 ? void 0 : matchingComponent.fullName) && (matchingComponent === null || matchingComponent === void 0 ? void 0 : matchingComponent.type.name)) {
|
|
401
416
|
const filenamesFromMatchingComponent = [matchingComponent.xml, ...matchingComponent.walkContent()];
|
|
402
417
|
// Set the ignored status at the component level so it can apply to all its files, some of which may not match the ignoreFile (ex: ApexClass)
|
|
403
|
-
this.forceIgnore = (_a = this.forceIgnore) !== null && _a !== void 0 ? _a : source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.
|
|
418
|
+
this.forceIgnore = (_a = this.forceIgnore) !== null && _a !== void 0 ? _a : source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().path);
|
|
404
419
|
const ignored = filenamesFromMatchingComponent
|
|
405
420
|
.filter(guards_1.stringGuard)
|
|
421
|
+
.filter((filename) => !filename.includes('__tests__'))
|
|
406
422
|
.some((filename) => this.forceIgnore.denies(filename));
|
|
407
423
|
filenamesFromMatchingComponent.map((filename) => {
|
|
408
424
|
if (filename && elementMap.has(filename)) {
|
|
@@ -444,6 +460,13 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
444
460
|
results = results.concat(localAdds.flatMap((item) => this.localChangesToOutputRow(item, 'add')), localModifies.flatMap((item) => this.localChangesToOutputRow(item, 'modify')), localDeletes.flatMap((item) => this.localChangesToOutputRow(item, 'delete')));
|
|
445
461
|
return results;
|
|
446
462
|
}
|
|
463
|
+
registrySupportsType(type) {
|
|
464
|
+
if (this.registry.findType((metadataType) => metadataType.name === type)) {
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
process.emitWarning(`Unable to find type ${type} in registry`);
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
447
470
|
/**
|
|
448
471
|
* uses SDR to translate remote metadata records into local file paths
|
|
449
472
|
*/
|
|
@@ -452,17 +475,26 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
452
475
|
return [];
|
|
453
476
|
}
|
|
454
477
|
this.logger.debug('populateFilePaths for change elements', elements);
|
|
455
|
-
// component set generated from an array of
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
478
|
+
// component set generated from an array of MetadataMember from all the remote changes
|
|
479
|
+
// but exclude the ones that aren't in the registry
|
|
480
|
+
const remoteChangesAsMetadataMember = elements
|
|
481
|
+
.map((element) => {
|
|
482
|
+
if (typeof element.type === 'string' && typeof element.name === 'string') {
|
|
483
|
+
return {
|
|
484
|
+
type: element.type,
|
|
485
|
+
fullName: element.name,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
})
|
|
489
|
+
.filter(guards_1.metadataMemberGuard);
|
|
490
|
+
const remoteChangesAsComponentSet = new source_deploy_retrieve_1.ComponentSet(remoteChangesAsMetadataMember);
|
|
461
491
|
this.logger.debug(` the generated component set has ${remoteChangesAsComponentSet.size.toString()} items`);
|
|
462
492
|
if (remoteChangesAsComponentSet.size < elements.length) {
|
|
493
|
+
// iterate the elements to see which ones didn't make it into the component set
|
|
463
494
|
throw new Error(`unable to generate complete component set for ${elements
|
|
464
|
-
.
|
|
465
|
-
.
|
|
495
|
+
.filter((element) => !remoteChangesAsComponentSet.has({ type: element === null || element === void 0 ? void 0 : element.type, fullName: element === null || element === void 0 ? void 0 : element.name }))
|
|
496
|
+
.map((element) => `${element.name} (${element.type})`)
|
|
497
|
+
.join(os_1.EOL)}`);
|
|
466
498
|
}
|
|
467
499
|
const matchingLocalSourceComponentsSet = source_deploy_retrieve_1.ComponentSet.fromSource({
|
|
468
500
|
fsPaths: this.packagesDirs.map((dir) => dir.path),
|
|
@@ -527,10 +559,12 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
527
559
|
}
|
|
528
560
|
throw new Error('no filenames found for local ChangeResult');
|
|
529
561
|
}
|
|
562
|
+
// this will eventually have async call to figure out the target file locations for remote changes
|
|
563
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
530
564
|
async remoteChangesToOutputRows(input) {
|
|
531
565
|
var _a, _b, _c, _d;
|
|
532
566
|
this.logger.debug('converting ChangeResult to a row', input);
|
|
533
|
-
this.forceIgnore = (_a = this.forceIgnore) !== null && _a !== void 0 ? _a : source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.
|
|
567
|
+
this.forceIgnore = (_a = this.forceIgnore) !== null && _a !== void 0 ? _a : source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().path);
|
|
534
568
|
const baseObject = {
|
|
535
569
|
type: (_b = input.type) !== null && _b !== void 0 ? _b : '',
|
|
536
570
|
origin: input.origin,
|
|
@@ -545,26 +579,9 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
545
579
|
ignored: this.forceIgnore.denies(filename),
|
|
546
580
|
}));
|
|
547
581
|
}
|
|
548
|
-
// when the file doesn't exist locally, there are no filePaths
|
|
549
|
-
// we can
|
|
550
|
-
|
|
551
|
-
fullName: baseObject.fullName,
|
|
552
|
-
typeName: baseObject.type,
|
|
553
|
-
});
|
|
554
|
-
return [{ ...baseObject, ignored: fakeFilePaths.some((filePath) => this.forceIgnore.denies(filePath)) }];
|
|
555
|
-
}
|
|
556
|
-
// TODO: This goes in SDR on SourceComponent
|
|
557
|
-
// we don't have a local copy of the component
|
|
558
|
-
// this uses SDR's approach to determine what the filePath would be if the component were written locally
|
|
559
|
-
async filesPathFromNonLocalSourceComponent({ fullName, typeName, }) {
|
|
560
|
-
var _a, _b;
|
|
561
|
-
this.registry = (_a = this.registry) !== null && _a !== void 0 ? _a : new source_deploy_retrieve_1.RegistryAccess();
|
|
562
|
-
const component = new source_deploy_retrieve_1.SourceComponent({ name: fullName, type: this.registry.getTypeByName(typeName) });
|
|
563
|
-
this.transformerFactory =
|
|
564
|
-
(_b = this.transformerFactory) !== null && _b !== void 0 ? _b : new metadataTransformerFactory_1.MetadataTransformerFactory(this.registry, new convertContext_1.ConvertContext());
|
|
565
|
-
const transformer = this.transformerFactory.getTransformer(component);
|
|
566
|
-
const writePaths = await transformer.toSourceFormat(component);
|
|
567
|
-
return writePaths.map((writePath) => writePath.output);
|
|
582
|
+
// when the file doesn't exist locally, there are no filePaths
|
|
583
|
+
// So we can't say whether it's ignored or not
|
|
584
|
+
return [baseObject];
|
|
568
585
|
}
|
|
569
586
|
}
|
|
570
587
|
exports.SourceTracking = SourceTracking;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"0.4.4","commands":{}}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/source-tracking",
|
|
3
3
|
"description": "API for tracking local and remote Salesforce metadata changes",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
9
|
"homepage": "https://github.com/forcedotcom/source-tracking#readme",
|
|
10
|
-
"repository": "forcedotcom/source-tracking
|
|
10
|
+
"repository": "forcedotcom/source-tracking",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "sf-build",
|
|
13
13
|
"ci-docs": "yarn sf-ci-docs",
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
"format": "sf-format",
|
|
19
19
|
"lint": "sf-lint",
|
|
20
20
|
"lint-fix": "yarn sf-lint --fix",
|
|
21
|
-
"prepack": "sf-build",
|
|
22
21
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
22
|
+
"prepack": "sf-prepack",
|
|
23
|
+
"prepare": "sf-install",
|
|
23
24
|
"pretest": "sf-compile-test",
|
|
24
|
-
"
|
|
25
|
-
"test
|
|
26
|
-
"
|
|
25
|
+
"prune:dead": "ts-prune | grep -v 'source-deploy-retrieve' | grep -v 'index.ts'",
|
|
26
|
+
"test": "sf-test",
|
|
27
|
+
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel"
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
29
30
|
"force",
|
|
@@ -40,28 +41,20 @@
|
|
|
40
41
|
"!lib/**/*.map",
|
|
41
42
|
"/oclif.manifest.json"
|
|
42
43
|
],
|
|
43
|
-
"husky": {
|
|
44
|
-
"hooks": {
|
|
45
|
-
"commit-msg": "sf-husky-commit-msg",
|
|
46
|
-
"pre-commit": "sf-husky-pre-commit",
|
|
47
|
-
"pre-push": "sf-husky-pre-push"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
44
|
"dependencies": {
|
|
51
|
-
"@salesforce/core": "^2.
|
|
45
|
+
"@salesforce/core": "^2.31.0",
|
|
52
46
|
"@salesforce/kit": "^1.5.17",
|
|
53
|
-
"@salesforce/source-deploy-retrieve": "^5.0
|
|
47
|
+
"@salesforce/source-deploy-retrieve": "^5.8.0",
|
|
54
48
|
"isomorphic-git": "^1.9.2",
|
|
55
49
|
"ts-retry-promise": "^0.6.0"
|
|
56
50
|
},
|
|
57
51
|
"devDependencies": {
|
|
58
52
|
"@salesforce/cli-plugins-testkit": "^1.3.7",
|
|
59
53
|
"@salesforce/dev-config": "^2.1.2",
|
|
60
|
-
"@salesforce/dev-scripts": "^0.
|
|
54
|
+
"@salesforce/dev-scripts": "^1.0.0",
|
|
61
55
|
"@salesforce/prettier-config": "^0.0.2",
|
|
62
56
|
"@salesforce/ts-sinon": "^1.3.21",
|
|
63
57
|
"@types/shelljs": "^0.8.9",
|
|
64
|
-
"@types/sinon": "^10.0.2",
|
|
65
58
|
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
|
66
59
|
"@typescript-eslint/parser": "^4.29.0",
|
|
67
60
|
"chai": "^4.3.0",
|
|
@@ -72,10 +65,10 @@
|
|
|
72
65
|
"eslint-config-salesforce-license": "^0.1.6",
|
|
73
66
|
"eslint-config-salesforce-typescript": "^0.2.7",
|
|
74
67
|
"eslint-plugin-header": "^3.1.1",
|
|
75
|
-
"eslint-plugin-import": "
|
|
76
|
-
"eslint-plugin-jsdoc": "^
|
|
68
|
+
"eslint-plugin-import": "2.24.2",
|
|
69
|
+
"eslint-plugin-jsdoc": "^37.0.1",
|
|
77
70
|
"eslint-plugin-prettier": "^3.4.0",
|
|
78
|
-
"husky": "^
|
|
71
|
+
"husky": "^7.0.4",
|
|
79
72
|
"mocha": "^9.0.3",
|
|
80
73
|
"nyc": "^15.1.0",
|
|
81
74
|
"prettier": "^2.3.2",
|
|
@@ -85,7 +78,7 @@
|
|
|
85
78
|
"sinon": "^10.0.0",
|
|
86
79
|
"ts-node": "^10.1.0",
|
|
87
80
|
"ts-prune": "^0.10.0",
|
|
88
|
-
"typescript": "^4.
|
|
81
|
+
"typescript": "^4.4.4"
|
|
89
82
|
},
|
|
90
83
|
"oclif": {
|
|
91
84
|
"commands": "./lib/commands",
|