forked from reggie3/react-native-webview-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
163 lines (141 loc) · 3.37 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
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
const gulp = require('gulp');
const concat = require('gulp-concat');
const jeditor = require('gulp-json-editor');
const bump = require('gulp-bump');
const run = require('gulp-run');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const gutil = require('gulp-util');
const stripDebug = require('gulp-strip-debug');
// dependencies for npm publishing
const npmDeps = {
"is-valid-coordinates": "^1.0.0",
"leaflet": "^1.3.1",
"leaflet.markercluster": "^1.4.1",
"expo-asset-utils": "^1.0.0",
"prop-types": "^15.6.0",
"util": "^0.10.3",
"lodash.uniqby": "^4.7.0",
"geolib": "^2.0.24",
"react-leaflet": "^2.1.1",
/* "@sentry/browser": "^4.0.4",
"sentry-expo": "^1.9.0", */
"react-leaflet-markercluster": "^2.0.0-rc3",
};
const npmPeerDeps={
"react": "16.5.0",
"react-dom": "^16.5.0",
"react-native": "^0.57.1"
}
// additional dependencies for expo app
const expoDeps = {
expo: '^32.0.0',
react: '16.5.0',
'react-dom': '^16.5.0',
'react-native': `https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz`
};
// main for npm publishing
const npmMain = 'index.js';
// main for expo app
const expoMain = 'node_modules/expo/AppEntry.js';
// read the package.json and update it for npm publishing
gulp.task('forNPM', (done) => {
gulp
.src('./package.json')
.pipe(bump())
.pipe(
jeditor(function(json) {
json.dependencies = npmDeps;
json.peerDependencies = npmPeerDeps;
json.main = npmMain;
return json;
})
)
.pipe(concat('package.json'))
.pipe(gulp.dest('./'));
done();
});
// pack the files
gulp.task('webpack', (done) => {
return run('webpack').exec();
done();
});
gulp.task('npm-publish', (done) => {
return run('npm publish').exec();
done();
});
gulp.task('npm-publish-beta', (done) => {
return run('npm publish --tag beta').exec();
done();
});
gulp.task('git-add', (done) => {
return run('git add .').exec();
done();
});
gulp.task('git-commit', (done) => {
return run('git commit -m "publishing"').exec();
done();
});
gulp.task('git-push', (done) => {
return run('git push origin master').exec();
done();
});
gulp.task('git-push-beta', (done) => {
return run('git push origin 5-with-raster-layers').exec();
});
gulp.task('forExpo', (done) => {
gulp
.src('./package.json')
.pipe(
jeditor({
dependencies: expoDeps,
main: expoMain,
peerDependencies: {}
})
)
.pipe(concat('package.json'))
.pipe(gulp.dest('./'));
done();
});
gulp.task('copy-build-files', (done) => {
gulp.src('./build/index.html').pipe(gulp.dest('./assets/dist/'));
gulp.src('./build/main.bundle.js.map').pipe(gulp.dest('./assets/dist/'));
gulp.src('./build/images/*').pipe(gulp.dest('./assets/dist/images'));
done();
});
gulp.task('build', gulp.series('webpack', 'copy-build-files'));
gulp.task(
'prod',
gulp.series(
'forNPM',
'build',
gulp.parallel(
gulp.series('git-add', 'git-commit', 'git-push'),
'npm-publish'
),
'forExpo'
)
);
gulp.task(
'beta',
gulp.series(
'forNPM',
'build',
'npm-publish-beta',
'forExpo',
'copy-build-files'
)
);
gulp.task(
'test',
gulp.series(
'forNPM',
'webpack',
gulp.parallel(
gulp.series('git-add', 'git-commit', 'git-push'),
'npm-publish'
),
'forExpo',
'copy-build-files'
)
);