-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): 'mslite g model name ..names' now generates model files
- Loading branch information
Showing
5 changed files
with
52 additions
and
1 deletion.
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,10 @@ | ||
module.exports = (cmd, names, options) => { | ||
switch (cmd) { | ||
case 'model': | ||
require('./types/model')(names, options) | ||
break | ||
|
||
default: | ||
break | ||
} | ||
} |
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,22 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const cwd = process.cwd() | ||
|
||
const dest = `${cwd}/src/models/` | ||
const src = path.resolve(__dirname, '..', '..', '..', 'files/model.js') | ||
|
||
module.exports = (names, options) => { | ||
fs.ensureDir(dest).then(() => { | ||
const copyAction = [] | ||
names.forEach((name) => { | ||
copyAction.push(fs.copy(src, `${dest}${name}.js`)) | ||
}) | ||
return copyAction | ||
}).then(copyAction => Promise.all(copyAction).then(() => { | ||
|
||
}).catch(err => console.dir(err)) | ||
).catch(err => { | ||
if (err instanceof Error) throw err | ||
else throw new Error(err) | ||
}) | ||
} |
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,11 @@ | ||
// Define your collection (aka model) | ||
module.exports = (Waterline, config) => Waterline.Collection.extend(Object.assign(config, { | ||
|
||
tableName: 'model_name', | ||
|
||
identity: 'model_name', | ||
|
||
attributes: { | ||
|
||
} | ||
})) |