forked from TelegramMessenger/bodymovin-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
102 lines (89 loc) · 3.58 KB
/
gulpfile.js
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
var gulp = require('gulp');
var watch = require('gulp-watch');
var htmlreplace = require('gulp-html-replace');
var eventstream = require("event-stream");
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var gzip = require('gulp-gzip');
var insert = require('gulp-insert');
var version = '5.5.2'
var extensionSource = './bundle';
var extensionDestination = '/Library/Application Support/Adobe/CEP/extensions/bodymovin-tg';
gulp.task('watch-extension', function() {
gulp.src(extensionSource + '/**/*', {base: extensionSource})
.pipe(watch(extensionSource, {base: extensionSource}))
.pipe(gulp.dest(extensionDestination));
});
gulp.task('copy-extension', function() {
gulp.src(extensionSource+'/**/*')
.pipe(gulp.dest(extensionDestination));
});
gulp.task('copy-all', function() {
return gulp.src(extensionSource+'/**/*')
.pipe(gulp.dest('./build'));
});
gulp.task('create-bm', function() {
return gulp.src('player/lottie.min.js')
.pipe(rename('lottie.js'))
.pipe(gulp.dest('build/assets/player'));
});
gulp.task('create-bm-extension-player', function() {
return gulp.src('player/lottie.js')
.pipe(rename('lottie.js'))
.pipe(insert.prepend('/* eslint-disable */var define = define || null;'))
.pipe(gulp.dest('./src/'));
});
gulp.task('create-standalone', function() {
return gulp.src('player/lottie.min.js')
.pipe(rename('standalone.js'))
.pipe(gulp.dest('build/assets/player'));
});
gulp.task('create-gzip', function() {
return gulp.src('player/lottie.min.js')
.pipe(rename('lottie.js'))
.pipe(gzip({ append: true }))
.pipe(gulp.dest('build/assets/player'));
});
gulp.task('copy-manifest', function() {
return gulp.src('bundle/CSXS/manifest.xml')
.pipe(replace(/(<Extension Id="org\.telegram\.bodymovin-tg" Version=")(.+)(" \/>)/g,'$1'+version+'$3'))
.pipe(replace(/(<ExtensionManifest Version="5\.0" ExtensionBundleId="org\.telegram\.bodymovin-tg" ExtensionBundleVersion=")(.+)(")/g,'$1'+version+'$3'))
.pipe(replace(/(<MainPath>\.\/)(index_dev.html)(<\/MainPath>)/g,'$1'+'index.html'+'$3'))
.pipe(gulp.dest('build/CSXS/'));
});
gulp.task('copy-debug', function() {
return gulp.src('bundle/.debug')
.pipe(gulp.dest('build/'));
});
gulp.task('copy-renderManager', function() {
return gulp.src('bundle/jsx/renderManager.jsx')
//.pipe(replace(/(v : ')(.+)(',)/g,'$1'+version+'$3'))
.pipe(replace(/(version_number = ')(.+)(';)/g,'$1'+version+'$3'))
.pipe(gulp.dest('build/jsx/'));
});
var demoBuiltData = '';
gulp.task('build-demo-data', function() {
function saveToVar() {
// you're going to receive Vinyl files as chunks
function transform(file, cb) {
// read and modify file contents
demoBuiltData = String(file.contents);
cb(null, file);
}
return eventstream.map(transform);
}
return gulp.src('player/lottie.min.js')
.pipe(saveToVar());
});
gulp.task('replace-demo-data', gulp.series(['build-demo-data'], function() {
//htmlreplace;
return gulp.src('bundle/assets/player/demo.html')
.pipe(htmlreplace({
scripto:{
src: demoBuiltData,
tpl: '<!-- build:scripto --><script>%s</script><!-- endbuild -->'
}
}))
.pipe(gulp.dest('build/assets/player/'));
}));
gulp.task('copy-extension-bundle', gulp.series('copy-all', 'build-demo-data', 'replace-demo-data', 'create-bm', 'create-standalone', 'create-gzip', 'copy-manifest', 'copy-renderManager','copy-debug'))