Skip to content

Commit

Permalink
chore: add travis, semantic-release etc
Browse files Browse the repository at this point in the history
  • Loading branch information
finom committed Aug 24, 2016
1 parent 5609e55 commit 258e387
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ node_modules/
coverage
.coveralls.yml
dist
npm/*.js
npm/**/*.js
npm
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
notifications:
email: false
node_js:
- '6'
before_install:
- npm i -g npm@^3.0.0
before_script:
- npm prune
script:
- npm test
branches:
except:
- /^v\d+\.\d+\.\d+$/
deploy:
provider: script
script: npm run semantic-release
branch: next
41 changes: 36 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,54 @@
"description": "Matreshka.js source code",
"main": "matreshka.js",
"scripts": {
"clean": "shx rm -rf dist npm",
"node-test": "babel-node test/node-test/jasmine.js",
"node-cover": "babel-node ./node_modules/istanbul/lib/cli cover test/jasmine.js --report html",
"develop": "karma start test/karma.conf.js",
"karma-test": "karma start test/karma-test/karma.conf.js --single-run --no-auto-watch",
"test": "npm run karma-test && npm run karma-test -- --dom-library=jquery-1 && npm run karma-test -- --dom-library=jquery-2 && npm run karma-test -- --dom-library=jquery-3 && npm run karma-test -- --dom-library=zepto",
"compile-npm": "babel src -d npm",
"_test": "npm run karma-test && npm run karma-test -- --dom-library=jquery-1 && npm run karma-test -- --dom-library=jquery-2 && npm run karma-test -- --dom-library=jquery-3 && npm run karma-test -- --dom-library=zepto",
"compile-npm": "babel src -d npm && shx cp README.md npm/README.md && babel-node ./tools/generate-package",
"bundle-browser-test": "webpack --config test/webpack-test.config.js",
"watch-browser-test": "webpack --config test/webpack-test.config.js --watch",
"lint": "eslint .",
"check-updates": "ncu",
"upgrade": "npm run check-updates -- --upgradeAll && npm install",
"bundle": "webpack"
"bundle": "webpack",
"semantic-release": "semantic-release pre && echo 'Should publish on npm there' && semantic-release post",
"semantic-release-pre": "semantic-release pre",
"commit": "git-cz"
},
"repository": {
"type": "git",
"url": "git+https://github.com/matreshkajs/matreshka.git"
"url": "https://github.com/matreshkajs/matreshka.git"
},
"author": "",
"author": "Andrey Gubanov <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/matreshkajs/matreshka/issues"
},
"config": {
"commitizen": {
"path": "./tools/cz-simple-conventional-changelog"
},
"validate-commit-msg": {
"types": [
"feat",
"fix",
"refactor",
"perf",
"test",
"chore",
"revert"
]
},
"ghooks": {
"commit-msg": "validate-commit-msg"
}
},
"release": {
"branch": "next"
},
"homepage": "https://github.com/matreshkajs/matreshka#readme",
"devDependencies": {
"app-module-path": "^1.1.0",
Expand All @@ -47,6 +73,7 @@
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-object-spread-inline": "0.0.2",
"babel-polyfill": "^6.13.0",
"commitizen": "^2.8.6",
"copy-webpack-plugin": "^3.0.1",
"eslint": "^3.3.0",
"eslint-config-airbnb": "^10.0.1",
Expand All @@ -55,6 +82,7 @@
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-output-todo-comments": "0.0.6",
"eslint-plugin-react": "^6.0.0",
"install": "^0.8.1",
"istanbul": "^1.1.0-alpha.1",
"jasmine": "^2.4.1",
"jasmine-core": "^2.4.1",
Expand All @@ -70,7 +98,10 @@
"karma-webpack-with-fast-source-maps": "^1.9.2",
"npm-check-updates": "^2.8.0",
"optimist": "^0.6.1",
"semantic-release": "^undefined",
"shx": "^0.1.4",
"unminified-webpack-plugin": "^1.1.0",
"validate-commit-msg": "^2.6.1",
"webpack": "^1.13.1"
}
}
61 changes: 61 additions & 0 deletions tools/cz-simple-conventional-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// simplified version of this https://github.com/commitizen/cz-conventional-changelog
const wrap = require('word-wrap');

module.exports = {
prompter (cz, commit) {
global.console.log(`Line 1 will be cropped at 100 characters.
All other lines will be wrapped after 100 characters.`);
cz.prompt([{
type: 'list',
name: 'type',
message: 'Select the type of change that you\'re committing:',
choices: [{
name: 'feat: A new feature',
value: 'feat',
}, {
name: 'fix: A bug fix',
value: 'fix',
}, {
name: `refactor: A change that neither fixes a bug nor adds a feature
(for example, comments and code style fixes)`,
value: 'refactor',
}, {
name: 'perf: A change that improves performance',
value: 'perf',
}, {
name: 'test: A change that adds or updates tests',
value: 'test',
}, {
name: 'chore: A change to the build process, auxiliary tools, or documentation',
value: 'chore',
}],
}, {
type: 'input',
name: 'subject',
message: 'Write a short, imperative present tense description of the change:\n',
}, {
type: 'input',
name: 'body',
message: 'Provide a longer description of the change (emphasis on WHY not WHAT):\n',
}]).then(answers => {

const maxLineWidth = 100;

const wrapOptions = {
trim: true,
newline: '\n',
indent: '',
width: maxLineWidth,
};


// Hard limit this line
const head = `${answers.type}: ${answers.subject.trim()}`.slice(0, maxLineWidth);

// Wrap these lines at 100 characters
const body = wrap(answers.body, wrapOptions);

commit(`${head}\n\n${body}`);
});
},
};
33 changes: 33 additions & 0 deletions tools/generate-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require('fs');
const path = require('path');
const sourcePackage = require('../package');
const npmPackage = { name: 'matreshka' };
const defaultVersion = '0.0.0-auto';

if(sourcePackage.version === '0.0.0-auto') {
//throw Error(`Package version cannot be "${defaultVersion}"`)
}

for(const key of [
'version',
'author',
'repository',
'license',
'bugs',
'homepage'
]) {
const value = sourcePackage[key];
if(!value) {
throw Error(`"${key}" is not specified at package.json`);
}

npmPackage[key] = value;
}

console.log('generating package.json');

const npmPackageString = JSON.stringify(npmPackage, null, '\t');

fs.writeFileSync(path.resolve(__dirname, '../npm/package.json'), npmPackageString, {
encoding: 'utf8'
});

0 comments on commit 258e387

Please sign in to comment.