This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
192 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
logs/ndm-test.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
exports.Installer = require('./installer'); | ||
exports.Service = require('./service'); | ||
exports.Config = require('./config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var _ = require('lodash'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
ejs = require('ejs'); | ||
|
||
function Service(opts) { | ||
_.extend(this, | ||
{}, | ||
require('./config')(), | ||
opts | ||
); | ||
|
||
// run the script within its ndm | ||
// node_modules directory. | ||
this.workingDirectory = path.resolve( | ||
this.baseWorkingDirectory, | ||
'./node_modules', | ||
this.module | ||
) | ||
|
||
this.logFile = path.resolve( | ||
this.baseWorkingDirectory, | ||
'./logs', | ||
this.name + ".log" | ||
) | ||
}; | ||
|
||
Service.prototype.generateScript = function() { | ||
fs.writeFileSync( | ||
path.resolve(this.daemonsDirectory, this.name + this.daemonExtension), | ||
ejs.render(fs.readFileSync(this.template).toString(), this), | ||
{ | ||
mode: 0755 | ||
} | ||
); | ||
}; | ||
|
||
exports.allServices = function() { | ||
var services = [], | ||
serviceJson = JSON.parse(fs.readFileSync( | ||
path.resolve('./service.json') | ||
)); | ||
|
||
Object.keys(serviceJson).forEach(function(serviceName) { | ||
var serviceConfig = serviceJson[serviceName]; | ||
|
||
// apply sane defaults as we create | ||
// the services. | ||
var service = new Service(_.extend( | ||
{ | ||
module: serviceName, | ||
name: serviceName | ||
}, | ||
serviceConfig | ||
)); | ||
|
||
// populate the global env on the service. | ||
service.env = _.extend(serviceConfig.env, serviceJson.env); | ||
|
||
services.push(service); | ||
}); | ||
|
||
return services; | ||
} |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"ndm-test": { | ||
"description": "thumbnailing service", | ||
"env": { | ||
"PORT": 8000, | ||
"USER": "bcoe" | ||
} | ||
}, | ||
"ndm-test2": { | ||
"module": "ndm-test", | ||
"env": { | ||
"PORT": 8080 | ||
} | ||
}, | ||
"env": { | ||
"APP": "my-test-app" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
/** | ||
Handles parsing CLI arguments, walks a user through setting | ||
up their environment. | ||
*/ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
/** | ||
Handles installing npm dependencies, and populating | ||
default values in ndm.json. | ||
*/ | ||
var Lab = require('lab'); | ||
|
||
// See prepare-tests.js, for follower feed ordering. | ||
Lab.experiment('installer', function() { | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var Lab = require('lab'), | ||
path = require('path'), | ||
Service = require('../lib').Service, | ||
Config = require('../lib').Config, | ||
fs = require('fs'); | ||
|
||
Lab.experiment('service', function() { | ||
|
||
Lab.experiment('allServices', function(done) { | ||
Lab.it('should default module to service name, if no module stanza provided', function(done) { | ||
var service = Service.allServices()[0]; | ||
Lab.expect(service.module).to.eql(service.name); | ||
done(); | ||
}); | ||
|
||
Lab.it('should allow npm-module to be overridden', function(done) { | ||
var service = Service.allServices()[1]; | ||
Lab.expect(service.module).to.eql('ndm-test'); | ||
done(); | ||
}); | ||
|
||
Lab.it('should load global environment stanza if present', function(done) { | ||
var service = Service.allServices()[1]; | ||
Lab.expect(service.env.APP).to.eql('my-test-app'); | ||
done(); | ||
}); | ||
}); | ||
|
||
Lab.experiment('generateScript', function() { | ||
Lab.experiment('darwin', function() { | ||
Lab.it('should genterate a script with the appropriate variables populated', function(done) { | ||
// test generating a script for darwin. | ||
Config({ | ||
platform: 'darwin', | ||
daemonsDirectory: './' | ||
}); | ||
|
||
var service = Service.allServices()[0]; | ||
service.generateScript(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |