This repository has been archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jakefile
139 lines (120 loc) · 7.43 KB
/
Jakefile
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
var path = require('path'),
fs = require('fs'),
_ = require('underscore'),
async = require('async'),
childProcess = require('child_process'),
boilerplateDir = path.join(__dirname, 'boilerplate'),
releaseDir = path.join(__dirname, 'release'),
componentsDir = path.join(__dirname, 'components'),
baseDir = path.join(__dirname, 'base'),
releases = ['standalone', 'rails', 'mobile', 'lumbar'],
components = {
thorax: '[email protected]:walmartlabs/thorax.git',
'lumbar-loader': '[email protected]:walmartlabs/lumbar-loader.git',
bootstrap: '[email protected]:twitter/bootstrap.git'
};
function exec(command) {
return function(next) {
console.log(command);
childProcess.exec(command, function(error, stdout, stderr) {
error && process.stderr.write(error.toString());
stdout && process.stdout.write(stdout.toString());
stderr && process.stderr.write(stderr.toString());
next();
});
};
}
function mkdir(dir) {
return function(next) {
console.log('mkdir ' + dir);
try {
return fs.mkdir(dir, function() {
next();
});
} catch(e) {
next();
}
}
}
function copy(from, to) {
return exec('cp -r ' + from + ' ' + to);
}
desc('Update and build the boilerplate download');
task('release', function(options) {
var thoraxSrc = (options && options[0]) || path.join(process.cwd(), '../thorax/build/release');
async.series([
// setup components
exec('rm -rf ' + componentsDir),
mkdir(componentsDir),
function(next) {
async.series(_.map(components, function(gitUrl, componentName) {
return exec('git clone ' + gitUrl + ' ' + path.join(componentsDir, componentName));
}), next);
},
// setup release directory
exec('rm -rf ' + releaseDir),
mkdir(releaseDir),
copy('README.md', path.join(releaseDir, 'README.md')),
function(next) {
async.series(_.map(releases, function(release) {
return exec('cp -r ' + path.join(boilerplateDir, release) + ' ' + path.join(releaseDir, release));
}), next);
},
// ensure directories exist in release dirs
mkdir(path.join(releaseDir, 'lumbar/js')),
mkdir(path.join(releaseDir, 'lumbar/js/lib')),
mkdir(path.join(releaseDir, 'mobile/js/lib')),
mkdir(path.join(releaseDir, 'lumbar/static/img')),
mkdir(path.join(releaseDir, 'mobile/static/img')),
mkdir(path.join(releaseDir, 'lumbar/components')),
mkdir(path.join(releaseDir, 'mobile/components')),
mkdir(path.join(releaseDir, 'standalone/js/lib')),
mkdir(path.join(releaseDir, 'rails/vendor/assets/javascripts')),
mkdir(path.join(releaseDir, 'rails/vendor/assets/stylesheets')),
// copy components to lumbar, mobile
copy(path.join(componentsDir, 'thorax'), path.join(releaseDir, 'lumbar/components/thorax')),
copy(path.join(componentsDir, 'thorax'), path.join(releaseDir, 'mobile/components/thorax')),
copy(path.join(componentsDir, 'lumbar-loader'), path.join(releaseDir, 'lumbar/components/lumbar-loader')),
copy(path.join(componentsDir, 'lumbar-loader'), path.join(releaseDir, 'mobile/components/lumbar-loader')),
// copy bootstrap assets to lumbar
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap-responsive.css'), path.join(releaseDir, 'lumbar/styles/bootstrap-responsive.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap.css'), path.join(releaseDir, 'lumbar/styles/bootstrap.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings-white.png'), path.join(releaseDir, 'lumbar/static/img/glyphicons-halflings-white.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings.png'), path.join(releaseDir, 'lumbar/static/img/glyphicons-halflings.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/js/bootstrap.js'), path.join(releaseDir, 'lumbar/js/lib/bootstrap.js')),
// copy bootstrap assets to mobile
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap-responsive.css'), path.join(releaseDir, 'mobile/styles/bootstrap-responsive.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap.css'), path.join(releaseDir, 'mobile/styles/bootstrap.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings-white.png'), path.join(releaseDir, 'mobile/static/img/glyphicons-halflings-white.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings.png'), path.join(releaseDir, 'mobile/static/img/glyphicons-halflings.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/js/bootstrap.js'), path.join(releaseDir, 'mobile/js/lib/bootstrap.js')),
// copy bootstrap assets to standalone
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap-responsive.css'), path.join(releaseDir, 'standalone/styles/bootstrap-responsive.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap.css'), path.join(releaseDir, 'standalone/styles/bootstrap.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings-white.png'), path.join(releaseDir, 'standalone/img/glyphicons-halflings-white.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings.png'), path.join(releaseDir, 'standalone/img/glyphicons-halflings.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/js/bootstrap.js'), path.join(releaseDir, 'standalone/js/lib/bootstrap.js')),
// copy bootstrap assets to rails
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap-responsive.css'), path.join(releaseDir, 'rails/vendor/assets/stylesheets/bootstrap-responsive.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/css/bootstrap.css'), path.join(releaseDir, 'rails/vendor/assets/stylesheets/bootstrap.css')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings-white.png'), path.join(releaseDir, 'rails/app/assets/images/glyphicons-halflings-white.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/img/glyphicons-halflings.png'), path.join(releaseDir, 'rails/app/assets/images/glyphicons-halflings.png')),
copy(path.join(componentsDir, 'bootstrap/docs/assets/js/bootstrap.js'), path.join(releaseDir, 'rails/vendor/assets/javascripts/bootstrap.js')),
// copy thorax assets to rails
copy(path.join(thoraxSrc, 'thorax.js'), path.join(releaseDir, 'rails/vendor/assets/javascripts/thorax.js')),
// copy thorax assets to standalone
copy(path.join(thoraxSrc, 'thorax.js'), path.join(releaseDir, 'standalone/js/lib/thorax.js')),
// note + "/" to copy / merge contents of directory
// copy base js files into lumbar, mobile
copy(path.join(baseDir, 'js'), path.join(releaseDir, 'standalone')),
copy(path.join(baseDir, 'js') + '/', path.join(releaseDir, 'mobile/js')),
copy(path.join(baseDir, 'js') + '/', path.join(releaseDir, 'lumbar/js')),
copy(path.join(baseDir, 'js') + '/', path.join(releaseDir, 'rails/app/assets/javascripts')),
// copy base templates into lumbar, mobile, rails (standalone uses inline templates)
copy(path.join(baseDir, 'templates') + '/', path.join(releaseDir, 'mobile/templates')),
copy(path.join(baseDir, 'templates') + '/', path.join(releaseDir, 'lumbar/templates')),
copy(path.join(baseDir, 'templates') + '/', path.join(releaseDir, 'rails/app/assets/javascripts/templates')),
// create a zip file of the release
exec('zip -r release.zip ' + releaseDir)
]);
});