Skip to content

Commit

Permalink
Porting code from coffee-script to es6 (#17)
Browse files Browse the repository at this point in the history
* Repo configuration update

* Refactoring to es6 and getting rid of the generator logic

* Switching from dist/ to lib/

* Adding basic integration tests to verify js and coffee-script configs from the main module

* Removing unneeded plugin

* Updating coveralls config

* Updating coveralls package version

* Trying coveralls config to see if it resolves coveralls issue

* Disabling coveralls while I figure out why it's not syncing properly

* Updating the readme

* Updating version for rc

* Adding change log

* Updating package configuration for testing

* Switching to eslint-config-opentable lint configuration
* Adding istanbul config to fix minor coverage issue

* Published version 1.0.0-rc.2

* Allowing the src and test directories into the package

* Disabling coveralls

* Removing `next` tag

* Resetting to version `0.1.2`, that last public version and removing the next tag.

* Using node 4 alias
  • Loading branch information
acolchado authored Nov 5, 2016
1 parent b37296f commit f8f0fa1
Show file tree
Hide file tree
Showing 58 changed files with 676 additions and 394 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": ["es2015-loose"],
"plugins": ["add-module-exports"],
"sourceMaps": "both",
"retainLines": "true"
}
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-ci
repo_token: KmF9mrkUzNxpeEFy9UZpa6i1zLgz6xgmF
13 changes: 0 additions & 13 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
indent_size = 2

[nodemon.json]
insert_final_newline = false

Expand All @@ -20,15 +17,5 @@ insert_final_newline = false
[Makefile]
indent_style = tab

[*.{js,json,coffee,less,sass,scss,css,rb}]
indent_size = 2

[node_modules/**.js]
codepaint = false

[node_modules/**.coffee]
codepaint = false

[test/generated/**.js]
trim_trailing_whitespace = false
insert_final_newline = false
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
lib/
coverage/*
test/fixtures/**/*.js
test/generated/*.js
test/generated/**/*.js
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "opentable",
"env": {
"node": true
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
node_modules/
bower_components/
/coverage
/dist
/lib
.DS_Store*
2 changes: 2 additions & 0 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
instrumentation:
root: src
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.eslintrc
.eslintignore

/.editorconfig
/.babelrc
/.travis.yml
/.npmignore

/coverage
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js

node_js:
- "0.10"
- "0.11"
- "0.12"
- "4.2"
- "5"
after_success:
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'
- '0.10'
- '0.11'
- '0.12'
- '4'
- '5'
- '6'

script: npm run build-and-test
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<a name="1.0.0"></a>
# 1.0.0 (2016-07-17)


### Bug Fixes

-

### Features

* Switching from coffee-script to ES2015. Includes a minor refactor which doesn't change the implementation.
* Adding better integration tests.

### BREAKING CHANGES

* SpurConfigGenerator is no longer a part of the project. It wasn't used so it was removed.
109 changes: 65 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,94 +42,108 @@ $ npm install spur-config --save

### Configuration files

#### `src/config/default.coffee`
#### `src/config/default.js`

```coffeescript
module.exports = ()->
```javascript
module.exports = function() {

@properties {
environment: "default"
return this.properties({
environment: 'default',
port: 8080
}
});

}
```

#### `src/config/shared-deployed.coffee`
#### `src/config/shared-deployed.js`

```coffeescript
module.exports = ()->
```javascript
module.exports = function() {

@properties {
shared:
return this.properties({
shared: {
someProp: 123
}
}
});

}
```

#### `src/config/development.coffee` (default)
#### `src/config/development.js` (default)

```coffeescript
module.exports = ()->
```javascript
module.exports = function() {

@extends "default"
this.extends('default');

@properties {
environment: "default"
}
return this.properties({
environment: 'default'
});

}
```

#### `src/config/production.coffee`
#### `src/config/production.js`

```coffeescript
module.exports = ()->
```javascript
module.exports = function() {

# Extend multiple files
@extends "default", "shared-deployed"
this.extends('default', 'shared-deployed');

@properties {
environment: "production"
return this.properties({
environment: 'production',
port: process.env.PORT or 9000
}
});

}
```

### `Standalone use`

This example shows how to manually load configuration into

```coffeescript
spurConfig = require "spur-config"
```javascript
import spurConfig from 'spur-config';

const configDirectory = path.join(__dirname, "src/config");

# load specific environment file
config = SpurConfig.load path.join(__dirname, "src/config"), "production"
const config = SpurConfig.load(configDirectory, "production");

# loads configuration specified in NODE_ENV environment variable
config = SpurConfig.load path.join(__dirname, "src/config")
const config = SpurConfig.load(configDirectory);
```

### `With spur-ioc auto-registration`

This example loads the configuration into an injector/module and makes it available as the `config` dependency.

#### `src/injector.coffee`
```coffeescript
spur = require "spur-ioc"
spurConfig = require "spur-config"
registerConfig = require "spur-common/registerConfig"
#### `src/injector.js`
```javascript
import spur from 'spur-ioc';
import spurConfig from 'spur-config';
import registerConfig from 'spur-common/registerConfig';

module.exports = ()->
module.exports = function() {

ioc = spur.create("test-application")
const ioc = spur.create('test-application');
const configDirectory = path.join(__dirname, './config');

registerConfig(ioc, path.join(__dirname, "./config"))
registerConfig(ioc, configDirectory);

return ioc
return ioc;
}
```

#### `src/services/TestConfig.coffee`
#### `src/services/TestConfig.js`

```coffeescript
module.exports = (config)->
```javascript
module.exports = function(config) {

console.log(config)
console.log(config);

}
```

# Contributing
Expand All @@ -147,15 +161,22 @@ Please send in pull requests and they will be reviewed in a timely manner. Pleas

The majority of the settings are controlled using an [EditorConfig](.editorconfig) configuration file. To use it [please download a plugin](http://editorconfig.org/#download) for your editor of choice.

In addition we use **[ESLint](http://eslint.org/)** to enforce some of the JavaScript rules. To enable on your editor, please install one of the **[editor plugins](http://eslint.org/docs/user-guide/integrations#editors)**.

If your editor does not have ESLint integration, the test commands below will run them and fail your build.

## All tests should pass

To run the test suite, first install the dependancies, then run `npm test`
Execute the following the install the dependencies, build and test with the following.

```bash
$ npm install
$ npm run build
$ npm test
```

View the `package.json`'s `scripts` section for a list of all the other commands.

# License

[MIT](LICENSE)
2 changes: 0 additions & 2 deletions generator.js

This file was deleted.

2 changes: 0 additions & 2 deletions index.js

This file was deleted.

59 changes: 34 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
{
"name": "spur-config",
"description": "Configuration framework to help manage complex application configurations in Node.js.",
"version": "0.1.1",
"version": "0.1.2",
"main": "lib/SpurConfig",
"jsnext:main": "./src/SpurConfig",
"author": {
"name": "Siavash Etemadieh",
"email": "ssetem@googlemail.com"
"name": "Agustin Colchado",
"email": "agustin@colchado.com"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"contributors": [
{
"name": "Agustin Colchado",
"email": "agustin@colchado.com"
},
{
"name": "Joseph McElroy",
"email": "phoey1@gmail.com"
}
],
"keywords": [
"spur",
"spur-framework",
Expand All @@ -24,7 +19,17 @@
],
"license": "MIT",
"scripts": {
"test": "mocha --opts ./test/mocha.opts ./test/unit/ && istanbul report text-summary lcov"
"build": "babel src -d lib --source-maps",
"dev": "babel --watch src -d lib",
"lint": "eslint .",
"pretest": "npm run lint",
"test-unit": "babel-node --debug node_modules/mocha/bin/_mocha ./test/unit/",
"test-integration": "babel-node --debug node_modules/mocha/bin/_mocha ./test/integration/",
"test": "npm run test-unit && npm run test-integration",
"coverage": "babel-node node_modules/isparta/bin/isparta cover --report text --report html ./node_modules/mocha/bin/_mocha --report lcovonly -- ./test/unit/",
"precoveralls": "npm run build && npm run lint && npm run test-integration",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"build-and-test": "npm run build && npm test"
},
"bugs": {
"url": "https://github.com/opentable/spur-config/issues"
Expand All @@ -34,21 +39,25 @@
"type": "git",
"url": "git://github.com/opentable/spur-config.git"
},
"engines": {
"node": ">= 0.10.0"
},
"dependencies": {
"coffee-script": "1.9.1",
"lodash": "2.4.1",
"require-all": "^1.0.0",
"mkdirp": "^0.5.0"
"coffee-script": "^1.10.0",
"lodash": "^4.13.1",
"mkdirp": "^0.5.1",
"require-all": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.5.0",
"babel-preset-es2015-loose": "^7.0.0",
"chai": "^3.5.0",
"coffee-coverage": "^1.0.1",
"coveralls": "^2.11.6",
"istanbul": "^0.4.2",
"coveralls": "^2.11.11",
"eslint": "^2.4.0",
"eslint-config-opentable": "^4.0.0",
"eslint-plugin-import": "^1.8.1",
"isparta": "^4.0.0",
"mocha": "^2.4.5",
"sinon": "^1.17.3"
"mocha-lcov-reporter": "^1.2.0",
"sinon": "^1.17.4"
}
}
Loading

0 comments on commit f8f0fa1

Please sign in to comment.