Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrr committed May 15, 2024
2 parents 818c256 + 58bed60 commit 6e087e6
Show file tree
Hide file tree
Showing 261 changed files with 4,835 additions and 1,590 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/webook_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: notify dev
uses: distributhor/workflow-webhook@v2
env:
uses: distributhor/workflow-webhook@v3
with:
curl_opts: "--retry 5 --retry-all-errors"
webhook_type: "json-extended"
webhook_url: "https://dev.cables.gl/api/webhooks/updatecore?secret=${{ secrets.WEBHOOK_SECRET }}"
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
236 changes: 93 additions & 143 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,72 @@
//
import gulp from "gulp";

import footer from "gulp-footer";
import fs from "fs";
import getRepoInfo from "git-repo-info";
import git from "git-last-commit";
import clean from "gulp-clean";
import rename from "gulp-rename";
import concat from "gulp-concat";
import compiler from "webpack";
import webpack from "webpack-stream";

import webpackConfig from "./webpack.config.js";
import libWebpackConfig from "./webpack.config.libs.js";
import webpackLibsConfig from "./webpack.config.libs.js";

let buildInfo = getBuildInfo();
let configLocation = "../cables_api/cables.json";
if (process.env.npm_config_apiconfig) configLocation = "../cables_api/cables_env_" + process.env.npm_config_apiconfig + ".json";

function getBuildInfo()
let isLiveBuild = false;
let minify = false;
let config = {};
if (fs.existsSync(configLocation))
{
config = JSON.parse(fs.readFileSync(configLocation, "utf-8"));
isLiveBuild = config.env === "live";
minify = config.hasOwnProperty("minifyJs") ? config.minifyJs : false;
}
else
{
console.error("config file not found at", configLocation, "assuming local build (dev/no minify)");
}

function getBuildInfo(cb)
{
const git = getRepoInfo();
const date = new Date();
return {
"timestamp": date.getTime(),
"created": date.toISOString(),
"git": {
"branch": git.branch,
"commit": git.sha,
"date": git.committerDate,
"message": git.commitMessage
}
};
git.getLastCommit((err, commit) =>
{
cb({
"timestamp": date.getTime(),
"created": date.toISOString(),
"git": {
"branch": commit.branch,
"commit": commit.hash,
"date": commit.committedOn,
"message": commit.subject
}
});
});
}

function _update_buildInfo(done)
{
buildInfo = getBuildInfo();
fs.mkdir("build/", { "recursive": true }, (err) =>
{
if (err)
{
return console.error(err);
}
fs.writeFileSync("build/buildInfo.json", JSON.stringify(buildInfo));
done();
getBuildInfo((buildInfo) =>
{
fs.writeFileSync("build/buildinfo.json", JSON.stringify(buildInfo));
done();
});
});
}

function _append_build_info()
{
return gulp
.src(["build/*.js"])
.pipe(footer("\n\nvar CABLES = CABLES || {}; CABLES.build = " + JSON.stringify(buildInfo) + ";"))
.pipe(gulp.dest("build/"));
}

function _watch(done)
{
gulp.watch(["src/core/**/*", "../shared/client/**/*"], { "usePolling": true }, gulp.series(_update_buildInfo, gulp.parallel(_corejs_max), gulp.parallel(_core_libs_max), _append_build_info, _copy_ui, _core_libs_copy));
gulp.watch("libs/**/*", { "usePolling": true }, gulp.series(_update_buildInfo, _external_libs, _append_build_info, _copy_ui));
gulp.watch("src/libs/**/*", { "usePolling": true }, gulp.series(_update_buildInfo, _core_libs_clean, gulp.parallel(_core_libs_max), _append_build_info, _core_libs_copy));
gulp.watch(["src/core/**/*", "../shared/client/**/*"], { "usePolling": true }, gulp.series(_update_buildInfo, gulp.parallel(_corejs), gulp.parallel(_core_libs), _copy_ui, _core_libs_copy));
gulp.watch("libs/**/*", { "usePolling": true }, gulp.series(_update_buildInfo, _external_libs, _copy_ui));
gulp.watch("src/libs/**/*", { "usePolling": true }, gulp.series(_update_buildInfo, _core_libs_clean, gulp.parallel(_core_libs), _core_libs_copy));
done();
}

Expand All @@ -68,7 +77,7 @@ function _core_libs_clean()

function _copy_ui()
{
return gulp.src(["build/*", "!build/buildInfo.json", "!/build/libs/*"]).pipe(gulp.dest("../cables_ui/dist/js/"));
return gulp.src(["build/*", "!build/buildinfo.json", "!/build/libs/*"]).pipe(gulp.dest("../cables_ui/dist/js/"));
}

function _core_libs_copy()
Expand All @@ -83,117 +92,67 @@ function _external_libs()
.src(["libs/*.js"])
.pipe(concat("libs.core.js"))
.pipe(gulp.dest("build"))
.pipe(rename("libs.core.min.js"))
.pipe(gulp.dest("build"))
);
}

function _corejs_max(done)
function _corejs(done)
{
return gulp.src(["src/core/index.js"])
.pipe(
webpack(
{
"config": webpackConfig(false, false),
},
compiler,
(err, stats) =>
{
if (err) throw err;
if (stats.hasErrors())
getBuildInfo((buildInfo) =>
{
return gulp.src(["src/core/index.js"])
.pipe(
webpack(
{
done(new Error(stats.compilation.errors.join("\n")));
}
done();
}
)
)
.pipe(gulp.dest("build"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
}

function _corejs_min(done)
{
return gulp.src(["src/core/index.js"])
.pipe(
webpack(
{
"config": webpackConfig(true, false),
},
compiler,
(err, stats) =>
{
if (err) throw err;
if (stats.hasErrors())
"config": webpackConfig(isLiveBuild, buildInfo, minify),
},
compiler,
(err, stats) =>
{
done(new Error(stats.compilation.errors.join("\n")));
if (err) throw err;
if (stats.hasErrors())
{
done(new Error(stats.compilation.errors.join("\n")));
}
done();
}
done();
}
)
)
)

.pipe(gulp.dest("build"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
.pipe(gulp.dest("build"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
});
}

function _core_libs_max(done)
function _core_libs(done)
{
return gulp.src(["src/libs/**/*"])
.pipe(
webpack(
{
"config": libWebpackConfig(false),
},
compiler,
(err, stats) =>
{
if (err) throw err;
if (stats.hasErrors())
getBuildInfo((buildInfo) =>
{
return gulp.src(["src/libs/**/*"])
.pipe(
webpack(
{
done(Error(stats.compilation.errors.join("\n")));
}
done();
}
)
)
.pipe(gulp.dest("build/libs"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
}

function _core_libs_min()
{
return gulp.src(["src/libs/**/*"])
.pipe(
webpack(
{
"config": libWebpackConfig(true),
},
compiler,
(err, stats) =>
{
if (err) throw err;
if (stats.hasErrors())
"config": webpackLibsConfig(isLiveBuild, buildInfo, false),
},
compiler,
(err, stats) =>
{
return new Error(stats.compilation.errors.join("\n"));
if (err) throw err;
if (stats.hasErrors())
{
done(Error(stats.compilation.errors.join("\n")));
}
done();
}
}
)
)
)
.pipe(gulp.dest("build/libs"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
.pipe(gulp.dest("build/libs"))
.on("error", (err) =>
{
console.error("WEBPACK ERROR", err);
});
});
}

/*
Expand All @@ -206,15 +165,12 @@ gulp.task("default", gulp.series(
_update_buildInfo,
gulp.parallel(
_external_libs,
_corejs_max,
_corejs_min
_corejs
),
_core_libs_clean,
gulp.parallel(
_core_libs_max,
_core_libs_min
_core_libs
),
_append_build_info,
_copy_ui,
_core_libs_copy,
_watch
Expand All @@ -224,15 +180,12 @@ gulp.task("watch", gulp.series(
_update_buildInfo,
gulp.parallel(
_external_libs,
_corejs_max,
_corejs_min
_corejs
),
_core_libs_clean,
gulp.parallel(
_core_libs_max,
_core_libs_min
_core_libs
),
_append_build_info,
_copy_ui,
_core_libs_copy,
_watch
Expand All @@ -242,15 +195,12 @@ gulp.task("build", gulp.series(
_update_buildInfo,
gulp.parallel(
_external_libs,
_corejs_max,
_corejs_min
_corejs
),
_core_libs_clean,
gulp.parallel(
_core_libs_max,
_core_libs_min
_core_libs
),
_append_build_info,
_copy_ui,
_core_libs_copy
));
Loading

0 comments on commit 6e087e6

Please sign in to comment.