Skip to content

Commit 9807158

Browse files
author
Jared Rice Sr
committed
Push Stable 1.0.2
0 parents  commit 9807158

File tree

6 files changed

+292
-0
lines changed

6 files changed

+292
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
versions

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 Bench Open Systems
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# getNJS
2+
[![benOSShield-Official](https://img.shields.io/badge/benOS-Native-brightgreen.svg)](https://github.com/benchOS/benOS)[![benOSShield-Utils](https://img.shields.io/badge/benOS-Utils-brightgreen.svg)](https://github.com/benchOS/benOS)[![build status](http://img.shields.io/travis/benchOS/getnjs.svg?style=flat)](http://travis-ci.org/benchOS/getnjs)[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3+
[![benOSRepoHeader](https://raw.githubusercontent.com/benchOS/benchOS-design/master/repo-headers/getnjs.png)](https://github.com/benchOS/getnjs)
4+
<br>
5+
6+
One-line NodeJS installer used with [Benny](https://github.com/benchOS/benny) and [Bennyfile](https://github.com/benchOS/bennyfile).
7+
8+
9+
## Table of Contents
10+
11+
- [Background](#background)
12+
- [Installation](#installation)
13+
- [Usage](#usage)
14+
- [Related Projects](#related-projects)
15+
- [Why Decentralized Internet](#why-the-internet-must-have-a-decentralized-alternative)
16+
- [Bench On The dWeb](#bench-on-the-dweb)
17+
- [License](#license)
18+
- [Copyright](#license)
19+
20+
## Background
21+
One-line NodeJS installer used with [Benny](https://github.com/benchOS/benny) and [Bennyfile](https://github.com/benchOS/bennyfile).
22+
23+
[![benOSRepoHeader](https://raw.githubusercontent.com/benchOS/benchOS-design/master/terminal-screens/getnjs.png)](https://github.com/benchOS/getnjs)
24+
25+
26+
## Installation
27+
28+
Easily Install NodeJS With One-Line.
29+
30+
```
31+
curl -fs https://raw.githubusercontent.com/benchOS/getnjs/master/go | sh
32+
```
33+
34+
## Usage
35+
36+
Install any version of Node.js with ease.
37+
38+
```
39+
getnjs 0.10.10 # installs Node.js v0.10.10
40+
getnjs 0.8.24 # installs Node.js v0.8.24
41+
getnjs latest # installs latest stable node
42+
```
43+
44+
Autocomplete your Node.js installation with ease.
45+
46+
```
47+
getnjs --completion --save # Follow the install instructions
48+
getnjs <tab><tab> # Prints all Node.js versions available to `getnjs`
49+
```
50+
51+
## Related Projects
52+
- [benOS](https://github.com/benchOS/benOS) - benOS Decentralized Operating System
53+
- [benny](https://github.com/benchOS/dpack-logger) - benOS Native Container Builder
54+
- [bennyfile](https://github.com/distributedweb/bennyfile) - Build File Library For Benny Containers
55+
56+
## Why The Internet Must Have A Decentralized Alternative
57+
Today, the internet is more censored than ever and it's only getting worse. Our mission with the [dWeb Protocol](https://github.com/distributedweb/dweb) was to create a truly powerful P2P protocol, around [benOS](https://github.com/benchOS/benos), [dBrowser](https://github.com/benchOS/dbrowser) and many of benOS' underlying libraries to bring the most powerful P2P products to life. In the last few months, by rebuilding P2P technologies that have existed since the early 2000s, we have built a powerful suite of decentralized libraries for benOS and the Bench Network, that will only improve over time. But we also brought new ideas to life, like:
58+
59+
- [dDrive](https://github.com/distributedweb/ddrive)
60+
- [dExplorer](https://github.com/distributedweb/dexplorer)
61+
- [dDatabase](https://github.com/distributedweb/ddatabase)
62+
- [dSites](https://github.com/distributedweb/dsites)
63+
- [dPack](https://github.com/distributedweb/dpack)
64+
- [benFS](https://github.com/benchOS/benfs)
65+
- [DCDN](https://github.com/distributedweb/dcdn)
66+
- [Rocketainer](https://github.com/distributedweb/rocketainer)
67+
- [RocketOS](https://github.com/distributedweb/rocketos)
68+
- [dNames](https://github.com/distributedweb/dnames)
69+
- [P2PDNS](https://github.com/distributedweb/p2pdns)
70+
- [dWebFS](https://github.com/distributedweb/dwebfs)
71+
- [dWebDB](https://github.com/distributedweb/dwebdb)
72+
- [MeteorIDE](https://github.com/distributedweb/meteorIDE)
73+
- [Kepler](https://github.com/benchlab/kepler)
74+
- [Neutron](https://github.com/benchlab/neutron)
75+
- [Designate](https://github.com/benchlab/designate)
76+
- [Nova](https://github.com/benchlab/nova)
77+
78+
and more! These were the protocols and libraries that we needed to create a completely decentralized operating system, where everything was distributed, protected and people were once again in control of their data. benOS is made up of over 1100+ different libraries that we are releasing on a day-by-day basis as we move them to a stable/production state. While financial support is great for this open source project, we need developers who want to be some of the first to build the `dApps` and `dSites` of the future. We have to take back what our forefathers originally designed for freedom, by making our code the law, instead of releasing weak and highly centralized applications where law cannot be applied because the code lacks the foundation to implement a legal framework for itself. Join us for a truly historic journey on the [BenchLabs Telegram](https://t.me/benchlabs). See you there.
79+
80+
### Bench On The dWeb
81+
[dweb://bench.dnames.io](dweb://bench.dnames.io) // dNames Short Link
82+
[dweb://3EDAE09848B77401445B7739CAFCE442DDE1752AED63025A1F94E6A86D7E9F04](dweb://3EDAE09848B77401445B7739CAFCE442DDE1752AED63025A1F94E6A86D7E9F04) // dWeb Key Link
83+
84+
In order to make the links above clickable or to view these links period, you will need [dBrowser](https://github.com/benchOS/dbrowser) (Available for Mac OSX, Linux, Windows and soon to be available on iOS/Android)
85+
86+
#### "The Code Is The Law" - Stan Larimer - Godfather of BitShares.
87+
88+
## License
89+
[MIT](LICENSE.md)
90+
<br><br>
91+
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)
92+
<br>
93+
[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://js.distributedwebs.org)
94+
<br>
95+
96+
## Copyright
97+
Copyright (c) 2018 Bench Open Systems. All rights reserved.

getnjs

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
CACHE_FOLDER=~/.cache
7+
NODE_VERSIONS_CACHE=$CACHE_FOLDER/node-versions
8+
9+
error () {
10+
echo "$@"
11+
exit 1
12+
}
13+
14+
silent () {
15+
$@ > /dev/null 2> /dev/null
16+
}
17+
18+
update-versions () {
19+
[ $EUID = 0 ] && return 1
20+
mkdir -p $CACHE_FOLDER
21+
curl -fs https://nodejs.org/dist/ | grep v | grep -v npm | grep -v node- | grep -v latest | sed 's|/</a>.*||' | sed 's/.*>v//' > $NODE_VERSIONS_CACHE
22+
[ $? != 0 ] && rm -f $NODE_VERSIONS_CACHE
23+
true
24+
}
25+
26+
print-help () {
27+
echo "getNJS Usage: getnjs version"
28+
}
29+
30+
list () {
31+
if ! silent find $NODE_VERSIONS_CACHE -mtime -1; then
32+
update-versions
33+
fi
34+
[ -e $NODE_VERSIONS_CACHE ] && cat $NODE_VERSIONS_CACHE
35+
echo latest
36+
}
37+
38+
run () {
39+
[ $# = 0 ] && error "getNJS Usage: getnjs version"
40+
[ ! -d /usr/local/bin ] && error "/usr/local/bin does not exist"
41+
42+
local version=$1
43+
local os=
44+
local arch=x86
45+
local force=false
46+
local completion=false
47+
local save=false
48+
local list=false
49+
50+
if [ "$version" == "latest" ]; then
51+
version=$(curl -fs https://nodejs.org/dist/latest/ | grep node- | head -n1 | sed 's/.*node-v//' | sed 's/-.*//' || true)
52+
fi
53+
54+
version=${version//v/}
55+
56+
for opt in "$@"; do
57+
case "$opt" in
58+
--force) force=true ;;
59+
-f) force=true ;;
60+
--completion) completion=true ;;
61+
-c) completion=true ;;
62+
--save) save=true ;;
63+
-s) save=true ;;
64+
--list) list=true ;;
65+
-l) list=true ;;
66+
esac
67+
done
68+
69+
if ! $force && [ "$(node -v 2> /dev/null)" == "v$version" ]; then
70+
echo node $(node -v) is now installed
71+
exit 0
72+
fi
73+
74+
case "$(uname -a)" in
75+
Linux*) os=linux ;;
76+
Darwin*) os=darwin ;;
77+
SunOS*) os=sunos ;;
78+
esac
79+
80+
case "$(uname -m)" in
81+
*armv7l*) arch=armv7l ;;
82+
*x86_64*) arch=x64 ;;
83+
esac
84+
85+
if $list; then
86+
list
87+
return $?
88+
fi
89+
90+
if $completion && $save; then
91+
local bin=$0
92+
setup-completion () {
93+
[ ! -d $1 ] && return 0
94+
[ ! -w $1 ] && error "getNJS Permission Error: you do not have permission to write to $1"
95+
$bin --completion > $1/getnjs || exit 1
96+
echo "# completion installed. run the following to activate it now"
97+
echo
98+
echo ". $1/getnjs"
99+
echo
100+
exit 0
101+
}
102+
103+
setup-completion /usr/local/etc/bash_completion.d
104+
setup-completion /etc/bash_completion.d
105+
setup-completion ~/bash_completion.d
106+
setup-completion ~/.bash_completion.d
107+
108+
error could not find bash_completion dir
109+
fi
110+
111+
if $completion; then
112+
_getnjs () {
113+
COMPREPLY=($(getnjs --list | grep "^${COMP_WORDS[$COMP_CWORD]}"))
114+
}
115+
echo "# auto install to bash completion dir:"
116+
echo "# getnjs --completion --save"
117+
echo
118+
declare -f _getnjs
119+
echo
120+
echo complete -F _getnjs getnjs
121+
exit 0
122+
fi
123+
124+
local url=https://nodejs.org/dist/v$version/node-v$version-$os-$arch.tar.gz
125+
local pkg_url=https://nodejs.org/dist/v$version/node-v$version.pkg # support older node versions
126+
local pkg_tmp=/tmp/node-$version.pkg
127+
128+
[ ! -O /usr/local/bin ] && ! $force && [ "$(whoami)" = "root" ] && error "you are root and do not own /usr/local/bin\nuse --force to continue"
129+
[ ! -O /usr/local/bin ] && ! $force && error "you do not have permission to write to /usr/local/bin"
130+
131+
if ! silent curl -fsI $url; then
132+
if [ "$os" = "darwin" ] && silent curl -fsI $pkg_url; then
133+
curl -fs $pkg_url > $pkg_tmp && silent sudo installer -pkg $pkg_tmp -target / && rm -f $pkg_tmp
134+
else
135+
error cannot find node $version
136+
fi
137+
else
138+
if [ "$os" = "darwin" ]; then
139+
curl -fs $url | tar xzPs '|^[^/]*/|/usr/local/|' --include '*/*/*'
140+
else
141+
curl -fs $url | tar xzP --xform 's|^[^/]*/|/usr/local/|' --wildcards '*/*/*'
142+
fi
143+
fi
144+
145+
[ $? != 0 ] && exit 1
146+
147+
echo node $(node -v) is now installed
148+
}
149+
150+
run "$@"

go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[ ! -d /usr/local/bin ] && echo "/usr/local/bin is nonexistant" && exit 1
2+
[ ! -O /usr/local/bin ] && SUDO_MAYBE=sudo
3+
$SUDO_MAYBE curl -fso /usr/local/bin/getnjs https://raw.githubusercontent.com/benchOS/getnjs/master/go
4+
$SUDO_MAYBE chmod +x /usr/local/bin/getnjs

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "getnjs",
3+
"version": "1.0.2",
4+
"description": "Node.js Automated Installer",
5+
"main": "getnjs",
6+
"bin": {
7+
"getnjs": "./getnjs"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/benchOS/getnjs"
12+
},
13+
"author": "Bench Open Systems",
14+
"license": "MIT",
15+
"bugs": {
16+
"url": "https://github.com/benchOS/getnjs/issues"
17+
},
18+
"homepage": "https://github.com/benchOS/getnjs"
19+
}

0 commit comments

Comments
 (0)