Closed alexellis closed 4 years ago
I'll take a shot at this. I'm familiar with npm, node, the GitHub API and getting content from GitHub using axios
.
@doowb let me know if you need any help or testing! Here, or on Slack
Would be great if you could collaborate together. Any chance of cobbling together a PoC by Friday?
Any chance of cobbling together a PoC by Friday?
I don't think that'll be a problem.
@burtonr PTAL when you have a chance: https://github.com/doowb/faas-cli/tree/npm-postinstall
I've only tested this on Mac OSX (darwin) so far and I don't have Windows specific logic in there yet, but it's installing and moving the files to the correct place.
BTW... the way I'm testing this is to install it using the absolute file path in a random node project with a package.json
:
npm install /path/to/openfaas/faas-cli/npm
You should also be able to try from any directory and install globally:
npm install -g /path/to/openfaas/faas-cli/npm
@doowb How about opening a PR so we can look at the code and comment more specifically there.
That said, I did try this a couple of different ways, but neither was successful. Not an issue since this is the first round of work. I run Linux (Pop!_os/Ubuntu) with a Windows VM (for when I have to)
I found a small mis-type in the getSuffix()
function. It should look like this:
if (type === 'Linux') {
if (arch === 'x64') {
return ''
}
if (arch === 'arch64') {
return '-arm64'
}
if (arch === 'armv61' || arch === 'armv71') {
return '-armhf'
}
}
but even with that fix, there is the permissions issue with attempting to write to /usr/local/bin/
... need to have a look at that
Thanks for trying it out on Linux. I'll submit the PR so it's easier to work against.
there is the permissions issue
I was trying different ways to run npm install
as root
, but even when doing sudo npm install
, the uid
was never 0
.
@burtonr I updated the PR:
install.js
file with your comment aboveinstall.js
file to download the faas-cli
executable to ~/.openfaas/bin/faas-cli
(~/.openfaas/bin/faas-cli.exe
on Windows).cli.js
which will execute the faas-cli
executable and forward the command line arguments.bin
property to package.json
which tells npm to add faas
and faas-cli
to the PATH to point to cli.js
.The last item is the one that I didn't pick up on when I was looking at the wrangler
files and should be the key for allowing the cli to be installed on any system. This also means that a lot of the bash script logic could be skipped to allow npm to do it's job.
Let me know if you have any questions or feedback.
Thanks.
/close: released
/lock
I noticed that the CloudFlare team are distributing their new Rust binary via
npm
, and It think we could do the same.Expected Behaviour
Distribute via
npm
in addition tocurl
andbrew
Current Behaviour
Mac:
curl
/brew
Linuxcurl
(possibly Linux Brew??) Windows: manually go to downloads pagePossible Solution
Look into how CF use Axios to do a HTTP get of the right binary. Perhaps we can execute our get shell script, or copy parts of it into Node.js?
https://github.com/cloudflare/wrangler/blob/master/npm/package.json
At the end we'd have:
Would love to see some people get together and make this happen, or have a go at it.