Skip to content

Commit 0481aa0

Browse files
author
Bruno Herfst
committed
init
0 parents  commit 0481aa0

7 files changed

+163
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Bruno Herfst
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 all
13+
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 THE
21+
SOFTWARE.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# build-node-venv
2+
3+
A helper to (re-)build [nodeenv](https://github.com/ekalinin/nodeenv).
4+
5+
## install:
6+
7+
npm install build-node-venv --save-dev
8+
9+
Add `env` to `scripts` in your `package.json` for quick rebuilds:
10+
11+
```
12+
"scripts": {
13+
"env": "build-node-venv && # npm install && npm update"
14+
}
15+
```
16+
17+
> Note that you will need to have [virtualenv](https://pypi.python.org/pypi/virtualenv) installed.
18+

build-node-venv.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# current folder
4+
cd "${0%/*}"
5+
6+
# check requirements
7+
command -v virtualenv >/dev/null 2>&1 || { echo >&2 "I require virtualenv but it's not installed. See http://docs.python-guide.org/en/latest/dev/virtualenvs/ Aborting."; exit 1; }
8+
9+
# clear env if there
10+
if [ -e "./.venv" ] ; then
11+
# gotcha auto env!
12+
rm -rf "./.venv" && deactivate
13+
fi
14+
15+
# create node env
16+
virtualenv .venv && source .venv/bin/activate
17+
18+
# Add trusted-host
19+
printf "[global]\nindex-url=http://mirrors.aliyun.com/pypi/simple/\n" >> $VIRTUAL_ENV/pip.conf
20+
printf "[install]\ntrusted-host=mirrors.aliyun.com\n" >> $VIRTUAL_ENV/pip.conf
21+
22+
# add auto env
23+
pip install autoenv && echo "source `which activate.sh`" >> ~/.bashrc
24+
25+
# pip install nodeenv
26+
pip install nodeenv && nodeenv -p
27+
28+
# running node now
29+
npm config set strict-ssl false
30+
31+
echo "Now go like install some modules!"
32+
npm install && npm update

build-parent-node-venv.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# https://github.com/ES-CPP/bashnips
3+
4+
# current folder
5+
cd "${0%/*}"
6+
7+
# navigate to parent module
8+
cd ../../
9+
10+
# check requirements
11+
command -v virtualenv >/dev/null 2>&1 || { echo >&2 "I require virtualenv but it's not installed. See http://docs.python-guide.org/en/latest/dev/virtualenvs/ Aborting."; exit 1; }
12+
13+
# clear env if there
14+
if [ -e "./.venv" ] ; then
15+
# gotcha auto env!
16+
rm -rf "./.venv" && deactivate
17+
fi
18+
19+
# clear node_modules if there
20+
if [ -e "./node_modules" ] ; then
21+
rm -rf "./node_modules"
22+
fi
23+
24+
# create node env
25+
virtualenv .venv && source .venv/bin/activate
26+
27+
# Add trusted-host
28+
printf "[global]\nindex-url=http://mirrors.aliyun.com/pypi/simple/\n" >> $VIRTUAL_ENV/pip.conf
29+
printf "[install]\ntrusted-host=mirrors.aliyun.com\n" >> $VIRTUAL_ENV/pip.conf
30+
31+
# add auto env
32+
pip install autoenv && echo "source `which activate.sh`" >> ~/.bashrc
33+
34+
# pip install nodeenv
35+
pip install nodeenv && nodeenv -p
36+
37+
# running node now
38+
npm config set strict-ssl false
39+
40+
echo "Now go like install some modules!"
41+
npm install && npm update

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "build-node-venv",
3+
"version": "1.0.0",
4+
"description": "Bash helper to re-build node-venv",
5+
"main": "build-node-venv.sh",
6+
"bin": {
7+
"build-node-venv": "build-parent-node-venv.sh"
8+
},
9+
"scripts": {
10+
"env": "chmod +x ./build-node-venv.sh && ./build-node-venv.sh"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/GitBruno/build-node-venv.git"
15+
},
16+
"keywords": [
17+
"nodeenv",
18+
"python",
19+
"venv",
20+
"autoenv"
21+
],
22+
"author": "Bruno Herfst",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/GitBruno/build-node-venv/issues"
26+
},
27+
"homepage": "https://github.com/GitBruno/build-node-venv"
28+
}

test/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# test
2+
3+
A test for `build-node-venv`
4+
5+
npm run test
6+

test/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "test-build-node-venv",
3+
"version": "1.0.0",
4+
"description": "A test for build-node-env",
5+
"main": "README.md",
6+
"scripts": {
7+
"test": "npm install && build-node-venv"
8+
},
9+
"keywords": [
10+
"test"
11+
],
12+
"author": "Bruno Herfst",
13+
"license": "UNLICENSED",
14+
"dependencies": {
15+
"build-node-venv": "file:.."
16+
}
17+
}

0 commit comments

Comments
 (0)