forked from andresamayadiaz/FrontAccountingSimpleAPI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
174 lines (153 loc) · 4.6 KB
/
gulpfile.js
File metadata and controls
174 lines (153 loc) · 4.6 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
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
var gulp = require('gulp');
var gulpSequence = require('gulp-sequence');
var gutil = require('gulp-util');
var child_process = require('child_process');
var exec2 = require('child_process').exec;
var async = require('async');
var template = require('lodash.template');
var rename = require("gulp-rename");
var execute = function(command, options, callback) {
if (options == undefined) {
options = {};
}
command = template(command, options);
if (!options.silent) {
gutil.log(gutil.colors.green(command));
}
if (!options.dryRun) {
exec2(command, function(err, stdout, stderr) {
gutil.log(stdout);
gutil.log(gutil.colors.yellow(stderr));
callback(err);
});
} else {
callback(null);
}
};
var paths = {
src: ['**/*.inc', '**/*.php', '*.php', '*.inc', 'index.php', '!vendor/**'],
testUnit: ['tests/*.php']
};
gulp.task('tasks', function(cb) {
var command = 'grep gulp\.task gulpfile.js';
execute(command, null, function(err) {
cb(null); // Swallow the error propagation so that gulp doesn't display a nodejs backtrace.
});
});
gulp.task('default', function() {
// place code for your default task here
});
gulp.task('env-files', function() {
gulp.src('tests/data/*.php')
.pipe(gulp.dest('_frontaccounting/'));
gulp.src('tests/data/company/0/*.php')
.pipe(gulp.dest('_frontaccounting/company/0/'));
gulp.src('tests/data/lang/*')
.pipe(gulp.dest('_frontaccounting/lang/'));
});
gulp.task('env-db', function(cb) {
execute(
'gunzip -c tests/data/fa_test.sql.gz | mysql -u travis --password=\'\' -D fa_test',
null,
cb
);
});
gulp.task('env-test', ['env-db'], function() {});
gulp.task('env-test-travis', ['env-db', 'env-files'], function() {});
gulp.task('test-only', function(cb) {
var command = '';
var withCoverage = false;
if (withCoverage) {
command = '/usr/bin/env php _frontaccounting/modules/api/vendor/bin/phpunit --coverage-html ./wiki/code_coverage -c _frontaccounting/modules/api/phpunit.xml';
} else {
command = '/usr/bin/env php _frontaccounting/modules/api/vendor/bin/phpunit -c _frontaccounting/modules/api/phpunit.xml';
}
execute(command, null, function(err) {
cb(err); // Don't swallow the error propagation so that gulp does display a nodejs backtrace.
});
});
/* To run the tests you first need to start the php server on port 8000.
* `sh build-startServer.sh`
* then you can run the tests
* `gulp test`
*/
gulp.task('test', gulpSequence('env-test', 'test-only'));
gulp.task('test-travis', gulpSequence('env-test-travis', 'test-only'));
gulp.task('test-watch', function() {
gulp.watch([paths.testUnit, paths.src], ['test']);
});
gulp.task('doc-swagger-json', function(cb) {
var options = {
dryRun: false,
silent: false
};
execute(
'/usr/bin/env php vendor/zircote/swagger-php/bin/swagger src/ index.php',
options,
cb
);
});
// This task builds static documentation in the public folder from the swagger.json file using spectacle
// spectacle is assumed to be globally installed on the system, e.g. sudo npm install -g spectacle-docs
// more information on the Spectacle static docs generator: https://github.com/sourcey/spectacle
gulp.task('doc-spectacle', function(cb) {
var options = {
dryRun: false,
silent: false
};
execute(
'spectacle -q swagger.json',
options,
cb
);
});
gulp.task('doc', gulpSequence('doc-swagger-json', 'doc-spectacle'));
gulp.task('doc-watch', function() {
gulp.watch(['src/*.php', '*.php'], ['doc-swagger-json']);
// gulp.watch('index.php', function() {
// console.log('boo');
// gulp.start('doc-swagger-json');
// });
});
gulp.task('package-zip', ['package-vendor'], function(cb) {
var options = {
dryRun: false,
silent: false,
src: "./",
name: "frontaccounting",
version: "2.4",
release: "-api.module.1.7"
};
execute(
'rm -f *.zip && cd <%= src %> && zip -r -x@./upload-exclude-zip.txt -y -q ./<%= name %>-<%= version %><%= release %>.zip .',
options,
cb
);
});
gulp.task('package-tar', ['package-vendor'], function(cb) {
var options = {
dryRun: false,
silent: false,
src: "./",
name: "frontaccounting",
version: "2.4",
release: "-api.module.1.7"
};
execute(
'rm -f *.tgz && cd <%= src %> && tar -cvzf ./<%= name %>-<%= version %><%= release %>.tgz -X upload-exclude.txt * .htaccess',
options,
cb
);
});
gulp.task('package-vendor', function(cb) {
var options = {
dryRun: false,
silent: false
};
execute(
'rm -rf vendor && composer install --no-dev',
options,
cb
);
});
gulp.task('package', ['package-zip', 'package-tar']);