New Hooks for Unlocked Packages #2368
Replies: 13 comments
-
If the packages were just npm or yarn packages, it would make everything easier. |
Beta Was this translation helpful? Give feedback.
-
@AllanOricil |
Beta Was this translation helpful? Give feedback.
-
@ChuckJonas |
Beta Was this translation helpful? Give feedback.
-
In Sample gallery apps (https://github.com/trailheadapps/easy-spaces-lwc/blob/develop/.github/workflows/packaging-sfdx-ci-develop.yml) we do 2 and 4 today using github actions today! I agree will make it vendor-agnostic if CLI provides hooks. Also, it is not a bad idea to use the OCLIF hooks. Since the sfdx cli is build on the OCLIF, I think these hooks should work in CLI as well |
Beta Was this translation helpful? Give feedback.
-
@msrivastav13 -- I didn't think that OCLIF hooks were possible yet. The last time that I spoke with @clairebianchi and @amphro about this, they were saying that a lot of rework was needed to the internals of the existing CLI code in order to correctly support OCLIF hooks. Is that still the case? |
Beta Was this translation helpful? Give feedback.
-
I will wait for @clairebianchi and @amphro to officially confirm on this :) It is in the docs at least for now. I am going to try it now :) |
Beta Was this translation helpful? Give feedback.
-
Didn't say anything about running these hooks via local dev machines. I envisioned these running in a CI running sfdx... And ya, you can already all this via build script, but this could make it easier to setup, more standardized and upgradable across multiple repos. |
Beta Was this translation helpful? Give feedback.
-
@ImJohnMDaniel and @ChuckJonas I was able to validate that oclif lifecycle hooks fire on all commands (standard OOB commands) once you add them to a custom CLI plugin. Here is a sample project that shows this in case you are interested. https://github.com/msrivastav13/oclifhookssfcli/tree/master/src/hooks/oclifhook The Key is you add the hooks to the package.json |
Beta Was this translation helpful? Give feedback.
-
Yes I agree that they work in custom plugins that are expecting the hook. My point was that I thought that the current CLI functionality does not currently work with hooks. That is where we need the ability to tie in the hooks. |
Beta Was this translation helpful? Give feedback.
-
Ah got your point @ImJohnMDaniel ! Actually that's not true. You create the hooks via a custom CLI plugin but once you have them they work on any command out of the box provided by salesforce CLIand can listen for all OCLIF lifecycle hooks. Just tested it. |
Beta Was this translation helpful? Give feedback.
-
Good to hear. |
Beta Was this translation helpful? Give feedback.
-
@ChuckJonas could you explain what are you planning? Because usually we run those automations in Git, not per package. Because developers often forget to configure or run it, and also because those actions are generic and has to run for every package. Hooks were created to automate steps that are specific for a particular package. If an action has to ran on every package, always focus on automating on your Git remote repository, where you gather all the code. |
Beta Was this translation helpful? Give feedback.
-
As I stated above, I would be running these hooks from a git CI for the release management of the packages themselves. The examples I listed are just easy to talk about scenario's. There are countless use-cases, I just spit off the first couple that came to my head.
All the unlocked packages we use live in their own git repo.... So both per git repo and per package.
There are no hooks for packages yet... that's what this issue is requesting.
We're not using packages like that. We are using packages to share general purpose code across many completely unrelated orgs. EG: |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
In order to provide enhanced dev-ops around the creation of packages and package versions, it would be helpful to have some additional hooks types.
What are you trying to do
Some examples of what could be done:
prepackageversioncreate
that ensures there are no uncommitted changesprepackageversioncreate
that runs prettier / linter / static analysispostpackageversioncreate
that tags your repo with the version of the new package (or creates a new release in github)postpackageversioncreate
that updates a section in the README with a link to the latest install URLDescribe the solution you'd like
Add the following CLI hooks:
Describe alternatives you've considered
You can write a new CLI plugin command that "wraps" these calls and handles the results, but that more work and less composable
Beta Was this translation helpful? Give feedback.
All reactions