@jayree/sfdx-plugin-manifest 2.5.3 → 2.6.1
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 +22 -0
- package/README.md +63 -4
- package/lib/SDR-extra/collections/componentSetExtra.d.ts +38 -0
- package/lib/SDR-extra/collections/componentSetExtra.js +66 -0
- package/lib/SDR-extra/collections/componentSetExtra.js.map +1 -0
- package/lib/SDR-extra/resolve/gitDiffResolver.d.ts +18 -0
- package/lib/SDR-extra/resolve/gitDiffResolver.js +192 -0
- package/lib/SDR-extra/resolve/gitDiffResolver.js.map +1 -0
- package/lib/SDR-extra/resolve/treeContainersExtra.d.ts +13 -0
- package/lib/SDR-extra/resolve/treeContainersExtra.js +51 -0
- package/lib/SDR-extra/resolve/treeContainersExtra.js.map +1 -0
- package/lib/SDR-extra/utils/git-extra.d.ts +65 -0
- package/lib/SDR-extra/utils/git-extra.js +198 -0
- package/lib/SDR-extra/utils/git-extra.js.map +1 -0
- package/lib/commands/jayree/manifest/beta/git/diff.d.ts +32 -0
- package/lib/commands/jayree/manifest/beta/git/diff.js +127 -0
- package/lib/commands/jayree/manifest/beta/git/diff.js.map +1 -0
- package/lib/jayreeSfdxCommand.d.ts +3 -0
- package/lib/jayreeSfdxCommand.js +8 -1
- package/lib/jayreeSfdxCommand.js.map +1 -1
- package/lib/utils/gitdiff.js +1 -1
- package/lib/utils/gitdiff.js.map +1 -1
- package/messages/gitdiffbeta.json +17 -0
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [2.6.1](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.6.0...v2.6.1) (2023-01-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update changelog ([0829ae1](https://github.com/jayree/sfdx-plugin-manifest/commit/0829ae1362fec75ede6c8d63f669fabb6d6c1243))
|
|
7
|
+
|
|
8
|
+
# [2.6.0](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.5.3...v2.6.0) (2023-01-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **gitdiff:** fix diff status of childComponents ([ef13e60](https://github.com/jayree/sfdx-plugin-manifest/commit/ef13e600df02bf23aa764084686c0eb789055c20))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **manifest:beta:git:diff:** added new beta command manifest:beta:git:diff ([f4b6242](https://github.com/jayree/sfdx-plugin-manifest/commit/f4b6242e52a4a04d1279e2090dcf1fe37aca2ff2))
|
|
19
|
+
|
|
20
|
+
I recommend that you try the new manifest:beta:git:diff command.\
|
|
21
|
+
I plan to make the beta command generally available in the near future.
|
|
22
|
+
|
|
1
23
|
## [2.5.3](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.5.2...v2.5.3) (2022-12-31)
|
|
2
24
|
|
|
3
25
|
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ $ sfdx plugins:install @jayree/sfdx-plugin-manifest
|
|
|
22
22
|
$ sfdx jayree:[COMMAND]
|
|
23
23
|
running command...
|
|
24
24
|
$ sfdx plugins
|
|
25
|
-
@jayree/sfdx-plugin-manifest 2.
|
|
25
|
+
@jayree/sfdx-plugin-manifest 2.6.1
|
|
26
26
|
$ sfdx help jayree:[COMMAND]
|
|
27
27
|
USAGE
|
|
28
28
|
$ sfdx jayree:COMMAND
|
|
@@ -33,10 +33,69 @@ USAGE
|
|
|
33
33
|
## Commands
|
|
34
34
|
|
|
35
35
|
<!-- commands -->
|
|
36
|
+
* [`sfdx jayree:manifest:beta:git:diff`](#sfdx-jayreemanifestbetagitdiff)
|
|
36
37
|
* [`sfdx jayree:manifest:cleanup`](#sfdx-jayreemanifestcleanup)
|
|
37
38
|
* [`sfdx jayree:manifest:generate`](#sfdx-jayreemanifestgenerate)
|
|
38
39
|
* [`sfdx jayree:manifest:git:diff`](#sfdx-jayreemanifestgitdiff)
|
|
39
40
|
|
|
41
|
+
### `sfdx jayree:manifest:beta:git:diff`
|
|
42
|
+
|
|
43
|
+
create a project manifest and destructiveChanges manifest that lists the metadata components you want to deploy or delete based on changes in your git history
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
USAGE
|
|
47
|
+
$ sfdx jayree:manifest:beta:git:diff [-p <array>] [-o <string>] [-d] [--apiversion <string>] [--json] [--loglevel
|
|
48
|
+
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
|
|
49
|
+
|
|
50
|
+
ARGUMENTS
|
|
51
|
+
REF1 base commit or branch
|
|
52
|
+
REF2 commit or branch to compare to the base commit
|
|
53
|
+
|
|
54
|
+
FLAGS
|
|
55
|
+
-d, --destructivechangesonly create a destructiveChanges manifest
|
|
56
|
+
only (package.xml will be empty)
|
|
57
|
+
-o, --outputdir=<value> directory to save the created
|
|
58
|
+
manifest files
|
|
59
|
+
-p, --sourcepath=<value> comma-separated list of paths to the
|
|
60
|
+
local source files to include in the
|
|
61
|
+
manifest
|
|
62
|
+
--apiversion=<value> override the api version used for
|
|
63
|
+
api requests made by this command
|
|
64
|
+
--json format output as json
|
|
65
|
+
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
|
|
66
|
+
this command invocation
|
|
67
|
+
|
|
68
|
+
DESCRIPTION
|
|
69
|
+
create a project manifest and destructiveChanges manifest that lists the metadata components you want to deploy or
|
|
70
|
+
delete based on changes in your git history
|
|
71
|
+
Use this command to create a manifest and destructiveChanges manifest file based on the difference (git diff) of two
|
|
72
|
+
git refs.
|
|
73
|
+
|
|
74
|
+
You can use all ways to spell <commit> which are valid for 'git diff'.
|
|
75
|
+
(See https://git-scm.com/docs/git-diff)
|
|
76
|
+
|
|
77
|
+
EXAMPLES
|
|
78
|
+
$ sfdx jayree:manifest:beta:git:diff <commit> <commit>
|
|
79
|
+
|
|
80
|
+
$ sfdx jayree:manifest:git:diff <commit>..<commit>
|
|
81
|
+
|
|
82
|
+
uses the changes between two arbitrary <commit>
|
|
83
|
+
|
|
84
|
+
$ sfdx jayree:manifest:beta:git:diff <commit>...<commit>
|
|
85
|
+
|
|
86
|
+
uses the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>.
|
|
87
|
+
|
|
88
|
+
$ sfdx jayree:manifest:beta:git:diff branchA..branchB
|
|
89
|
+
|
|
90
|
+
uses the diff of what is unique in branchB (REF2) and unique in branchA (REF1)
|
|
91
|
+
|
|
92
|
+
$ sfdx jayree:manifest:beta:git:diff branchA...branchB
|
|
93
|
+
|
|
94
|
+
uses the diff of what is unique in branchB (REF2)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
_See code: [src/commands/jayree/manifest/beta/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.6.1/src/commands/jayree/manifest/beta/git/diff.ts)_
|
|
98
|
+
|
|
40
99
|
### `sfdx jayree:manifest:cleanup`
|
|
41
100
|
|
|
42
101
|
removes those tags from a manifest file that are present in a second manifest file
|
|
@@ -63,7 +122,7 @@ EXAMPLES
|
|
|
63
122
|
$ sfdx jayree:manifest:cleanup --manifest=package.xml --file=packageignore.xml
|
|
64
123
|
```
|
|
65
124
|
|
|
66
|
-
_See code: [src/commands/jayree/manifest/cleanup.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
|
125
|
+
_See code: [src/commands/jayree/manifest/cleanup.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.6.1/src/commands/jayree/manifest/cleanup.ts)_
|
|
67
126
|
|
|
68
127
|
### `sfdx jayree:manifest:generate`
|
|
69
128
|
|
|
@@ -106,7 +165,7 @@ EXAMPLES
|
|
|
106
165
|
<Package xmlns='http://soap.sforce.com/2006/04/metadata'>...</Package>
|
|
107
166
|
```
|
|
108
167
|
|
|
109
|
-
_See code: [src/commands/jayree/manifest/generate.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
|
168
|
+
_See code: [src/commands/jayree/manifest/generate.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.6.1/src/commands/jayree/manifest/generate.ts)_
|
|
110
169
|
|
|
111
170
|
### `sfdx jayree:manifest:git:diff`
|
|
112
171
|
|
|
@@ -160,5 +219,5 @@ EXAMPLES
|
|
|
160
219
|
uses the diff of what is unique in branchB (REF2)
|
|
161
220
|
```
|
|
162
221
|
|
|
163
|
-
_See code: [src/commands/jayree/manifest/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
|
222
|
+
_See code: [src/commands/jayree/manifest/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.6.1/src/commands/jayree/manifest/git/diff.ts)_
|
|
164
223
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentSet, OptionalTreeRegistryOptions } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
import Debug from 'debug';
|
|
3
|
+
export declare const debug: Debug.Debugger;
|
|
4
|
+
export interface FromGitDiffOptions extends OptionalTreeRegistryOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Git ref to resolve components against
|
|
7
|
+
*/
|
|
8
|
+
ref: string | string[];
|
|
9
|
+
/**
|
|
10
|
+
* File paths or directory paths to resolve components against
|
|
11
|
+
*/
|
|
12
|
+
fsPaths?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class ComponentSetExtra extends ComponentSet {
|
|
15
|
+
/**
|
|
16
|
+
* Resolve metadata components from git diff <ref> HEAD.
|
|
17
|
+
*
|
|
18
|
+
* @param ref Git ref to resolve components against HEAD
|
|
19
|
+
* @returns ComponentSet of source resolved components
|
|
20
|
+
*/
|
|
21
|
+
static fromGitDiff(ref: string): Promise<ComponentSet>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve metadata components from git diff <ref1> <ref2>.
|
|
24
|
+
*
|
|
25
|
+
* @param refs Git refs to resolve components against
|
|
26
|
+
* @returns ComponentSet of source resolved components
|
|
27
|
+
*/
|
|
28
|
+
static fromGitDiff(refs: string[]): Promise<ComponentSet>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve metadata components from git diff.
|
|
31
|
+
* Customize the resolution process using an options object, such as specifying filters
|
|
32
|
+
* and resolving against a different file system abstraction (see {@link TreeContainer}).
|
|
33
|
+
*
|
|
34
|
+
* @param options
|
|
35
|
+
* @returns ComponentSet of source resolved components
|
|
36
|
+
*/
|
|
37
|
+
static fromGitDiff(options: FromGitDiffOptions): Promise<ComponentSet>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, jayree
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { ComponentSet, DestructiveChangesType, registry as untypedRegistry, } from '@salesforce/source-deploy-retrieve';
|
|
8
|
+
import { SfProject } from '@salesforce/core';
|
|
9
|
+
import Debug from 'debug';
|
|
10
|
+
import { GitDiffResolver } from '../resolve/gitDiffResolver.js';
|
|
11
|
+
export const debug = Debug('sf:gitDiff:ComponentSetExtra');
|
|
12
|
+
export class ComponentSetExtra extends ComponentSet {
|
|
13
|
+
static async fromGitDiff(input) {
|
|
14
|
+
let fsPaths;
|
|
15
|
+
let registry;
|
|
16
|
+
let tree;
|
|
17
|
+
let ref1;
|
|
18
|
+
let ref2;
|
|
19
|
+
if (Array.isArray(input)) {
|
|
20
|
+
ref1 = input[0];
|
|
21
|
+
ref2 = input[1];
|
|
22
|
+
}
|
|
23
|
+
else if (typeof input === 'object') {
|
|
24
|
+
if (Array.isArray(input.ref)) {
|
|
25
|
+
ref1 = input.ref[0];
|
|
26
|
+
ref2 = input.ref[1];
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
ref1 = input.ref;
|
|
30
|
+
}
|
|
31
|
+
fsPaths = input.fsPaths;
|
|
32
|
+
registry = input.registry ?? registry;
|
|
33
|
+
tree = input.tree ?? tree;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
ref1 = input;
|
|
37
|
+
}
|
|
38
|
+
const proj = await SfProject.resolve();
|
|
39
|
+
fsPaths = fsPaths || proj.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
|
|
40
|
+
const gitDiffResolver = new GitDiffResolver();
|
|
41
|
+
const inclusiveFilter = await gitDiffResolver.resolve(ref1, ref2, fsPaths);
|
|
42
|
+
const components = ComponentSet.fromSource({
|
|
43
|
+
fsPaths,
|
|
44
|
+
include: inclusiveFilter,
|
|
45
|
+
tree,
|
|
46
|
+
registry,
|
|
47
|
+
});
|
|
48
|
+
const childsTobeReplacedByParent = [
|
|
49
|
+
...Object.keys(untypedRegistry.types.workflow.children.types),
|
|
50
|
+
...Object.keys(untypedRegistry.types.sharingrules.children.types),
|
|
51
|
+
...Object.keys(untypedRegistry.types.customobjecttranslation.children.types),
|
|
52
|
+
...Object.keys(untypedRegistry.types.bot.children.types),
|
|
53
|
+
];
|
|
54
|
+
for (const component of inclusiveFilter.getSourceComponents()) {
|
|
55
|
+
if (component.isMarkedForDelete()) {
|
|
56
|
+
components.add(component, DestructiveChangesType.POST);
|
|
57
|
+
}
|
|
58
|
+
else if (childsTobeReplacedByParent.includes(component.type.id)) {
|
|
59
|
+
debug(`add parent ${component.parent.type.name}:${component.parent.fullName} of ${component.type.name}:${component.fullName} to manifest`);
|
|
60
|
+
components.add(component.parent);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return components;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=componentSetExtra.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentSetExtra.js","sourceRoot":"","sources":["../../../src/SDR-extra/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IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,QAAQ,cAAc,CACpI,CAAC;gBACF,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aAClC;SACF;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentSet } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
import Debug from 'debug';
|
|
3
|
+
export declare const debug: Debug.Debugger;
|
|
4
|
+
/**
|
|
5
|
+
* Resolver for metadata type and component objects from a git diff result
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class GitDiffResolver {
|
|
10
|
+
private ref1VirtualTreeContainer;
|
|
11
|
+
private ref2VirtualTreeContainer;
|
|
12
|
+
private ref1Resolver;
|
|
13
|
+
private ref2Resolver;
|
|
14
|
+
private static getFileStatus;
|
|
15
|
+
resolve(ref1: string, ref2: string, fsPaths: string[]): Promise<ComponentSet>;
|
|
16
|
+
private getComponentSet;
|
|
17
|
+
private getChildComponentStatus;
|
|
18
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, jayree
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { ComponentSet, RegistryAccess, MetadataResolver, SourceComponent, DestructiveChangesType, } from '@salesforce/source-deploy-retrieve';
|
|
9
|
+
import { SfProject, SfError } from '@salesforce/core';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import { parseMetadataXml } from '@salesforce/source-deploy-retrieve/lib/src/utils/index.js';
|
|
12
|
+
import equal from 'fast-deep-equal';
|
|
13
|
+
import Debug from 'debug';
|
|
14
|
+
import { resolveMultiRefString, resolveSingleRefString, getFileState, getStatus } from '../utils/git-extra.js';
|
|
15
|
+
import { VirtualTreeContainerExtra } from './treeContainersExtra.js';
|
|
16
|
+
export const debug = Debug('sf:gitDiff:resolver');
|
|
17
|
+
const registryAccess = new RegistryAccess();
|
|
18
|
+
/**
|
|
19
|
+
* Resolver for metadata type and component objects from a git diff result
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export class GitDiffResolver {
|
|
24
|
+
static async getFileStatus(ref1, ref2, dir, resolveSourcePaths) {
|
|
25
|
+
let files;
|
|
26
|
+
if (ref2) {
|
|
27
|
+
files = (await getFileState(ref1, ref2, dir)).filter((l) => resolveSourcePaths.some((f) => l.path.startsWith(f)));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
files = await getStatus(dir, ref1);
|
|
31
|
+
files = files.filter((l) => resolveSourcePaths.some((f) => l.path.startsWith(f)));
|
|
32
|
+
}
|
|
33
|
+
files = files.filter((file) => {
|
|
34
|
+
if (file.status === 'D') {
|
|
35
|
+
for (const sourcePath of resolveSourcePaths) {
|
|
36
|
+
const defaultFolder = path.join(sourcePath, 'main', 'default');
|
|
37
|
+
const filePath = file.path.replace(file.path.startsWith(defaultFolder) ? defaultFolder : sourcePath, '');
|
|
38
|
+
const target = files.find((t) => t.path.endsWith(filePath) && t.status === 'A');
|
|
39
|
+
if (target) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
});
|
|
46
|
+
return files;
|
|
47
|
+
}
|
|
48
|
+
async resolve(ref1, ref2, fsPaths) {
|
|
49
|
+
const proj = await SfProject.resolve();
|
|
50
|
+
if (ref2 === undefined) {
|
|
51
|
+
const { ref1: r1, ref2: r2 } = await resolveMultiRefString({ ref: ref1, dir: proj.getPath(), fs });
|
|
52
|
+
ref1 = r1;
|
|
53
|
+
ref2 = r2;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const [r1, r2] = await Promise.all([
|
|
57
|
+
resolveSingleRefString({ ref: ref1, dir: proj.getPath(), fs }),
|
|
58
|
+
resolveSingleRefString({ ref: ref2, dir: proj.getPath(), fs }),
|
|
59
|
+
]);
|
|
60
|
+
ref1 = r1;
|
|
61
|
+
ref2 = r2;
|
|
62
|
+
}
|
|
63
|
+
debug({ ref1, ref2 });
|
|
64
|
+
const fileStatus = await GitDiffResolver.getFileStatus(ref1, ref2, proj.getPath(), fsPaths);
|
|
65
|
+
debug({ fileStatus });
|
|
66
|
+
const [ref1VirtualTreeContainer, ref2VirtualTreeContainer] = await Promise.all([
|
|
67
|
+
VirtualTreeContainerExtra.fromGitRef(ref1, proj.getPath(), fileStatus.filter((l) => l.status === 'M').map((l) => l.path)),
|
|
68
|
+
VirtualTreeContainerExtra.fromGitRef(ref2, proj.getPath(), fileStatus.filter((l) => l.status === 'M').map((l) => l.path)),
|
|
69
|
+
]);
|
|
70
|
+
this.ref1VirtualTreeContainer = ref1VirtualTreeContainer;
|
|
71
|
+
this.ref2VirtualTreeContainer = ref2VirtualTreeContainer;
|
|
72
|
+
fsPaths = fsPaths.map((filepath) => {
|
|
73
|
+
filepath = path.resolve(filepath);
|
|
74
|
+
if (!this.ref1VirtualTreeContainer.exists(filepath) && !this.ref2VirtualTreeContainer.exists(filepath)) {
|
|
75
|
+
throw new SfError(`The sourcepath "${filepath}" is not a valid source file path.`);
|
|
76
|
+
}
|
|
77
|
+
return filepath;
|
|
78
|
+
});
|
|
79
|
+
debug({ fsPaths });
|
|
80
|
+
this.ref1Resolver = new MetadataResolver(registryAccess, this.ref1VirtualTreeContainer);
|
|
81
|
+
this.ref2Resolver = new MetadataResolver(registryAccess, this.ref2VirtualTreeContainer);
|
|
82
|
+
return this.getComponentSet(fileStatus, fsPaths);
|
|
83
|
+
}
|
|
84
|
+
async getComponentSet(gitLines, fsPaths) {
|
|
85
|
+
const results = new ComponentSet(undefined, registryAccess);
|
|
86
|
+
const childComponentPromises = [];
|
|
87
|
+
for (const [, { status, path: fpath }] of gitLines.entries()) {
|
|
88
|
+
if (!fsPaths || fsPaths.some((fsPath) => path.resolve(fpath).startsWith(fsPath))) {
|
|
89
|
+
if (status === 'D') {
|
|
90
|
+
for (const c of this.ref1Resolver.getComponentsFromPath(fpath)) {
|
|
91
|
+
// if the component supports partial delete AND there are files that are not deleted,
|
|
92
|
+
// set the component for deploy, not for delete.
|
|
93
|
+
if (!!c.type.supportsPartialDelete && c.content && this.ref2VirtualTreeContainer.exists(c.content)) {
|
|
94
|
+
// all bundle types have a directory name
|
|
95
|
+
try {
|
|
96
|
+
this.ref2Resolver
|
|
97
|
+
.getComponentsFromPath(path.resolve(c.content))
|
|
98
|
+
.filter((input) => input instanceof SourceComponent)
|
|
99
|
+
.map((nonDeletedComponent) => {
|
|
100
|
+
results.add(nonDeletedComponent);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
debug(`unable to find component at ${c.content}. That's ok if it was supposed to be deleted`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
results.add(c, DestructiveChangesType.POST);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (status === 'A') {
|
|
113
|
+
for (const c of this.ref2Resolver.getComponentsFromPath(fpath)) {
|
|
114
|
+
results.add(c);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
childComponentPromises.push(this.getChildComponentStatus(fpath));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for await (const check of childComponentPromises) {
|
|
123
|
+
if (check.status === 0) {
|
|
124
|
+
for (const c of this.ref2Resolver.getComponentsFromPath(check.path)) {
|
|
125
|
+
results.add(c);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (check.status === -1) {
|
|
129
|
+
// unchanged file
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
for (const c of check.toDestructiveChanges) {
|
|
133
|
+
results.add(c, DestructiveChangesType.POST);
|
|
134
|
+
}
|
|
135
|
+
for (const c of check.toManifest) {
|
|
136
|
+
results.add(c);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
debug({
|
|
141
|
+
forceIgnoredPaths: {
|
|
142
|
+
ref1: Array.from(this.ref1Resolver.forceIgnoredPaths),
|
|
143
|
+
ref2: Array.from(this.ref2Resolver.forceIgnoredPaths),
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
return results;
|
|
147
|
+
}
|
|
148
|
+
async getChildComponentStatus(fpath) {
|
|
149
|
+
if (!parseMetadataXml(fpath)) {
|
|
150
|
+
return { path: fpath, status: 0 };
|
|
151
|
+
}
|
|
152
|
+
const [ref2Component] = this.ref2Resolver.getComponentsFromPath(fpath); // git path only conaints files
|
|
153
|
+
const [ref1Component] = this.ref1Resolver.getComponentsFromPath(fpath); // git path only conaints files
|
|
154
|
+
if (equal(await ref1Component.parseXml(), await ref2Component.parseXml())) {
|
|
155
|
+
return { path: fpath, status: -1 };
|
|
156
|
+
}
|
|
157
|
+
if (ref1Component.type.strictDirectoryName === true || !ref1Component.type.children) {
|
|
158
|
+
return { path: fpath, status: 0 };
|
|
159
|
+
}
|
|
160
|
+
const getUniqueIdentifier = (component) => `${component.type.name}#${component[component.type.uniqueIdElement]}`;
|
|
161
|
+
const ref2ChildUniqueIdArray = ref2Component
|
|
162
|
+
.getChildren()
|
|
163
|
+
.map((childComponent) => getUniqueIdentifier(childComponent));
|
|
164
|
+
const ref1ChildUniqueIdArray = ref1Component
|
|
165
|
+
.getChildren()
|
|
166
|
+
.map((childComponent) => getUniqueIdentifier(childComponent));
|
|
167
|
+
const childComponentsNotInRef2 = ref1Component
|
|
168
|
+
.getChildren()
|
|
169
|
+
.filter((childComponent) => !ref2ChildUniqueIdArray.includes(getUniqueIdentifier(childComponent))); // deleted
|
|
170
|
+
const childComponentsNotInRef1 = ref2Component
|
|
171
|
+
.getChildren()
|
|
172
|
+
.filter((childComponent) => !ref1ChildUniqueIdArray.includes(getUniqueIdentifier(childComponent))); // added
|
|
173
|
+
const childComponentsInRef1AndRef2 = ref1Component
|
|
174
|
+
.getChildren()
|
|
175
|
+
.filter((childComponent) => ref2ChildUniqueIdArray.includes(getUniqueIdentifier(childComponent))); // modified?
|
|
176
|
+
for await (const childComponentRef1 of childComponentsInRef1AndRef2) {
|
|
177
|
+
const [childComponentRef2] = ref2Component
|
|
178
|
+
.getChildren()
|
|
179
|
+
.filter((childComponent) => getUniqueIdentifier(childComponentRef1) === getUniqueIdentifier(childComponent));
|
|
180
|
+
if (!equal(await childComponentRef1.parseXml(), await childComponentRef2.parseXml())) {
|
|
181
|
+
childComponentsNotInRef1.push(childComponentRef2); // modified! -> add to added
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
path: fpath,
|
|
186
|
+
status: 1 + childComponentsNotInRef2.length + childComponentsNotInRef1.length,
|
|
187
|
+
toManifest: childComponentsNotInRef1,
|
|
188
|
+
toDestructiveChanges: childComponentsNotInRef2,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=gitDiffResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitDiffResolver.js","sourceRoot":"","sources":["../../../src/SDR-extra/resolve/gitDiffResolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE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M,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,mBAAmB,CAAC,cAAc,CAAC,CAAC,CAAC;YAC/G,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAkB,CAAC,QAAQ,EAAE,EAAE,MAAM,kBAAkB,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACpF,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,4BAA4B;aAChF;SACF;QAED,OAAO;YACL,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,GAAG,wBAAwB,CAAC,MAAM;YAC7E,UAAU,EAAE,wBAAwB;YACpC,oBAAoB,EAAE,wBAAwB;SAC/C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VirtualTreeContainer } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
export declare class VirtualTreeContainerExtra extends VirtualTreeContainer {
|
|
3
|
+
/**
|
|
4
|
+
* Designed for recreating virtual files from a git ref
|
|
5
|
+
* To support use of MetadataResolver to also resolve metadata xmls file names can be provided
|
|
6
|
+
*
|
|
7
|
+
* @param ref git ref
|
|
8
|
+
* @param dir git dir
|
|
9
|
+
* @param includeBufferForFiles full paths to modified files
|
|
10
|
+
* @returns VirtualTreeContainer
|
|
11
|
+
*/
|
|
12
|
+
static fromGitRef(ref: string, dir: string, includeBufferForFiles: string[]): Promise<VirtualTreeContainer>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, jayree
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { VirtualTreeContainer } from '@salesforce/source-deploy-retrieve';
|
|
9
|
+
import { parseMetadataXml } from '@salesforce/source-deploy-retrieve/lib/src/utils/index.js';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import { listFullPathFiles, getOid, readBlobAsBuffer } from '../utils/git-extra.js';
|
|
12
|
+
export class VirtualTreeContainerExtra extends VirtualTreeContainer {
|
|
13
|
+
/**
|
|
14
|
+
* Designed for recreating virtual files from a git ref
|
|
15
|
+
* To support use of MetadataResolver to also resolve metadata xmls file names can be provided
|
|
16
|
+
*
|
|
17
|
+
* @param ref git ref
|
|
18
|
+
* @param dir git dir
|
|
19
|
+
* @param includeBufferForFiles full paths to modified files
|
|
20
|
+
* @returns VirtualTreeContainer
|
|
21
|
+
*/
|
|
22
|
+
static async fromGitRef(ref, dir, includeBufferForFiles) {
|
|
23
|
+
const paths = await listFullPathFiles(dir, ref);
|
|
24
|
+
const oid = await getOid(dir, ref);
|
|
25
|
+
const virtualDirectoryByFullPath = new Map();
|
|
26
|
+
for await (const filename of paths) {
|
|
27
|
+
let dirPath = path.dirname(filename);
|
|
28
|
+
virtualDirectoryByFullPath.set(dirPath, {
|
|
29
|
+
dirPath,
|
|
30
|
+
children: Array.from(new Set(virtualDirectoryByFullPath.get(dirPath)?.children ?? []).add({
|
|
31
|
+
name: path.basename(filename),
|
|
32
|
+
data: parseMetadataXml(filename) && includeBufferForFiles.includes(filename)
|
|
33
|
+
? oid
|
|
34
|
+
? await readBlobAsBuffer(dir, oid, filename)
|
|
35
|
+
: await fs.readFile(filename)
|
|
36
|
+
: Buffer.from(''),
|
|
37
|
+
})),
|
|
38
|
+
});
|
|
39
|
+
const splits = filename.split(path.sep);
|
|
40
|
+
for (let i = 1; i < splits.length - 1; i++) {
|
|
41
|
+
dirPath = splits.slice(0, i + 1).join(path.sep);
|
|
42
|
+
virtualDirectoryByFullPath.set(dirPath, {
|
|
43
|
+
dirPath,
|
|
44
|
+
children: Array.from(new Set(virtualDirectoryByFullPath.get(dirPath)?.children ?? []).add(splits[i + 1])),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return new VirtualTreeContainer(Array.from(virtualDirectoryByFullPath.values()));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=treeContainersExtra.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeContainersExtra.js","sourceRoot":"","sources":["../../../src/SDR-extra/resolve/treeContainersExtra.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAoB,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,MAAM,OAAO,yBAA0B,SAAQ,oBAAoB;IACjE;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAC5B,GAAW,EACX,GAAW,EACX,qBAA+B;QAE/B,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAA4B,CAAC;QACvE,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,KAAK,EAAE;YAClC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,0BAA0B,CAAC,GAAG,CAAC,OAAO,EAAE;gBACtC,OAAO;gBACP,QAAQ,EAAE,KAAK,CAAC,IAAI,CAClB,IAAI,GAAG,CAAC,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAC,CAA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ient, PromiseFsClient } from 'isomorphic-git';
|
|
3
|
+
import Debug from 'debug';
|
|
4
|
+
export declare const debug: Debug.Debugger;
|
|
5
|
+
export interface GetCommitLogOptions {
|
|
6
|
+
/**
|
|
7
|
+
* File paths or directory paths to resolve components against
|
|
8
|
+
*/
|
|
9
|
+
ref: string;
|
|
10
|
+
/**
|
|
11
|
+
* File paths or directory paths to resolve components against
|
|
12
|
+
*/
|
|
13
|
+
dir: string;
|
|
14
|
+
/**
|
|
15
|
+
* File paths or directory paths to resolve components against
|
|
16
|
+
*/
|
|
17
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
18
|
+
}
|
|
19
|
+
interface MultiRefStringOptions {
|
|
20
|
+
/**
|
|
21
|
+
* File paths or directory paths to resolve components against
|
|
22
|
+
*/
|
|
23
|
+
ref: string;
|
|
24
|
+
/**
|
|
25
|
+
* File paths or directory paths to resolve components against
|
|
26
|
+
*/
|
|
27
|
+
dir: string;
|
|
28
|
+
/**
|
|
29
|
+
* File paths or directory paths to resolve components against
|
|
30
|
+
*/
|
|
31
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
32
|
+
}
|
|
33
|
+
export declare function resolveMultiRefString(options: MultiRefStringOptions): Promise<{
|
|
34
|
+
ref1: string;
|
|
35
|
+
ref2: string;
|
|
36
|
+
}>;
|
|
37
|
+
interface SingleRefStringOptions {
|
|
38
|
+
/**
|
|
39
|
+
* File paths or directory paths to resolve components against
|
|
40
|
+
*/
|
|
41
|
+
ref: string;
|
|
42
|
+
/**
|
|
43
|
+
* File paths or directory paths to resolve components against
|
|
44
|
+
*/
|
|
45
|
+
dir: string;
|
|
46
|
+
/**
|
|
47
|
+
* File paths or directory paths to resolve components against
|
|
48
|
+
*/
|
|
49
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
50
|
+
}
|
|
51
|
+
export declare function resolveSingleRefString(options: SingleRefStringOptions): Promise<string>;
|
|
52
|
+
export declare function getFileState(commitHash1: string, commitHash2: string, dir: string): Promise<[
|
|
53
|
+
{
|
|
54
|
+
path: string;
|
|
55
|
+
status: string;
|
|
56
|
+
}
|
|
57
|
+
]>;
|
|
58
|
+
export declare function getStatus(dir: string, ref: string): Promise<Array<{
|
|
59
|
+
path: string;
|
|
60
|
+
status: string;
|
|
61
|
+
}>>;
|
|
62
|
+
export declare function listFullPathFiles(dir: string, ref: string): Promise<string[]>;
|
|
63
|
+
export declare function getOid(dir: string, ref: string): Promise<string>;
|
|
64
|
+
export declare function readBlobAsBuffer(dir: string, oid: string, filename: string): Promise<Buffer>;
|
|
65
|
+
export {};
|