Skip to content

Commit 380c978

Browse files
authored
feat: support retrieves in metadata format (#313)
merged without successful nuts due to forcedotcom/cli#1690
1 parent e1583d1 commit 380c978

File tree

16 files changed

+903
-339
lines changed

16 files changed

+903
-339
lines changed

command-snapshot.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@
9191
"manifest",
9292
"metadata",
9393
"package-name",
94+
"single-package",
9495
"source-dir",
96+
"target-metadata-dir",
9597
"target-org",
96-
"wait"
98+
"unzip",
99+
"wait",
100+
"zip-file-name"
97101
],
98102
"alias": []
99103
},

messages/retrieve.metadata.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ To retrieve multiple metadata components, either use multiple --metadata <name>
5151
<%= config.bin %> <%= command.id %> --package-name Package1 "PackageName With Spaces" Package3
5252
<%= config.bin %> <%= command.id %> --package-name Package1 --package-name "PackageName With Spaces" --package-name Package3
5353

54+
- Retrieve using Metadata API
55+
56+
<%= config.bin %> <%= command.id %> --source-dir force-app --target-metadata-dir output
57+
58+
- Retrieve using Metadata API and automatically unzip the contents
59+
60+
<%= config.bin %> <%= command.id %> --source-dir force-app --target-metadata-dir output --unzip
61+
5462
# flags.api-version.summary
5563

5664
Target API version for the retrieve.
@@ -65,7 +73,7 @@ Ignore conflicts and retrieve and save files to your local filesystem, even if t
6573

6674
# flags.ignore-conflicts.description
6775

68-
This flag applies only to orgs that allow source tracking. It has no effect on orgs that don't allow it, such as production orgs.
76+
This flag applies only to orgs that allow source tracking. It has no effect on orgs that don't allow it, such as production orgs.
6977

7078
# flags.manifest.summary
7179

@@ -107,6 +115,26 @@ Number of minutes to wait for the command to complete and display results to the
107115

108116
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
109117

118+
# flags.metadata-dir.summary
119+
120+
Root of directory or zip file of metadata formatted files to retrieve.
121+
122+
# flags.single-package.summary
123+
124+
Indicates that the zip file points to a directory structure for a single package.
125+
126+
# flags.target-metadata-dir.summary
127+
128+
Directory root for the retrieved files.
129+
130+
# flags.unzip.summary
131+
132+
Extract all files from the retrieved zip file.
133+
134+
# flags.zip-file-name.summary
135+
136+
File name to use for the retrieved zip file.
137+
110138
# spinner.start
111139

112140
Preparing retrieve request
@@ -128,3 +156,11 @@ There are changes in your local files that conflict with the org changes you're
128156
- To overwrite the local changes, rerun this command with the --ignore-conflicts flag.
129157

130158
- To overwrite the remote changes, run the "sf deploy metadata" command with the --ignore-conflicts flag.
159+
160+
# info.WroteZipFile
161+
162+
Wrote retrieve zip file to %s.
163+
164+
# info.ExtractedZipFile
165+
166+
Extracted %s to %s.

messages/validation.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# error.InvalidFlagPath
2+
3+
Invalid path specified: %s. %s
4+
5+
# error.ExpectedDirectory
6+
7+
Expected a directory but found a file.
8+
9+
# error.ExpectedFileOrDirToExist
10+
11+
Expected a file or directory to exist.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^1.15.0",
8+
"@oclif/core": "^1.16.0",
99
"@salesforce/core": "^3.26.1",
1010
"@salesforce/kit": "^1.5.45",
1111
"@salesforce/sf-plugins-core": "1.14.0",
@@ -33,8 +33,8 @@
3333
"@types/archiver": "^5.3.1",
3434
"@types/fs-extra": "^9.0.13",
3535
"@types/shelljs": "^0.8.11",
36-
"@typescript-eslint/eslint-plugin": "^5.32.0",
37-
"@typescript-eslint/parser": "^5.32.0",
36+
"@typescript-eslint/eslint-plugin": "^5.36.2",
37+
"@typescript-eslint/parser": "^5.36.2",
3838
"archiver": "^5.3.1",
3939
"chai": "^4.3.6",
4040
"cross-env": "^7.0.3",

schemas/retrieve-metadata.json

Lines changed: 121 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,73 @@
33
"$ref": "#/definitions/RetrieveResultJson",
44
"definitions": {
55
"RetrieveResultJson": {
6-
"type": "object",
7-
"additionalProperties": false,
8-
"properties": {
9-
"files": {
10-
"type": "array",
11-
"items": {
12-
"$ref": "#/definitions/FileResponse"
13-
}
14-
},
15-
"done": {
16-
"type": "boolean"
17-
},
18-
"fileProperties": {
19-
"anyOf": [
20-
{
21-
"$ref": "#/definitions/FileProperties"
22-
},
23-
{
24-
"type": "array",
25-
"items": {
26-
"$ref": "#/definitions/FileProperties"
27-
}
28-
}
29-
]
30-
},
31-
"id": {
32-
"type": "string"
33-
},
34-
"status": {
35-
"$ref": "#/definitions/RequestStatus"
36-
},
37-
"success": {
38-
"type": "boolean"
39-
},
40-
"messages": {
41-
"anyOf": [
42-
{
6+
"anyOf": [
7+
{
8+
"type": "object",
9+
"additionalProperties": false,
10+
"properties": {
11+
"files": {
4312
"type": "array",
4413
"items": {
45-
"$ref": "#/definitions/RetrieveMessage"
14+
"$ref": "#/definitions/FileResponse"
4615
}
4716
},
48-
{
49-
"$ref": "#/definitions/RetrieveMessage"
17+
"done": {
18+
"type": "boolean"
19+
},
20+
"fileProperties": {
21+
"anyOf": [
22+
{
23+
"$ref": "#/definitions/FileProperties"
24+
},
25+
{
26+
"type": "array",
27+
"items": {
28+
"$ref": "#/definitions/FileProperties"
29+
}
30+
}
31+
]
32+
},
33+
"id": {
34+
"type": "string"
35+
},
36+
"status": {
37+
"$ref": "#/definitions/RequestStatus"
38+
},
39+
"success": {
40+
"type": "boolean"
41+
},
42+
"messages": {
43+
"anyOf": [
44+
{
45+
"type": "array",
46+
"items": {
47+
"$ref": "#/definitions/RetrieveMessage"
48+
}
49+
},
50+
{
51+
"$ref": "#/definitions/RetrieveMessage"
52+
}
53+
]
54+
},
55+
"zipFile": {
56+
"type": "string",
57+
"description": "`base64` encoded string"
5058
}
59+
},
60+
"required": [
61+
"done",
62+
"fileProperties",
63+
"files",
64+
"id",
65+
"status",
66+
"success",
67+
"zipFile"
5168
]
5269
},
53-
"zipFile": {
54-
"type": "string",
55-
"description": "`base64` encoded string"
70+
{
71+
"$ref": "#/definitions/MetadataRetrieveResultJson"
5672
}
57-
},
58-
"required": [
59-
"done",
60-
"fileProperties",
61-
"files",
62-
"id",
63-
"status",
64-
"success",
65-
"zipFile"
6673
]
6774
},
6875
"FileResponse": {
@@ -231,6 +238,68 @@
231238
"problem"
232239
],
233240
"additionalProperties": false
241+
},
242+
"MetadataRetrieveResultJson": {
243+
"type": "object",
244+
"additionalProperties": false,
245+
"properties": {
246+
"zipFilePath": {
247+
"type": "string"
248+
},
249+
"files": {
250+
"type": "array",
251+
"items": {
252+
"$ref": "#/definitions/FileResponse"
253+
}
254+
},
255+
"done": {
256+
"type": "boolean"
257+
},
258+
"fileProperties": {
259+
"anyOf": [
260+
{
261+
"$ref": "#/definitions/FileProperties"
262+
},
263+
{
264+
"type": "array",
265+
"items": {
266+
"$ref": "#/definitions/FileProperties"
267+
}
268+
}
269+
]
270+
},
271+
"id": {
272+
"type": "string"
273+
},
274+
"status": {
275+
"$ref": "#/definitions/RequestStatus"
276+
},
277+
"success": {
278+
"type": "boolean"
279+
},
280+
"messages": {
281+
"anyOf": [
282+
{
283+
"type": "array",
284+
"items": {
285+
"$ref": "#/definitions/RetrieveMessage"
286+
}
287+
},
288+
{
289+
"$ref": "#/definitions/RetrieveMessage"
290+
}
291+
]
292+
}
293+
},
294+
"required": [
295+
"done",
296+
"fileProperties",
297+
"files",
298+
"id",
299+
"status",
300+
"success",
301+
"zipFilePath"
302+
]
234303
}
235304
}
236305
}

src/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export default class Deploy extends SfCommand<void> {
2525
public static summary = messages.getMessage('summary');
2626
public static description = messages.getMessage('description');
2727
public static examples = messages.getMessages('examples');
28+
public static enableJsonFlag = false;
2829

2930
public static flags = {
3031
interactive: Flags.boolean({
3132
summary: messages.getMessage('flags.interactive.summary'),
3233
}),
3334
};
34-
public static enableJsonFlag = false;
3535

3636
public async run(): Promise<void> {
3737
process.setMaxListeners(new Env().getNumber('SF_MAX_EVENT_LISTENERS') || 1000);

src/commands/deploy/metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Messages.importMessagesDirectory(__dirname);
2121
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');
2222

2323
const exclusiveFlags = ['manifest', 'source-dir', 'metadata', 'metadata-dir'];
24+
2425
export default class DeployMetadata extends SfCommand<DeployResultJson> {
2526
public static readonly description = messages.getMessage('description');
2627
public static readonly summary = messages.getMessage('summary');

0 commit comments

Comments
 (0)