@salesforce/source-tracking 0.4.4 → 0.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.
- package/CHANGELOG.md +18 -0
- package/LICENSE.txt +1 -1
- package/lib/shared/functions.d.ts +2 -0
- package/lib/shared/functions.js +3 -1
- package/lib/shared/guards.d.ts +0 -1
- package/lib/shared/guards.js +1 -5
- package/lib/shared/localShadowRepo.js +8 -2
- package/lib/sourceTracking.d.ts +7 -2
- package/lib/sourceTracking.js +100 -43
- package/package.json +2 -29
- package/lib/shared/filenamesToVirtualTree.d.ts +0 -10
- package/lib/shared/filenamesToVirtualTree.js +0 -39
- package/oclif.manifest.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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
|
+
## [0.5.0](https://github.com/forcedotcom/source-tracking/compare/v0.4.4...v0.5.0) (2021-12-02)
|
|
6
|
+
|
|
7
|
+
### ⚠ BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
- mpd suport (array of componentSets for localChanges)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- delete bundle member but not the bundle ([fbb81f2](https://github.com/forcedotcom/source-tracking/commit/fbb81f25af4cb9e81e3bbee93a08b072318eca10))
|
|
14
|
+
- delete bundle members instead of bundle ([0aedbd5](https://github.com/forcedotcom/source-tracking/commit/0aedbd56b3bf34ce9e344ec03bb258c9db2098aa))
|
|
15
|
+
- mpd suport (array of componentSets for localChanges) ([dd072bb](https://github.com/forcedotcom/source-tracking/commit/dd072bb86450a2e071dca3aece3cba6a2339b05a))
|
|
16
|
+
- trackingFiles handle deleted bundle members ([137cd39](https://github.com/forcedotcom/source-tracking/commit/137cd391f0ea8ae60b3351d7b3361ae97b890d45))
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- deploy by pkgDir groupings, not all ([7f1262e](https://github.com/forcedotcom/source-tracking/commit/7f1262e1d05a57d3094849d052376b13dd7a5ec7))
|
|
21
|
+
- windows paths when pkgDir path has separators in it ([b0ab346](https://github.com/forcedotcom/source-tracking/commit/b0ab3468d9c54722f832fb7d27a84525d593d4f7))
|
|
22
|
+
|
|
5
23
|
### [0.4.4](https://github.com/forcedotcom/source-tracking/compare/v0.4.3...v0.4.4) (2021-12-01)
|
|
6
24
|
|
|
7
25
|
### Features
|
package/LICENSE.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
1
2
|
import { RemoteChangeElement, ChangeResult } from './types';
|
|
2
3
|
export declare const getMetadataKey: (metadataType: string, metadataName: string) => string;
|
|
3
4
|
export declare const getKeyFromObject: (element: RemoteChangeElement | ChangeResult) => string;
|
|
5
|
+
export declare const isBundle: (cmp: SourceComponent) => boolean;
|
package/lib/shared/functions.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getKeyFromObject = exports.getMetadataKey = void 0;
|
|
9
|
+
exports.isBundle = exports.getKeyFromObject = exports.getMetadataKey = void 0;
|
|
10
10
|
const getMetadataKey = (metadataType, metadataName) => {
|
|
11
11
|
return `${metadataType}__${metadataName}`;
|
|
12
12
|
};
|
|
@@ -18,4 +18,6 @@ const getKeyFromObject = (element) => {
|
|
|
18
18
|
throw new Error(`unable to complete key from ${JSON.stringify(element)}`);
|
|
19
19
|
};
|
|
20
20
|
exports.getKeyFromObject = getKeyFromObject;
|
|
21
|
+
const isBundle = (cmp) => { var _a; return ((_a = cmp.type.strategies) === null || _a === void 0 ? void 0 : _a.adapter) === 'bundle'; };
|
|
22
|
+
exports.isBundle = isBundle;
|
|
21
23
|
//# sourceMappingURL=functions.js.map
|
package/lib/shared/guards.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { SourceComponent, MetadataMember } from '@salesforce/source-deploy-retrieve';
|
|
2
|
-
export declare const stringGuard: (input: string | undefined) => input is string;
|
|
3
2
|
export declare const sourceComponentGuard: (input: SourceComponent | undefined) => input is SourceComponent;
|
|
4
3
|
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.metadataMemberGuard = exports.sourceComponentGuard =
|
|
3
|
+
exports.metadataMemberGuard = exports.sourceComponentGuard = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -8,10 +8,6 @@ exports.metadataMemberGuard = exports.sourceComponentGuard = exports.stringGuard
|
|
|
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 source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
11
|
-
const stringGuard = (input) => {
|
|
12
|
-
return typeof input === 'string';
|
|
13
|
-
};
|
|
14
|
-
exports.stringGuard = stringGuard;
|
|
15
11
|
const sourceComponentGuard = (input) => {
|
|
16
12
|
return input instanceof source_deploy_retrieve_1.SourceComponent;
|
|
17
13
|
};
|
|
@@ -81,18 +81,24 @@ class ShadowRepo {
|
|
|
81
81
|
async getStatus(noCache = false) {
|
|
82
82
|
if (!this.status || noCache) {
|
|
83
83
|
try {
|
|
84
|
+
// only ask about OS once but use twice
|
|
85
|
+
const isWindows = os.type() === 'Windows_NT';
|
|
84
86
|
await this.stashIgnoreFile();
|
|
87
|
+
const filepaths = isWindows
|
|
88
|
+
? // iso-git uses posix paths, but packageDirs has already normalized them so we need to convert if windows
|
|
89
|
+
this.packageDirs.map((dir) => dir.path.split(path.sep).join(path.posix.sep))
|
|
90
|
+
: this.packageDirs.map((dir) => dir.path);
|
|
85
91
|
// status hasn't been initalized yet
|
|
86
92
|
this.status = await git.statusMatrix({
|
|
87
93
|
fs: core_1.fs,
|
|
88
94
|
dir: this.projectPath,
|
|
89
95
|
gitdir: this.gitDir,
|
|
90
|
-
filepaths
|
|
96
|
+
filepaths,
|
|
91
97
|
// filter out hidden files and __tests__ patterns, regardless of gitignore
|
|
92
98
|
filter: (f) => !f.includes(`${path.sep}.`) && !f.includes('__tests__'),
|
|
93
99
|
});
|
|
94
100
|
// isomorphic-git stores things in unix-style tree. Convert to windows-style if necessary
|
|
95
|
-
if (
|
|
101
|
+
if (isWindows) {
|
|
96
102
|
this.status = this.status.map((row) => [path.normalize(row[FILE]), row[HEAD], row[WORKDIR], row[3]]);
|
|
97
103
|
}
|
|
98
104
|
}
|
package/lib/sourceTracking.d.ts
CHANGED
|
@@ -27,7 +27,12 @@ export declare class SourceTracking extends AsyncCreatable {
|
|
|
27
27
|
private forceIgnore;
|
|
28
28
|
constructor(options: SourceTrackingOptions);
|
|
29
29
|
init(): Promise<void>;
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param byPackageDir if true, returns one ComponentSet for each packageDir with changes
|
|
33
|
+
* @returns ComponentSet[]
|
|
34
|
+
*/
|
|
35
|
+
localChangesAsComponentSet(byPackageDir?: boolean): Promise<ComponentSet[]>;
|
|
31
36
|
/**
|
|
32
37
|
* Does most of the work for the force:source:status command.
|
|
33
38
|
* Outputs need a bit of massage since this aims to provide nice json.
|
|
@@ -102,7 +107,7 @@ export declare class SourceTracking extends AsyncCreatable {
|
|
|
102
107
|
* uses SDR to translate remote metadata records into local file paths (which only typically have the filename).
|
|
103
108
|
*
|
|
104
109
|
* @input elements: ChangeResult[]
|
|
105
|
-
* @input
|
|
110
|
+
* @input excludeUnresolvable: boolean Filter out components where you can't get the name and type (that is, it's probably not a valid source component)
|
|
106
111
|
* @input resolveDeleted: constructs a virtualTree instead of the actual filesystem--useful when the files no longer exist
|
|
107
112
|
* @input useFsForceIgnore: (default behavior) use forceIgnore from the filesystem. If false, uses the base forceIgnore from SDR
|
|
108
113
|
*/
|
package/lib/sourceTracking.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.SourceTracking = 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 fs = require("fs");
|
|
11
|
-
const
|
|
11
|
+
const path_1 = require("path");
|
|
12
12
|
const os_1 = require("os");
|
|
13
13
|
const core_1 = require("@salesforce/core");
|
|
14
14
|
const kit_1 = require("@salesforce/kit");
|
|
@@ -16,7 +16,6 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
16
16
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
17
17
|
const remoteSourceTrackingService_1 = require("./shared/remoteSourceTrackingService");
|
|
18
18
|
const localShadowRepo_1 = require("./shared/localShadowRepo");
|
|
19
|
-
const filenamesToVirtualTree_1 = require("./shared/filenamesToVirtualTree");
|
|
20
19
|
const guards_1 = require("./shared/guards");
|
|
21
20
|
const functions_1 = require("./shared/functions");
|
|
22
21
|
/**
|
|
@@ -39,43 +38,82 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
39
38
|
async init() {
|
|
40
39
|
// reserved for future use
|
|
41
40
|
}
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param byPackageDir if true, returns one ComponentSet for each packageDir with changes
|
|
44
|
+
* @returns ComponentSet[]
|
|
45
|
+
*/
|
|
46
|
+
async localChangesAsComponentSet(byPackageDir = false) {
|
|
47
|
+
var _a;
|
|
43
48
|
const [projectConfig] = await Promise.all([this.project.resolveProjectConfig(), this.ensureLocalTracking()]);
|
|
49
|
+
(_a = this.forceIgnore) !== null && _a !== void 0 ? _a : (this.forceIgnore = source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().name));
|
|
44
50
|
const sourceApiVersion = (0, ts_types_1.getString)(projectConfig, 'sourceApiVersion');
|
|
45
|
-
const componentSet = new source_deploy_retrieve_1.ComponentSet();
|
|
46
|
-
if (sourceApiVersion) {
|
|
47
|
-
componentSet.sourceApiVersion = sourceApiVersion;
|
|
48
|
-
}
|
|
49
|
-
const [nonDeletes, deletes] = await Promise.all([
|
|
50
|
-
this.localRepo.getNonDeleteFilenames(),
|
|
51
|
-
this.localRepo.getDeleteFilenames(),
|
|
52
|
-
]);
|
|
53
|
-
if (nonDeletes.length === 0 && deletes.length === 0) {
|
|
54
|
-
this.logger.debug('no local changes found in source tracking files');
|
|
55
|
-
return componentSet;
|
|
56
|
-
}
|
|
57
51
|
// optimistic resolution...some files may not be possible to resolve
|
|
58
52
|
const resolverForNonDeletes = new source_deploy_retrieve_1.MetadataResolver();
|
|
59
53
|
// we need virtual components for the deletes.
|
|
60
54
|
// TODO: could we use the same for the non-deletes?
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
const [allNonDeletes, allDeletes] = (await Promise.all([this.localRepo.getNonDeleteFilenames(), this.localRepo.getDeleteFilenames()]))
|
|
56
|
+
// remove the forceIgnored items early
|
|
57
|
+
.map((group) => group.filter((item) => this.forceIgnore.accepts(item)));
|
|
58
|
+
// it'll be easier to filter filenames and work with smaller component sets than to filter SourceComponents
|
|
59
|
+
const groupings = (byPackageDir
|
|
60
|
+
? this.packagesDirs.map((pkgDir) => ({
|
|
61
|
+
path: pkgDir.name,
|
|
62
|
+
nonDeletes: allNonDeletes.filter((f) => f.startsWith(pkgDir.name)),
|
|
63
|
+
deletes: allDeletes.filter((f) => f.startsWith(pkgDir.name)),
|
|
64
|
+
}))
|
|
65
|
+
: [
|
|
66
|
+
{
|
|
67
|
+
nonDeletes: allNonDeletes,
|
|
68
|
+
deletes: allDeletes,
|
|
69
|
+
path: this.packagesDirs.map((dir) => dir.name).join(';'),
|
|
70
|
+
},
|
|
71
|
+
]).filter((group) => group.deletes.length || group.nonDeletes.length);
|
|
72
|
+
this.logger.debug(`will build array of ${groupings.length} componentSet(s)`);
|
|
73
|
+
return groupings
|
|
74
|
+
.map((grouping) => {
|
|
75
|
+
this.logger.debug(`building componentSet for ${grouping.path} (deletes: ${grouping.deletes.length} nonDeletes: ${grouping.nonDeletes.length})`);
|
|
76
|
+
const componentSet = new source_deploy_retrieve_1.ComponentSet();
|
|
77
|
+
if (sourceApiVersion) {
|
|
78
|
+
componentSet.sourceApiVersion = sourceApiVersion;
|
|
70
79
|
}
|
|
80
|
+
const resolverForDeletes = new source_deploy_retrieve_1.MetadataResolver(undefined, source_deploy_retrieve_1.VirtualTreeContainer.fromFilePaths(grouping.deletes));
|
|
81
|
+
grouping.deletes
|
|
82
|
+
.flatMap((filename) => resolverForDeletes.getComponentsFromPath(filename))
|
|
83
|
+
.filter(guards_1.sourceComponentGuard)
|
|
84
|
+
.map((component) => {
|
|
85
|
+
// if the component is a file in a bundle type AND there are files from the bundle that are not deleted, set the bundle for deploy, not for delete
|
|
86
|
+
if ((0, functions_1.isBundle)(component) && component.content && fs.existsSync(component.content)) {
|
|
87
|
+
// all bundle types have a directory name
|
|
88
|
+
try {
|
|
89
|
+
resolverForNonDeletes
|
|
90
|
+
.getComponentsFromPath((0, path_1.resolve)(component.content))
|
|
91
|
+
.filter(guards_1.sourceComponentGuard)
|
|
92
|
+
.map((nonDeletedComponent) => componentSet.add(nonDeletedComponent));
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
this.logger.warn(`unable to find component at ${component.content}. That's ok if it was supposed to be deleted`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
componentSet.add(component, source_deploy_retrieve_1.DestructiveChangesType.POST);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
grouping.nonDeletes
|
|
103
|
+
.flatMap((filename) => {
|
|
104
|
+
try {
|
|
105
|
+
return resolverForNonDeletes.getComponentsFromPath((0, path_1.resolve)(filename));
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
this.logger.warn(`unable to resolve ${filename}`);
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.filter(guards_1.sourceComponentGuard)
|
|
113
|
+
.map((component) => componentSet.add(component));
|
|
114
|
+
return componentSet;
|
|
71
115
|
})
|
|
72
|
-
.filter(
|
|
73
|
-
.map((component) => componentSet.add(component));
|
|
74
|
-
deletes
|
|
75
|
-
.flatMap((filename) => resolverForDeletes.getComponentsFromPath(filename))
|
|
76
|
-
.filter(guards_1.sourceComponentGuard)
|
|
77
|
-
.map((component) => componentSet.add(component, source_deploy_retrieve_1.DestructiveChangesType.POST));
|
|
78
|
-
return componentSet;
|
|
116
|
+
.filter((componentSet) => componentSet.size > 0);
|
|
79
117
|
}
|
|
80
118
|
/**
|
|
81
119
|
* Does most of the work for the force:source:status command.
|
|
@@ -100,7 +138,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
100
138
|
}
|
|
101
139
|
if (local && remote) {
|
|
102
140
|
// keys like ApexClass__MyClass.cls
|
|
103
|
-
const conflictFiles = (await this.getConflicts()).flatMap((conflict) => conflict.filenames).filter(
|
|
141
|
+
const conflictFiles = (await this.getConflicts()).flatMap((conflict) => conflict.filenames).filter(ts_types_1.isString);
|
|
104
142
|
results = results.map((row) => ({
|
|
105
143
|
...row,
|
|
106
144
|
conflict: !!row.filePath && conflictFiles.includes(row.filePath),
|
|
@@ -129,7 +167,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
129
167
|
}
|
|
130
168
|
if (options.format === 'SourceComponent') {
|
|
131
169
|
const resolver = options.state === 'delete'
|
|
132
|
-
? new source_deploy_retrieve_1.MetadataResolver(undefined,
|
|
170
|
+
? new source_deploy_retrieve_1.MetadataResolver(undefined, source_deploy_retrieve_1.VirtualTreeContainer.fromFilePaths(filenames))
|
|
133
171
|
: new source_deploy_retrieve_1.MetadataResolver();
|
|
134
172
|
return filenames
|
|
135
173
|
.flatMap((filename) => {
|
|
@@ -224,9 +262,28 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
224
262
|
async updateLocalTracking(options) {
|
|
225
263
|
var _a, _b;
|
|
226
264
|
await this.ensureLocalTracking();
|
|
265
|
+
// relative paths make smaller trees AND isogit wants them relative
|
|
266
|
+
const relativeOptions = {
|
|
267
|
+
files: ((_a = options.files) !== null && _a !== void 0 ? _a : []).map((file) => this.ensureRelative(file)),
|
|
268
|
+
deletedFiles: ((_b = options.deletedFiles) !== null && _b !== void 0 ? _b : []).map((file) => this.ensureRelative(file)),
|
|
269
|
+
};
|
|
270
|
+
// plot twist: if you delete a member of a bundle (ex: lwc/foo/foo.css) and push, it'll not be in the fileResponses (deployedFiles) or deletedFiles
|
|
271
|
+
// what got deleted? Any local changes NOT in the fileResponses but part of a successfully deployed bundle
|
|
272
|
+
const deployedFilesAsVirtualComponentSet = source_deploy_retrieve_1.ComponentSet.fromSource({
|
|
273
|
+
// resolve from highest possible level. TODO: can we use [.]
|
|
274
|
+
fsPaths: relativeOptions.files.length ? [relativeOptions.files[0].split(path_1.sep)[0]] : [],
|
|
275
|
+
tree: source_deploy_retrieve_1.VirtualTreeContainer.fromFilePaths(relativeOptions.files),
|
|
276
|
+
});
|
|
277
|
+
// these are top-level bundle paths like lwc/foo
|
|
278
|
+
const bundlesWithDeletedFiles = (await this.getChanges({ origin: 'local', state: 'delete', format: 'SourceComponent' }))
|
|
279
|
+
.filter(functions_1.isBundle)
|
|
280
|
+
.filter((cmp) => deployedFilesAsVirtualComponentSet.has({ type: cmp.type, fullName: cmp.fullName }))
|
|
281
|
+
.map((cmp) => cmp.content)
|
|
282
|
+
.filter(ts_types_1.isString);
|
|
227
283
|
await this.localRepo.commitChanges({
|
|
228
|
-
deployedFiles:
|
|
229
|
-
deletedFiles: (
|
|
284
|
+
deployedFiles: relativeOptions.files,
|
|
285
|
+
deletedFiles: relativeOptions.deletedFiles.concat((await this.localRepo.getDeleteFilenames()).filter((deployedFile) => bundlesWithDeletedFiles.some((bundlePath) => deployedFile.startsWith(bundlePath)) &&
|
|
286
|
+
!relativeOptions.files.includes(deployedFile))),
|
|
230
287
|
});
|
|
231
288
|
}
|
|
232
289
|
/**
|
|
@@ -253,7 +310,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
253
310
|
}
|
|
254
311
|
this.localRepo = await localShadowRepo_1.ShadowRepo.getInstance({
|
|
255
312
|
orgId: this.orgId,
|
|
256
|
-
projectPath: this.projectPath,
|
|
313
|
+
projectPath: (0, path_1.normalize)(this.projectPath),
|
|
257
314
|
packageDirs: this.packagesDirs,
|
|
258
315
|
});
|
|
259
316
|
// loads the status from file so that it's cached
|
|
@@ -377,7 +434,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
377
434
|
* uses SDR to translate remote metadata records into local file paths (which only typically have the filename).
|
|
378
435
|
*
|
|
379
436
|
* @input elements: ChangeResult[]
|
|
380
|
-
* @input
|
|
437
|
+
* @input excludeUnresolvable: boolean Filter out components where you can't get the name and type (that is, it's probably not a valid source component)
|
|
381
438
|
* @input resolveDeleted: constructs a virtualTree instead of the actual filesystem--useful when the files no longer exist
|
|
382
439
|
* @input useFsForceIgnore: (default behavior) use forceIgnore from the filesystem. If false, uses the base forceIgnore from SDR
|
|
383
440
|
*/
|
|
@@ -386,9 +443,9 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
386
443
|
return [];
|
|
387
444
|
}
|
|
388
445
|
this.logger.debug(`populateTypesAndNames for ${elements.length} change elements`);
|
|
389
|
-
const filenames = elements.flatMap((element) => element.filenames).filter(
|
|
446
|
+
const filenames = elements.flatMap((element) => element.filenames).filter(ts_types_1.isString);
|
|
390
447
|
// component set generated from the filenames on all local changes
|
|
391
|
-
const resolver = new source_deploy_retrieve_1.MetadataResolver(undefined, resolveDeleted ?
|
|
448
|
+
const resolver = new source_deploy_retrieve_1.MetadataResolver(undefined, resolveDeleted ? source_deploy_retrieve_1.VirtualTreeContainer.fromFilePaths(filenames) : undefined, useFsForceIgnore);
|
|
392
449
|
const sourceComponents = filenames
|
|
393
450
|
.flatMap((filename) => {
|
|
394
451
|
try {
|
|
@@ -415,9 +472,9 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
415
472
|
if ((matchingComponent === null || matchingComponent === void 0 ? void 0 : matchingComponent.fullName) && (matchingComponent === null || matchingComponent === void 0 ? void 0 : matchingComponent.type.name)) {
|
|
416
473
|
const filenamesFromMatchingComponent = [matchingComponent.xml, ...matchingComponent.walkContent()];
|
|
417
474
|
// 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)
|
|
418
|
-
|
|
475
|
+
(_a = this.forceIgnore) !== null && _a !== void 0 ? _a : (this.forceIgnore = source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().path));
|
|
419
476
|
const ignored = filenamesFromMatchingComponent
|
|
420
|
-
.filter(
|
|
477
|
+
.filter(ts_types_1.isString)
|
|
421
478
|
.filter((filename) => !filename.includes('__tests__'))
|
|
422
479
|
.some((filename) => this.forceIgnore.denies(filename));
|
|
423
480
|
filenamesFromMatchingComponent.map((filename) => {
|
|
@@ -522,7 +579,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
522
579
|
return Array.from(elementMap.values());
|
|
523
580
|
}
|
|
524
581
|
ensureRelative(filePath) {
|
|
525
|
-
return
|
|
582
|
+
return (0, path_1.isAbsolute)(filePath) ? (0, path_1.relative)(this.projectPath, filePath) : filePath;
|
|
526
583
|
}
|
|
527
584
|
async getLocalChangesAsFilenames(state) {
|
|
528
585
|
if (state === 'modify') {
|
|
@@ -564,7 +621,7 @@ class SourceTracking extends kit_1.AsyncCreatable {
|
|
|
564
621
|
async remoteChangesToOutputRows(input) {
|
|
565
622
|
var _a, _b, _c, _d;
|
|
566
623
|
this.logger.debug('converting ChangeResult to a row', input);
|
|
567
|
-
|
|
624
|
+
(_a = this.forceIgnore) !== null && _a !== void 0 ? _a : (this.forceIgnore = source_deploy_retrieve_1.ForceIgnore.findAndCreate(this.project.getDefaultPackage().path));
|
|
568
625
|
const baseObject = {
|
|
569
626
|
type: (_b = input.type) !== null && _b !== void 0 ? _b : '',
|
|
570
627
|
origin: input.origin,
|
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": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@salesforce/cli-plugins-testkit": "^1.3.7",
|
|
53
53
|
"@salesforce/dev-config": "^2.1.2",
|
|
54
|
-
"@salesforce/dev-scripts": "^1.0.
|
|
54
|
+
"@salesforce/dev-scripts": "^1.0.2",
|
|
55
55
|
"@salesforce/prettier-config": "^0.0.2",
|
|
56
56
|
"@salesforce/ts-sinon": "^1.3.21",
|
|
57
57
|
"@types/shelljs": "^0.8.9",
|
|
@@ -80,33 +80,6 @@
|
|
|
80
80
|
"ts-prune": "^0.10.0",
|
|
81
81
|
"typescript": "^4.4.4"
|
|
82
82
|
},
|
|
83
|
-
"oclif": {
|
|
84
|
-
"commands": "./lib/commands",
|
|
85
|
-
"bin": "sfdx",
|
|
86
|
-
"devPlugins": [
|
|
87
|
-
"@oclif/plugin-help",
|
|
88
|
-
"@oclif/plugin-command-snapshot",
|
|
89
|
-
"@salesforce/plugin-command-reference"
|
|
90
|
-
],
|
|
91
|
-
"topics": {
|
|
92
|
-
"force": {
|
|
93
|
-
"external": true,
|
|
94
|
-
"subtopics": {
|
|
95
|
-
"user": {
|
|
96
|
-
"description": "commands that perform user-related admin tasks",
|
|
97
|
-
"subtopics": {
|
|
98
|
-
"permset": {
|
|
99
|
-
"description": "Use to interact with permission sets assigned to a user"
|
|
100
|
-
},
|
|
101
|
-
"password": {
|
|
102
|
-
"description": "Used to generate and set passwords for users"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
83
|
"config": {
|
|
111
84
|
"commitizen": {
|
|
112
85
|
"path": "cz-conventional-changelog"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { VirtualTreeContainer } from '@salesforce/source-deploy-retrieve';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated this is moving to SDR
|
|
4
|
-
* Designed for recreating virtual files from deleted files where the only information we have is the file's former location
|
|
5
|
-
* Any use of MetadataResolver was trying to access the non-existent files and throwing
|
|
6
|
-
*
|
|
7
|
-
* @param filenames full paths to files
|
|
8
|
-
* @returns VirtualTreeContainer to use with MetadataResolver
|
|
9
|
-
*/
|
|
10
|
-
export declare const filenamesToVirtualTree: (filenames: string[]) => VirtualTreeContainer;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filenamesToVirtualTree = 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 path = require("path");
|
|
11
|
-
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated this is moving to SDR
|
|
14
|
-
* Designed for recreating virtual files from deleted files where the only information we have is the file's former location
|
|
15
|
-
* Any use of MetadataResolver was trying to access the non-existent files and throwing
|
|
16
|
-
*
|
|
17
|
-
* @param filenames full paths to files
|
|
18
|
-
* @returns VirtualTreeContainer to use with MetadataResolver
|
|
19
|
-
*/
|
|
20
|
-
const filenamesToVirtualTree = (filenames) => {
|
|
21
|
-
// a map to reduce array iterations
|
|
22
|
-
const virtualDirectoryByFullPath = new Map();
|
|
23
|
-
filenames.map((filename) => {
|
|
24
|
-
var _a;
|
|
25
|
-
const splits = filename.split(path.sep);
|
|
26
|
-
for (let i = 0; i < splits.length - 1; i++) {
|
|
27
|
-
const fullPathSoFar = splits.slice(0, i + 1).join(path.sep);
|
|
28
|
-
const existing = virtualDirectoryByFullPath.get(fullPathSoFar);
|
|
29
|
-
virtualDirectoryByFullPath.set(fullPathSoFar, {
|
|
30
|
-
dirPath: fullPathSoFar,
|
|
31
|
-
// only add to children if we don't already have it
|
|
32
|
-
children: Array.from(new Set((_a = existing === null || existing === void 0 ? void 0 : existing.children) !== null && _a !== void 0 ? _a : []).add(splits[i + 1])),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return new source_deploy_retrieve_1.VirtualTreeContainer(Array.from(virtualDirectoryByFullPath.values()));
|
|
37
|
-
};
|
|
38
|
-
exports.filenamesToVirtualTree = filenamesToVirtualTree;
|
|
39
|
-
//# sourceMappingURL=filenamesToVirtualTree.js.map
|
package/oclif.manifest.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"0.4.4","commands":{}}
|