diff --git a/app/lib/system/index.js b/app/lib/system/index.js index af528c0..50d09c4 100644 --- a/app/lib/system/index.js +++ b/app/lib/system/index.js @@ -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; \ No newline at end of file +module.exports = system; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/app/lib/system/index.js.map b/app/lib/system/index.js.map new file mode 100644 index 0000000..51168a1 --- /dev/null +++ b/app/lib/system/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,GAA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ib/system/index.js @@ -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; \ No newline at end of file +module.exports = system; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/cli/lib/system/index.js.map b/cli/lib/system/index.js.map new file mode 100644 index 0000000..51168a1 --- /dev/null +++ b/cli/lib/system/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"} \ No newline at end of file diff --git a/lib/system/index.js b/lib/system/index.js new file mode 100644 index 0000000..50d09c4 --- /dev/null +++ b/lib/system/index.js @@ -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 \ No newline at end of file diff --git a/lib/system/index.js.map b/lib/system/index.js.map new file mode 100644 index 0000000..51168a1 --- /dev/null +++ b/lib/system/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,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AG,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"} \ No newline at end of file diff --git a/src/globals.d.ts b/src/globals.d.ts index bd8c2ca..ce6dfb3 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -5,6 +5,7 @@ declare module 'electron'; declare module 'fs-extra'; declare module 'exec'; declare module 'spawn'; +declare module 'systeminformation'; interface Device { arduino : string; diff --git a/src/system/Readme.md b/src/system/Readme.md new file mode 100644 index 0000000..9a1dbf0 --- /dev/null +++ b/src/system/Readme.md @@ -0,0 +1,37 @@ +## Functions + +
Evaluates system dependencies for digital +projector features by executing processes with +--help flag. If they do not exist, log to console
+object
Profile the current system and return an object with +data about the displays and dependencies for the digital +projector feature.
+string
| Operating system type |
+
+
+
+## system() ⇒ object
+Profile the current system and return an object with
+data about the displays and dependencies for the digital
+projector feature.
+
+**Kind**: global function
+**Returns**: object
- Object containing system information
diff --git a/src/system/index.ts b/src/system/index.ts
new file mode 100644
index 0000000..1906850
--- /dev/null
+++ b/src/system/index.ts
@@ -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;
\ No newline at end of file
diff --git a/src/system/package.json b/src/system/package.json
new file mode 100644
index 0000000..148877b
--- /dev/null
+++ b/src/system/package.json
@@ -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"
+}