Permalink
Browse files

chore: remove babel, fix integration tests

This commit removes babel/es6 from all source and test files, because it was introducing a lot of overhead and only little gain.
This commit fixes and enables integration tests on Travis.
This commit fixes #153 and #151 along the way.

_Originally this commit should have only removed babel, but without working tests that's a bit too hairy._
_I only realized that half way into removing babel/es6, so things are all over the place now._

Closes #153, Closes #151
  • Loading branch information...
boennemann committed Dec 29, 2015
1 parent 8833452 commit 5cdc732b6852adf0e7d87e57f894c1982c972ea9
View
@@ -1,14 +1,9 @@
-# common
coverage
node_modules
test/registry/couch
test/registry/data
+test/tmp
*.log
*.dump
.DS_Store
.nyc_output
-.test
-.tmp
-
-# build-artifacts
-dist
View
@@ -1,18 +0,0 @@
-# common
-coverage
-node_modules
-test/registry/couch
-test/registry/data
-*.log
-*.dump
-.DS_Store
-.nyc_output
-.test
-.tmp
-
-# source/config
-src
-*.yml
-.gitignore
-.editorconfig
-.npmrc
View
@@ -6,10 +6,9 @@ cache:
notifications:
email: false
node_js:
-- v5
-- v4
-- iojs-v2
-- iojs-v1
+- 5
+- 4
+- iojs
- '0.12'
- '0.10'
before_install:
@@ -19,3 +18,5 @@ before_script:
after_success:
- npm run coverage:upload
- npm run semantic-release
+services:
+- couchdb
View
@@ -257,9 +257,7 @@ It is indeed a great idea because it _forces_ you to follow best practices. If y
### Why should I trust `semantic-release` with my releases?
-`semantic-release` has a full unit- and integration-test-suite that tests _actual_ `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp/) on node.js `^0.10`, `^0.12` and io.js `^1`, `^2`. A new version won’t get published if it doesn’t pass on all these engines.
-
-Note: Currently integration-tests don’t run on Travis CI. If you know stuff about npm/Travis/Couch: Please help!
+`semantic-release` has a full unit- and integration-test-suite that tests _actual_ `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp/) on all major node.js versions from `^0.10` on. A new version won’t get published if it doesn’t pass on all these engines.
## Badge
View
@@ -1,13 +1,163 @@
#!/usr/bin/env node
-/* istanbul ignore next */
-try {
- require('../dist')
-} catch (err) {
- if (err.code === 'MODULE_NOT_FOUND') {
- require('babel/register')
- require('../src')
+var fs = require('fs')
+var path = require('path')
+var url = require('url')
+
+var _ = require('lodash')
+var log = require('npmlog')
+var nopt = require('nopt')
+var npmconf = require('npmconf')
+var normalizeData = require('normalize-package-data')
+
+log.heading = 'semantic-release'
+var env = process.env
+var pkg = JSON.parse(fs.readFileSync('./package.json'))
+normalizeData(pkg)
+var knownOptions = {
+ branch: String,
+ debug: Boolean,
+ 'github-token': String,
+ 'github-url': String,
+ 'analyze-commits': [path, String],
+ 'generate-notes': [path, String],
+ 'verify-conditions': [path, String],
+ 'verify-release': [path, String]
+}
+var options = _.defaults(
+ _.mapKeys(nopt(knownOptions), function (value, key) {
+ return _.camelCase(key)
+ }),
+ pkg.release,
+ {
+ branch: 'master',
+ fallbackTags: {
+ next: 'latest'
+ },
+ debug: !env.CI,
+ githubToken: env.GH_TOKEN || env.GITHUB_TOKEN,
+ githubUrl: env.GH_URL
+ }
+)
+var plugins = require('../src/lib/plugins')(options)
+
+npmconf.load({}, function (err, conf) {
+ if (err) {
+ log.error('init', 'Failed to load npm config.', err)
+ process.exit(1)
+ }
+
+ var npm = {
+ auth: {
+ token: env.NPM_TOKEN
+ },
+ loglevel: conf.get('loglevel'),
+ registry: require('../src/lib/get-registry')(pkg, conf),
+ tag: (pkg.publishConfig || {}).tag || conf.get('tag') || 'latest'
+ }
+
+ // normalize trailing slash
+ npm.registry = url.format(url.parse(npm.registry))
+
+ log.level = npm.loglevel
+
+ var config = {
+ env: env,
+ pkg: pkg,
+ options: options,
+ plugins: plugins,
+ npm: npm
+ }
+
+ var hide = {}
+ if (options.githubToken) hide.githubToken = '***'
+
+ log.verbose('init', 'options:', _.assign({}, options, hide))
+ log.verbose('init', 'Verifying config.')
+
+ var errors = require('../src/lib/verify')(config)
+ errors.forEach(function (err) {
+ log.error('init', err.message + ' ' + err.code)
+ })
+ if (errors.length) process.exit(1)
+
+ if (options.argv.remain[0] === 'pre') {
+ log.verbose('pre', 'Running pre-script.')
+ log.verbose('pre', 'Veriying conditions.')
+
+ plugins.verifyConditions(config, function (err) {
+ if (err) {
+ log[options.debug ? 'warn' : 'error']('pre', err.message)
+ if (!options.debug) process.exit(1)
+ }
+
+ var nerfDart = require('nerf-dart')(npm.registry)
+ var wroteNpmRc = false
+
+ if (env.NPM_OLD_TOKEN && env.NPM_EMAIL) {
+ // Using the old auth token format is not considered part of the public API
+ // This might go away anytime (i.e. once we have a better testing strategy)
+ conf.set('_auth', '${NPM_OLD_TOKEN}', 'project')
+ conf.set('email', '${NPM_EMAIL}', 'project')
+ wroteNpmRc = true
+ } else if (env.NPM_TOKEN) {
+ conf.set(nerfDart + ':_authToken', '${NPM_TOKEN}', 'project')
+ wroteNpmRc = true
+ }
+
+ conf.save('project', function (err) {
+ if (err) return log.error('pre', 'Failed to save npm config.', err)
+
+ if (wroteNpmRc) log.verbose('pre', 'Wrote authToken to .npmrc.')
+
+ require('../src/pre')(config, function (err, release) {
+ if (err) {
+ log.error('pre', 'Failed to determine new version.')
+
+ var args = ['pre', (err.code ? err.code + ' ' : '') + err.message]
+ if (err.stack) args.push(err.stack)
+ log.error.apply(log, args)
+ process.exit(1)
+ }
+
+ var message = 'Determined version ' + release.version + ' as "' + npm.tag + '".'
+
+ log.verbose('pre', message)
+
+ if (options.debug) {
+ log.error('pre', message + ' Not publishing in debug mode.', release)
+ process.exit(1)
+ }
+
+ try {
+ var shrinkwrap = JSON.parse(fs.readFileSync('./npm-shrinkwrap.json'))
+ shrinkwrap.version = release.version
+ fs.writeFileSync('./npm-shrinkwrap.json', JSON.stringify(shrinkwrap, null, 2))
+ log.verbose('pre', 'Wrote version ' + release.version + 'to npm-shrinkwrap.json.')
+ } catch (e) {
+ log.silly('pre', 'Couldn\'t find npm-shrinkwrap.json.')
+ }
+
+ fs.writeFileSync('./package.json', JSON.stringify(_.assign(pkg, {
+ version: release.version
+ }), null, 2))
+
+ log.verbose('pre', 'Wrote version ' + release.version + ' to package.json.')
+ })
+ })
+ })
+ } else if (options.argv.remain[0] === 'post') {
+ log.verbose('post', 'Running post-script.')
+
+ require('../src/post')(config, function (err, published, release) {
+ if (err) {
+ log.error('post', 'Failed to publish release notes.', err)
+ process.exit(1)
+ }
+
+ log.verbose('post', (published ? 'Published' : 'Generated') + ' release notes.', release)
+ })
} else {
- console.log(err)
+ log.error('post', 'Command "' + options.argv.remain[0] + '" not recognized. User either "pre" or "post"')
}
-}
+})
View
@@ -1,21 +1,14 @@
{
"name": "semantic-release",
"description": "automated semver compliant package publishing",
+ "version": "0.0.0-placeholder",
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"bin": {
- "semantic-release": "./bin/semantic-release.js"
+ "semantic-release": "bin/semantic-release.js"
},
"bugs": {
"url": "https://github.com/semantic-release/semantic-release/issues"
},
- "config": {
- "nyc": {
- "exclude": [
- ".test",
- "node_modules"
- ]
- }
- },
"czConfig": {
"path": "node_modules/cz-conventional-changelog/"
},
@@ -40,7 +33,6 @@
"semver": "^5.0.3"
},
"devDependencies": {
- "babel": "^5.8.21",
"coveralls": "^2.11.4",
"cz-conventional-changelog": "^1.1.4",
"mkdirp": "^0.5.1",
@@ -49,7 +41,7 @@
"npm-registry-couchapp": "^2.6.11",
"nyc": "^5.0.0",
"proxyquire": "^1.7.3",
- "rimraf": "^2.4.3",
+ "rimraf": "^2.5.0",
"standard": "^5.3.0",
"tap": "^2.1.1"
},
@@ -70,7 +62,11 @@
"version"
],
"license": "MIT",
- "main": "dist/index.js",
+ "main": "bin/semantic-release.js",
+ "files": [
+ "bin",
+ "src"
+ ],
"publishConfig": {
"tag": "next"
},
@@ -82,17 +78,12 @@
"url": "git+https://github.com/semantic-release/semantic-release.git"
},
"scripts": {
- "build": "rimraf dist && mkdirp dist && babel src --out-dir dist",
"coverage": "nyc report",
- "coverage:upload": "npm run coverage -- --reporter=lcovonly && coveralls < coverage/lcov.info",
- "prepublish": "npm run build",
- "pretest:integration": "npm run build && npm run test:build",
- "pretest:unit": "npm run build && npm run test:build",
- "semantic-release": "./bin/semantic-release.js pre && npm dedupe && npm publish && ./bin/semantic-release.js post",
- "test": "npm run test:style && npm run test:unit",
- "test:build": "rimraf .test && mkdirp .test && babel test --out-dir .test",
- "test:integration": "tap --no-cov .test/scenarios/*.js",
- "test:style": "standard",
- "test:unit": "nyc tap --no-cov .test/specs/*.js"
+ "coverage:upload": "npm run coverage -s -- --reporter=text-lcov | coveralls",
+ "pretest": "standard",
+ "semantic-release": "./bin/semantic-release.js pre && npm publish && ./bin/semantic-release.js post",
+ "test": "npm run test:unit && npm run test:integration",
+ "test:integration": "tap --no-cov test/scenarios/*.js",
+ "test:unit": "nyc tap --no-cov test/specs/*.js"
}
}
Oops, something went wrong.

0 comments on commit 5cdc732

Please sign in to comment.