Skip to content

Commit 879de4d

Browse files
committed
Cleanup temporary files after command is run
1 parent 77952f2 commit 879de4d

File tree

5 files changed

+117
-13
lines changed

5 files changed

+117
-13
lines changed

messages/org.json

-6
This file was deleted.

messages/retrieve.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"commandDescription": "print a greeting and your org IDs",
2+
"commandDescription": "Download a changeset to the project",
33
"changesetnameFlagDescription": "name of changeset to retrieve",
4-
"modeFlagDescription": "source or convert",
5-
"errorNoOrgResults": "No results found for the org '%s'."
4+
"modeFlagDescription": "source re-retrieves the package with source:retrieve, mdapi converts the package with mdapi:convert"
65
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@salesforce/command": "^1.4.1",
1212
"@salesforce/core": "^1.3.2",
1313
"adm-zip": "^0.4.13",
14+
"del": "^4.1.0",
1415
"jsforce": "^1.9.1",
1516
"tslib": "^1"
1617
},

src/commands/changeset/retrieve.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { flags, SfdxCommand } from '@salesforce/command';
22
import { Messages, SfdxError } from '@salesforce/core';
33
import { AnyJson } from '@salesforce/ts-types';
44
import * as AdmZip from 'adm-zip';
5+
import * as del from 'del';
56
import { runCommand } from '../../lib/sfdx';
67

78
// Initialize Messages with the current plugin directory
@@ -24,7 +25,7 @@ export default class Retrieve extends SfdxCommand {
2425
protected static flagsConfig = {
2526
// flag with a value (-n, --name=VALUE)
2627
changesetname: flags.string({char: 'c', required: true, description: messages.getMessage('changesetnameFlagDescription')}),
27-
mode: flags.string({char: 'm', description: messages.getMessage('modeFlagDescription')})
28+
mode: flags.enum({char: 'm', options: ['source', 'mdapi'], default: 'mdapi', description: messages.getMessage('modeFlagDescription')})
2829
};
2930

3031
// Comment this out if your command does not require an org username
@@ -55,7 +56,8 @@ export default class Retrieve extends SfdxCommand {
5556
await runCommand(`sfdx force:source:retrieve -u ${username} -x changesets/${changesetname}/package.xml`);
5657
this.ux.stopSpinner('Done!');
5758
}
58-
else {
59+
60+
if (mode == 'mdapi') {
5961
this.ux.startSpinner('Extracting Package');
6062
let zip = new AdmZip(pkgBuf);
6163
await zip.extractAllTo(`changesets`, true);
@@ -66,7 +68,10 @@ export default class Retrieve extends SfdxCommand {
6668
this.ux.stopSpinner('Done!');
6769
}
6870

69-
// Return an object to be displayed with --json
71+
this.ux.startSpinner('Cleaning up temporary files');
72+
del.sync(['changesets']);
73+
this.ux.stopSpinner('Done!');
74+
7075
return;
7176
}
7277

yarn.lock

+106-1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@
334334
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.0.11.tgz#6f28f005a36e779b7db0f1359b9fb9eef72aae88"
335335
integrity sha512-6ee09Ugx6GyEr0opUIakmxIWFNmqYPjkqa3/BuxCBokA0klsOLPgMD5K4q40lH7/yZVuJVzOfQpd7pipwjngkQ==
336336

337+
adm-zip@^0.4.13:
338+
version "0.4.13"
339+
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.13.tgz#597e2f8cc3672151e1307d3e95cddbc75672314a"
340+
integrity sha512-fERNJX8sOXfel6qCBCMPvZLzENBEhZTzKqg6vrOW5pvoEaQuJhRU4ndTAh6lHOxn1I6jnz2NHra56ZODM751uw==
341+
337342
ajv@^6.5.5:
338343
version "6.10.0"
339344
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1"
@@ -508,6 +513,11 @@ balanced-match@^1.0.0:
508513
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
509514
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
510515

516+
base64-url@^2.2.0:
517+
version "2.2.1"
518+
resolved "https://registry.yarnpkg.com/base64-url/-/base64-url-2.2.1.tgz#55dc1519cf28e70b7613bb6201c890b7612ad1e6"
519+
integrity sha512-RWaW1M7+pLUikK1bnGyiDe1oY2BKOtbS30Ua1pSAH41st59qDxi/XiggjVhHVPIejXY1eqJ21W3uxHtZpM6KQw==
520+
511521
base@^0.11.1:
512522
version "0.11.2"
513523
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
@@ -999,6 +1009,18 @@ define-property@^2.0.2:
9991009
is-descriptor "^1.0.2"
10001010
isobject "^3.0.1"
10011011

1012+
del@^4.1.0:
1013+
version "4.1.0"
1014+
resolved "https://registry.yarnpkg.com/del/-/del-4.1.0.tgz#049543b8290e1a9293e2bd150ab3a06f637322b8"
1015+
integrity sha512-C4kvKNlYrwXhKxz97BuohF8YoGgQ23Xm9lvoHmgT7JaPGprSEjk3+XFled74Yt/x0ZABUHg2D67covzAPUKx5Q==
1016+
dependencies:
1017+
globby "^6.1.0"
1018+
is-path-cwd "^2.0.0"
1019+
is-path-in-cwd "^2.0.0"
1020+
p-map "^2.0.0"
1021+
pify "^4.0.1"
1022+
rimraf "^2.6.3"
1023+
10021024
delayed-stream@~1.0.0:
10031025
version "1.0.0"
10041026
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
@@ -1410,7 +1432,7 @@ glob@^6.0.1:
14101432
once "^1.3.0"
14111433
path-is-absolute "^1.0.0"
14121434

1413-
glob@^7.1.1, glob@^7.1.2, glob@^7.1.3:
1435+
glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3:
14141436
version "7.1.3"
14151437
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
14161438
integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==
@@ -1427,6 +1449,17 @@ globals@^11.1.0:
14271449
resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e"
14281450
integrity sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==
14291451

1452+
globby@^6.1.0:
1453+
version "6.1.0"
1454+
resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
1455+
integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=
1456+
dependencies:
1457+
array-union "^1.0.1"
1458+
glob "^7.0.3"
1459+
object-assign "^4.0.1"
1460+
pify "^2.0.0"
1461+
pinkie-promise "^2.0.0"
1462+
14301463
globby@^8, globby@^8.0.1:
14311464
version "8.0.2"
14321465
resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.2.tgz#5697619ccd95c5275dbb2d6faa42087c1a941d8d"
@@ -1713,6 +1746,25 @@ is-number@^3.0.0:
17131746
dependencies:
17141747
kind-of "^3.0.2"
17151748

1749+
is-path-cwd@^2.0.0:
1750+
version "2.0.0"
1751+
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.0.0.tgz#d4777a8e227a00096a31f030db3770f84b116c02"
1752+
integrity sha512-m5dHHzpOXEiv18JEORttBO64UgTEypx99vCxQLjbBvGhOJxnTNglYoFXxwo6AbsQb79sqqycQEHv2hWkHZAijA==
1753+
1754+
is-path-in-cwd@^2.0.0:
1755+
version "2.0.0"
1756+
resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-2.0.0.tgz#68e452a6eec260500cec21e029c0a44cc0dcd2ea"
1757+
integrity sha512-6Vz5Gc9s/sDA3JBVu0FzWufm8xaBsqy1zn8Q6gmvGP6nSDMw78aS4poBNeatWjaRpTpxxLn1WOndAiOlk+qY8A==
1758+
dependencies:
1759+
is-path-inside "^1.0.0"
1760+
1761+
is-path-inside@^1.0.0:
1762+
version "1.0.1"
1763+
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
1764+
integrity sha1-jvW33lBDej/cprToZe96pVy0gDY=
1765+
dependencies:
1766+
path-is-inside "^1.0.1"
1767+
17161768
is-plain-obj@^1.0.0:
17171769
version "1.1.0"
17181770
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
@@ -1887,6 +1939,27 @@ jsforce@1.8.5:
18871939
request "^2.72.0"
18881940
xml2js "^0.4.16"
18891941

1942+
jsforce@^1.9.1:
1943+
version "1.9.1"
1944+
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-1.9.1.tgz#a112fb0b9ece04fe14d2e14bc72a76e46ff544de"
1945+
integrity sha512-AP4wVnz8guvF8zvHdk2xA2DZxvOq3MGbLNPu7tPVOyO38D1qt+psWpYmHgncjkmy9LoSk58K+dU56YE38zqMlg==
1946+
dependencies:
1947+
base64-url "^2.2.0"
1948+
co-prompt "^1.0.0"
1949+
coffeescript "^1.10.0"
1950+
commander "^2.9.0"
1951+
csv-parse "^1.1.1"
1952+
csv-stringify "^1.0.4"
1953+
faye "^1.2.0"
1954+
inherits "^2.0.1"
1955+
lodash "^4.11.1"
1956+
multistream "^2.0.5"
1957+
opn "^5.3.0"
1958+
promise "^7.1.1"
1959+
readable-stream "^2.1.0"
1960+
request "^2.72.0"
1961+
xml2js "^0.4.16"
1962+
18901963
json-parse-better-errors@^1.0.1:
18911964
version "1.0.2"
18921965
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
@@ -2409,6 +2482,11 @@ oauth-sign@~0.9.0:
24092482
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455"
24102483
integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==
24112484

2485+
object-assign@^4.0.1:
2486+
version "4.1.1"
2487+
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
2488+
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
2489+
24122490
object-copy@^0.1.0:
24132491
version "0.1.0"
24142492
resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c"
@@ -2516,6 +2594,11 @@ p-locate@^3.0.0:
25162594
dependencies:
25172595
p-limit "^2.0.0"
25182596

2597+
p-map@^2.0.0:
2598+
version "2.0.0"
2599+
resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.0.0.tgz#be18c5a5adeb8e156460651421aceca56c213a50"
2600+
integrity sha512-GO107XdrSUmtHxVoi60qc9tUl/KkNKm+X2CF4P9amalpGxv5YqVPJNfSb0wcA+syCopkZvYYIzW8OVTQW59x/w==
2601+
25192602
p-try@^1.0.0:
25202603
version "1.0.0"
25212604
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
@@ -2572,6 +2655,11 @@ path-is-absolute@^1.0.0:
25722655
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
25732656
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
25742657

2658+
path-is-inside@^1.0.1:
2659+
version "1.0.2"
2660+
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
2661+
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=
2662+
25752663
path-key@^2.0.0, path-key@^2.0.1:
25762664
version "2.0.1"
25772665
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
@@ -2606,6 +2694,11 @@ performance-now@^2.1.0:
26062694
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
26072695
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
26082696

2697+
pify@^2.0.0:
2698+
version "2.3.0"
2699+
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
2700+
integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw=
2701+
26092702
pify@^3.0.0:
26102703
version "3.0.0"
26112704
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
@@ -2616,6 +2709,18 @@ pify@^4.0.1:
26162709
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
26172710
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
26182711

2712+
pinkie-promise@^2.0.0:
2713+
version "2.0.1"
2714+
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
2715+
integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o=
2716+
dependencies:
2717+
pinkie "^2.0.0"
2718+
2719+
pinkie@^2.0.0:
2720+
version "2.0.4"
2721+
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
2722+
integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA=
2723+
26192724
pkg-dir@^2.0.0:
26202725
version "2.0.0"
26212726
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"

0 commit comments

Comments
 (0)