@salesforce/plugin-deploy-retrieve 3.3.1 → 3.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/README.md +1530 -2
- package/lib/commands/project/convert/mdapi.js +3 -2
- package/lib/commands/project/convert/mdapi.js.map +1 -1
- package/lib/commands/project/convert/source.js +4 -2
- package/lib/commands/project/convert/source.js.map +1 -1
- package/lib/commands/project/delete/source.d.ts +1 -15
- package/lib/commands/project/delete/source.js +130 -173
- package/lib/commands/project/delete/source.js.map +1 -1
- package/lib/commands/project/deploy/cancel.d.ts +1 -0
- package/lib/commands/project/deploy/cancel.js +11 -1
- package/lib/commands/project/deploy/cancel.js.map +1 -1
- package/lib/commands/project/generate/manifest.js +1 -0
- package/lib/commands/project/generate/manifest.js.map +1 -1
- package/lib/commands/project/retrieve/start.js +11 -2
- package/lib/commands/project/retrieve/start.js.map +1 -1
- package/lib/formatters/deleteResultFormatter.js +4 -9
- package/lib/formatters/deleteResultFormatter.js.map +1 -1
- package/lib/formatters/deployResultFormatter.d.ts +6 -3
- package/lib/formatters/deployResultFormatter.js +28 -20
- package/lib/formatters/deployResultFormatter.js.map +1 -1
- package/lib/formatters/metadataRetrieveResultFormatter.js +2 -2
- package/lib/formatters/metadataRetrieveResultFormatter.js.map +1 -1
- package/lib/formatters/retrieveResultFormatter.js +7 -3
- package/lib/formatters/retrieveResultFormatter.js.map +1 -1
- package/lib/utils/conflicts.js +4 -3
- package/lib/utils/conflicts.js.map +1 -1
- package/lib/utils/deploy.js +8 -3
- package/lib/utils/deploy.js.map +1 -1
- package/lib/utils/manifestCache.d.ts +2 -2
- package/lib/utils/manifestCache.js +4 -2
- package/lib/utils/manifestCache.js.map +1 -1
- package/lib/utils/metadataTypes.d.ts +7 -0
- package/lib/utils/metadataTypes.js +14 -0
- package/lib/utils/metadataTypes.js.map +1 -0
- package/lib/utils/output.d.ts +5 -4
- package/lib/utils/output.js +16 -15
- package/lib/utils/output.js.map +1 -1
- package/lib/utils/previewOutput.js +7 -7
- package/lib/utils/previewOutput.js.map +1 -1
- package/lib/utils/types.d.ts +1 -0
- package/lib/utils/types.js +1 -0
- package/lib/utils/types.js.map +1 -1
- package/npm-shrinkwrap.json +9924 -14761
- package/oclif.lock +1024 -3192
- package/oclif.manifest.json +436 -426
- package/package.json +15 -16
- package/schemas/project-delete-source.json +8 -8
- package/schemas/project-deploy-cancel.json +8 -8
- package/schemas/project-deploy-quick.json +8 -8
- package/schemas/project-deploy-report.json +8 -8
- package/schemas/project-deploy-resume.json +8 -8
- package/schemas/project-deploy-start.json +8 -8
- package/schemas/project-deploy-validate.json +8 -8
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { dirname, resolve } from 'node:path';
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import { Messages, SfError } from '@salesforce/core';
|
|
10
|
-
import { ComponentSetBuilder, MetadataConverter, } from '@salesforce/source-deploy-retrieve';
|
|
10
|
+
import { ComponentSetBuilder, MetadataConverter, RegistryAccess, } from '@salesforce/source-deploy-retrieve';
|
|
11
11
|
import { arrayWithDeprecation, Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
|
|
12
12
|
import { MetadataConvertResultFormatter } from '../../../formatters/metadataConvertResultFormatter.js';
|
|
13
13
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -90,11 +90,12 @@ export class Mdapi extends SfCommand {
|
|
|
90
90
|
directoryPaths: [this.flags['root-dir']],
|
|
91
91
|
}
|
|
92
92
|
: undefined,
|
|
93
|
+
...(this.project ? { projectDir: this.project?.getPath() } : {}),
|
|
93
94
|
});
|
|
94
95
|
const numOfComponents = this.componentSet.getSourceComponents().toArray().length;
|
|
95
96
|
if (numOfComponents > 0) {
|
|
96
97
|
this.spinner.start(`Converting ${numOfComponents} metadata components`);
|
|
97
|
-
const converter = new MetadataConverter();
|
|
98
|
+
const converter = new MetadataConverter(new RegistryAccess(undefined, this.project?.getPath()));
|
|
98
99
|
this.convertResult = await converter.convert(this.componentSet, 'source', {
|
|
99
100
|
type: 'directory',
|
|
100
101
|
outputDirectory: outputDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdapi.js","sourceRoot":"","sources":["../../../../src/commands/project/convert/mdapi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"mdapi.js","sourceRoot":"","sources":["../../../../src/commands/project/convert/mdapi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,EACjB,cAAc,GACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,KAAK,EACL,QAAQ,EACR,iCAAiC,EACjC,SAAS,GACV,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,8BAA8B,EAAE,MAAM,uDAAuD,CAAC;AAEvG,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,eAAe,CAAC,CAAC;AAQ9F,MAAM,OAAO,KAAM,SAAQ,SAA2B;IAC7C,MAAM,CAAU,OAAO,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAClD,MAAM,CAAU,gBAAg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CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAoB,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { resolve } from 'node:path';
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import { Messages } from '@salesforce/core';
|
|
10
|
-
import { ComponentSetBuilder, MetadataConverter, } from '@salesforce/source-deploy-retrieve';
|
|
10
|
+
import { ComponentSetBuilder, MetadataConverter, RegistryAccess, } from '@salesforce/source-deploy-retrieve';
|
|
11
11
|
import { arrayWithDeprecation, Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
|
|
12
12
|
import { getPackageDirs, getSourceApiVersion } from '../../../utils/project.js';
|
|
13
13
|
import { SourceConvertResultFormatter } from '../../../formatters/sourceConvertResultFormatter.js';
|
|
@@ -105,10 +105,12 @@ export class Source extends SfCommand {
|
|
|
105
105
|
directoryPaths: await getPackageDirs(),
|
|
106
106
|
}
|
|
107
107
|
: undefined,
|
|
108
|
+
projectDir: this.project?.getPath(),
|
|
108
109
|
});
|
|
109
110
|
const packageName = this.flags['package-name'];
|
|
110
111
|
const outputDirectory = resolve(this.flags['output-dir']);
|
|
111
|
-
const
|
|
112
|
+
const registry = new RegistryAccess(undefined, this.project?.getPath());
|
|
113
|
+
const converter = new MetadataConverter(registry);
|
|
112
114
|
this.convertResult = await converter.convert(this.componentSet, 'metadata', {
|
|
113
115
|
type: 'directory',
|
|
114
116
|
outputDirectory,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../../src/commands/project/convert/source.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAA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AAM,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAChF,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/D,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;QACnD,CAAC;IACH,CAAC;IAES,cAAc;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YACpC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAES,KAAK,CAAC,YAAY;QAC1B,MAAM,SAAS,GAAG,IAAI,4BAA4B,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;QACD,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC"}
|
|
@@ -29,17 +29,13 @@ export declare class Source extends SfCommand<DeleteSourceJson> {
|
|
|
29
29
|
};
|
|
30
30
|
protected fileResponses: FileResponse[] | undefined;
|
|
31
31
|
protected tracking: SourceTracking | undefined;
|
|
32
|
-
private aborted;
|
|
33
32
|
private components;
|
|
34
33
|
private mixedDeployDelete;
|
|
35
34
|
private stashPath;
|
|
36
|
-
private tempDir;
|
|
37
35
|
private flags;
|
|
38
36
|
private org;
|
|
39
37
|
private componentSet;
|
|
40
|
-
private isRest;
|
|
41
38
|
private deployResult;
|
|
42
|
-
private deleteResultFormatter;
|
|
43
39
|
run(): Promise<DeleteSourceJson>;
|
|
44
40
|
protected preChecks(): Promise<void>;
|
|
45
41
|
protected delete(): Promise<void>;
|
|
@@ -50,21 +46,11 @@ export declare class Source extends SfCommand<DeleteSourceJson> {
|
|
|
50
46
|
protected formatResult(): Promise<DeleteSourceJson>;
|
|
51
47
|
private maybeUpdateTracking;
|
|
52
48
|
private deleteFilesLocally;
|
|
53
|
-
private
|
|
54
|
-
private restoreFileFromStash;
|
|
55
|
-
private deleteStash;
|
|
56
|
-
private moveBundleToManifest;
|
|
49
|
+
private moveToManifest;
|
|
57
50
|
private handlePrompt;
|
|
58
51
|
/**
|
|
59
52
|
* Check if any conflicts exist in a specific component set.
|
|
60
53
|
* If conflicts exist, this will output the table and throw
|
|
61
54
|
*/
|
|
62
55
|
private filterConflictsByComponentSet;
|
|
63
|
-
/**
|
|
64
|
-
* Write a table (if not json) and throw an error that includes a custom message and the conflict data
|
|
65
|
-
*
|
|
66
|
-
* @param conflicts
|
|
67
|
-
* @param message
|
|
68
|
-
*/
|
|
69
|
-
private processConflicts;
|
|
70
56
|
}
|
|
@@ -9,11 +9,14 @@ import path from 'node:path';
|
|
|
9
9
|
import os from 'node:os';
|
|
10
10
|
import { Lifecycle, Messages, SfError } from '@salesforce/core';
|
|
11
11
|
import { ComponentSet, ComponentSetBuilder, ComponentStatus, DestructiveChangesType, RequestStatus, SourceComponent, } from '@salesforce/source-deploy-retrieve';
|
|
12
|
-
import { Duration } from '@salesforce/kit';
|
|
12
|
+
import { Duration, logFn } from '@salesforce/kit';
|
|
13
13
|
import { deleteCustomLabels, SourceTracking } from '@salesforce/source-tracking';
|
|
14
14
|
import { arrayWithDeprecation, Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
|
|
15
15
|
import chalk from 'chalk';
|
|
16
|
-
import {
|
|
16
|
+
import { writeConflictTable } from '../../../utils/conflicts.js';
|
|
17
|
+
import { isNonDecomposedCustomLabel, isNonDecomposedCustomLabelsOrCustomLabel } from '../../../utils/metadataTypes.js';
|
|
18
|
+
import { getFileResponseSuccessProps } from '../../../utils/output.js';
|
|
19
|
+
import { API, isFileResponseDeleted, isSdrSuccess, isSourceComponent } from '../../../utils/types.js';
|
|
17
20
|
import { getPackageDirs, getSourceApiVersion } from '../../../utils/project.js';
|
|
18
21
|
import { resolveApi, validateTests } from '../../../utils/deploy.js';
|
|
19
22
|
import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js';
|
|
@@ -21,7 +24,6 @@ import { DeleteResultFormatter } from '../../../formatters/deleteResultFormatter
|
|
|
21
24
|
import { DeployProgress } from '../../../utils/progressBar.js';
|
|
22
25
|
import { DeployCache } from '../../../utils/deployCache.js';
|
|
23
26
|
import { testLevelFlag, testsFlag } from '../../../utils/flags.js';
|
|
24
|
-
const fsPromises = fs.promises;
|
|
25
27
|
const testFlags = 'Test';
|
|
26
28
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
27
29
|
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'delete.source');
|
|
@@ -103,20 +105,15 @@ export class Source extends SfCommand {
|
|
|
103
105
|
};
|
|
104
106
|
fileResponses;
|
|
105
107
|
tracking;
|
|
106
|
-
// private deleteResultFormatter: DeleteResultFormatter | DeployResultFormatter;
|
|
107
|
-
aborted = false;
|
|
108
108
|
components;
|
|
109
109
|
// create the delete FileResponse as we're parsing the comp. set to use in the output
|
|
110
110
|
mixedDeployDelete = { delete: [], deploy: [] };
|
|
111
111
|
// map of component in project, to where it is stashed
|
|
112
112
|
stashPath = new Map();
|
|
113
|
-
tempDir = path.join(os.tmpdir(), 'source_delete');
|
|
114
113
|
flags;
|
|
115
114
|
org;
|
|
116
115
|
componentSet;
|
|
117
|
-
isRest;
|
|
118
116
|
deployResult;
|
|
119
|
-
deleteResultFormatter;
|
|
120
117
|
async run() {
|
|
121
118
|
this.flags = (await this.parse(Source)).flags;
|
|
122
119
|
this.org = this.flags['target-org'];
|
|
@@ -151,6 +148,7 @@ export class Source extends SfCommand {
|
|
|
151
148
|
directoryPaths: await getPackageDirs(),
|
|
152
149
|
}
|
|
153
150
|
: undefined,
|
|
151
|
+
projectDir: this.project?.getPath(),
|
|
154
152
|
});
|
|
155
153
|
if (this.flags['track-source'] && !this.flags['force-overwrite']) {
|
|
156
154
|
await this.filterConflictsByComponentSet();
|
|
@@ -179,29 +177,38 @@ export class Source extends SfCommand {
|
|
|
179
177
|
});
|
|
180
178
|
this.componentSet = cs;
|
|
181
179
|
if (sourcepaths) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
:
|
|
180
|
+
await Promise.all([
|
|
181
|
+
// determine if user is trying to delete a single file from a bundle, which is actually just an fs delete operation
|
|
182
|
+
// and then a constructive deploy on the "new" bundle
|
|
183
|
+
...this.components
|
|
184
|
+
.filter((comp) => comp.type.strategies?.adapter === 'bundle')
|
|
185
|
+
.filter(isSourceComponent)
|
|
186
|
+
.flatMap((bundle) => sourcepaths
|
|
187
|
+
.filter(someContentsEndWithPath(bundle))
|
|
188
|
+
.map((sourcepath) => this.moveToManifest(bundle, sourcepath, path.join(bundle.name, path.basename(sourcepath))))),
|
|
189
|
+
// same for decomposed components with non-addressable children (ex: decomposedPermissionSet. Deleting a file means "redploy without that")
|
|
190
|
+
...this.components
|
|
191
|
+
.filter(allChildrenAreNotAddressable)
|
|
192
|
+
.filter(isSourceComponent)
|
|
193
|
+
.flatMap((decomposed) => sourcepaths
|
|
194
|
+
.filter(someContentsEndWithPath(decomposed))
|
|
195
|
+
.map((sourcepath) => this.moveToManifest(decomposed, sourcepath, decomposed.fullName))),
|
|
196
|
+
]);
|
|
192
197
|
}
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
if (!(await this.handlePrompt())) {
|
|
199
|
+
await Promise.all(this.mixedDeployDelete.delete.map(async (file) => {
|
|
200
|
+
await restoreFileFromStash(this.stashPath, file.filePath);
|
|
201
|
+
}));
|
|
195
202
|
throw messages.createError('prompt.delete.cancel');
|
|
196
203
|
}
|
|
197
204
|
// fire predeploy event for the delete
|
|
198
205
|
await Lifecycle.getInstance().emit('predeploy', this.components);
|
|
199
|
-
|
|
200
|
-
this.log(`*** Deleting with ${
|
|
206
|
+
const isRest = (await resolveApi()) === API['REST'];
|
|
207
|
+
this.log(`*** Deleting with ${isRest ? 'REST' : 'SOAP'} API ***`);
|
|
201
208
|
const deploy = await this.componentSet.deploy({
|
|
202
209
|
usernameOrConnection: this.org.getUsername(),
|
|
203
210
|
apiOptions: {
|
|
204
|
-
rest:
|
|
211
|
+
rest: isRest,
|
|
205
212
|
checkOnly: this.flags['check-only'] ?? false,
|
|
206
213
|
...(this.flags.tests ? { runTests: this.flags.tests } : {}),
|
|
207
214
|
...(this.flags['test-level'] ? { testLevel: this.flags['test-level'] } : {}),
|
|
@@ -224,19 +231,16 @@ export class Source extends SfCommand {
|
|
|
224
231
|
* Checks the response status to determine whether the delete was successful.
|
|
225
232
|
*/
|
|
226
233
|
async resolveSuccess() {
|
|
227
|
-
|
|
228
|
-
if (status !== RequestStatus.Succeeded
|
|
234
|
+
// if deploy failed restore the stashed files if they exist
|
|
235
|
+
if (this.deployResult?.response?.status !== RequestStatus.Succeeded) {
|
|
229
236
|
process.exitCode = 1;
|
|
230
|
-
}
|
|
231
|
-
// if deploy failed OR the operation was cancelled, restore the stashed files if they exist
|
|
232
|
-
else if (status !== RequestStatus.Succeeded || this.aborted) {
|
|
233
237
|
await Promise.all(this.mixedDeployDelete.delete.map(async (file) => {
|
|
234
|
-
await this.
|
|
238
|
+
await restoreFileFromStash(this.stashPath, file.filePath);
|
|
235
239
|
}));
|
|
236
240
|
}
|
|
237
241
|
else if (this.mixedDeployDelete.delete.length) {
|
|
238
242
|
// successful delete -> delete the stashed file
|
|
239
|
-
|
|
243
|
+
return deleteStash();
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
246
|
async formatResult() {
|
|
@@ -244,33 +248,23 @@ export class Source extends SfCommand {
|
|
|
244
248
|
verbose: this.flags.verbose ?? false,
|
|
245
249
|
testLevel: this.flags['test-level'],
|
|
246
250
|
};
|
|
247
|
-
|
|
248
|
-
? new DeployResultFormatter(this.deployResult, formatterOptions)
|
|
251
|
+
const deleteResultFormatter = this.mixedDeployDelete.deploy.length
|
|
252
|
+
? new DeployResultFormatter(this.deployResult, formatterOptions, this.mixedDeployDelete.delete)
|
|
249
253
|
: new DeleteResultFormatter(this.deployResult, formatterOptions);
|
|
250
254
|
// Only display results to console when JSON flag is unset.
|
|
251
255
|
if (!this.jsonEnabled()) {
|
|
252
|
-
|
|
256
|
+
deleteResultFormatter.display();
|
|
253
257
|
}
|
|
254
|
-
if (this.mixedDeployDelete.deploy.length
|
|
258
|
+
if (this.mixedDeployDelete.deploy.length) {
|
|
255
259
|
// override JSON output when we actually deployed
|
|
256
|
-
const json = (await
|
|
260
|
+
const json = (await deleteResultFormatter.getJson());
|
|
257
261
|
json.deletedSource = this.mixedDeployDelete.delete; // to match toolbelt json output
|
|
258
262
|
json.outboundFiles = []; // to match toolbelt version
|
|
259
263
|
json.deletes = json.deploys; // to match toolbelt version
|
|
260
264
|
delete json.deploys;
|
|
261
265
|
return json;
|
|
262
266
|
}
|
|
263
|
-
|
|
264
|
-
return {
|
|
265
|
-
status: 0,
|
|
266
|
-
result: {
|
|
267
|
-
deletedSource: [],
|
|
268
|
-
deletes: [{}],
|
|
269
|
-
outboundFiles: [],
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
return (await this.deleteResultFormatter.getJson());
|
|
267
|
+
return (await deleteResultFormatter.getJson());
|
|
274
268
|
}
|
|
275
269
|
async maybeUpdateTracking() {
|
|
276
270
|
if (this.flags['track-source'] ?? false) {
|
|
@@ -279,7 +273,7 @@ export class Source extends SfCommand {
|
|
|
279
273
|
return;
|
|
280
274
|
}
|
|
281
275
|
this.spinner.start('Updating source tracking');
|
|
282
|
-
const successes = (this.fileResponses ?? this.deployResult.getFileResponses()).filter(
|
|
276
|
+
const successes = (this.fileResponses ?? this.deployResult.getFileResponses()).filter(isSdrSuccess);
|
|
283
277
|
if (!successes.length) {
|
|
284
278
|
this.spinner.stop();
|
|
285
279
|
return;
|
|
@@ -290,118 +284,75 @@ export class Source extends SfCommand {
|
|
|
290
284
|
.filter((fileResponse) => fileResponse.state !== ComponentStatus.Deleted)
|
|
291
285
|
.map((fileResponse) => fileResponse.filePath),
|
|
292
286
|
deletedFiles: successes
|
|
293
|
-
.filter(
|
|
287
|
+
.filter(isFileResponseDeleted)
|
|
294
288
|
.map((fileResponse) => fileResponse.filePath),
|
|
295
289
|
}),
|
|
296
|
-
this.tracking?.updateRemoteTracking(successes.map(
|
|
290
|
+
this.tracking?.updateRemoteTracking(successes.map(getFileResponseSuccessProps)),
|
|
297
291
|
]);
|
|
298
292
|
this.spinner.stop();
|
|
299
293
|
}
|
|
300
294
|
}
|
|
301
295
|
async deleteFilesLocally() {
|
|
302
296
|
if (!this.flags['check-only'] && this.deployResult?.response?.status === RequestStatus.Succeeded) {
|
|
303
|
-
const
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const stats = fs.statSync(component.content);
|
|
316
|
-
if (stats.isDirectory()) {
|
|
317
|
-
promises.push(fsPromises.rm(component.content, { recursive: true }));
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
promises.push(fsPromises.unlink(component.content));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (component.xml) {
|
|
324
|
-
if (component.type.id !== 'customlabel') {
|
|
325
|
-
// CustomLabels handled as a special case above
|
|
326
|
-
promises.push(fsPromises.unlink(component.xml));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
await Promise.all(promises);
|
|
297
|
+
const customLabels = this.componentSet.getSourceComponents().toArray().filter(isNonDecomposedCustomLabel);
|
|
298
|
+
const promisesFromLabels = customLabels[0]?.xml ? [deleteCustomLabels(customLabels[0].xml, customLabels)] : [];
|
|
299
|
+
// mixed delete/deploy operations have already been deleted and stashed
|
|
300
|
+
const otherPromises = !this.mixedDeployDelete.delete.length
|
|
301
|
+
? (this.components ?? [])
|
|
302
|
+
.filter(isSourceComponent)
|
|
303
|
+
.flatMap((component) => [
|
|
304
|
+
...(component.content ? [fs.promises.rm(component.content, { recursive: true, force: true })] : []),
|
|
305
|
+
...(component.xml && !isNonDecomposedCustomLabel(component) ? [fs.promises.rm(component.xml)] : []),
|
|
306
|
+
])
|
|
307
|
+
: [];
|
|
308
|
+
await Promise.all([...promisesFromLabels, ...otherPromises]);
|
|
332
309
|
}
|
|
333
310
|
}
|
|
334
|
-
async
|
|
335
|
-
await fsPromises.mkdir(path.dirname(this.stashPath.get(file)), { recursive: true });
|
|
336
|
-
await fsPromises.copyFile(file, this.stashPath.get(file));
|
|
337
|
-
await fsPromises.unlink(file);
|
|
338
|
-
}
|
|
339
|
-
async restoreFileFromStash(file) {
|
|
340
|
-
await fsPromises.rename(this.stashPath.get(file), file);
|
|
341
|
-
}
|
|
342
|
-
async deleteStash() {
|
|
343
|
-
await fsPromises.rm(this.tempDir, { recursive: true, force: true });
|
|
344
|
-
}
|
|
345
|
-
async moveBundleToManifest(bundle, sourcepath) {
|
|
346
|
-
// if one of the passed in sourcepaths is to a bundle component
|
|
347
|
-
const fileName = path.basename(sourcepath);
|
|
348
|
-
const fullName = path.join(bundle.name, fileName);
|
|
311
|
+
async moveToManifest(cmp, sourcepath, fullName) {
|
|
349
312
|
this.mixedDeployDelete.delete.push({
|
|
350
313
|
state: ComponentStatus.Deleted,
|
|
351
314
|
fullName,
|
|
352
|
-
type:
|
|
315
|
+
type: cmp.type.name,
|
|
353
316
|
filePath: sourcepath,
|
|
354
317
|
});
|
|
355
318
|
// stash the file in case we need to restore it due to failed deploy/aborted command
|
|
356
|
-
this.stashPath.set(sourcepath, path.join(
|
|
357
|
-
await this.
|
|
319
|
+
this.stashPath.set(sourcepath, path.join(os.tmpdir(), 'source_delete', fullName));
|
|
320
|
+
await moveFileToStash(this.stashPath, sourcepath);
|
|
358
321
|
// re-walk the directory to avoid picking up the deleted file
|
|
359
|
-
this.mixedDeployDelete.deploy.push(...
|
|
360
|
-
// now
|
|
361
|
-
// set
|
|
362
|
-
this.componentSet.destructiveChangesPost.delete(`${
|
|
363
|
-
|
|
364
|
-
this.componentSet.add(
|
|
322
|
+
this.mixedDeployDelete.deploy.push(...cmp.walkContent());
|
|
323
|
+
// now from destructive changes and add to manifest
|
|
324
|
+
// set NOT marked for delete
|
|
325
|
+
this.componentSet.destructiveChangesPost.delete(`${cmp.type.id}#${cmp.fullName}`);
|
|
326
|
+
cmp.setMarkedForDelete(false);
|
|
327
|
+
this.componentSet.add(cmp);
|
|
365
328
|
}
|
|
366
329
|
async handlePrompt() {
|
|
367
330
|
if (!this.flags['no-prompt']) {
|
|
368
|
-
const remote = []
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.components
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
local
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
message.push(messages.getMessage('remotePrompt', [[...new Set(remote)].join('\n')]));
|
|
394
|
-
}
|
|
395
|
-
if (local.length) {
|
|
396
|
-
if (message.length) {
|
|
397
|
-
// add a whitespace between remote and local
|
|
398
|
-
message.push('\n');
|
|
399
|
-
}
|
|
400
|
-
message.push('\n', messages.getMessage('localPrompt', [[...new Set(local)].join('\n')]));
|
|
401
|
-
}
|
|
402
|
-
message.push(this.flags['check-only'] ?? false
|
|
403
|
-
? messages.getMessage('areYouSureCheckOnly')
|
|
404
|
-
: messages.getMessage('areYouSure'));
|
|
331
|
+
const remote = (this.components ?? [])
|
|
332
|
+
.filter((comp) => !(comp instanceof SourceComponent))
|
|
333
|
+
.map((comp) => `${comp.type.name}:${comp.fullName}`);
|
|
334
|
+
const local = (this.components ?? [])
|
|
335
|
+
.filter(isSourceComponent)
|
|
336
|
+
.filter(sourceComponentIsNotInMixedDeployDelete(this.mixedDeployDelete))
|
|
337
|
+
.map(logFn)
|
|
338
|
+
.flatMap((c) =>
|
|
339
|
+
// for custom labels, print each custom label to be deleted, not the whole file
|
|
340
|
+
isNonDecomposedCustomLabelsOrCustomLabel(c)
|
|
341
|
+
? [`${c.type.name}:${c.fullName}`]
|
|
342
|
+
: [c.xml, ...c.walkContent()] ?? [])
|
|
343
|
+
.concat(this.mixedDeployDelete.delete.map((fr) => `${fr.fullName} (${fr.filePath})`));
|
|
344
|
+
const message = [
|
|
345
|
+
...(this.mixedDeployDelete.deploy.length
|
|
346
|
+
? [messages.getMessage('deployPrompt', [[...new Set(this.mixedDeployDelete.deploy)].join('\n')])]
|
|
347
|
+
: []),
|
|
348
|
+
...(remote.length ? [messages.getMessage('remotePrompt', [[...new Set(remote)].join('\n')])] : []),
|
|
349
|
+
// add a whitespace between remote and local
|
|
350
|
+
...(local.length && (this.mixedDeployDelete.deploy.length || remote.length) ? ['\n'] : []),
|
|
351
|
+
...(local.length ? [messages.getMessage('localPrompt', [[...new Set(local)].join('\n')])] : []),
|
|
352
|
+
this.flags['check-only'] ?? false
|
|
353
|
+
? messages.getMessage('areYouSureCheckOnly')
|
|
354
|
+
: messages.getMessage('areYouSure'),
|
|
355
|
+
];
|
|
405
356
|
return this.confirm({ message: message.join('\n') });
|
|
406
357
|
}
|
|
407
358
|
return true;
|
|
@@ -412,41 +363,47 @@ export class Source extends SfCommand {
|
|
|
412
363
|
*/
|
|
413
364
|
filterConflictsByComponentSet = async () => {
|
|
414
365
|
const filteredConflicts = (await this.tracking?.getConflicts())?.filter((cr) => this.componentSet.has({ fullName: cr.name, type: cr.type })) ?? [];
|
|
415
|
-
|
|
366
|
+
processConflicts(filteredConflicts, messages.getMessage('conflictMsg'));
|
|
416
367
|
return filteredConflicts;
|
|
417
368
|
};
|
|
418
|
-
/**
|
|
419
|
-
* Write a table (if not json) and throw an error that includes a custom message and the conflict data
|
|
420
|
-
*
|
|
421
|
-
* @param conflicts
|
|
422
|
-
* @param message
|
|
423
|
-
*/
|
|
424
|
-
processConflicts = (conflicts, message) => {
|
|
425
|
-
if (conflicts.length === 0) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
this.table(conflicts, {
|
|
429
|
-
state: { header: 'STATE' },
|
|
430
|
-
fullName: { header: 'FULL NAME' },
|
|
431
|
-
type: { header: 'TYPE' },
|
|
432
|
-
filePath: { header: 'FILE PATH' },
|
|
433
|
-
}, { 'no-truncate': true });
|
|
434
|
-
// map do dedupe by name-type-filename
|
|
435
|
-
const conflictMap = new Map();
|
|
436
|
-
conflicts.forEach((c) => {
|
|
437
|
-
c.filenames?.forEach((f) => {
|
|
438
|
-
conflictMap.set(`${c.name}#${c.type}#${f}`, {
|
|
439
|
-
state: 'Conflict',
|
|
440
|
-
fullName: c.name,
|
|
441
|
-
type: c.type,
|
|
442
|
-
filePath: path.resolve(f),
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
const reformattedConflicts = Array.from(conflictMap.values());
|
|
447
|
-
const err = new SfError(message, 'sourceConflictDetected');
|
|
448
|
-
err.setData(reformattedConflicts);
|
|
449
|
-
throw err;
|
|
450
|
-
};
|
|
451
369
|
}
|
|
370
|
+
const moveFileToStash = async (stashPath, file) => {
|
|
371
|
+
await fs.promises.mkdir(path.dirname(stashPath.get(file)), { recursive: true });
|
|
372
|
+
await fs.promises.copyFile(file, stashPath.get(file));
|
|
373
|
+
await fs.promises.unlink(file);
|
|
374
|
+
};
|
|
375
|
+
const restoreFileFromStash = async (stashPath, file) => fs.promises.rename(stashPath.get(file), file);
|
|
376
|
+
const deleteStash = async () => fs.promises.rm(path.join(os.tmpdir(), 'source_delete'), { recursive: true, force: true });
|
|
377
|
+
const someContentsEndWithPath = (cmp) => (sourcePath) =>
|
|
378
|
+
// walkContent returns absolute paths while sourcepath will usually be relative
|
|
379
|
+
cmp.walkContent().some((content) => content.endsWith(sourcePath));
|
|
380
|
+
const allChildrenAreNotAddressable = (comp) => {
|
|
381
|
+
const types = Object.values(comp.type.children?.types ?? {});
|
|
382
|
+
return types.length > 0 && types.every((child) => child.isAddressable === false);
|
|
383
|
+
};
|
|
384
|
+
const sourceComponentIsNotInMixedDeployDelete = (mixedDeployDelete) => (c) => !mixedDeployDelete.delete.some((d) => d.fullName === c.fullName && d.type === c.type.name);
|
|
385
|
+
/**
|
|
386
|
+
* Write a table (if not json) and throw an error that includes a custom message and the conflict data
|
|
387
|
+
*
|
|
388
|
+
* @param conflicts
|
|
389
|
+
* @param message
|
|
390
|
+
*/
|
|
391
|
+
const processConflicts = (conflicts, message) => {
|
|
392
|
+
if (conflicts.length === 0)
|
|
393
|
+
return;
|
|
394
|
+
const reformattedConflicts = Array.from(
|
|
395
|
+
// map do dedupe by name-type-filename
|
|
396
|
+
new Map(conflicts.flatMap(changeResultToConflictResponses).map((c) => [`${c.fullName}#${c.type}#${c.filePath}`, c])).values());
|
|
397
|
+
writeConflictTable(reformattedConflicts);
|
|
398
|
+
const err = new SfError(message, 'sourceConflictDetected');
|
|
399
|
+
err.setData(reformattedConflicts);
|
|
400
|
+
throw err;
|
|
401
|
+
};
|
|
402
|
+
/** each ChangeResult can have multiple filenames, each of which becomes a ConflictResponse */
|
|
403
|
+
const changeResultToConflictResponses = (cr) => (cr.filenames ?? []).map((f) => ({
|
|
404
|
+
state: 'Conflict',
|
|
405
|
+
fullName: cr.name ?? '<Name is missing>',
|
|
406
|
+
type: cr.type ?? '<Type is missing>',
|
|
407
|
+
filePath: path.resolve(f),
|
|
408
|
+
}));
|
|
452
409
|
//# sourceMappingURL=source.js.map
|