-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/generationtux/cufflink in…
…to OP-266-teardown-command * 'master' of https://github.com/generationtux/cufflink: Move drivers 0.0.26 Added bin 0.0.25 renamed entrypoint 0.0.24 Fixed failing test removed seeded data its working formatting and remove pointless test.js file Added create command
- Loading branch information
Showing
13 changed files
with
81 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
let fs = require('fs'); | ||
let counter = 0; | ||
class CustomerDriver { | ||
|
||
create() { | ||
counter++; | ||
fs.writeFileSync("./customer.txt", `Created Customer Counter: ${counter}`); | ||
return { | ||
"name": "Bob Dole" | ||
}; | ||
} | ||
} | ||
|
||
class CartDriver { | ||
create() { | ||
counter++; | ||
fs.writeFileSync("./cart.txt", `Created Cart Counter: ${counter}`); | ||
return { | ||
"items": ["Pizza"] | ||
} | ||
} | ||
} | ||
|
||
class ItemDriver { | ||
create() { | ||
counter++; | ||
fs.writeFileSync("./item.txt", `Created Item Counter: ${counter}`); | ||
return { | ||
"name": "Pizza", | ||
"price": 1.00 | ||
}; | ||
} | ||
} | ||
|
||
module.exports = { | ||
"ItemDriver": ItemDriver, | ||
"CustomerDriver": CustomerDriver, | ||
"CartDriver": CartDriver | ||
}; |
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
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,39 +1,37 @@ | ||
class DriverLocator | ||
{ | ||
constructor(fs, path) | ||
{ | ||
class DriverLocator { | ||
|
||
constructor(fs, path) { | ||
this.fs = fs; | ||
this.path = path; | ||
} | ||
|
||
|
||
drivers() | ||
{ | ||
if (!this.fs.existsSync(this.path)){ | ||
drivers() { | ||
if (!this.fs.existsSync(this.path)) { | ||
throw Error(this.path + ' path does not exist'); | ||
} | ||
|
||
let driverModules = require(this.path); | ||
let driverNames = Object.keys(driverModules); | ||
let driversList = {}; | ||
driverNames.forEach(function(driverName) { | ||
driverNames.forEach(function (driverName) { | ||
let driverKey = driverName.toLocaleLowerCase(); | ||
if(driverKey.indexOf('driver') < 0) { | ||
if (driverKey.indexOf('driver') < 0) { | ||
return; | ||
} | ||
driverKey = driverKey.replace('driver', ''); | ||
driversList[driverKey] = new driverModules[driverName](); | ||
}); | ||
if(Object.keys(driversList).length <= 0) { | ||
if (Object.keys(driversList).length <= 0) { | ||
throw Error( | ||
'No drivers found in module: ' + | ||
this.path + | ||
" drivers must have 'driver' in name" | ||
); | ||
} | ||
|
||
return driversList; | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports.DriverLocator = DriverLocator; | ||
module.exports = DriverLocator; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
let ObjectLocator = require('./ObjectLocator'); | ||
let DependencyGraph = require('./DependencyGraph'); | ||
let DriverLocator = require('./DriverLocator'); | ||
let CreateCommand = require('./CreateCommand'); | ||
let fs = require('fs'); | ||
let objectName = process.argv[2]; | ||
|
||
let objectLocator = new ObjectLocator(fs,objectName ); | ||
let objects = objectLocator.run(); | ||
|
||
let dependencyGraph = new DependencyGraph(objects); | ||
let driverLocator = new DriverLocator(fs, process.cwd() + "/drivers/"); | ||
let createCommand = new CreateCommand(dependencyGraph,driverLocator,fs); | ||
createCommand.run(); | ||
|
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 |
---|---|---|
|
@@ -16,4 +16,5 @@ program | |
*/ | ||
program | ||
.command('create [dataObject]', 'Generate seed data').alias('c') | ||
.parse(process.argv); | ||
|
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
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 was deleted.
Oops, something went wrong.