Skip to content

Commit 4596da6

Browse files
fix: fixed some of Steve's comments
1 parent 7828c3f commit 4596da6

File tree

4 files changed

+84
-69
lines changed

4 files changed

+84
-69
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/config": "^1",
9-
"@salesforce/cli-plugins-testkit": "^0.0.3",
109
"@salesforce/command": "^3.1.0",
1110
"@salesforce/core": "^2.18.3",
1211
"@salesforce/source-deploy-retrieve": "^1.1.17",
@@ -17,6 +16,7 @@
1716
"@oclif/dev-cli": "^1",
1817
"@oclif/plugin-command-snapshot": "^2.0.0",
1918
"@salesforce/dev-config": "^2.1.0",
19+
"@salesforce/cli-plugins-testkit": "^0.0.4",
2020
"@salesforce/dev-scripts": "^0.7.0",
2121
"@salesforce/plugin-command-reference": "^1.3.0",
2222
"@salesforce/prettier-config": "^0.0.1",

src/commands/force/source/retrieve.ts

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import * as os from 'os';
8+
import * as path from 'path';
89
import { flags, FlagsConfig } from '@salesforce/command';
910
import { Lifecycle, Messages, SfdxError } from '@salesforce/core';
1011
import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
1112
import { Duration } from '@salesforce/kit';
13+
import { asString } from '@salesforce/ts-types';
1214
import { DEFAULT_SRC_WAIT_MINUTES, MINIMUM_SRC_WAIT_MINUTES, SourceCommand } from '../../../sourceCommand';
1315

1416
Messages.importMessagesDirectory(__dirname);
@@ -57,69 +59,20 @@ export class retrieve extends SourceCommand {
5759
// safe to cast from the flags as an array of strings
5860
packagenames: this.flags.packagenames as string[],
5961
sourcepath: this.flags.sourcepath as string[],
60-
manifest: this.flags.manifest as string,
62+
manifest: asString(this.flags.manifest),
6163
metadata: this.flags.metadata as string[],
6264
});
6365

6466
// emit pre retrieve event
6567
// needs to be a path to the temp dir package.xml
6668
await hookEmitter.emit('preretrieve', { packageXmlPath: cs.getPackageXml() });
6769

68-
const results = await cs.retrieve(this.org.getUsername(), this.getAbsolutePath(defaultPackage.path), {
70+
const results = await cs.retrieve(this.org.getUsername(), path.resolve(defaultPackage.path), {
6971
merge: true,
7072
// TODO: fix this once wait has been updated in library
7173
wait: 1000000,
7274
});
7375

74-
// emit post retrieve event
75-
// results must match = {
76-
// "done": true,
77-
// "fileProperties": [
78-
// {
79-
// "createdById": "0053B000005FbiuQAC",
80-
// "createdByName": "User User",
81-
// "createdDate": "2021-02-09T23:48:26.000Z",
82-
// "fileName": "unpackaged/classes/MyTest.cls",
83-
// "fullName": "MyTest",
84-
// "id": "01p3B000008hOVcQAM",
85-
// "lastModifiedById": "0053B000005FbiuQAC",
86-
// "lastModifiedByName": "User User",
87-
// "lastModifiedDate": "2021-02-11T23:00:49.000Z",
88-
// "manageableState": "unmanaged",
89-
// "type": "ApexClass"
90-
// },
91-
// {
92-
// "createdById": "0053B000005FbiuQAC",
93-
// "createdByName": "User User",
94-
// "createdDate": "2021-02-09T23:48:27.000Z",
95-
// "fileName": "unpackaged/classes/force.cls",
96-
// "fullName": "force",
97-
// "id": "01p3B000008hOVdQAM",
98-
// "lastModifiedById": "0053B000005FbiuQAC",
99-
// "lastModifiedByName": "User User",
100-
// "lastModifiedDate": "2021-02-11T23:00:49.000Z",
101-
// "manageableState": "unmanaged",
102-
// "type": "ApexClass"
103-
// },
104-
// {
105-
// "createdById": "0053B000005FbiuQAC",
106-
// "createdByName": "User User",
107-
// "createdDate": "2021-02-12T17:27:58.876Z",
108-
// "fileName": "unpackaged/package.xml",
109-
// "fullName": "unpackaged/package.xml",
110-
// "id": "",
111-
// "lastModifiedById": "0053B000005FbiuQAC",
112-
// "lastModifiedByName": "User User",
113-
// "lastModifiedDate": "2021-02-12T17:27:58.876Z",
114-
// "manageableState": "unmanaged",
115-
// "type": "Package"
116-
// }
117-
// ],
118-
// "id": "09S3B000002N5lcUAC",
119-
// "status": "Succeeded",
120-
// "success": true,
121-
// "zipFilePath": "/var/folders/28/dmr8rt4d5f5bq_ttscbspz580000gp/T/sdx_sourceRetrieve_pkg_1613150491146/unpackaged.zip"
122-
// }
12376
await hookEmitter.emit('postretrieve', results);
12477

12578
if (results.status === 'InProgress') {

src/sourceCommand.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ export const DEFAULT_SRC_WAIT_MINUTES = 33;
2727
export abstract class SourceCommand extends SfdxCommand {
2828
public async retrievePackageDirs(): Promise<PackageDir[]> {
2929
const proj = await SfdxProjectJson.create({});
30-
return await proj.getPackageDirectories();
31-
}
32-
33-
/**
34-
* creates an absolute path by joining process.cwd() and the passed in string
35-
*
36-
* @param relPath
37-
*/
38-
public getAbsolutePath(relPath: string): string {
39-
return path.join(process.cwd(), relPath);
30+
return proj.getPackageDirectories();
4031
}
4132

4233
/**
@@ -53,7 +44,7 @@ export abstract class SourceCommand extends SfdxCommand {
5344
if (options.sourcepath) {
5445
options.sourcepath.forEach((filepath) => {
5546
if (fs.fileExistsSync(filepath)) {
56-
setAggregator.push(ComponentSet.fromSource(this.getAbsolutePath(filepath)));
47+
setAggregator.push(ComponentSet.fromSource(path.resolve(filepath)));
5748
} else {
5849
throw SfdxError.create('@salesforce/plugin-source', 'sourceCommand', 'SourcePathInvalid', [filepath]);
5950
}
@@ -69,7 +60,7 @@ export abstract class SourceCommand extends SfdxCommand {
6960
})
7061
// for the requested ones get the ComponentSet from their path
7162
.forEach((pkg) => {
72-
setAggregator.push(ComponentSet.fromSource(this.getAbsolutePath(pkg.path)));
63+
setAggregator.push(ComponentSet.fromSource(path.resolve(pkg.path)));
7364
});
7465
}
7566

@@ -79,7 +70,7 @@ export abstract class SourceCommand extends SfdxCommand {
7970
// to create a link to the actual source component we need to have it resolve through all packages
8071
// to find the matching source metadata
8172
// this allows us to deploy after
82-
resolve: pkgs.map((pkg) => this.getAbsolutePath(pkg.path)),
73+
resolve: pkgs.map((pkg) => path.resolve(pkg.path)),
8374
})
8475
);
8576
}

yarn.lock

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,15 @@
523523
mv "~2"
524524
safe-json-stringify "~1"
525525

526-
"@salesforce/cli-plugins-testkit@^0.0.3":
527-
version "0.0.3"
528-
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-0.0.3.tgz#05d7b6d47c51500964b66b956f949ebba6da7a3c"
529-
integrity sha512-U9PBZ2OLhp239HvZj/ZnzsR7lJMV8b+Wrn5VBJOXm4wr4a2zMkJrWXbMtU3sEuyE2l9pKCpoP90m6x9o1dJ9vA==
526+
"@salesforce/cli-plugins-testkit@^0.0.4":
527+
version "0.0.4"
528+
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-0.0.4.tgz#5ab57097df901186a5434fd0675933b9cecb42f0"
529+
integrity sha512-4Cr6NugaV049rW1FWqTfrBF2PuEBcSga4vojxkg6sV0UVqKW7cWFjsZ9Coa1cbBneOTjRi9KafQeKI3KVkGWMw==
530530
dependencies:
531531
"@salesforce/core" "^2.16.3"
532532
"@salesforce/kit" "^1.3.4"
533533
"@salesforce/ts-types" "^1.4.4"
534+
archiver "^5.2.0"
534535
debug "^4.3.1"
535536
shelljs "^0.8.4"
536537

@@ -1050,6 +1051,19 @@ [email protected]:
10501051
tar-stream "^2.1.2"
10511052
zip-stream "^3.0.1"
10521053

1054+
archiver@^5.2.0:
1055+
version "5.2.0"
1056+
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.2.0.tgz#25aa1b3d9febf7aec5b0f296e77e69960c26db94"
1057+
integrity sha512-QEAKlgQuAtUxKeZB9w5/ggKXh21bZS+dzzuQ0RPBC20qtDCbTyzqmisoeJP46MP39fg4B4IcyvR+yeyEBdblsQ==
1058+
dependencies:
1059+
archiver-utils "^2.1.0"
1060+
async "^3.2.0"
1061+
buffer-crc32 "^0.2.1"
1062+
readable-stream "^3.6.0"
1063+
readdir-glob "^1.0.0"
1064+
tar-stream "^2.1.4"
1065+
zip-stream "^4.0.4"
1066+
10531067
archy@^1.0.0:
10541068
version "1.0.0"
10551069
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
@@ -1186,6 +1200,11 @@ async@^2.6.3:
11861200
dependencies:
11871201
lodash "^4.17.14"
11881202

1203+
async@^3.2.0:
1204+
version "3.2.0"
1205+
resolved "https://registry.yarnpkg.com/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720"
1206+
integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==
1207+
11891208
asynckit@^0.4.0:
11901209
version "0.4.0"
11911210
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -1772,6 +1791,16 @@ compress-commons@^3.0.0:
17721791
normalize-path "^3.0.0"
17731792
readable-stream "^2.3.7"
17741793

1794+
compress-commons@^4.0.2:
1795+
version "4.0.2"
1796+
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-4.0.2.tgz#d6896be386e52f37610cef9e6fa5defc58c31bd7"
1797+
integrity sha512-qhd32a9xgzmpfoga1VQEiLEwdKZ6Plnpx5UCgIsf89FSolyJ7WnifY4Gtjgv5WR6hWAyRaHxC5MiEhU/38U70A==
1798+
dependencies:
1799+
buffer-crc32 "^0.2.13"
1800+
crc32-stream "^4.0.1"
1801+
normalize-path "^3.0.0"
1802+
readable-stream "^3.6.0"
1803+
17751804
17761805
version "0.0.1"
17771806
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -1866,6 +1895,14 @@ cosmiconfig@^7.0.0:
18661895
path-type "^4.0.0"
18671896
yaml "^1.10.0"
18681897

1898+
crc-32@^1.2.0:
1899+
version "1.2.0"
1900+
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.0.tgz#cb2db6e29b88508e32d9dd0ec1693e7b41a18208"
1901+
integrity sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==
1902+
dependencies:
1903+
exit-on-epipe "~1.0.1"
1904+
printj "~1.1.0"
1905+
18691906
crc32-stream@^3.0.1:
18701907
version "3.0.1"
18711908
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-3.0.1.tgz#cae6eeed003b0e44d739d279de5ae63b171b4e85"
@@ -1874,6 +1911,14 @@ crc32-stream@^3.0.1:
18741911
crc "^3.4.4"
18751912
readable-stream "^3.4.0"
18761913

1914+
crc32-stream@^4.0.1:
1915+
version "4.0.2"
1916+
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-4.0.2.tgz#c922ad22b38395abe9d3870f02fa8134ed709007"
1917+
integrity sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==
1918+
dependencies:
1919+
crc-32 "^1.2.0"
1920+
readable-stream "^3.4.0"
1921+
18771922
crc@^3.4.4:
18781923
version "3.8.0"
18791924
resolved "https://registry.yarnpkg.com/crc/-/crc-3.8.0.tgz#ad60269c2c856f8c299e2c4cc0de4556914056c6"
@@ -2500,6 +2545,11 @@ execa@^4.1.0:
25002545
signal-exit "^3.0.2"
25012546
strip-final-newline "^2.0.0"
25022547

2548+
exit-on-epipe@~1.0.1:
2549+
version "1.0.1"
2550+
resolved "https://registry.yarnpkg.com/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz#0bdd92e87d5285d267daa8171d0eb06159689692"
2551+
integrity sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==
2552+
25032553
expand-brackets@^2.1.4:
25042554
version "2.1.4"
25052555
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
@@ -5191,6 +5241,11 @@ pretty-quick@^2.0.1:
51915241
mri "^1.1.4"
51925242
multimatch "^4.0.0"
51935243

5244+
printj@~1.1.0:
5245+
version "1.1.2"
5246+
resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222"
5247+
integrity sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==
5248+
51945249
process-nextick-args@~2.0.0:
51955250
version "2.0.1"
51965251
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
@@ -5357,6 +5412,13 @@ readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable
53575412
string_decoder "~1.1.1"
53585413
util-deprecate "~1.0.1"
53595414

5415+
readdir-glob@^1.0.0:
5416+
version "1.1.1"
5417+
resolved "https://registry.yarnpkg.com/readdir-glob/-/readdir-glob-1.1.1.tgz#f0e10bb7bf7bfa7e0add8baffdc54c3f7dbee6c4"
5418+
integrity sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==
5419+
dependencies:
5420+
minimatch "^3.0.4"
5421+
53605422
readdirp@~3.2.0:
53615423
version "3.2.0"
53625424
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839"
@@ -6800,3 +6862,12 @@ zip-stream@^3.0.1:
68006862
archiver-utils "^2.1.0"
68016863
compress-commons "^3.0.0"
68026864
readable-stream "^3.6.0"
6865+
6866+
zip-stream@^4.0.4:
6867+
version "4.0.4"
6868+
resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-4.0.4.tgz#3a8f100b73afaa7d1ae9338d910b321dec77ff3a"
6869+
integrity sha512-a65wQ3h5gcQ/nQGWV1mSZCEzCML6EK/vyVPcrPNynySP1j3VBbQKh3nhC8CbORb+jfl2vXvh56Ul5odP1bAHqw==
6870+
dependencies:
6871+
archiver-utils "^2.1.0"
6872+
compress-commons "^4.0.2"
6873+
readable-stream "^3.6.0"

0 commit comments

Comments
 (0)