})).then(function (versions) { // select first msbuild version available, and resolve promise with it return versions[0] || versions[1] ? Q.resolve(versions[0] || versions[1]) : // Reject promise if no msbuild versions found Q.reject('MSBuild tools not found'); });
module.exports.run = function () { if (os.platform() != 'win32'){ // Build Universal windows apps available for windows platform only, so we reject on others platforms return Q.reject('ERROR: Cordova tooling for Windows requires Windows OS'); } // Check whther MSBuild Tools are available return MSBuildTools.findAvailableVersion(); };
module.exports.getAppStoreUtils = function () { var appStoreUtils = path.join(__dirname, 'WindowsStoreAppUtils.ps1'); if (!fs.existsSync (appStoreUtils)) { return Q.reject("Can't unblock AppStoreUtils script"); } //console.log("Removing execution restrictions from AppStoreUtils..."); return spawn('powershell', ['Unblock-File', module.exports.quote(appStoreUtils)]).then(function () { return Q.resolve(appStoreUtils); }).fail(function (err) { return Q.reject(err); }); };
module.exports.getApplyPlatformConfigScript = function () { var scriptPath = path.join(__dirname, 'ApplyPlatformConfig.ps1'); if (!fs.existsSync (scriptPath)) { return Q.reject("Can't unblock ApplyPlatformConfig.ps1 script"); } //console.log("Removing execution restrictions from ApplyPlatformConfig..."); return spawn('powershell', ['Unblock-File', module.exports.quote(scriptPath)]).then(function () { return Q.resolve(scriptPath); }).fail(function (err) { return Q.reject(err); }); };
module.exports.run = function (argv) { var projectPath = argv[2]; if (!fs.existsSync(projectPath)){ // if specified project path is not valid then reject promise Q.reject("The given path to the project does not exist." + " Please provide a path to the project you would like to update."); } return extractMetadata(projectPath).then(function (metadata) { shell.rm('-rf', projectPath); // setup args for create.run which requires process.argv-like array var createArgs = argv.concat([metadata.namespace, metadata.name]); return create.run(createArgs); }); };
// returns package metadata from config.xml with fields 'namespace' and 'name' function extractMetadata(projectPath) { if (!fs.existsSync(path.join(projectPath, 'config.xml'))){ return Q.reject('config.xml does not exist'); } var meta = { // default values namespace: 'io.cordova.hellocordova', name: 'HelloCordova' }; // TODO: read real values from config.xml // in case of Cordova CLI all values will be automatically updated by cli for you // but the script could be used w/o CLI so we should correctly populate meta return Q.resolve(meta); }
this.getBrowser = function() { return q.reject('Sessions are being terminating'); };
function (error) { t.ok(error, "fetch error"); return Q.reject(error); }
.fail(function(e) { _this._cancelled = true; return q.reject(e); })
.then(function() { // TODO: This seems like another error case, even though it always happens. console.error('ERROR : Unable to create an avd emulator, no targets found.'); console.error('Please insure you have targets available by running the "android" command'); return Q.reject(); }, function(error) {
function (error) { return Q.reject(error); }
contentSenderMock.send = function() { return q.reject(new Error('Error in contentSender.send')); };
}).fail(function (err) { return Q.reject(err); });
run: function() { return Q.reject("** No rule to make target '" + id + "'"); }
.then(function (val) { if (!val || !val.val || !val.uri) { return Q.reject('no plugin changed!'); } return val; })
var requesterDruid_0_8_3 = ({query}) => { if (query.queryType === 'status') return Q({ version: '0.8.3' }); expect(query.dataSource).to.equal('wikipedia'); if (query.queryType === 'segmentMetadata') { expect(query.merge).to.equal(true); expect(query.analysisTypes).to.be.an('array'); var merged = { "id": "merged", "intervals": null, "size": 0, "numRows": 654321, "columns": { "__time": { "type": "LONG", "hasMultipleValues": false, "size": 0, "cardinality": null, "errorMessage": null }, "added": { "type": "FLOAT", "hasMultipleValues": false, "size": 0, "cardinality": null, "errorMessage": null }, "anonymous": { "type": "STRING", "hasMultipleValues": false, "size": 0, "cardinality": 0, "errorMessage": null }, "count": { "type": "LONG", "hasMultipleValues": false, "size": 0, "cardinality": null, "errorMessage": null }, "delta_hist": { "type": "approximateHistogram", "hasMultipleValues": false, "size": 0, "cardinality": null, "errorMessage": null }, "language": { "type": "STRING", "hasMultipleValues": false, "size": 0, "cardinality": 0, "errorMessage": null }, "namespace": { "type": "STRING", "hasMultipleValues": true, "size": 0, "cardinality": 0, "errorMessage": null }, "newPage": { "type": "STRING", "hasMultipleValues": false, "size": 0, "cardinality": 0, "errorMessage": "lol wtf" }, "newUser": { "type": "STRING", "hasMultipleValues": false, "size": -1, "cardinality": 0, "errorMessage": null }, "page": { "type": "STRING", "hasMultipleValues": false, "size": 0, "cardinality": 0, "errorMessage": null }, "time": { "type": "STRING", "hasMultipleValues": false, "size": 0, "cardinality": 0, "errorMessage": null }, "user_unique": { "type": "hyperUnique", "hasMultipleValues": false, "size": 0, "cardinality": null, "errorMessage": null } } }; if (query.analysisTypes.indexOf("aggregators") !== -1) { return Q.reject(new Error('Can not construct instance of io.druid.query.metadata.metadata.SegmentMetadataQuery$AnalysisType')); } return Q([merged]); } else if (query.queryType === 'introspect') { return Q({ dimensions: ['anonymous', 'language', 'namespace', 'newPage', 'page', 'time'], metrics: ['added', 'count', 'delta_hist', 'user_unique'] }); } else { throw new Error(`unsupported query ${query.queryType}`); } };
.then(function(docs) { if (!docs || !docs.password) return q.reject(Error("email not present")); return q.all([docs,checkPwd(docs.password,obj.password)]); });
var requesterFail = ({query}) => { return Q.reject(new Error('Bad status code')); };
Q.fcall(function(){ if (req.method != 'GET') { return Q.reject(); } })
module.exports.run = function (argv) { var args = nopt({ // "archs": String, // TODO: add support for building different archs 'debug': Boolean, 'release': Boolean, 'device': Boolean, 'emulator': Boolean, 'codeSignIdentity': String, 'codeSignResourceRules': String, 'provisioningProfile': String, 'buildConfig' : String }, {'-r': '--release'}, argv); if (args.debug && args.release) { return Q.reject('Only one of "debug"/"release" options should be specified'); } if (args.device && args.emulator) { return Q.reject('Only one of "device"/"emulator" options should be specified'); } if(args.buildConfig) { if(!fs.existsSync(args.buildConfig)) { return Q.reject('Build config file does not exist:' + args.buildConfig); } console.log('Reading build config file:', path.resolve(args.buildConfig)); var buildConfig = JSON.parse(fs.readFileSync(args.buildConfig, 'utf-8')); if(buildConfig.ios) { var buildType = args.release ? 'release' : 'debug'; var config = buildConfig.ios[buildType]; if(config) { ['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile'].forEach( function(key) { args[key] = args[key] || config[key]; }); } } } return check_reqs.run().then(function () { return findXCodeProjectIn(projectPath); }).then(function (name) { projectName = name; var extraConfig = ''; if (args.codeSignIdentity) { extraConfig += 'CODE_SIGN_IDENTITY = ' + args.codeSignIdentity + '\n'; extraConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*] = ' + args.codeSignIdentity + '\n'; } if (args.codeSignResourceRules) { extraConfig += 'CODE_SIGN_RESOURCE_RULES_PATH = ' + args.codeSignResourceRules + '\n'; } if (args.provisioningProfile) { extraConfig += 'PROVISIONING_PROFILE = ' + args.provisioningProfile + '\n'; } return Q.nfcall(fs.writeFile, path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8'); }).then(function () { var configuration = args.release ? 'Release' : 'Debug'; console.log('Building project : ' + path.join(projectPath, projectName + '.xcodeproj')); console.log('\tConfiguration : ' + configuration); console.log('\tPlatform : ' + (args.device ? 'device' : 'emulator')); var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration, args.device); return spawn('xcodebuild', xcodebuildArgs, projectPath); }).then(function () { if (!args.device) { return; } var buildOutputDir = path.join(projectPath, 'build', 'device'); var pathToApp = path.join(buildOutputDir, projectName + '.app'); var pathToIpa = path.join(buildOutputDir, projectName + '.ipa'); var xcRunArgs = ['-sdk', 'iphoneos', 'PackageApplication', '-v', pathToApp, '-o', pathToIpa]; if (args.codeSignIdentity) { xcRunArgs.concat('--sign', args.codeSignIdentity); } if (args.provisioningProfile) { xcRunArgs.concat('--embed', args.provisioningProfile); } return spawn('xcrun', xcRunArgs, projectPath); }); };
var func = function () { return Q.reject(); };
exports.signTransaction = function(transactionHex, unspents, keychain) { if (typeof(transactionHex) != 'string') { throw new Error('expecting the transaction hex as a string'); } if (!Array.isArray(unspents)) { throw new Error('expecting the unspents array'); } if (typeof(keychain) != 'object' || typeof(keychain.xprv) != 'string') { throw new Error('expecting the keychain object with xprv'); } var transaction = Transaction.fromHex(transactionHex); if (transaction.ins.length !== unspents.length) { throw new Error('length of unspents array should equal to the number of transaction inputs'); } var rootExtKey = HDNode.fromBase58(keychain.xprv); for (var index = 0; index < transaction.ins.length; ++index) { var path = keychain.path + '/0/0' + unspents[index].chainPath; var extKey = rootExtKey.deriveFromPath(path); // subscript is the part of the output script after the OP_CODESEPARATOR. // Since we are only ever signing p2sh outputs, which do not have // OP_CODESEPARATORS, it is always the output script. var subscript = Script.fromHex(unspents[index].redeemScript); // In order to sign with bitcoinjs-lib, we must use its transaction // builder, confusingly named the same exact thing as our transaction // builder, but with inequivalent behavior. var txb = _TransactionBuilder.fromTransaction(transaction); try { txb.sign(index, extKey.privKey, subscript, Transaction.SIGHASH_ALL); } catch (e) { return Q.reject('Failed to sign input #' + index); } // Build the "incomplete" transaction, i.e. one that does not have all // the signatures (since we are only signing the first of 2 signatures in // a 2-of-3 multisig). transaction = txb.buildIncomplete(); // bitcoinjs-lib adds one more OP_0 than we need. It creates one OP_0 for // every n public keys in an m-of-n multisig, and replaces the OP_0s with // the signature of the nth public key, then removes any remaining OP_0s // at the end. This behavior is not incorrect and valid for some use // cases, particularly if you do not know which keys will be signing the // transaction and the signatures may be added to the transaction in any // chronological order, but is not compatible with the BitGo API, which // assumes m OP_0s for m-of-n multisig (or m-1 after the first signature // is created). Thus we need to remove the superfluous OP_0. var chunks = transaction.ins[index].script.chunks; if (chunks.length !== 5) { throw new Error('unexpected number of chunks in the OP_CHECKMULTISIG script after signing') } if (chunks[1]) { chunks.splice(2, 1); // The extra OP_0 is the third chunk } else if (chunks[2]) { chunks.splice(1, 1); // The extra OP_0 is the second chunk } transaction.ins[index].script = Script.fromChunks(chunks); // Finally, verify that the signature is correct, and if not, throw an // error. if (exports.verifyInputSignatures(transaction, index, subscript) !== -1) { throw new Error('number of signatures is invalid - something went wrong when signing'); } } return Q.when({ transactionHex: transaction.toBuffer().toString('hex') }); };
var logError = function(err) { console.log(err.message || err); return Q.reject(err); };
const notStarted = () => project ? null : q.reject({ statusCode: 500, response: {body: "Server error: Project Not Started"} });
gitRemoteOriginUrl = function() { return Q.reject(err); };
module.exports.check_os = function () { // Build iOS apps available for OSX platform only, so we reject on others platforms return os_platform_is_supported() ? Q.resolve(process.platform) : Q.reject('Cordova tooling for iOS requires Apple macOS'); };
function startProject(project) { const itemsenseApi = util.connectToItemsense(project.itemSense.trim(), project.user, project.password); var readPromise = null, interval = null, itemSenseJob = null, connected = false, results = wrapResults(), wrapper = Object.create({ stash: function (promise) { return promise.then(function (data) { results.last = createResultItem(data.items, "at"); return results.last; }, function (error) { if (results.last.at) results.last.to = true; else results.last = createResultItem(error, "from"); return q.reject(error); }).finally(function () { readPromise = null; }); }, restCall(opts, user, password){ const defer = q.defer(), options = _.extend({method: "GET", json: true}, opts), req = request(options, function (err, response, body) { if (err) defer.reject(err); else if (response.statusCode > 399) defer.reject(response); else defer.resolve(body); }); if (user) req.auth(user, password); return defer.promise; }, getNodeRedFlow(){ readPromise = wrapper.stash(wrapper.restCall({url: project.nodeRedEndPoint})) .catch(error => { console.log(error); return q.reject(error); }); return readPromise; }, getDirect(){ if (!itemSenseJob) if (connected) return q.reject({statusCode: 503, response: {body: "Job not started"}}); else return q({items: []}); readPromise = wrapper.stash(itemsenseApi.items.get({ pageSize: 1000, fromTime: itemSenseJob.creationTime.replace(/[.].+Z.+/, "") })); return readPromise; }, getItems: function () { if (readPromise) return readPromise; return project.itemSource === "Direct Connection" ? this.getDirect() : this.getNodeRedFlow(); }, dumpConfig(){ const worker = new ConfigDump(itemsenseApi, project); if (itemSenseJob && !this.isComplete(itemSenseJob)) return worker.dumpJob(itemSenseJob.id); return worker.dumpAll(); }, startJob: function (opts) { var job = _.merge({ "recipeName": "RTL", "durationSeconds": 20, "startDelay": "PT0S", "reportToDatabaseEnabled": true, "reportToHistoryEnabled": true, "reportToMessageQueueEnabled": true, "reportToFileEnabled": true }, opts); return itemsenseApi.jobs.start(job).then(function (job) { itemSenseJob = job; return job; }); }, postReaders: function (data) { return itemsenseApi.readerDefinitions.update(data); }, getReaders: function () { return itemsenseApi.readerDefinitions.get().then(list => _.filter(list || [], this.inProject)); }, getRecipes: function (recipeName) { return itemsenseApi.recipes.get(recipeName); }, addZoneMap: function (data) { var self = this; return itemsenseApi.zoneMaps.update(data).then(function (zmap) { if (!itemSenseJob) return self.setCurrentZoneMap(zmap.name).then(function () { return zmap; }); return zmap; }); }, addFacility: function (data) { return itemsenseApi.facilities.createOrReplace(data); }, deleteZoneMap: function (data) { return itemsenseApi.zoneMaps.delete(data); }, setCurrentZoneMap: function (name) { return itemsenseApi.currentZoneMap.update(name); }, getCurrentZoneMap() { return itemsenseApi.currentZoneMap.get(project.facility); }, getZoneMap(data) { return data ? itemsenseApi.zoneMaps.get(data) : itemsenseApi.zoneMaps.getAll(); }, getFacilities: () => itemsenseApi.facilities.get(), getJobs: function (id) { return itemsenseApi.jobs.get(id); }, getRunningJob: function () { return this.getJobs().then(function (jobs) { return _.find(jobs, function (j) { return j.status.indexOf("RUNNING") !== -1 && j.job.facility === project.facility; }); }); }, getJobReaders: (job, recipe) => recipe.readerConfigurationName ? job.readerNames : Object.keys(recipe.readerConfigurations), inProject: reader => reader.facility === project.facility && (!reader.placement || reader.placement.floor === project.floorName), getLLRPStatus() { const result = {}; return this.getReaders().then(readers => { result.readers = readers; return this.getRunningJob(); }).then(job => { result.job = itemSenseJob = job; return job ? this.getRecipes(job.job.recipeName) : null; }).then(recipe => { if (!recipe) return {}; const jobReaders = this.getJobReaders(result.job, recipe); return _.reduce(jobReaders, function (r, reader) { r[reader] = "engage"; return r; }, {}); }).then(inJob => { const notInJob = _.filter(result.readers, reader => !inJob[reader.name]); result.status = inJob; return q.all(_.map(notInJob, reader => this.isReaderConnected(reader))); }).then(occupied => _.reduce(occupied, function (r, reader) { if (reader) r[reader.name] = reader.status || "occupied"; return r; }, result.status) ).then(status => _.reduce(result.readers, function (r, reader) { if (!r[reader.name]) r[reader.name] = "disengage"; return r; }, status) ); }, isReaderConnected(reader){ return this.getReaderHomePage(reader) .then(homePage => this.isReaderOccupied(homePage) ? {name: reader.name} : null) .catch(err => { console.log("Error reading home page", err, err.message, reader); return (err.message === "ETIMEDOUT") ? {name: reader.name, status: "disconnected"} : {name: reader.name, status: err.message}; }); }, getReaderHomePage(reader) { return this.restCall({ url: `http://${reader.address}/cgi-bin/index.cgi`, method: "GET", timeout: 10000 }, project.readerUser || "root", project.readerPassword || "impinj"); }, isReaderOccupied(homePage) { const match = homePage.match(/Table_Contents_Left..LLRP Status[^T]+Table_Contents_Right..([^<]+)/); return !match || match[1] !== "Disconnected"; }, isComplete: function (job) { return job ? _.find(["COMPLETE", "STOPPED"], function (c) { return job.status.startsWith(c); }) : true; }, stopInterval: function () { if (interval) clearInterval(interval); interval = null; }, monitorJob: function (id) { var self = this; return this.getJobs(id).then(function (job) { if (itemSenseJob && job.id === itemSenseJob.id) if (self.isComplete(job)) { self.stopInterval(); itemSenseJob = null; } return job; }); }, stopJob: function (id) { return itemsenseApi.jobs.stop(id).then(() => { if (id === itemSenseJob.id) itemSenseJob = null; }); } }, { project: { get: function () { return project; }, set: function (v) { project = v; } }, results: { get: function () { return results; } }, lastResult: { get: function () { return results.last; } }, itemSenseJob: { set: function (v) { itemSenseJob = v; } }, connected: { set: function (v) { connected = true; } } }); return wrapper; }
return versions.get_tool_version(tool).then(function (version) { return versions.compareVersions(version, minVersion) >= 0 ? Q.resolve(version) : Q.reject('Cordova needs ' + tool + ' version ' + minVersion + ' or greater, you have version ' + version + '.'); });
.catch(error => { console.log(error); return q.reject(error); });
var checkGenerator = function(options) { if (!generators[options.generator]) { return Q.reject(new Error("Invalid generator (availables are: "+_.keys(generators).join(", ")+")")); } return Q(); };