hook.io-sdk icon indicating copy to clipboard operation
hook.io-sdk copied to clipboard

hook-deploy CLI always creates new hook instead of updating existing

Open kolya-ay opened this issue 7 years ago • 7 comments

Is that by design?

Currently I workaround this by creating custom update utility, but it's not convenient at all. Is there plans to allow passing config params through environment variables, i.e for CD needs?

kolya-ay avatar Dec 03 '17 17:12 kolya-ay

That shouldn't be happening.

Are you seeing duplicate hooks with the same name? It shouldn't be possible to create multiple hooks with the same name.

Can you provide steps to reproduce?

Marak avatar Dec 03 '17 17:12 Marak

Thank you for immediate response. hook.io looks very cool, but a bit uncrowned here and there.

Are you seeing duplicate hooks with the same name?

Yes, just tried

$ mkdir hook
$ echo "module.exports = () => console.log('Hello world');" > hook/broken.js
$ node_modules/.bin/hook deploy hook/broken.js
$ node_modules/.bin/hook deploy hook/broken.js

Two last commands give the same message created new service at: https://hook.io/kolya-ay/hookbroken-js. I can provide you my production.json if it's necessary.

kolya-ay avatar Dec 03 '17 17:12 kolya-ay

Thanks for the additional information. I agree that the production site still needs improvement, we are actively working on it.

I'm guessing this issue may be because there isn't a package.json manifest for the service. I'm not certain we support the command syntax you are trying to use. I'll see what I can do about making sure we catch the error condition causing this confusing created message.

Can you try running hook-init in the folder for your service? From there you can define the entry point and service name. Once initialized you should be able to hook deploy

Marak avatar Dec 03 '17 17:12 Marak

I also just noticed that the example code you posted isn't using the hook.res or res variable which is required for JavaScript services in order to end the request.

For more examples you can try deploying any of these folders: https://github.com/stackvana/microcule-examples

Marak avatar Dec 03 '17 20:12 Marak

Didn't mean to close the issue yet.

I've updated master to fix this deployment issue, as well as generally improve the hook-deploy command.

The crux of the issue was that sdk client previously was unable to smoothly deploy single files without a valid package.json file. Now it should be possible to deploy either a folder with a package.json, or a single file.

We should be pushing out a new sdk release and production update soon.

Marak avatar Dec 04 '17 05:12 Marak

Thank you. Just hadn't found in the docs that package.json is required or either used somehow. I'm totally fine with that especially because it addresses my another question how to specify exact hook name from command line;)

I think also that package.json semantic could be extended to optionally contain some data from the hook.io-sdk/config manifest. It's just my suggestion but it seems to be the right place (user/email fields are already there). It may be related to global hook config the same way as git system/git local configurations relate to each other. This would partially solve CI deployment issue. Not sure how to deal with the private_key though.

By the way, where is the right place to ask questions or make feature requests? Is there some slack/gitter channel?

Fill free to close the issue as my particular use-case is satisfied.

kolya-ay avatar Dec 04 '17 15:12 kolya-ay

@kolya-ay -

Would it help at all if we exposed hook_private_key and user and other config properties as arguments to the CLI commands? Are you trying to run hook-deploy binary as part of a CD script?

It might make more sense for you to create a custom deployment script doing something like:

var sdk = require("hook.io-sdk");

var client = sdk.createClient({
  // custom configuration goes here
});

client.hook.deploy(pkg, function (err, res){
  console.log(err, res)
});

The best place to request features is as Github Issues or the related repos or using http://hook.io/wishlist

Marak avatar Dec 04 '17 18:12 Marak