-
Notifications
You must be signed in to change notification settings - Fork 12
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: adapt build plugin implementation to new API #319
Conversation
Holding off for |
const { fs, path, rimraf } = cds.utils | ||
|
||
module.exports = class PostgresBuildPlugin extends BuildPlugin { | ||
static hasTask() { // REVISIT: should be unnecessary -> plugin mechanism knows what to pull |
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.
The hasTask
impl has ensured that a postgres build task is only executed if a postgres database is used according to the effective cds configuration. E.g. a sqlite
database might have been configured for the development
profile.
Of course, this might be an edge case, but on the other hand the check is simple and ensures that users don't get surprised if cds build is executed with development
profile ;-)
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.
Yes, unfortunately I also don't see another way to make it work properly w/ the profile technique where you switch between HANA/Postgres based on config profiles. I re-added the hasTask
again.
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.
...unfortunately? - I think this is a perfect solution :)
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.
I think it's close to perfect, but ideally the plugin doesn't handle what the plugin orchestrator in cap/cds
should do, deciding which plugins to pull.
I'd rather have an opt-out mechanism like this instead, which is then also combinable with profiles:
"cds": {
"requires": {
"plugins": {
"[pg]": {
"@sap/cds-hana": false
},
"[hana]": {
"@cap-js/postgres": false
}
}
}
}
Opting out in non-centralized places like the build plugin introduces inconsistent behavior, e.g. the plugin will still show up as loaded with DEBUG=plugins
.
Also, it reduces the number of functions you have to implement from 2 to 1, which is huge imo.
@danjoa What's your take on this?
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.
But isn't this more a question of different lifecycles for cds plugin
versus cds build task
. Loading the cds plugin
does not necessarily mean that a corresponding build task
respectively its BuildPlugin
counterpart will get executed.
I think the cds add plugin
would behave similar. A cds plugin
will be loaded, but the concrete cds facet
implementation might not, as this is determined using the concrete cds add
command line parameters or some other facet dependencies.
bc3fe78
to
483a108
Compare
Would be great if we could ship this version soon as the current postgres plugin version does not support @sap/cds-dk 7.3.2. See https://github.tools.sap/cap/issues/issues/14748 |
Open points re simplifications to be discussed in follow-up. |
@patricebender @johannes-vogel Can we ignore HANA tests for changes in |
requires
@sap/cds-dk
7.3.2