-
Notifications
You must be signed in to change notification settings - Fork 3
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(cli): on update process add flag to opt-out from publishing #415
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -60,6 +60,14 @@ export const createCLI = () => { | |||
'--name <value>', | |||
'name of plugin (Lowercase alphanumeric and dash)', | |||
) | |||
.option( |
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 tried out this approach as described in commander.js --> https://www.npmjs.com/package/commander#other-option-types-negatable-boolean-and-booleanvalue
However I might rewrite it depending on your feedback.
The better solution to this I see is to have --publish=true|false
however then --publish
without value might not work. And I will need to parse and validate boolean values, but thats fine, just a heads-up :)
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 approach looks good to me, Bibi. 🤔
I wonder though, what if we have just the --no-publish
option, and in case it's not passed (meaning it will be true), we always prompt the user to confirm the publishing unless the --skipPrompts
is also present?
The combinations would be something like:
yarn deploy
(which in case of an update, always asks if the user wants or not to publish)
yarn deploy --skipPrompts
(publish without asking anything)
yarn deploy --no-publish
(does not publish and does not show the prompt)
yarn deploy --no-publish --skipPrompts
(does not publish and not show any prompt)
I didn't think deeply about it, so I may be missing some pieces 🤣 🤣
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.
This might also work. Let's see what @eunjae-lee and @Dawntraoz think as well :)
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.
This can be a slight breaking change. Let's imagine someone was using deploy command with all the options except for --skipPrompts, but since all the options were given, they didn't encounter any prompt, and they used it for their CI. Now we're changing the default behavior to prompt about publishing. Then their CI will break.
So I think we can keep publishing by default, and just provide --no-publish
, then it would also be clear that publishing is done by default. What do you think? 🤔
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.
Ok so you would also suggest removing --publish? Works for me :) I will adjust it
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.
@demetriusfeijoo @eunjae-lee here are the updates
a5a690e
@@ -378,6 +381,7 @@ export const createFieldPlugin = async ( | |||
//we need to force an update call right after the creation. | |||
//If no options is found, it's not going to be sent to the API since undefined | |||
//properties are not encoded. | |||
//NOTE: The `publish` property is set to true here because it is a part of the creation process and should provide a consistent flow. | |||
await client.updateFieldType({ | |||
id: fieldPlugin.id, | |||
publish: true, |
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 am not 100% happy about this as it is a piece of code that might easily get overlooked, but I think keeping it to publish:true makes sense here, as it kind of mimics the creation process. So I would suggest keeping it to not confuse our users.
//NOTE: Publish true is the default value | ||
return publish || true |
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.
nit: Maybe here it could be simplified like that, Bibi? wdyt?
//NOTE: Publish true is the default value | |
return publish || true | |
//NOTE: Publish true is the default value | |
return true |
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.
Hey @demetriusfeijoo, if skipPrompts is true, it can still be the case that the --no-publish flag was defined. If so it should be taken into account. || true
is only for this case yarn deploy --skipPrompts
where no publish flag is defined.
WDYT?
@@ -60,6 +60,14 @@ export const createCLI = () => { | |||
'--name <value>', | |||
'name of plugin (Lowercase alphanumeric and dash)', | |||
) | |||
.option( |
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 approach looks good to me, Bibi. 🤔
I wonder though, what if we have just the --no-publish
option, and in case it's not passed (meaning it will be true), we always prompt the user to confirm the publishing unless the --skipPrompts
is also present?
The combinations would be something like:
yarn deploy
(which in case of an update, always asks if the user wants or not to publish)
yarn deploy --skipPrompts
(publish without asking anything)
yarn deploy --no-publish
(does not publish and does not show the prompt)
yarn deploy --no-publish --skipPrompts
(does not publish and not show any prompt)
I didn't think deeply about it, so I may be missing some pieces 🤣 🤣
Co-authored-by: Demetrius Feijóo <[email protected]>
bf2e9b5
to
dab1a5b
Compare
@@ -15,6 +15,7 @@ import { Scope } from '../../storyblok/storyblok-client' | |||
export type DeployArgs = { | |||
skipPrompts: boolean | |||
dir: string | |||
publish: boolean |
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.
@BibiSebi is this value coming from the flag --no-publish
? Maybe I missed it, but where the flag is --no-publish
is giving the value to this boolean? 🤔
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.
Yeah its rather weird and unintuitive but when defining -noo-publish
option with commander.js
it will automatically translate it into publish:false
and if you do not provide the option then it will be per default publish:true
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.
Oh, next level of a smart tool 🤯 Love it!
dab1a5b
to
3a6d8b9
Compare
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.
LGTM! 🎉
Super small nit: It can be nice to add a test with the --no-publish
flag in place
You are right @Dawntraoz I just added a test :) |
ffd8b39
to
c731282
Compare
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.
Great job @BibiSebi! 👏 👏
What?
This PR adds a new flag to the deploy command for publishing a new version of field plugin during the update process.
Context
As we have found out trough researching the APIs the POST request automatically publishes a field-plugin, therefore it is not possible to opt-out during the initial creations. However when using PUT method, updating the plugin, it is possible to send
publish
property, which will either only save the new plugin or save and publish it as a new version.Deploy Command with
--no-publish
flagHere are all the new test cases that are introduced by the change and are applied when a field plugin is updated. `
yarn deploy --no-publish
yarn deploy --skipPrompts
yarn deploy --skipPrompts --no-publish
Why?
#380
How to test?
yarn deploy
--> NEW: User is prompted with the following question Do you want to publish a new version of the field plugin?
--> Depending on the user input the field plugin will be deployed
yarn deploy --skipPrompts
--> Plugin will be updated and published inside Storyblok.
yarn deploy --no-publish
&yarn deploy --skipPrompts --no-publish
--> Plugin will be updated inside Storyblok but not published.