Browse Source

Merge pull request #226 from alberthdev/master

Initial Linux support for GPMDP
pull/241/merge
Samuel Attard 6 years ago
parent
commit
a26e87efdf
  1. 6
      .travis.yml
  2. 3
      circle.yml
  3. 59
      gulpfile.js
  4. 2
      package.json
  5. 35
      sig/publish-linux.js
  6. 0
      sig/publish-mac.js
  7. 2
      src/inject/darwin/index.js
  8. 1
      src/inject/linux/index.js
  9. 0
      src/inject/silent_Notification.js
  10. 2
      src/inject/win32/polyfill_Notification.js
  11. 0
      src/main/features/linux/index.js
  12. 4
      src/main/utils/PlaybackAPI.js
  13. 4
      src/main/utils/Settings.js

6
.travis.yml

@ -1,5 +1,6 @@
os:
- osx
- linux
cache:
directories:
@ -18,7 +19,10 @@ branches:
- website
script:
- npm run test && ./sig/import.sh && npm run make:darwin && node ./sig/publish.js
- npm run test
- npm run build
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PULL_REQUEST == "false" ]]; then ./sig/import.sh && npm run make:darwin && node ./sig/publish-mac.js; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ $TRAVIS_PULL_REQUEST == "false" ]]; then npm run make:linux && node ./sig/publish-linux.js; fi
notifications:
webhooks:

3
circle.yml

@ -0,0 +1,3 @@
machine:
node:
version: 4.2.2

59
gulpfile.js

@ -69,6 +69,10 @@ const cleanGlob = (glob) => {
gulp.task('clean', cleanGlob(['./build', './dist']));
gulp.task('clean-dist-win', cleanGlob(`./dist/${packageJSON.productName}-win32-ia32`));
gulp.task('clean-dist-darwin', cleanGlob(`./dist/${packageJSON.productName}-darwin-ia32`));
gulp.task('clean-dist-linux', cleanGlob([
`./dist/${packageJSON.productName}-linux-ia32`,
`./dist/${packageJSON.productName}-linux-x64`
]));
gulp.task('clean-external', cleanGlob('./build/external.js'));
gulp.task('clean-material', cleanGlob('./build/assets/material'));
gulp.task('clean-utility', cleanGlob('./build/assets/util'));
@ -191,8 +195,61 @@ gulp.task('make:darwin', ['package:darwin'], (done) => {
});
});
gulp.task('package:linux', ['clean-dist-linux', 'build'], (done) => {
packager(_.extend({}, defaultPackageConf, { platform: 'linux'}), done);
});
gulp.task('make:linux', ['package:linux'], (done) => {
const pathEscapedName = packageJSON.productName.replace(/ /gi, '\ ');
// Zip Linux x86
const child = spawn('zip', ['-r', '-y',
`${pathEscapedName}-linux-ia32.zip`,
`.`],
{
cwd: `./dist/${packageJSON.productName}-linux-ia32`,
});
console.log(`Zipping "${packageJSON.productName}-linux-ia32"`); // eslint-disable-line
// spit stdout to screen
child.stdout.on('data', (data) => { process.stdout.write(data.toString()); });
// Send stderr to the main console
child.stderr.on('data', (data) => {
process.stdout.write(data.toString());
});
child.on('close', (code) => {
console.log('Finished zipping with code ' + code); // eslint-disable-line
});
// Zip Linux x64
const child2 = spawn('zip', ['-r', '-y',
`${pathEscapedName}-linux-x64.zip`,
`.`],
{
cwd: `./dist/${packageJSON.productName}-linux-x64`,
});
console.log(`Zipping "${packageJSON.productName}-linux-x64"`); // eslint-disable-line
// spit stdout to screen
child2.stdout.on('data', (data) => { process.stdout.write(data.toString()); });
// Send stderr to the main console
child2.stderr.on('data', (data) => {
process.stdout.write(data.toString());
});
child2.on('close', (code) => {
console.log('Finished zipping with code ' + code); // eslint-disable-line
done();
});
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch', 'transpile', 'images']);
gulp.task('build', ['external', 'materialize-js', 'utility-js', 'transpile', 'images', 'less',
'fonts', 'html']);
gulp.task('package', ['package:win', 'package:darwin']);
gulp.task('package', ['package:win', 'package:darwin', 'package:linux']);

2
package.json

@ -10,8 +10,10 @@
"lint": "eslint ./src/ ./test/",
"make:win": "gulp make:win",
"make:darwin": "gulp make:darwin",
"make:linux": "gulp make:linux",
"package:darwin": "gulp package:darwin",
"package:win": "gulp package:win",
"package:linux": "gulp package:linux",
"release:win": "release-nucleus --nucleus-path=./ --release-type=win",
"release:darwin": "release-nucleus --nucleus-path=./ --release-type=darwin",
"test": "npm run lint",

35
sig/publish-linux.js

@ -0,0 +1,35 @@
'use strict';
const fs = require('fs');
const request = require('request');
const path = require('path');
console.log('Uploading ZIP artifact'); // eslint-disable-line
const req = request.post(`http://linux.googleplaymusicdesktopplayer.com/upload/${process.env.TRAVIS_COMMIT}/${process.env.TRAVIS_BUILD_NUMBER}`, (err, resp, body) => {
if (err) {
console.log('Upload failed with error!'); // eslint-disable-line
console.log(err); // eslint-disable-line
} else {
console.log('Upload sucessfull'); // eslint-disable-line
console.log('URL: ' + body); // eslint-disable-line
}
});
const form = req.form();
form.append('zip', fs.createReadStream(path.resolve(`${__dirname}/../dist/Google Play Music Desktop Player-linux-ia32/Google Play Music Desktop Player.zip`))); // eslint-disable-line
form.append('key', process.env.LINUX_ARTIFACT_KEY || '');
const req2 = request.post(`http://linux.googleplaymusicdesktopplayer.com/upload/${process.env.TRAVIS_COMMIT}/${process.env.TRAVIS_BUILD_NUMBER}`, (err, resp, body) => {
if (err) {
console.log('Upload failed with error!'); // eslint-disable-line
console.log(err); // eslint-disable-line
} else {
console.log('Upload sucessfull'); // eslint-disable-line
console.log('URL: ' + body); // eslint-disable-line
}
});
const form2 = req2.form();
form2.append('zip', fs.createReadStream(path.resolve(`${__dirname}/../dist/Google Play Music Desktop Player-linux-x64/Google Play Music Desktop Player.zip`))); // eslint-disable-line
form2.append('key', process.env.LINUX_ARTIFACT_KEY || '');

0
sig/publish.js → sig/publish-mac.js

2
src/inject/darwin/index.js

@ -1 +1 @@
import './silent_Notification';
import '../silent_Notification';

1
src/inject/linux/index.js

@ -0,0 +1 @@
import '../silent_Notification';

0
src/inject/darwin/silent_Notification.js → src/inject/silent_Notification.js

2
src/inject/win32/polyfill_Notification.js

@ -5,7 +5,7 @@ const osVersion = os.release().split('.');
if (osVersion[0] && parseInt(osVersion[0], 10) > 7) {
// If we are above windows 7 we can use the system notifications but with
// the silent flag forced on
require('../darwin/silent_Notification');
require('../silent_Notification');
} else {
const NOTIFICATIONS = [];

0
src/main/features/linux/index.js

4
src/main/utils/PlaybackAPI.js

@ -1,12 +1,14 @@
import fs from 'fs';
import mkdirp from 'mkdirp';
const os = require('os');
const environment = process.env;
class PlaybackAPI {
constructor() {
const DIR = (environment.APPDATA ||
(process.platform === 'darwin' ? environment.HOME + '/Library/Preferences' : '/var/local')) +
(process.platform === 'darwin' ? environment.HOME + '/Library/Preferences' : os.homedir())) +
'/GPMDP_STORE';
this.PATH = `${DIR}/playback.json`;

4
src/main/utils/Settings.js

@ -2,12 +2,14 @@ import fs from 'fs';
import mkdirp from 'mkdirp';
import initalSettings from './initialSettings';
const os = require('os');
const environment = process.env;
class Settings {
constructor(jsonPrefix, wipeOldData) {
const DIR = (environment.APPDATA ||
(process.platform === 'darwin' ? environment.HOME + '/Library/Preferences' : '/var/local')) +
(process.platform === 'darwin' ? environment.HOME + '/Library/Preferences' : os.homedir())) +
'/GPMDP_STORE';
this.PATH = `${DIR}/${(jsonPrefix || '')}.settings.json`;
this.data = initalSettings;

Loading…
Cancel
Save