New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support retrieves in metadata format #313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions, and one real change on the output.ts comment
src/utils/flags.ts
Outdated
let resolvedPath: string; | ||
if (trimmedPath?.length) { | ||
resolvedPath = resolve(trimmedPath); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- avoids
let
- explicit that resolvedPath could be
undefined
(I'm not sure that's how it's supposed to work, but that's possible in both the existing and suggested code.
let resolvedPath: string; | |
if (trimmedPath?.length) { | |
resolvedPath = resolve(trimmedPath); | |
} | |
const resolvedPath = trimmedPath?.length ? resolve(trimmedPath) : undefined; |
src/utils/flags.ts
Outdated
|
||
try { | ||
const stats = fs.statSync(resolvedPath); | ||
if (type !== 'any') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why might it be 'any'
? If it is 'any'
, then nothing should happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's happy as long as something exists there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any
denotes that it could be a file or a directory
For context, I took this directly from plugin-source: https://github.com/salesforcecli/plugin-source/blob/d8192203b018df2ed6af68ed695ca96e759a89c3/src/sourceCommand.ts#L81 without any modification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't have a use case for that in mind, I'd be happy omitting it
public async display(): Promise<void> { | ||
CliUx.ux.log(retrieveMessages.getMessage('info.WroteZipFile', [this.zipFilePath])); | ||
if (this.opts.unzip) { | ||
const extractPath = path.join(this.opts['target-metadata-dir'], path.parse(this.opts['zip-file-name']).name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 473, we set this.zipFilePath
to the default unpackaged.zip
but it doesn't get defaulted on this.opts
. It's always safer to do that kind of stuff in the constructor (have it set defaults on the options object) to avoid this accidental potential undefined.
If you strongly prefer to not modify the options, you could put a private zipFileName
and have the constructor set that and refer to it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually not a need to default it anywhere since the flag does that already:
plugin-deploy-retrieve/src/utils/flags.ts
Line 149 in 6df9c94
export const zipFileFlag = (opts: ZipFileOpts): Interfaces.OptionFlag<string | undefined> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better
src/utils/flags.ts
Outdated
): Interfaces.OptionFlag<TestLevel | undefined> => { | ||
return Flags.build<TestLevel | undefined>({ | ||
char: 'l', | ||
parse: (input: string) => Promise.resolve(input as TestLevel), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens without the parse function that's doing nothing (it's either undefined or one of the options!?). Or is it necessary to coerce the type via the assertion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flags.build
requires the parse
to be present so you have to put something.
If you did parse: (input: string) => Promise.resolve(input)
, it would complain that you're returning a string when it expects a TestLevel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that feels like an oclif problem.
[side note: is this PR description wrong?]
QA notes: 👎🏻 there should be examples for this mdapi format stuff 👎🏻
retrieve metadata -t package.json --source-dir force-app Error (1): Invalid path specified: package.json
Expected a directory but found a file.
💡 why not mdapiOut/pkg1/etc, mdapiOut/pkg2/etc (or just pkg1 if single-package)? If I'm giving the target folder (mdapiOut) you could put each pkg in the folder I said (so it supports multiple) OR just put the contents of the single-package in there, so that it's mdapiOut/package.xml. Maybe there's a good reason for this (mdapi deploy expects it?), but I've always avoided mdapi and don't understand the logic. Or maybe it's awkward but better to keep it like sfdx does it. 🤷🏻
|
QA (primarily rechecking flag config and interactions given the oclif changes) Error: The following errors occurred:
--ignore-conflicts=true cannot also be provided when using --target-metadata-dir
--ignore-conflicts=true cannot also be provided when using --unzip 💡 idea for oclif: what if the error message included the short char, like --ignore-conflicts=true (-c) cannot also be provided when using --target-metadata-dir (-t) push to org ✅ after fix
✅ retrieving to a zip file works fine without a name (=> unpackaged.zip) |
What does this PR do?
Adds metadata format support to
retrieve metadata
New flags:
--target-metadata-dir
,-t
(depends on one ofsource-dir
,manifest
, andmetadata
)--single-package
(depends ontarget-metadata-dir
)--unzip
,-z
(depends ontarget-metadata-dir
)--zip-file-name
(depends ontarget-metadata-dir
)TODO:
What issues does this PR fix or reference?
@W-10748963@