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
diff options
context:
space:
mode:
-rw-r--r--gulp/gulpfile.app.js39
-rw-r--r--gulp/gulpfile.common.js130
-rw-r--r--gulp/gulpfile.wx.js16
-rwxr-xr-xgulpfile.js10
-rw-r--r--package.json2
-rw-r--r--yarn.lock50
6 files changed, 172 insertions, 75 deletions
diff --git a/gulp/gulpfile.app.js b/gulp/gulpfile.app.js
index 32764e64..595199f6 100644
--- a/gulp/gulpfile.app.js
+++ b/gulp/gulpfile.app.js
@@ -124,7 +124,6 @@ async function packageWin32() {
arch: "ia32",
platform: "win32",
download: {
- // cache: path.join(common.BASE_DIR_BUILD, "/electron/cache"),
cacheRoot: path.join(common.BASE_DIR_BUILD, "/electron/cache")
},
out: path.join(common.BASE_DIR_BUILD, "/electron/out"),
@@ -220,6 +219,41 @@ function watchSrc() {
);
}
+/**
+ * Zip the windows electron app.
+ */
+async function zipWin32() {
+ "use strict";
+
+ const version = (await common.getPackageVersion()).join(".");
+
+ const source = path.resolve(path.join(common.BASE_DIR_BUILD, "/electron/out/sieve-win32-ia32"));
+ const destination = path.join(common.BASE_DIR_BUILD, `sieve-${version}-win32-ia32.zip`);
+
+ await common.compress(source, destination);
+}
+
+/**
+ * Zip the linux electron app.
+ */
+async function zipLinux() {
+ "use strict";
+
+ const version = (await common.getPackageVersion()).join(".");
+
+ const source = path.resolve(path.join(common.BASE_DIR_BUILD, "/electron/out/sieve-linux-x64"));
+ const destination = path.join(common.BASE_DIR_BUILD, `sieve-${version}-linux-x64.zip`);
+
+ const options = {
+ permissions: {
+ "sieve": 0o100770,
+ "*": 0o100660
+ }
+ };
+
+ await common.compress(source, destination, options);
+}
+
exports["watch"] = watchSrc;
exports["updateVersion"] = updateVersion;
@@ -237,6 +271,9 @@ exports["packageWin32"] = packageWin32;
exports["packageLinux"] = packageLinux;
exports["packageMacOS"] = packageMacOS;
+exports["zipWin32"] = zipWin32;
+exports["zipLinux"] = zipLinux;
+
exports['package'] = parallel(
packageDefinition,
packageJQuery,
diff --git a/gulp/gulpfile.common.js b/gulp/gulpfile.common.js
index 4eb5a0ea..84b483df 100644
--- a/gulp/gulpfile.common.js
+++ b/gulp/gulpfile.common.js
@@ -9,10 +9,17 @@
* Thomas Schmid <schmid-thomas@gmx.net>
*/
-const fs = require('fs');
const { src, dest } = require('gulp');
const logger = require('gulplog');
+const { readdir, unlink, rmdir, readFile, writeFile } = require('fs').promises;
+const { createWriteStream, existsSync } = require('fs');
+
+const path = require('path');
+const yazl = require('yazl');
+
+
+
const BASE_DIR_BOOTSTRAP = "./node_modules/bootstrap/dist";
const BASE_DIR_MATERIALICONS = "./node_modules/material-design-icons-iconfont/dist";
const BASE_DIR_JQUERY = "./node_modules/jquery/dist";
@@ -28,28 +35,29 @@ const INDEX_PATCH = 2;
/**
* Delete all files from the given path.
*
- * @param {string} path
+ * @param {string} dir
* the base path which should be cleared.
*/
-async function deleteRecursive(path) {
+async function deleteRecursive(dir) {
"use strict";
- if (! fs.existsSync(path))
+ if (! existsSync(dir))
return;
- const files = await fs.promises.readdir(path);
+ const items = await readdir(dir, { withFileTypes: true });
+
+ for (const item of items) {
+ const curPath = path.join(dir, item.name);
- for (const file of files) {
- const curPath = path + "/" + file;
- if (!(await fs.promises.lstat(curPath)).isDirectory()) {
- await fs.promises.unlink(curPath);
+ if (!item.isDirectory()) {
+ await unlink(curPath);
continue;
}
await deleteRecursive(curPath);
}
- await fs.promises.rmdir(path);
+ await rmdir(dir);
}
/**
@@ -141,7 +149,7 @@ async function getPackageVersion(file) {
if ((typeof (file) === "undefined") || file === null)
file = "./package.json";
- let version = JSON.parse(await fs.promises.readFile(file, 'utf8')).version;
+ let version = JSON.parse(await readFile(file, 'utf8')).version;
version = version.split(".");
@@ -169,10 +177,10 @@ async function setPackageVersion(version, file) {
logger.info(`Updating ${file} to ${version}`);
- const data = JSON.parse(await fs.promises.readFile(file, 'utf8'));
+ const data = JSON.parse(await readFile(file, 'utf8'));
data.version = version;
- await fs.promises.writeFile(file, JSON.stringify(data, null, 2), 'utf-8');
+ await writeFile(file, JSON.stringify(data, null, 2), 'utf-8');
}
// We can only use major, minor and patch. Everything else
@@ -235,7 +243,103 @@ async function bumpPatchVersion() {
await setPackageVersion(pkgVersion, './package.json');
}
+/**
+ * Compresses the given file or directory recursively.
+ *
+ * You can set special file permissions via the options.
+ * See the parent compress method for more details.
+ *
+ * The path's of zipped files are stored relative to an
+ * root directory. By default the root directory is set to
+ * the source directory. But you can override it by setting
+ * "options.root".
+ *
+ * @param {ZipFile} zip
+ * the yazl object
+ * @param {string} dir
+ * the directory or file which should be compressed.
+ * @param {object} options
+ * extended instructions for compressing.
+ */
+async function compressDirectory(zip, dir, options) {
+ "use strict";
+
+ if (typeof (options) === "undefined" || options === null)
+ options = {};
+
+ if (!options.root)
+ options.root = dir;
+
+ const dirs = await readdir(dir, { withFileTypes: true });
+
+ for (const item of dirs) {
+
+ const realPath = path.join(dir, item.name);
+ const metaPath = path.relative(options.root, realPath);
+
+ if (item.isDirectory()) {
+ zip.addEmptyDirectory(metaPath);
+ compressDirectory(zip, realPath, options);
+ continue;
+ }
+
+ let fileOptions = null;
+ if (options.permissions) {
+ if (options.permissions[metaPath])
+ fileOptions = { mode: options.permissions[metaPath] };
+
+ if (options.permissions["*"]) {
+ fileOptions = { mode: options.permissions["*"] };
+ }
+ }
+
+ zip.addFile(realPath, metaPath, fileOptions);
+ }
+}
+
+/**
+ * Stores and compresses all data from the source directory
+ * into the destination file
+ *
+ * You can change the default permissions for all files by setting
+ * the option "permissions[*]" to the desired permission.
+ *
+ * To change the permission for a single file just specify the
+ * meta file name instead of the asterisk.
+ *
+ * @param {string} source
+ * the source directory or file.
+ * @param {string} destination
+ * the destination file. In case it exists it will be overwritten.
+ * @param {object} options
+ * extended instructions for compressing.
+ */
+async function compress(source, destination, options) {
+
+ "use strict";
+
+ if (existsSync(destination)) {
+ logger.info(`Deleting ${path.basename(destination)}`);
+ await unlink(destination);
+ }
+
+ logger.info(`Compressing ${path.basename(destination)}`);
+
+ const zip = new yazl.ZipFile();
+
+ await compressDirectory(zip, source, options);
+
+ await new Promise((resolve) => {
+ zip.outputStream
+ .pipe(createWriteStream(destination))
+ .on("close", () => { resolve(); });
+
+ zip.end();
+ });
+}
+
exports["clean"] = clean;
+exports["compress"] = compress;
exports["packageJQuery"] = packageJQuery;
exports["packageCodeMirror"] = packageCodeMirror;
diff --git a/gulp/gulpfile.wx.js b/gulp/gulpfile.wx.js
index 59f96320..71b86005 100644
--- a/gulp/gulpfile.wx.js
+++ b/gulp/gulpfile.wx.js
@@ -11,14 +11,9 @@
const { src, dest, watch, parallel } = require('gulp');
-const { unlink } = require('fs').promises;
-const { existsSync } = require('fs');
-
const common = require("./gulpfile.common.js");
-const zip = require('gulp-zip');
const path = require('path');
-const logger = require('gulplog');
const BUILD_DIR_WX = path.join(common.BASE_DIR_BUILD, "thunderbird-wx");
const BASE_DIR_WX = "./src/wx/";
@@ -142,15 +137,10 @@ async function packageXpi() {
const version = (await common.getPackageVersion()).join(".");
- if (existsSync(`./release/thunderbird/sieve-${version}.xpi`)) {
- logger.info(`Deleting sieve-${version}.xpi`);
- await unlink(`./release/thunderbird/sieve-${version}.xpi`);
- }
+ const destination = path.resolve(common.BASE_DIR_BUILD, `sieve-${version}.xpi`);
+ const source = path.resolve(`./${BUILD_DIR_WX}/`);
- logger.info(`Packaging sieve-${version}.xpi`);
- await src([`./${BUILD_DIR_WX}/**`], {buffer:false})
- .pipe(zip(`sieve-${version}.xpi`))
- .pipe(dest('./release/thunderbird'));
+ await common.compress(source, destination);
}
diff --git a/gulpfile.js b/gulpfile.js
index 91b2207a..38bfccf7 100755
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -35,11 +35,21 @@ exports['app:package-win32'] = series(
app.packageWin32
);
+exports['app:zip-win32'] = series(
+ exports['app:package-win32'],
+ app.zipWin32
+);
+
exports['app:package-linux'] = series(
app.package,
app.packageLinux
);
+exports['app:zip-linux'] = series(
+ exports['app:package-linux'],
+ app.zipLinux
+);
+
exports['app:package-macos'] = series(
app.package,
app.packageMacOS
diff --git a/package.json b/package.json
index c572532d..d981cfe1 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"eslint": "^6.4.0",
"eslint-plugin-jsdoc": "^21.0.0",
"gulp": "^4.0.0",
- "gulp-zip": "^5.0.0",
+ "yazl": "^2.5.1",
"jquery": "^3.4.1",
"material-design-icons-iconfont": "^5.0.1"
},
diff --git a/yarn.lock b/yarn.lock
index 9f2be24a..4bccef16 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1635,17 +1635,6 @@ gulp-cli@^2.2.0:
v8flags "^3.0.1"
yargs "^7.1.0"
-gulp-zip@^5.0.0:
- version "5.0.1"
- resolved "https://registry.yarnpkg.com/gulp-zip/-/gulp-zip-5.0.1.tgz#0dba5094901b0d91bcc8b53b3f6ff797c0f2002d"
- integrity sha512-M/IWLh9RvOpuofDZkgDirtiyz9J3yIqnDOJ3muzk2D/XnZ1ruqPlPLRIpXnl/aZU+xXwKPdOIxjRzkUcVEQyZQ==
- dependencies:
- get-stream "^5.1.0"
- plugin-error "^1.0.1"
- through2 "^3.0.1"
- vinyl "^2.1.0"
- yazl "^2.5.1"
-
gulp@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/gulp/-/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa"
@@ -2779,16 +2768,6 @@ plist@^3.0.0, plist@^3.0.1:
xmlbuilder "^9.0.7"
xmldom "0.1.x"
-plugin-error@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c"
- integrity sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==
- dependencies:
- ansi-colors "^1.0.1"
- arr-diff "^4.0.0"
- arr-union "^3.1.0"
- extend-shallow "^3.0.2"
-
posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
@@ -2903,15 +2882,6 @@ read-pkg@^2.0.0:
normalize-package-data "^2.3.2"
path-type "^2.0.0"
-"readable-stream@2 || 3":
- version "3.4.0"
- resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc"
- integrity sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==
- dependencies:
- inherits "^2.0.3"
- string_decoder "^1.1.1"
- util-deprecate "^1.0.1"
-
readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
@@ -3134,7 +3104,7 @@ rxjs@^6.5.3:
dependencies:
tslib "^1.9.0"
-safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@~5.2.0:
+safe-buffer@^5.1.0, safe-buffer@^5.1.2:
version "5.2.0"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519"
integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==
@@ -3400,13 +3370,6 @@ string-width@^4.1.0:
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.0"
-string_decoder@^1.1.1:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e"
- integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==
- dependencies:
- safe-buffer "~5.2.0"
-
string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
@@ -3530,13 +3493,6 @@ through2@^2.0.0, through2@^2.0.3, through2@~2.0.0:
readable-stream "~2.3.6"
xtend "~4.0.1"
-through2@^3.0.1:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.1.tgz#39276e713c3302edf9e388dd9c812dd3b825bd5a"
- integrity sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==
- dependencies:
- readable-stream "2 || 3"
-
through@^2.3.6:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@@ -3743,7 +3699,7 @@ utf8-byte-length@^1.0.1:
resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61"
integrity sha1-9F8VDExm7uloGGUFq5P8u4rWv2E=
-util-deprecate@^1.0.1, util-deprecate@~1.0.1:
+util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
@@ -3809,7 +3765,7 @@ vinyl-sourcemap@^1.1.0:
remove-bom-buffer "^3.0.0"
vinyl "^2.0.0"
-vinyl@^2.0.0, vinyl@^2.1.0:
+vinyl@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86"
integrity sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==