Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thsmi/sieve.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/gulp
diff options
context:
space:
mode:
authorThomas Schmid <thsmi@users.noreply.github.com>2020-05-22 02:26:02 +0300
committerGitHub <noreply@github.com>2020-05-22 02:26:02 +0300
commit3d869d5648a17ee46ffb5cc2508ce7a8c87359a2 (patch)
treea0cadfe64f8cd9de727c4430bcf2ae7a19301d51 /gulp
parent378570591e3a5b2c2c1e9a6be7bb6e120f90a337 (diff)
Gulp Task to create an Appimage (#286)
* Transform build output into an real AppDir Structure * Cleanup and optimize gulp tasks * Resolve path and await exec result Closes #268
Diffstat (limited to 'gulp')
-rw-r--r--gulp/gulpfile.app.js138
-rw-r--r--gulp/gulpfile.common.js62
-rw-r--r--gulp/gulpfile.wx.js83
3 files changed, 237 insertions, 46 deletions
diff --git a/gulp/gulpfile.app.js b/gulp/gulpfile.app.js
index b906caf0..74fae9dc 100644
--- a/gulp/gulpfile.app.js
+++ b/gulp/gulpfile.app.js
@@ -31,6 +31,8 @@ const BUILD_DIR_APP = path.join(common.BASE_DIR_BUILD, "electron/resources");
const OUTPUT_DIR_APP = path.join(common.BASE_DIR_BUILD, "electron/out");
const BASE_DIR_APP = "./src/app/";
+const BUILD_DIR_APP_LIBS = path.join(BUILD_DIR_APP, '/libs');
+
const KEYTAR_NAME = "keytar";
const KEYTAR_OUTPUT_DIR = `/libs/${KEYTAR_NAME}`;
@@ -48,6 +50,10 @@ const RUNTIME_ELECTRON = "electron";
const APP_IMAGE_RELEASE_URL = "https://api.github.com/repos/AppImage/AppImageKit/releases/latest";
const APP_IMAGE_TOOL_NAME = "appimagetool-x86_64.AppImage";
+const APP_IMAGE_DIR = path.join(OUTPUT_DIR_APP, "sieve.AppDir");
+
+const OUTPUT_DIR_APP_WIN32 = path.join(OUTPUT_DIR_APP, `sieve-${WIN_PLATFORM}-${WIN_ARCH}`);
+const OUTPUT_DIR_APP_LINUX = path.join(OUTPUT_DIR_APP, `sieve-${LINUX_PLATFORM}-${LINUX_ARCH}`);
/**
* Extracts a tar or tar.gz file to the given destination.
@@ -197,23 +203,57 @@ function packageSrc() {
}
/**
- * The common files need to go into the app/lib directory...
+ * Copies the application's icons into the lib folder.
+ * We use it internally for windows decoration.
*
* @returns {Stream}
* a stream to be consumed by gulp
*/
-function packageCommon() {
+function packageIcons() {
"use strict";
return src([
- common.BASE_DIR_COMMON + "/**",
- // Filter out the rfc documents
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/rfc*.txt",
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/tests/",
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/tests/**"
- ]).pipe(dest(BUILD_DIR_APP + '/libs'));
+ path.join(common.BASE_DIR_COMMON, "icons") + "/**"
+ ], { base: common.BASE_DIR_COMMON }).pipe(dest(BUILD_DIR_APP_LIBS));
+}
+
+/**
+ * Copies the common libManageSieve files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibManageSieve() {
+ "use strict";
+ return common.packageLibManageSieve(BUILD_DIR_APP_LIBS);
+}
+
+
+/**
+ * Copies the common libSieve files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibSieve() {
+ "use strict";
+ return common.packageLibSieve(BUILD_DIR_APP_LIBS);
+}
+
+
+/**
+ * Copies the common managiesieve.ui files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageManageSieveUi() {
+ "use strict";
+
+ return common.packageManageSieveUi(BUILD_DIR_APP_LIBS);
}
+
/**
* The keytar files need to go into the app/lib directory.
* After packaging electron the you need to add the native
@@ -423,7 +463,9 @@ function watchSrc() {
'./src/**/*.properties'],
parallel(
packageSrc,
- packageCommon)
+ packageManageSieveUi,
+ packageLibSieve,
+ packageLibManageSieve)
);
}
@@ -435,7 +477,7 @@ async function zipWin32() {
const version = (await common.getPackageVersion()).join(".");
- const source = path.resolve(path.join(OUTPUT_DIR_APP, `sieve-${WIN_PLATFORM}-${WIN_ARCH}`));
+ const source = path.resolve(OUTPUT_DIR_APP_WIN32);
const destination = path.join(common.BASE_DIR_BUILD, `sieve-${version}-${WIN_PLATFORM}-${WIN_ARCH}.zip`);
await common.compress(source, destination);
@@ -449,7 +491,7 @@ async function zipLinux() {
const version = (await common.getPackageVersion()).join(".");
- const source = path.resolve(path.join(OUTPUT_DIR_APP, `sieve-${LINUX_PLATFORM}-${LINUX_ARCH}`));
+ const source = path.resolve(path.join(OUTPUT_DIR_APP_LINUX));
const destination = path.join(common.BASE_DIR_BUILD, `sieve-${version}-${LINUX_PLATFORM}-${LINUX_ARCH}.zip`);
const options = {
@@ -463,9 +505,40 @@ async function zipLinux() {
}
/**
+ * App Images enforce a very strict naming scheme, this means
+ * we copy the staged files and do our adjustments
+ *
+ * @returns {stream}
+ * a stream to be consumed by gulp
+ */
+function packageAppImageDir() {
+ "use strict";
+
+ return src([
+ OUTPUT_DIR_APP_LINUX + "/**/*"
+ ]).pipe(dest(APP_IMAGE_DIR));
+}
+
+/**
+ * Packages the AppDir related files into the app image folder.
+ *
+ * @returns {stream}
+ * a stream to be consumed by gulp
+ */
+function packageAppImageFiles() {
+ "use strict";
+
+ const appImageFiles = path.join(common.BASE_DIR_COMMON, "/appImage/");
+
+ return src([
+ appImageFiles + "/**/*"
+ ], { base: appImageFiles}).pipe(dest(APP_IMAGE_DIR));
+}
+
+/**
* Creates a linux appImage Container
*/
-async function appImageLinux() {
+async function packageAppImage() {
"use strict";
const latest = await https.fetch(APP_IMAGE_RELEASE_URL);
@@ -479,7 +552,7 @@ async function appImageLinux() {
if (!url)
throw new Error("Could not download app image tool.");
- const tool = path.join(CACHE_DIR_APP, `appimagetool-v${latest.name}.AppImage`);
+ const tool = path.resolve(path.join(CACHE_DIR_APP, `appimagetool-v${latest.name}.AppImage`));
if (!existsSync(tool))
await https.download(url, tool);
@@ -487,12 +560,14 @@ async function appImageLinux() {
const RWX_RWX_RX = 0o775;
await chmod(tool, RWX_RWX_RX);
+ await chmod(path.resolve(path.join(APP_IMAGE_DIR, "AppRun")), RWX_RWX_RX);
+
const version = (await common.getPackageVersion()).join(".");
- const source = path.resolve(path.join(OUTPUT_DIR_APP, `sieve-${LINUX_PLATFORM}-${LINUX_ARCH}`));
+ const source = path.resolve(APP_IMAGE_DIR);
const destination = path.resolve(path.join(common.BASE_DIR_BUILD, `sieve-${version}-${LINUX_PLATFORM}-${LINUX_ARCH}.AppImage`));
- exec(`${tool} "${source}" "${destination}" 2>&1`);
+ await exec(`${tool} "${source}" "${destination}" 2>&1`);
}
@@ -528,7 +603,9 @@ exports["packageBootstrap"] = packageBootstrap;
exports["packageMaterialIcons"] = packageMaterialIcons;
exports["packageLicense"] = packageLicense;
exports["packageSrc"] = packageSrc;
-exports["packageCommon"] = packageCommon;
+exports["packageLibManageSieve"] = packageLibManageSieve;
+exports["packageLibSieve"] = packageLibSieve;
+exports["packageManageSieveUi"] = packageManageSieveUi;
exports["packageWin32"] = series(
packageWin32,
@@ -549,16 +626,25 @@ exports["zipWin32"] = zipWin32;
exports["zipLinux"] = zipLinux;
exports["zipMacOs"] = zipMacOs;
-exports["appImageLinux"] = appImageLinux;
+exports["appImageLinux"] = series(
+ packageAppImageDir,
+ packageAppImageFiles,
+ packageAppImage
+);
-exports['package'] = parallel(
+exports['package'] = series(
packageDefinition,
- packageJQuery,
- packageCodeMirror,
- packageBootstrap,
- packageMaterialIcons,
- packageLicense,
- packageSrc,
- packageCommon,
- packageKeytar
+ parallel(
+ packageLicense,
+ packageIcons,
+ packageJQuery,
+ packageCodeMirror,
+ packageBootstrap,
+ packageMaterialIcons,
+ packageLibManageSieve,
+ packageLibSieve,
+ packageManageSieveUi,
+ packageKeytar
+ ),
+ packageSrc
);
diff --git a/gulp/gulpfile.common.js b/gulp/gulpfile.common.js
index 031f4e5f..e2926d2b 100644
--- a/gulp/gulpfile.common.js
+++ b/gulp/gulpfile.common.js
@@ -28,6 +28,10 @@ const BASE_DIR_CODEMIRROR = "./node_modules/codemirror";
const BASE_DIR_COMMON = "./src/common";
const BASE_DIR_BUILD = "./build";
+const BASE_DIR_LIBMANAGESIEVE = path.join(BASE_DIR_COMMON, "libManageSieve");
+const BASE_DIR_LIBSIEVE = path.join(BASE_DIR_COMMON, "libSieve");
+const BASE_DIR_MANAGESIEVEUI = path.join(BASE_DIR_COMMON, "managesieve.ui");
+
const INDEX_MAJOR = 0;
const INDEX_MINOR = 1;
const INDEX_PATCH = 2;
@@ -148,6 +152,60 @@ function packageMaterialIcons(destination) {
}
/**
+ * Packages the common libManageSieve files
+ *
+ * @param {string} destination
+ * where to place the common libManageSieve files
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibManageSieve(destination) {
+ "use strict";
+
+ return src([
+ BASE_DIR_LIBMANAGESIEVE + "/**"
+ ], { base: BASE_DIR_COMMON }).pipe(dest(destination));
+}
+
+/**
+ * Packages the common libSieve files
+ *
+ * @param {string} destination
+ * where to place the common libSieve files
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibSieve(destination) {
+ "use strict";
+
+ return src([
+ BASE_DIR_LIBSIEVE + "/**",
+ "!" + BASE_DIR_LIBSIEVE + "/libSieve/**/rfc*.txt",
+ "!" + BASE_DIR_LIBSIEVE + "/libSieve/**/tests/",
+ "!" + BASE_DIR_LIBSIEVE + "/libSieve/**/tests/**"
+ ], { base: BASE_DIR_COMMON }).pipe(dest(destination));
+}
+
+/**
+ * Packages the common managesieve.ui files
+ *
+ * @param {string} destination
+ * where to place the common managesieve.ui files
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageManageSieveUi(destination) {
+ "use strict";
+
+ return src([
+ BASE_DIR_MANAGESIEVEUI + "/**"
+ ], { base: BASE_DIR_COMMON }).pipe(dest(destination));
+}
+
+/**
* Extracts the version from the package.json file
*
* @param {string} [file]
@@ -360,6 +418,10 @@ exports["packageCodeMirror"] = packageCodeMirror;
exports["packageBootstrap"] = packageBootstrap;
exports["packageMaterialIcons"] = packageMaterialIcons;
+exports["packageLibManageSieve"] = packageLibManageSieve;
+exports["packageLibSieve"] = packageLibSieve;
+exports["packageManageSieveUi"] = packageManageSieveUi;
+
exports["getPackageVersion"] = getPackageVersion;
exports["setPackageVersion"] = setPackageVersion;
diff --git a/gulp/gulpfile.wx.js b/gulp/gulpfile.wx.js
index 0d6951f6..9455e77b 100644
--- a/gulp/gulpfile.wx.js
+++ b/gulp/gulpfile.wx.js
@@ -9,15 +9,19 @@
* Thomas Schmid <schmid-thomas@gmx.net>
*/
-const { src, dest, watch, parallel } = require('gulp');
+const { src, dest, watch, parallel, series } = require('gulp');
const common = require("./gulpfile.common.js");
const path = require('path');
const BUILD_DIR_WX = path.join(common.BASE_DIR_BUILD, "thunderbird-wx");
+const BUILD_DIR_WX_LIBS = path.join(BUILD_DIR_WX, '/libs');
+
const BASE_DIR_WX = "./src/wx/";
+
+
/**
* Copies the license file into the build directory.
*
@@ -98,21 +102,54 @@ function packageSrc() {
}
/**
- * The common files need to go into the app/lib directory...
+ * Copies the application's icons into the lib folder.
+ * We use it internally for windows decoration.
*
* @returns {Stream}
* a stream to be consumed by gulp
*/
-function packageCommon() {
+function packageIcons() {
"use strict";
return src([
- common.BASE_DIR_COMMON + "/**",
- // Filter out the rfc documents
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/rfc*.txt",
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/tests/",
- "!" + common.BASE_DIR_COMMON + "/libSieve/**/tests/**"
- ]).pipe(dest(BUILD_DIR_WX + '/libs'));
+ path.join(common.BASE_DIR_COMMON, "icons") + "/**"
+ ], { base: common.BASE_DIR_COMMON }).pipe(dest(BUILD_DIR_WX_LIBS));
+}
+
+/**
+ * Copies the common libManageSieve files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibManageSieve() {
+ "use strict";
+ return common.packageLibManageSieve(BUILD_DIR_WX_LIBS);
+}
+
+
+/**
+ * Copies the common libSieve files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageLibSieve() {
+ "use strict";
+ return common.packageLibSieve(BUILD_DIR_WX_LIBS);
+}
+
+
+/**
+ * Copies the common managesieve.ui files into the app's lib folder
+ *
+ * @returns {Stream}
+ * a stream to be consumed by gulp
+ */
+function packageManageSieveUi() {
+ "use strict";
+
+ return common.packageManageSieveUi(BUILD_DIR_WX_LIBS);
}
@@ -132,7 +169,9 @@ function watchSrc() {
'./src/**/*.json'],
parallel(
packageSrc,
- packageCommon)
+ packageManageSieveUi,
+ packageLibSieve,
+ packageLibManageSieve)
);
}
@@ -172,16 +211,20 @@ exports["packageBootstrap"] = packageBootstrap;
exports["packageMaterialIcons"] = packageMaterialIcons;
exports["packageLicense"] = packageLicense;
exports["packageSrc"] = packageSrc;
-exports["packageCommon"] = packageCommon;
-
-exports['package'] = parallel(
- packageJQuery,
- packageCodeMirror,
- packageBootstrap,
- packageMaterialIcons,
- packageLicense,
- packageSrc,
- packageCommon
+
+exports['package'] = series(
+ parallel(
+ packageJQuery,
+ packageCodeMirror,
+ packageBootstrap,
+ packageMaterialIcons,
+ packageLicense,
+ packageIcons,
+ packageLibManageSieve,
+ packageLibSieve,
+ packageManageSieveUi
+ ),
+ packageSrc
);
exports["packageXpi"] = packageXpi;