Skip to content

Commit

Permalink
Modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Jul 22, 2016
1 parent 17741a5 commit c7a67c1
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 57 deletions.
10 changes: 8 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{
"parserOptions": {
"ecmaVersion": 5,
"ecmaVersion": 6,
"sourceType": "script"
},
"env": {
"node": true
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [2, 2],
"brace-style": [2, "1tbs"],
"quotes": [2, "single"],
"semi": [2, "always"],
"comma-style": [2, "last"],
"one-var": [2, "never"],
"strict": [2, "global"],
"prefer-template": 2,
"no-console": 0,
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": 0,
Expand Down
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
node_modules
.idea
# Ignore certain IDEA/WebStorm project files
.idea/deployment.xml
.idea/workspace.xml

# Code coverage reults
coverage/

# npm modules
node_modules/

# npm error log
npm-debug.log
7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/libraries/strider_template_node_modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/strider-template.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ language: node_js
node_js:
- "4"
- "node"

sudo: false
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2016 Strider Continuous Deployment <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 changes: 1 addition & 21 deletions config/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
{
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script"
},
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"globals": {
"app": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [2, 2],
"brace-style": [2, "1tbs"],
"quotes": [2, "single"],
"no-console": 1,
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": 0,
"no-constant-condition": 0,
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"func-style": [2, "declaration"]
"commonjs": true
}
}
4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var app = window.app;
var configDefaults = {
const app = window.app;
const configDefaults = {
environment: 'Hi from `environment`',
prepare: 'Hi from `prepare`',
test: 'Hi from `test`',
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "strider-template",
"version": "1.0.1",
"version": "2.0.0",
"description": "Plugin template for Strider CD",
"main": "webapp.js",
"scripts": {
"lint": "eslint config *.js",
"test": "npm run lint && mocha -R spec --recursive test"
"lint": "eslint *.js config lib",
"test": "npm run lint && istanbul cover node_modules/mocha/bin/_mocha --recursive test"
},
"repository": {
"type": "git",
Expand All @@ -16,9 +16,11 @@
"plugin",
"template"
],
"author": "Kyle Newsome <[email protected]>",
"license": "ISC",
"dependencies": {},
"author": "Strider Continuous Deployment <[email protected]>",
"license": "MIT",
"dependencies": {
"debug": "^2.2.0"
},
"strider": {
"type": "job",
"id": "template",
Expand All @@ -32,7 +34,8 @@
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^3.0.1",
"eslint": "^3.1.1",
"istanbul": "^0.4.4",
"mocha": "^2.4.5",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0"
Expand Down
24 changes: 14 additions & 10 deletions test/worker_test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
'use strict';

var sinon = require('sinon');
var chai = require('chai');
var sinonChai = require('sinon-chai');

var Worker = require('../worker.js');
var WebApp = require('../webapp.js');

var expect = chai.expect;
const chai = require('chai');
const expect = chai.expect;
const sinon = require('sinon');
const sinonChai = require('sinon-chai');

chai.use(sinonChai);

const Worker = require('../worker.js');
const WebApp = require('../webapp.js');

describe('template worker test example', function () {
var work, io, context, config, job, exitCode;
let work;
let io;
let context;
let config;
let job;
let exitCode;

function prepareWorker(done) {
context = {};
Expand Down Expand Up @@ -56,7 +60,7 @@ describe('template worker test example', function () {
});

it('should set up the phase actions properly', function () {
var setup = work();
const setup = work();
//environment returns a string
expect(setup.environment).to.equal('echo "test message"');
//prepare returns an object
Expand Down
10 changes: 7 additions & 3 deletions webapp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
'use strict';

const debug = require('debug')('strider-template:webapp');

module.exports = {
// mongoose schema, if you need project-specific config
config: {
Expand All @@ -18,21 +22,21 @@ module.exports = {
// req.pluginConfig() -> get the config for this plugin
// req.pluginConfig(config, cb(err)) -> set the config for this plugin
routes: function (app, context) {
console.log(context);
debug(context);
},
// Define global routes
// all routes namespaced within /ext/:pluginid
// req.user is the current user
// req.user.account_level can be used for authorization
// 0 - anonymous, 1 - authed, 2 - admin / collaborator
globalRoutes: function (app, context) {
console.log(context);
debug(context);
},
// Listen for global events
// all job-local events that begin with `plugin.` are proxied to
// the main strider eventemitter, so you can listen for them here.
// Other events include `job.new`, `job.done` and `browser.update`.
listen: function (emitter, context) {
console.log(context);
debug(context);
}
};
18 changes: 10 additions & 8 deletions worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const debug = require('debug')('strider-template:worker');

/* Functions for demonstration purposes only */
function checkSomething(context, callback) {
//Do something here, then call back
Expand All @@ -26,10 +28,10 @@ module.exports = {
// enumeration of the events. Emit plugin.[pluginid].myevent to
// communicate things up to the browser or to the webapp.
listen: function (emitter, context) {
console.log(context);
debug(context);
emitter.on('job.status.phase.done', function (id, data) {
var phase = data.phase;
console.log('the ' + phase + ' phase has completed');
const phase = data.phase;
debug(`the ${phase} phase has completed`);
return true;
});
},
Expand All @@ -38,16 +40,16 @@ module.exports = {
// or a fn(context, done(err, didrun))

//string style
environment: 'echo "' + config.environment + '"',
environment: `echo "${config.environment}"`,
//object style
prepare: {
command: 'echo',
args: ['"' + config.prepare + '"']
args: [`"${config.prepare}"`]
},
//function style (calling done is a MUST)
test: function (context, done) {
//this will show up in the terminal log as 'info'
console.log(config.test);
debug(config.test);

//demonstration of how to perform async tasks, finishing with a call to done()
checkSomething(context, function (shouldDoThings) {
Expand All @@ -64,8 +66,8 @@ module.exports = {
});
});
},
deploy: 'echo "' + config.deploy + '"',
cleanup: 'echo "' + config.cleanup + '"'
deploy: `echo "${config.deploy}"`,
cleanup: `echo "${config.cleanup}"`
});
},
// this is only used if there is _no_ plugin configuration for a
Expand Down

0 comments on commit c7a67c1

Please sign in to comment.