Skip to content

Commit 00dfaf8

Browse files
authored
Merge pull request #13 from Cyriaqu3/dev
Release test
2 parents 1301009 + 43048f8 commit 00dfaf8

15 files changed

+275
-122
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config.json
1313
exports
1414
temps
1515
dist
16+
release
1617
cache
1718
build
1819

auto_updater.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"url": "http://mycompany.com/myapp/releases/myrelease",
3+
"name": "My Release Name",
4+
"notes": "Theses are some release notes innit",
5+
"pub_date": "2013-09-18T12:29:53+01:00"
6+
}

gulpfile.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var electronVersion = "1.0.1";
2+
3+
14
var gulp = require('gulp');
25
var concat = require('gulp-concat');
36
var uglify = require('gulp-uglify');
@@ -10,11 +13,14 @@ var imageop = require('gulp-image-optimization');
1013
var ngmin = require('gulp-ngmin');
1114
var nodemon = require('gulp-nodemon');
1215
var bower = require('gulp-bower');
13-
var electron = require('gulp-electron');
16+
var packager = require('electron-packager');
1417
var packageJson = require('./src/package.json');
1518
var plumber = require('gulp-plumber'); //prevent watch crash
16-
var winInstaller = require('electron-windows-installer');
1719
var gulpsync = require('gulp-sync')(gulp);
20+
var winInstaller = require('electron-winstaller');
21+
22+
//retreive package.json data
23+
var pjson = require('./package.json');
1824

1925
gulp.task('server', function () {
2026
nodemon({
@@ -40,7 +46,7 @@ gulp.task('clean:build', function() {
4046
});
4147

4248
gulp.task('install-dependencies', function() {
43-
return bower({ cwd: './src/web' });
49+
return bower({ cwd: './src/web',interactive:true });
4450
});
4551

4652
gulp.task('scripts', function() {
@@ -88,42 +94,22 @@ gulp.task('copy-electron-components',function(){
8894
.pipe(gulp.dest('./dist'))
8995
});
9096

91-
gulp.task('create-windows-installer', function(done) {
92-
winInstaller({
93-
appDirectory: './build/win32',
94-
outputDirectory: './release',
95-
arch: 'ia32'
96-
}).then(done).catch(done);
97-
});
98-
99-
gulp.task('electron', function() {
100-
101-
gulp.src("")
102-
.pipe(electron({
103-
src: './dist',
104-
packageJson: packageJson,
105-
release: './build',
106-
cache: './cache',
107-
version: 'v1.0.1',
108-
packaging: false,
109-
platforms: ['win32-ia32', 'darwin-x64'],
110-
platformResources: {
111-
darwin: {
112-
CFBundleDisplayName: packageJson.name,
113-
CFBundleIdentifier: packageJson.name,
114-
CFBundleName: packageJson.name,
115-
CFBundleVersion: packageJson.version,
116-
icon: './dist/web/img/tgf/icon_circle.ico'
117-
},
118-
win: {
119-
"version-string": packageJson.version,
120-
"file-version": packageJson.version,
121-
"product-version": packageJson.version,
122-
"icon": './dist/web/img/tgf/icon_circle.ico'
123-
}
124-
}
125-
}))
126-
.pipe(gulp.dest(""));
97+
gulp.task('electron-build', function(callback) {
98+
var options = {
99+
dir: "./dist",
100+
name: "tagifier",
101+
platform: "win32",
102+
arch: "all",
103+
'app-version':pjson.version,
104+
'build-version':pjson.version,
105+
overwrite: true,
106+
icon: "./dist/web/img/tgf/icon_circle.png",
107+
out: "build"
108+
};
109+
packager(options, function done (err, appPath) {
110+
if(err) { return console.log(err); }
111+
callback();
112+
});
127113
});
128114

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

122+
gulp.task('create-windows-installer',function(){
123+
del('./release/**/*');
124+
return resultPromise = winInstaller.createWindowsInstaller({
125+
appDirectory: './build/tagifier-win32-ia32',
126+
outputDirectory: './release',
127+
authors: 'Cyriaque DELAUNAY',
128+
exe: 'Tagifier.exe'
129+
});
130+
131+
resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`));
132+
133+
});
134+
136135
gulp.task('prepare-dev-env', gulpsync.sync([
137136
// sync
138137
'clean:dist',
@@ -153,7 +152,8 @@ gulp.task('prepare-dev-env', gulpsync.sync([
153152
gulp.task('build', gulpsync.sync([
154153
['clean:build'],
155154
['prepare-dev-env'],
156-
['electron']
155+
['electron-build'],
156+
['create-windows-installer']
157157
]));
158158

159159
gulp.task('default', gulpsync.sync([

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tagifier",
3-
"version": "1.0.0",
4-
"description": "Download Youtube video as tagged mp3 files",
3+
"version": "1.0.1",
4+
"description": "Advanced mp3 metadata manager",
55
"main": "app.js",
66
"scripts": {
77
"postinstall": "node postinstall.js"
@@ -28,14 +28,19 @@
2828
"homepage": "https://github.com/CYRIAQU3/tagifier#readme",
2929
"dependencies": {
3030
"del": "^2.2.0",
31+
"electron-gh-releases": "^2.0.3",
32+
"electron-packager": "^7.1.0",
3133
"electron-prebuilt": "^1.1.0",
32-
"electron-windows-installer": "^1.4.1",
34+
"electron-winstaller": "^2.3.1",
3335
"gulp": "^3.9.1",
3436
"gulp-bower": "0.0.13",
3537
"gulp-clean": "^0.3.2",
3638
"gulp-concat": "^2.6.0",
39+
"gulp-electron": "^0.1.3",
40+
"gulp-filter": "^4.0.0",
3741
"gulp-htmlmin": "^1.3.0",
3842
"gulp-image-optimization": "^0.1.3",
43+
"gulp-install": "^0.6.0",
3944
"gulp-jsonminify": "^1.0.0",
4045
"gulp-ngmin": "^0.3.0",
4146
"gulp-nodemon": "^2.0.6",
@@ -45,7 +50,6 @@
4550
"gulp-sync": "^0.1.4",
4651
"gulp-uglify": "^1.5.3",
4752
"gulp-usemin": "^0.3.23",
48-
"package-script": "0.0.8",
49-
"gulp-install": "^0.6.0"
53+
"package-script": "0.0.8"
5054
}
5155
}

postinstall.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
require('package-script').spawn([
22
{
33
command: "npm",
4-
args: ["install", "-g", "gulp"]
4+
args: ["install", "-g", "bower"]
55
},
66
{
77
command: "npm",
8-
args: ["install", "-g", "bower"]
8+
args: ["install", "-g", "gulp"]
99
},
1010
{
1111
command: "npm",
12-
args: ["install", "-g", " electron-prebuilt"]
12+
args: ["install", "-g", "electron-prebuilt"]
1313
},
1414
{
1515
command: "gulp",

src/app.js

+105-26
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,121 @@
33
//
44

55
const electron = require('electron');
6-
const app = electron.app;
6+
const {app} = require('electron');
77
const Menu = electron.Menu;
88
const BrowserWindow = electron.BrowserWindow;
9+
const GhReleases = require('electron-gh-releases');
910
const ipc = electron.ipcMain;
11+
let splashScreen
1012
let mainWindow
11-
function createWindow () {
12-
mainWindow = new BrowserWindow({
13-
width: 1024,
14-
height: 600,
15-
minWidth: 1024,
16-
icon: __dirname + '/web/img/tgf/icon_circle.png'
17-
});
18-
mainWindow.loadURL(`file://${__dirname}/web/index.html`);
13+
//retreive package.json properties
14+
var pjson = require('./package.json');
1915

20-
mainWindow.on('closed', function () {
21-
// Dereference the window object, usually you would store windows
22-
// in an array if your app supports multi windows, this is the time
23-
// when you should delete the corresponding element.
24-
mainWindow = null
25-
});
26-
}
27-
app.on('ready', createWindow);
16+
console.log("Tagifier V."+pjson.version);
17+
18+
app.on('ready', function(){
19+
createSplashScreen();
20+
});
2821
app.on('window-all-closed', function () {
2922
if (process.platform !== 'darwin') {
3023
app.quit()
3124
}
32-
})
25+
});
26+
27+
app.on('ready', () => {
28+
const {protocol} = require('electron');
29+
protocol.registerFileProtocol('tagifier', (request, callback) => {
30+
console.log(request);
31+
const url = request.url.substr(7);
32+
callback({path: path.normalize(__dirname + '/' + url)});
33+
}, (error) => {
34+
if (error)
35+
console.error('Failed to register protocol');
36+
});
37+
});
3338

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

47+
48+
//
49+
// Create the splashscreen
50+
//
51+
// Also check for update -> Pre-render the app -> show the app
52+
53+
function createSplashScreen () {
54+
splashScreen = new BrowserWindow({
55+
width: 300,
56+
height: 300,
57+
show:false,
58+
frame:false,
59+
icon: __dirname + '/web/img/tgf/icon_circle.png'
60+
});
61+
62+
splashScreen.loadURL(`file://${__dirname}/web/splash.html`);
63+
64+
splashScreen.once('ready-to-show', () => {
65+
splashScreen.show();
66+
splashScreen.webContents.send("tgf_version",{version:pjson.version});
67+
splashScreen.webContents.send("splash_message",{message:"Checking for update..."});
68+
69+
//check for updates
70+
let options = {
71+
repo: 'Cyriaqu3/tagifier',
72+
currentVersion: pjson.version
73+
}
74+
75+
const updater = new GhReleases(options)
76+
77+
// Check for updates
78+
// `status` returns true if there is a new update available
79+
updater.check((err, status) => {
80+
if (!err && status) {
81+
ipc.emit("splach_message",{message:"Downloading update..."});
82+
// Download the update
83+
updater.download();
84+
85+
//no update available, prepare the mainWindow
86+
} else {
87+
splashScreen.webContents.send("splash_message",{message:"Loading..."});
88+
mainWindow = new BrowserWindow({
89+
show:false,
90+
width: 1024,
91+
height: 600,
92+
minWidth: 1024,
93+
icon: __dirname + '/web/img/tgf/icon_circle.png'
94+
});
95+
mainWindow.loadURL(`file://${__dirname}/web/index.html`);
96+
//display the main app and close the
97+
mainWindow.once('ready-to-show', () => {
98+
splashScreen.close();
99+
mainWindow.show();
100+
mainWindow.focus();
101+
});
102+
}
103+
});
104+
105+
// When an update has been downloaded
106+
updater.on('update-downloaded', (info) => {
107+
// Restart the app and install the update
108+
updater.install()
109+
})
110+
111+
// Access electrons autoUpdater
112+
updater.autoUpdater
113+
114+
});
115+
116+
splashScreen.on('closed', function () {
117+
splashScreen = null
118+
});
119+
}
120+
42121
var fs = require('fs-sync');
43122
var ofs = require('fs'); // old fs
44123
var util = require('util');
@@ -56,7 +135,7 @@ var sanitize = require("sanitize-filename");
56135
var ffmpeg = require('fluent-ffmpeg');
57136

58137
//File class
59-
var File = require("./file.js");
138+
var File = require(__dirname+"/file.js");
60139
//
61140

62141
var fidOpt = {
@@ -66,13 +145,13 @@ var fidOpt = {
66145

67146
//set the ffmpeg binary location (path)
68147
if(os.platform() === 'win32'){
69-
var ffmpegPath = './bin/ffmpeg/ffmpeg.exe'
148+
var ffmpegPath = __dirname+'/bin/ffmpeg/ffmpeg.exe'
70149
}else{
71-
var ffmpegPath = './bin/ffmpeg/ffmpeg'
150+
var ffmpegPath = __dirname+'/bin/ffmpeg/ffmpeg'
72151
}
73152
ffmpeg.setFfmpegPath(ffmpegPath);
74153
// create the "exports" folder
75-
var p = "./exports";
154+
var p = __dirname+"/exports";
76155
if (!ofs.existsSync(p)){
77156
ofs.mkdirSync(p);
78157
}
@@ -141,7 +220,7 @@ ipc.on('processRequest', function (data) {
141220
session.files.push(file);
142221
}
143222

144-
session.tempPath = "./exports/"+session.id;
223+
session.tempPath = __dirname+"/exports/"+session.id;
145224

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

278357

279358

280-
rmDir('./web/img/temps',false);
281-
rmDir('./exports',false);
359+
rmDir(__dirname+'/web/img/temps',false);
360+
rmDir(__dirname+'/exports',false);
282361
console.log("Temp files cleaned");

0 commit comments

Comments
 (0)