Skip to content

Commit

Permalink
Frikes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Apr 22, 2016
2 parents bdcd078 + 690a232 commit 842f29d
Show file tree
Hide file tree
Showing 38 changed files with 925 additions and 708 deletions.
6 changes: 4 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ Inputs to improvement? [Open an issue](https://github.com/agershun/alasql/issues

**All contributions are much welcome and greatly appreciated(!)**

- Clone repo and install dependencies `git clone https://github.com/agershun/alasql/ && cd alasql && npm install`
- Fork the repo here on Github
- Clone your forked repo and install dependencies `git clone https://github.com/MYUSERNAME/alasql/ && cd alasql && npm install`
- Please work with the code from the develop branch `git checkout develop`
- Add a test for the issue: Copy `test/test000.js` and replace `000` with a new number.
- Impelement a test that reflects the issue.
- Run `npm test` to verify only the new test fails
- Implement your contributions in `src/`
- Run `npm test` and verify all tests are OK
- Pull-request to the develop branch
- Commit changes to git and push to your forked repo
- Click "Create Pull-request" when looking at your forked repo on Github

_Please note that `npm test` will compile from `src/` before running tests_

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
test/res*
node_modules/
npm-debug.log

site/
24 changes: 12 additions & 12 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"passfail" : false, // Stop on first error.
"maxerr" : 10000, // Maximum error before stopping.
//"maxstatements" : 200, // Set lower as you evolve...


// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,
Expand All @@ -13,7 +13,7 @@
"mocha" : true,
"node" : true,
"worker" : true,

"predef" : [ // Custom globals.
"alasql",
"yy",
Expand All @@ -26,7 +26,7 @@
"NL",
"ID",
"P",
utils,
"utils",
"n2u",
"LocalFileSystem",
"Meteor",
Expand All @@ -47,19 +47,19 @@
"cloneDeep",
"hash"
],


// Development.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"devel" : false, // Allow developments statements e.g. `console.log();`.
"evil" :true,

// ECMAScript 5.
"es5" : true, // Allow ECMAScript 5 syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').


// The Good Parts.
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
Expand All @@ -83,8 +83,8 @@
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, //This option warns when you define and never use your variables. It is very useful for general code cleanup, especially when used in addition to undef.



// Personal styling preferences.
"newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
Expand All @@ -98,4 +98,4 @@
"indent" : 1, // Specify indentation spacing
"lastsemic" : true, // Suppresses warnings about missing semicolons when the semicolon is omitted for the last statement in a one-line block
"multistr" : true
}
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ node_js:
- "4"
- "0.12"

before_install:
- npm install -g alasql
script: npm run test:only && npm test

20 changes: 16 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Changelog
* Check https://trello.com/b/qxz65pVi/alasql-roadmap for roadmap

_0.2.6 "Frikes" (22.04.2016)_
* ...

0.2.5 "Polychrono" (23.03.2016)
### 0.2.6 "Frikes" (22.04.2016)

* Added: Progress callback
* Change: CLI defaults to pretty print (with option for compressed output as original)
* Update: CLI output is guaranteed to be valid JSON
* Update: Better error message for missing table or column
* Update: Typescript defenition for .promise
* Update: Empty params not needed for async calls
* Fix: Declaring all variables
* Fix: Read XLSX files
* Fix: Selecting a view from localstorage
* Fix: CREATE VIEW for localStorage engine
* Fix: Better use for RequireJS


### 0.2.5 "Polychrono" (23.03.2016)
* Added: Promise chain of queries
* Fix: Remove leading whitespace from fields when importing csv files
* Fix: Set default option for XLSXML
Expand Down
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# How to Contribute to the AlaSQL project

Thank you very much or the your intentions! AlaSQL project still has a lot of thing to be improved, and your help is very appreciated!

You can read these materials before to start:

* [How to Contribute to Open-Source](https://guides.github.com/activities/contributing-to-open-source/)
* [How to setup AlaSQL development environment](https://github.com/agershun/alasql/wiki#development)

We have many things to improve:
* [issues and bugs](https://github.com/agershun/alasql/issues)
* [wiki documentation](https://github.com/agershun/alasql/wiki)
* code refactoring and documenting
* import-export functions
* examples
* [alasql.org web site](https://github.com/agershun/alasql-org)

You can choose any of these areas or issues, related to your needs for other projects.

Thank you!
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?

# AlaSQL

<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/13632161/9fd9cd08-e5e8-11e5-98cc-dca251e7b427.png" align="left" alt="AlaSQL logo" width="82" height="82"/></a>
<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/14003945/d6e56888-f156-11e5-95b9-3035a2538ae8.png" align="left" alt="AlaSQL logo" width="82" height="82"/></a>

_( [à la](http://en.wiktionary.org/wiki/%C3%A0_la) [SQL](http://en.wikipedia.org/wiki/SQL) ) [ælæ ɛskju:ɛl]_ - AlaSQL is an open source SQL database for Javascript with a strong focus on query speed and datasource flexibility for relational data, schemaless data, and graph data. It works in your browser, Node.js, IO.js and Cordova.

Expand Down Expand Up @@ -145,7 +145,7 @@ When you feel you got the grip you can check out the wiki section about [data ma
The project has never received any funding and is based on unpaid voluntary work: [We really (really) love pull requests](https://github.com/agershun/alasql/blob/develop/CONTRIBUTING.md)


AlaSQL project is very young and still in active development phase, therefore it <s>may</s> have [bugs](https://github.com/agershun/alasql/labels/Bug). Please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new). AlaSQL uses [Semantic Versioning](http://semver.org/) so please note that major version is zero (0.y.z) and the API can not be considered 100% stable. Consider this before using the library in production.
AlaSQL project is very young and still in active development phase, therefore it <s>may</s> have [bugs](https://github.com/agershun/alasql/labels/%21%20Bug). Please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new). AlaSQL uses [Semantic Versioning](http://semver.org/) so please note that major version is zero (0.y.z) and the API can not be considered 100% stable. Consider this before using the library in production.

Please checkout the [limitations of the library](https://github.com/agershun/alasql#limitations)

Expand Down Expand Up @@ -644,4 +644,7 @@ and other people for useful tools, which make our work much easier.
----
© 2014-2015, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected])
<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/14003946/d6e5c076-f156-11e5-8238-e62d2a8d20dc.png" align="right" alt="AlaSQL logo" width="82" height="82"/></a>
© 2014-2016, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected])
129 changes: 129 additions & 0 deletions bin/alasql-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env node
//
// Command line interface for Alasql
// Version: 0.2.2
// Date: 28.07.2015
// (c) 2014-2015, Andrey Gershun & M. Rangel Wulff
//

var alasql = require('alasql');
var path = require('path');
var fs = require('fs');
var yargs = require('yargs')
.demand(1)
.strict()
.usage('AlaSQL command-line utility (version '+alasql.version+')\n\nUsage: $0 [options] [sql] [params]')

.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
.example('')
.example('$0 \'value of select 2+?\' 40', 'Outputs 42')
.example('')
.example('$0 \'select count(*) from txt()\' < city.txt', 'Count lines in city.txt')
.example('')
.example('$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'', 'Convert from txt to xlsx')
.example('')
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')

.version('v', 'Echo AlaSQL version', alasql.version)
.alias('v', 'version')

.boolean('m')
.describe('m', 'Minify json output')
.alias('m', 'minify')

.describe('f', 'Load SQL from file')
.alias('f', 'file')
.nargs('f', 1)
.normalize('f')

.help('h')
.alias('h', 'help')

.epilog('\nMore information about the library: www.alasql.org')
var argv = yargs.argv;
var sql = '';
var params = [];


if(argv.v) {
console.log(alasql.version);
process.exit(0);
}

if(argv.f) {
if (!fs.existsSync(argv.f)) {
console.log('Error: file not found');
process.exit(1);
}

if (isDirectory(argv.f)) {
console.log('Error: file expected but directory found');
process.exit(1);
}

sql = fs.readFileSync(argv.f, 'utf8').toString();
} else {
sql = argv._.shift() || '';
}

params = argv._;

if(0===sql.trim().length){
yargs.showHelp();
process.exit(1);
}

for(var i=1;i<params.length;i++) {
var a = params[i];
if(a[0] !== '"' && a[0] !== "'") {
if(+a == a){ // jshint ignore:line
params[i] = +a;
}
}
}

alasql.promise(sql,params)
.then(function(res){
if(!alasql.options.stdout){
console.log(formatOutput(res));
}
process.exit(0);
}).catch(function(err){
console.log(formatOutput({error:err}));
process.exit(1);
});


/**
* Is a Directory
*
* @param {String} filePath
* @returns {Boolean}
*/
function isDirectory(filePath){
var isDir = false;
try {
var absolutePath = path.resolve(filePath);
isDir = fs.lstatSync(absolutePath).isDirectory();
} catch (e) {
isDir = e.code === 'ENOENT';
}
return isDir;
}


/**
* Format output
*
* @param {Object} Object to be formatted according to -p flag
* @returns {JSON string}
*/
function formatOutput(obj){
if(argv.m){
return JSON.stringify(obj);
}
return JSON.stringify(obj, null, 2);
}



Loading

0 comments on commit 842f29d

Please sign in to comment.