This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
/
setup-local-dev.sh
executable file
·165 lines (138 loc) · 5.02 KB
/
setup-local-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash -e
set -e
while [ "$1" ]; do
case "$1" in
--compress) COMPRESS=1 ;;
--obfuscate) OBFUSCATE=1 ;;
*) echo "Unknown option: $1" >&2; exit 1 ;;
esac
shift
done
uname="$(uname -a)"
os=
arch="$(uname -m)"
case "$uname" in
Linux\ *) os=linux ;;
Darwin\ *) os=darwin ;;
SunOS\ *) os=sunos ;;
FreeBSD\ *) os=freebsd ;;
CYGWIN*) os=windows ;;
MINGW*) os=windows ;;
MSYS_NT*) os=windows ;;
esac
case "$uname" in
*x86_64*) arch=x64 ;;
*i*86*) arch=x86 ;;
*armv6l*) arch=arm-pi ;;
*armv7l*) arch=arm-pi ;;
esac
PATH=$HOME/.c9/node/bin:$PATH
cd "$(dirname "$0")/.."
SOURCE="$(pwd)"
if [ "$os" == "linux" ]; then
if [ ! -d "$SOURCE"/build/webkitbuilds/cache/linux/0.12.3 ]; then
mkdir -p "$SOURCE"/build/webkitbuilds/cache/linux/0.12.3/
pushd "$SOURCE"/build/webkitbuilds/cache/linux/0.12.3
wget http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz
tar -zxf nwjs-v0.12.3-linux-x64.tar.gz
popd
fi
DEST="$SOURCE/build/Cloud9-dev-linux"
rm -rf "$DEST"
mkdir -p "$DEST"
cp -R "$SOURCE"/build/webkitbuilds/cache/linux/0.12.3/nwjs-v0.12.3-linux-x64/* "$DEST"
cp "$SOURCE"/build/linux/c9.png "$DEST"/icon.png
node --eval "
var path = require('path')
var p = require('./local/package.json');
p.main = path.relative('$DEST', '$SOURCE/local/projectManager.html');
delete p.dependencies;
p.window.icon = 'icon.png';
console.log(JSON.stringify(p, null, 2));
" > "$DEST"/package.json
fi
if [ "$os" == "darwin" ]; then
if [ ! -d "$SOURCE"/build/webkitbuilds/cache/mac/0.9.3 ]; then
mkdir -p "$SOURCE"/build/webkitbuilds/cache/mac/0.9.3/node-webkit.app
pushd "$SOURCE"/build/webkitbuilds/cache/mac/0.9.3
curl -OL http://dl.node-webkit.org/v0.9.3/node-webkit-v0.9.3-pre8-osx-ia32.zip
unzip node-webkit-v0.9.3-pre8-osx-ia32.zip
popd
fi
DEST="$SOURCE/build/Cloud9-dev.app"
RES="$DEST/Contents/Resources"
rm -rf "$DEST"
mkdir -p "$RES/app.nw"
cp -R "$SOURCE"/build/webkitbuilds/cache/mac/0.9.3/node-webkit.app/* "$DEST"
cat "$SOURCE"/local/Info.plist | sed "s/Cloud9/Cloud9-dev/" > "$DEST"/Contents/Info.plist
# TODO add blue icon for dev mode
# rm $DEST/Contents/Resources/nw.icns
cp "$SOURCE"/build/osx/c9.icns "$DEST"/Contents/Resources/nw.icns
node --eval "
var path = require('path')
var p = require('./local/package.json');
p.main = path.relative('$RES/app.nw', '$SOURCE/local/projectManager.html');
delete p.dependencies;
// p.window.icon = 'icon.png';
console.log(JSON.stringify(p, null, 2));
" > "$RES"/app.nw/package.json
echo dev app created in build/Cloud9-dev.app/Contents/MacOS/node-webkit
fi
if [ "$os" == "windows" ]; then
NW_VERSION=v0.12.2
# TODO find a more reliable place to put c9 dependencies
HOME="$HOMEDRIVE$HOMEPATH"
pushd build
if [ ! -f "$HOME/.c9/"node.exe ] || [ ! -d "$HOME/.c9/"msys ]; then
echo "downloading node"
pushd "$HOME/.c9/"
curl -L https://raw.githubusercontent.com/cloud9ide/sdk-deps-win32/master/install.sh | bash
# bash $SOURCE/../sdk-deps-win32/install.sh # for testing
popd
fi
NW_FILE_NAME=nwjs-$NW_VERSION-win-ia32
if [ ! -f $NW_FILE_NAME.zip ]; then
echo "downloading node-webkit"
curl -OL http://dl.nwjs.io/$NW_VERSION/$NW_FILE_NAME.zip
fi
dest=win32-dev/bin
mkdir -p $dest
unzip -uo $NW_FILE_NAME.zip -d win32-dev
rm -rf $dest
mv win32-dev/$NW_FILE_NAME $dest
# cp node.exe $dest
mv $dest/nw.exe $dest/Cloud9.exe
cp win32/icon.png $dest
# cp -Rf win32/deps win32/bin/deps
node --eval '
var p=require("../local/package.json");
p.main = "../../../local/projectManager.html";
delete p.dependencies;
p.window.icon = "icon.png";
console.log(JSON.stringify(p, null, 2));
' > $dest/package.json
popd
# create shortcuts
echo '
var WshShell = WScript.CreateObject("WScript.Shell");
var strDesktop = WshShell.SpecialFolders("Desktop");
var cwd = WScript.ScriptFullName.replace(/\\[^\\]+$/, "");
var link1 = WshShell.CreateShortcut(cwd + "\\Cloud9#.lnk");
link1.TargetPath = cwd + "\\build\\win32-dev\\bin\\Cloud9.exe";
link1.IconLocation = cwd + "\\build\\win32\\Cloud9.ico";
link1.Description = "Cloud9";
link1.WorkingDirectory = cwd;
link1.Save();
var link2 = WshShell.CreateShortcut(cwd + "\\Cloud9#packed.lnk");
link2.TargetPath = link1.TargetPath;
link2.Arguments = "--packed --no-devtools";
link2.IconLocation = link1.IconLocation;
link2.Description = "Cloud9";
link2.WorkingDirectory = cwd;
link2.Save();
' > ./shortcut.wscript.js
cscript //NoLogo //B //E:jscript ./shortcut.wscript.js
rm -f ./shortcut.wscript.js
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
bash "$current_dir/makelocal.sh"
fi