Skip to content
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

Add warning when sgd generates empty package.xml #249

Closed
tprouvot opened this issue Feb 23, 2022 · 3 comments · Fixed by #289
Closed

Add warning when sgd generates empty package.xml #249

tprouvot opened this issue Feb 23, 2022 · 3 comments · Fixed by #289
Assignees
Labels
enhancement New feature or request

Comments

@tprouvot
Copy link
Contributor

tprouvot commented Feb 23, 2022

Is your proposal related to a problem?


Since we can add files to .sgdignore, some commits on those files can lead to empty package.xml and destructiveChanges.xml and cause deployment errors.

Describe the solution you'd like


It would be great if we can have this information returned in the command output such as:

{
  "error": null,
  "output": ".",
  "success": true,
  "warnings": ["Empty packages"]
}

Describe alternatives you've considered


Another solution would be to parse the package.xml and destructivesChanges files in CICD script to count the number of lines and detect when files are empty.

Additional context


I would be more than happy to contribute to this enhancement if you can provide me some implementation guidelines.

@tprouvot tprouvot added the enhancement New feature or request label Feb 23, 2022
@scolladon
Copy link
Owner

Hi @tprouvot !

Thanks for this suggestion.
A little bit more context on how error and warnings are populated:

  • error correspond to any parameter check issue (--to different than HEAD with -d per exemple)
  • warnings correspond to any issue while trying to move delta source after the package.xml has been properly populated

We could consider adding this has a warning may break ascendant compatibility if some pipeline already interpret its content.

Interpret the result of the package.xml and destructiveChanges.xml can easily be done using grep -q '<types>' path/to/package.xml (status code is 0 in case of match and 1 when no match).
Then it can be easy to condition a deployment based on the result:

$ grep -q '<types>' output/package/package.xml && sfdx force:source:deploy -x output/package/package.xml
$ grep -q '<types>' output/destructiveChanges/destructiveChanges.xml && sfdx force:mdapi:deploy -d  output/destructiveChanges/destructiveChanges.xml --ignorewarnings

If you want you could create a dedicated subsection under the advance use case section in the README!

@mehdicherf
Copy link
Collaborator

Hi @tprouvot!

Following up on this enhancement request: what do you think of @scolladon 's reply and suggestion of dealing with it through an entry in the Readme (to explain how to use grep for that use-case)?

Actually you're most welcome to submit a PR with this addition in the Readme (under the "advance use cases" section) since it may help others too :-)

@tprouvot
Copy link
Contributor Author

Hi @mehdisfdc,

I'm OK with @scolladon 's suggestion, I created the following PR #289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants