apify-cli
apify-cli copied to clipboard
Output from warnings doesn't go to `stderr` and breaks working `*nix` integrations even on non otherwise non-breaking releases
Example:
$ apify actor:get-input 2>/dev/null
Warning: You are using an old version of Apify CLI. We strongly recommend you always use the latest available version.
↪ Run ' brew update && brew upgrade apify-cli ' to update! 👍
{ "usernames":
["netmilk", "n1k"]
}
Example of a broken integration then:
$ apify actor:get-input | jq
jq: parse error: Invalid numeric literal at line 2, column 8
Expected behavior:
$ apify actor:get-input 2>stderr.txt
{ "usernames":
["netmilk", "n1k"]
}
$ cat stderr.txt
Warning: You are using an old version of Apify CLI. We strongly recommend you always use the latest available version.
↪ Run ' brew update && brew upgrade apify-cli ' to update! 👍
As a quick remediation I propose to use console.warn() and console.error() instead of console.log() at least for warn and error in output.ts
$ cat warn-test.js
console.log("this is a standard output")
console.warn("this is a warning")
console.error("this is an error")
$ node warn-test.js 2>/dev/null
this is a standard output
Feel free to PR the changes, because I agree and they look correct!
Yeah, good point.
The same goes for the info level:
$ cat storage/key_value_stores/default/INPUT.json
{
"urls": [
"http://google.com"
]
}
$ apify actor:get-input 2>/dev/null
Info: Making sure that Apify CLI is up to date...
Info: Apify CLI is up to date 👍
{
"urls": [
"http://google.com"
]
}
Info: Apify collects telemetry data about general usage of Apify CLI to help us improve the product. This feature is enabled by default, and you can disable it by setting the "APIFY_CLI_DISABLE_TELEMETRY" environment variable to "1". You can find more information about our telemetry in https://docs.apify.com/cli/docs/telemetry.
INPUT: http://google.com
That isn't a parseable JSON output.