Install private modules in the cli project
This commit is contained in:
parent
f09ada2cd2
commit
1413e323f0
|
@ -0,0 +1,152 @@
|
||||||
|
{
|
||||||
|
"version": "1.3.2",
|
||||||
|
"ext_port": 1111,
|
||||||
|
"profiles": {
|
||||||
|
"mcopy": {
|
||||||
|
"label": "Default mcopy profile",
|
||||||
|
"cam": {
|
||||||
|
"time": 850,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 0
|
||||||
|
},
|
||||||
|
"proj": {
|
||||||
|
"time": 1400,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 0
|
||||||
|
},
|
||||||
|
"black": {
|
||||||
|
"before": 0,
|
||||||
|
"after": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jk103": {
|
||||||
|
"label": "JK103",
|
||||||
|
"cam": {
|
||||||
|
"time": 600,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 240
|
||||||
|
},
|
||||||
|
"proj": {
|
||||||
|
"time": 950,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 240
|
||||||
|
},
|
||||||
|
"black": {
|
||||||
|
"before": 0,
|
||||||
|
"after": 0
|
||||||
|
},
|
||||||
|
"light": false
|
||||||
|
},
|
||||||
|
"jk_original": {
|
||||||
|
"label": "JK45 profile",
|
||||||
|
"cam": {
|
||||||
|
"time": 750,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"proj": {
|
||||||
|
"time": 1300,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"black": {
|
||||||
|
"before": 250,
|
||||||
|
"after": 250
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"intval3": {
|
||||||
|
"label": "INTVAL3",
|
||||||
|
"cam": {
|
||||||
|
"time": 630,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jk_mono": {
|
||||||
|
"label": "MONO's JK",
|
||||||
|
"cam": {
|
||||||
|
"time": 750,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"proj": {
|
||||||
|
"time": 1300,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"light": false,
|
||||||
|
"projector_second": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cmd": {
|
||||||
|
"camera_forward": "CF",
|
||||||
|
"camera_backward": "CB",
|
||||||
|
"projector_forward": "PF",
|
||||||
|
"projector_backward": "PB",
|
||||||
|
"black_forward": "BF",
|
||||||
|
"black_backward": "BB",
|
||||||
|
"camera_second_forward": "C2F",
|
||||||
|
"camera_second_backward": "C2B",
|
||||||
|
"cameras_forward": "CCB",
|
||||||
|
"camera_forward_camera_second_backward": "CFCB",
|
||||||
|
"camera_backward_camera_second_forward": "CBCF",
|
||||||
|
"projector_second_forward": "P2F",
|
||||||
|
"projector_second_backward": "P2B",
|
||||||
|
"projectors_forward": "PPF",
|
||||||
|
"projectors_backward": "PPB",
|
||||||
|
"projector_forward_projector_second_backward": "PFPB",
|
||||||
|
"projector_backward_projector_second_forward": "PBPF"
|
||||||
|
},
|
||||||
|
"arduino": {
|
||||||
|
"baud": 57600,
|
||||||
|
"board": "uno",
|
||||||
|
"serialDelay": 20,
|
||||||
|
"sequenceDelay": 100,
|
||||||
|
"cam": {
|
||||||
|
"time": 850,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"proj": {
|
||||||
|
"time": 1300,
|
||||||
|
"delay": 50,
|
||||||
|
"momentary": 300
|
||||||
|
},
|
||||||
|
"black": {
|
||||||
|
"before": 250,
|
||||||
|
"after": 250
|
||||||
|
},
|
||||||
|
"cmd": {
|
||||||
|
"debug": "d",
|
||||||
|
"connect": "i",
|
||||||
|
"light": "l",
|
||||||
|
"camera": "c",
|
||||||
|
"projector": "p",
|
||||||
|
"black": "b",
|
||||||
|
"camera_forward": "e",
|
||||||
|
"camera_backward": "f",
|
||||||
|
"projector_forward": "g",
|
||||||
|
"projector_backward": "h",
|
||||||
|
"projector_identifier": "j",
|
||||||
|
"camera_identifier": "k",
|
||||||
|
"mcopy_identifier": "m",
|
||||||
|
"camera_timed": "n",
|
||||||
|
"light_identifier": "o",
|
||||||
|
"projector_light_identifier": "q",
|
||||||
|
"projector_camera_light_identifier": "r",
|
||||||
|
"projector_camera_identifier": "s",
|
||||||
|
"projector_second_identifier": "t",
|
||||||
|
"projectors_identifier": "d",
|
||||||
|
"projector_second_forward": "u",
|
||||||
|
"projector_second_backward": "v",
|
||||||
|
"projector_second": "w",
|
||||||
|
"projectors": "x",
|
||||||
|
"camera_second_identifier": "y",
|
||||||
|
"cameras_identifier": "a",
|
||||||
|
"camera_second_forward": "1",
|
||||||
|
"camera_second_backward": "2",
|
||||||
|
"camera_second": "3",
|
||||||
|
"cameras": "4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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,15 @@
|
||||||
|
<a name="exec"></a>
|
||||||
|
|
||||||
|
## exec(cmd, arg, opts) ⇒ <code>Promise.<{stdout: string, stderr: stderr}></code>
|
||||||
|
Promisified child_process.exec
|
||||||
|
|
||||||
|
**Kind**: global function
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | | |
|
||||||
|
| arg | | |
|
||||||
|
| opts | | See child_process.exec node docs |
|
||||||
|
| opts.stdout | <code>stream.Writable</code> | If defined, child process stdout will be piped to it. |
|
||||||
|
| opts.stderr | <code>stream.Writable</code> | If defined, child process stderr will be piped to it. |
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const execRaw = require('child_process').exec
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Promisified child_process.exec
|
||||||
|
*
|
||||||
|
* @param cmd
|
||||||
|
* @param arg
|
||||||
|
* @param opts See child_process.exec node docs
|
||||||
|
* @param {stream.Writable} opts.stdout If defined, child process stdout will be piped to it.
|
||||||
|
* @param {stream.Writable} opts.stderr If defined, child process stderr will be piped to it.
|
||||||
|
*
|
||||||
|
* @returns {Promise<{ stdout: string, stderr: stderr }>}
|
||||||
|
*/
|
||||||
|
async function exec(...args) {
|
||||||
|
let cmd = args[0]
|
||||||
|
let argz = null
|
||||||
|
let opts = null
|
||||||
|
if (typeof args[1] === 'object' && Array.isArray(args[1])) {
|
||||||
|
argz = args[1]
|
||||||
|
}
|
||||||
|
if (argz === null && typeof args[1] === 'object') {
|
||||||
|
opts = args[1]
|
||||||
|
} else if (typeof args[2] === 'object') {
|
||||||
|
opts = args[2]
|
||||||
|
}
|
||||||
|
if (opts === null) {
|
||||||
|
opts = { maxBuffer : 1024 * 1024 }
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const child = execRaw(cmd, opts,
|
||||||
|
(err, stdout, stderr) => err ? reject(err) : resolve({
|
||||||
|
stdout: stdout,
|
||||||
|
stderr: stderr
|
||||||
|
}));
|
||||||
|
if (opts.stdout) {
|
||||||
|
child.stdout.pipe(opts.stdout);
|
||||||
|
}
|
||||||
|
if (opts.stderr) {
|
||||||
|
child.stderr.pipe(opts.stderr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = exec
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "exec",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "<a name=\"exec\"></a>",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<a name="spawn"></a>
|
||||||
|
|
||||||
|
## spawn()
|
||||||
|
Wrapper function around spawn that prints to console
|
||||||
|
after process closes. Not used.
|
||||||
|
|
||||||
|
**Kind**: global function
|
|
@ -0,0 +1,22 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const spawnRaw = require('child_process').spawn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper function around spawn that prints to console
|
||||||
|
* after process closes. Not used.
|
||||||
|
**/
|
||||||
|
function spawn (cmd, args) {
|
||||||
|
const sp = spawnRaw(cmd, args);
|
||||||
|
let output = '';
|
||||||
|
sp.stderr.on('data', (data) => {
|
||||||
|
output += data;
|
||||||
|
//console.log(`${data}`);
|
||||||
|
});
|
||||||
|
sp.on('close', (code) => {
|
||||||
|
console.log(output);
|
||||||
|
});
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = spawn;
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "spawn",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
|
@ -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,89 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-cli",
|
"name": "mcopy-cli",
|
||||||
"version": "0.0.1",
|
"version": "1.3.2",
|
||||||
"description": "CLI for controlling the mcopy optical printer platform",
|
"description": "CLI for controlling the mcopy optical printer platform",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -18,19 +18,34 @@
|
||||||
"homepage": "https://github.com/sixteenmillimeter/mcopy#readme",
|
"homepage": "https://github.com/sixteenmillimeter/mcopy#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"arduino": "file:lib/arduino",
|
"arduino": "file:lib/arduino",
|
||||||
|
"cam": "file:lib/cam",
|
||||||
|
"cmd": "file:lib/cmd",
|
||||||
"commander": "^2.19.0",
|
"commander": "^2.19.0",
|
||||||
"delay": "file:../app/lib/delay",
|
"delay": "file:../app/lib/delay",
|
||||||
"device": "file:lib/device",
|
"device": "file:lib/device",
|
||||||
|
"devices": "file:lib/devices",
|
||||||
|
"digital": "file:lib/digital",
|
||||||
|
"display": "file:lib/display",
|
||||||
|
"exec": "file:lib/exec",
|
||||||
"exit": "file:lib/exit",
|
"exit": "file:lib/exit",
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^7.0.1",
|
||||||
"humanize-duration": "^3.17.0",
|
"humanize-duration": "^3.17.0",
|
||||||
"intval": "file:lib/intval",
|
"intval": "file:lib/intval",
|
||||||
|
"light": "file:lib/light",
|
||||||
"log": "file:lib/log",
|
"log": "file:lib/log",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"mscript": "file:../app/lib/mscript",
|
"mscript": "file:../app/lib/mscript",
|
||||||
|
"proj": "file:lib/proj",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
|
"sequencer": "file:lib/sequencer",
|
||||||
"serialport": "^7.0.2",
|
"serialport": "^7.0.2",
|
||||||
|
"settings": "file:lib/settings",
|
||||||
|
"spawn": "file:lib/spawn",
|
||||||
|
"systeminformation": "^4.1.1",
|
||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
"winston": "^3.2.1"
|
"winston": "^3.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"pkg": "^4.3.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue