-
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.
chore(release): Add 0.2.1 release files [ci skip]
- Loading branch information
CircleCI
committed
Oct 29, 2019
1 parent
0112ccc
commit b25e91f
Showing
22 changed files
with
1,048 additions
and
0 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,115 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var _path = require('path'); | ||
|
||
var _expose = require('@ls-age/expose'); | ||
|
||
var _expose2 = _interopRequireDefault(_expose); | ||
|
||
var _package = require('../package.json'); | ||
|
||
var _cli = require('./lib/cli'); | ||
|
||
var _release = require('./commands/release'); | ||
|
||
var _release2 = _interopRequireDefault(_release); | ||
|
||
var _changelog = require('./commands/changelog'); | ||
|
||
var _changelog2 = _interopRequireDefault(_changelog); | ||
|
||
var _messages = require('./commands/messages'); | ||
|
||
var _messages2 = _interopRequireDefault(_messages); | ||
|
||
var _tags = require('./commands/tags'); | ||
|
||
var _tags2 = _interopRequireDefault(_tags); | ||
|
||
var _recommendBump = require('./commands/recommend-bump'); | ||
|
||
var _recommendBump2 = _interopRequireDefault(_recommendBump); | ||
|
||
var _onReleaseBranch = require('./commands/on-release-branch'); | ||
|
||
var _onReleaseBranch2 = _interopRequireDefault(_onReleaseBranch); | ||
|
||
var _clean = require('./commands/clean'); | ||
|
||
var _clean2 = _interopRequireDefault(_clean); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
const printingOptions = {}; | ||
|
||
const cli = new _expose2.default({ | ||
name: Object.keys(_package.bin)[0], | ||
description: _package.description, | ||
onResult(result) { | ||
return (0, _cli.printResult)(result, printingOptions); | ||
}, | ||
onError(err) { | ||
return (0, _cli.handleError)(err, printingOptions); | ||
} | ||
}); | ||
|
||
function toAbsolute(path) { | ||
return (0, _path.isAbsolute)(path) ? path : (0, _path.join)(process.cwd(), path); | ||
} | ||
|
||
// Global options | ||
cli.addOptions([new _expose.StringOption({ | ||
name: 'cwd', | ||
description: 'Manually set the working directory', | ||
extendSchema: schema => schema.transform(toAbsolute), | ||
set(cwd) { | ||
printingOptions.cwd = cwd; | ||
} | ||
}), new _expose.NumberOption({ | ||
name: 'limit', | ||
description: 'Number of results to return', | ||
extendSchema: schema => schema.positive(), | ||
set(limit) { | ||
printingOptions.limit = limit; | ||
} | ||
}), new _expose.BooleanOption({ | ||
name: 'json', | ||
description: 'Create JSON output', | ||
set(json) { | ||
printingOptions.json = json; | ||
} | ||
}), new _expose.BooleanOption({ | ||
name: 'exit-code', | ||
description: 'Set status code for results', | ||
set(statusCode) { | ||
printingOptions.statusCode = statusCode; | ||
} | ||
}), new _expose.BooleanOption({ | ||
name: 'verbose', | ||
description: 'Use verbose logging', | ||
set(verbose) { | ||
printingOptions.verbose = verbose; | ||
} | ||
}), new _expose.StringOption({ | ||
name: 'out-file', | ||
description: 'The file to write to', | ||
set(path) { | ||
printingOptions.outFile = path; | ||
} | ||
})]); | ||
|
||
cli.addHelp(); | ||
cli.addVersion(_package.version); | ||
|
||
// Commands | ||
|
||
cli.addCommand(_release2.default); | ||
cli.addCommand(_changelog2.default); | ||
cli.addCommand(_messages2.default); | ||
cli.addCommand(_tags2.default); | ||
cli.addCommand(_recommendBump2.default); | ||
cli.addCommand(_onReleaseBranch2.default); | ||
cli.addCommand(_clean2.default); | ||
|
||
cli.run(); |
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,95 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createChangelog = createChangelog; | ||
|
||
var _expose = require('@ls-age/expose'); | ||
|
||
var _conventionalChangelogWriter = require('conventional-changelog-writer'); | ||
|
||
var _conventionalChangelogWriter2 = _interopRequireDefault(_conventionalChangelogWriter); | ||
|
||
var _conventionalChangelogAngular = require('conventional-changelog-angular'); | ||
|
||
var _conventionalChangelogAngular2 = _interopRequireDefault(_conventionalChangelogAngular); | ||
|
||
var _streamToPromise = require('stream-to-promise'); | ||
|
||
var _streamToPromise2 = _interopRequireDefault(_streamToPromise); | ||
|
||
var _dateformat = require('dateformat'); | ||
|
||
var _dateformat2 = _interopRequireDefault(_dateformat); | ||
|
||
var _package = require('../lib/package'); | ||
|
||
var _package2 = _interopRequireDefault(_package); | ||
|
||
var _tags = require('./tags'); | ||
|
||
var _messages = require('./messages'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
async function createChangelog(options) { | ||
const [{ writerOpts }, tags, pkg] = await Promise.all([_conventionalChangelogAngular2.default, options.tags ? Promise.resolve(options.tags) : (0, _tags.getFilteredTags)(Object.assign(options, { | ||
filter: 'non-prerelease' | ||
})), (0, _package2.default)(options)]); | ||
|
||
const msgOptions = [...tags, null].map((tag, i) => { | ||
const last = tags[i - 1]; | ||
|
||
return { | ||
from: tag && tag.name, | ||
until: last ? last.name : 'HEAD', | ||
date: last ? last.date : new Date(), | ||
version: last ? last.name : pkg.version | ||
}; | ||
}); | ||
|
||
let byVersion = await Promise.all(msgOptions.map(({ from, until, version, date }) => (0, _messages.getMessages)(Object.assign(options, { | ||
from, | ||
until | ||
})).then(messages => ({ messages, version, date })))); | ||
|
||
if (options.last) { | ||
byVersion = [byVersion[0]]; | ||
} | ||
|
||
const { host, user: owner, repo: repository, https_url: repoUrl } = (0, _package.getRepo)(pkg); | ||
|
||
const writerContext = { | ||
host: `https://${host}`, | ||
owner, | ||
repository, | ||
repoUrl, | ||
linkReferences: true | ||
}; | ||
|
||
const versionLogs = await Promise.all(byVersion.map(({ messages, version, date }) => { | ||
if (messages.length === 0 && version === pkg.version) { | ||
return ''; | ||
} | ||
const writer = (0, _conventionalChangelogWriter2.default)(Object.assign({ | ||
version: version.match(/v?(.*)/i)[1], | ||
date: (0, _dateformat2.default)(date, 'yyyy-mm-dd', true) | ||
}, writerContext), writerOpts); | ||
|
||
const promise = (0, _streamToPromise2.default)(writer); | ||
messages.forEach(m => writer.write(m)); | ||
writer.end(); | ||
|
||
return promise; | ||
})); | ||
|
||
return versionLogs.join('\n'); | ||
} | ||
|
||
exports.default = new _expose.Command({ | ||
name: 'changelog', | ||
description: 'Create changelog', | ||
run: ({ options }) => createChangelog(options), | ||
options: [_tags.fetchOption] | ||
}); |
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,19 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _expose = require('@ls-age/expose'); | ||
|
||
var _status = require('../lib/git/status'); | ||
|
||
var _status2 = _interopRequireDefault(_status); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
exports.default = new _expose.Command({ | ||
name: 'clean', | ||
description: 'Check if CWD has uncommitted changes', | ||
run: ({ options }) => (0, _status2.default)(options) | ||
}); |
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,51 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getMessages = getMessages; | ||
|
||
var _expose = require('@ls-age/expose'); | ||
|
||
var _logs = require('../lib/logs'); | ||
|
||
var _logs2 = _interopRequireDefault(_logs); | ||
|
||
var _commitMessage = require('../lib/commitMessage'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function getMessages(options) { | ||
const { from, until, raw, cwd } = options; | ||
|
||
return (0, _logs2.default)({ from, until, cwd }).then(commits => { | ||
if (raw) { | ||
return commits; | ||
} | ||
|
||
const messages = commits.map(({ message }) => message); | ||
|
||
return (0, _commitMessage.parse)(messages).then(results => results.map((result, i) => Object.assign({ | ||
hash: commits[i].hash, | ||
date: new Date(commits[i].date) | ||
}, result))); | ||
}); | ||
} | ||
|
||
exports.default = new _expose.Command({ | ||
name: 'messages', | ||
description: 'Print commit messages', | ||
alias: 'msg', | ||
run: ({ options }) => getMessages(options), | ||
|
||
options: [new _expose.StringOption({ | ||
name: 'from', | ||
description: 'Reference to start from' | ||
}), new _expose.StringOption({ | ||
name: 'until', | ||
description: 'Last reference to process' | ||
}), new _expose.BooleanOption({ | ||
name: 'raw', | ||
description: 'Return raw commit messages' | ||
})] | ||
}); |
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,30 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.onReleaseBranch = onReleaseBranch; | ||
|
||
var _expose = require('@ls-age/expose'); | ||
|
||
var _branch = require('../lib/git/branch'); | ||
|
||
async function onReleaseBranch(options) { | ||
const branch = options.branch || (await (0, _branch.currentBranch)(options)); | ||
|
||
if (branch === 'beta') { | ||
// FIXME: Take from config | ||
return 'beta'; | ||
} | ||
if (branch === 'master') { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
exports.default = new _expose.Command({ | ||
name: 'on-release-branch', | ||
description: 'Check if on release branch', | ||
run: ({ options }) => onReleaseBranch(options) | ||
}); |
Oops, something went wrong.