-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
76 lines (63 loc) · 1.84 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
const { src, dest, series, parallel } = require("gulp");
const replace = require("gulp-replace");
const zip = require("gulp-zip");
const es = require("event-stream");
const { spawn } = require("child_process");
const PLUGIN_SLUG = "passle-sync";
const getEnv = () => process.env.PASSLE_ENV;
const installComposerDependencies = (cb) => {
const args = ["install"];
if (getEnv() != null) {
args.push("--no-dev");
}
spawn("composer", args, { stdio: "inherit", shell: true }).on("close", cb);
};
const installNpmDependencies = (cb) => {
spawn("npm", ["ci"], { cwd: "frontend/", stdio: "inherit", shell: true }).on(
"close",
cb,
);
};
const buildFrontend = (cb) => {
spawn("npm", ["run", "build"], {
cwd: "frontend/",
stdio: "inherit",
shell: true,
}).on("close", cb);
};
const installDependenciesAndBuildFrontend = series(
parallel(installComposerDependencies, installNpmDependencies),
buildFrontend,
);
const buildZip = (cb) => {
const constants = src("constants.php").pipe(replace("localhost", getEnv()));
const allFiles = src([
"**/*",
"!constants.php",
"!**/node_modules{,/**}",
"!frontend/src{,/**}",
"!frontend/tsconfig.json",
"!frontend/webpack.config.js",
"!.vscode{,/**}",
"!gulpfile.js",
"!**/package.json",
"!**/package-lock.json",
"!composer.json",
"!composer.lock",
"!phpdoc.xml",
"!build{,/**}",
]);
es.merge(allFiles, constants)
.pipe(zip(`${PLUGIN_SLUG}.zip`))
.pipe(dest("./build/"));
cb();
};
const generateDocs = (cb) => {
spawn("composer", ["run", "generate-docs"], {
stdio: "inherit",
shell: true,
}).on("close", cb);
};
exports.init = installDependenciesAndBuildFrontend;
exports.buildZip = series(installDependenciesAndBuildFrontend, buildZip);
exports.generateDocs = series(installComposerDependencies, generateDocs);