Esempio n. 1
0
  function gitInfo() {
    const git = {
      commit: (shell.exec(`git rev-parse --verify HEAD`, {silent: true}).output || ``).split(`\n`).join(``),
      branch: (shell.exec(`git rev-parse --abbrev-ref HEAD`, {silent: true}).output || ``).split(`\n`).join(``)
    };

    fs.writeFileSync(cfg[`git-info`].dest, JSON.stringify(git, null, 2));
  }
    it("exec blackberry-nativepackager", function () {
        var bbTabletXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<qnx><id>" + config.id + "</id>" +
            "<versionNumber>" + config.version + "</versionNumber>" +
            "<author>" + config.author + "</author>" +
            "<asset entry=\"true\" type=\"qnx/elf\">wwe</asset>" +
            "<asset>abc</asset>" +
            "<asset>xyz</asset>" +
            "<entryPointType>Qnx/WebKit</entryPointType>" +
            "<cascadesTheme>" + config.theme + "</cascadesTheme>" +
            "<initialWindow><systemChrome>none</systemChrome><transparent>true</transparent><autoOrients>true</autoOrients></initialWindow>",
            bbTabletXML2 = "<permission system=\"true\">run_native</permission>" +
            "<permission system=\"false\">access_internet</permission>" +
            "<name>" + config.name['default'] + "</name>" +
            "<description>" + config.description['default'] + "</description></qnx>",
            cmd = "blackberry-nativepackager" + (pkgrUtils.isWindows() ? ".bat" : "");

        spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
            expect(sourceDir).toEqual(session.sourceDir);
            expect(outputDir).toEqual(conf.BAR_DESCRIPTOR);

            //We have to validate the xml data in 2 chucks, because the WEBWORKS_VERSION env variable
            //has a different value for SCM builds and we can't mock the webworks-info file
            expect(data).toContain(bbTabletXML);
            expect(data).toContain(bbTabletXML2);
        });
        nativePkgr.exec(session, target, testData.config, callback);

        expect(fs.writeFileSync).toHaveBeenCalledWith(jasmine.any(String), jasmine.any(String));
        expect(childProcess.spawn).toHaveBeenCalledWith(cmd, ["@options"], {"cwd": session.sourceDir, "env": process.env});
        expect(callback).toHaveBeenCalledWith(0);
    });
 fs.readdir(apiPath, (err, files) =>
 {
     if (files.length > 0)
     {
         for (const fileName of files)
         {
             if (fileName !== '.DS_Store')
             {
                 const apiObj = require(`../api/${fileName}`).default;
                 const { routes, initExec } = apiObj.init();
                 if ((undefined !== initExec && !initExec) && (isArray(routes) && routes.length > 0))
                 {
                     for (const route of routes)
                     {
                         app[route.method.toLowerCase()](route.url.toLowerCase(), apiObj.exec);
                     }
                 }
                 else if (undefined !== initExec && initExec)
                 {
                     apiObj.exec();
                 }
             }
         }
     }
     resolve();
 });
Esempio n. 4
0
File: DB.js Progetto: Omneedia/db
	get: function(uql,cb) {
		var engine=require(__dirname+require('path').sep+'__QUERY__.js');
		var o={
			__SQL__: uql
		};
		engine.exec(o,cb);
	},
Esempio n. 5
0
exports.system = exports.exec = function (cmd, showMessage)
{
    if (!isset(showMessage)) {
        showMessage = true;
    }
    return cpp.exec(cmd, showMessage);    
}
Esempio n. 6
0
 cwd => new Promise( ( resolve, reject ) => exec(
     `npm install`,
     {
         cwd,
         "env": process.env,
     },
     error => ( error ? reject( error ) : resolve() ) )
Esempio n. 7
0
 process.nextTick(function() {
     if (marked)
         md = marked(data);
     else
         md = '<pre>' + data + '</pre>';
     
     Util.exec(callback, null, md);
 });
Esempio n. 8
0
 it('should execute function with parameters', function() {
     var WORD    = 'hello',
         func    = function(word) {
             return word;
         },
         word  = Util.exec(func, WORD);
     
      WORD.should.equal(word);
 });
Esempio n. 9
0
        it("returns 404 if the method is not found", function () {
            req.params.ext = "blackberry.app";
            req.params.method = "NotAMethod";
            spyOn(console, "warn");

            defaultPlugin.exec(req, succ, fail, args);

            expect(fail).toHaveBeenCalledWith(-1, jasmine.any(String), 404);
            expect(console.warn).toHaveBeenCalledWith("Method " + req.params.method + " for " + req.params.ext + " not found");
        });
Esempio n. 10
0
    it("can process localized application description", function () {
        var config = testUtils.cloneObj(testData.config);
        config.description = {"FR": "My app description - FR"};

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain('<description><text xml:lang="FR">My app description - FR</text></description>');
        });

        nativePkgr.exec(session, target, config, callback);
    });
Esempio n. 11
0
    it("makes sure slog2 logging is not enabled when not in debug mode", function () {
        var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";

        spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
            expect(data).not.toContain(tabletXMLEntry);
        });

        session.debug = false;
        nativePkgr.exec(session, target, testData.config, callback);
    });
Esempio n. 12
0
    it("can process localized application name", function () {
        var config = testUtils.cloneObj(testData.config);
        config.name = {"FR": "API Smoke Test - FR"};

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain('<name><text xml:lang="FR">API Smoke Test - FR</text></name>');
        });

        nativePkgr.exec(session, target, config, callback);
    });
    it("shows debug token warning when debug token not a .bar file", function () {
        spyOn(logger, "warn");

        session.debug = true;
        //Current time will ensure that the file doesn't exist.
        session.conf.DEBUG_TOKEN = new Date().getTime() + ".xyz";

        nativePkgr.exec(session, target, testData.config, callback);
        expect(logger.warn).toHaveBeenCalledWith(localize.translate("EXCEPTION_DEBUG_TOKEN_WRONG_FILE_EXTENSION"));
    });
Esempio n. 14
0
    it("can process permissions with no attributes", function () {
        var config = testUtils.cloneObj(testData.config);
        config.permissions = ['read_device_identifying_information'];

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain("<permission>read_device_identifying_information</permission>");
        });

        nativePkgr.exec(session, target, config, callback);

    });
Esempio n. 15
0
    it("can process permissions with attributes", function () {
        var config = testUtils.cloneObj(testData.config);
        config.permissions = [{ '#': 'systemPerm', '@': {"system": "true"}}];

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain("<permission system=\"true\">systemPerm</permission>");
        });

        nativePkgr.exec(session, target, config, callback);

    });
    it("won't show debug token warning when -d options wasn't provided", function () {
        spyOn(logger, "warn");

        session.debug = false;
        //Current time will ensure that the file doesn't exist.
        session.conf.DEBUG_TOKEN = new Date().getTime() + ".bar";

        nativePkgr.exec(session, target, testData.config, callback);

        expect(logger.warn).not.toHaveBeenCalled();
    });
Esempio n. 17
0
    it("can process application description", function () {
        var config = testUtils.cloneObj(testData.config);
        config.description = {"default": "My app description"};

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain("<description>My app description</description>");
        });

        nativePkgr.exec(session, target, config, callback);

    });
    it("should not display empty messages in logger", function () {
        spyOn(logger, "warn");
        spyOn(logger, "error");
        spyOn(logger, "info");

        nativePkgr.exec(session, target, testData.config, callback);

        expect(logger.warn).not.toHaveBeenCalledWith("");
        expect(logger.error).not.toHaveBeenCalledWith("");
        expect(logger.info).not.toHaveBeenCalledWith("");
    });
Esempio n. 19
0
    it("can process application name", function () {
        var config = testUtils.cloneObj(testData.config);
        config.name = {"default": "API Smoke Test"};

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain("<name>API Smoke Test</name>");
        });

        nativePkgr.exec(session, target, config, callback);

    });
Esempio n. 20
0
    it("shows debug token warning when path to file is not valid", function () {
        spyOn(pkgrUtils, "writeFile");
        spyOn(logger, "warn");

        session.debug = true;
        //Current time will ensure that the file doesn't exist.
        session.conf.DEBUG_TOKEN = new Date().getTime() + ".bar";

        nativePkgr.exec(session, target, testData.config, callback);

        expect(logger.warn).toHaveBeenCalledWith(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND"));
    });
Esempio n. 21
0
Applescript.run = function(applescriptString, hollaback) {
  var child = Runner.exec("osascript", ["-"], function(error, result) {
    if (error) {
      logger.error(error);
    } else {
      result = result.trim();
    }
    hollaback(error, result);
  });
  child.stdin.write(applescriptString);
  child.stdin.end();
}
Esempio n. 22
0
    it("makes sure slog2 logging is enabled in debug mode", function () {
        var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";

        //Silence the logger during unit tests
        spyOn(logger, "warn").andCallFake(function () { });
        spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
            expect(data).toContain(tabletXMLEntry);
        });

        session.debug = true;
        nativePkgr.exec(session, target, testData.config, callback);
    });
Esempio n. 23
0
        it("calls the method of the extension", function () {
            var env = {"request": req, "response": res};

            spyOn(testExtension, "getReadOnlyFields");

            req.params.ext = "blackberry.app";
            req.params.method = "getReadOnlyFields";

            defaultPlugin.exec(req, succ, fail, args, env);

            expect(testExtension.getReadOnlyFields).toHaveBeenCalledWith(succ, fail, args, env);
        });
Esempio n. 24
0
        it("returns 404 if the extension is not found", function () {
            var ext = "NotAnExt",
                errMsg = "Extension " + ext + " not found";

            req.params.ext = ext;
            spyOn(console, "warn");

            defaultPlugin.exec(req, succ, fail, args);

            expect(fail).toHaveBeenCalledWith(-1, errMsg, 404);
            expect(console.warn).toHaveBeenCalledWith(errMsg);
        });
Esempio n. 25
0
    function next(err) {
        if (err) {
            return die('Error removing ' + conf.build.dir + "\n" + err);
        }

        var Mojito = require(BASE + 'lib/mojito'),
            Scraper = require('./scraper'),
            Builder = require('./' + buildtype),
            builder = new Builder(writer, new Scraper(Mojito));

        builder.exec(conf, store, cb);
    }
Esempio n. 26
0
    it("adds the mandatory permissions for webworks", function () {
        var config = testUtils.cloneObj(testData.config);
        config.permissions = [];

        spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
            expect(fileData).toContain("<permission system=\"false\">access_internet</permission>");
            expect(fileData).toContain("<permission system=\"true\">run_native</permission>");
        });

        nativePkgr.exec(session, target, config, callback);

    });
Esempio n. 27
0
 exec: (data, event) => {
   const cmdInfo = parseCmd(data)
   const plugin = getPlugin(cmdInfo.plugin)
   try {
     plugin.exec(cmdInfo.args, event, cmdInfo)
   } catch (e) {
     console.error('Plugin [%s] exec failed!', cmdInfo.plugin.name, e)
   }
     // child.exec(`${cmdInfo.path} ${cmdInfo.args.join(' ')}`, (error, stdout, stderr)=>{
     //   if(error) console.error(error);
     //   cb(stdout)
     // })
 },
Esempio n. 28
0
 s3.getSshKey(gateway.s3_keypair_id, function(err, key){
   if (err) { callback(err); return };
   ssh = new Shell({
     host: gateway.public_ip,
     privateKey: new Buffer(key)
   });
   ssh.exec('/home/ubuntu/gatewayd/bin/gateway get_key', function(err, apiKey){
     if (err) { callback(err); return };
     gateway.api_key = apiKey;
     gateway.save().complete(function(){
       callback(null, apiKey);
     });
   });
 });
Esempio n. 29
0
        it("throws a 404 is a multi-level method is not found", function () {
            var env = {"request": req, "response": res};

            spyOn(console, "warn");
            spyOn(testExtension, "getReadOnlyFields");
            testExtension.getReadOnlyFields.a = {
            };

            req.params.ext = "blackberry.app";
            req.params.method = "getReadOnlyFields/a/b/c";

            defaultPlugin.exec(req, succ, fail, args, env);

            expect(fail).toHaveBeenCalledWith(-1, jasmine.any(String), 404);
            expect(console.warn).toHaveBeenCalledWith("Method " + req.params.method + " for " + req.params.ext + " not found");
        });
Esempio n. 30
0
 fs.readFile(name || PATH_INDEX, 'utf8', function(error, template) {
     var panel, data;
     
     if (!error) {
         panel   = CloudFunc.buildFromJSON({
             data        : json,
             template    : Template
         }),
         
         data    = indexProcessing({
             panel   : panel,
             data    : template,
         });
     }
     
     Util.exec(callback, error, data);
 });