Skip to content

Commit a93f120

Browse files
mshanemcjshackell-sfdcmdonnalley
authored
Sm/source tracking (#272)
* feat: supports source tracking for deploy/retrieve * fix: existing mpd nuts ignore tracking conflicts * chore: deps * test: nuts from plugin-source * test(wip): remoteChanges nut fails until plugin-source PO merges (sfdx/sf folder) * feat: ignoreConflicts for validate * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/deploy.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * Update messages/retrieve.metadata.md Co-authored-by: Juliet Shackell <[email protected]> * chore: bump plugins * chore: bump lint rules and sdr (for events) * refactor: linter fixes * test: lwc nut and pjson script * test: factor out ebikes deploy count * fix: no tracking on validate/quick * refactor: pr feedback * chore: re-remove moved message * chore: dep bump * chore: bump STL * chore: bump source-testkit * chore: bump deps * test: expect sfError * test: nut seeds only deploy dreamhouse permset if it's dreamhouse Co-authored-by: Juliet Shackell <[email protected]> Co-authored-by: Mike Donnalley <[email protected]>
1 parent 66d5e8d commit a93f120

33 files changed

+1901
-723
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
module.exports = {
8-
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license'],
8+
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/recommended'],
99
};

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
},
1313
"editor.tabSize": 2,
1414
"editor.formatOnSave": true,
15-
"rewrap.wrappingColumn": 80
15+
"rewrap.wrappingColumn": 80,
16+
"typescript.tsdk": "node_modules/typescript/lib"
1617
}

command-snapshot.json

Lines changed: 93 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,94 @@
11
[
2-
{
3-
"command": "deploy",
4-
"plugin": "@salesforce/plugin-deploy-retrieve",
5-
"flags": [
6-
"interactive"
7-
],
8-
"alias": []
9-
},
10-
{
11-
"command": "deploy:metadata",
12-
"plugin": "@salesforce/plugin-deploy-retrieve",
13-
"flags": [
14-
"api-version",
15-
"async",
16-
"concise",
17-
"dry-run",
18-
"ignore-errors",
19-
"ignore-warnings",
20-
"json",
21-
"manifest",
22-
"metadata",
23-
"metadata-dir",
24-
"single-package",
25-
"source-dir",
26-
"target-org",
27-
"test-level",
28-
"tests",
29-
"verbose",
30-
"wait"
31-
],
32-
"alias": []
33-
},
34-
{
35-
"command": "deploy:metadata:cancel",
36-
"plugin": "@salesforce/plugin-deploy-retrieve",
37-
"flags": [
38-
"async",
39-
"job-id",
40-
"json",
41-
"use-most-recent",
42-
"wait"
43-
],
44-
"alias": []
45-
},
46-
{
47-
"command": "deploy:metadata:quick",
48-
"plugin": "@salesforce/plugin-deploy-retrieve",
49-
"flags": [
50-
"async",
51-
"concise",
52-
"job-id",
53-
"json",
54-
"target-org",
55-
"use-most-recent",
56-
"verbose",
57-
"wait"
58-
],
59-
"alias": []
60-
},
61-
{
62-
"command": "deploy:metadata:report",
63-
"plugin": "@salesforce/plugin-deploy-retrieve",
64-
"flags": [
65-
"job-id",
66-
"json",
67-
"use-most-recent"
68-
],
69-
"alias": []
70-
},
71-
{
72-
"command": "deploy:metadata:resume",
73-
"plugin": "@salesforce/plugin-deploy-retrieve",
74-
"flags": [
75-
"concise",
76-
"job-id",
77-
"json",
78-
"use-most-recent",
79-
"verbose",
80-
"wait"
81-
],
82-
"alias": []
83-
},
84-
{
85-
"command": "deploy:metadata:validate",
86-
"plugin": "@salesforce/plugin-deploy-retrieve",
87-
"flags": [
88-
"api-version",
89-
"async",
90-
"concise",
91-
"json",
92-
"manifest",
93-
"metadata",
94-
"metadata-dir",
95-
"single-package",
96-
"source-dir",
97-
"target-org",
98-
"test-level",
99-
"tests",
100-
"verbose",
101-
"wait"
102-
],
103-
"alias": []
104-
},
105-
{
106-
"command": "retrieve:metadata",
107-
"plugin": "@salesforce/plugin-deploy-retrieve",
108-
"flags": [
109-
"api-version",
110-
"json",
111-
"manifest",
112-
"metadata",
113-
"package-name",
114-
"source-dir",
115-
"target-org",
116-
"wait"
117-
],
118-
"alias": []
119-
}
120-
]
2+
{
3+
"command": "deploy",
4+
"plugin": "@salesforce/plugin-deploy-retrieve",
5+
"flags": ["interactive"],
6+
"alias": []
7+
},
8+
{
9+
"command": "deploy:metadata",
10+
"plugin": "@salesforce/plugin-deploy-retrieve",
11+
"flags": [
12+
"api-version",
13+
"async",
14+
"concise",
15+
"dry-run",
16+
"ignore-conflicts",
17+
"ignore-errors",
18+
"ignore-warnings",
19+
"json",
20+
"manifest",
21+
"metadata",
22+
"metadata-dir",
23+
"single-package",
24+
"source-dir",
25+
"target-org",
26+
"test-level",
27+
"tests",
28+
"verbose",
29+
"wait"
30+
],
31+
"alias": []
32+
},
33+
{
34+
"command": "deploy:metadata:cancel",
35+
"plugin": "@salesforce/plugin-deploy-retrieve",
36+
"flags": ["async", "job-id", "json", "use-most-recent", "wait"],
37+
"alias": []
38+
},
39+
{
40+
"command": "deploy:metadata:quick",
41+
"plugin": "@salesforce/plugin-deploy-retrieve",
42+
"flags": ["async", "concise", "job-id", "json", "target-org", "use-most-recent", "verbose", "wait"],
43+
"alias": []
44+
},
45+
{
46+
"command": "deploy:metadata:report",
47+
"plugin": "@salesforce/plugin-deploy-retrieve",
48+
"flags": ["job-id", "json", "use-most-recent"],
49+
"alias": []
50+
},
51+
{
52+
"command": "deploy:metadata:resume",
53+
"plugin": "@salesforce/plugin-deploy-retrieve",
54+
"flags": ["concise", "job-id", "json", "use-most-recent", "verbose", "wait"],
55+
"alias": []
56+
},
57+
{
58+
"command": "deploy:metadata:validate",
59+
"plugin": "@salesforce/plugin-deploy-retrieve",
60+
"flags": [
61+
"api-version",
62+
"async",
63+
"concise",
64+
"json",
65+
"manifest",
66+
"metadata",
67+
"metadata-dir",
68+
"single-package",
69+
"source-dir",
70+
"target-org",
71+
"test-level",
72+
"tests",
73+
"verbose",
74+
"wait"
75+
],
76+
"alias": []
77+
},
78+
{
79+
"command": "retrieve:metadata",
80+
"plugin": "@salesforce/plugin-deploy-retrieve",
81+
"flags": [
82+
"api-version",
83+
"ignore-conflicts",
84+
"json",
85+
"manifest",
86+
"metadata",
87+
"package-name",
88+
"source-dir",
89+
"target-org",
90+
"wait"
91+
],
92+
"alias": []
93+
}
94+
]

messages/deploy.metadata.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ Deploy metadata in source format to an org from your local project.
66

77
You must run this command from within a project.
88

9-
This command doesn't support source-tracking. The source you deploy overwrites the corresponding metadata in your org. This command doesn’t attempt to merge your source with the versions in your org.
9+
If your org allows source tracking, then this command tracks the changes in your source. Some orgs, such as production org, never allow source tracking. You can also use the "--no-track-source" flag when you create a scratch or sandbox org to disable source tracking.
1010

1111
To deploy multiple metadata components, either set multiple --metadata <name> flags or a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --manifest and --source-dir.
1212

1313
# examples
1414

15+
- Deploy local changes not in the org:
16+
17+
<%= config.bin %> <%= command.id %>
18+
1519
- Deploy the source files in a directory:
1620

1721
<%= config.bin %> <%= command.id %> --source-dir path/to/source
@@ -106,6 +110,14 @@ All child components are included. If you specify this flag, don’t specify --m
106110

107111
Validate deploy and run Apex tests but don’t save to the org.
108112

113+
# flags.ignore-conflicts.summary
114+
115+
Ignore conflicts and deploy local files, even if they overwrite changes in the org.
116+
117+
# flags.ignore-conflicts.description
118+
119+
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.
120+
109121
# flags.ignore-errors.summary
110122

111123
Ignore any errors and don’t roll back deployment.
@@ -182,3 +194,13 @@ You must specify tests using the --tests flag if the --test-level flag is set to
182194
# error.ClientTimeout
183195

184196
The client has timed out. Use sf deploy metadata resume to resume watching this deploy.
197+
198+
# error.Conflicts
199+
200+
There are changes in the org that conflict with the local changes you're trying to deploy.
201+
202+
# error.Conflicts.Actions
203+
204+
- To overwrite the remote changes, rerun this command with the --ignore-conflicts flag.
205+
206+
- To overwrite the local changes, run the "sf retrieve metadata" command with the --ignore-conflicts flag.

messages/retrieve.metadata.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ Retrieve metadata in source format from an org to your local project.
66

77
You must run this command from within a project.
88

9-
This command doesn't support source-tracking. The source you retrieve overwrites the corresponding source files in your local project. This command doesn’t attempt to merge the source from your org with your local source files.
9+
If your org allows source tracking, then this command tracks the changes in your source. Some orgs, such as production org, never allow source tracking. You can also use the "--no-track-source" flag when you create a scratch or sandbox org to disable source tracking.
1010

1111
To retrieve multiple metadata components, either use multiple --metadata <name> flags or use a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --manifest and --source-dir.
1212

1313
# examples
1414

15+
- Retrieve remote changes:
16+
17+
<%= config.bin %> <%= command.id %>
18+
1519
- Retrieve the source files in a directory:
1620

1721
<%= config.bin %> <%= command.id %> --source-dir path/to/source
@@ -55,6 +59,14 @@ Target API version for the retrieve.
5559

5660
Use this flag to override the default API version, which is the latest version supported the CLI, with the API version in your package.xml file.
5761

62+
# flags.ignore-conflicts.summary
63+
64+
Ignore conflicts and retrieve and save files to your local filesystem, even if they overwrite your local changes.
65+
66+
# flags.ignore-conflicts.description
67+
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.
69+
5870
# flags.manifest.summary
5971

6072
File path for the manifest (package.xml) that specifies the components to retrieve.
@@ -106,3 +118,13 @@ Sending request to org (metadata API version %s)
106118
# spinner.polling
107119

108120
Waiting for the org to respond
121+
122+
# error.Conflicts
123+
124+
There are changes in your local files that conflict with the org changes you're trying to retrieve.
125+
126+
# error.Conflicts.Actions
127+
128+
- To overwrite the local changes, rerun this command with the --ignore-conflicts flag.
129+
130+
- To overwrite the remote changes, run the "sf deploy metadata" command with the --ignore-conflicts flag.

messages/tracking.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# error.noChanges
2+
3+
No local changes to deploy.

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,49 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^1.7.0",
9-
"@salesforce/core": "^3.19.4",
8+
"@oclif/core": "^1.9.0",
9+
"@salesforce/core": "^3.22.1",
1010
"@salesforce/kit": "^1.5.41",
11-
"@salesforce/sf-plugins-core": "^1.12.3",
12-
"@salesforce/source-deploy-retrieve": "^5.13.1",
11+
"@salesforce/sf-plugins-core": "^1.13.0",
12+
"@salesforce/source-deploy-retrieve": "^6.1.0",
13+
"@salesforce/source-tracking": "^2.2.0",
1314
"chalk": "^4.1.2",
1415
"fs-extra": "^10.0.1",
1516
"shelljs": "^0.8.5",
1617
"tslib": "^2"
1718
},
1819
"devDependencies": {
1920
"@oclif/plugin-command-snapshot": "^3.1.3",
20-
"@salesforce/cli-plugins-testkit": "^1.5.20",
21+
"@salesforce/cli-plugins-testkit": "^2.3.0",
2122
"@salesforce/dev-config": "^3.0.1",
2223
"@salesforce/dev-scripts": "^2.0.1",
2324
"@salesforce/plugin-command-reference": "^2.2.8",
2425
"@salesforce/plugin-config": "^2.3.0",
2526
"@salesforce/plugin-functions": "^1.7.0",
26-
"@salesforce/plugin-source": "^1.8.18",
27-
"@salesforce/plugin-user": "^1.7.1",
27+
"@salesforce/plugin-source": "^2.0.3",
28+
"@salesforce/plugin-user": "^2.0.2",
2829
"@salesforce/prettier-config": "^0.0.2",
29-
"@salesforce/source-testkit": "^0.0.18",
30+
"@salesforce/source-testkit": "^1.2.0",
3031
"@salesforce/ts-sinon": "1.3.21",
3132
"@types/archiver": "^5.3.1",
3233
"@types/fs-extra": "^9.0.13",
3334
"@types/shelljs": "^0.8.11",
34-
"@typescript-eslint/eslint-plugin": "^4.33.0",
35-
"@typescript-eslint/parser": "^4.33.0",
35+
"@typescript-eslint/eslint-plugin": "^5.27.1",
36+
"@typescript-eslint/parser": "^5.27.1",
3637
"archiver": "^5.3.1",
3738
"chai": "^4.3.6",
3839
"cross-env": "^7.0.3",
3940
"cz-conventional-changelog": "^3.3.0",
40-
"eslint": "^7.32.0",
41+
"eslint": "^8.17.0",
4142
"eslint-config-prettier": "^6.15.0",
42-
"eslint-config-salesforce": "^0.1.6",
43+
"eslint-config-salesforce": "^1.0.1",
4344
"eslint-config-salesforce-license": "^0.1.6",
44-
"eslint-config-salesforce-typescript": "^0.2.8",
45+
"eslint-config-salesforce-typescript": "^1.0.0",
4546
"eslint-plugin-header": "^3.1.1",
46-
"eslint-plugin-import": "2.25.4",
47+
"eslint-plugin-import": "^2.26.0",
4748
"eslint-plugin-jsdoc": "^35.5.1",
4849
"eslint-plugin-prettier": "^3.4.1",
50+
"eslint-plugin-sf-plugin": "^0.2.0",
4951
"husky": "^7.0.4",
5052
"lint-staged": "^11.2.6",
5153
"mocha": "^9.1.3",
@@ -139,6 +141,7 @@
139141
"test:deprecation-policy": "./bin/dev snapshot:compare",
140142
"test:json-schema": "./bin/dev schema:compare",
141143
"test:nuts": "ts-node ./test/nuts/generateNuts.ts && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
144+
"test:nuts:tracking": "nyc mocha \"test/nuts/tracking/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
142145
"test:nuts:deploy:metadata:manifest": "cross-env PLUGIN_DEPLOY_RETRIEVE_SEED_FILTER=deploy.metadata.manifest ts-node ./test/nuts/generateNuts.ts && mocha \"test/nuts/generated/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
143146
"test:nuts:deploy:metadata:metadata-dir": "cross-env PLUGIN_DEPLOY_RETRIEVE_SEED_FILTER=deploy.metadata.metadata-dir ts-node ./test/nuts/generateNuts.ts && mocha \"test/nuts/generated/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",
144147
"test:nuts:deploy:metadata:metadata": "cross-env PLUGIN_DEPLOY_RETRIEVE_SEED_FILTER=deploy.metadata.metadata ts-node ./test/nuts/generateNuts.ts && mocha \"test/nuts/generated/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --retries 0",

0 commit comments

Comments
 (0)