From 14b247934504dcf2055674facf8d8ac077823e23 Mon Sep 17 00:00:00 2001 From: blackcat Date: Sun, 22 Sep 2013 19:52:09 +0200 Subject: [PATCH 1/5] coffee-script not required anymore and fixed some bugs --- .gitignore | 2 + bin/aur-info | 1 - bin/aur-publish | 1 - lib/aur.js | 168 +++++++++++++++++++++++++++++++++++++ lib/aur.map | 10 +++ lib/config.js | 15 ++++ lib/config.map | 10 +++ package.json | 7 +- {lib => src}/aur.coffee | 4 +- {lib => src}/config.coffee | 3 +- 10 files changed, 213 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 lib/aur.js create mode 100644 lib/aur.map create mode 100644 lib/config.js create mode 100644 lib/config.map rename {lib => src}/aur.coffee (96%) rename {lib => src}/config.coffee (71%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..50a0c39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +node_modules/ diff --git a/bin/aur-info b/bin/aur-info index 1c6d65d..d08bec9 100755 --- a/bin/aur-info +++ b/bin/aur-info @@ -1,6 +1,5 @@ #!/usr/bin/env node -require ('coffee-script'); var aur = require('../lib/aur'); var argv = require('optimist') diff --git a/bin/aur-publish b/bin/aur-publish index 2502ed1..a207985 100755 --- a/bin/aur-publish +++ b/bin/aur-publish @@ -1,6 +1,5 @@ #!/usr/bin/env node -require ('coffee-script'); var aur = require('../lib/aur'); var argv = require('optimist') diff --git a/lib/aur.js b/lib/aur.js new file mode 100644 index 0000000..127ba35 --- /dev/null +++ b/lib/aur.js @@ -0,0 +1,168 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var FormData, aur, cheerio, config, defaultCb, fs, querystring, request, _; + + request = require('request'); + + querystring = require('querystring'); + + FormData = require('form-data'); + + fs = require('fs'); + + _ = require('underscore'); + + config = require('./config'); + + cheerio = require("cheerio"); + + request = request.defaults({ + proxy: process.env['https_proxy'], + jar: false + }); + + aur = module.exports = { + info: function(name, options, cb) { + var url; + if (typeof options === 'function') { + cb = options; + options = {}; + } + cb || (cb = defaultCb); + options = _.extend({}, config, options); + url = options.url.base + options.url.info + name; + return request({ + url: url + }, function(err, resp, body) { + var json; + if (err) { + return cb(err); + } + json = JSON.parse(body); + if (json.type === 'error') { + return cb(new Error(json.results)); + } + return cb(null, json.results); + }); + }, + publish: function(user, password, filePkg, category, options, cb) { + var categories, categoryId; + if (typeof options === 'function') { + cb = options; + options = {}; + } + cb || (cb = defaultCb); + if (typeof category === 'object') { + options = category; + category = null; + } + category || (category = 'system'); + options = _.extend({}, config, options); + categories = { + daemons: 2, + devel: 3, + editors: 4, + emulators: 5, + games: 6, + gnome: 7, + i18n: 8, + kde: 9, + lib: 10, + modules: 11, + multimedia: 12, + network: 13, + office: 14, + science: 15, + system: 16, + x11: 17, + xfce: 18, + kernels: 19 + }; + categoryId = categories[category]; + return this.login(user, password, options, function(err, cookie) { + var form; + if (err) { + return cb(err); + } + form = new FormData(); + form.append('pkgsubmit', '1'); + form.append('token', cookie.replace('AURSID=', '')); + form.append('category', categoryId + ''); + form.append('pfile', fs.createReadStream(filePkg)); + return form.getLength(function(err, length) { + if (err) { + return cb(err); + } + return form.pipe(request({ + method: 'POST', + headers: form.getHeaders({ + 'Cookie': cookie, + 'Content-Length': length + }), + url: options.url.base + options.url.post + }, function(err, resp, data) { + var $; + if (err) { + return cb(err); + } + $ = cheerio.load(data); + if ($('.pkgoutput').text()) { + return cb(new Error($(".pkgoutput").text())); + } + return cb(null, data); + })); + }); + }); + }, + login: function(user, password, options, cb) { + var dataForm, url; + if (typeof options === 'function') { + cb = options; + options = {}; + } + cb || (cb = defaultCb); + options = _.extend({}, config, options); + url = options.url.base; + dataForm = querystring.stringify({ + user: user, + passwd: password + }); + return request({ + url: url, + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Length': dataForm.length + }, + body: dataForm + }, function(err, resp) { + var regex, setCookie, sid; + if (err) { + return cb(err); + } + if (!resp.headers['set-cookie']) { + return cb(new Error('Wrong login or password')); + } + setCookie = resp.headers['set-cookie']; + regex = /AURSID=\w*/; + if (!regex.test(setCookie)) { + return cb(new Error('No SessionID')); + } + sid = regex.exec(setCookie)[0]; + return cb(null, sid); + }); + } + }; + + defaultCb = function(err, results) { + if (err) { + return console.error(err); + } + return console.log(results); + }; + +}).call(this); + +/* +//@ sourceMappingURL=aur.map +*/ diff --git a/lib/aur.map b/lib/aur.map new file mode 100644 index 0000000..988aff3 --- /dev/null +++ b/lib/aur.map @@ -0,0 +1,10 @@ +{ + "version": 3, + "file": "aur.js", + "sourceRoot": "..", + "sources": [ + "src/aur.coffee" + ], + "names": [], + "mappings": ";AAAA;CAAA,KAAA,gEAAA;;CAAA,CAAA,CAAc,IAAd,EAAc;;CAAd,CACA,CAAc,IAAA,IAAd,EAAc;;CADd,CAEA,CAAc,IAAA,CAAd,GAAc;;CAFd,CAGA,CAAc,CAAA,GAAA;;CAHd,CAIA,CAAc,IAAA,KAAA;;CAJd,CAKA,CAAc,GAAd,CAAc,GAAA;;CALd,CAMA,CAAc,IAAd,EAAc;;CANd,CAQA,CAAU,IAAV,CAAU;CAAiB,CAAO,CAAY,CAAnB,CAAA,EAAc,MAAK;CAAnB,CAAwC,CAAL,CAAA,CAAnC;CAR3B,GAQU;;CARV,CAUA,CAAA,GAAY,CAAN;CAGJ,CAAM,CAAA,CAAN,GAAM,EAAC;CACL,EAAA,OAAA;AAAG,CAAH,GAAG,CAAkB,CAArB,CAAG,GAAH;CACE,CAAA,CAAK,IAAL,CAAA;CAAA,CAAA,CACU,IAAV,CAAA;QAFF;CAAA,EAGO,GAAP;CAHA,CAIU,CAAA,GAAV,CAAA;CAJA,EAKA,CAAM,EAAN,CAAa;CACL,MAAR,MAAA;CAAQ,CAAI,CAAJ,KAAA;EAAS,CAAA,CAAA,IAAjB,CAAkB;CAChB,GAAA,QAAA;CAAA,EAAA,CAAiB,IAAjB;CAAA,CAAO,CAAA,cAAA;UAAP;CAAA,EACO,CAAP,CAAO,GAAP;CACA,GAAqC,C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AA;UAAP;AACsD,CAAtD,GAAkD,GAAiB,CAAnE,IAAmE;CAAnE,CAAO,EAAO,CAAA,YAAP,QAAO;UADd;CAAA,EAEY,CAAI,GAAS,CAAzB,CAAA,GAAyB;CAFzB,EAIQ,EAAR,GAAA,IAJA;AAK2C,CAA3C,GAAuC,CAAS,GAAhD,CAA2C;CAA3C,CAAO,EAAO,CAAA,SAAA,GAAP;UALP;CAAA,EAOA,CAAI,CAAK,GAAT,CAAI;CACD,CAAH,CAAA,CAAA,WAAA;CAhBJ,MAOE;CA1FJ,IAqEO;CAlFT,GAAA;;CAAA,CAmHA,CAAY,IAAA,EAAZ;CACE,EAAA,CAAA;CAAA,EAAO,EAAA,EAAO,MAAP;MAAP;CACQ,EAAR,IAAO,IAAP;CArHF,EAmHY;CAnHZ" +} \ No newline at end of file diff --git a/lib/config.js b/lib/config.js new file mode 100644 index 0000000..ca1f973 --- /dev/null +++ b/lib/config.js @@ -0,0 +1,15 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + module.exports = { + url: { + base: 'https://aur.archlinux.org/', + info: 'rpc.php?type=info&arg=', + post: 'pkgsubmit.php' + } + }; + +}).call(this); + +/* +//@ sourceMappingURL=config.map +*/ diff --git a/lib/config.map b/lib/config.map new file mode 100644 index 0000000..0a0f3da --- /dev/null +++ b/lib/config.map @@ -0,0 +1,10 @@ +{ + "version": 3, + "file": "config.js", + "sourceRoot": "..", + "sources": [ + "src/config.coffee" + ], + "names": [], + "mappings": ";AAAA;CAAA,CAAA,CACE,GADI,CAAN;CACE,CACE,CADF,CAAA;CACE,CAAM,EAAN,EAAA,sBAAA;CAAA,CACM,EAAN,EAAA,kBADA;CAAA,CAEM,EAAN,EAAA,SAFA;MADF;CADF,GAAA;CAAA" +} \ No newline at end of file diff --git a/package.json b/package.json index b84fae6..86013cf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Filirom1 ", "name": "aur", "description": "Archlinux AUR cli", - "version": "0.1.2", + "version": "0.1.3", "homepage": "https://github.com/Filirom1/nodejs-aur", "repository": { "type": "git", @@ -12,7 +12,7 @@ "type": "MIT", "url": "http://www.opensource.org/licenses/MIT" }, - "main": "lib/aur.coffee", + "main": "lib/aur", "bin": { "aur-info": "bin/aur-info", "aur-publish": "bin/aur-publish" @@ -24,16 +24,17 @@ "dependencies": { "form-data": "https://github.com/Filirom1/node-form-data/tarball/master", "request": "~2.9.202", - "coffee-script": "~1.3.3", "underscore": "~1.3.3", "optimist": "~0.3.4", "cheerio": "~0.8.3" }, "devDependencies": { + "coffee-script": "~1.6.3", "vows": "0.6.x", "express": "2.5.x" }, "scripts": { + "install": "coffee -o lib -m -c src", "test": "./node_modules/.bin/vows test/* --spec" } } diff --git a/lib/aur.coffee b/src/aur.coffee similarity index 96% rename from lib/aur.coffee rename to src/aur.coffee index f512907..21af7f9 100644 --- a/lib/aur.coffee +++ b/src/aur.coffee @@ -72,7 +72,7 @@ aur = module.exports = headers: form.getHeaders 'Cookie': cookie 'Content-Length': length - url: options.url.base + options.url.post + url: options.url.base + (options.url.post || '') , (err, resp, data) -> return cb err if err $ = cheerio.load data @@ -86,7 +86,7 @@ aur = module.exports = options = {} cb or= defaultCb options = _.extend {}, config, options - url = options.url.base + url = options.url.base + (options.url.login || '') # Create the auth data form dataForm = querystring.stringify diff --git a/lib/config.coffee b/src/config.coffee similarity index 71% rename from lib/config.coffee rename to src/config.coffee index 9c83ecf..50c9c68 100644 --- a/lib/config.coffee +++ b/src/config.coffee @@ -2,4 +2,5 @@ module.exports = url: base: 'https://aur.archlinux.org/' info: 'rpc.php?type=info&arg=' - post: 'pkgsubmit.php' + post: 'submit/' + login: 'login/' From 57963a3799afe6ad2fb99ca6d312bad4f468bfe0 Mon Sep 17 00:00:00 2001 From: blackcat Date: Sun, 22 Sep 2013 19:58:24 +0200 Subject: [PATCH 2/5] don't need source map --- lib/aur.js | 8 ++------ lib/aur.map | 10 ---------- lib/config.js | 7 ++----- lib/config.map | 10 ---------- package.json | 2 +- 5 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 lib/aur.map delete mode 100644 lib/config.map diff --git a/lib/aur.js b/lib/aur.js index 127ba35..42be5d7 100644 --- a/lib/aur.js +++ b/lib/aur.js @@ -99,7 +99,7 @@ 'Cookie': cookie, 'Content-Length': length }), - url: options.url.base + options.url.post + url: options.url.base + (options.url.post || '') }, function(err, resp, data) { var $; if (err) { @@ -122,7 +122,7 @@ } cb || (cb = defaultCb); options = _.extend({}, config, options); - url = options.url.base; + url = options.url.base + (options.url.login || ''); dataForm = querystring.stringify({ user: user, passwd: password @@ -162,7 +162,3 @@ }; }).call(this); - -/* -//@ sourceMappingURL=aur.map -*/ diff --git a/lib/aur.map b/lib/aur.map deleted file mode 100644 index 988aff3..0000000 --- a/lib/aur.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "aur.js", - "sourceRoot": "..", - "sources": [ - "src/aur.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,gEAAA;;CAAA,CAAA,CAAc,IAAd,EAAc;;CAAd,CACA,CAAc,IAAA,IAAd,EAAc;;CADd,CAEA,CAAc,IAAA,CAAd,GAAc;;CAFd,CAGA,CAAc,CAAA,GAAA;;CAHd,CAIA,CAAc,IAAA,KAAA;;CAJd,CAKA,CAAc,GAAd,CAAc,GAAA;;CALd,CAMA,CAAc,IAAd,EAAc;;CANd,CAQA,CAAU,IAAV,CAAU;CAAiB,CAAO,CAAY,CAAnB,CAAA,EAAc,MAAK;CAAnB,CAAwC,CAAL,CAAA,CAAnC;CAR3B,GAQU;;CARV,CAUA,CAAA,GAAY,CAAN;CAGJ,CAAM,CAAA,CAAN,GAAM,EAAC;CACL,EAAA,OAAA;AAAG,CAAH,GAAG,CAAkB,CAArB,CAAG,GAAH;CACE,CAAA,CAAK,IAAL,CAAA;CAAA,CAAA,CACU,IAAV,CAAA;QAFF;CAAA,EAGO,GAAP;CAHA,CAIU,CAAA,GAAV,CAAA;CAJA,EAKA,CAAM,EAA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,CAAA;CACE,CAAgB,QAAhB,IAAA,qBAAA;CAAA,CACkB,IADlB,EAC0B,EAA1B,MAAA;UAJF;CAAA,CAKM,EAAN,IAAA;EACA,CAAA,CAAA,IAPF,CAOG;CACC,WAAA,SAAA;CAAA,EAAA,CAAiB,IAAjB;CAAA,CAAO,CAAA,cAAA;UAAP;AACsD,CAAtD,GAAkD,GAAiB,CAAnE,IAAmE;CAAnE,CAAO,EAAO,CAAA,YAAP,QAAO;UADd;CAAA,EAEY,CAAI,GAAS,CAAzB,CAAA,GAAyB;CAFzB,EAIQ,EAAR,GAAA,IAJA;AAK2C,CAA3C,GAAuC,CAAS,GAAhD,CAA2C;CAA3C,CAAO,EAAO,CAAA,SAAA,GAAP;UALP;CAAA,EAOA,CAAI,CAAK,GAAT,CAAI;CACD,CAAH,CAAA,CAAA,WAAA;CAhBJ,MAOE;CA1FJ,IAqEO;CAlFT,GAAA;;CAAA,CAmHA,CAAY,IAAA,EAAZ;CACE,EAAA,CAAA;CAAA,EAAO,EAAA,EAAO,MAAP;MAAP;CACQ,EAAR,IAAO,IAAP;CArHF,EAmHY;CAnHZ" -} \ No newline at end of file diff --git a/lib/config.js b/lib/config.js index ca1f973..8241db4 100644 --- a/lib/config.js +++ b/lib/config.js @@ -4,12 +4,9 @@ url: { base: 'https://aur.archlinux.org/', info: 'rpc.php?type=info&arg=', - post: 'pkgsubmit.php' + post: 'submit/', + login: 'login/' } }; }).call(this); - -/* -//@ sourceMappingURL=config.map -*/ diff --git a/lib/config.map b/lib/config.map deleted file mode 100644 index 0a0f3da..0000000 --- a/lib/config.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "config.js", - "sourceRoot": "..", - "sources": [ - "src/config.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,CAAA,CACE,GADI,CAAN;CACE,CACE,CADF,CAAA;CACE,CAAM,EAAN,EAAA,sBAAA;CAAA,CACM,EAAN,EAAA,kBADA;CAAA,CAEM,EAAN,EAAA,SAFA;MADF;CADF,GAAA;CAAA" -} \ No newline at end of file diff --git a/package.json b/package.json index 86013cf..ce35018 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "express": "2.5.x" }, "scripts": { - "install": "coffee -o lib -m -c src", + "install": "coffee -o lib -c src", "test": "./node_modules/.bin/vows test/* --spec" } } From f04bf4de91bdd3c54493f79f73426e1218a5febc Mon Sep 17 00:00:00 2001 From: blackcat Date: Sun, 22 Sep 2013 20:07:20 +0200 Subject: [PATCH 3/5] tests should work --- test/aur.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/aur.coffee b/test/aur.coffee index 0a480fe..2972523 100644 --- a/test/aur.coffee +++ b/test/aur.coffee @@ -86,7 +86,8 @@ config = url: base: "http://localhost:#{port}/" info: 'rpc.php?type=info&arg=' - post: 'pkgsubmit.php' + login: 'login/' + post: 'submit/' dummyPkg = Maintainer: 'filirom1' @@ -114,7 +115,7 @@ app.get '/rpc.php', (req, res)-> res.json type: 'error', results: 'No results found' # Login -app.post '/', (req, res)-> +app.post '/#{config.url.login}/', (req, res)-> if req.body.user is 'user' and req.body.passwd is 'passwd' res.cookie('AURSID','70bd1ee338d6767283b81e3e50c3610b', {httpOnly: true, secure: true, path: '/'}) res.send '' From 6792213e3f31cd989cdc8ca8ebffb2316959c3a6 Mon Sep 17 00:00:00 2001 From: blackcat Date: Sun, 22 Sep 2013 21:09:42 +0200 Subject: [PATCH 4/5] correct tests --- Makefile | 5 +++++ package.json | 3 +-- test.log | 23 +++++++++++++++++++++++ test/aur.coffee | 7 ++++--- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 Makefile create mode 100644 test.log diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5653d46 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +all: + coffee -o lib -c src + +clean: + rm lib/*.js diff --git a/package.json b/package.json index ce35018..84c5424 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "express": "2.5.x" }, "scripts": { - "install": "coffee -o lib -c src", - "test": "./node_modules/.bin/vows test/* --spec" + "test": "./node_modules/.bin/vows test/*.coffee --spec" } } diff --git a/test.log b/test.log new file mode 100644 index 0000000..96046bb --- /dev/null +++ b/test.log @@ -0,0 +1,23 @@ +/rpc.php +/login/ +/submit/ +/rpc.php called: {} +/rpc.php called: {} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"blabla"} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"blabal"} +/login/ called: {"user":"user","passwd":"passwd"} +/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} +/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} +/rpc.php called: {} +/rpc.php called: {} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"blabla"} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"passwd"} +/login/ called: {"user":"user","passwd":"blabal"} +/login/ called: {"user":"user","passwd":"passwd"} +/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} +/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} diff --git a/test/aur.coffee b/test/aur.coffee index 2972523..18af871 100644 --- a/test/aur.coffee +++ b/test/aur.coffee @@ -1,7 +1,8 @@ vows = require 'vows' assert = require 'assert' express = require 'express' -aur = require '../lib/aur' +aur = require '../src/aur' +fs = require "fs" app = express.createServer() app.use express.bodyParser() @@ -107,7 +108,7 @@ dummyPkg = app.use express.bodyParser() # Search -app.get '/rpc.php', (req, res)-> +app.get "/rpc.php", (req, res)-> throw new Error 'arg not specified' if not req.query.arg if req.query.arg is 'nodejs-npm2arch' res.json type: 'info', results: dummyPkg @@ -115,7 +116,7 @@ app.get '/rpc.php', (req, res)-> res.json type: 'error', results: 'No results found' # Login -app.post '/#{config.url.login}/', (req, res)-> +app.post "/#{config.url.login}", (req, res)-> if req.body.user is 'user' and req.body.passwd is 'passwd' res.cookie('AURSID','70bd1ee338d6767283b81e3e50c3610b', {httpOnly: true, secure: true, path: '/'}) res.send '' From 72b549ede0ca5ce1b009861f514fb7514d3f793b Mon Sep 17 00:00:00 2001 From: blackcat Date: Sun, 22 Sep 2013 21:10:12 +0200 Subject: [PATCH 5/5] don't need logfile --- test.log | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 test.log diff --git a/test.log b/test.log deleted file mode 100644 index 96046bb..0000000 --- a/test.log +++ /dev/null @@ -1,23 +0,0 @@ -/rpc.php -/login/ -/submit/ -/rpc.php called: {} -/rpc.php called: {} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"blabla"} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"blabal"} -/login/ called: {"user":"user","passwd":"passwd"} -/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} -/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} -/rpc.php called: {} -/rpc.php called: {} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"blabla"} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"passwd"} -/login/ called: {"user":"user","passwd":"blabal"} -/login/ called: {"user":"user","passwd":"passwd"} -/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"} -/submit/ called: {"pkgsubmit":"1","token":"70bd1ee338d6767283b81e3e50c3610b","category":"16"}