mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-15 20:35:23 +03:00
Fix some Sonar issue of gulpfile
This commit is contained in:
parent
7fcc9efc72
commit
d27f1b806c
1 changed files with 124 additions and 120 deletions
244
gulpfile.js
244
gulpfile.js
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
// remove gulp-appdmg from the package.json we're going to write
|
// remove gulp-appdmg from the package.json we're going to write
|
||||||
delete pkg.optionalDependencies['gulp-appdmg'];
|
delete pkg.optionalDependencies['gulp-appdmg'];
|
||||||
|
|
||||||
|
@ -46,18 +46,18 @@ const LINUX_INSTALL_DIR = '/opt/betaflight';
|
||||||
const NODE_ENV = process.env.NODE_ENV || 'production';
|
const NODE_ENV = process.env.NODE_ENV || 'production';
|
||||||
|
|
||||||
// Global variable to hold the change hash from when we get it, to when we use it.
|
// Global variable to hold the change hash from when we get it, to when we use it.
|
||||||
var gitChangeSetId;
|
let gitChangeSetId;
|
||||||
|
|
||||||
var nwBuilderOptions = {
|
const nwBuilderOptions = {
|
||||||
version: '0.47.0',
|
version: '0.47.0',
|
||||||
files: './dist/**/*',
|
files: './dist/**/*',
|
||||||
macIcns: './src/images/bf_icon.icns',
|
macIcns: './src/images/bf_icon.icns',
|
||||||
macPlist: { 'CFBundleDisplayName': 'Betaflight Configurator'},
|
macPlist: { 'CFBundleDisplayName': 'Betaflight Configurator'},
|
||||||
winIco: './src/images/bf_icon.ico',
|
winIco: './src/images/bf_icon.ico',
|
||||||
zip: false
|
zip: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
var nwArmVersion = '0.27.6';
|
const nwArmVersion = '0.27.6';
|
||||||
|
|
||||||
let cordovaDependencies = true;
|
let cordovaDependencies = true;
|
||||||
|
|
||||||
|
@ -119,11 +119,11 @@ gulp.task('default', debugBuild);
|
||||||
// #
|
// #
|
||||||
function getInputPlatforms() {
|
function getInputPlatforms() {
|
||||||
const supportedPlatforms = ['linux64', 'linux32', 'armv7', 'osx64', 'win32', 'win64', 'android'];
|
const supportedPlatforms = ['linux64', 'linux32', 'armv7', 'osx64', 'win32', 'win64', 'android'];
|
||||||
var platforms = [];
|
const platforms = [];
|
||||||
var regEx = /--(\w+)/;
|
const regEx = /--(\w+)/;
|
||||||
console.log(process.argv);
|
console.log(process.argv);
|
||||||
for (var i = 3; i < process.argv.length; i++) {
|
for (let i = 3; i < process.argv.length; i++) {
|
||||||
var arg = process.argv[i].match(regEx)[1];
|
const arg = process.argv[i].match(regEx)[1];
|
||||||
if (supportedPlatforms.indexOf(arg) > -1) {
|
if (supportedPlatforms.indexOf(arg) > -1) {
|
||||||
platforms.push(arg);
|
platforms.push(arg);
|
||||||
} else if (arg === 'nowinicon') {
|
} else if (arg === 'nowinicon') {
|
||||||
|
@ -133,13 +133,13 @@ function getInputPlatforms() {
|
||||||
console.log('ignoring cordova dependencies');
|
console.log('ignoring cordova dependencies');
|
||||||
cordovaDependencies = false;
|
cordovaDependencies = false;
|
||||||
} else {
|
} else {
|
||||||
console.log('Unknown platform: ' + arg);
|
console.log(`Unknown platform: ${arg}`);
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platforms.length === 0) {
|
if (platforms.length === 0) {
|
||||||
var defaultPlatform = getDefaultPlatform();
|
const defaultPlatform = getDefaultPlatform();
|
||||||
if (supportedPlatforms.indexOf(defaultPlatform) > -1) {
|
if (supportedPlatforms.indexOf(defaultPlatform) > -1) {
|
||||||
platforms.push(defaultPlatform);
|
platforms.push(defaultPlatform);
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,7 +149,7 @@ function getInputPlatforms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platforms.length > 0) {
|
if (platforms.length > 0) {
|
||||||
console.log('Building for platform(s): ' + platforms + '.');
|
console.log(`Building for platform(s): ${platforms}.`);
|
||||||
} else {
|
} else {
|
||||||
console.error('No suitables platforms found.');
|
console.error('No suitables platforms found.');
|
||||||
process.exit();
|
process.exit();
|
||||||
|
@ -160,7 +160,7 @@ function getInputPlatforms() {
|
||||||
|
|
||||||
// Gets the default platform to be used
|
// Gets the default platform to be used
|
||||||
function getDefaultPlatform() {
|
function getDefaultPlatform() {
|
||||||
var defaultPlatform;
|
let defaultPlatform;
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
defaultPlatform = 'osx64';
|
defaultPlatform = 'osx64';
|
||||||
|
@ -189,7 +189,7 @@ function getPlatforms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeItem(platforms, item) {
|
function removeItem(platforms, item) {
|
||||||
var index = platforms.indexOf(item);
|
const index = platforms.indexOf(item);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
platforms.splice(index, 1);
|
platforms.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
@ -233,19 +233,19 @@ function getReleaseFilename(platform, ext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_dist() {
|
function clean_dist() {
|
||||||
return del([DIST_DIR + '**'], { force: true });
|
return del([`${DIST_DIR}**`], { force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_apps() {
|
function clean_apps() {
|
||||||
return del([APPS_DIR + '**'], { force: true });
|
return del([`${APPS_DIR}**`], { force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_debug() {
|
function clean_debug() {
|
||||||
return del([DEBUG_DIR + '**'], { force: true });
|
return del([`${DEBUG_DIR}**`], { force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_release() {
|
function clean_release() {
|
||||||
return del([RELEASE_DIR + '**'], { force: true });
|
return del([`${RELEASE_DIR}**`], { force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_cache() {
|
function clean_cache() {
|
||||||
|
@ -255,12 +255,12 @@ function clean_cache() {
|
||||||
// Real work for dist task. Done in another task to call it via
|
// Real work for dist task. Done in another task to call it via
|
||||||
// run-sequence.
|
// run-sequence.
|
||||||
function dist_src() {
|
function dist_src() {
|
||||||
var distSources = [
|
const distSources = [
|
||||||
'./src/**/*',
|
'./src/**/*',
|
||||||
'!./src/css/dropdown-lists/LICENSE',
|
'!./src/css/dropdown-lists/LICENSE',
|
||||||
'!./src/support/**'
|
'!./src/support/**',
|
||||||
];
|
];
|
||||||
var packageJson = new stream.Readable;
|
const packageJson = new stream.Readable;
|
||||||
packageJson.push(JSON.stringify(pkg,undefined,2));
|
packageJson.push(JSON.stringify(pkg,undefined,2));
|
||||||
packageJson.push(null);
|
packageJson.push(null);
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ function dist_src() {
|
||||||
|
|
||||||
function dist_changelog() {
|
function dist_changelog() {
|
||||||
return gulp.src('changelog.html')
|
return gulp.src('changelog.html')
|
||||||
.pipe(gulp.dest(DIST_DIR+"tabs/"));
|
.pipe(gulp.dest(`${DIST_DIR}tabs/`));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function relies on files from the dist_src function
|
// This function relies on files from the dist_src function
|
||||||
|
@ -281,18 +281,18 @@ function dist_yarn() {
|
||||||
return gulp.src(['./dist/package.json', './dist/yarn.lock'])
|
return gulp.src(['./dist/package.json', './dist/yarn.lock'])
|
||||||
.pipe(gulp.dest('./dist'))
|
.pipe(gulp.dest('./dist'))
|
||||||
.pipe(yarn({
|
.pipe(yarn({
|
||||||
production: true
|
production: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function dist_locale() {
|
function dist_locale() {
|
||||||
return gulp.src('./locales/**/*', { base: 'locales'})
|
return gulp.src('./locales/**/*', { base: 'locales'})
|
||||||
.pipe(gulp.dest(DIST_DIR + '_locales'));
|
.pipe(gulp.dest(`${DIST_DIR}_locales`));
|
||||||
}
|
}
|
||||||
|
|
||||||
function dist_libraries() {
|
function dist_libraries() {
|
||||||
return gulp.src('./libraries/**/*', { base: '.'})
|
return gulp.src('./libraries/**/*', { base: '.'})
|
||||||
.pipe(gulp.dest(DIST_DIR + 'js'));
|
.pipe(gulp.dest(`${DIST_DIR}js`));
|
||||||
}
|
}
|
||||||
|
|
||||||
function dist_resources() {
|
function dist_resources() {
|
||||||
|
@ -334,38 +334,38 @@ function dist_rollup() {
|
||||||
|
|
||||||
// Create runable app directories in ./apps
|
// Create runable app directories in ./apps
|
||||||
function apps(done) {
|
function apps(done) {
|
||||||
var platforms = getPlatforms();
|
const platforms = getPlatforms();
|
||||||
removeItem(platforms, 'android');
|
removeItem(platforms, 'android');
|
||||||
|
|
||||||
buildNWAppsWrapper(platforms, 'normal', APPS_DIR, done);
|
buildNWAppsWrapper(platforms, 'normal', APPS_DIR, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
function listPostBuildTasks(folder, done) {
|
function listPostBuildTasks(folder) {
|
||||||
|
|
||||||
var platforms = getPlatforms();
|
const platforms = getPlatforms();
|
||||||
|
|
||||||
var postBuildTasks = [];
|
const postBuildTasks = [];
|
||||||
|
|
||||||
if (platforms.indexOf('linux32') != -1) {
|
if (platforms.indexOf('linux32') !== -1) {
|
||||||
postBuildTasks.push(function post_build_linux32(done) {
|
postBuildTasks.push(function post_build_linux32(done) {
|
||||||
return post_build('linux32', folder, done);
|
return post_build('linux32', folder, done);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platforms.indexOf('linux64') != -1) {
|
if (platforms.indexOf('linux64') !== -1) {
|
||||||
postBuildTasks.push(function post_build_linux64(done) {
|
postBuildTasks.push(function post_build_linux64(done) {
|
||||||
return post_build('linux64', folder, done);
|
return post_build('linux64', folder, done);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platforms.indexOf('armv7') != -1) {
|
if (platforms.indexOf('armv7') !== -1) {
|
||||||
postBuildTasks.push(function post_build_armv7(done) {
|
postBuildTasks.push(function post_build_armv7(done) {
|
||||||
return post_build('armv7', folder, done);
|
return post_build('armv7', folder, done);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to return at least one task, if not gulp will throw an error
|
// We need to return at least one task, if not gulp will throw an error
|
||||||
if (postBuildTasks.length == 0) {
|
if (postBuildTasks.length === 0) {
|
||||||
postBuildTasks.push(function post_build_none(done) {
|
postBuildTasks.push(function post_build_none(done) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -377,8 +377,8 @@ function post_build(arch, folder, done) {
|
||||||
|
|
||||||
if ((arch === 'linux32') || (arch === 'linux64')) {
|
if ((arch === 'linux32') || (arch === 'linux64')) {
|
||||||
// Copy Ubuntu launcher scripts to destination dir
|
// Copy Ubuntu launcher scripts to destination dir
|
||||||
var launcherDir = path.join(folder, pkg.name, arch);
|
const launcherDir = path.join(folder, pkg.name, arch);
|
||||||
console.log('Copy Ubuntu launcher scripts to ' + launcherDir);
|
console.log(`Copy Ubuntu launcher scripts to ${launcherDir}`);
|
||||||
return gulp.src('assets/linux/**')
|
return gulp.src('assets/linux/**')
|
||||||
.pipe(gulp.dest(launcherDir));
|
.pipe(gulp.dest(launcherDir));
|
||||||
}
|
}
|
||||||
|
@ -393,39 +393,40 @@ function post_build(arch, folder, done) {
|
||||||
|
|
||||||
// Create debug app directories in ./debug
|
// Create debug app directories in ./debug
|
||||||
function debug(done) {
|
function debug(done) {
|
||||||
var platforms = getPlatforms();
|
const platforms = getPlatforms();
|
||||||
removeItem(platforms, 'android');
|
removeItem(platforms, 'android');
|
||||||
|
|
||||||
buildNWAppsWrapper(platforms, 'sdk', DEBUG_DIR, done);
|
buildNWAppsWrapper(platforms, 'sdk', DEBUG_DIR, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectARMCache(flavor, callback) {
|
function injectARMCache(flavor, callback) {
|
||||||
var flavorPostfix = `-${flavor}`;
|
const flavorPostfix = `-${flavor}`;
|
||||||
var flavorDownloadPostfix = flavor !== 'normal' ? `-${flavor}` : '';
|
const flavorDownloadPostfix = flavor !== 'normal' ? `-${flavor}` : '';
|
||||||
clean_cache().then(function() {
|
clean_cache().then(function() {
|
||||||
if (!fs.existsSync('./cache')) {
|
if (!fs.existsSync('./cache')) {
|
||||||
fs.mkdirSync('./cache');
|
fs.mkdirSync('./cache');
|
||||||
}
|
}
|
||||||
fs.closeSync(fs.openSync('./cache/_ARMv7_IS_CACHED', 'w'));
|
fs.closeSync(fs.openSync('./cache/_ARMv7_IS_CACHED', 'w'));
|
||||||
var versionFolder = `./cache/${nwBuilderOptions.version}${flavorPostfix}`;
|
const versionFolder = `./cache/${nwBuilderOptions.version}${flavorPostfix}`;
|
||||||
if (!fs.existsSync(versionFolder)) {
|
if (!fs.existsSync(versionFolder)) {
|
||||||
fs.mkdirSync(versionFolder);
|
fs.mkdirSync(versionFolder);
|
||||||
}
|
}
|
||||||
if (!fs.existsSync(versionFolder + '/linux32')) {
|
const linux32Folder = `${versionFolder}/linux32`;
|
||||||
fs.mkdirSync(`${versionFolder}/linux32`);
|
if (!fs.existsSync(linux32Folder)) {
|
||||||
|
fs.mkdirSync(linux32Folder);
|
||||||
}
|
}
|
||||||
var downloadedArchivePath = `${versionFolder}/nwjs${flavorPostfix}-v${nwArmVersion}-linux-arm.tar.gz`;
|
const downloadedArchivePath = `${versionFolder}/nwjs${flavorPostfix}-v${nwArmVersion}-linux-arm.tar.gz`;
|
||||||
var downloadUrl = `https://github.com/LeonardLaszlo/nw.js-armv7-binaries/releases/download/v${nwArmVersion}/nwjs${flavorDownloadPostfix}-v${nwArmVersion}-linux-arm.tar.gz`;
|
const downloadUrl = `https://github.com/LeonardLaszlo/nw.js-armv7-binaries/releases/download/v${nwArmVersion}/nwjs${flavorDownloadPostfix}-v${nwArmVersion}-linux-arm.tar.gz`;
|
||||||
if (fs.existsSync(downloadedArchivePath)) {
|
if (fs.existsSync(downloadedArchivePath)) {
|
||||||
console.log('Prebuilt ARMv7 binaries found in /tmp');
|
console.log('Prebuilt ARMv7 binaries found in /tmp');
|
||||||
downloadDone(flavorDownloadPostfix, downloadedArchivePath, versionFolder);
|
downloadDone(flavorDownloadPostfix, downloadedArchivePath, versionFolder);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Downloading prebuilt ARMv7 binaries from "${downloadUrl}"...`);
|
console.log(`Downloading prebuilt ARMv7 binaries from "${downloadUrl}"...`);
|
||||||
process.stdout.write('> Starting download...\r');
|
process.stdout.write('> Starting download...\r');
|
||||||
var armBuildBinary = fs.createWriteStream(downloadedArchivePath);
|
const armBuildBinary = fs.createWriteStream(downloadedArchivePath);
|
||||||
var request = https.get(downloadUrl, function(res) {
|
https.get(downloadUrl, function(res) {
|
||||||
var totalBytes = res.headers['content-length'];
|
const totalBytes = res.headers['content-length'];
|
||||||
var downloadedBytes = 0;
|
let downloadedBytes = 0;
|
||||||
res.pipe(armBuildBinary);
|
res.pipe(armBuildBinary);
|
||||||
res.on('data', function (chunk) {
|
res.on('data', function (chunk) {
|
||||||
downloadedBytes += chunk.length;
|
downloadedBytes += chunk.length;
|
||||||
|
@ -441,7 +442,7 @@ function injectARMCache(flavor, callback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function downloadDone(flavorDownloadPostfix, downloadedArchivePath, versionFolder) {
|
function downloadDone(flavorDownload, downloadedArchivePath, versionFolder) {
|
||||||
console.log('Injecting prebuilt ARMv7 binaries into Linux32 cache...');
|
console.log('Injecting prebuilt ARMv7 binaries into Linux32 cache...');
|
||||||
targz.decompress({
|
targz.decompress({
|
||||||
src: downloadedArchivePath,
|
src: downloadedArchivePath,
|
||||||
|
@ -453,11 +454,11 @@ function injectARMCache(flavor, callback) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
fs.rename(
|
fs.rename(
|
||||||
`${versionFolder}/nwjs${flavorDownloadPostfix}-v${nwArmVersion}-linux-arm`,
|
`${versionFolder}/nwjs${flavorDownload}-v${nwArmVersion}-linux-arm`,
|
||||||
`${versionFolder}/linux32`,
|
`${versionFolder}/linux32`,
|
||||||
(err) => {
|
(renameErr) => {
|
||||||
if (err) {
|
if (renameErr) {
|
||||||
console.log(err);
|
console.log(renameErr);
|
||||||
clean_debug();
|
clean_debug();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -487,7 +488,7 @@ function buildNWAppsWrapper(platforms, flavor, dir, done) {
|
||||||
console.log('Purging cache because it needs to be overwritten...');
|
console.log('Purging cache because it needs to be overwritten...');
|
||||||
clean_cache().then(() => {
|
clean_cache().then(() => {
|
||||||
injectARMCache(flavor, buildNWAppsCallback);
|
injectARMCache(flavor, buildNWAppsCallback);
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
buildNWAppsCallback();
|
buildNWAppsCallback();
|
||||||
}
|
}
|
||||||
|
@ -503,22 +504,22 @@ function buildNWAppsWrapper(platforms, flavor, dir, done) {
|
||||||
|
|
||||||
function buildNWApps(platforms, flavor, dir, done) {
|
function buildNWApps(platforms, flavor, dir, done) {
|
||||||
if (platforms.length > 0) {
|
if (platforms.length > 0) {
|
||||||
var builder = new NwBuilder(Object.assign({
|
const builder = new NwBuilder(Object.assign({
|
||||||
buildDir: dir,
|
buildDir: dir,
|
||||||
platforms: platforms,
|
platforms,
|
||||||
flavor: flavor
|
flavor,
|
||||||
}, nwBuilderOptions));
|
}, nwBuilderOptions));
|
||||||
builder.on('log', console.log);
|
builder.on('log', console.log);
|
||||||
builder.build(function (err) {
|
builder.build(function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Error building NW apps: ' + err);
|
console.log(`Error building NW apps: ${err}`);
|
||||||
clean_debug();
|
clean_debug();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('No platform suitable for NW Build')
|
console.log('No platform suitable for NW Build');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,28 +536,28 @@ function getHash(cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeChangesetId() {
|
function writeChangesetId() {
|
||||||
var versionJson = new stream.Readable;
|
const versionJson = new stream.Readable;
|
||||||
versionJson.push(JSON.stringify({
|
versionJson.push(JSON.stringify({
|
||||||
gitChangesetId: gitChangeSetId,
|
gitChangesetId: gitChangeSetId,
|
||||||
version: pkg.version
|
version: pkg.version,
|
||||||
}, undefined, 2));
|
}, undefined, 2));
|
||||||
versionJson.push(null);
|
versionJson.push(null);
|
||||||
return versionJson
|
return versionJson
|
||||||
.pipe(source('version.json'))
|
.pipe(source('version.json'))
|
||||||
.pipe(gulp.dest(DIST_DIR))
|
.pipe(gulp.dest(DIST_DIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_debug(done) {
|
function start_debug(done) {
|
||||||
|
|
||||||
var platforms = getPlatforms();
|
const platforms = getPlatforms();
|
||||||
|
|
||||||
var exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
if (platforms.length === 1) {
|
if (platforms.length === 1) {
|
||||||
if (platforms[0] === 'android') {
|
if (platforms[0] === 'android') {
|
||||||
cordova_debug();
|
cordova_debug();
|
||||||
} else {
|
} else {
|
||||||
var run = getRunDebugAppCommand(platforms[0]);
|
const run = getRunDebugAppCommand(platforms[0]);
|
||||||
console.log('Starting debug app (' + run + ')...');
|
console.log(`Starting debug app (${run})...`);
|
||||||
exec(run);
|
exec(run);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -619,28 +620,32 @@ function release_deb(arch, appDirectory, done) {
|
||||||
|
|
||||||
// Check if dpkg-deb exists
|
// Check if dpkg-deb exists
|
||||||
if (!commandExistsSync('dpkg-deb')) {
|
if (!commandExistsSync('dpkg-deb')) {
|
||||||
console.warn('dpkg-deb command not found, not generating deb package for ' + arch);
|
console.warn(`dpkg-deb command not found, not generating deb package for ${arch}`);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
return gulp.src([path.join(appDirectory, pkg.name, arch, '*')])
|
return gulp.src([path.join(appDirectory, pkg.name, arch, '*')])
|
||||||
.pipe(deb({
|
.pipe(deb({
|
||||||
package: pkg.name,
|
package: pkg.name,
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
section: 'base',
|
section: 'base',
|
||||||
priority: 'optional',
|
priority: 'optional',
|
||||||
architecture: getLinuxPackageArch('deb', arch),
|
architecture: getLinuxPackageArch('deb', arch),
|
||||||
maintainer: pkg.author,
|
maintainer: pkg.author,
|
||||||
description: pkg.description,
|
description: pkg.description,
|
||||||
preinst: [`rm -rf ${LINUX_INSTALL_DIR}/${pkg.name}`],
|
preinst: [`rm -rf ${LINUX_INSTALL_DIR}/${pkg.name}`],
|
||||||
postinst: [`chown root:root ${LINUX_INSTALL_DIR}`, `chown -R root:root ${LINUX_INSTALL_DIR}/${pkg.name}`, `xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${pkg.name}/${pkg.name}.desktop`],
|
postinst: [
|
||||||
prerm: [`xdg-desktop-menu uninstall ${pkg.name}.desktop`],
|
`chown root:root ${LINUX_INSTALL_DIR}`,
|
||||||
depends: 'libgconf-2-4',
|
`chown -R root:root ${LINUX_INSTALL_DIR}/${pkg.name}`,
|
||||||
changelog: [],
|
`xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${pkg.name}/${pkg.name}.desktop`,
|
||||||
_target: `${LINUX_INSTALL_DIR}/${pkg.name}`,
|
],
|
||||||
_out: RELEASE_DIR,
|
prerm: [`xdg-desktop-menu uninstall ${pkg.name}.desktop`],
|
||||||
_copyright: 'assets/linux/copyright',
|
depends: 'libgconf-2-4',
|
||||||
_clean: true
|
changelog: [],
|
||||||
|
_target: `${LINUX_INSTALL_DIR}/${pkg.name}`,
|
||||||
|
_out: RELEASE_DIR,
|
||||||
|
_copyright: 'assets/linux/copyright',
|
||||||
|
_clean: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,61 +653,62 @@ function release_rpm(arch, appDirectory, done) {
|
||||||
|
|
||||||
// Check if dpkg-deb exists
|
// Check if dpkg-deb exists
|
||||||
if (!commandExistsSync('rpmbuild')) {
|
if (!commandExistsSync('rpmbuild')) {
|
||||||
console.warn('rpmbuild command not found, not generating rpm package for ' + arch);
|
console.warn(`rpmbuild command not found, not generating rpm package for ${arch}`);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The buildRpm does not generate the folder correctly, manually
|
// The buildRpm does not generate the folder correctly, manually
|
||||||
createDirIfNotExists(RELEASE_DIR);
|
createDirIfNotExists(RELEASE_DIR);
|
||||||
|
|
||||||
var regex = /-/g;
|
const regex = /-/g;
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
version: pkg.version.replace(regex, '_'), // RPM does not like release candidate versions
|
version: pkg.version.replace(regex, '_'), // RPM does not like release candidate versions
|
||||||
buildArch: getLinuxPackageArch('rpm', arch),
|
buildArch: getLinuxPackageArch('rpm', arch),
|
||||||
vendor: pkg.author,
|
vendor: pkg.author,
|
||||||
summary: pkg.description,
|
summary: pkg.description,
|
||||||
license: 'GNU General Public License v3.0',
|
license: 'GNU General Public License v3.0',
|
||||||
requires: 'libgconf-2-4',
|
requires: 'libgconf-2-4',
|
||||||
prefix: '/opt',
|
prefix: '/opt',
|
||||||
files:
|
files: [{
|
||||||
[ { cwd: path.join(appDirectory, pkg.name, arch),
|
cwd: path.join(appDirectory, pkg.name, arch),
|
||||||
src: '*',
|
src: '*',
|
||||||
dest: `${LINUX_INSTALL_DIR}/${pkg.name}` } ],
|
dest: `${LINUX_INSTALL_DIR}/${pkg.name}`,
|
||||||
postInstallScript: [`xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${pkg.name}/${pkg.name}.desktop`],
|
}],
|
||||||
preUninstallScript: [`xdg-desktop-menu uninstall ${pkg.name}.desktop`],
|
postInstallScript: [`xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${pkg.name}/${pkg.name}.desktop`],
|
||||||
tempDir: path.join(RELEASE_DIR,'tmp-rpm-build-' + arch),
|
preUninstallScript: [`xdg-desktop-menu uninstall ${pkg.name}.desktop`],
|
||||||
keepTemp: false,
|
tempDir: path.join(RELEASE_DIR, `tmp-rpm-build-${arch}`),
|
||||||
verbose: false,
|
keepTemp: false,
|
||||||
rpmDest: RELEASE_DIR,
|
verbose: false,
|
||||||
execOpts: { maxBuffer: 1024 * 1024 * 16 },
|
rpmDest: RELEASE_DIR,
|
||||||
|
execOpts: { maxBuffer: 1024 * 1024 * 16 },
|
||||||
};
|
};
|
||||||
|
|
||||||
buildRpm(options, function(err, rpm) {
|
buildRpm(options, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("Error generating rpm package: " + err);
|
console.error(`Error generating rpm package: ${err}`);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLinuxPackageArch(type, arch) {
|
function getLinuxPackageArch(type, arch) {
|
||||||
var packArch;
|
let packArch;
|
||||||
|
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'linux32':
|
case 'linux32':
|
||||||
packArch = 'i386';
|
packArch = 'i386';
|
||||||
break;
|
break;
|
||||||
case 'linux64':
|
case 'linux64':
|
||||||
if (type == 'rpm') {
|
if (type === 'rpm') {
|
||||||
packArch = 'x86_64';
|
packArch = 'x86_64';
|
||||||
} else {
|
} else {
|
||||||
packArch = 'amd64';
|
packArch = 'amd64';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.error("Package error, arch: " + arch);
|
console.error(`Package error, arch: ${arch}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -711,7 +717,7 @@ function getLinuxPackageArch(type, arch) {
|
||||||
}
|
}
|
||||||
// Create distribution package for macOS platform
|
// Create distribution package for macOS platform
|
||||||
function release_osx64(appDirectory) {
|
function release_osx64(appDirectory) {
|
||||||
var appdmg = require('gulp-appdmg');
|
const appdmg = require('gulp-appdmg');
|
||||||
|
|
||||||
// The appdmg does not generate the folder correctly, manually
|
// The appdmg does not generate the folder correctly, manually
|
||||||
createDirIfNotExists(RELEASE_DIR);
|
createDirIfNotExists(RELEASE_DIR);
|
||||||
|
@ -725,16 +731,16 @@ function release_osx64(appDirectory) {
|
||||||
title: 'Betaflight Configurator',
|
title: 'Betaflight Configurator',
|
||||||
contents: [
|
contents: [
|
||||||
{ 'x': 448, 'y': 342, 'type': 'link', 'path': '/Applications' },
|
{ 'x': 448, 'y': 342, 'type': 'link', 'path': '/Applications' },
|
||||||
{ 'x': 192, 'y': 344, 'type': 'file', 'path': pkg.name + '.app', 'name': 'Betaflight Configurator.app' }
|
{ 'x': 192, 'y': 344, 'type': 'file', 'path': `${pkg.name}.app`, 'name': 'Betaflight Configurator.app' },
|
||||||
],
|
],
|
||||||
background: path.join(__dirname, 'assets/osx/dmg-background.png'),
|
background: path.join(__dirname, 'assets/osx/dmg-background.png'),
|
||||||
format: 'UDZO',
|
format: 'UDZO',
|
||||||
window: {
|
window: {
|
||||||
size: {
|
size: {
|
||||||
width: 638,
|
width: 638,
|
||||||
height: 479
|
height: 479,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -743,10 +749,8 @@ function release_osx64(appDirectory) {
|
||||||
// Create the dir directory, with write permissions
|
// Create the dir directory, with write permissions
|
||||||
function createDirIfNotExists(dir) {
|
function createDirIfNotExists(dir) {
|
||||||
fs.mkdir(dir, '0775', function(err) {
|
fs.mkdir(dir, '0775', function(err) {
|
||||||
if (err) {
|
if (err && err.code !== 'EEXIST') {
|
||||||
if (err.code !== 'EEXIST') {
|
throw err;
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -754,9 +758,9 @@ function createDirIfNotExists(dir) {
|
||||||
// Create a list of the gulp tasks to execute for release
|
// Create a list of the gulp tasks to execute for release
|
||||||
function listReleaseTasks(appDirectory) {
|
function listReleaseTasks(appDirectory) {
|
||||||
|
|
||||||
var platforms = getPlatforms();
|
const platforms = getPlatforms();
|
||||||
|
|
||||||
var releaseTasks = [];
|
const releaseTasks = [];
|
||||||
|
|
||||||
if (platforms.indexOf('linux64') !== -1) {
|
if (platforms.indexOf('linux64') !== -1) {
|
||||||
releaseTasks.push(function release_linux64_zip() {
|
releaseTasks.push(function release_linux64_zip() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue