+15
| #!/usr/bin/env node | ||
| var Engine = require('../src/Engine'), | ||
| updateNotifier = require('update-notifier'), | ||
| notifier, | ||
| birdy; | ||
| // Checks for available update | ||
| notifier = updateNotifier({ | ||
| packagePath: '../package' | ||
| }); | ||
| if (notifier.update) notifier.notify(); | ||
| birdy = new Engine(process.argv); | ||
| birdy.read(); |
| # birdy-cli | ||
| Installation: | ||
| * ``npm install -g birdy-cli`` | ||
| If you need help, just type ``birdy`` and all commands available will show. |
| 'use strict'; | ||
| var fs = require('fs') | ||
| function Generator() { | ||
| this._controllersDir = './birdy/Controllers/' | ||
| this._viewsDir = './views/' | ||
| }; | ||
| Generator.prototype.create = function(arg, callback) { | ||
| var parent = this; | ||
| fs.readFile(__dirname + '/../templates/controller.tmpl', 'utf8', function (err,data) { | ||
| if (err && err.code) return callback(err.code) | ||
| var tempController = data.replace(/{{name}}/g, arg.toLowerCase()).replace(/{{Name}}/g, arg) | ||
| fs.readFile(__dirname + '/../templates/view.tmpl', 'utf8', function (err,data) { | ||
| if (err && err.code) return callback(err.code) | ||
| var tempView = data.replace(/{{name}}/g, arg.toLowerCase()) | ||
| fs.writeFile(parent._controllersDir + arg + 'Controller.js', tempController, function (err) { | ||
| if(err && err.code) return callback(err.code) | ||
| fs.writeFile(parent._viewsDir + arg.toLowerCase() + '.html', tempView, function (err) { | ||
| if(err && err.code) return callback(err.code) | ||
| console.log('You have successfully created the controller: %s'.green, arg) | ||
| }) | ||
| }) | ||
| }) | ||
| }) | ||
| } | ||
| Generator.prototype.delete = function(arg, callback) { | ||
| var parent = this, | ||
| controllerPath = this._controllersDir + arg + 'Controller.js', | ||
| viewPath = this._controllersDir + arg.toLowerCase() + '.html' | ||
| fs.readFile(controllerPath, 'utf8', function (err) { | ||
| if(err && err.code) return callback(err.code) | ||
| fs.readFile(viewPath, 'utf8', function (err) { | ||
| if(err && err.code) return callback(err.code) | ||
| fs.unlinkSync(controllerPath) | ||
| fs.unlinkSync(viewPath) | ||
| console.log('You have successfully removed the controller: %s'.green, arg) | ||
| }) | ||
| }) | ||
| } | ||
| Generator.prototype.getCommands = function() { | ||
| return { | ||
| 'create <name>': { | ||
| description: 'Create a controller' | ||
| }, | ||
| 'delete <name>': { | ||
| description: 'Delete a controller' | ||
| } | ||
| } | ||
| } | ||
| module.exports = Generator |
| 'use strict'; | ||
| var fs = require('fs') | ||
| function Generator() { | ||
| this._servicesDir = './birdy/Services/' | ||
| }; | ||
| Generator.prototype.create = function(arg, callback) { | ||
| var parent = this; | ||
| fs.readFile(__dirname + '/../templates/service.tmpl', 'utf8', function (err,data) { | ||
| if (err && err.code) return callback(err.code) | ||
| var tempService = data.replace(/{{name}}/g, arg.toLowerCase()).replace(/{{Name}}/g, arg) | ||
| fs.writeFile(parent._servicesDir + arg + 'Service.js', tempService, function (err) { | ||
| if(err && err.code) return callback(err.code) | ||
| console.log('Has creado correctamente el servicio: %s', arg) | ||
| }) | ||
| }) | ||
| } | ||
| Generator.prototype.getCommands = function() { | ||
| return { | ||
| 'create <name>': { | ||
| description: 'Create a service' | ||
| } | ||
| } | ||
| } | ||
| module.exports = Generator |
+127
| 'use strict'; | ||
| var fs = require('fs'), | ||
| mout = require('mout'), | ||
| colors = require('colors'), | ||
| os = require('os') | ||
| /* | ||
| * Constructor | ||
| */ | ||
| function Birdy(args) { | ||
| this._commands = [] | ||
| this._components = [] | ||
| this._componentsDir = __dirname + '/components/' | ||
| this._loadComponents() | ||
| this._args = args | ||
| } | ||
| Birdy.prototype.read = function() { | ||
| var component = this._args[2], | ||
| task = this._args[3], | ||
| parent = this | ||
| // If not defined exit with the usage information | ||
| if (!component || !task) this.exit() | ||
| if(this._checkIfExists(component, task)) { | ||
| var argument = this._args[4].charAt(0).toUpperCase() + this._args[4].slice(1) | ||
| this._components[component][task](argument, function(res) { | ||
| if(res) | ||
| { | ||
| parent._report('Ha sucedido un error, recuerda que debes estar en el directorio principal.') | ||
| } else parent._report('Ha sucedido un error desconocido.') | ||
| }) | ||
| } else this.exit() | ||
| } | ||
| Birdy.prototype._loadComponents = function() { | ||
| var files = fs.readdirSync(this._componentsDir), | ||
| file, | ||
| componentName; | ||
| // for each file in components | ||
| for (file in files) { | ||
| componentName = files[file].split('.', 1)[0]; | ||
| this._loadComponent(componentName.toLowerCase(), this._componentsDir + componentName) | ||
| } | ||
| } | ||
| Birdy.prototype._loadComponent = function(name, dir) { | ||
| var Component = require(dir), | ||
| commands, | ||
| command, | ||
| commandName, | ||
| parameters, | ||
| componentName = name.toLowerCase() | ||
| this._components[componentName] = new Component(this) | ||
| // Prepare the object | ||
| this._commands[componentName] = {}; | ||
| // commands of the component | ||
| commands = this._components[componentName].getCommands() | ||
| for (command in commands) { | ||
| commandName = command.split(/\s+/)[0] | ||
| parameters = command.match(/<[^>]+>/g) | ||
| this._commands[componentName][commandName] = { | ||
| name: command, | ||
| description: commands[command].description, | ||
| parameters: mout.lang.isArray(parameters) ? parameters.length : 0 | ||
| } | ||
| } | ||
| } | ||
| Birdy.prototype._checkIfExists = function(component, task) { | ||
| if (this._components[component] && this._commands[component][task]) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| Birdy.prototype.exit = function() { | ||
| var component, | ||
| commands, | ||
| command, | ||
| output = [ | ||
| '\nUsage: '.cyan + this._getEnvironmentName() + ' <component> <action> [parameters]\n' | ||
| ] | ||
| for (component in this._components) { | ||
| commands = this._commands[component] | ||
| // If no commands, skip component | ||
| if (!mout.object.size(commands)) continue | ||
| output.push(component.green) | ||
| for (command in commands) { | ||
| output.push(' ' + commands[command].name.grey + ' ' + commands[command].description) | ||
| output.push('') | ||
| } | ||
| } | ||
| this._output(output) | ||
| process.exit() | ||
| } | ||
| Birdy.prototype._report = function(str) { | ||
| if(mout.lang.isString(str)) console.log(str.red) | ||
| } | ||
| Birdy.prototype._output = function(output) { | ||
| for (var line in output) console.log(output[line]) | ||
| } | ||
| Birdy.prototype._getEnvironmentName = function() { | ||
| var script = this._args[1].split(os.platform().match(/win32/) ? (/\\/) : (/\//)); | ||
| return script[script.length - 1]; | ||
| } | ||
| module.exports = Birdy |
| var d = require('dejavu'), | ||
| Controller = require('../Controller'); | ||
| var {{Name}}Controller = d.Class.declare({ | ||
| $name: '{{Name}}Controller', | ||
| $extends: Controller, | ||
| index: function(req, res) { | ||
| // Service call examples | ||
| //this._services['logger'].log('Example using logger service'); | ||
| //this._services['emitter'].emit('hungry'); | ||
| res.render('{{name}}.html'); | ||
| } | ||
| }); | ||
| module.exports = {{Name}}Controller |
| var d = require('dejavu') | ||
| var {{Name}} = d.Class.declare({ | ||
| $name: '{{Name}}Service', | ||
| initialize: function() { | ||
| //Something here... | ||
| } | ||
| }); | ||
| module.exports = {{Name}} |
| {% extends "layout.html" %} | ||
| {% set page = "{{name}}" %} | ||
| {% block title %}Welcome to birdy!{% endblock %} | ||
| {% block yield %} | ||
| <h1>Welcome to {{name}}#index</h1> | ||
| <p>This is the example content for views/{{name}}.html</p> | ||
| {% endblock %} |
+18
-11
| { | ||
| "name": "birdy-cli", | ||
| "version": "0.1.2", | ||
| "description": "Birdy command line tool", | ||
| "main": "birdy.js", | ||
| "version": "0.1.5", | ||
| "description": "Birdy server command line tool", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/underc0de/birdy-cli.git" | ||
| "url": "https://github.com/underc0de/birdy-cli" | ||
| }, | ||
| "keywords": [ | ||
| "birdy", | ||
| "cli" | ||
| "cli", | ||
| "server", | ||
| "command", | ||
| "line", | ||
| "tool" | ||
| ], | ||
@@ -20,10 +23,14 @@ "author": "Iegor Azuaga", | ||
| "homepage": "https://github.com/underc0de/birdy-cli", | ||
| "bin": { | ||
| "birdy": "bin/birdy.js" | ||
| }, | ||
| "engines": { | ||
| "node": ">= 0.8.0" | ||
| }, | ||
| "preferGlobal": true, | ||
| "dependencies": { | ||
| "update-notifier": "~0.1.2", | ||
| "colors": "~0.6.0", | ||
| "dot": "~1.0.0", | ||
| "nopt": "~2.0.0", | ||
| "update-notifier": "~0.1.2", | ||
| "dejavu": "~0.4.4" | ||
| }, | ||
| "preferGlobal": true | ||
| "mout": "~0.6.0" | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
-18
| var Birdy = require('../src/Birdy'), | ||
| updateNotifier = require('update-notifier'), | ||
| notifier, | ||
| birdy; | ||
| // Check for updates | ||
| var notifier = updateNotifier({ | ||
| packagePath: '../package' | ||
| }); | ||
| if (notifier.update) notifier.notify(); | ||
| // Debug | ||
| console.log('It works!'); | ||
| // Initialize | ||
| birdy = new Birdy(process.argv); | ||
| birdy.parse(); |
-43
| 'use strict'; | ||
| var dejavu = require('dejavu'), | ||
| fs = require('fs'), | ||
| colors = require('colors'), | ||
| nopt = require('nopt'); | ||
| // Theme setup | ||
| colors.setTheme({ | ||
| input: 'grey', | ||
| info: 'green', | ||
| data: 'grey', | ||
| help: 'cyan', | ||
| warn: 'yellow', | ||
| debug: 'blue', | ||
| error: 'red' | ||
| }); | ||
| var Birdy = dejavu.Class.declare({ | ||
| $name: 'Birdy', | ||
| _componentsFolder: __dirname + '/components/', | ||
| _args: null, | ||
| _info: ['Info output'], | ||
| initialize: function(args) { | ||
| this._loadComponents(); | ||
| this._args = args; | ||
| }, | ||
| parse: function() { | ||
| this._log(this._info); | ||
| }, | ||
| _loadComponents: function() { | ||
| }, | ||
| _log: function(stringArr) { | ||
| for (var line in stringArr) console.log(stringArr[line]); | ||
| } | ||
| }); | ||
| module.exports = Birdy; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7884
337.51%3
-40%10
100%181
293.48%1
-50%6
Infinity%4
300%1
Infinity%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed