Skip to content

Commit

Permalink
fix: fixed some of Steve's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Feb 16, 2021
1 parent 7828c3f commit 4596da6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/config": "^1",
"@salesforce/cli-plugins-testkit": "^0.0.3",
"@salesforce/command": "^3.1.0",
"@salesforce/core": "^2.18.3",
"@salesforce/source-deploy-retrieve": "^1.1.17",
Expand All @@ -17,6 +16,7 @@
"@oclif/dev-cli": "^1",
"@oclif/plugin-command-snapshot": "^2.0.0",
"@salesforce/dev-config": "^2.1.0",
"@salesforce/cli-plugins-testkit": "^0.0.4",
"@salesforce/dev-scripts": "^0.7.0",
"@salesforce/plugin-command-reference": "^1.3.0",
"@salesforce/prettier-config": "^0.0.1",
Expand Down
55 changes: 4 additions & 51 deletions src/commands/force/source/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as os from 'os';
import * as path from 'path';
import { flags, FlagsConfig } from '@salesforce/command';
import { Lifecycle, Messages, SfdxError } from '@salesforce/core';
import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
import { Duration } from '@salesforce/kit';
import { asString } from '@salesforce/ts-types';
import { DEFAULT_SRC_WAIT_MINUTES, MINIMUM_SRC_WAIT_MINUTES, SourceCommand } from '../../../sourceCommand';

Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -57,69 +59,20 @@ export class retrieve extends SourceCommand {
// safe to cast from the flags as an array of strings
packagenames: this.flags.packagenames as string[],
sourcepath: this.flags.sourcepath as string[],
manifest: this.flags.manifest as string,
manifest: asString(this.flags.manifest),
metadata: this.flags.metadata as string[],
});

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

const results = await cs.retrieve(this.org.getUsername(), this.getAbsolutePath(defaultPackage.path), {
const results = await cs.retrieve(this.org.getUsername(), path.resolve(defaultPackage.path), {
merge: true,
// TODO: fix this once wait has been updated in library
wait: 1000000,
});

// emit post retrieve event
// results must match = {
// "done": true,
// "fileProperties": [
// {
// "createdById": "0053B000005FbiuQAC",
// "createdByName": "User User",
// "createdDate": "2021-02-09T23:48:26.000Z",
// "fileName": "unpackaged/classes/MyTest.cls",
// "fullName": "MyTest",
// "id": "01p3B000008hOVcQAM",
// "lastModifiedById": "0053B000005FbiuQAC",
// "lastModifiedByName": "User User",
// "lastModifiedDate": "2021-02-11T23:00:49.000Z",
// "manageableState": "unmanaged",
// "type": "ApexClass"
// },
// {
// "createdById": "0053B000005FbiuQAC",
// "createdByName": "User User",
// "createdDate": "2021-02-09T23:48:27.000Z",
// "fileName": "unpackaged/classes/force.cls",
// "fullName": "force",
// "id": "01p3B000008hOVdQAM",
// "lastModifiedById": "0053B000005FbiuQAC",
// "lastModifiedByName": "User User",
// "lastModifiedDate": "2021-02-11T23:00:49.000Z",
// "manageableState": "unmanaged",
// "type": "ApexClass"
// },
// {
// "createdById": "0053B000005FbiuQAC",
// "createdByName": "User User",
// "createdDate": "2021-02-12T17:27:58.876Z",
// "fileName": "unpackaged/package.xml",
// "fullName": "unpackaged/package.xml",
// "id": "",
// "lastModifiedById": "0053B000005FbiuQAC",
// "lastModifiedByName": "User User",
// "lastModifiedDate": "2021-02-12T17:27:58.876Z",
// "manageableState": "unmanaged",
// "type": "Package"
// }
// ],
// "id": "09S3B000002N5lcUAC",
// "status": "Succeeded",
// "success": true,
// "zipFilePath": "/var/folders/28/dmr8rt4d5f5bq_ttscbspz580000gp/T/sdx_sourceRetrieve_pkg_1613150491146/unpackaged.zip"
// }
await hookEmitter.emit('postretrieve', results);

if (results.status === 'InProgress') {
Expand Down
17 changes: 4 additions & 13 deletions src/sourceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,7 @@ export const DEFAULT_SRC_WAIT_MINUTES = 33;
export abstract class SourceCommand extends SfdxCommand {
public async retrievePackageDirs(): Promise<PackageDir[]> {
const proj = await SfdxProjectJson.create({});
return await proj.getPackageDirectories();
}

/**
* creates an absolute path by joining process.cwd() and the passed in string
*
* @param relPath
*/
public getAbsolutePath(relPath: string): string {
return path.join(process.cwd(), relPath);
return proj.getPackageDirectories();
}

/**
Expand All @@ -53,7 +44,7 @@ export abstract class SourceCommand extends SfdxCommand {
if (options.sourcepath) {
options.sourcepath.forEach((filepath) => {
if (fs.fileExistsSync(filepath)) {
setAggregator.push(ComponentSet.fromSource(this.getAbsolutePath(filepath)));
setAggregator.push(ComponentSet.fromSource(path.resolve(filepath)));
} else {
throw SfdxError.create('@salesforce/plugin-source', 'sourceCommand', 'SourcePathInvalid', [filepath]);
}
Expand All @@ -69,7 +60,7 @@ export abstract class SourceCommand extends SfdxCommand {
})
// for the requested ones get the ComponentSet from their path
.forEach((pkg) => {
setAggregator.push(ComponentSet.fromSource(this.getAbsolutePath(pkg.path)));
setAggregator.push(ComponentSet.fromSource(path.resolve(pkg.path)));
});
}

Expand All @@ -79,7 +70,7 @@ export abstract class SourceCommand extends SfdxCommand {
// to create a link to the actual source component we need to have it resolve through all packages
// to find the matching source metadata
// this allows us to deploy after
resolve: pkgs.map((pkg) => this.getAbsolutePath(pkg.path)),
resolve: pkgs.map((pkg) => path.resolve(pkg.path)),
})
);
}
Expand Down
79 changes: 75 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,15 @@
mv "~2"
safe-json-stringify "~1"

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

Expand Down Expand Up @@ -1050,6 +1051,19 @@ [email protected]:
tar-stream "^2.1.2"
zip-stream "^3.0.1"

archiver@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.2.0.tgz#25aa1b3d9febf7aec5b0f296e77e69960c26db94"
integrity sha512-QEAKlgQuAtUxKeZB9w5/ggKXh21bZS+dzzuQ0RPBC20qtDCbTyzqmisoeJP46MP39fg4B4IcyvR+yeyEBdblsQ==
dependencies:
archiver-utils "^2.1.0"
async "^3.2.0"
buffer-crc32 "^0.2.1"
readable-stream "^3.6.0"
readdir-glob "^1.0.0"
tar-stream "^2.1.4"
zip-stream "^4.0.4"

archy@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
Expand Down Expand Up @@ -1186,6 +1200,11 @@ async@^2.6.3:
dependencies:
lodash "^4.17.14"

async@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720"
integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
Expand Down Expand Up @@ -1772,6 +1791,16 @@ compress-commons@^3.0.0:
normalize-path "^3.0.0"
readable-stream "^2.3.7"

compress-commons@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-4.0.2.tgz#d6896be386e52f37610cef9e6fa5defc58c31bd7"
integrity sha512-qhd32a9xgzmpfoga1VQEiLEwdKZ6Plnpx5UCgIsf89FSolyJ7WnifY4Gtjgv5WR6hWAyRaHxC5MiEhU/38U70A==
dependencies:
buffer-crc32 "^0.2.13"
crc32-stream "^4.0.1"
normalize-path "^3.0.0"
readable-stream "^3.6.0"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down Expand Up @@ -1866,6 +1895,14 @@ cosmiconfig@^7.0.0:
path-type "^4.0.0"
yaml "^1.10.0"

crc-32@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.0.tgz#cb2db6e29b88508e32d9dd0ec1693e7b41a18208"
integrity sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==
dependencies:
exit-on-epipe "~1.0.1"
printj "~1.1.0"

crc32-stream@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-3.0.1.tgz#cae6eeed003b0e44d739d279de5ae63b171b4e85"
Expand All @@ -1874,6 +1911,14 @@ crc32-stream@^3.0.1:
crc "^3.4.4"
readable-stream "^3.4.0"

crc32-stream@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-4.0.2.tgz#c922ad22b38395abe9d3870f02fa8134ed709007"
integrity sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==
dependencies:
crc-32 "^1.2.0"
readable-stream "^3.4.0"

crc@^3.4.4:
version "3.8.0"
resolved "https://registry.yarnpkg.com/crc/-/crc-3.8.0.tgz#ad60269c2c856f8c299e2c4cc0de4556914056c6"
Expand Down Expand Up @@ -2500,6 +2545,11 @@ execa@^4.1.0:
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"

exit-on-epipe@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz#0bdd92e87d5285d267daa8171d0eb06159689692"
integrity sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==

expand-brackets@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
Expand Down Expand Up @@ -5191,6 +5241,11 @@ pretty-quick@^2.0.1:
mri "^1.1.4"
multimatch "^4.0.0"

printj@~1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222"
integrity sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
Expand Down Expand Up @@ -5357,6 +5412,13 @@ readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable
string_decoder "~1.1.1"
util-deprecate "~1.0.1"

readdir-glob@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/readdir-glob/-/readdir-glob-1.1.1.tgz#f0e10bb7bf7bfa7e0add8baffdc54c3f7dbee6c4"
integrity sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==
dependencies:
minimatch "^3.0.4"

readdirp@~3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839"
Expand Down Expand Up @@ -6800,3 +6862,12 @@ zip-stream@^3.0.1:
archiver-utils "^2.1.0"
compress-commons "^3.0.0"
readable-stream "^3.6.0"

zip-stream@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-4.0.4.tgz#3a8f100b73afaa7d1ae9338d910b321dec77ff3a"
integrity sha512-a65wQ3h5gcQ/nQGWV1mSZCEzCML6EK/vyVPcrPNynySP1j3VBbQKh3nhC8CbORb+jfl2vXvh56Ul5odP1bAHqw==
dependencies:
archiver-utils "^2.1.0"
compress-commons "^4.0.2"
readable-stream "^3.6.0"

0 comments on commit 4596da6

Please sign in to comment.