Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: apiaxle/module-smith
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: nodejitsu/module-smith
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
Loading
Showing with 558 additions and 226 deletions.
  1. +19 −0 LICENSE
  2. +68 −42 README.md
  3. +30 −23 example/bcrypt.js
  4. +425 −149 lib/builder.js
  5. +16 −12 package.json
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (C) 2011 Charlie Robbins, Bradley Meck and the 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.
110 changes: 68 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# Module Smith

A simple extensible NPM build bot.
![](https://i.cloudup.com/YjjosQY66o-3000x3000.png)

A simple extensible `npm` build bot that works on Linux, SmartOS, and Windows.

## Example

Given a small script for building a specific module:

```javascript
var tmp = require('tmp');
var assert = require('assert');
``` js
var assert = require('assert'),
tmp = require('tmp'),
ModuleSmith = require('module-smith');

var ModuleSmith = require('module-smith');
var buildbot = ModuleSmith.createModuleSmith();

//
// Grab a temporary directory to build in
//
tmp.dir(function (err, tmpdir) {
assert.ifError(err);
//
// Start our build
//
buildbot.build({
repository: {
type: 'git',
url: 'git@github.com:bmeck/bcrypt-example.git'
},
directories: {
rootdir: tmpdir
}
}, function (err, stream) {
assert.ifError(err);
//
// Pipe out the data to stdio
//
stream.pipe(process.stdout);
});
assert.ifError(err);
//
// Start our build
//
buildbot.build({
repository: {
type: 'git',
url: 'git@github.com:bmeck/bcrypt-example.git'
},
directories: {
root: tmpdir
}
}, function (err, stream) {
assert.ifError(err);
//
// Pipe out the data to stdio
//
stream.pipe(process.stdout);
});
});
```

@@ -49,22 +51,43 @@ node build.js > built.tgz

### ModuleSmith.createModuleSmith(options)

#### String[] options.versions

List of the versions supported with absolute version numbers like ie. '0.8.12'

#### BuildDescription options.defaults

The defaults for a build run using this ModuleSmith.
* `Array` _options.versions_: List of the versions supported with absolute version numbers like ie. '0.8.12'
* `BuildDescription` _options.defaults_: The defaults for a build run using this ModuleSmith.

### ModuleSmith.build(buildDescription, callback(err, tgzStream))

Runs a build

### BuildDescription

``` js
{
uid: 'nobody',
gid: 'nobody',
command: 'install',
env: {
'npm_config_registry': 'http://registry.npmjs.org',
'npm_config_nodedir': path.join(process.env.HOME, '.node-gyp')
},
repository: {
type: 'git',
url: 'git@github.com:bmeck/bcrypt-example.git'
},
directories: {
root: '/path/to/build/output/root'
}
}
```

A build description enumerates a number of values

#### BuildDescription.command

The `npm` command that you wish to execute for the build. Can be:

* `install`: Installs all module dependencies.
* `build`: Runs `node-gyp` to build any binary dependencies.

#### BuildDescription.env

Optional environmental variables to spawn `npm` with.
@@ -82,7 +105,7 @@ Optional user to spawn `npm` as.

Optional group to spawn `npm` under.

#### BuildDescription.packageJSON
#### BuildDescription.package

Optional package.json overrides.
Can be extended easily from the repository during `npm.configure`.
@@ -91,29 +114,32 @@ Some interesting fields are:

* engines.node - version to spawn as


#### BuildDescription.repository

A `checkout` npm module repository to download wbefore building.
A `checkout` npm module repository to download before building.

#### BuildDescription.directories.rootdir
#### BuildDescription.directories.root

The place to use for creating the build.

## Understudy Actions

Extensibility for complex actions can be done via Understudy based actions, only `before` actions are supported.

### build.configure (buildDescription)

### npm.configure (buildDescription)

### npm.package (buildDescription, packageJSON)
* build.configure (buildDescription)
* npm.configure (buildDescription)
* npm.package (buildDescription, package)
* build.output (buildDescription, tgzStream)

## Events

Notifications of actions that have been completed are available via the EventEmitter APIs.

### npm.spawned (buildDescription, npmProcess)
* npm.spawned (buildDescription, npmProcess)

<hr>
#### Copyright (C) Charlie Robbins, Bradley Meck and the Contributors
#### Authors: [Bradley Meck](https://github.com/bmeck), [Charlie Robbins](https://github.com/indexzero)
#### License: MIT

### build.output (buildDescription, tgzStream)
_Hammer Icon by Edward Boatman from The Noun Project_
53 changes: 30 additions & 23 deletions example/bcrypt.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
var tmp = require('tmp');
var assert = require('assert');
/*
* bcrypt.js: Example that builds bcrypt.
*
* (C) 2012 Charlie Robbins, Bradley Meck and the Contributors
*
*/

var ModuleSmith = require('../');
var buildbot = ModuleSmith.createModuleSmith();
var assert = require('assert'),
tmp = require('tmp'),
moduleSmith = require('../');

var buildbot = moduleSmith.createModuleSmith();

//
// Grab a temporary directory to build in
//
tmp.dir(function (err, tmpdir) {
assert.ifError(err);
//
// Start our build
//
buildbot.build({
repository: {
type: 'git',
url: 'git@github.com:bmeck/bcrypt-example.git'
},
directories: {
rootdir: tmpdir
}
}, function (err, stream) {
assert.ifError(err);
//
// Pipe out the data to stdio
//
stream.pipe(process.stdout);
});
assert.ifError(err);
//
// Start our build
//
buildbot.build({
repository: {
type: 'git',
url: 'git@github.com:bmeck/bcrypt-example.git'
},
directories: {
root: tmpdir
}
}, function (err, stream) {
assert.ifError(err);
//
// Pipe out the data to stdio
//
stream.pipe(process.stdout);
});
});
Loading