Skip to content

Commit

Permalink
Merge pull request #25 from apiaryio/miiila/decaf
Browse files Browse the repository at this point in the history
Decaffeinate everything
  • Loading branch information
miiila authored Sep 26, 2017
2 parents 03e2b7c + e4e3bf2 commit 5af79b3
Show file tree
Hide file tree
Showing 29 changed files with 868 additions and 831 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; EditorConfig file: http://EditorConfig.org
; Install the "EditorConfig" plugin into your editor to use

root = true

[*]
charset = utf-8
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'extends': 'airbnb',
'env': {
'node': true,
'mocha': true,
},
'rules': {
'no-console': 0,
'import/no-amd': 0,
'import/no-extraneous-dependencies': 0,
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never', // This is not supported in Node without Babel transform
}],
},
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
/npm-debug.log
*.DS_Store
lib/
*.log
!test/fixtures/config.json
config.json
Expand Down
4 changes: 1 addition & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
src
scripts
test
cov.info
README.md
example.coffee
config.json
coffeelint.json
.travis.yml
example.js
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "5"
- "6"
- node
before_script:
Expand All @@ -10,7 +9,7 @@ before_install:
# so 'conventional-changelog-lint' could compare commits and lint them: marionebl/conventional-changelog-lint#7
- "git remote set-branches origin master && git fetch && git checkout master && git checkout -"
after_success:
- "npm run coveralls || true"
# - "npm run coveralls || true"; @fixme: tempory commenting out, until coveralls flow for JS will be solved
- "npm run semantic-release || true"
env:
global:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

# NodeJS supported versions

- 5.x
- 6.x (LTS)

# Pager Duty Overrides Checker
Expand Down
55 changes: 27 additions & 28 deletions bin/pdoverrides
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
#!/usr/bin/env node

var program = require('commander');
var fs = require('fs');
var pjson = require('../package.json');
var config = require('../lib/config');
var fsAccess = require('fs-access');

program
.command('check')
.description('Check PagerDuty Overlaps')
.action(runCheck);
const program = require('commander');
const pjson = require('../package.json');
const config = require('../src/config');
const fsAccess = require('fs-access');
const pd = require('../src/pagerduty');

function runCheck(configFile) {
fsAccess(configFile, function (err) {
fsAccess(configFile, (err) => {
if (err) throw err;
config.setupConfig(configFile, function(err, res){
if (err) {
console.error(err);
config.setupConfig(configFile, (configErr) => {
if (configErr) {
console.error(configErr);
process.exit(1);
}
var pd = require('../lib/pagerduty');
pd.checkSchedulesIds(function(error, res) {
if (error) {
console.error("Check failed with error:", error)
pd.checkSchedulesIds((checkError, res) => {
if (checkError) {
console.error('Check failed with error:', checkError);
process.exit(1);
}
if (!res) {
console.error("Check failed - empty response");
console.error('Check failed - empty response');
process.exit(1);
} else {
console.log("Config schedule IDs passed.");
pd.processSchedulesFromConfig(function(error, msg) {
console.log('Config schedule IDs passed.');
pd.processSchedulesFromConfig((error, msg) => {
if (error) {
console.error("Error while processing schedules from config", error);
process.exit(1)
console.error('Error while processing schedules from config', error);
process.exit(1);
}
console.log(msg);
process.exit(0);
Expand All @@ -42,13 +36,18 @@ function runCheck(configFile) {
});
});
});
};
}

program
.command('check')
.description('Check PagerDuty Overlaps')
.action(runCheck);

program
.version(pjson.version)
.usage('check --config <path/to/config.json>')
.option('-c, --config', 'Path to config.json')
.parse(process.argv);
.version(pjson.version)
.usage('check --config <path/to/config.json>')
.option('-c, --config', 'Path to config.json')
.parse(process.argv);

// default help
if (!program.args.length) program.help();
103 changes: 0 additions & 103 deletions coffeelint.json

This file was deleted.

18 changes: 0 additions & 18 deletions example.coffee

This file was deleted.

20 changes: 20 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const config = require('./src/config');
const pd = require('./src/pagerduty');

const configPath = `${__dirname}/config.json`;

config.setupConfig(configPath, (configErr) => {
if (configErr) { console.error(configErr); }
return pd.checkSchedulesIds((checkSchedulesErr, res) => {
if (checkSchedulesErr) { console.error(checkSchedulesErr); }
if (!res) {
return console.error('Check failed');
}
return pd.processSchedulesFromConfig((err, msg) => {
if (err) {
return console.error(err);
}
return console.log(msg);
});
});
});
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
"name": "pagerduty-overlap-checker",
"version": "0.0.0-semantically-released",
"description": "PagerDuty Overlap Duties Checker",
"main": "lib/",
"main": "src/",
"bin": {
"pdoverrides": "bin/pdoverrides"
},
"scripts": {
"test": "./node_modules/.bin/mocha --compilers \"coffee:coffee-script/register\"",
"integration": "./node_modules/.bin/mocha --compilers \"coffee:coffee-script/register\" --recursive",
"lint": "conventional-changelog-lint --from=master && coffeelint ./src",
"compile": "coffee -b -c -o lib/ src/",
"pretest": "npm run compile",
"prepublish": "npm run compile",
"test": "./node_modules/.bin/mocha",
"lint": "conventional-changelog-lint --from=master && eslint ./src",
"coverage": "./scripts/cov",
"coveralls": "npm run coverage && cat ./cov.info | ./node_modules/coveralls/bin/coveralls.js",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
Expand Down Expand Up @@ -40,11 +36,13 @@
},
"devDependencies": {
"chai": "",
"coffee-coverage": "^0.7.0",
"coffee-script": "1.10.0",
"coffeelint": "^1.9.2",
"conventional-changelog-lint": "^1.1.9",
"coveralls": "~2.11.2",
"eslint": "^4.6.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0",
"mocha": "",
"mocha-lcov-reporter": "1.0.0",
"nock": "7.2.2",
Expand Down
6 changes: 0 additions & 6 deletions scripts/build

This file was deleted.

18 changes: 0 additions & 18 deletions src/config.coffee

This file was deleted.

19 changes: 19 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');
const nconf = require('nconf');

function setupConfig(configPath, cb) {
if (fs.existsSync(configPath)) {
console.log('Loading config from :', configPath);
// Priority order argv before ENV and file as defaults
nconf.argv()
.env()
.file({ file: configPath });
process.env.DEBUG = nconf.get('DEBUG');
return cb();
}
return cb(new Error(`Config does not exist: ${configPath}`));
}

module.exports = {
setupConfig,
};
5 changes: 0 additions & 5 deletions src/index.coffee

This file was deleted.

Loading

0 comments on commit 5af79b3

Please sign in to comment.