Best JavaScript code snippet using root
hg.config-wizard.js
Source:hg.config-wizard.js
1/*2 * Copyright (c) 2010, Sebastian Sdorra3 * All rights reserved.4 * 5 * Redistribution and use in source and binary forms, with or without6 * modification, are permitted provided that the following conditions are met:7 * 8 * 1. Redistributions of source code must retain the above copyright notice,9 * this list of conditions and the following disclaimer.10 * 2. Redistributions in binary form must reproduce the above copyright notice,11 * this list of conditions and the following disclaimer in the documentation12 * and/or other materials provided with the distribution.13 * 3. Neither the name of SCM-Manager; nor the names of its14 * contributors may be used to endorse or promote products derived from this15 * software without specific prior written permission.16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE20 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27 * 28 * http://bitbucket.org/sdorra/scm-manager29 * 30 */31Ext.ns("Sonia.hg");32Sonia.hg.ConfigWizard = Ext.extend(Ext.Window,{33 34 hgConfig: null,35 title: 'Mercurial Configuration Wizard',36 37 initComponent: function(){38 39 this.addEvents('finish');40 41 var config = {42 title: this.title,43 layout: 'fit',44 width: 420,45 height: 140,46 closable: true,47 resizable: true,48 plain: true,49 border: false,50 modal: true,51 bodyCssClass: 'x-panel-mc',52 items: [{53 id: 'hgConfigWizardPanel',54 xtype: 'hgConfigWizardPanel',55 hgConfig: this.hgConfig,56 listeners: {57 finish: {58 fn: this.onFinish,59 scope: this60 }61 }62 }]63 }64 65 Ext.apply(this, Ext.apply(this.initialConfig, config));66 Sonia.hg.ConfigWizard.superclass.initComponent.apply(this, arguments);67 },68 69 onFinish: function(config){70 this.fireEvent('finish', config);71 this.close();72 }73 74});75Sonia.hg.InstallationJsonReader = function(){76 this.RecordType = Ext.data.Record.create([{77 name: "path",78 mapping: "path",79 type: "string"80 }]);81};82Ext.extend(Sonia.hg.InstallationJsonReader, Ext.data.JsonReader, {83 84 readRecords: function(o){85 this.jsonData = o;86 87 if (debug){88 console.debug('read installation data from json');89 console.debug(o);90 }91 92 var records = [];93 var paths = o.path;94 for ( var i=0; i<paths.length; i++ ){95 records.push(new this.RecordType({96 'path': paths[i]97 }));98 }99 return {100 success: true,101 records: records,102 totalRecords: records.length103 };104 }105 106});107Sonia.hg.ConfigWizardPanel = Ext.extend(Ext.Panel,{108 109 hgConfig: null,110 packageTemplate: '<tpl for="."><div class="x-combo-list-item">\111 {id} (hg: {hg-version}, py: {python-version}, size: {size:fileSize})\112 </div></tpl>',113 114 // text115 backText: 'Back',116 nextText: 'Next',117 finishText: 'Finish',118 configureLocalText: 'Configure local installation',119 configureRemoteText: 'Download and install',120 loadingText: 'Loading ...',121 hgInstallationText: 'Mercurial Installation',122 pythonInstallationText: 'Python Installation',123 hgPackageText: 'Mercurial Package',124 errorTitleText: 'Error',125 packageInstallationFailedText: 'Package installation failed',126 installPackageText: 'install mercurial package {0}',127 128 initComponent: function(){129 this.addEvents('finish');130 131 var packageStore = new Ext.data.JsonStore({132 storeId: 'pkgStore',133 proxy: new Ext.data.HttpProxy({134 url: restUrl + 'config/repositories/hg/packages.json',135 disableCaching: false136 }),137 fields: [ 'id', 'hg-version', 'python-version', 'size' ],138 root: 'package',139 listeners: {140 load: {141 fn: this.checkIfPackageAvailable,142 scope: this143 }144 }145 });146 147 var hgInstallationStore = new Ext.data.Store({148 proxy: new Ext.data.HttpProxy({149 url: restUrl + 'config/repositories/hg/installations/hg.json'150 }),151 fields: [ 'path' ],152 reader: new Sonia.hg.InstallationJsonReader(),153 autoLoad: true,154 autoDestroy: true155 });156 157 var pythonInstallationStore = new Ext.data.Store({158 proxy: new Ext.data.HttpProxy({159 url: restUrl + 'config/repositories/hg/installations/python.json'160 }),161 fields: [ 'path' ],162 reader: new Sonia.hg.InstallationJsonReader(),163 autoLoad: true,164 autoDestroy: true165 });166 167 var config = {168 layout: 'card',169 activeItem: 0,170 bodyStyle: 'padding: 5px',171 defaults: {172 bodyCssClass: 'x-panel-mc',173 border: false,174 labelWidth: 120,175 width: 250176 },177 bbar: ['->',{178 id: 'move-prev',179 text: this.backText,180 handler: this.navHandler.createDelegate(this, [-1]),181 disabled: true,182 scope: this183 },{184 id: 'move-next',185 text: this.nextText,186 handler: this.navHandler.createDelegate(this, [1]),187 scope: this188 },{189 id: 'finish',190 text: this.finishText,191 handler: this.applyChanges,192 scope: this,193 disabled: true194 }],195 items: [{196 id: 'cod',197 items: [{198 id: 'configureOrDownload',199 xtype: 'radiogroup',200 name: 'configureOrDownload',201 columns: 1,202 items: [{203 boxLabel: this.configureLocalText, 204 name: 'cod', 205 inputValue: 'localInstall',206 checked: true207 },{208 id: 'remoteInstallRadio',209 boxLabel: this.configureRemoteText, 210 name: 'cod', 211 inputValue: 'remoteInstall', 212 disabled: true213 }]214 }],215 listeners: {216 render: {217 fn: function(panel){218 panel.body.mask(this.loadingText);219 var store = Ext.StoreMgr.lookup('pkgStore');220 store.load.defer(100, store);221 },222 scope: this223 }224 }225 },{226 id: 'localInstall',227 layout: 'form',228 defaults: {229 width: 250230 },231 items: [{232 id: 'mercurial',233 fieldLabel: this.hgInstallationText,234 name: 'mercurial',235 xtype: 'combo',236 readOnly: false,237 triggerAction: 'all',238 lazyRender: true,239 mode: 'local',240 editable: true,241 store: hgInstallationStore,242 valueField: 'path',243 displayField: 'path',244 allowBlank: false,245 value: this.hgConfig.hgBinary246 },{247 id: 'python',248 fieldLabel: this.pythonInstallationText,249 name: 'python',250 xtype: 'combo',251 readOnly: false,252 triggerAction: 'all',253 lazyRender: true,254 mode: 'local',255 editable: true,256 store: pythonInstallationStore,257 valueField: 'path',258 displayField: 'path',259 allowBlank: false,260 value: this.hgConfig.pythonBinary261 }]262 },{263 id: 'remoteInstall',264 layout: 'form',265 defaults: {266 width: 250267 },268 items: [{269 id: 'package',270 fieldLabel: this.hgPackageText,271 name: 'package',272 xtype: 'combo',273 readOnly: false,274 triggerAction: 'all',275 lazyRender: true,276 mode: 'local',277 editable: false,278 store: packageStore,279 valueField: 'id',280 displayField: 'id',281 allowBlank: false,282 tpl: this.packageTemplate,283 listeners: {284 select: function(){285 Ext.getCmp('finish').setDisabled(false);286 }287 }288 }]289 }]290 }291 292 Ext.apply(this, Ext.apply(this.initialConfig, config));293 Sonia.hg.ConfigWizardPanel.superclass.initComponent.apply(this, arguments);294 },295 296 checkIfPackageAvailable: function(store){297 Ext.getCmp('cod').body.unmask();298 var c = store.getTotalCount();299 if ( debug ){300 console.debug( "found " + c + " package(s)" );301 }302 if ( c > 0 ){303 Ext.getCmp('remoteInstallRadio').setDisabled(false);304 }305 },306 307 navHandler: function(direction){308 var layout = this.getLayout();309 var id = layout.activeItem.id;310 311 var next = -1;312 313 if ( id == 'cod' && direction == 1 ){314 var v = Ext.getCmp('configureOrDownload').getValue().getRawValue();315 var df = false;316 if ( v == 'localInstall' ){317 next = 1;318 } else if ( v == 'remoteInstall' ){319 next = 2;320 df = true;321 }322 Ext.getCmp('move-prev').setDisabled(false);323 Ext.getCmp('move-next').setDisabled(true);324 Ext.getCmp('finish').setDisabled(df);325 } 326 else if (direction == -1 && (id == 'localInstall' || id == 'remoteInstall')) {327 next = 0;328 Ext.getCmp('move-prev').setDisabled(true);329 Ext.getCmp('move-next').setDisabled(false);330 Ext.getCmp('finish').setDisabled(true); 331 }332 333 if ( next >= 0 ){334 layout.setActiveItem(next);335 }336 },337 338 applyChanges: function(){339 var v = Ext.getCmp('configureOrDownload').getValue().getRawValue();340 if ( v == 'localInstall' ){341 this.applyLocalConfiguration();342 } else if ( v == 'remoteInstall' ){343 this.applyRemoteConfiguration();344 }345 },346 347 applyRemoteConfiguration: function(){348 if ( debug ){349 console.debug( "apply remote configuration" );350 }351 352 var pkg = Ext.getCmp('package').getValue();353 if ( debug ){354 console.debug( 'install mercurial package ' + pkg );355 }356 357 var lbox = Ext.MessageBox.show({358 title: this.loadingText,359 msg: String.format(this.installPackageText, pkg),360 width: 300,361 wait: true,362 animate: true,363 progress: true,364 closable: false365 });366 367 Ext.Ajax.request({368 url: restUrl + 'config/repositories/hg/packages/' + pkg + '.json',369 method: 'POST',370 scope: this,371 timeout: 900000, // 15min372 success: function(){373 if ( debug ){374 console.debug('package successfully installed');375 }376 lbox.hide();377 this.fireEvent('finish');378 },379 failure: function(){380 if ( debug ){381 console.debug('package installation failed');382 }383 lbox.hide();384 Ext.MessageBox.show({385 title: this.errorTitleText,386 msg: this.packageInstallationFailedText,387 buttons: Ext.MessageBox.OK,388 icon:Ext.MessageBox.ERROR389 });390 }391 });392 393 394 },395 396 applyLocalConfiguration: function(){397 if ( debug ){398 console.debug( "apply remote configuration" );399 }400 var mercurial = Ext.getCmp('mercurial').getValue();401 var python = Ext.getCmp('python').getValue();402 if (debug){403 console.debug( 'configure mercurial=' + mercurial + " and python=" + python );404 }405 delete this.hgConfig.pythonPath;406 delete this.hgConfig.useOptimizedBytecode;407 this.hgConfig.hgBinary = mercurial;408 this.hgConfig.pythonBinary = python;409 410 if ( debug ){411 console.debug( this.hgConfig );412 }413 414 this.fireEvent('finish', this.hgConfig);415 }416 417});418// register xtype419Ext.reg('hgConfigWizardPanel', Sonia.hg.ConfigWizardPanel);420// i18n421if ( i18n != null && i18n.country == 'de' ){422 Ext.override(Sonia.hg.ConfigWizardPanel, {423 backText: 'Zurück',424 nextText: 'Weiter',425 finishText: 'Fertigstellen',426 configureLocalText: 'Eine lokale Installation Konfigurieren',427 configureRemoteText: 'Herunterladen und installieren',428 loadingText: 'Lade ...',429 hgInstallationText: 'Mercurial Installation',430 pythonInstallationText: 'Python Installation',431 hgPackageText: 'Mercurial Package',432 errorTitleText: 'Fehler',433 packageInstallationFailedText: 'Package Installation fehlgeschlagen',434 installPackageText: 'Installiere Mercurial-Package {0}'435 });...
AppInstallHelper.test.js
Source:AppInstallHelper.test.js
1const deviceId = 'mock-device-id';2const appBinaryPath = '/mock-app-binary-path/binary.apk';3const testBinaryPath = '/mock-test-binary-path/test/binary.apk';4describe('Android app installation helper', () => {5 let adb;6 beforeEach(() => {7 const ADBMock = jest.genMockFromModule('../exec/ADB');8 adb = new ADBMock();9 });10 let fileXfer;11 let uut;12 beforeEach(() => {13 const TempFileXfer = jest.genMockFromModule('./TempFileXfer');14 fileXfer = new TempFileXfer();15 const AppInstallHelper = require('./AppInstallHelper');16 uut = new AppInstallHelper(adb, fileXfer);17 });18 it('should recreate the transient dir on the device', async () => {19 await uut.install(deviceId, appBinaryPath, testBinaryPath);20 expect(fileXfer.prepareDestinationDir).toHaveBeenCalledWith(deviceId);21 });22 it('should throw if transient dir prep fails', async () => {23 fileXfer.prepareDestinationDir.mockRejectedValue(new Error('mocked error in adb-shell'));24 try {25 await uut.install(deviceId, appBinaryPath, testBinaryPath);26 fail('expected to throw');27 } catch (err) {}28 });29 it('should push app-binary file to the device', async () => {30 await uut.install(deviceId, appBinaryPath, testBinaryPath);31 expect(fileXfer.send).toHaveBeenCalledWith(deviceId, appBinaryPath, 'Application.apk');32 });33 it('should push test-binary file to the device', async () => {34 await uut.install(deviceId, appBinaryPath, testBinaryPath);35 expect(fileXfer.send).toHaveBeenCalledWith(deviceId, testBinaryPath, 'Test.apk');36 });37 it('should break if file push fails', async () => {38 fileXfer.send.mockRejectedValue(new Error('mocked error in adb-push'));39 try {40 await uut.install(deviceId, appBinaryPath, testBinaryPath);41 fail('expected to throw');42 } catch(err) {}43 });44 it('should remote-install both binaries via shell', async () => {45 fileXfer.send46 .mockReturnValueOnce('/mocked-final-dir/first.apk')47 .mockReturnValueOnce('/mocked-final-dir/second.apk');48 await uut.install(deviceId, appBinaryPath, testBinaryPath);49 expect(adb.remoteInstall).toHaveBeenCalledWith(deviceId, '/mocked-final-dir/first.apk');50 expect(adb.remoteInstall).toHaveBeenCalledWith(deviceId, '/mocked-final-dir/second.apk');51 });52 it('should break if remote-install fails', async () => {53 adb.remoteInstall.mockRejectedValue(new Error('mocked error in remote-install'));54 try {55 await uut.install(deviceId, appBinaryPath, testBinaryPath);56 fail('expected to throw');57 } catch(err) {}58 });59 it('should allow for an install with no test binary', async () => {60 fileXfer.send61 .mockReturnValueOnce('/mocked-final-dir/first.apk')62 .mockReturnValueOnce('/mocked-final-dir/second.apk');63 await uut.install(deviceId, appBinaryPath, undefined);64 expect(fileXfer.send).toHaveBeenCalledTimes(1);65 expect(adb.remoteInstall).toHaveBeenCalledWith(deviceId, '/mocked-final-dir/first.apk');66 expect(adb.remoteInstall).toHaveBeenCalledTimes(1);67 });...
shipitfile.js
Source:shipitfile.js
1var path = require('path');2var Promise = require('bluebird');3var argv = require('minimist')(process.argv.slice(2));4module.exports = function (shipit) {5 require('shipit-deploy')(shipit);6 shipit.initConfig({7 default: {8 workspace: '/tmp/hipush',9 deployTo: '/opt/hipush',10 repositoryUrl: 'git@github.com:hipush/hipush.git',11 ignores: ['.*', 'test'],12 keepReleases: 5,13 branch: 'master'14 },15 http: {16 services: ['hipush-http'],17 servers: 'www.hipush.net'18 },19 workers: {20 services: ['hipush-send-worker', 'hipush-apn-worker'],21 servers: 'workers.hipush.net'22 }23 });24 shipit.currentPath = path.join(shipit.config.deployTo, 'current');25 shipit.on('fetched', function () {26 shipit.start('install', 'build', 'migrate', 'prune');27 });28 shipit.on('updated', function () {29 shipit.start('remoteInstall');30 });31 shipit.on('published', function () {32 shipit.start('restartServices');33 });34 shipit.blTask('install', function () {35 return shipit.local(36 'npm install',37 {cwd: shipit.config.workspace}38 );39 });40 shipit.blTask('build', function () {41 return shipit.local(42 './node_modules/.bin/gulp build',43 {cwd: shipit.config.workspace}44 );45 });46 shipit.blTask('prune', function () {47 return shipit.local(48 'npm prune --production',49 {cwd: shipit.config.workspace}50 );51 });52 shipit.blTask('migrate', function () {53 return shipit.local(54 './node_modules/.bin/gulp db:migrate',55 {cwd: shipit.config.workspace}56 );57 });58 shipit.blTask('remoteInstall', function () {59 return shipit.remote(60 'cd ' + shipit.releasePath + ' && ' +61 'npm rebuild'62 );63 });64 shipit.blTask('restartServices', function () {65 return Promise.all(shipit.config.services.map(function (service) {66 return shipit.remote('sudo service ' + service + ' restart');67 }));68 });...
Using AI Code Generation
1$scope.remoteInstall = function() {2 $rootScope.remoteInstall();3};4$rootScope.remoteInstall = function() {5 $http({6 }).then(function successCallback(response) {7 console.log(response);8 }, function errorCallback(response) {9 console.log(response);10 });11};12I have also tried to use the remoteInstall method in the test.js file. But I am getting an error. I have also tried to use the $scope.remoteInstall()
Using AI Code Generation
1var root = require('root.js');2var remoteInstall = root.remoteInstall;3remoteInstall(url, function(err, result) {4 if (err) {5 console.log('error occurred while installing', err);6 } else {7 console.log('result of installation', result);8 }9});10- [async](
Using AI Code Generation
1var remoteInstall = root.remoteInstall;2 console.log(data);3});4var remoteInstall = child.remoteInstall;5 console.log(data);6});7var remoteInstall = root.remoteInstall;8 console.log(data);9});10var remoteInstall = child.remoteInstall;11 console.log(data);12});13var remoteInstall = root.remoteInstall;14 console.log(data);15});16var remoteInstall = child.remoteInstall;17 console.log(data);18});19var remoteInstall = root.remoteInstall;20 console.log(data);21});22var remoteInstall = child.remoteInstall;23 console.log(data);24});25var remoteInstall = root.remoteInstall;26 console.log(data);27});28var remoteInstall = child.remoteInstall;29 console.log(data);30});31var remoteInstall = root.remoteInstall;32 console.log(data);33});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!