Create a system lib that can be used in the UI and cli.
This commit is contained in:
parent
b02b92c1c7
commit
e35c41791b
|
@ -1,85 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const electron = require('electron');
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
const si = require("systeminformation");
|
||||
//private
|
||||
const exec = require('exec');
|
||||
/**
|
||||
* Evaluates system dependencies for digital
|
||||
* projector features by executing processes with
|
||||
* --help flag. If they do not exist, log to console
|
||||
*
|
||||
*
|
||||
* @param {string} platform Operating system type
|
||||
**/
|
||||
|
||||
async function dependencies (platform) {
|
||||
let obj = {};
|
||||
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
} catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
} catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
async function dependencies(platform) {
|
||||
let obj = {};
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function getDisplays () {
|
||||
let displays = electron.screen.getAllDisplays();
|
||||
return displays.map(obj => {
|
||||
return {
|
||||
width : obj.workArea.width,
|
||||
height : obj.workArea.height,
|
||||
x : obj.bounds.x,
|
||||
y : obj.bounds.y
|
||||
}
|
||||
});
|
||||
|
||||
function displayMap(obj) {
|
||||
const sm = {
|
||||
width: obj.resolutionx,
|
||||
height: obj.resolutiony
|
||||
};
|
||||
return sm;
|
||||
}
|
||||
async function displays() {
|
||||
const obj = await si.graphics();
|
||||
const arr = obj.displays;
|
||||
return arr.map(displayMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile the current system and return an object with
|
||||
* data about the displays and dependencies for the digital
|
||||
* projector feature.
|
||||
*
|
||||
* @returns {object} Object containing system information
|
||||
*/
|
||||
async function system () {
|
||||
const obj = {};
|
||||
let platform;
|
||||
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
} catch (err) {
|
||||
obj.tmp = '/tmp'
|
||||
}
|
||||
|
||||
platform = os.type();
|
||||
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
} else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
} else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
|
||||
obj.displays = getDisplays()
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
|
||||
return obj;
|
||||
*/
|
||||
async function system() {
|
||||
const obj = {};
|
||||
let platform;
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
}
|
||||
catch (err) {
|
||||
obj.tmp = '/tmp';
|
||||
}
|
||||
platform = os.type();
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
}
|
||||
else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
}
|
||||
else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
obj.displays = await displays();
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports = system;
|
||||
module.exports = system;
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/system/index.ts"],"names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AG,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACb,GAAG,CAAC,GAAG,GAAG,MAAM,CAAA;KAChB;IAED,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAErB,IAAI,QAAQ,KAAK,QAAQ,EAAE;QAC1B,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM,IAAI,QAAQ,KAAK,YAAY,EAAE;QACrC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM;QACN,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;IAED,GAAG,CAAC,QAAQ,GAAG,MAAM,QAAQ,EAAE,CAAA;IAC/B,GAAG,CAAC,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
|
|
@ -1,89 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const si = require('systeminformation');
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
const si = require("systeminformation");
|
||||
//private
|
||||
const exec = require('exec');
|
||||
/**
|
||||
* Evaluates system dependencies for digital
|
||||
* projector features by executing processes with
|
||||
* --help flag. If they do not exist, log to console
|
||||
*
|
||||
*
|
||||
* @param {string} platform Operating system type
|
||||
**/
|
||||
|
||||
async function dependencies (platform) {
|
||||
let obj = {};
|
||||
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
} catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
} catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
async function dependencies(platform) {
|
||||
let obj = {};
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @returns {array} Array of objects containing displays and relative positions
|
||||
*/
|
||||
function getDisplays () {
|
||||
let displays = electron.screen.getAllDisplays();
|
||||
return displays.map(obj => {
|
||||
return {
|
||||
width : obj.workArea.width,
|
||||
height : obj.workArea.height,
|
||||
x : obj.bounds.x,
|
||||
y : obj.bounds.y
|
||||
}
|
||||
});
|
||||
|
||||
function displayMap(obj) {
|
||||
const sm = {
|
||||
width: obj.resolutionx,
|
||||
height: obj.resolutiony
|
||||
};
|
||||
return sm;
|
||||
}
|
||||
async function displays() {
|
||||
const obj = await si.graphics();
|
||||
const arr = obj.displays;
|
||||
return arr.map(displayMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile the current system and return an object with
|
||||
* data about the displays and dependencies for the digital
|
||||
* projector feature.
|
||||
*
|
||||
* @returns {object} Object containing system information
|
||||
*/
|
||||
async function system () {
|
||||
const obj = {};
|
||||
let platform;
|
||||
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
} catch (err) {
|
||||
obj.tmp = '/tmp'
|
||||
}
|
||||
|
||||
platform = os.type();
|
||||
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
} else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
} else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
|
||||
obj.displays = getDisplays()
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
|
||||
return obj;
|
||||
*/
|
||||
async function system() {
|
||||
const obj = {};
|
||||
let platform;
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
}
|
||||
catch (err) {
|
||||
obj.tmp = '/tmp';
|
||||
}
|
||||
platform = os.type();
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
}
|
||||
else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
}
|
||||
else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
obj.displays = await displays();
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports = system;
|
||||
module.exports = system;
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,yBAA0B;AAC1B,wCAAyC;AACzC,SAAS;AACT,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B;;;;;;IAMI;AAEJ,KAAK,UAAU,YAAY,CAAE,QAAiB;IAC7C,IAAI,GAAG,GAAS,EAAE,CAAC;IAEnB,IAAI;QACH,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACb,4CAA4C;QAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;KACrD;IACD,UAAU;IACV,IAAI,QAAQ,KAAK,KAAK,EAAE;QACvB,IAAI;YACH,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC;SAChB;QAAC,OAAO,GAA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,GAAG,MAAM,CAAC"}
|
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
const si = require("systeminformation");
|
||||
//private
|
||||
const exec = require('exec');
|
||||
/**
|
||||
* Evaluates system dependencies for digital
|
||||
* projector features by executing processes with
|
||||
* --help flag. If they do not exist, log to console
|
||||
*
|
||||
* @param {string} platform Operating system type
|
||||
**/
|
||||
async function dependencies(platform) {
|
||||
let obj = {};
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
}
|
||||
catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
function displayMap(obj) {
|
||||
const sm = {
|
||||
width: obj.resolutionx,
|
||||
height: obj.resolutiony
|
||||
};
|
||||
return sm;
|
||||
}
|
||||
async function displays() {
|
||||
const obj = await si.graphics();
|
||||
const arr = obj.displays;
|
||||
return arr.map(displayMap);
|
||||
}
|
||||
/**
|
||||
* Profile the current system and return an object with
|
||||
* data about the displays and dependencies for the digital
|
||||
* projector feature.
|
||||
*
|
||||
* @returns {object} Object containing system information
|
||||
*/
|
||||
async function system() {
|
||||
const obj = {};
|
||||
let platform;
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
}
|
||||
catch (err) {
|
||||
obj.tmp = '/tmp';
|
||||
}
|
||||
platform = os.type();
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
}
|
||||
else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
}
|
||||
else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
obj.displays = await displays();
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
return obj;
|
||||
}
|
||||
module.exports = system;
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,yBAA0B;AAC1B,wCAAyC;AACzC,SAAS;AACT,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B;;;;;;IAMI;AAEJ,KAAK,UAAU,YAAY,CAAE,QAAiB;IAC7C,IAAI,GAAG,GAAS,EAAE,CAAC;IAEnB,IAAI;QACH,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACb,4CAA4C;QAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;KACrD;IACD,UAAU;IACV,IAAI,QAAQ,KAAK,KAAK,EAAE;QACvB,IAAI;YACH,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC;SAChB;QAAC,OAAO,GAAG,EAAE;YACb,yCAAyC;YACzC,OAAO,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;SAClD;KACD;IAED,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,UAAU,CAAE,GAAS;IAC7B,MAAM,EAAE,GAAG;QACV,KAAK,EAAG,GAAG,CAAC,WAAW;QACvB,MAAM,EAAG,GAAG,CAAC,WAAW;KACxB,CAAC;IACF,OAAO,EAAE,CAAC;AACX,CAAC;AAED,KAAK,UAAU,QAAQ;IACtB,MAAM,GAAG,GAAS,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAA;IACrC,MAAM,GAAG,GAAW,GAAG,CAAC,QAAQ,CAAC;IACjC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,MAAM;IACpB,MAAM,GAAG,GAAS,EAAE,CAAC;IACrB,IAAI,QAAiB,CAAC;IAEtB,IAAI;QACH,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACb,GAAG,CAAC,GAAG,GAAG,MAAM,CAAA;KAChB;IAED,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAErB,IAAI,QAAQ,KAAK,QAAQ,EAAE;QAC1B,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM,IAAI,QAAQ,KAAK,YAAY,EAAE;QACrC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM;QACN,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;IAED,GAAG,CAAC,QAAQ,GAAG,MAAM,QAAQ,EAAE,CAAA;IAC/B,GAAG,CAAC,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
|
|
@ -5,6 +5,7 @@ declare module 'electron';
|
|||
declare module 'fs-extra';
|
||||
declare module 'exec';
|
||||
declare module 'spawn';
|
||||
declare module 'systeminformation';
|
||||
|
||||
interface Device {
|
||||
arduino : string;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
## Functions
|
||||
|
||||
<dl>
|
||||
<dt><a href="#dependencies">dependencies(platform)</a></dt>
|
||||
<dd><p>Evaluates system dependencies for digital
|
||||
projector features by executing processes with
|
||||
--help flag. If they do not exist, log to console</p>
|
||||
</dd>
|
||||
<dt><a href="#system">system()</a> ⇒ <code>object</code></dt>
|
||||
<dd><p>Profile the current system and return an object with
|
||||
data about the displays and dependencies for the digital
|
||||
projector feature.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<a name="dependencies"></a>
|
||||
|
||||
## dependencies(platform)
|
||||
Evaluates system dependencies for digital
|
||||
projector features by executing processes with
|
||||
--help flag. If they do not exist, log to console
|
||||
|
||||
**Kind**: global function
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| platform | <code>string</code> | Operating system type |
|
||||
|
||||
<a name="system"></a>
|
||||
|
||||
## system() ⇒ <code>object</code>
|
||||
Profile the current system and return an object with
|
||||
data about the displays and dependencies for the digital
|
||||
projector feature.
|
||||
|
||||
**Kind**: global function
|
||||
**Returns**: <code>object</code> - Object containing system information
|
|
@ -0,0 +1,86 @@
|
|||
'use strict';
|
||||
|
||||
import os = require('os');
|
||||
import si = require('systeminformation');
|
||||
//private
|
||||
const exec = require('exec');
|
||||
/**
|
||||
* Evaluates system dependencies for digital
|
||||
* projector features by executing processes with
|
||||
* --help flag. If they do not exist, log to console
|
||||
*
|
||||
* @param {string} platform Operating system type
|
||||
**/
|
||||
|
||||
async function dependencies (platform : string ) {
|
||||
let obj : any = {};
|
||||
|
||||
try {
|
||||
await exec('ffmpeg -h');
|
||||
obj.ffmpeg = 'ffmpeg';
|
||||
} catch (err) {
|
||||
//return exit('ffmpeg is not installed', 3);
|
||||
return console.error('ffmpeg is not installed', err);
|
||||
}
|
||||
//if linux
|
||||
if (platform === 'nix') {
|
||||
try {
|
||||
await exec('eog -h');
|
||||
obj.eog = 'eog';
|
||||
} catch (err) {
|
||||
//return exit('eog is not installed', 4);
|
||||
return console.error('eog is not installed', err);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function displayMap (obj : any) {
|
||||
const sm = {
|
||||
width : obj.resolutionx,
|
||||
height : obj.resolutiony
|
||||
};
|
||||
return sm;
|
||||
}
|
||||
|
||||
async function displays () {
|
||||
const obj : any = await si.graphics()
|
||||
const arr : any[] = obj.displays;
|
||||
return arr.map(displayMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile the current system and return an object with
|
||||
* data about the displays and dependencies for the digital
|
||||
* projector feature.
|
||||
*
|
||||
* @returns {object} Object containing system information
|
||||
*/
|
||||
async function system () {
|
||||
const obj : any = {};
|
||||
let platform : string;
|
||||
|
||||
try {
|
||||
obj.tmp = os.tmpdir();
|
||||
} catch (err) {
|
||||
obj.tmp = '/tmp'
|
||||
}
|
||||
|
||||
platform = os.type();
|
||||
|
||||
if (platform === 'Darwin') {
|
||||
obj.platform = 'osx';
|
||||
} else if (platform === 'Windows_NT') {
|
||||
obj.platform = 'win';
|
||||
} else {
|
||||
obj.platform = 'nix';
|
||||
}
|
||||
|
||||
obj.displays = await displays()
|
||||
obj.deps = await dependencies(obj.platform);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports = system;
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "system",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
Loading…
Reference in New Issue