-
Notifications
You must be signed in to change notification settings - Fork 183
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) Add custom build hook to zapier commands #262
Conversation
Nice! I really like the idea of using the users defined npm scripts instead of prescribing behaviour. Random aside but how good would it be if the zapier push command checked for a |
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.
Nice enhancement! I have some minor suggestions in the comments. Can you also document this feature in README-source.md
? Feel free to merge if you've addressed all my suggestions.
I'm not sure if that belongs in the public package we ship to partners, unless partners have a use case for overriding |
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.
Like Chang-Hung said, we'll bump the version at a later date. I made one suggestion you should probably address, but this looks great!
My only other thought is whether this is actually a breaking change. zapier-build
is a pretty common scripts
key (I'm pretty sure it's a default in some of our examples). It's not uncommon to have a script like: "zapier-build": "zapier build"
. As written, I think we send the user into an infinite loop. Here's an example of that setup:
zapier-platform/example-apps/babel/package.json
Lines 11 to 13 in 56f1e53
"zapier-build": "rm -rf lib && babel src --out-dir lib", | |
"zapier-dev": "rm -rf lib && babel src --out-dir lib --watch", | |
"zapier-push": "npm run zapier-build && zapier push", |
So I think we need to:
- mark this as a breaking change
- probably also add a control to check if we're in a loop already (in case people don't read the update notes)
- maybe make the build key something that's less common or less likely to be in wide use (could be as simple as a leading
_
)
@xavdid Hmm...that is a concern. I chose I'm going to try checking out and searching across branches in |
@xavdid You're right, |
We could be sure (enough) that a script key like Also, per these docs, A last option is that we ask partners to put their hooks in a
which also lets us easily add more later. Then the code is something like: // build.js
if (_.get(pJson, ['zapier-hooks', 'build'])) {
runCommand('npm', ['run', _.get(pJson, ['zapier-hooks', 'build'])])
} We'd still want to check for recursion (if |
I'm fine with a script called I'll try to add a recursion check, and update |
This PR adds support for a custom build hook to zapier CLI commands.
By specifying a
_zapier-build
script inpackage.json
, apps can ensure that script will run duringzapier build
,zapier push
, etc. This is useful if someone wishes to write apps in TypeScript, or using Babel, since they can ensure they are never pushing a stale build that is out of sync with their sources.If there is no script named
_zapier-build
, there will be no change in functionality.