Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release test #13

Merged
merged 18 commits into from
Jul 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config.json
exports
temps
dist
release
cache
build

Expand Down
6 changes: 6 additions & 0 deletions auto_updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"url": "http://mycompany.com/myapp/releases/myrelease",
"name": "My Release Name",
"notes": "Theses are some release notes innit",
"pub_date": "2013-09-18T12:29:53+01:00"
}
80 changes: 40 additions & 40 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var electronVersion = "1.0.1";


var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
Expand All @@ -10,11 +13,14 @@ var imageop = require('gulp-image-optimization');
var ngmin = require('gulp-ngmin');
var nodemon = require('gulp-nodemon');
var bower = require('gulp-bower');
var electron = require('gulp-electron');
var packager = require('electron-packager');
var packageJson = require('./src/package.json');
var plumber = require('gulp-plumber'); //prevent watch crash
var winInstaller = require('electron-windows-installer');
var gulpsync = require('gulp-sync')(gulp);
var winInstaller = require('electron-winstaller');

//retreive package.json data
var pjson = require('./package.json');

gulp.task('server', function () {
nodemon({
Expand All @@ -40,7 +46,7 @@ gulp.task('clean:build', function() {
});

gulp.task('install-dependencies', function() {
return bower({ cwd: './src/web' });
return bower({ cwd: './src/web',interactive:true });
});

gulp.task('scripts', function() {
Expand Down Expand Up @@ -88,42 +94,22 @@ gulp.task('copy-electron-components',function(){
.pipe(gulp.dest('./dist'))
});

gulp.task('create-windows-installer', function(done) {
winInstaller({
appDirectory: './build/win32',
outputDirectory: './release',
arch: 'ia32'
}).then(done).catch(done);
});

gulp.task('electron', function() {

gulp.src("")
.pipe(electron({
src: './dist',
packageJson: packageJson,
release: './build',
cache: './cache',
version: 'v1.0.1',
packaging: false,
platforms: ['win32-ia32', 'darwin-x64'],
platformResources: {
darwin: {
CFBundleDisplayName: packageJson.name,
CFBundleIdentifier: packageJson.name,
CFBundleName: packageJson.name,
CFBundleVersion: packageJson.version,
icon: './dist/web/img/tgf/icon_circle.ico'
},
win: {
"version-string": packageJson.version,
"file-version": packageJson.version,
"product-version": packageJson.version,
"icon": './dist/web/img/tgf/icon_circle.ico'
}
}
}))
.pipe(gulp.dest(""));
gulp.task('electron-build', function(callback) {
var options = {
dir: "./dist",
name: "tagifier",
platform: "win32",
arch: "all",
'app-version':pjson.version,
'build-version':pjson.version,
overwrite: true,
icon: "./dist/web/img/tgf/icon_circle.png",
out: "build"
};
packager(options, function done (err, appPath) {
if(err) { return console.log(err); }
callback();
});
});

gulp.task('watch', function () {
Expand All @@ -133,6 +119,19 @@ gulp.task('watch', function () {
gulp.watch('./src/*', ['copy-electron-components']);
});

gulp.task('create-windows-installer',function(){
del('./release/**/*');
return resultPromise = winInstaller.createWindowsInstaller({
appDirectory: './build/tagifier-win32-ia32',
outputDirectory: './release',
authors: 'Cyriaque DELAUNAY',
exe: 'Tagifier.exe'
});

resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`));

});

gulp.task('prepare-dev-env', gulpsync.sync([
// sync
'clean:dist',
Expand All @@ -153,7 +152,8 @@ gulp.task('prepare-dev-env', gulpsync.sync([
gulp.task('build', gulpsync.sync([
['clean:build'],
['prepare-dev-env'],
['electron']
['electron-build'],
['create-windows-installer']
]));

gulp.task('default', gulpsync.sync([
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tagifier",
"version": "1.0.0",
"description": "Download Youtube video as tagged mp3 files",
"version": "1.0.1",
"description": "Advanced mp3 metadata manager",
"main": "app.js",
"scripts": {
"postinstall": "node postinstall.js"
Expand All @@ -28,14 +28,19 @@
"homepage": "https://github.com/CYRIAQU3/tagifier#readme",
"dependencies": {
"del": "^2.2.0",
"electron-gh-releases": "^2.0.3",
"electron-packager": "^7.1.0",
"electron-prebuilt": "^1.1.0",
"electron-windows-installer": "^1.4.1",
"electron-winstaller": "^2.3.1",
"gulp": "^3.9.1",
"gulp-bower": "0.0.13",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-electron": "^0.1.3",
"gulp-filter": "^4.0.0",
"gulp-htmlmin": "^1.3.0",
"gulp-image-optimization": "^0.1.3",
"gulp-install": "^0.6.0",
"gulp-jsonminify": "^1.0.0",
"gulp-ngmin": "^0.3.0",
"gulp-nodemon": "^2.0.6",
Expand All @@ -45,7 +50,6 @@
"gulp-sync": "^0.1.4",
"gulp-uglify": "^1.5.3",
"gulp-usemin": "^0.3.23",
"package-script": "0.0.8",
"gulp-install": "^0.6.0"
"package-script": "0.0.8"
}
}
6 changes: 3 additions & 3 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require('package-script').spawn([
{
command: "npm",
args: ["install", "-g", "gulp"]
args: ["install", "-g", "bower"]
},
{
command: "npm",
args: ["install", "-g", "bower"]
args: ["install", "-g", "gulp"]
},
{
command: "npm",
args: ["install", "-g", " electron-prebuilt"]
args: ["install", "-g", "electron-prebuilt"]
},
{
command: "gulp",
Expand Down
131 changes: 105 additions & 26 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,121 @@
//

const electron = require('electron');
const app = electron.app;
const {app} = require('electron');
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
const GhReleases = require('electron-gh-releases');
const ipc = electron.ipcMain;
let splashScreen
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 1024,
height: 600,
minWidth: 1024,
icon: __dirname + '/web/img/tgf/icon_circle.png'
});
mainWindow.loadURL(`file://${__dirname}/web/index.html`);
//retreive package.json properties
var pjson = require('./package.json');

mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
});
}
app.on('ready', createWindow);
console.log("Tagifier V."+pjson.version);

app.on('ready', function(){
createSplashScreen();
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
});

app.on('ready', () => {
const {protocol} = require('electron');
protocol.registerFileProtocol('tagifier', (request, callback) => {
console.log(request);
const url = request.url.substr(7);
callback({path: path.normalize(__dirname + '/' + url)});
}, (error) => {
if (error)
console.error('Failed to register protocol');
});
});

app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
if (splashScreen === null) {
createWindow();
}
});


//
// Create the splashscreen
//
// Also check for update -> Pre-render the app -> show the app

function createSplashScreen () {
splashScreen = new BrowserWindow({
width: 300,
height: 300,
show:false,
frame:false,
icon: __dirname + '/web/img/tgf/icon_circle.png'
});

splashScreen.loadURL(`file://${__dirname}/web/splash.html`);

splashScreen.once('ready-to-show', () => {
splashScreen.show();
splashScreen.webContents.send("tgf_version",{version:pjson.version});
splashScreen.webContents.send("splash_message",{message:"Checking for update..."});

//check for updates
let options = {
repo: 'Cyriaqu3/tagifier',
currentVersion: pjson.version
}

const updater = new GhReleases(options)

// Check for updates
// `status` returns true if there is a new update available
updater.check((err, status) => {
if (!err && status) {
ipc.emit("splach_message",{message:"Downloading update..."});
// Download the update
updater.download();

//no update available, prepare the mainWindow
} else {
splashScreen.webContents.send("splash_message",{message:"Loading..."});
mainWindow = new BrowserWindow({
show:false,
width: 1024,
height: 600,
minWidth: 1024,
icon: __dirname + '/web/img/tgf/icon_circle.png'
});
mainWindow.loadURL(`file://${__dirname}/web/index.html`);
//display the main app and close the
mainWindow.once('ready-to-show', () => {
splashScreen.close();
mainWindow.show();
mainWindow.focus();
});
}
});

// When an update has been downloaded
updater.on('update-downloaded', (info) => {
// Restart the app and install the update
updater.install()
})

// Access electrons autoUpdater
updater.autoUpdater

});

splashScreen.on('closed', function () {
splashScreen = null
});
}

var fs = require('fs-sync');
var ofs = require('fs'); // old fs
var util = require('util');
Expand All @@ -56,7 +135,7 @@ var sanitize = require("sanitize-filename");
var ffmpeg = require('fluent-ffmpeg');

//File class
var File = require("./file.js");
var File = require(__dirname+"/file.js");
//

var fidOpt = {
Expand All @@ -66,13 +145,13 @@ var fidOpt = {

//set the ffmpeg binary location (path)
if(os.platform() === 'win32'){
var ffmpegPath = './bin/ffmpeg/ffmpeg.exe'
var ffmpegPath = __dirname+'/bin/ffmpeg/ffmpeg.exe'
}else{
var ffmpegPath = './bin/ffmpeg/ffmpeg'
var ffmpegPath = __dirname+'/bin/ffmpeg/ffmpeg'
}
ffmpeg.setFfmpegPath(ffmpegPath);
// create the "exports" folder
var p = "./exports";
var p = __dirname+"/exports";
if (!ofs.existsSync(p)){
ofs.mkdirSync(p);
}
Expand Down Expand Up @@ -141,7 +220,7 @@ ipc.on('processRequest', function (data) {
session.files.push(file);
}

session.tempPath = "./exports/"+session.id;
session.tempPath = __dirname+"/exports/"+session.id;

//create the temp session path
if (!ofs.existsSync(session.tempPath)){
Expand Down Expand Up @@ -277,6 +356,6 @@ var rmDir = function(dirPath, removeSelf) {



rmDir('./web/img/temps',false);
rmDir('./exports',false);
rmDir(__dirname+'/web/img/temps',false);
rmDir(__dirname+'/exports',false);
console.log("Temp files cleaned");
Loading