Git Product home page Git Product logo

caminte-cli's Introduction

Dependency Status NPM version

CaminteJS CLI

Command line interface for CaminteJS Cross-db ORM

Installation

$ npm install -g caminte-cli

Options

Usage: caminte [options] [name] [fields]

Options:

-h, --help                                output usage information
-V, --version                             output the version number
-i, --init                                create structure and config
-a, --adapter [name]                      database adapter (mysql|redis|etc...)
-m, --model <modelname> [fields]          create data model
-r, --route <routename>                   create data routes
-c, --crud  <crudname>  [fields]          create model and route
-d, --dump  <dumpfile>                    parse sql dump file
-t, --tests                               add tests
-f, --force                               force on non-empty directory
-p, --destination-path <destinationPath>  change destination path
-w, --swagger                             generate swagger.json

Usage with Express

Usage with Express.JS here

Usage with Swagger generated server

Usage with Swagger Server here

Quick Start

The quickest way to get started with caminte is to utilize the executable caminte(1) to create an models and routes as shown below:

Create structure:

$ caminte -i -a mysql

Create model:

$ caminte -m User active:int name email password note:text created:date
# with tests  
$ caminte -t -m User active:int name email password note:text created:date

Create model and routes:

$ caminte -c Post published:bool title content:text created:date
# with tests    
$ caminte -t -c User active:int name email password note:text created:date

Create model and routes from SQL dump:

$ caminte -d dumpfile.sql

Routes

will provide the following routes:

method        route                    action 
------------------------------------------------------------
GET           /:table                  index  
GET           /:table/count            count     
GET           /:table/new              new     
GET           /:table/:id              show       
POST          /:table                  create    
PUT           /:table/:id              update      
DELETE        /:table/:id              destroy 
DELETE        /:table/truncate         truncate

Directory structure

On initialization directories tree generated, like that:

.
| 
|-- models
|   |-- User.js
|   `-- ...
|-- routes
|   |-- users.js
|   `-- ...
|-- test
|   |-- model
|   |   |-- user.js
|   |   `-- ...
|   |-- route
|   |   |-- user.js
|   |   `-- ...
|   |-- unit
|   |   |-- user.js
|   |   `-- ...
|   `-- tests.js
`-- database.js

Create swagger.json file:

$ caminte -w

CaminteJS ORM db adapters:

mysql, sqlite3, postgres, mongodb, redis, neo4j, riak, couchdb, rethinkdb, tingodb, arangodb

Recommend extensions

  • TrinteJS - Javascrpt MVC Framework for Node.JS
  • CaminteJS - Cross-db ORM for NodeJS
  • 2CO - is the module that will provide nodejs adapters for 2checkout API payment gateway.

License

(The MIT License)

Copyright (c) 2014 Alexey Gordeyev <[email protected]>

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.

Resources

Analytics Bitdeli Badge

caminte-cli's People

Contributors

ajmalmsali avatar arbuzov avatar biggora avatar kinok avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

caminte-cli's Issues

Problems with generated model tests

I'm using a mongodb schema.

When I create models with the command caminte -t -m User name:String pass:String email:String and then run the tests, all the assertions found.id.should.equal(id); fail because found.id and id appear to be objects. If I change the assertions to a deep equals like found.id.should.eql(id) they work.

Also, the tests for #find fail unless the test database is manually cleared after every run, because it finds the old records. I'm not sure if that's intended, but it may be nicer to destroyAll before each model test or at least take that into account in the #find test.

Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/caminte-cli/bin/../templates/Model.ejs'

When I'm trying to init my models, I get this error:

fs.js:558
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/caminte-cli/bin/../templates/Model.ejs'
    at Object.fs.openSync (fs.js:558:18)
    at Object.fs.readFileSync (fs.js:468:33)
    at Object.<anonymous> (/usr/local/lib/node_modules/caminte-cli/bin/caminte:60:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:418:7)

Platform: Ubuntu 16.04 amd64, [email protected]

It seems that creation of models from a dump doesn't work

Hello.

Errors while trying to create models and routes from a mysql dump file:

caminte -V: 1.3.1

sql-file: dump.sql

CREATE TABLE IF NOT EXISTS platforms_locations (
id int(11) NOT NULL AUTO_INCREMENT,
platform_id int(11) NOT NULL,
parent_id int(11) NOT NULL,
external_id varchar(255) NOT NULL,
name varchar(255) NOT NULL,
is_active tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (id),
KEY FK_platforms_locations_platforms (platform_id),
CONSTRAINT FK_platforms_locations_platforms FOREIGN KEY (platform_id) REFERENCES platforms (id) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=384 DEFAULT CHARSET=utf8;

caminte -d ./dump.sql

produces errors like (I've added error printing in 'caminte' file):

[ { modelName: 'PlatformsLocations',
tableName: 'platforms_locations',
version: '0.0.1',
created: '2019-02-12T00:32:42.280Z',
fields: [ [Object], [Object], [Object], [Object], [Object] ],
indexes: [ [Object] ],
pkeys: [] } ]
aborting, dump file not found: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:129:9)
at Object.writeFile (fs.js:1159:14)
at write (C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\bin\caminte:745:8)
at C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\bin\caminte:118:21
at C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\lib\sqlparser.js:119:17
at Array.forEach ()
at Object.renderFields (C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\lib\sqlparser.js:93:16)
at C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\bin\caminte:95:27
at Array.forEach ()
at Object. (C:\Users\Dell\AppData\Roaming\nvm\v10.14.2\node_modules\caminte-cli\bin\caminte:94:21)

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.