SyncTask.prototype.multiserve = function() { var localkit; try { localkit = new Localkit(monaca, true); } catch (error) { util.err('Unable to start livesync: ' + error); } var projects = argv._.slice(1); if (projects.length === 0) { util.err('You must supply a list of project directories.'); process.exit(1); } localkit.setProjects(projects) .then( function() { util.print('Starting file listening.'); return localkit.startWatch(); }, function(error) { util.err('Unable to add projects: ' + error); process.exit(1); } ) .then( function() { util.print('Starting HTTP server.'); return localkit.startHttpServer({ httPort: argv.port }); }, function(error) { util.error('Unable to start file watching: ' + error); process.exit(1); } ) .then( function(server) { util.print(('Listening on ' + server.address + ':' + server.port).help); util.print('Starting beacon transmitter.'); return localkit.startBeaconTransmitter(); }, function(error) { util.err('Unable to start HTTP server: ' + error); process.exit(1); } ) .then( function() { util.print('Waiting for connections from Monaca debugger...'.help); }, function(error) { util.err('Unable to start beacon transmitter: ' + error); process.exit(1); } ); };
function(error) { if (error === 'ECONNRESET') { util.err('Unable to connect to Monaca Cloud.'); util.print('Are you connected to the Internet?'); util.print('If you need to use a proxy, please configure it with "monaca proxy".'); } else { util.err('Must be signed in to use this command.'); util.print('Please sign in with \'monaca login\'.'); util.print('If you don\'t have an account yet you can create one at https://monaca.mobi/en/register/start'); } }
ContentVersion.findById(id,function(err,version) { if(err && !version) { calipso.err(err); next(); return; } // Copy over Content.findById(contentId,function(err,content) { if(err && !content) { calipso.err(err) next(); return; } calipso.form.mapFields(version.doc,content); content.author = req.session.user.username; content.set("comment",'Reverted to version: ' + content.updated); content.updated = new Date(); content.set("version",'Yes'); content.save(function(err) { res.redirect('/content/show/' + contentId); next(); }); }); });
read( { prompt: 'Destination directory: ', default: project.name, edit: true }, function(error, destPath) { if (destPath.trim() === '') { destPath = process.cwd(); } if (error) { util.err('Unable to read destination directory.'); } else { var absolutePath = path.resolve(destPath); util.print('Cloning "' + project.name + '" to ' + absolutePath); monaca.cloneProject(project.projectId, destPath).then( function() { util.print('Project successfully cloned from Monaca Cloud!'); }, function(error) { util.err('Clone failed: ' + error); }, function(progress) { var per = 100 * (progress.index + 1) / progress.total; per = per.toString().substr(0, 5) + '%'; util.print(('[' + per + '] ').verbose + progress.path); } ); } });
var loginErrorHandler = function (error) { if (error === 'ECONNRESET') { util.print('Unable to connect to Monaca Cloud. Are you connected to the internet?').warn; util.print('If you need to use a proxy, please configure it with "monaca proxy".'); } else { if (error.hasOwnProperty('code') && error.code == 503) { if (error.hasOwnProperty('result') && error.result.hasOwnProperty('confirm') && error.result.confirm) { util.warn(error); read({ prompt: ' [Y/n]:' }, function(err, answer) { if (answer.toLowerCase().charAt(0) !== 'n') { if (error.result.hasOwnProperty('redirect')) { open(error.result.redirect); } } }); } else { util.warn(error); if (error.hasOwnProperty('result') && error.result.hasOwnProperty('redirect')) { read({ prompt: 'Press Enter to continue...' }, function() { open(error.result.redirect); }); } } } else if (error.hasOwnProperty('code') && error.code == 402) { util.err('Your Monaca CLI evaluation period has expired. Please upgrade the plan to continue.'); read({ prompt: 'Press Enter to display upgrade page.' }, function(err, answer) { open('https://monaca.mobi/plan/change'); }); } else { util.err(); util.err('Unable to sign in: ', error); return { nextTask: { set: 'auth', name: 'login' } }; } } };
syno.surveillance.camera.disable({cameraIds: configured_cams.ids[i].id}, function(err, data){ if (err){ logger.err(err); }else{ logger.info("adapter surveillance camera ["+configured_cams.ids[i].id+"] " +"was disabled ("+data.success+")."); } });
syno.surveillance.recording.record({cameraId: configured_cams.ids[i].id, action: action}, function(err, data){ if (err){ logger.err(err); }else{ logger.info("adapter surveillance camera ["+configured_cams.ids[i].id+"] " +action+"s recording ("+data.success+")."); } });
localkit.on('inspectorError', function(error) { switch (error) { case 'ERROR_ADB': util.print(); util.err('Error running ADB command.'); util.err('Make sure you installed Android SDK and adb is in your PATH.'); util.print('Download site: http://developer.android.com/sdk/index.html') util.print(); break; case 'ERROR_START_PROXY': util.err('Failed starting the proxy. Check if iOS device is properly connected and authorized.'); break; default: util.err('Error launching inspector. Please check the connection to the device. ERRNO=' + error); util.print('Troubleshooting Guide: ' + lib.DEBUGGER_TROUBLESHOOTING_DOC_URL); break; } });
var displayMonacaInfo = function() { try { var cliPackage = require(path.join(__dirname, '..', 'package.json')); util.success('\nMonaca dependencies\n'); util.print(util.alignContent('monaca-lib') + cliPackage.dependencies['monaca-lib']); util.print(util.alignContent('monaca-cli') + info.clientVersion + '\n'); } catch (err) { util.err('Failed displaying monaca info: ' + err); } };
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'ok': deferred.resolve(response); break; case 'fatal': case 'error': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'continue': conn.sendBinary(dumpPointCloud); break; case 'ok': deferred.resolve(response); break; case 'fatal': case 'error': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'continue': conn.sendBinary(svgFile); conn.sendBinary(bitmapFile); break; case 'ok': deferred.resolve(response); break; case 'fatal': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'progressing': case 'computing': // ignore break; case 'complete': deferred.resolve(response); break; case 'fatal': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'ok': case 'continue': // do nothing break; case 'progressing': dumpPointCloud = response.buffer; deferred.resolve(response); break; case 'fatal': case 'error': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'continue': width = response.width; height = response.height; break; case 'progressing': deferred.resolve(response); break; case 'ok': // do nothing break; case 'fatal': default: bootstrap.err(response); break; } })
onProgress(function(response, deferred, conn) { // progress switch (response.status) { case 'starting': conn.sendText(['upload', uploadName, file.length].join(' ')); break; case 'continue': conn.sendBinary(file); break; case 'ok': deferred.resolve(response); break; case 'fatal': case 'error': default: bootstrap.err(response); break; } })
var displaySystem = function() { util.success('System\n'); try { var os = getOperatingSystem(), nodeVersion = process.versions.node, npmVersion = npm.version; if (os) { util.print(util.alignContent('os') + os); } if (nodeVersion) { util.print(util.alignContent('node') + nodeVersion); } if (npmVersion) { util.print(util.alignContent('npm') + npmVersion + '\n'); } } catch (err) { util.err('Failed displaying system info: ' + err); } };
Content.findById(contentId,function(err, content) { if(err && !content) { calipso.err(err) next(); return; } calipso.utils.copyMongoObject(version, content, content.schema); content.author = req.session.user.username; content.set("comment",'Reverted to version: ' + content.updated); content.updated = new Date(); content.set("version", 'Yes'); content.save(function(err) { res.redirect('/content/show/' + contentId); next(); }); });
ContentVersion.findById(id,function(err,version) { if(err && !version) { calipso.err(err); next(); return; } if(format === 'html') { calipso.theme.renderItem(req,res,template,block,{version:version},next); } if(format === 'json') { res.format = format; res.send(version.map(function(u) { return u.toObject(); })); next(); } });
onProgress(function(response, deferred, conn) { var nextParam; // progress switch (response.status) { case 'starting': case 'ok': nextParam = params.pop(); if ('undefined' === typeof nextParam) { deferred.resolve(response); } else { conn.sendText(['set_params', nextParam.name, nextParam.value].join(' ')); } break; case 'fatal': default: bootstrap.err(response); break; } })
function(error) { util.err('Unable to add project: ' + error); process.exit(1); }
function(error) { util.err('Unable to start beacon transmitter: ' + error); process.exit(1); }
SyncTask.prototype.livesync = function() { var localkit; try { localkit = new Localkit(monaca, true); } catch(error) { util.err('Unable to start livesync: ' + error); process.exit(1); } util.print('Starting HTTP server...'); localkit.startHttpServer({ httpPort: argv.port }).then( function(server) { util.print('HTTP server started.'); util.print(('Listening on ' + server.address + ':' + server.port).help); util.print('Starting beacon transmitter...'); // Send "exit" event when program is terminated. process.on('SIGINT', function() { util.print('Stopping livesync...'); this.sendExitEvent(); process.exit(0); }.bind(localkit.projectEvents)); localkit.startBeaconTransmitter().then( function() { util.print('Beacon transmitter started.'); util.print('Waiting for connections from Monaca debugger...'.help); var projectPath = process.cwd(); localkit.addProject(projectPath).then( function() { return monaca.getLocalProjectId(projectPath); }, function(error) { util.err('Unable to add project: ' + error); process.exit(1); } ) .then( function(projectId) { localkit.projectEvents.sse.on('connection', function(client) { localkit.projectEvents.sendMessage({ action: 'start', projectId: projectId }, client); }); return localkit.startWatch(); }, function(error) { util.err('Unable to get project id: ' + error); } ) .then( function() { util.print('Started file watching.'); return localkit.startProject(projectPath); }, function(error) { util.err('Unable to start file watching: ' + error); process.exit(1); } ); }, function(error) { util.err('Unable to start beacon transmitter: ' + error); process.exit(1); } ); }, function(error) { util.err('Unable to start HTTP server: ' + error); util.print('This is probably due to the port already being in use. Please use --port option to change port.'); process.exit(1); } ); };
function(error) { util.err('Unable to start HTTP server: ' + error); util.print('This is probably due to the port already being in use. Please use --port option to change port.'); process.exit(1); }
function(error) { util.err('Unable to start file watching: ' + error); process.exit(1); }
SyncTask.livesync = function() { var localkit, nwError = false; try { localkit = new Localkit(monaca, false); } catch (error) { return monaca .reportFail(report, 'Unable to start debug: ' + util.parseError(error)) .catch(util.fail); } if (Object.keys(localkit.pairingKeys).length == 0) { util.print(''); util.print('Welcome to Monaca debug - Live-reload and debug in the real device'); util.print(''); util.print('To get started, you need to install Monaca Debugger on your phone.') util.print(''); util.print(' For Android Devices: Search and install "Monaca" in Google Play'); util.print(' For iOS Devices: Search and install "Monaca" in App Store'); util.print('') util.print('After installation, connect your device to the same WiFi network'); util.print('and it will find this computer for pairing.') util.print('') util.print('Debugging Guide (JavaScript Dev Tools)') util.print(' https://docs.monaca.io/en/manual/debugger/debug/#debugger-with-local-tools') util.print('') util.print('Troubleshooting Guide:') util.print(' https://docs.monaca.io/en/manual/debugger/troubleshooting') util.print('') } else { util.print('Please run Monaca Debugger on your device.'); util.print('') util.print('Debugging Guide (JavaScript Dev Tools)') util.print(' https://docs.monaca.io/en/manual/debugger/debug/#debugger-with-local-tools') util.print('') util.print('Troubleshooting Guide:') util.print(' https://docs.monaca.io/en/manual/debugger/troubleshooting') util.print('') } try { localkit.on('debuggerConnected', function(client) { util.print('Debugger connected: ' + client.deviceManufacturer + ' ' + client.deviceType); }) localkit.on('debuggerDisconnected', function(client) { util.print('Debugger disconnected: ' + client.deviceManufacturer + ' ' + client.deviceType); }) localkit.on('httpResponse', function(response) { util.print(' ' + response.message + ' > ' + response.code); }) localkit.on('inspectorError', function(error) { switch (error) { case 'ERROR_ADB': util.print(); util.err('Error running ADB command.'); util.err('Make sure you installed Android SDK and adb is in your PATH.'); util.print('Download site: http://developer.android.com/sdk/index.html') util.print(); break; case 'ERROR_START_PROXY': util.err('Failed starting the proxy. Check if iOS device is properly connected and authorized.'); break; default: util.err('Error launching inspector. Please check the connection to the device. ERRNO=' + error); util.print('Troubleshooting Guide: https://docs.monaca.io/en/manual/debugger/troubleshooting/'); break; } }); } catch (error) { } try { var nw = path.join(process.cwd(), 'node_modules', 'nw'); var nwBin = require(nw).findpath(); var adbPath = path.join(__dirname, '..', 'bin', process.platform, (process.platform == "win32") ? 'adb.exe' : 'adb'); localkit.initInspector({ inspectorCallback: function(result) { child_process.spawn(nwBin, [result.app, result.webSocketUrl]); }, adbPath: adbPath }); } catch (error) { if ( error.code === 'MODULE_NOT_FOUND' ) { nwError = true; } } var projects = argv._.slice(1); if (projects.length === 0) { projects.push('.'); } var report = { event: 'debug', arg1: JSON.stringify(projects) }; monaca.reportAnalytics(report); if (projects.length > 1) { projects = [projects.shift()]; util.err('Only one project can be served at the same time. Serving ', projects[0]); } var error = 'Unable to add projects: '; localkit.setProjects(projects) // Adding projects. .then( function() { // Starting file watching error = 'Unable to start file watching: '; return localkit.startWatch(); } ) .then( function() { // Starting HTTP server error = 'Unable to start HTTP server: '; return localkit.startHttpServer({ httpPort: argv.port }); } ) // Starting HTTP server. .then( function(server) { // Send "exit" event when program is terminated. process.on('SIGINT', function() { util.print('\nStopping debug...'); this.sendExitEvent(); process.exit(0); }.bind(localkit.projectEvents)); util.print('Waiting for Monaca Debugger connecting to ' + server.address + ':' + server.port + '.'); error = 'Unable to start beacon transmitter: '; return localkit.startBeaconTransmitter(); } ) // Starting beacon transmiter. .then( function() { if (nwError) { util.warn('\nNode Webkit is not installed, so inspector capabilities will be disabled.\nPlease run "npm install nw" and restart the debug.\n'); } } ) .then( monaca.reportFinish.bind(monaca, report), monaca.reportFail.bind(monaca, report) ) .then( function() { var options = { watch: true, cache: true }; var promises = []; projects.forEach(function(project) { promises.push(monaca.transpile(project, options)) }); return Q.all(promises); } ) .catch( util.fail.bind(null, error, '\n') ); };
return monaca.setProjectId(project.absolutePath, project.projectId).catch(function(error) { util.err('\nProject is cloned to given location but Cloud project ID for this project could not be saved. \nThis project is not linked with corresponding project on Monaca Cloud.'); });
}, function(error) { util.err('Failed to transpile: ', error); });
(dir) => { projectDir= dir; lib.needToUpgrade(projectDir, monaca); // if it is transpile project but doesn't has the watch script, it should be failed if (monaca.hasTranspileScript(projectDir) && !monaca.hasDebugScript(projectDir)) util.fail('Please create \'monaca:debug\' script to transpile and watch the file changes in \'package.json\' '); try { var nw = path.join(projectDir, 'node_modules', 'nw'); var nwBin = require(nw).findpath(); var adbPath = path.join(__dirname, '..', 'bin', process.platform, (process.platform == "win32") ? 'adb.exe' : 'adb'); localkit.initInspector({ inspectorCallback: function(result) { child_process.spawn(nwBin, [result.app, result.webSocketUrl]); }, adbPath: adbPath }); } catch (error) { if ( error.code === 'MODULE_NOT_FOUND' ) { nwError = true; } } var projects = argv._.slice(1); if (projects.length === 0) { projects.push(projectDir); } var report = { event: 'debug', arg1: JSON.stringify(projects) }; monaca.reportAnalytics(report); if (projects.length > 1) { projects = [projects.shift()]; util.err('Only one project can be served at the same time. Serving ', projects[0]); } var error = 'Unable to add projects: '; localkit.setProjects(projects) // Adding projects. .then( function() { // Starting file watching error = 'Unable to start file watching: '; return localkit.startWatch(); } ) .then( function() { // Starting HTTP server error = 'Unable to start HTTP server: '; return localkit.startHttpServer({ httpPort: port }); } ) // Starting HTTP server. .then( function(server) { // Send "exit" event when program is terminated. process.on('SIGINT', function() { util.print('\nStopping debug...'); this.sendExitEvent(); process.exit(0); }.bind(localkit.projectEvents)); util.print('Waiting for Monaca Debugger connecting to ' + server.address + ':' + server.port + '.'); error = 'Unable to start beacon transmitter: '; return localkit.startBeaconTransmitter(); } ) // Starting beacon transmiter. .then( function() { if (nwError) { util.warn('\nNode Webkit is not installed, so inspector capabilities will be disabled.\nPlease run "npm install nw@0.26.6" and restart the debug.\n'); } } ) .then( monaca.reportFinish.bind(monaca, report), monaca.reportFail.bind(monaca, report) ) .then( function() { var options = { watch: true, cache: true }; var promises = []; projects.forEach(function(project) { promises.push(monaca.transpile(project, options)); }); return Q.all(promises); } ) .catch( util.fail.bind(null, error, '\n') ); }
function(error) { util.err('Unable to get project id: ' + error); }