Skip to content

Commit 842f29d

Browse files
committed
Frikes
2 parents bdcd078 + 690a232 commit 842f29d

38 files changed

+925
-708
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ Inputs to improvement? [Open an issue](https://github.com/agershun/alasql/issues
99

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

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

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
test/res*
33
node_modules/
44
npm-debug.log
5-
5+
site/

.jshintrc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"passfail" : false, // Stop on first error.
44
"maxerr" : 10000, // Maximum error before stopping.
55
//"maxstatements" : 200, // Set lower as you evolve...
6-
7-
6+
7+
88
// Predefined globals whom JSHint will ignore.
99
"browser" : true, // Standard browser globals e.g. `window`, `document`.
1010
"node" : true,
@@ -13,7 +13,7 @@
1313
"mocha" : true,
1414
"node" : true,
1515
"worker" : true,
16-
16+
1717
"predef" : [ // Custom globals.
1818
"alasql",
1919
"yy",
@@ -26,7 +26,7 @@
2626
"NL",
2727
"ID",
2828
"P",
29-
utils,
29+
"utils",
3030
"n2u",
3131
"LocalFileSystem",
3232
"Meteor",
@@ -47,19 +47,19 @@
4747
"cloneDeep",
4848
"hash"
4949
],
50-
51-
50+
51+
5252
// Development.
5353
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
5454
"devel" : false, // Allow developments statements e.g. `console.log();`.
5555
"evil" :true,
56-
56+
5757
// ECMAScript 5.
5858
"es5" : true, // Allow ECMAScript 5 syntax.
5959
"strict" : false, // Require `use strict` pragma in every file.
6060
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
61-
62-
61+
62+
6363
// The Good Parts.
6464
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
6565
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
@@ -83,8 +83,8 @@
8383
"undef" : true, // Require all non-global variables be declared before they are used.
8484
"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.
8585

86-
87-
86+
87+
8888
// Personal styling preferences.
8989
"newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
9090
"noempty" : true, // Prohibit use of empty blocks.
@@ -98,4 +98,4 @@
9898
"indent" : 1, // Specify indentation spacing
9999
"lastsemic" : true, // Suppresses warnings about missing semicolons when the semicolon is omitted for the last statement in a one-line block
100100
"multistr" : true
101-
}
101+
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ node_js:
1111
- "4"
1212
- "0.12"
1313

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

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
# Changelog
22
* Check https://trello.com/b/qxz65pVi/alasql-roadmap for roadmap
3-
4-
_0.2.6 "Frikes" (22.04.2016)_
5-
* ...
63

7-
0.2.5 "Polychrono" (23.03.2016)
4+
### 0.2.6 "Frikes" (22.04.2016)
5+
6+
* Added: Progress callback
7+
* Change: CLI defaults to pretty print (with option for compressed output as original)
8+
* Update: CLI output is guaranteed to be valid JSON
9+
* Update: Better error message for missing table or column
10+
* Update: Typescript defenition for .promise
11+
* Update: Empty params not needed for async calls
12+
* Fix: Declaring all variables
13+
* Fix: Read XLSX files
14+
* Fix: Selecting a view from localstorage
15+
* Fix: CREATE VIEW for localStorage engine
16+
* Fix: Better use for RequireJS
17+
18+
19+
### 0.2.5 "Polychrono" (23.03.2016)
820
* Added: Promise chain of queries
921
* Fix: Remove leading whitespace from fields when importing csv files
1022
* Fix: Set default option for XLSXML

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# How to Contribute to the AlaSQL project
2+
3+
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!
4+
5+
You can read these materials before to start:
6+
7+
* [How to Contribute to Open-Source](https://guides.github.com/activities/contributing-to-open-source/)
8+
* [How to setup AlaSQL development environment](https://github.com/agershun/alasql/wiki#development)
9+
10+
We have many things to improve:
11+
* [issues and bugs](https://github.com/agershun/alasql/issues)
12+
* [wiki documentation](https://github.com/agershun/alasql/wiki)
13+
* code refactoring and documenting
14+
* import-export functions
15+
* examples
16+
* [alasql.org web site](https://github.com/agershun/alasql-org)
17+
18+
You can choose any of these areas or issues, related to your needs for other projects.
19+
20+
Thank you!

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?
1313

1414
# AlaSQL
1515

16-
<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>
16+
<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>
1717

1818
_( [à 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.
1919

@@ -145,7 +145,7 @@ When you feel you got the grip you can check out the wiki section about [data ma
145145
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)
146146

147147

148-
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.
148+
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.
149149

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

@@ -644,4 +644,7 @@ and other people for useful tools, which make our work much easier.
644644
645645
----
646646
647-
© 2014-2015, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected])
647+
648+
<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>
649+
© 2014-2016, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected])
650+

bin/alasql-cli.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env node
2+
//
3+
// Command line interface for Alasql
4+
// Version: 0.2.2
5+
// Date: 28.07.2015
6+
// (c) 2014-2015, Andrey Gershun & M. Rangel Wulff
7+
//
8+
9+
var alasql = require('alasql');
10+
var path = require('path');
11+
var fs = require('fs');
12+
var yargs = require('yargs')
13+
.demand(1)
14+
.strict()
15+
.usage('AlaSQL command-line utility (version '+alasql.version+')\n\nUsage: $0 [options] [sql] [params]')
16+
17+
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
18+
.example('')
19+
.example('$0 \'value of select 2+?\' 40', 'Outputs 42')
20+
.example('')
21+
.example('$0 \'select count(*) from txt()\' < city.txt', 'Count lines in city.txt')
22+
.example('')
23+
.example('$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'', 'Convert from txt to xlsx')
24+
.example('')
25+
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')
26+
27+
.version('v', 'Echo AlaSQL version', alasql.version)
28+
.alias('v', 'version')
29+
30+
.boolean('m')
31+
.describe('m', 'Minify json output')
32+
.alias('m', 'minify')
33+
34+
.describe('f', 'Load SQL from file')
35+
.alias('f', 'file')
36+
.nargs('f', 1)
37+
.normalize('f')
38+
39+
.help('h')
40+
.alias('h', 'help')
41+
42+
.epilog('\nMore information about the library: www.alasql.org')
43+
var argv = yargs.argv;
44+
var sql = '';
45+
var params = [];
46+
47+
48+
if(argv.v) {
49+
console.log(alasql.version);
50+
process.exit(0);
51+
}
52+
53+
if(argv.f) {
54+
if (!fs.existsSync(argv.f)) {
55+
console.log('Error: file not found');
56+
process.exit(1);
57+
}
58+
59+
if (isDirectory(argv.f)) {
60+
console.log('Error: file expected but directory found');
61+
process.exit(1);
62+
}
63+
64+
sql = fs.readFileSync(argv.f, 'utf8').toString();
65+
} else {
66+
sql = argv._.shift() || '';
67+
}
68+
69+
params = argv._;
70+
71+
if(0===sql.trim().length){
72+
yargs.showHelp();
73+
process.exit(1);
74+
}
75+
76+
for(var i=1;i<params.length;i++) {
77+
var a = params[i];
78+
if(a[0] !== '"' && a[0] !== "'") {
79+
if(+a == a){ // jshint ignore:line
80+
params[i] = +a;
81+
}
82+
}
83+
}
84+
85+
alasql.promise(sql,params)
86+
.then(function(res){
87+
if(!alasql.options.stdout){
88+
console.log(formatOutput(res));
89+
}
90+
process.exit(0);
91+
}).catch(function(err){
92+
console.log(formatOutput({error:err}));
93+
process.exit(1);
94+
});
95+
96+
97+
/**
98+
* Is a Directory
99+
*
100+
* @param {String} filePath
101+
* @returns {Boolean}
102+
*/
103+
function isDirectory(filePath){
104+
var isDir = false;
105+
try {
106+
var absolutePath = path.resolve(filePath);
107+
isDir = fs.lstatSync(absolutePath).isDirectory();
108+
} catch (e) {
109+
isDir = e.code === 'ENOENT';
110+
}
111+
return isDir;
112+
}
113+
114+
115+
/**
116+
* Format output
117+
*
118+
* @param {Object} Object to be formatted according to -p flag
119+
* @returns {JSON string}
120+
*/
121+
function formatOutput(obj){
122+
if(argv.m){
123+
return JSON.stringify(obj);
124+
}
125+
return JSON.stringify(obj, null, 2);
126+
}
127+
128+
129+

0 commit comments

Comments
 (0)