@jayree/sfdx-plugin-manifest 2.6.3 → 2.7.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 +20 -0
- package/README.md +48 -53
- package/lib/SDR-extra/collections/componentSetExtra.d.ts +2 -3
- package/lib/SDR-extra/collections/componentSetExtra.js +32 -15
- package/lib/SDR-extra/collections/componentSetExtra.js.map +1 -1
- package/lib/SDR-extra/collections/index.d.ts +1 -0
- package/lib/SDR-extra/collections/index.js +8 -0
- package/lib/SDR-extra/collections/index.js.map +1 -0
- package/lib/SDR-extra/index.d.ts +3 -0
- package/lib/SDR-extra/index.js +10 -0
- package/lib/SDR-extra/index.js.map +1 -0
- package/lib/SDR-extra/resolve/gitDiffResolver.d.ts +9 -4
- package/lib/SDR-extra/resolve/gitDiffResolver.js +88 -79
- package/lib/SDR-extra/resolve/gitDiffResolver.js.map +1 -1
- package/lib/SDR-extra/resolve/index.d.ts +2 -0
- package/lib/SDR-extra/resolve/index.js +9 -0
- package/lib/SDR-extra/resolve/index.js.map +1 -0
- package/lib/SDR-extra/resolve/treeContainersExtra.d.ts +2 -1
- package/lib/SDR-extra/resolve/treeContainersExtra.js +9 -7
- package/lib/SDR-extra/resolve/treeContainersExtra.js.map +1 -1
- package/lib/SDR-extra/utils/index.d.ts +1 -0
- package/lib/SDR-extra/utils/index.js +8 -0
- package/lib/SDR-extra/utils/index.js.map +1 -0
- package/lib/SDR-extra/utils/localGitRepo.d.ts +39 -0
- package/lib/SDR-extra/utils/localGitRepo.js +239 -0
- package/lib/SDR-extra/utils/localGitRepo.js.map +1 -0
- package/lib/commands/jayree/manifest/beta/git/diff.d.ts +18 -14
- package/lib/commands/jayree/manifest/beta/git/diff.js +44 -35
- package/lib/commands/jayree/manifest/beta/git/diff.js.map +1 -1
- package/lib/commands/jayree/manifest/cleanup.d.ts +1 -2
- package/lib/commands/jayree/manifest/cleanup.js +1 -1
- package/lib/commands/jayree/manifest/cleanup.js.map +1 -1
- package/lib/commands/jayree/manifest/git/diff.d.ts +5 -2
- package/lib/commands/jayree/manifest/git/diff.js.map +1 -1
- package/lib/utils/gitdiff.js +10 -2
- package/lib/utils/gitdiff.js.map +1 -1
- package/messages/gitdiffbeta.md +67 -0
- package/oclif.manifest.json +1 -1
- package/package.json +9 -5
- package/schemas/jayree-manifest-beta-git-diff.json +38 -0
- package/schemas/jayree-manifest-generate.json +51 -0
- package/schemas/jayree-manifest-git-diff.json +19 -0
- package/lib/SDR-extra/utils/git-extra.d.ts +0 -65
- package/lib/SDR-extra/utils/git-extra.js +0 -198
- package/lib/SDR-extra/utils/git-extra.js.map +0 -1
- package/messages/gitdiffbeta.json +0 -17
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# [2.7.0](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.6.4...v2.7.0) (2023-01-09)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **manifest:beta:git:diff:** fix output if ref2 is set ([9886831](https://github.com/jayree/sfdx-plugin-manifest/commit/9886831f7533d2b9d2bfdba2f1da5f94f2eb3caa))
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **manifest:beta:git:diff:** more enhancements and new sf flags. -d is now used for --source-dir ([1c6be65](https://github.com/jayree/sfdx-plugin-manifest/commit/1c6be65967f6c1fd0afa6ae590466563347d80aa))
|
12
|
+
|
13
|
+
## [2.6.4](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.6.3...v2.6.4) (2023-01-09)
|
14
|
+
|
15
|
+
|
16
|
+
### Bug Fixes
|
17
|
+
|
18
|
+
* **manifest:beta:git:diff:** fix sourcepath parameter ([0cc68bf](https://github.com/jayree/sfdx-plugin-manifest/commit/0cc68bf9547cc3ea67c0b6b591c2166f2debc852))
|
19
|
+
* **manifest:git:diff:** ignore modified forceignored metadata ([a264829](https://github.com/jayree/sfdx-plugin-manifest/commit/a26482954f18cb316b71e79d53191f2e6307b4c6))
|
20
|
+
|
1
21
|
## [2.6.3](https://github.com/jayree/sfdx-plugin-manifest/compare/v2.6.2...v2.6.3) (2023-01-06)
|
2
22
|
|
3
23
|
|
package/README.md
CHANGED
@@ -3,32 +3,16 @@
|
|
3
3
|
A Salesforce CLI plugin containing commands for creating manifest files from Salesforce orgs or git commits of sfdx projects.
|
4
4
|
|
5
5
|
[](https://developer.salesforce.com/tools/sfdxcli)
|
6
|
-
[](https://npmjs.org/package/@jayree/sfdx-plugin-manifest)
|
7
7
|
[](https://github.com/jayree/sfdx-plugin-manifest/actions/workflows/release.yml)
|
8
8
|
[](https://npmjs.org/package/@jayree/sfdx-plugin-manifest)
|
9
9
|
[](https://github.com/jayree-plugins/sfdx-plugin-manifest/blob/main/package.json)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<!-- install -->
|
16
|
-
|
17
|
-
## Usage
|
18
|
-
|
19
|
-
<!-- usage -->
|
20
|
-
```sh-session
|
21
|
-
$ sfdx plugins:install @jayree/sfdx-plugin-manifest
|
22
|
-
$ sfdx jayree:[COMMAND]
|
23
|
-
running command...
|
24
|
-
$ sfdx plugins
|
25
|
-
@jayree/sfdx-plugin-manifest 2.6.3
|
26
|
-
$ sfdx help jayree:[COMMAND]
|
27
|
-
USAGE
|
28
|
-
$ sfdx jayree:COMMAND
|
29
|
-
...
|
11
|
+
## Install
|
12
|
+
|
13
|
+
```bash
|
14
|
+
sfdx plugins:install @jayree/sfdx-plugin-manifest
|
30
15
|
```
|
31
|
-
<!-- usagestop -->
|
32
16
|
|
33
17
|
## Commands
|
34
18
|
|
@@ -40,61 +24,72 @@ USAGE
|
|
40
24
|
|
41
25
|
### `sfdx jayree:manifest:beta:git:diff`
|
42
26
|
|
43
|
-
|
27
|
+
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
28
|
|
45
29
|
```
|
46
30
|
USAGE
|
47
|
-
$ sfdx jayree:manifest:beta:git:diff [
|
48
|
-
|
31
|
+
$ sfdx jayree:manifest:beta:git:diff [REF1] [REF2] [--json] [--api-version <value>] [-d <value>] [--output-dir <value>]
|
32
|
+
[--destructive-changes-only]
|
49
33
|
|
50
34
|
ARGUMENTS
|
51
35
|
REF1 base commit or branch
|
52
36
|
REF2 commit or branch to compare to the base commit
|
53
37
|
|
54
38
|
FLAGS
|
55
|
-
-d, --
|
56
|
-
|
57
|
-
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
39
|
+
-d, --source-dir=<value>... Path to the local source files to include in the manifest.
|
40
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
41
|
+
--destructive-changes-only Create a destructiveChanges manifest only.
|
42
|
+
--output-dir=<value> Directory to save the created manifest files.
|
43
|
+
|
44
|
+
GLOBAL FLAGS
|
45
|
+
--json Format output as json.
|
67
46
|
|
68
47
|
DESCRIPTION
|
69
|
-
|
70
|
-
delete based on changes in your git history
|
48
|
+
Create a project manifest and destructiveChanges manifest that lists the metadata components you want to deploy or
|
49
|
+
delete based on changes in your git history.
|
50
|
+
|
71
51
|
Use this command to create a manifest and destructiveChanges manifest file based on the difference (git diff) of two
|
72
52
|
git refs.
|
73
53
|
|
74
|
-
You can use all ways to spell <commit> which are valid for 'git diff'.
|
75
|
-
(See https://git-scm.com/docs/git-diff)
|
54
|
+
You can use all ways to spell <commit> which are valid for 'git diff' (See https://git-scm.com/docs/git-diff).
|
76
55
|
|
77
56
|
EXAMPLES
|
78
|
-
|
57
|
+
Uses the changes between two arbitrary <commit>.
|
79
58
|
|
80
|
-
|
59
|
+
$ sfdx jayree:manifest:beta:git:diff <commit> <commit>
|
60
|
+
$ sfdx jayree:manifest:beta:git:diff <commit>..<commit>
|
81
61
|
|
82
|
-
|
62
|
+
Uses the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both
|
63
|
+
<commit>.
|
83
64
|
|
84
|
-
|
65
|
+
$ sfdx jayree:manifest:beta:git:diff <commit>...<commit>
|
85
66
|
|
86
|
-
|
67
|
+
Uses the diff of what is unique in branchB (REF2) and unique in branchA (REF1).
|
87
68
|
|
88
|
-
|
69
|
+
$ sfdx jayree:manifest:beta:git:diff branchA..branchB
|
89
70
|
|
90
|
-
|
71
|
+
Uses the diff of what is unique in branchB (REF2).
|
91
72
|
|
92
|
-
|
73
|
+
$ sfdx jayree:manifest:beta:git:diff branchA...branchB
|
93
74
|
|
94
|
-
|
75
|
+
FLAG DESCRIPTIONS
|
76
|
+
-d, --source-dir=<value>... Path to the local source files to include in the manifest.
|
77
|
+
|
78
|
+
The supplied path can be to a single file (in which case the operation is applied to only one file) or to a folder
|
79
|
+
(in which case the operation is applied to all metadata types in the directory and its subdirectories).
|
80
|
+
|
81
|
+
You can specify this flag more than once.
|
82
|
+
|
83
|
+
--destructive-changes-only Create a destructiveChanges manifest only.
|
84
|
+
|
85
|
+
Use this flag to create a 'destructiveChanges.xml' and a blank 'package.xml'.
|
86
|
+
|
87
|
+
--output-dir=<value> Directory to save the created manifest files.
|
88
|
+
|
89
|
+
The location can be an absolute path or relative to the current working directory.
|
95
90
|
```
|
96
91
|
|
97
|
-
_See code: [src/commands/jayree/manifest/beta/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
92
|
+
_See code: [src/commands/jayree/manifest/beta/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.7.0/src/commands/jayree/manifest/beta/git/diff.ts)_
|
98
93
|
|
99
94
|
### `sfdx jayree:manifest:cleanup`
|
100
95
|
|
@@ -122,7 +117,7 @@ EXAMPLES
|
|
122
117
|
$ sfdx jayree:manifest:cleanup --manifest=package.xml --file=packageignore.xml
|
123
118
|
```
|
124
119
|
|
125
|
-
_See code: [src/commands/jayree/manifest/cleanup.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
120
|
+
_See code: [src/commands/jayree/manifest/cleanup.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.7.0/src/commands/jayree/manifest/cleanup.ts)_
|
126
121
|
|
127
122
|
### `sfdx jayree:manifest:generate`
|
128
123
|
|
@@ -165,7 +160,7 @@ EXAMPLES
|
|
165
160
|
<Package xmlns='http://soap.sforce.com/2006/04/metadata'>...</Package>
|
166
161
|
```
|
167
162
|
|
168
|
-
_See code: [src/commands/jayree/manifest/generate.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
163
|
+
_See code: [src/commands/jayree/manifest/generate.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.7.0/src/commands/jayree/manifest/generate.ts)_
|
169
164
|
|
170
165
|
### `sfdx jayree:manifest:git:diff`
|
171
166
|
|
@@ -219,5 +214,5 @@ EXAMPLES
|
|
219
214
|
uses the diff of what is unique in branchB (REF2)
|
220
215
|
```
|
221
216
|
|
222
|
-
_See code: [src/commands/jayree/manifest/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.
|
217
|
+
_See code: [src/commands/jayree/manifest/git/diff.ts](https://github.com/jayree/sfdx-plugin-manifest/blob/v2.7.0/src/commands/jayree/manifest/git/diff.ts)_
|
223
218
|
<!-- commandsstop -->
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { ComponentSet, OptionalTreeRegistryOptions } from '@salesforce/source-deploy-retrieve';
|
2
|
-
|
3
|
-
export declare const debug: Debug.Debugger;
|
4
|
-
export interface FromGitDiffOptions extends OptionalTreeRegistryOptions {
|
2
|
+
interface FromGitDiffOptions extends OptionalTreeRegistryOptions {
|
5
3
|
/**
|
6
4
|
* Git ref to resolve components against
|
7
5
|
*/
|
@@ -36,3 +34,4 @@ export declare class ComponentSetExtra extends ComponentSet {
|
|
36
34
|
*/
|
37
35
|
static fromGitDiff(options: FromGitDiffOptions): Promise<ComponentSet>;
|
38
36
|
}
|
37
|
+
export {};
|
@@ -4,11 +4,13 @@
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
6
6
|
*/
|
7
|
+
import path from 'path';
|
7
8
|
import { ComponentSet, DestructiveChangesType, registry as untypedRegistry, } from '@salesforce/source-deploy-retrieve';
|
8
|
-
import { SfProject } from '@salesforce/core';
|
9
|
+
import { SfProject, Lifecycle } from '@salesforce/core';
|
9
10
|
import Debug from 'debug';
|
10
|
-
import
|
11
|
-
|
11
|
+
import fs from 'graceful-fs';
|
12
|
+
import { GitDiffResolver } from '../resolve/index.js';
|
13
|
+
const debug = Debug('sf:gitDiff:ComponentSetExtra');
|
12
14
|
export class ComponentSetExtra extends ComponentSet {
|
13
15
|
static async fromGitDiff(input) {
|
14
16
|
let fsPaths;
|
@@ -35,29 +37,44 @@ export class ComponentSetExtra extends ComponentSet {
|
|
35
37
|
else {
|
36
38
|
ref1 = input;
|
37
39
|
}
|
38
|
-
const
|
39
|
-
|
40
|
-
const gitDiffResolver = new GitDiffResolver();
|
40
|
+
const project = await SfProject.resolve();
|
41
|
+
const gitDiffResolver = new GitDiffResolver(project);
|
41
42
|
const inclusiveFilter = await gitDiffResolver.resolve(ref1, ref2, fsPaths);
|
42
|
-
const components = ComponentSet.fromSource({
|
43
|
-
fsPaths,
|
44
|
-
include: inclusiveFilter,
|
45
|
-
tree,
|
46
|
-
registry,
|
47
|
-
});
|
48
43
|
const childsTobeReplacedByParent = [
|
49
44
|
...Object.keys(untypedRegistry.types.workflow.children.types),
|
50
45
|
...Object.keys(untypedRegistry.types.sharingrules.children.types),
|
51
46
|
...Object.keys(untypedRegistry.types.customobjecttranslation.children.types),
|
52
47
|
...Object.keys(untypedRegistry.types.bot.children.types),
|
53
48
|
];
|
49
|
+
for (const component of inclusiveFilter.getSourceComponents()) {
|
50
|
+
if (childsTobeReplacedByParent.includes(component.type.id)) {
|
51
|
+
debug(`add parent ${component.parent.type.name}:${component.parent.fullName} of ${component.type.name}:${component.fullName} to manifest`);
|
52
|
+
inclusiveFilter.add(component.parent);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
fsPaths =
|
56
|
+
fsPaths?.map((filepath) => path.resolve(filepath)).filter((filepath) => fs.existsSync(filepath)) ||
|
57
|
+
project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
|
58
|
+
debug({ fsPaths });
|
59
|
+
const components = ComponentSet.fromSource({
|
60
|
+
fsPaths,
|
61
|
+
include: inclusiveFilter,
|
62
|
+
tree,
|
63
|
+
registry,
|
64
|
+
});
|
54
65
|
for (const component of inclusiveFilter.getSourceComponents()) {
|
55
66
|
if (component.isMarkedForDelete()) {
|
56
67
|
components.add(component, DestructiveChangesType.POST);
|
57
68
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
69
|
+
}
|
70
|
+
for await (const component of inclusiveFilter.getSourceComponents()) {
|
71
|
+
if (!components
|
72
|
+
.getSourceComponents()
|
73
|
+
.find((localComponent) => !!localComponent
|
74
|
+
.getChildren()
|
75
|
+
.find((localChild) => component.type.name === localChild.type.name && component.fullName === localChild.fullName) ||
|
76
|
+
(component.type.name === localComponent.type.name && component.fullName === localComponent.fullName))) {
|
77
|
+
await Lifecycle.getInstance().emitWarning(`The component "${component.type.name}:${component.fullName}" was not found locally.`);
|
61
78
|
}
|
62
79
|
}
|
63
80
|
return components;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"componentSetExtra.js","sourceRoot":"","sources":["../../../src/SDR-extra/collections/componentSetExtra.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,YAAY,EAGZ,sBAAsB,EAEtB,QAAQ,IAAI,eAAe,GAC5B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"componentSetExtra.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QAAQ,0BAA0B,CACtF,CAAC;aACH;SACF;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './componentSetExtra.js';
|
@@ -0,0 +1,8 @@
|
|
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
|
+
export * from './componentSetExtra.js';
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SDR-extra/collections/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,wBAAwB,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
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
|
+
export * from './collections/index.js';
|
8
|
+
export * from './resolve/index.js';
|
9
|
+
export * from './utils/index.js';
|
10
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/SDR-extra/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
@@ -1,18 +1,23 @@
|
|
1
1
|
import { ComponentSet } from '@salesforce/source-deploy-retrieve';
|
2
|
-
import
|
3
|
-
export declare const debug: Debug.Debugger;
|
2
|
+
import { SfProject } from '@salesforce/core';
|
4
3
|
/**
|
5
4
|
* Resolver for metadata type and component objects from a git diff result
|
6
5
|
*
|
7
6
|
* @internal
|
8
7
|
*/
|
9
8
|
export declare class GitDiffResolver {
|
10
|
-
private ref1VirtualTreeContainer;
|
11
9
|
private ref2VirtualTreeContainer;
|
12
10
|
private ref1Resolver;
|
13
11
|
private ref2Resolver;
|
14
|
-
private
|
12
|
+
private gitDir;
|
13
|
+
private uniquePackageDirectories;
|
14
|
+
private localRepo;
|
15
|
+
/**
|
16
|
+
* @param dir SFDX project directory
|
17
|
+
*/
|
18
|
+
constructor(project: SfProject);
|
15
19
|
resolve(ref1: string, ref2: string, fsPaths: string[]): Promise<ComponentSet>;
|
20
|
+
private getFileStatus;
|
16
21
|
private getComponentSet;
|
17
22
|
private getChildComponentStatus;
|
18
23
|
}
|
@@ -6,14 +6,12 @@
|
|
6
6
|
*/
|
7
7
|
import path from 'path';
|
8
8
|
import { ComponentSet, RegistryAccess, MetadataResolver, SourceComponent, DestructiveChangesType, } from '@salesforce/source-deploy-retrieve';
|
9
|
-
import {
|
10
|
-
import fs from 'fs-extra';
|
11
|
-
import { parseMetadataXml } from '@salesforce/source-deploy-retrieve/lib/src/utils/index.js';
|
9
|
+
import { SfError, Lifecycle } from '@salesforce/core';
|
12
10
|
import equal from 'fast-deep-equal';
|
13
11
|
import Debug from 'debug';
|
14
|
-
import {
|
15
|
-
import { VirtualTreeContainerExtra } from './
|
16
|
-
|
12
|
+
import { GitRepo } from '../utils/localGitRepo.js';
|
13
|
+
import { VirtualTreeContainerExtra, parseMetadataXml } from './index.js';
|
14
|
+
const debug = Debug('sf:gitDiff:resolver');
|
17
15
|
const registryAccess = new RegistryAccess();
|
18
16
|
/**
|
19
17
|
* Resolver for metadata type and component objects from a git diff result
|
@@ -21,104 +19,111 @@ const registryAccess = new RegistryAccess();
|
|
21
19
|
* @internal
|
22
20
|
*/
|
23
21
|
export class GitDiffResolver {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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;
|
22
|
+
/**
|
23
|
+
* @param dir SFDX project directory
|
24
|
+
*/
|
25
|
+
constructor(project) {
|
26
|
+
this.gitDir = project.getPath();
|
27
|
+
this.uniquePackageDirectories = project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
|
28
|
+
this.localRepo = GitRepo.getInstance({
|
29
|
+
gitDir: this.gitDir,
|
30
|
+
packageDirs: this.uniquePackageDirectories,
|
45
31
|
});
|
46
|
-
return files;
|
47
32
|
}
|
48
33
|
async resolve(ref1, ref2, fsPaths) {
|
49
|
-
const proj = await SfProject.resolve();
|
50
34
|
if (ref2 === undefined) {
|
51
|
-
const { ref1: r1, ref2: r2 } = await resolveMultiRefString(
|
35
|
+
const { ref1: r1, ref2: r2 } = await this.localRepo.resolveMultiRefString(ref1);
|
52
36
|
ref1 = r1;
|
53
37
|
ref2 = r2;
|
54
38
|
}
|
55
39
|
else {
|
56
40
|
const [r1, r2] = await Promise.all([
|
57
|
-
resolveSingleRefString(
|
58
|
-
resolveSingleRefString(
|
41
|
+
this.localRepo.resolveSingleRefString(ref1),
|
42
|
+
this.localRepo.resolveSingleRefString(ref2),
|
59
43
|
]);
|
60
44
|
ref1 = r1;
|
61
45
|
ref2 = r2;
|
62
46
|
}
|
63
47
|
debug({ ref1, ref2 });
|
64
|
-
const fileStatus = await
|
48
|
+
const fileStatus = await this.getFileStatus(ref1, ref2);
|
65
49
|
debug({ fileStatus });
|
66
50
|
const [ref1VirtualTreeContainer, ref2VirtualTreeContainer] = await Promise.all([
|
67
|
-
VirtualTreeContainerExtra.fromGitRef(ref1,
|
68
|
-
VirtualTreeContainerExtra.fromGitRef(ref2,
|
51
|
+
VirtualTreeContainerExtra.fromGitRef(ref1, this.gitDir, fileStatus.filter((l) => l.status === 'M').map((l) => l.path)),
|
52
|
+
VirtualTreeContainerExtra.fromGitRef(ref2, this.gitDir, fileStatus.filter((l) => l.status === 'M').map((l) => l.path)),
|
69
53
|
]);
|
70
|
-
|
54
|
+
if (fsPaths) {
|
55
|
+
fsPaths.map((filepath) => {
|
56
|
+
filepath = path.resolve(filepath);
|
57
|
+
if (!ref1VirtualTreeContainer.exists(filepath) && !ref2VirtualTreeContainer.exists(filepath)) {
|
58
|
+
throw new SfError(`The sourcepath "${filepath}" is not a valid source file path.`);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
}
|
71
62
|
this.ref2VirtualTreeContainer = ref2VirtualTreeContainer;
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
63
|
+
this.ref1Resolver = new MetadataResolver(registryAccess, ref1VirtualTreeContainer);
|
64
|
+
this.ref2Resolver = new MetadataResolver(registryAccess, this.ref2VirtualTreeContainer);
|
65
|
+
return this.getComponentSet(fileStatus);
|
66
|
+
}
|
67
|
+
async getFileStatus(ref1, ref2) {
|
68
|
+
let files;
|
69
|
+
if (ref2) {
|
70
|
+
files = (await this.localRepo.getFileState({ ref1, ref2 })).filter((l) => this.uniquePackageDirectories.some((f) => l.path.startsWith(f)));
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
files = await this.localRepo.getStatus(ref1);
|
74
|
+
}
|
75
|
+
files = files.filter((file) => {
|
76
|
+
if (file.status === 'D') {
|
77
|
+
for (const sourcePath of this.uniquePackageDirectories) {
|
78
|
+
const defaultFolder = path.join(sourcePath, 'main', 'default');
|
79
|
+
const filePath = file.path.replace(file.path.startsWith(defaultFolder) ? defaultFolder : sourcePath, '');
|
80
|
+
const target = files.find((t) => t.path.endsWith(filePath) && t.status === 'A');
|
81
|
+
// debug({ target, file, sourcePath, filePath });
|
82
|
+
if (target) {
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
}
|
76
86
|
}
|
77
|
-
return
|
87
|
+
return true;
|
78
88
|
});
|
79
|
-
|
80
|
-
this.ref1Resolver = new MetadataResolver(registryAccess, this.ref1VirtualTreeContainer);
|
81
|
-
this.ref2Resolver = new MetadataResolver(registryAccess, this.ref2VirtualTreeContainer);
|
82
|
-
return this.getComponentSet(fileStatus, fsPaths);
|
89
|
+
return files;
|
83
90
|
}
|
84
|
-
async getComponentSet(gitLines
|
91
|
+
async getComponentSet(gitLines) {
|
85
92
|
const results = new ComponentSet(undefined, registryAccess);
|
86
93
|
const childComponentPromises = [];
|
87
94
|
for (const [, { status, path: fpath }] of gitLines.entries()) {
|
88
|
-
if (
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
});
|
103
|
-
}
|
104
|
-
catch (e) {
|
105
|
-
debug(`unable to find component at ${c.content}. That's ok if it was supposed to be deleted`);
|
106
|
-
}
|
95
|
+
if (status === 'D') {
|
96
|
+
for (const c of this.ref1Resolver.getComponentsFromPath(fpath)) {
|
97
|
+
// if the component supports partial delete AND there are files that are not deleted,
|
98
|
+
// set the component for deploy, not for delete.
|
99
|
+
// https://github.com/forcedotcom/source-tracking/blob/5cb32bef2e5860c0f8fc2afa3ea65432fe511a99/src/shared/localComponentSetArray.ts#L81
|
100
|
+
if (!!c.type.supportsPartialDelete && c.content && this.ref2VirtualTreeContainer.exists(c.content)) {
|
101
|
+
// all bundle types have a directory name
|
102
|
+
try {
|
103
|
+
this.ref2Resolver
|
104
|
+
.getComponentsFromPath(path.resolve(c.content))
|
105
|
+
.filter((input) => input instanceof SourceComponent)
|
106
|
+
.map((nonDeletedComponent) => {
|
107
|
+
results.add(nonDeletedComponent);
|
108
|
+
});
|
107
109
|
}
|
108
|
-
|
109
|
-
|
110
|
+
catch (e) {
|
111
|
+
debug(`unable to find component at ${c.content}. That's ok if it was supposed to be deleted`);
|
110
112
|
}
|
111
113
|
}
|
112
|
-
|
113
|
-
|
114
|
-
for (const c of this.ref2Resolver.getComponentsFromPath(fpath)) {
|
115
|
-
results.add(c);
|
114
|
+
else {
|
115
|
+
results.add(c, DestructiveChangesType.POST);
|
116
116
|
}
|
117
117
|
}
|
118
|
-
|
119
|
-
|
118
|
+
}
|
119
|
+
else if (status === 'A') {
|
120
|
+
for (const c of this.ref2Resolver.getComponentsFromPath(fpath)) {
|
121
|
+
results.add(c);
|
120
122
|
}
|
121
123
|
}
|
124
|
+
else {
|
125
|
+
childComponentPromises.push(this.getChildComponentStatus(fpath));
|
126
|
+
}
|
122
127
|
}
|
123
128
|
for await (const check of childComponentPromises) {
|
124
129
|
if (check.status === 0) {
|
@@ -129,6 +134,9 @@ export class GitDiffResolver {
|
|
129
134
|
else if (check.status === -1) {
|
130
135
|
// unchanged file
|
131
136
|
}
|
137
|
+
else if (check.status === -2) {
|
138
|
+
// forceignored file
|
139
|
+
}
|
132
140
|
else {
|
133
141
|
for (const c of check.toDestructiveChanges) {
|
134
142
|
results.add(c, DestructiveChangesType.POST);
|
@@ -138,12 +146,10 @@ export class GitDiffResolver {
|
|
138
146
|
}
|
139
147
|
}
|
140
148
|
}
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
},
|
146
|
-
});
|
149
|
+
const forceIgnored = Array.from(new Set([...this.ref1Resolver.forceIgnoredPaths, ...this.ref2Resolver.forceIgnoredPaths]));
|
150
|
+
for await (const file of forceIgnored) {
|
151
|
+
await Lifecycle.getInstance().emitWarning(`The forceignored file "${file}" was ignored.`);
|
152
|
+
}
|
147
153
|
return results;
|
148
154
|
}
|
149
155
|
async getChildComponentStatus(fpath) {
|
@@ -152,6 +158,9 @@ export class GitDiffResolver {
|
|
152
158
|
}
|
153
159
|
const [ref2Component] = this.ref2Resolver.getComponentsFromPath(fpath); // git path only conaints files
|
154
160
|
const [ref1Component] = this.ref1Resolver.getComponentsFromPath(fpath); // git path only conaints files
|
161
|
+
if (this.ref1Resolver.forceIgnoredPaths.has(fpath) || this.ref2Resolver.forceIgnoredPaths.has(fpath)) {
|
162
|
+
return { path: fpath, status: -2 };
|
163
|
+
}
|
155
164
|
if (equal(await ref1Component.parseXml(), await ref2Component.parseXml())) {
|
156
165
|
return { path: fpath, status: -1 };
|
157
166
|
}
|