Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
node_modules/
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
coffee -o lib -c src

clean:
rm lib/*.js
1 change: 0 additions & 1 deletion bin/aur-info
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

require ('coffee-script');
var aur = require('../lib/aur');

var argv = require('optimist')
Expand Down
1 change: 0 additions & 1 deletion bin/aur-publish
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

require ('coffee-script');
var aur = require('../lib/aur');

var argv = require('optimist')
Expand Down
164 changes: 164 additions & 0 deletions lib/aur.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lib/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Filirom1 <filirom1@gmail.com>",
"name": "aur",
"description": "Archlinux AUR cli",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/Filirom1/nodejs-aur",
"repository": {
"type": "git",
Expand All @@ -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"
Expand All @@ -24,16 +24,16 @@
"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": {
"test": "./node_modules/.bin/vows test/* --spec"
"test": "./node_modules/.bin/vows test/*.coffee --spec"
}
}
4 changes: 2 additions & 2 deletions lib/aur.coffee → src/aur.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/config.coffee → src/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
10 changes: 6 additions & 4 deletions test/aur.coffee
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -86,7 +87,8 @@ config =
url:
base: "http://localhost:#{port}/"
info: 'rpc.php?type=info&arg='
post: 'pkgsubmit.php'
login: 'login/'
post: 'submit/'

dummyPkg =
Maintainer: 'filirom1'
Expand All @@ -106,15 +108,15 @@ 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
else
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 '<html></html>'
Expand Down