Skip to content

Commit 5d63a9e

Browse files
author
Rafael Grigorian
committed
Updated build system to Gulp
1 parent a74997b commit 5d63a9e

File tree

6 files changed

+1403
-2020
lines changed

6 files changed

+1403
-2020
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.DS_Store
2-
/.composer/
32
/.docker-sync/
43
/node_modules/
54
/public_html/
5+
/build/
66
/dist/
7-
/vendor/

Gruntfile.js

Lines changed: 0 additions & 140 deletions
This file was deleted.

gulpfile.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const gulp = require ("gulp")
2+
const gzip = require ("gulp-gzip")
3+
const magepack = require ("gulp-magepack")
4+
const replace = require ("gulp-replace")
5+
const tar = require ("gulp-tar")
6+
const fs = require ("fs")
7+
const fse = require ("fs-extra")
8+
9+
const PACKAGE_NAMESPACE = require ("./package.json").namespace
10+
const PACKAGE_VERSION = require ("./package.json").version
11+
12+
const SOURCE_DIR = "src"
13+
const BUILD_DIR = "build"
14+
const STAGING_DIR = "public_html"
15+
const PACKAGE_DIR = "dist"
16+
17+
gulp.task ( "init", [], ( callback ) => {
18+
let mkdirNotExists = ( name ) => {
19+
if ( !fs.existsSync ( name ) ) {
20+
fs.mkdirSync ( name )
21+
}
22+
}
23+
mkdirNotExists ( BUILD_DIR )
24+
mkdirNotExists ( PACKAGE_DIR )
25+
mkdirNotExists ( STAGING_DIR )
26+
callback ()
27+
})
28+
29+
gulp.task ( "clean", [], ( callback ) => {
30+
let unlinkExists = ( name ) => {
31+
if ( fs.existsSync ( name ) ) {
32+
fse.removeSync ( name )
33+
}
34+
}
35+
unlinkExists ( BUILD_DIR )
36+
unlinkExists ( PACKAGE_DIR )
37+
callback ()
38+
})
39+
40+
gulp.task ( "bump", [], ( callback ) => {
41+
return gulp.src ( SOURCE_DIR + "/**/*" )
42+
.pipe ( replace ( /(^.*\*\s+@version\s+)(.+$)/gm, "$1" + PACKAGE_VERSION ) )
43+
.pipe ( gulp.dest ( SOURCE_DIR ) )
44+
.on ( "done", callback )
45+
})
46+
47+
gulp.task ( "build", [ "init" ], ( callback ) => {
48+
return gulp.src ( SOURCE_DIR + "/**/*" )
49+
.pipe ( gulp.dest ( BUILD_DIR ) )
50+
.on ( "done", callback )
51+
})
52+
53+
gulp.task ( "deploy", ["build"], ( callback ) => {
54+
return gulp.src ( BUILD_DIR + "/**/*" )
55+
.pipe ( gulp.dest ( STAGING_DIR ) )
56+
.on ( "done", callback )
57+
})
58+
59+
gulp.task ( "watch", ["deploy"], () => {
60+
return gulp.watch ( SOURCE_DIR + "/**/*", ["deploy"] )
61+
})
62+
63+
gulp.task ( "package", [ "clean", "bump", "build" ], ( callback ) => {
64+
let options = {
65+
"template": "conf/package.xml",
66+
"version": PACKAGE_VERSION
67+
}
68+
gulp.src ( BUILD_DIR + "/**/*" )
69+
.pipe ( magepack ( options ) )
70+
.pipe ( tar (`${PACKAGE_NAMESPACE}-${PACKAGE_VERSION}`) )
71+
.pipe ( gzip ({ extension: "tgz" }) )
72+
.pipe ( gulp.dest ( PACKAGE_DIR ) )
73+
.on ( "done", callback )
74+
})

0 commit comments

Comments
 (0)