Skip to content

Commit

Permalink
fix URL links
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Apr 30, 2024
1 parent 20b9663 commit 37e4cbc
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 91 deletions.
158 changes: 70 additions & 88 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ const LINUX_INSTALL_DIR = '/opt/emuflight';
// Global variable to hold the change hash from when we get it, to when we use it.
var gitChangeSetId;

// FIXME: hardcoded version number
// 0.45.6 Win7 connects; 0.42.3 fixed OSX Flashing; 0.46.X broke Win7 connect. maybe serial/usb needs updating
// reverted to 0.42.6 due to Windows increased CLI-tab buffer/autocomplete issues.
// 0.50.3 is last version to open Links properly. also works on Win11.
var NWversion;
if (os.platform() === 'win32') {
NWversion ='0.42.6'
Expand All @@ -52,13 +48,12 @@ if (os.platform() === 'win32') {
var nwBuilderOptions = {
version: NWversion,
files: './dist/**/*',
macIcns: './assets/osx/app-icon.icns',
macPlist: { 'CFBundleDisplayName': 'Emuflight Configurator'},
macIcns: '/assets/osx/app-icon.icns',
macPlist: { 'CFBundleDisplayName': 'EmuFlight Configurator'},
winIco: './src/images/emu_icon.ico',
zip: false
};

// FIXME: hardcoded version number
var nwArmVersion = '0.28.4';

//-----------------
Expand Down Expand Up @@ -87,21 +82,23 @@ const getChangesetId = gulp.series(getHash, writeChangesetId);
gulp.task('get-changeset-id', getChangesetId);

// dist_yarn MUST be done after dist_src
var distBuild = gulp.series(dist_src, dist_changelog, dist_yarn, dist_locale, dist_libraries, dist_resources, getChangesetId);
var distRebuild = gulp.series(clean_dist, distBuild);
const distBuild = gulp.series(dist_src, dist_changelog, dist_yarn, dist_locale, dist_libraries, dist_resources, getChangesetId);
const distRebuild = gulp.series(clean_dist, distBuild);
gulp.task('dist', distRebuild);

var appsBuild = gulp.series(gulp.parallel(clean_apps, distRebuild), apps, gulp.parallel(listPostBuildTasks(APPS_DIR)));
const appsBuild = gulp.series(gulp.parallel(clean_apps, distRebuild), apps, gulp.parallel(listPostBuildTasks(APPS_DIR)));
gulp.task('apps', appsBuild);

var debugBuild = gulp.series(distBuild, debug, gulp.parallel(listPostBuildTasks(DEBUG_DIR)), start_debug)
const debugAppsBuild = gulp.series(gulp.parallel(clean_debug, distRebuild), debug, gulp.parallel(listPostBuildTasks(DEBUG_DIR)));

const debugBuild = gulp.series(distBuild, debug, gulp.parallel(listPostBuildTasks(DEBUG_DIR)), start_debug);
gulp.task('debug', debugBuild);

var releaseBuild = gulp.series(gulp.parallel(clean_release, appsBuild), gulp.parallel(listReleaseTasks()));
const releaseBuild = gulp.series(gulp.parallel(clean_release, appsBuild), gulp.parallel(listReleaseTasks(APPS_DIR)));
gulp.task('release', releaseBuild);

var multiReleaseBuild = gulp.series(gulp.parallel(appsBuild), gulp.parallel(listReleaseTasks()));
gulp.task('mrelease', multiReleaseBuild);
const debugReleaseBuild = gulp.series(gulp.parallel(clean_release, debugAppsBuild), gulp.parallel(listReleaseTasks(DEBUG_DIR)));
gulp.task('debug-release', debugReleaseBuild);

gulp.task('default', debugBuild);

Expand All @@ -114,7 +111,7 @@ gulp.task('default', debugBuild);
// # gulp <task> [<platform>]+ Run only for platform(s) (with <platform> one of --linux64, --linux32, --armv7, --osx64, --win32, --win64, or --chromeos)
// #
function getInputPlatforms() {
var supportedPlatforms = ['linux64', 'linux32', 'armv7', 'osx64', 'win32', 'win64', 'chromeos'];
var supportedPlatforms = ['linux64', 'linux32', 'armv7', 'osx64', 'win32','win64', 'chromeos'];
var platforms = [];
var regEx = /--(\w+)/;
console.log(process.argv);
Expand Down Expand Up @@ -157,18 +154,20 @@ function getDefaultPlatform() {
switch (os.platform()) {
case 'darwin':
defaultPlatform = 'osx64';

break;
case 'linux':
defaultPlatform = 'linux64';

break;
case 'win32':
defaultPlatform = 'win32';

break;
case 'win64':
defaultPlatform = 'win64';
break;

default:
defaultPlatform = '';

break;
}
return defaultPlatform;
Expand All @@ -190,18 +189,25 @@ function getRunDebugAppCommand(arch) {
switch (arch) {
case 'osx64':
return 'open ' + path.join(DEBUG_DIR, pkg.name, arch, pkg.name + '.app');

break;

case 'linux64':
case 'linux32':
case 'armv7':
return path.join(DEBUG_DIR, pkg.name, arch, pkg.name);

break;

case 'win32':
case 'win64':
return path.join(DEBUG_DIR, pkg.name, arch, pkg.name + '.exe');

break;

default:
return '';

break;
}
}
Expand Down Expand Up @@ -236,8 +242,6 @@ function dist_src() {
var distSources = [
'./src/**/*',
'!./src/css/dropdown-lists/LICENSE',
'!./src/css/font-awesome/css/font-awesome.css',
'!./src/css/opensans_webfontkit/*.{txt,html}',
'!./src/support/**'
];
var packageJson = new stream.Readable;
Expand Down Expand Up @@ -285,7 +289,6 @@ function dist_resources() {
function apps(done) {
var platforms = getPlatforms();
removeItem(platforms, 'chromeos');
removeItem(platforms, 'android');

buildNWAppsWrapper(platforms, 'normal', APPS_DIR, done);
}
Expand Down Expand Up @@ -488,8 +491,7 @@ function writeChangesetId() {
var versionJson = new stream.Readable;
versionJson.push(JSON.stringify({
gitChangesetId: gitChangeSetId,
version: pkg.version,
max_msp: pkg.max_msp
version: pkg.version
}, undefined, 2));
versionJson.push(null);
return versionJson
Expand All @@ -513,45 +515,44 @@ function start_debug(done) {
}

// Create installer package for windows platforms
function release_win(arch, done) {
function release_win(arch, appDirectory, done) {

// Check if makensis exists
if (!commandExistsSync('makensis')) {
console.warn('makensis command not found, not generating package for: ' + arch);
return done();
console.warn('makensis command not found, not generating win package for ' + arch);
done();
}

// The makensis does not generate the folder correctly, manually
createDirIfNotExists(RELEASE_DIR);

// Parameters passed to the installer script
const options = {
verbose: 3,
verbose: 2,
define: {
'VERSION': pkg.version,
'PLATFORM': arch,
'DEST_FOLDER': RELEASE_DIR
'DEST_FOLDER': RELEASE_DIR,
'SOURCE_FOLDER': appDirectory,
}
}

var output = makensis.compileSync('./assets/windows/installer.nsi', options);

if (output.status === 0) {
console.log(`Standard output:\n${output.stdout}`);
} else {
console.error(`Exit Code ${output.status}: ${output.stderr}`);
if (output.status !== 0) {
console.error('Installer for platform ' + arch + ' finished with error ' + output.status + ': ' + output.stderr);
}

done();
}

// Create distribution package (zip) for windows and linux platforms
function release_zip(arch) {
var src = path.join(APPS_DIR, pkg.name, arch, '**');
var output = getReleaseFilename(arch, 'zip');
var base = path.join(APPS_DIR, pkg.name, arch);
function release_zip(arch, appDirectory) {
const src = path.join(appDirectory, pkg.name, arch, '**');
const output = getReleaseFilename(arch, 'zip');
const base = path.join(appDirectory, pkg.name, arch);

return compressFiles(src, base, output, 'Emuflight Configurator');
return compressFiles(src, base, output, 'EmuFlight Configurator');
}

// Create distribution package for chromeos platform
Expand All @@ -573,15 +574,15 @@ function compressFiles(srcPath, basePath, outputFile, zipFolder) {
.pipe(gulp.dest(RELEASE_DIR));
}

function release_deb(arch, done) {
function release_deb(arch, appDirectory, done) {

// Check if dpkg-deb exists
if (!commandExistsSync('dpkg-deb')) {
console.warn('dpkg-deb command not found, not generating deb package for ' + arch);
return done();
done();
}

return gulp.src([path.join(APPS_DIR, pkg.name, arch, '*')])
return gulp.src([path.join(appDirectory, pkg.name, arch, '*')])
.pipe(deb({
package: pkg.name,
version: pkg.version,
Expand All @@ -602,28 +603,30 @@ function release_deb(arch, done) {
}));
}

function release_rpm(arch, done) {
function release_rpm(arch, appDirectory, done) {

// Check if dpkg-deb exists
if (!commandExistsSync('rpmbuild')) {
console.warn('rpmbuild command not found, not generating rpm package for ' + arch);
return done();
done();
}

// The buildRpm does not generate the folder correctly, manually
createDirIfNotExists(RELEASE_DIR);

var regex = /-/g;

var options = {
name: pkg.name,
version: pkg.version,
version: pkg.version.replace(regex, '_'), // RPM does not like release candidate versions
buildArch: getLinuxPackageArch('rpm', arch),
vendor: pkg.author,
summary: pkg.description,
license: 'GNU General Public License v3.0',
requires: 'libgconf-2-4',
prefix: '/opt',
files:
[ { cwd: path.join(APPS_DIR, pkg.name, arch),
[ { cwd: path.join(appDirectory, pkg.name, arch),
src: '*',
dest: `${LINUX_INSTALL_DIR}/${pkg.name}` } ],
postInstallScript: [`xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${pkg.name}/${pkg.name}.desktop`],
Expand Down Expand Up @@ -665,21 +668,9 @@ function getLinuxPackageArch(type, arch) {

return packArch;
}

// TODO: add code-signing https://github.com/LinusU/node-appdmg
// Create distribution package for macOS platform
function release_osx64() {

if (process.env.TRAVIS_OS_NAME == 'osx') {
const { execSync } = require('child_process');
let stdout = execSync('./codesign_osxapp.sh');
} else {
console.log('running locally - skipping signing of app');
}

//var appdmg = require('gulp-appdmg');
const appdmg = require('./gulp-macdmg');

function release_osx64(appDirectory) {
var appdmg = require('gulp-appdmg');

// The appdmg does not generate the folder correctly, manually
createDirIfNotExists(RELEASE_DIR);
Expand All @@ -688,26 +679,21 @@ function release_osx64() {
return gulp.src(['.'])
.pipe(appdmg({
target: path.join(RELEASE_DIR, getReleaseFilename('macOS', 'dmg')),
basepath: path.join(APPS_DIR, pkg.name, 'osx64'),
basepath: path.join(appDirectory, pkg.name, 'osx64'),
specification: {
'title': 'Emuflight Configurator',
//'icon': 'assets/osx/app-icon.icns', // FIXME
'icon-size': 128,
'background': path.join(__dirname, 'assets/osx/dmg-background.png'),
'contents': [
{ 'x': 180, 'y': 590, 'type': 'file', 'path': pkg.name + '.app', 'name': 'Emuflight Configurator.app' },
{ 'x': 570, 'y': 590, 'type': 'link', 'path': '/Applications' }

title: 'EmuFlight Configurator',
contents: [
{ 'x': 448, 'y': 342, 'type': 'link', 'path': '/Applications' },
{ 'x': 192, 'y': 344, 'type': 'file', 'path': pkg.name + '.app', 'name': 'EmuFlight Configurator.app' }
],
background: path.join(__dirname, 'assets/osx/dmg-background.png'),
format: 'UDZO',
window: {
size: {
width: 755,
height: 755
width: 638,
height: 479
}
},
//'code-sign': { 'signing-identity': process.env.APP_IDENTITY }
}
},
})
);
Expand All @@ -725,7 +711,7 @@ function createDirIfNotExists(dir) {
}

// Create a list of the gulp tasks to execute for release
function listReleaseTasks(done) {
function listReleaseTasks(appDirectory) {

var platforms = getPlatforms();

Expand All @@ -737,53 +723,49 @@ function listReleaseTasks(done) {

if (platforms.indexOf('linux64') !== -1) {
releaseTasks.push(function release_linux64_zip() {
return release_zip('linux64');
return release_zip('linux64', appDirectory);
});
releaseTasks.push(function release_linux64_deb(done) {
return release_deb('linux64', done);
return release_deb('linux64', appDirectory, done);
});
releaseTasks.push(function release_linux64_rpm(done) {
return release_rpm('linux64', done);
return release_rpm('linux64', appDirectory, done);
});
}

if (platforms.indexOf('linux32') !== -1) {
releaseTasks.push(function release_linux32_zip() {
return release_zip('linux32');
return release_zip('linux32', appDirectory);
});
releaseTasks.push(function release_linux32_deb(done) {
return release_deb('linux32', done);
return release_deb('linux32', appDirectory, done);
});
releaseTasks.push(function release_linux32_rpm(done) {
return release_rpm('linux32', done);
return release_rpm('linux32', appDirectory, done);
});
}

if (platforms.indexOf('armv7') !== -1) {
releaseTasks.push(function release_armv7_zip() {
return release_zip('armv7');
return release_zip('armv7', appDirectory);
});
}

if (platforms.indexOf('osx64') !== -1) {
releaseTasks.push(release_osx64);
releaseTasks.push(function () {
return release_osx64(appDirectory);
});
}

if (platforms.indexOf('win32') !== -1) {
releaseTasks.push(function release_win32_zip() {
return release_zip('win32');
});
releaseTasks.push(function release_win32(done) {
return release_win('win32', done);
return release_win('win32', appDirectory, done);
});
}

if (platforms.indexOf('win64') !== -1) {
releaseTasks.push(function release_win64_zip() {
return release_zip('win64');
});
releaseTasks.push(function release_win64(done) {
return release_win('win64', done);
return release_win('win64', appDirectory, done);
});
}

Expand Down
Loading

0 comments on commit 37e4cbc

Please sign in to comment.