This repository was archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 925
/
Copy pathbuild-local.sh
executable file
·204 lines (168 loc) · 5.82 KB
/
build-local.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash -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
showStatus () { printf "\e[1A\e[0K\r%s\n" $1; }
cd `dirname $0`/..
SOURCE=`pwd`
export NODE_PATH=plugins/node_modules
LOCAL=$SOURCE/local
APPDIR=$SOURCE/build/webkitbuilds/app.nw
LOCALCFG=configs/client-default-local.js
# init
rm -Rf $APPDIR
rm -Rf $SOURCE/build/webkitbuilds/releases
# copy the C9 source into the package
mkdir -p $APPDIR
mkdir -p $APPDIR/bin
mkdir -p $APPDIR/build
mkdir -p $APPDIR/configs
mkdir -p $APPDIR/plugins
mkdir -p $APPDIR/settings
mkdir -p $APPDIR/scripts
mkdir -p $APPDIR/node_modules
cp -a build/standalone $APPDIR/build
rm -Rf $APPDIR/build/standalone/static
cp -a $SOURCE/local $APPDIR
cp -a server.js $APPDIR
# bin
cp -a bin/c9 $APPDIR/bin
# configs
cp configs/standalone.js $APPDIR/configs
cp configs/local.js $APPDIR/configs
cp configs/cli.js $APPDIR/configs
cp configs/client-default.js $APPDIR/configs
cp configs/client-default-local.js $APPDIR/configs
# settings
cp settings/standalone.js $APPDIR/settings
cp settings/local.js $APPDIR/settings
# scripts
cp -a scripts/makest* $APPDIR/scripts
cp -a scripts/install-nw-pty.sh $APPDIR/scripts
cp -a scripts/checkforupdates.sh $APPDIR/scripts
node -e "
var fs = require('fs');
var path = require('path');
var copy = require('architect-build/copy');
function pluginDirs(plugins) {
var map = Object.create(null);
plugins.forEach(function(p) {
p = p.packagePath || p;
if (typeof p === 'string')
map[path.dirname(p)] = 1;
});
return Object.keys(map);
}
console.log('Client Plugins:');
var plugins = require('./configs/client-default-local')(require('./settings/local')());
// this isn't included in local config but is needed for loading remote projects
plugins.push('plugins/c9.ide.collab/collab');
copy.dirs('$SOURCE', '$APPDIR', pluginDirs(plugins), {
include: /^(libmarkdown.js|loading.css|runners_list.js|builders_list.js)$/,
exclude: /\\.(js|css|less|xml)$|^mock$/,
onDir: function(e) { console.log('\x1b[1A\x1b[0K' + e) }
});
console.log('CLI Plugins:');
plugins = require('./configs/cli')().concat('plugins/c9.login.client/bootstrap')
copy.dirs('$SOURCE', '$APPDIR', pluginDirs(plugins), {
exclude: /^mock$/,
});
console.log('Node Modules:');
require('architect-build/npm_build')({
root: '.',
dest: './build/webkitbuilds/app.nw',
args: ['local','-s', 'local'],
ignore: /^(pty.js)$/
}, function(err, result) {
var deps = result.roots;
// add client plugins
deps.push('node_modules/rusha', 'node_modules/nak');
deps = deps.filter(function(x){
if (!require('fs').statSync(x).isDirectory())
return false;
return true;
});
copy.dirs('$SOURCE', '$APPDIR', deps, {
include: null,
exclude: /^(mock|tests?|examples?|samples|Readme.*|build|dist|LICENSE|\\.(idea|grunt|jshintrc|npmignore|gitignore|travis.yml))\$|_test\\.js/i
});
});
console.log('local:');
['index.html', 'projectManager.html'].forEach(function(p) {
copy.file('$LOCAL/' + p, '$APPDIR/local/' + p, function(source) {
return source.replace(/\/[/*]::dev:(:.*|{[\s\S]*?\/[/*]::dev:}.*)/g, '');
});
});
"
# copy the local package json to the root
node -e "p=require('./local/package.json'); p.name = 'Cloud9'; p.main = 'local/projectManager.html'; p.revision = '$(git rev-parse HEAD)'; console.log(JSON.stringify(p, null, 2));" > $APPDIR/package.json
# remove unneeded files
rm $APPDIR/plugins/c9.vfs.server/vfs.connect.hosted*
rm $APPDIR/plugins/c9.vfs.server/last_access.js
rm $APPDIR/plugins/c9.vfs.server/registry.js
cp $SOURCE/plugins/c9.connect.favicon/favicon.ico $APPDIR
# remove debug symbols
cat $LOCALCFG | sed "s/options.debug *= .*/options.debug = false/" > $APPDIR/$LOCALCFG
cat $SOURCE/settings/local.js | sed "s/config.packed = false;/config.dev = false;config.packed = true;/" > $APPDIR/settings/local.js
# set version
date +%s > $APPDIR/version
# set nw version
NWVERSION=0.9.3
echo $NWVERSION > $APPDIR/nwversion
if [ "$COMPRESS" ]; then
if [ "$OBFUSCATE" ]; then
OPTS="{ obfuscate: true }"
else
OPTS="{}"
fi
node -e "require('architect-build/compress_folder')('$APPDIR', '$OPTS')"
fi
if [[ $os == "windows" ]]; then
echo done!
elif [ $os == "darwin" ]; then
if [ ! -d $SOURCE/build/webkitbuilds/cache/mac/$NWVERSION ]; then
mkdir -p $SOURCE/build/webkitbuilds/cache/mac/$NWVERSION/node-webkit.app
pushd $SOURCE/build/webkitbuilds/cache/mac/$NWVERSION
curl -O http://dl.node-webkit.org/v$NWVERSION/node-webkit-v$NWVERSION-pre8-osx-ia32.zip
unzip node-webkit-v$NWVERSION-pre8-osx-ia32.zip
popd
fi
DEST="$SOURCE/build/webkitbuilds/releases/Cloud9/mac/Cloud9.app"
RES="$DEST/Contents/Resources"
rm -rf "$DEST"
mkdir -p "$RES"
cp -R $SOURCE/build/webkitbuilds/cache/mac/$NWVERSION/node-webkit.app/* $DEST
cp -R "$SOURCE/build/webkitbuilds/app.nw" "$RES"
# copy Infoplist
cat $SOURCE/local/Info.plist > $DEST/Contents/Info.plist
# copy icons
rm $DEST/Contents/Resources/nw.icns
cp $SOURCE/build/osx/c9.icns $DEST/Contents/Resources/nw.icns
# make cli executable
chmod +x $RES/app.nw/bin/c9
else
echo TODO
fi