total5 0.0.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/503.html +65 -0
- package/CONTRIBUTING.md +55 -0
- package/LICENSE +211 -0
- package/README.md +32 -0
- package/api.js +289 -0
- package/bin/total5 +984 -0
- package/builders.js +1435 -0
- package/bundles.js +457 -0
- package/cache.js +58 -0
- package/changelog.txt +3 -0
- package/cluster.js +320 -0
- package/cms.js +625 -0
- package/controller.js +1419 -0
- package/cron.js +99 -0
- package/debug.js +539 -0
- package/edit.js +469 -0
- package/error.html +49 -0
- package/filestorage.js +1088 -0
- package/flow-flowstream.js +3152 -0
- package/flow.js +209 -0
- package/flowstream.js +1991 -0
- package/global.js +125 -0
- package/helpers/index.js +32 -0
- package/htmlparser.js +650 -0
- package/http.js +81 -0
- package/image.js +773 -0
- package/images.js +747 -0
- package/index.js +2658 -0
- package/jsonschema.js +691 -0
- package/ldap.js +792 -0
- package/mail.js +936 -0
- package/minificators.js +858 -0
- package/nosql-builder.js +440 -0
- package/nosql-querybuilder.js +316 -0
- package/nosql-reader.js +353 -0
- package/nosql-stream.js +617 -0
- package/nosql.js +763 -0
- package/openclient.js +219 -0
- package/package.json +32 -0
- package/pause.html +67 -0
- package/querybuilder.js +1361 -0
- package/release.js +167 -0
- package/routing.js +905 -0
- package/sourcemap.js +160 -0
- package/tangular.js +409 -0
- package/templates.js +145 -0
- package/templates.json +74 -0
- package/tms.js +384 -0
- package/tmsclient.js +125 -0
- package/todo.txt +7 -0
- package/tools/beta.sh +6 -0
- package/tools/release.sh +6 -0
- package/uibuilder.js +206 -0
- package/utils.js +6374 -0
- package/viewengine.js +880 -0
- package/websocket.js +1939 -0
- package/workers.js +129 -0
package/bin/total5
ADDED
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('total5');
|
|
4
|
+
|
|
5
|
+
const Internal = require('total4/internal');
|
|
6
|
+
var $type = 0;
|
|
7
|
+
var isDirectory = false;
|
|
8
|
+
|
|
9
|
+
function display_help() {
|
|
10
|
+
log_title('Help');
|
|
11
|
+
|
|
12
|
+
console.log('create <template> <path> : Download template from "total4 templates" list. Default path is "./<template>". Requires git.');
|
|
13
|
+
console.log('templates : List of all Total.js templates');
|
|
14
|
+
console.log('translate : Creates a resource file with the localized text from views');
|
|
15
|
+
console.log('translate "TEXT" : Creates an identificator for the resource');
|
|
16
|
+
console.log('translate <filename> : Parses and creates a resource file from the text file');
|
|
17
|
+
console.log('translatecsv : Parses and creates CSV with localization in the current directory');
|
|
18
|
+
console.log('csv <filename> : Parses CSV and creates resources from CSV file');
|
|
19
|
+
console.log('diff <source> <target> : Creates differences between two resources');
|
|
20
|
+
console.log('merge <source> <target> : Merges first resource into the second');
|
|
21
|
+
console.log('clean <source> : Cleans a resource file "total4 clean source"');
|
|
22
|
+
console.log('minify <filename> : Minifies .js, .css or .html file into filename.min.<extension>');
|
|
23
|
+
console.log('bundle <filename> : Makes a bundle from the current directory');
|
|
24
|
+
console.log('package <filename> : Makes a package from the current directory');
|
|
25
|
+
console.log('extract <filename> : Extracts a bundle/package');
|
|
26
|
+
console.log('help : List all total4 commands');
|
|
27
|
+
console.log('8000 : Starts a server on port "8000"');
|
|
28
|
+
console.log('edit <url?id=project> : Synchronizes the current directory with the Total.js Code Editor');
|
|
29
|
+
console.log('');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function log_title(title) {
|
|
33
|
+
var line = title + ': ';
|
|
34
|
+
|
|
35
|
+
var underline = '';
|
|
36
|
+
for (var i = 0; i < line.length - 1; i++)
|
|
37
|
+
underline += '╍';
|
|
38
|
+
|
|
39
|
+
console.log(line);
|
|
40
|
+
console.log(underline);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function log_error(error) {
|
|
44
|
+
console.log(' ⬢ [ERROR]: ' + error + ' ⬢');
|
|
45
|
+
console.log('');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function translateFile(a) {
|
|
49
|
+
|
|
50
|
+
if (!F.Fs.existsSync(a))
|
|
51
|
+
return false;
|
|
52
|
+
|
|
53
|
+
var arr = F.Fs.readFileSync(a).toString('utf8').split('\n');
|
|
54
|
+
var builder = [];
|
|
55
|
+
var count = 0;
|
|
56
|
+
|
|
57
|
+
for (var i = 0, length = arr.length; i < length; i++) {
|
|
58
|
+
var line = arr[i].trim();
|
|
59
|
+
if (line.length) {
|
|
60
|
+
builder.push('T' + HASH(line, true).toString(36).padRight(17, ' ') + ': ' + line);
|
|
61
|
+
count++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
F.Fs.writeFileSync('translate.resource', '// Total.js translation file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + builder.join('\n'));
|
|
66
|
+
console.log('Translation has been created successfully (' + count + ' texts)');
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function diff(a, b) {
|
|
71
|
+
|
|
72
|
+
if (!F.Fs.existsSync(a)) {
|
|
73
|
+
console.log('Translation file does not exist: ' + a);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!F.Fs.existsSync(b)) {
|
|
78
|
+
console.log('Translation file does not exist: ' + b);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var ba = F.Fs.readFileSync(a).toString('utf8');
|
|
83
|
+
var bb = F.Fs.readFileSync(b).toString('utf8');
|
|
84
|
+
var ca = ba.parseConfig();
|
|
85
|
+
var cb = bb.parseConfig();
|
|
86
|
+
var ka = Object.keys(ca);
|
|
87
|
+
var kb = Object.keys(cb);
|
|
88
|
+
|
|
89
|
+
ba = ba.split('\n');
|
|
90
|
+
bb = bb.split('\n');
|
|
91
|
+
|
|
92
|
+
var output = '';
|
|
93
|
+
var items = [];
|
|
94
|
+
var add = 0;
|
|
95
|
+
var rem = 0;
|
|
96
|
+
var padding = 0;
|
|
97
|
+
|
|
98
|
+
for (var i = 0, length = ba.length; i < length; i++) {
|
|
99
|
+
if (ba[i].indexOf(ka[0]) !== -1) {
|
|
100
|
+
padding = ba[i].indexOf(':');
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (padding <= 0)
|
|
106
|
+
padding = 17;
|
|
107
|
+
|
|
108
|
+
function find_comment(arr, id) {
|
|
109
|
+
var comment = '';
|
|
110
|
+
for (var i = 0, length = arr.length; i < length; i++) {
|
|
111
|
+
if (arr[i].indexOf(id) !== -1)
|
|
112
|
+
return comment;
|
|
113
|
+
var line = arr[i];
|
|
114
|
+
if (line[0] !== '/' && line[1] !== '/')
|
|
115
|
+
continue;
|
|
116
|
+
comment = line;
|
|
117
|
+
}
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var comment = '';
|
|
122
|
+
var prev = '';
|
|
123
|
+
|
|
124
|
+
for (var i = 0, length = ka.length; i < length; i++) {
|
|
125
|
+
var key = ka[i];
|
|
126
|
+
|
|
127
|
+
if (cb[key] !== undefined)
|
|
128
|
+
continue;
|
|
129
|
+
|
|
130
|
+
comment = find_comment(ba, key);
|
|
131
|
+
|
|
132
|
+
if (comment) {
|
|
133
|
+
if (items[items.length - 1] !== '')
|
|
134
|
+
items.push('');
|
|
135
|
+
items.push(comment);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var empty = comment === prev;
|
|
139
|
+
|
|
140
|
+
prev = comment;
|
|
141
|
+
items.push(key.padRight(padding) + ': ' + ca[key]);
|
|
142
|
+
|
|
143
|
+
if (!empty)
|
|
144
|
+
items.push('');
|
|
145
|
+
|
|
146
|
+
add++;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (items.length > 0) {
|
|
150
|
+
output += '\n';
|
|
151
|
+
output += 'Add to "' + b + '" these:\n';
|
|
152
|
+
output += '\n';
|
|
153
|
+
output += items.join('\n');
|
|
154
|
+
output += '\n';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
items = [];
|
|
158
|
+
|
|
159
|
+
for (var i = 0, length = kb.length; i < length; i++) {
|
|
160
|
+
var key = kb[i];
|
|
161
|
+
|
|
162
|
+
if (ca[key] !== undefined)
|
|
163
|
+
continue;
|
|
164
|
+
|
|
165
|
+
comment = find_comment(bb, key);
|
|
166
|
+
|
|
167
|
+
if (comment) {
|
|
168
|
+
if (items[items.length - 1] !== '')
|
|
169
|
+
items.push('');
|
|
170
|
+
items.push(comment);
|
|
171
|
+
}
|
|
172
|
+
else if (prev !== '')
|
|
173
|
+
items.push('');
|
|
174
|
+
|
|
175
|
+
var empty = comment === prev;
|
|
176
|
+
|
|
177
|
+
prev = comment;
|
|
178
|
+
items.push(key.padRight(padding) + ': ' + cb[key]);
|
|
179
|
+
|
|
180
|
+
if (!empty)
|
|
181
|
+
items.push('');
|
|
182
|
+
|
|
183
|
+
rem++;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (items.length) {
|
|
187
|
+
output += '\n';
|
|
188
|
+
output += 'Remove from "' + b + '" these:\n';
|
|
189
|
+
output += '\n';
|
|
190
|
+
output += items.join('\n');
|
|
191
|
+
output += '\n';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var filename = F.Path.join(F.Path.dirname(b), F.Path.basename(b, '.resource') + '-diff.txt');
|
|
195
|
+
F.Fs.writeFileSync(filename, '// Total.js diff file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + clean_resource(output));
|
|
196
|
+
log_title('Translation differences:');
|
|
197
|
+
console.log('');
|
|
198
|
+
console.log('Add : ' + add);
|
|
199
|
+
console.log('Rem : ' + rem);
|
|
200
|
+
console.log('Output : ' + filename);
|
|
201
|
+
console.log('');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function merge(a, b) {
|
|
205
|
+
|
|
206
|
+
if (!F.Fs.existsSync(a)) {
|
|
207
|
+
log_error('Translation file does not exist: ' + a);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!F.Fs.existsSync(b)) {
|
|
212
|
+
log_error('Translation file does not exist: ' + b);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var ba = F.Fs.readFileSync(b).toString('utf8');
|
|
217
|
+
var bb = F.Fs.readFileSync(a).toString('utf8');
|
|
218
|
+
var arr = ba.split('\n');
|
|
219
|
+
var output = [];
|
|
220
|
+
var cb = bb.parseConfig();
|
|
221
|
+
var upd = 0;
|
|
222
|
+
|
|
223
|
+
for (var i = 0, length = arr.length; i < length; i++) {
|
|
224
|
+
|
|
225
|
+
var line = arr[i];
|
|
226
|
+
if (!line || line[0] === '#' || line.startsWith('//')) {
|
|
227
|
+
output.push(line);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
var index = line.indexOf(' :');
|
|
232
|
+
if (index === -1) {
|
|
233
|
+
index = line.indexOf('\t:');
|
|
234
|
+
if (index === -1) {
|
|
235
|
+
output.push(line);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
var key = line.substring(0, index).trim();
|
|
241
|
+
var val = cb[key];
|
|
242
|
+
if (!val) {
|
|
243
|
+
output.push(line);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
upd++;
|
|
248
|
+
output.push(key.padRight(index) + ' : ' + val);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var filename = F.Path.join(F.Path.dirname(b), F.Path.basename(b, '.resource') + '-merged.txt');
|
|
252
|
+
F.Fs.writeFileSync(filename, '// Total.js merged file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + clean_resource(output.join('\n')));
|
|
253
|
+
log_title('Merged result:');
|
|
254
|
+
console.log('');
|
|
255
|
+
console.log('Merged : ' + upd);
|
|
256
|
+
console.log('Output : ' + filename);
|
|
257
|
+
console.log('');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function clean_resource(content) {
|
|
261
|
+
var lines = content.split('\n');
|
|
262
|
+
var output = [];
|
|
263
|
+
var max = 0;
|
|
264
|
+
|
|
265
|
+
for (var i = 0, length = lines.length; i < length; i++) {
|
|
266
|
+
var line = lines[i];
|
|
267
|
+
if (!line || line[0] === '#' || line.startsWith('//'))
|
|
268
|
+
continue;
|
|
269
|
+
|
|
270
|
+
var index = line.indexOf(' :');
|
|
271
|
+
if (index === -1) {
|
|
272
|
+
index = line.indexOf('\t:');
|
|
273
|
+
if (index === -1)
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
max = Math.max(max, index);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
for (var i = 0, length = lines.length; i < length; i++) {
|
|
281
|
+
var line = lines[i];
|
|
282
|
+
if (!line || line[0] === '#' || line.startsWith('//')) {
|
|
283
|
+
output.push(line);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
var index = line.indexOf(' :');
|
|
288
|
+
if (index === -1) {
|
|
289
|
+
index = line.indexOf('\t:');
|
|
290
|
+
if (index === -1) {
|
|
291
|
+
output.push(line);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
var key = line.substring(0, index).trim();
|
|
297
|
+
output.push(key.padRight(max, ' ') + ' : ' + line.substring(index + 2).trim());
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return output.join('\n');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function convert4(a) {
|
|
304
|
+
|
|
305
|
+
if (!F.Fs.existsSync(a)) {
|
|
306
|
+
log_error('Translation file does not exist: ' + a);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
var body = F.Fs.readFileSync(a).toString('utf8');
|
|
311
|
+
var output = [];
|
|
312
|
+
|
|
313
|
+
var lines = body.split('\n');
|
|
314
|
+
for (var i = 0; i < lines.length; i++) {
|
|
315
|
+
var line = lines[i];
|
|
316
|
+
var index = line.indexOf(' :');
|
|
317
|
+
if (index === -1) {
|
|
318
|
+
index = line.indexOf('\t:');
|
|
319
|
+
if (index === -1) {
|
|
320
|
+
output.push(line);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var key = line.substring(0, index).trim();
|
|
326
|
+
|
|
327
|
+
if (key[0] !== 'T') {
|
|
328
|
+
output.push(line);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (key[1] === '-')
|
|
333
|
+
key = 'T' + ((+key.substring(1)) >>> 0).toString(36);
|
|
334
|
+
else
|
|
335
|
+
key = 'T' + (+key.substring(1)).toString(36);
|
|
336
|
+
|
|
337
|
+
output.push(key.padRight(index, ' ') + ' : ' + line.substring(index + 2).trim());
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
var filename = a.replace('.', '-new.');
|
|
341
|
+
F.Fs.writeFileSync(filename, clean_resource(output.join('\n')));
|
|
342
|
+
log_title('Converted:');
|
|
343
|
+
console.log('');
|
|
344
|
+
console.log('Output : ' + filename);
|
|
345
|
+
console.log('');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function parse_csv(content) {
|
|
349
|
+
|
|
350
|
+
var output = {};
|
|
351
|
+
var max = 0;
|
|
352
|
+
var csv = content.parseCSV(';');
|
|
353
|
+
|
|
354
|
+
for (var i = 1; i < csv.length; i++) {
|
|
355
|
+
var line = csv[i];
|
|
356
|
+
var key = line.a || '';
|
|
357
|
+
var val = line.b || '';
|
|
358
|
+
if (key) {
|
|
359
|
+
max = Math.max(key.length, max);
|
|
360
|
+
output[key] = val;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var builder = [];
|
|
365
|
+
max += 10;
|
|
366
|
+
|
|
367
|
+
Object.keys(output).forEach(function(key) {
|
|
368
|
+
builder.push('{0}: {1}'.format(key.padRight(max, ' '), output[key]));
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
return '\n' + builder.join('\n');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function main() {
|
|
375
|
+
|
|
376
|
+
console.log('');
|
|
377
|
+
console.log('╔──────────────────────────────────────────────────╗');
|
|
378
|
+
console.log('│ ⬢ Total.js - www.totaljs.com │');
|
|
379
|
+
console.log('│ ⬡ Version: v' + F.version_header.padRight(37) + '│');
|
|
380
|
+
console.log('╚──────────────────────────────────────────────────╝');
|
|
381
|
+
console.log('');
|
|
382
|
+
|
|
383
|
+
var dir = process.cwd();
|
|
384
|
+
|
|
385
|
+
for (var i = 2; i < process.argv.length; i++) {
|
|
386
|
+
var arg = process.argv[i];
|
|
387
|
+
var cmd = arg.toLowerCase();
|
|
388
|
+
|
|
389
|
+
if (cmd.substring(0, 2) === '--')
|
|
390
|
+
cmd = cmd.substring(1);
|
|
391
|
+
|
|
392
|
+
if (i === 2) {
|
|
393
|
+
var port = cmd.parseInt();
|
|
394
|
+
if (port) {
|
|
395
|
+
|
|
396
|
+
CONF.$dirtmp = F.Path.join(F.Os.tmpdir(), 'total' + dir.makeid());
|
|
397
|
+
CONF.$dirpublic = dir;
|
|
398
|
+
CONF.$minifyjs = false;
|
|
399
|
+
CONF.$minifycss = false;
|
|
400
|
+
CONF.$minifyhtml = false;
|
|
401
|
+
|
|
402
|
+
F.directory = dir;
|
|
403
|
+
F.http('debug', { port: port });
|
|
404
|
+
|
|
405
|
+
ROUTE('GET /*', function() {
|
|
406
|
+
|
|
407
|
+
var self = this;
|
|
408
|
+
var dir = PATH.public(self.url.substring(1));
|
|
409
|
+
var filename = F.Path.join(self.url, 'index.html').substring(1);
|
|
410
|
+
|
|
411
|
+
PATH.exists(filename, function(e) {
|
|
412
|
+
|
|
413
|
+
if (e)
|
|
414
|
+
return self.file(filename, '');
|
|
415
|
+
|
|
416
|
+
F.Fs.readdir(dir, function(err, items) {
|
|
417
|
+
|
|
418
|
+
var render = function(controller, directories, files) {
|
|
419
|
+
controller.content('<!DOCTYPE html><html><head><title>Directory listing: {0}</title><meta charset="utf-8" /><style>body{font-family:Arial;font-size:16px;padding:10px 30px 30px}a{display:block}.directory:last-child{margin-bottom:10px}.directory{padding:2px 10px;background-color:#F8F8F8;margin-bottom:2px;text-decoration:none;color:black;font-weight:bold;font-size:18px}.directory-back{text-decoration:none;font-size:50px;margin:0 0 10px 5px;color:gray}.file{color:gray;text-decoration:none;font-size:14px;padding:3px 10px;border-bottom:1px solid #F0F0F0;}.file span{float:right;font-size:12px;margin:2px 0 0 0;color:#A0A0A0}.file:hover{background-color:#F8F8F8}</style></head><body><div class="directories">{1}</div><div class="files">{2}</div></body></html>'.format(controller.url, directories.join(''), files.join('')), 'text/html');
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
var directories = [];
|
|
423
|
+
var files = [];
|
|
424
|
+
|
|
425
|
+
if (self.url !== '/')
|
|
426
|
+
directories.push('<a href=".." class="directory-back">..</a>');
|
|
427
|
+
|
|
428
|
+
if (err)
|
|
429
|
+
return render(self, directories, files);
|
|
430
|
+
|
|
431
|
+
items.wait(function(item, next) {
|
|
432
|
+
var filename = F.Path.join(dir, item);
|
|
433
|
+
F.Fs.stat(filename, function(err, info) {
|
|
434
|
+
|
|
435
|
+
if (info.isFile())
|
|
436
|
+
files.push('<a href="{1}" class="file">{0}<span>{2}</span></a>'.format(item, self.url + item, info.size.filesize()));
|
|
437
|
+
else
|
|
438
|
+
directories.push('<a href="{1}/" class="directory">{0}</a>'.format(item, self.url + item));
|
|
439
|
+
|
|
440
|
+
next();
|
|
441
|
+
});
|
|
442
|
+
}, () => render(self, directories, files));
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (!$type && (cmd === '-v' || cmd === '-version' || cmd === 'version'))
|
|
452
|
+
return;
|
|
453
|
+
|
|
454
|
+
if (!$type && (cmd === '-e' || cmd === '-edit' || cmd === 'edit')) {
|
|
455
|
+
F.dir(dir);
|
|
456
|
+
console.log('Directory: ' + F.directory);
|
|
457
|
+
require('../edit').init(process.argv[i + 1]);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (!$type && (cmd === '-t' || cmd === '-translate' || cmd === 'translate')) {
|
|
462
|
+
$type = 4;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (!$type && (cmd === '-merge' || cmd === 'merge')) {
|
|
467
|
+
merge(process.argv[i + 1] || '', process.argv[i + 2] || '');
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (!$type && (cmd === '-translatecsv' || cmd === '-c' || cmd === 'translatecsv')) {
|
|
472
|
+
$type = 6;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (!$type && (cmd === '-translate4' || cmd === '-4' || cmd === 'translate4')) {
|
|
477
|
+
convert4(process.argv[i + 1] || '');
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (!$type && (cmd === '-csv' || cmd === 'csv')) {
|
|
482
|
+
var tmp = process.argv[i + 1] || '';
|
|
483
|
+
var tt = F.Path.join(F.Path.dirname(tmp), F.Path.basename(tmp, '.csv') + '.resource');
|
|
484
|
+
F.Fs.writeFileSync(tt, '// Total.js resource file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + parse_csv(F.Fs.readFileSync(tmp).toString('utf8')));
|
|
485
|
+
log_title('Parsed CSV:');
|
|
486
|
+
console.log('');
|
|
487
|
+
console.log('Output : ' + tt);
|
|
488
|
+
console.log('');
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (cmd === '-minify' || cmd === '-compress' || cmd === '-compile' || cmd === 'minify') {
|
|
493
|
+
$type = 5;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (!$type && (cmd === '-clean' || cmd === 'clean')) {
|
|
498
|
+
var tmp = process.argv[i + 1] || '';
|
|
499
|
+
var tt = F.Path.join(F.Path.dirname(tmp), F.Path.basename(tmp, '.resource') + '-cleaned.txt');
|
|
500
|
+
F.Fs.writeFileSync(tt, '// Total.js cleaned file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + clean_resource(F.Fs.readFileSync(tmp).toString('utf8')));
|
|
501
|
+
log_title('Cleaned result:');
|
|
502
|
+
console.log('');
|
|
503
|
+
console.log('Output : ' + tt);
|
|
504
|
+
console.log('');
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!$type && (cmd === '-extract' || cmd === 'extract')) {
|
|
509
|
+
restorebundle(dir, process.argv[i + 1] || '');
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (!$type && (cmd === '-bundle' || cmd === 'bundle')) {
|
|
514
|
+
makebundle(dir, process.argv[i + 1] || '');
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (!$type && (cmd === '-package' || cmd === 'package')) {
|
|
519
|
+
makepackage(dir, process.argv[i + 1] || '');
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (!$type && (cmd === '-diff' || cmd === 'diff')) {
|
|
524
|
+
diff(process.argv[i + 1] || '', process.argv[i + 2] || '');
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (!$type && (cmd === '-h' || cmd === 'h' || cmd === '-help' || cmd === 'help')) {
|
|
529
|
+
display_help();
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (cmd === '-templates' || cmd === 'templates') {
|
|
534
|
+
$type = 7;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (cmd === 'create' || cmd === '-create' || cmd === 'template' || cmd === '-template' || cmd === 'download' || cmd === 'download') {
|
|
539
|
+
$type = 8;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
dir = arg;
|
|
544
|
+
isDirectory = true;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (!$type)
|
|
548
|
+
$type = 1;
|
|
549
|
+
|
|
550
|
+
if (dir === '.')
|
|
551
|
+
dir = process.cwd();
|
|
552
|
+
|
|
553
|
+
if ($type === 5) {
|
|
554
|
+
|
|
555
|
+
dir = F.Path.join(dir, process.argv.last());
|
|
556
|
+
|
|
557
|
+
if (!F.Fs.existsSync(dir)) {
|
|
558
|
+
log_error('File not found');
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
var content = F.Fs.readFileSync(dir).toString('utf8');
|
|
563
|
+
var extension = U.getExtension(dir);
|
|
564
|
+
var filename = dir.replace('.' + extension, '.min.' + extension);
|
|
565
|
+
|
|
566
|
+
switch (extension.toLowerCase()) {
|
|
567
|
+
case 'html':
|
|
568
|
+
F.Fs.writeFileSync(filename, U.minify_html(content));
|
|
569
|
+
break;
|
|
570
|
+
case 'js':
|
|
571
|
+
F.Fs.writeFileSync(filename, U.minify_js(content));
|
|
572
|
+
break;
|
|
573
|
+
case 'css':
|
|
574
|
+
F.Fs.writeFileSync(filename, U.minify_css(content));
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
console.log('Minified: ' + filename);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if ($type === 4) {
|
|
583
|
+
|
|
584
|
+
log_title('Creating of translation');
|
|
585
|
+
|
|
586
|
+
if (isDirectory) {
|
|
587
|
+
if (translateFile(dir))
|
|
588
|
+
return;
|
|
589
|
+
console.log('T' + dir.hash(true).toString(36).padRight(17, ' ') + ': ' + dir);
|
|
590
|
+
console.log('');
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (!F.Fs.existsSync(dir)) {
|
|
595
|
+
log_error('Directory does not exist');
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
U.ls(dir, function(files) {
|
|
600
|
+
|
|
601
|
+
var resource = {};
|
|
602
|
+
var texts = {};
|
|
603
|
+
var max = 0;
|
|
604
|
+
var count = 0;
|
|
605
|
+
var key;
|
|
606
|
+
var file;
|
|
607
|
+
|
|
608
|
+
for (var i = 0, length = files.length; i < length; i++) {
|
|
609
|
+
var filename = files[i];
|
|
610
|
+
var ext = U.getExtension(filename);
|
|
611
|
+
|
|
612
|
+
if (filename.indexOf('sitemap') === -1 && ext !== 'html' && ext !== 'js')
|
|
613
|
+
continue;
|
|
614
|
+
|
|
615
|
+
var content = F.Fs.readFileSync(filename).toString('utf8');
|
|
616
|
+
var command = Internal.findLocalization(content, 0);
|
|
617
|
+
while (command !== null) {
|
|
618
|
+
|
|
619
|
+
// Skip for direct reading
|
|
620
|
+
if (command.command[0] === '#' && command.command[1] !== ' ') {
|
|
621
|
+
command = Internal.findLocalization(content, command.end);
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
key = 'T' + HASH(command.command, true).toString(36);
|
|
626
|
+
file = filename.substring(dir.length + 1);
|
|
627
|
+
|
|
628
|
+
texts[key] = command.command;
|
|
629
|
+
|
|
630
|
+
if (resource[key]) {
|
|
631
|
+
if (resource[key].indexOf(file) === -1)
|
|
632
|
+
resource[key] += ', ' + file;
|
|
633
|
+
} else
|
|
634
|
+
resource[key] = file;
|
|
635
|
+
|
|
636
|
+
count++;
|
|
637
|
+
max = Math.max(max, key.length);
|
|
638
|
+
command = Internal.findLocalization(content, command.end);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (ext === 'js') {
|
|
642
|
+
// ErrorBuilder
|
|
643
|
+
var tmp = content.match(/\$\.invalid\('[a-z-0-9]+'\)/gi);
|
|
644
|
+
if (tmp) {
|
|
645
|
+
for (var j = 0; j < tmp.length; j++) {
|
|
646
|
+
var m = (tmp[j] + '');
|
|
647
|
+
m = m.substring(11, m.length - 2);
|
|
648
|
+
key = m;
|
|
649
|
+
file = filename.substring(dir.length + 1);
|
|
650
|
+
texts[key] = m;
|
|
651
|
+
if (resource[key]) {
|
|
652
|
+
if (resource[key].indexOf(file) === -1)
|
|
653
|
+
resource[key] += ', ' + file;
|
|
654
|
+
} else
|
|
655
|
+
resource[key] = file;
|
|
656
|
+
count++;
|
|
657
|
+
max = Math.max(max, key.length);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// DBMS
|
|
662
|
+
tmp = content.match(/\.(error|err)\('[a-z-0-9]+'/gi);
|
|
663
|
+
if (tmp) {
|
|
664
|
+
for (var j = 0; j < tmp.length; j++) {
|
|
665
|
+
var m = (tmp[j] + '');
|
|
666
|
+
m = m.substring(m.indexOf('(') + 2, m.length - 1);
|
|
667
|
+
key = m;
|
|
668
|
+
file = filename.substring(dir.length + 1);
|
|
669
|
+
texts[key] = m;
|
|
670
|
+
if (resource[key]) {
|
|
671
|
+
if (resource[key].indexOf(file) === -1)
|
|
672
|
+
resource[key] += ', ' + file;
|
|
673
|
+
} else
|
|
674
|
+
resource[key] = file;
|
|
675
|
+
count++;
|
|
676
|
+
max = Math.max(max, key.length);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
var keys = Object.keys(resource);
|
|
683
|
+
var builder = [];
|
|
684
|
+
var output = {};
|
|
685
|
+
|
|
686
|
+
for (var i = 0, length = keys.length; i < length; i++) {
|
|
687
|
+
if (!output[resource[keys[i]]])
|
|
688
|
+
output[resource[keys[i]]] = [];
|
|
689
|
+
output[resource[keys[i]]].push(keys[i].padRight(max + 5, ' ') + ': ' + texts[keys[i]]);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
keys = Object.keys(output);
|
|
693
|
+
for (var i = 0, length = keys.length; i < length; i++)
|
|
694
|
+
builder.push('\n// ' + keys[i] + '\n' + output[keys[i]].join('\n'));
|
|
695
|
+
|
|
696
|
+
F.Fs.writeFileSync('translate.resource', '// Total.js translation file\n// Created: ' + new Date().format('yyyy-MM-dd HH:mm') + '\n' + builder.join('\n'));
|
|
697
|
+
|
|
698
|
+
console.log('Translation has been created successfully (' + count + ' texts)');
|
|
699
|
+
console.log('');
|
|
700
|
+
|
|
701
|
+
}, (path, dir) => dir ? (path.endsWith('/node_modules') || path.endsWith('/tmp') || path.endsWith('/.git')) ? false : true : true);
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
if ($type === 6) {
|
|
706
|
+
log_title('Creating of translation to CSV');
|
|
707
|
+
|
|
708
|
+
U.ls(dir, function(files) {
|
|
709
|
+
|
|
710
|
+
var resource = {};
|
|
711
|
+
var texts = {};
|
|
712
|
+
var count = 0;
|
|
713
|
+
var output = ['Hash;Text;Translation'];
|
|
714
|
+
|
|
715
|
+
for (var i = 0, length = files.length; i < length; i++) {
|
|
716
|
+
var filename = files[i];
|
|
717
|
+
var ext = U.getExtension(filename);
|
|
718
|
+
|
|
719
|
+
if (ext !== 'html' && ext !== 'js')
|
|
720
|
+
continue;
|
|
721
|
+
|
|
722
|
+
var content = F.Fs.readFileSync(filename).toString('utf8');
|
|
723
|
+
var command = Internal.findLocalization(content, 0);
|
|
724
|
+
while (command !== null) {
|
|
725
|
+
|
|
726
|
+
// Skip for direct reading
|
|
727
|
+
if (command.command[0] === '#' && command.command[1] !== ' ') {
|
|
728
|
+
command = Internal.findLocalization(content, command.end);
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
var key = 'T' + HASH(command.command, true).toString(36);
|
|
733
|
+
|
|
734
|
+
texts[key] = command.command;
|
|
735
|
+
|
|
736
|
+
if (!resource[key]) {
|
|
737
|
+
output.push(key + ';"' + command.command.replace(/"/g, '""') + '";');
|
|
738
|
+
resource[key] = true;
|
|
739
|
+
count++;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
command = Internal.findLocalization(content, command.end);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
F.Fs.writeFileSync('translate.csv', output.join('\n'));
|
|
747
|
+
console.log('Translation has been created successfully (' + count + ' texts).');
|
|
748
|
+
console.log('');
|
|
749
|
+
}, (path, dir) => dir ? (path.endsWith('/node_modules') && path.endsWith('/tmp') && path.endsWith('/.git')) ? false : true : true);
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if ($type === 7) {
|
|
754
|
+
templates(function(templates) {
|
|
755
|
+
log_title('Templates');
|
|
756
|
+
|
|
757
|
+
for (var key in templates) {
|
|
758
|
+
var template = templates[key];
|
|
759
|
+
console.log(key.padRight(17, ' ') + ': ' + template.description);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
console.log('');
|
|
763
|
+
console.log('Create template with "total4 create <template> <path>".');
|
|
764
|
+
console.log('Default path is "./<template>".');
|
|
765
|
+
console.log('');
|
|
766
|
+
|
|
767
|
+
});
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if ($type === 8) {
|
|
772
|
+
|
|
773
|
+
var name = process.argv[3] || 'empty';
|
|
774
|
+
var path = process.argv[4];
|
|
775
|
+
|
|
776
|
+
// Default path
|
|
777
|
+
if (!path)
|
|
778
|
+
path = './' + name;
|
|
779
|
+
|
|
780
|
+
path = PATH.join(dir, path);
|
|
781
|
+
|
|
782
|
+
if (!F.Fs.existsSync(path))
|
|
783
|
+
F.Fs.mkdirSync(path);
|
|
784
|
+
|
|
785
|
+
var files = F.Fs.readdirSync(path);
|
|
786
|
+
|
|
787
|
+
if (files.length > 0) {
|
|
788
|
+
|
|
789
|
+
var can = true;
|
|
790
|
+
for (var i = 0; i < files.length; i++) {
|
|
791
|
+
var name = files[i];
|
|
792
|
+
if (name[0] !== '.')
|
|
793
|
+
can = false;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (!can) {
|
|
797
|
+
log_error('Directory is not empty.');
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
templates(function(res) {
|
|
803
|
+
|
|
804
|
+
var template = res[name];
|
|
805
|
+
|
|
806
|
+
if (template)
|
|
807
|
+
git(path, template);
|
|
808
|
+
else
|
|
809
|
+
log_error('Template "{0}" is invalid. Use "total4 templates" to list all avaliable templates.'.format(name));
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (cmd)
|
|
816
|
+
log_error('Command "{0}" is invalid. Use "total4 help" to list all commands.'.format(cmd));
|
|
817
|
+
else {
|
|
818
|
+
console.log('Use "total4 help" to list all commands.');
|
|
819
|
+
console.log('');
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
function templates(callback) {
|
|
824
|
+
RESTBuilder.GET('https://raw.githubusercontent.com/totaljs/framework4/master/templates.json').exec(function(err, res, out) {
|
|
825
|
+
if (err || out.status !== 200) {
|
|
826
|
+
log_error('Total.js templates are currently unavailable.');
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
callback(res);
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function git(dir, template) {
|
|
835
|
+
|
|
836
|
+
var done = function() {
|
|
837
|
+
console.log('Template "{0}" was created successfully.'.format(template.name));
|
|
838
|
+
console.log('');
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
F.Child.execFile('git', ['--version'], (error) => {
|
|
842
|
+
|
|
843
|
+
if (error) {
|
|
844
|
+
log_error('Git not found. Please, download the template from https://github.com/totaljs/{0}.git'.format(template.id));
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
U.ls(dir, function(fol, fil) {
|
|
849
|
+
|
|
850
|
+
if (fol.length || fil.length) {
|
|
851
|
+
log_error('Directory "{0}" is not empty.'.format(dir));
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
PATH.mkdir(dir);
|
|
856
|
+
F.Child.exec('git clone https://github.com/totaljs/{0}.git {1}'.format(template.id, dir), function() {
|
|
857
|
+
PATH.mkdir(F.Path.join(dir, '/node_modules/'));
|
|
858
|
+
PATH.rmdir(F.Path.join(dir, '.git'), function() {
|
|
859
|
+
PATH.unlink(F.Path.join(dir, '.gitignore'), function() {
|
|
860
|
+
PATH.exists(F.Path.join(dir, 'package.json'), function(e) {
|
|
861
|
+
if (e)
|
|
862
|
+
F.Child.exec('npm install total5 --save', done);
|
|
863
|
+
else
|
|
864
|
+
F.Child.exec('npm install', done);
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function makebundle(dir, filename) {
|
|
874
|
+
|
|
875
|
+
if (!filename)
|
|
876
|
+
filename = 'app.bundle';
|
|
877
|
+
|
|
878
|
+
var blacklist = {};
|
|
879
|
+
blacklist['/bundle.json'] = 1;
|
|
880
|
+
blacklist['/debug.js'] = 1;
|
|
881
|
+
blacklist['/debug.js.json'] = 1;
|
|
882
|
+
blacklist['/debug.pid'] = 1;
|
|
883
|
+
blacklist['/release.js'] = 1;
|
|
884
|
+
blacklist['/release.js.json'] = 1;
|
|
885
|
+
blacklist['/release.pid'] = 1;
|
|
886
|
+
blacklist['/index.js'] = 1;
|
|
887
|
+
blacklist['/index.js.json'] = 1;
|
|
888
|
+
blacklist['/index.pid'] = 1;
|
|
889
|
+
blacklist['/package.json'] = 1;
|
|
890
|
+
blacklist['/readme.md'] = 1;
|
|
891
|
+
blacklist['/license.txt'] = 1;
|
|
892
|
+
blacklist['/bundles/'] = 1;
|
|
893
|
+
blacklist['/tmp/'] = 1;
|
|
894
|
+
blacklist['/.src/'] = 1;
|
|
895
|
+
|
|
896
|
+
if (filename[0] !== '/')
|
|
897
|
+
blacklist['/' + filename] = 1;
|
|
898
|
+
else
|
|
899
|
+
blacklist[filename] = 1;
|
|
900
|
+
|
|
901
|
+
blacklist['/.git/'] = 1;
|
|
902
|
+
|
|
903
|
+
if (filename.toLowerCase().lastIndexOf('.bundle') === -1)
|
|
904
|
+
filename += '.bundle';
|
|
905
|
+
|
|
906
|
+
blacklist[filename] = 1;
|
|
907
|
+
|
|
908
|
+
console.log('--- CREATE BUNDLE --');
|
|
909
|
+
console.log('');
|
|
910
|
+
console.log('Directory :', dir);
|
|
911
|
+
console.log('Filename :', filename);
|
|
912
|
+
|
|
913
|
+
F.backup(filename, U.path(dir), function(err, path) {
|
|
914
|
+
|
|
915
|
+
if (err)
|
|
916
|
+
throw err;
|
|
917
|
+
|
|
918
|
+
console.log('Success :', path.files.pluralize('# files,# file,# files,# files') + ' (' + path.size.filesize() + ')');
|
|
919
|
+
console.log('');
|
|
920
|
+
|
|
921
|
+
}, function(path) {
|
|
922
|
+
return blacklist[path] == null;
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
function restorebundle(dir, filename) {
|
|
928
|
+
|
|
929
|
+
F.restore(filename, U.path(dir), function(err, path) {
|
|
930
|
+
|
|
931
|
+
if (err)
|
|
932
|
+
throw err;
|
|
933
|
+
|
|
934
|
+
console.log('Success :', path.files.pluralize('# files,# file,# files,# files') + ' (' + path.size.filesize() + ')');
|
|
935
|
+
console.log('');
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
function makepackage(dir, filename) {
|
|
941
|
+
|
|
942
|
+
if (!filename)
|
|
943
|
+
filename = 'noname.package';
|
|
944
|
+
|
|
945
|
+
var blacklist = {};
|
|
946
|
+
blacklist['/bundle.json'] = 1;
|
|
947
|
+
blacklist['/debug.js'] = 1;
|
|
948
|
+
blacklist['/release.js'] = 1;
|
|
949
|
+
blacklist['/debug.pid'] = 1;
|
|
950
|
+
blacklist['/package.json'] = 1;
|
|
951
|
+
blacklist['/readme.md'] = 1;
|
|
952
|
+
blacklist['/license.txt'] = 1;
|
|
953
|
+
blacklist['/bundles/'] = 1;
|
|
954
|
+
blacklist['/tmp/'] = 1;
|
|
955
|
+
|
|
956
|
+
if (filename[0] !== '/')
|
|
957
|
+
blacklist['/' + filename] = 1;
|
|
958
|
+
else
|
|
959
|
+
blacklist[filename] = 1;
|
|
960
|
+
|
|
961
|
+
blacklist['/.git/'] = 1;
|
|
962
|
+
|
|
963
|
+
if (filename.toLowerCase().lastIndexOf('.package') === -1)
|
|
964
|
+
filename += '.package';
|
|
965
|
+
|
|
966
|
+
blacklist[filename] = 1;
|
|
967
|
+
|
|
968
|
+
console.log('--- CREATE PACKAGE --');
|
|
969
|
+
console.log('');
|
|
970
|
+
console.log('Directory :', dir);
|
|
971
|
+
console.log('Filename :', filename);
|
|
972
|
+
|
|
973
|
+
F.backup(filename, dir, function(err, path) {
|
|
974
|
+
|
|
975
|
+
if (err)
|
|
976
|
+
throw err;
|
|
977
|
+
|
|
978
|
+
console.log('Success :', path.files.pluralize('# files,# file,# files,# files') + ' (' + path.size.filesize() + ')');
|
|
979
|
+
console.log('');
|
|
980
|
+
|
|
981
|
+
}, path => blacklist[path] == null);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
main();
|