-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ts
64 lines (55 loc) · 1.58 KB
/
gulpfile.ts
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
import gulp from 'gulp';
import runSequence from 'run-sequence';
import nodemon from 'gulp-nodemon';
import ts from 'gulp-typescript';
import sourcemaps from 'gulp-sourcemaps';
const { GulpSSHDeploy } = require('gulp-ssh-deploy');
const gulpConfig = {
nodemon: {
nodemon: require('nodemon'),
script: './dist/src/app.js',
ext: 'ts',
watch: 'src',
env: { NODE_ENV: 'development' },
tasks: ['build'],
},
copyfiles: ['package.json', 'config/*.json'],
sshDeploy: {
host: '127.0.0.1',
port: 53841,
package_json_file_path: 'package.json',
source_files: './dist',
remote_directory: '/remoteLocation/Koa-ts',
username: 'root',
ssh_key_file: '~/.ssh/id_rsa',
releases_to_keep: 3,
// group: 'root-group',
permissions: 'ugo+rX',
// package_task: 'someTask',
},
};
// const run = require('gulp-run-command').default;
gulp.task('copyfile', () => {
for (const fileUrl of gulpConfig.copyfiles) {
gulp.src(fileUrl, { base: './' }).pipe(gulp.dest('dist'));
}
});
gulp.task('nodemon', () => {
nodemon(gulpConfig.nodemon as any);
});
gulp.task('tsc', () => {
const tsProject = ts.createProject('tsconfig.json');
return tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('../dist', { addComment: false }))
.pipe(gulp.dest('dist'));
});
gulp.task('build', (callback) => runSequence('tsc', 'copyfile', callback));
gulp.task('default', (callback) => runSequence('build', 'nodemon', callback));
try {
new GulpSSHDeploy(gulpConfig.sshDeploy, gulp);
} catch (e) {
console.error(e);
}