-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
140 lines (121 loc) · 3.15 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
const gulp = require("gulp");
const ts = require("gulp-typescript");
const exec = require("gulp-exec");
const del = require("del");
const serverProject = ts.createProject("tsconfig.json");
const DIST_FOLDER = "./dist/";
const Tasks = Object.freeze({
BuildServer: "BuildServer",
CopyPackageJson: "CopyPackageJson",
CopyPackageLockJson: "CopyPackageLockJson",
CopyIcon: "CopyIcon",
BuildClient: "BuildClient",
CopyClientDist: "CopyClientDist",
InstallDependenciesDist: "InstallDependenciesDist",
Package_Win_x64: "Package",
BuildAndCopyFiles: "BuildAndCopyFiles",
Clean: "Clean",
RemoveLocales: "RemoveLocales"
});
/**
* Compile server code
*/
gulp.task(Tasks.BuildServer, () => {
return serverProject
.src()
.pipe(serverProject())
.js.pipe(gulp.dest(DIST_FOLDER));
});
/**
* Copy package.json and package-lock.json to the dist folder
*/
gulp.task(Tasks.CopyPackageJson, () => {
return gulp
.src("./package.json")
.pipe(gulp.dest(DIST_FOLDER));
});
gulp.task(Tasks.CopyPackageLockJson, () => {
return gulp.src("./package-lock.json")
.pipe(gulp.dest(DIST_FOLDER));
});
gulp.task(Tasks.CopyIcon, () => {
return gulp.src("./icon.ico")
.pipe(gulp.dest(DIST_FOLDER));
});
/**
* Builds the client side (using Angular CLI)
*/
gulp.task(Tasks.BuildClient, () => {
return gulp
.src("./client/")
.pipe(exec("npm run build:prod", {
cwd: "./client/"
}));
});
/**
* Copies the compiled client dist folder in the server one
*/
gulp.task(Tasks.CopyClientDist, () => {
return gulp.src("client/dist/**/*")
.pipe(gulp.dest(DIST_FOLDER + "client/"));
});
/**
* Installs dependencies in the dist folder
*/
gulp.task(Tasks.InstallDependenciesDist, () => {
return gulp.src(DIST_FOLDER)
.pipe(exec("npm install", {
cwd: DIST_FOLDER
}));
});
/**
* Package app for win x64
*/
gulp.task(Tasks.Package_Win_x64, () => {
return gulp.src(DIST_FOLDER)
.pipe(exec("npm run package_win_x64", {
cwd: DIST_FOLDER
}));
});
gulp.task(Tasks.Clean, () => {
return del([
"dist/**",
"bin/**",
"client/dist/**"
]);
});
/**
* Remove unused locales.
* Keep only [en-GB.pak, en-US.pak, it.pak]
*/
gulp.task(Tasks.RemoveLocales, () => {
return del("locales/!(en-GB|en-US|it)*.pak", {
cwd: "dist/bin/ipchanger-win32-x64"
});
});
/**
* Run all
*/
gulp.task(Tasks.BuildAndCopyFiles, (done) => {
return gulp.series(
Tasks.Clean,
Tasks.BuildServer,
Tasks.BuildClient,
Tasks.CopyClientDist,
gulp.parallel(
Tasks.CopyPackageJson,
Tasks.CopyPackageLockJson,
Tasks.CopyIcon
)
)(done);
});
gulp.task("default", (done) => {
return gulp.series(
Tasks.BuildAndCopyFiles,
Tasks.InstallDependenciesDist,
gulp.parallel(
Tasks.Package_Win_x64
),
Tasks.RemoveLocales
)(done);
});