deploy.sh
2.08 KB
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
#/bin/sh
# Ugly mix of shell and javascript to get the job done.
# Maybe it would be better to fuse all into one javascript code for node.
if [ -z $2 ]; then
cat <<_USAGE
usage: $0 dev_app_path deploy_path
$0 must be run from the base path (baseUrl) of your application
all paths must be directories and deploy_path must be empty
_USAGE
exit 1 ;
fi
if [ ! -d $1 ]; then
echo "$1 do not exist or is not a directory. Stop."
exit 1;
fi
if [ ! -e $2 ]; then
echo "$2 do not exist. Creating."
mkdir -p "$2"
else
if [ ! -d $2 ]; then
echo "$2 is not a directory. Stop"
exit 1;
fi
fi
for i in $1/*.json ;
do
DEPS=`node <<_END | sort | uniq
/* this dummy arcs_module function is here to extract dependencies of each
* component library
*/
function arcs_module() {
var i,j , arr;
for (i = 1; i < arguments.length; i++) {
arr = arguments[i];
for (j=0; j < arr.length; j++) {
if (typeof arr[j] === "string") {
console.log( arr[j] + '.js' );
} else {
if (arr[j].name !== undefined ) {
console.log( arr[j].name + '.js' );
}
}
}
}
}
/* this main code checks out if a file name arcsapp.json exists and then
* parses it and look for component libraries
*/
var j, libs, mod;
var descr = require('./$i');
if (descr.context !== undefined) {
if (descr.context.libraries !== undefined) {
libs = descr.context.libraries ;
if (libs.length !== undefined) {
for (j= 0; j < libs.length; j++) {
console.log('./' + libs[j] + ".js");
var mod = require( './' + libs[j] + ".js");
}
}
}
}
_END
`;
mkdir -p "$2/$1"
mkdir -p "$2/deps/requirejs"
cp "deps/requirejs/"* "$2/deps/requirejs"
cp -r docs "$2/"
cp -r "$1/"* "$2/$1"
mkdir "$2/build"
cp build/arcs.*js "build/arcs_browser.js" "$2/build"
for i in $DEPS; do
echo "Copying $i"
FILE="$2/"$i
#echo "$FILE"
mkdir -p "$FILE"
rmdir "$FILE";
cp "$i" "$FILE"
done
done