Permalink
Browse files

extracted repository to new ender-repository lib

  • Loading branch information...
1 parent d0229c9 commit 8657ed9f5060c6add57d8e1d181ae3381eb8bac2 @rvagg rvagg committed Dec 25, 2012
View
@@ -39,8 +39,8 @@
*/
var async = require('async')
+ , repository = require('ender-repository')
, packageUtil = require('./package-util')
- , repository = require('./repository')
, installUtil = require('./install-util')
, DependencyTree = require('./dependency-tree')
View
@@ -34,10 +34,10 @@
*/
var async = require('async')
+ , repository = require('ender-repository')
, util = require('./util')
, mainBuild = require('./main-build')
, argsParse = require('./args-parse')
- , repository = require('./repository')
, mainInfoUtil = require('./main-info-util')
, mainBuildUtil = require('./main-build-util')
View
@@ -30,7 +30,7 @@
* first and also only show 'max' results.
*/
-var repository = require('./repository')
+var repository = require('ender-repository')
, xregexp = require('xregexp')
, searchUtil = require('./main-search-util')
, defaultMax = 8
View
@@ -1,147 +0,0 @@
-/*!
- * ENDER - The open module JavaScript framework
- *
- * Copyright (c) 2011-2012 @ded, @fat, @rvagg and other contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-/******************************************************************************
- * Our only interface with `npm`, all npm interaction must go through here so
- * it's safely abstracted away from the rest of the code. The important parts
- * are the `setup()` and `packup()` methods which must wrap around any call to
- * an npm command. If you don't do a `setup()` then you'll get an error, if
- * you don't do a `packup()` then you'll likely have a hanging-process.
- * These two methods manage npm initialisation and also manage an npm logfile
- * that goes into /tmp/ender_npm_... If `packup()` is called with a falsy
- * first arg then the log file is deleted, otherwise it is left alone for
- * debugging.
- * Note that multiple npm commands can be run between `setup()` and `packup()`,
- * they only need to be done once per app execute.
- */
-
-var npm = require('npm')
- , fs = require('fs')
- , path = require('path')
- , net = require('net')
- , util = require('./util')
- , colors = require('colors')
- , packageUtil = require('./package-util')
- , FilesystemError = require('./errors').FilesystemError
- , RepositorySetupError = require('./errors').RepositorySetupError
- , RepositoryCommandError = require('./errors').RepositoryCommandError
-
- , isSetup
- , sessionFile
- , sessionStream
-
- // This is no longer an async function due to the way that createWriteStream works
- , generateTempFile = function () {
- sessionFile = path.join(util.tmpDir, 'ender_npm_' + process.pid + '.' + (+new Date()))
- return fs.createWriteStream(sessionFile, {flags: 'w', mode: '0644'})
- }
-
- // must be called at the start of an npm session
- , setup = function (callback) {
- if (isSetup) return callback()
-
- try {
- sessionStream = generateTempFile()
- } catch (err) {
- return callback(new FilesystemError(err))
- }
-
- sessionStream.on('error', function(err) {
- callback(new FilesystemError(err))
- })
-
- // streams are the safest way to deal with npm, actual fds are now unreliable
- // and since we have no real way to tell when npm is finished (the callbacks
- // are triggered before it does its own cleanup) the best we can do is a
- // destroySoon() on our stream.
- var config = {
- logstream : sessionStream
- , outfd : sessionStream
- }
-
- npm.load(config, function (err) {
- if (!err) isSetup = true
- callback.apply(null, arguments)
- })
- }
-
- // must be called at the end of an npm session
- , packup = function (wasError, callback) { // callback is optional here, usually not required
- if (!isSetup) return callback && callback()
-
- isSetup = false
-
- // gently close so we don't upset npm
- sessionStream.on('close', function () {
- if (!wasError) return fs.unlink(sessionFile, callback)
- callback && callback()
- sessionStream = null
- })
-
- sessionStream.destroySoon()
- }
-
- // wrap around npm.commands.search()
- , search = function (keywords, callback) {
- if (!isSetup) throw new RepositorySetupError('repository.setup() has not been called')
-
- npm.commands.search(keywords, function (err) {
- if (err) return callback(new RepositoryCommandError(err))
- callback.apply(null, arguments)
- })
- }
-
- // wrap around npm.commands.uninstall()
- , uninstall = function (packages, callback) {
- if (!isSetup) throw new RepositorySetupError('repository.setup() has not been called')
-
- npm.commands.uninstall(packages, function (err) {
- if (err) return callback(new RepositoryCommandError(err))
- callback.apply(null, arguments)
- })
- }
-
- // simple wraper around npm.commands.install()
- , install = function (packages, callback) {
- if (!isSetup) throw new RepositorySetupError('repository.setup() has not been called')
-
- npm.commands.install(packages, function (err, installed, tree, pretty) {
- if (err) return callback(new RepositoryCommandError(err))
-
- callback(null, {
- tree : tree
- , pretty : pretty
- , installed : installed
- })
- })
- }
-
-module.exports = {
- setup : setup
- , packup : packup
- , search : search
- , install : install
- , uninstall : uninstall
-}
View
@@ -1,7 +1,7 @@
{
"name": "ender"
, "description": "Open Module JavaScript Framework"
- , "version": "0.9.6-dev"
+ , "version": "0.9.7-dev"
, "authors": [
"Jacob Thornton @fat <jacob@twitter.com> (https://github.com/fat)"
, "Dustin Diaz @ded <dustin@obvious.com> (https://github.com/ded)"
@@ -10,31 +10,27 @@
, "keywords": [ "ender", "modules", "builder", "framework", "packager" ]
, "main": "./lib/main.js"
, "homepage": "https://ender.no.de"
- , "engines": {
- "node" : ">= 0.7.12"
- }
, "dependencies": {
- "npm" : ">= 1.1.30"
- , "colors" : ">= 0.6.0"
- , "uglify-js" : ">= 1.3.0"
- , "async" : ">= 0.1.22"
- , "hogan.js" : ">= 2.0.0"
- , "archy" : ">= 0.0.2"
- , "colors-tmpl" : ">= 0.0.3"
- , "xregexp" : ">= 2.0.0"
- , "errno" : ">= 0.0.1"
- , "glob" : ">= 3.1.10"
- , "ender-minify" : ">= 0.0.3"
+ "ender-repository" : "~0.0.1"
+ , "ender-minify" : "~0.0.4"
+ , "colors" : "~0.6.0"
+ , "async" : "~0.1.22"
+ , "hogan.js" : "~2.0.0"
+ , "archy" : "~0.0.2"
+ , "colors-tmpl" : "~0.1.0"
+ , "xregexp" : "~2.0.0"
+ , "errno" : "~0.0.3"
+ , "glob" : "~3.1.14"
}
, "directories": {
"lib" : "./lib"
, "bin" : "./bin"
}
, "devDependencies": {
- "buster" : ">= 0.5.4"
- , "rimraf" : ">= 2.0.2"
- , "jshint" : ">= 0.7.1"
- , "mkfiletree" : ">= 0.0.0"
+ "buster" : "~0.6.12"
+ , "rimraf" : "~2.1.1"
+ , "jshint" : "~0.9.1"
+ , "mkfiletree" : "~0.0.0"
}
, "bin": {
"ender" : "./bin/ender"
@@ -24,8 +24,8 @@
var testCase = require('buster').testCase
+ , repository = require('ender-repository')
, install = require('../../lib/install')
- , repository = require('../../lib/repository')
, util = require('../../lib/util')
, installUtil = require('../../lib/install-util')
, DependencyTree = require('../../lib/dependency-tree')
@@ -24,11 +24,11 @@
var testCase = require('buster').testCase
+ , repository = require('ender-repository')
, util = require('../../lib/util')
, mainBuild = require('../../lib/main-build')
, mainInfoUtil = require('../../lib/main-info-util')
, mainRemove = require('../../lib/main-remove')
- , repository = require('../../lib/repository')
testCase('Remove', {
'test basic remove': function (done) {
@@ -24,8 +24,8 @@
var testCase = require('buster').testCase
+ , repository = require('ender-repository')
, searchUtil = require('../../lib/main-search-util')
- , repository = require('../../lib/repository')
, search = require('../../lib/main-search')
, searchOutput = require('../../lib/output/main-search-output').create()
Oops, something went wrong.

0 comments on commit 8657ed9

Please sign in to comment.