This repository has been archived by the owner on May 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
determine the version of the last release via the Atom Package Manager registry. This repository duplicate the behavior of https://github.com/semantic-release/last-release-npm
- Loading branch information
1 parent
00bc6e1
commit 62a9d43
Showing
13 changed files
with
296 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"plugins": [ | ||
"add-module-exports" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "airbnb/base", | ||
"parser": "babel-eslint", | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,11 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
# Coverage directory | ||
coverage/ | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
# Compiled sources | ||
dist/ | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Logs | ||
*.log | ||
|
||
# Coverage directory | ||
coverage/ | ||
|
||
# Dependency directory | ||
node_modules/ | ||
|
||
# Sources | ||
src/ | ||
test/ | ||
.babelrc | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc | ||
.gitignore | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "4" | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
notifications: | ||
email: false | ||
|
||
before_install: | ||
- npm i -g npm@2 | ||
|
||
before_script: | ||
- npm prune | ||
|
||
script: | ||
- npm run coverage | ||
|
||
after_success: | ||
- npm run coverage:upload | ||
- npm run semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# semantic-release last-release-apm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "last-release-apm", | ||
"version": "0.0.0-semantic-release", | ||
"description": "determine the version of the last release via the apm registry", | ||
"author": "Arnaud Dezandee <dezandee.arnaud@gmail.com> (https://github.com/Adezandee)", | ||
"keywords": [ | ||
"apm", | ||
"registry", | ||
"semantic-release", | ||
"version" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Adezandee/last-release-apm.git" | ||
}, | ||
"homepage": "https://github.com/Adezandee/last-release-apm#readme", | ||
"bugs": { | ||
"url": "https://github.com/Adezandee/last-release-apm/issues" | ||
}, | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "npm run build", | ||
"prebuild": "rm -rf dist && mkdir dist", | ||
"build": "babel -d dist src", | ||
"pretest": "eslint .", | ||
"test": "mocha --compilers js:babel-register", | ||
"coverage": "babel-node ./node_modules/.bin/isparta cover _mocha", | ||
"coverage:upload": "cat ./coverage/lcov.info | coveralls", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"dependencies": { | ||
"@semantic-release/error": "^1.0.0", | ||
"request": "^2.67.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.4.0", | ||
"babel-eslint": "^5.0.0-beta6", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-register": "^6.3.13", | ||
"chai": "^3.4.1", | ||
"coveralls": "^2.11.6", | ||
"cz-conventional-changelog": "^1.1.5", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^3.1.0", | ||
"isparta": "^4.0.0", | ||
"mocha": "^2.3.4", | ||
"nock": "^5.2.1", | ||
"semantic-release": "^4.3.5" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Dependencies | ||
*/ | ||
|
||
import SemanticReleaseError from '@semantic-release/error'; | ||
import request from 'request'; | ||
|
||
/** | ||
* Interface | ||
*/ | ||
|
||
const ATOM_REGISTRY = 'https://atom.io'; | ||
|
||
export default function (pluginConfig, { pkg }, callback) { | ||
const requestSettings = { | ||
url: `${ATOM_REGISTRY}/api/packages/${pkg.name}`, | ||
json: true, | ||
}; | ||
|
||
request.get(requestSettings, (error, response, body = {}) => { | ||
if (error) { | ||
return callback(error); | ||
} | ||
|
||
if (response.statusCode === 404) { | ||
return callback(null, {}); | ||
} | ||
|
||
if (response.statusCode === 200 && body.releases && body.releases.latest) { | ||
return callback(null, { | ||
version: body.releases.latest, | ||
tag: 'latest', | ||
}); | ||
} | ||
|
||
const message = body.message || body.error || body; | ||
return callback(new SemanticReleaseError( | ||
`Requesting package failed: ${JSON.stringify(message)}` | ||
)); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"env": { | ||
"mocha": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Dependencies | ||
*/ | ||
|
||
import { expect } from 'chai'; | ||
import SemanticReleaseError from '@semantic-release/error'; | ||
import lastRelease from '../src/index.js'; | ||
|
||
/** | ||
* Tests | ||
*/ | ||
|
||
describe('last release from registry', () => { | ||
it('get release from package name', done => { | ||
lastRelease({}, { | ||
pkg: { name: 'present' }, | ||
}, (error, release) => { | ||
expect(error).to.equal(null); | ||
expect(release).to.deep.equal({ | ||
version: '1.0.0', | ||
tag: 'latest', | ||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('get nothing from not yet published package name', () => { | ||
it('missing', done => { | ||
lastRelease({}, { | ||
pkg: { name: 'missing' }, | ||
}, (error, release) => { | ||
expect(error).to.equal(null); | ||
expect(release.version).to.equal(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('missing no 404', done => { | ||
lastRelease({}, { | ||
pkg: { name: 'missing-no-404' }, | ||
}, (error, release) => { | ||
expect(error).to.exist.and.be.instanceof(SemanticReleaseError); | ||
expect(error.message).to.equal('Requesting package failed: "Not Found"'); | ||
expect(release).to.equal(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('missing no body', done => { | ||
lastRelease({}, { | ||
pkg: { name: 'missing-no-body' }, | ||
}, (error, release) => { | ||
expect(error).to.exist.and.be.instanceof(SemanticReleaseError); | ||
expect(error.message).to.equal('Requesting package failed: {}'); | ||
expect(release).to.equal(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('error', done => { | ||
lastRelease({}, { | ||
pkg: { name: 'error' }, | ||
}, (error, release) => { | ||
expect(error).to.deep.equal({ | ||
message: 'Error', | ||
statusCode: 500, | ||
code: 'E500', | ||
}); | ||
expect(release).to.equal(undefined); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Dependencies | ||
*/ | ||
|
||
import nock from 'nock'; | ||
|
||
/** | ||
* Mock | ||
*/ | ||
|
||
const ATOM_REGISTRY = 'https://atom.io'; | ||
|
||
const present = { | ||
name: 'present', | ||
releases: { | ||
latest: '1.0.0', | ||
}, | ||
}; | ||
|
||
const missing = { | ||
message: 'Not Found', | ||
}; | ||
|
||
export const registry = nock(ATOM_REGISTRY) | ||
.get('/api/packages/present') | ||
.reply(200, present) | ||
.get('/api/packages/missing') | ||
.reply(404, missing) | ||
.get('/api/packages/missing-no-404') | ||
.reply(200, missing) | ||
.get('/api/packages/missing-no-body') | ||
.reply(200) | ||
.get('/api/packages/error') | ||
.replyWithError({ | ||
message: 'Error', | ||
statusCode: 500, | ||
code: 'E500', | ||
}); |