Skip to content

Commit 20d6eb8

Browse files
committed
cloned form tgriesser/bookshelf
1 parent 660ecf1 commit 20d6eb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+16079
-1
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["es2015"],
3+
"plugins": [
4+
"syntax-object-rest-spread",
5+
"transform-object-rest-spread",
6+
["transform-runtime", {"polyfill": false}]
7+
]
8+
}

.eslintrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "eslint:recommended",
4+
"env": {
5+
"es6": true,
6+
"node": true
7+
},
8+
"ecmaFeatures": {
9+
"destructuring": true,
10+
"modules": true
11+
},
12+
"rules": {
13+
"no-console": 1,
14+
"no-const-assign": 2,
15+
"no-unused-vars": [1, {"vars": "all", "args": "none"}],
16+
"no-var": 1,
17+
"prefer-const": 1,
18+
"no-trailing-spaces": 1
19+
}
20+
}

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
raw
2+
*.sw?
3+
.DS_Store
4+
node_modules
5+
npm-debug.log
6+
tmp
7+
coverage/
8+
lib/
9+
build/
10+
index.html
11+
docs/
12+
.jsdoc-temp/

.istanbul.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
reporting:
2+
dir: ./coverage

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docs/
2+
index.html

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# .travis.yml
2+
language: node_js
3+
4+
services:
5+
- postgresql
6+
- mysql
7+
8+
sudo: false
9+
10+
node_js:
11+
- '0.10'
12+
- '0.12'
13+
- '4'
14+
- '6'
15+
16+
before_script:
17+
- psql -c 'create database bookshelf_test;' -U postgres
18+
- mysql -e 'create database bookshelf_test;'
19+
20+
notifications:
21+
email: false
22+
23+
matrix:
24+
fast_finish: true

CHANGELOG.md

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bookshelfjs.org

CONTRIBUTING.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
## How to contribute to Bookshelf.js
2+
3+
* Before sending a pull request for a feature or bug fix, be sure to have
4+
[tests](https://github.com/tgriesser/bookshelf/tree/master/test).
5+
6+
* Use the same coding style as the rest of the
7+
[codebase](https://github.com/tgriesser/bookshelf/blob/master/src/bookshelf.js).
8+
9+
* Make changes in the /src directory, running "npm run dev" which will kick off
10+
transpilation from ES6 in the background.
11+
12+
* All pull requests should be made to the `master` branch.
13+
14+
### Development Environment Setup
15+
16+
You'll need to have `git` installed obviously. Begin by forking the [main
17+
repository](https://github.com/tgriesser/bookshelf) and then getting the code from your forked copy:
18+
19+
```sh
20+
$ git clone git@github.com:yourusername/bookshelf.git
21+
```
22+
23+
Afterwards go to the bookshelf directory that was just created and install the dependencies:
24+
25+
```sh
26+
$ npm install
27+
```
28+
29+
At this point the only thing missing are the databases that will be used for running some of the tests of the automated
30+
test suite.
31+
32+
There are two options for setting up this part. The first one is to change some configuration options of the database
33+
servers and the other is to use a config file in case you already have your servers configured and don't want to change
34+
any of their config files. The first two sections below deal with the first option and then there are instructions on
35+
how to use the other option.
36+
37+
#### MySQL
38+
39+
You can install [MySQL](https://www.mysql.com/) easily on most linux distros by using their package manager. With Ubuntu
40+
this should do it:
41+
42+
```sh
43+
$ sudo apt-get install mysql-server mysql-client
44+
```
45+
46+
On OSX you can download a disk image directly from the [MySQL Downloads page](http://dev.mysql.com/downloads/mysql/), or
47+
use one of the popular package managers like [homebrew](http://brew.sh/) or [MacPorts](https://www.macports.org/).
48+
49+
To run the test suite you will need to make sure it is possible to connect as the user `root` without the need for a
50+
password.
51+
52+
It is strongly recommended that you use the command line `mysql` client to access your MySQL instance since there can be
53+
problems connecting as the root user with some graphical clients like `phpMyAdmin`. To check if you can connect as root
54+
without needing a password use the following command:
55+
56+
```sh
57+
$ mysql -u root
58+
```
59+
60+
If you see an error like:
61+
62+
```sh
63+
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
64+
```
65+
66+
that means you can't login as root without a password. If you do know the root user's password just login with the known
67+
password like this:
68+
69+
```sh
70+
$ mysql -u root -p
71+
```
72+
73+
and enter the password when asked. Then just set an empty password for root like so:
74+
75+
```SQL
76+
USE mysql;
77+
UPDATE user SET password = "" WHERE User = "root";
78+
FLUSH PRIVILEGES;
79+
QUIT;
80+
```
81+
82+
Note that you'll probably need to set the password to `NULL` instead of an empty string in MySQL versions 5.5 and older.
83+
The above example should work with versions 5.6 and newer.
84+
85+
If you have forgotten the root password you'll need to take some extra steps to reset it. Take a look at
86+
[this Stack Overflow answer](http://stackoverflow.com/a/7825212/504930) for further details.
87+
88+
#### PostgreSQL
89+
90+
You can install [PostgreSQL](http://www.postgresql.org/) easily on most linux distros by using their package manager.
91+
With Ubuntu this should do it:
92+
93+
```sh
94+
$ sudo apt-get install postgresql postgresql-client
95+
```
96+
97+
On OSX the easiest way is probably by using [PosgresApp](http://postgresapp.com/). It should also be available to
98+
install via [homebrew](http://brew.sh/) or [MacPorts](https://www.macports.org/) if you prefer.
99+
100+
In the case of PostgreSQL the requirement is to be able to connect as the `postgres` user on localhost also without the
101+
need for a password. This can be achieved by editing or adding the following line in the `pg_hba.conf` file:
102+
103+
```
104+
host all all 127.0.0.1/32 trust
105+
```
106+
107+
This file can be found in `/etc/postgresql/9.4/main/` on most linux systems. The `9.4` part could be different depending
108+
on the version that is available in your distro. On OSX the location of this file will depend on the installation method
109+
chosen, but for the recommended PostgresApp install it will be in `/Users/[yourusername]/Library/Application
110+
Support/Postgres/var-9.3/`. Again, the `var-9.3` part may be different depending on the version you installed.
111+
112+
The `trust` in the example above tells the locally running PostgreSQL server to ignore user passwords and always grant
113+
access on clients connecting locally. Do not use this setting in a production environment.
114+
115+
After editing the `pg_hba.conf` file you'll need to restart the PostgreSQL server for the changes to take effect.
116+
117+
#### Using a config file
118+
119+
If you don't want to go to the trouble of performing the changes explained in the previous two sections you can instead
120+
use a config file that tells the test suite about your database setup.
121+
122+
The tests will look for a `BOOKSHELF_TEST` environment variable that points to a `config.js` file with the connection
123+
details for each database server. This file must not be the same database config file you use for any other application,
124+
otherwise you risk data loss in that application.
125+
126+
Example config file:
127+
128+
```javascript
129+
module.exports = {
130+
mysql: {
131+
database: 'bookshelf_test',
132+
user: 'root',
133+
encoding: 'utf8'
134+
},
135+
136+
postgres: {
137+
user: 'myusername',
138+
database: 'bookshelf_test',
139+
password: 'secretpassword',
140+
host: 'localhost',
141+
port: 5432,
142+
charset: 'utf8',
143+
ssl: false
144+
},
145+
146+
sqlite3: {
147+
filename: ':memory:'
148+
}
149+
};
150+
```
151+
152+
This file can be placed anywhere on your system and can have any name that you like, as long as the environment variable
153+
is pointing correctly to it. For convenience you can put it in your home directory and add the following line to your
154+
`.bashrc` or `.zshrc`:
155+
156+
```
157+
export BOOKSHELF_TEST='/home/myusername/.bookshelf_config.js'
158+
```
159+
160+
#### Database creation
161+
162+
After having ensured the test suite can access both database servers just create a new database on each that will be
163+
used exclusively by Bookshelf.js:
164+
165+
```SQL
166+
CREATE DATABASE bookshelf_test;
167+
```
168+
169+
### Running the Tests
170+
171+
The test suite requires that both MySQL and PostgreSQL servers have a database named `bookshelf_test`. See the sections
172+
above for further instructions.
173+
174+
Once you have done that, you can run the tests:
175+
176+
```sh
177+
$ npm test
178+
```
179+
180+
Always make sure all the tests are passing before sending a pull request.

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2014 Tim Griesser
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)