1.1.4 • Published 7 years ago
proton-lib v1.1.4
Proton
Proton is a library designed to distribute any native desktop application using Electron or as a stand alone node app.
Usage (Project in development)
It's an initial version which supports Java platform, proton requires a JSON configuration file (proton.json) in order to configure the basic app handling.
The following is an example of proton.json file:
{
"name": "App name",
"icon": {
"title": "App title",
"file": "app.ico"
},
"platform": {
"name": "java",
"version": "1.8.0_51",
"env": "prod",
"environments": {
"prod": {
"serviceUrl": "http://localhost:8080/latestVersionNumber",
"download": "http://localhost:8080/download/app.jar",
"artifact": "app.jar",
"jvmargs": "-Xms256m -Xmx512m"
}
},
"artifacts": {
"maxStorageSize": "1GB"
}
}
}
Proton usage example with Electron:
var proton = require('proton-lib');
var http = require('http');
var electron = require('electron');
//electron code...
proton.checkUpdates((options,downloadApp) => {
//your app update logic goes here - example with basic http get
http.get(options.env.serviceUrl, (res) => {
res.setEncoding('utf-8');
var data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
var obj = JSON.parse(data);
downloadApp(obj.version);
});
res.on('error', (e) => {
downloadApp(); //force app download
});
});
};
//optional stuff goes here...
proton.start(electron);
Proton stand alone usage example:
var proton = require('proton-lib');
var http = require('http');
proton.checkUpdates((options,downloadApp) => {
//your app update logic goes here - example with basic http get
http.get(options.env.serviceUrl, (res) => {
res.setEncoding('utf-8');
var data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
var obj = JSON.parse(data);
downloadApp(obj.version);
});
res.on('error', (e) => {
downloadApp(); //force app download
});
});
};
proton.start();
Features
- Auto update target application (see
proton.checkUpdates(callback)
) - Application downloading and storage into cache files
- Designed to support any platform (currently Java only)
- App platform configuration are segregated by environments (e.g.: dev, qa, stage, production)
- Automatic cache files clean up (default max size is 1GB and oldest files are priority for clean up)
- Resources directory handling
Implemented Platforms
- Java (
'java'
)
Basic proton flow
- Check for application updates (see
proton.checkUpdates(callback)
) - Download application version if not found in cache
- check downloadAppCb in
proton.checkUpdates((options,downloadAppCb) => { /*logic here*/ })
- check downloadAppCb in
- Execute application
Optional configurations
Proton optional process config before proton.start()
proton.process.stdout.on((data) => {
console.log(data.toString()); //standard target process output
});
proton.process.stderr.on((data) => {
console.error(data.toString()); //standard target process error output
});
proton.common.debug = (msg) => {
console.log("DEBUG: " + msg); //enable proton debug
};
proton.common.resources.directory.onRequest((msg) => {
return './../app.asar.unpacked/'; //resource directory override
});
1.1.x Release roadmap
- Test and Fix Java Platform issues
1.2.x Release roadmap
- Define UI integration with Electron
Releases
- 1.1.3
- Improved error handling / fixed modules
- 1.1.4
- Added resources directory (to work with packaged applications, e.g.: asar)
- Added optional configuration maxStorageSize for artifacts cache storage (default 1GB)
- Fixed proton init concurrency