-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change changelog
task to for direct invocation from external command
#5
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// jshint node:true | ||
'use strict'; | ||
|
||
var SilentError = require('silent-error'); | ||
var chalk = require('chalk'); | ||
var generateChangelog = require('../tasks/changelog'); | ||
|
||
module.exports = { | ||
|
@@ -11,9 +13,23 @@ module.exports = { | |
|
||
availableOptions: [], | ||
|
||
anonymousOptions: [], | ||
anonymousOptions: [ | ||
'<from-rev>', | ||
'<release-name>', | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you intend to invoke
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's what I want to do, see this branch over on The command args are separate from how release will use it, but are necessary to include if the task is to be self-contained, i.e. if these weren't provided on the command line, the config would have to be read in before the task is invoked. This is part of a larger question I had about how you see the
Either way I think it requires the user to specify more information to the command. Hope I'm not missing something obvious. |
||
|
||
run: function() { | ||
return generateChangelog.call(this); | ||
run: function(options, rawArgs) { | ||
var fromRev = rawArgs.shift(); | ||
var releaseName = rawArgs.shift(); | ||
|
||
if (!fromRev) { | ||
throw new SilentError("Changelog generation requires a valid starting git revision."); | ||
} | ||
|
||
if (!releaseName) { | ||
throw new SilentError("Changelog generation requires specifying the name of the release."); | ||
} | ||
|
||
return generateChangelog(this.project, fromRev, releaseName); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// jshint node:true | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var fs = require('fs'); | ||
var chalk = require('chalk'); | ||
var objectAssign = require('object-assign'); | ||
var readPackage = require('./read-package'); | ||
var getRepoInfo = require('./get-repo-info'); | ||
|
||
// Returns a config object augmented with user defined config options | ||
module.exports = function getConfig(project) { | ||
var pkg = readPackage(project.root); | ||
var config = { | ||
root: project.root, | ||
version: pkg.version, | ||
}; | ||
|
||
return getRepoInfo(project) | ||
.then(function(repoInfo) { | ||
// Add repo info to the config object | ||
objectAssign(config, repoInfo); | ||
|
||
config.hostIsGithub = repoInfo.service === 'github'; | ||
config.hostIsBitbucket = repoInfo.service === 'bitbucket'; | ||
config.hostIsCustom = repoInfo.service === 'custom'; | ||
|
||
return readConfig(project); | ||
}).then(function(userConfig) { | ||
// Add user config options to the config object | ||
objectAssign(config, userConfig); | ||
|
||
return config; | ||
}); | ||
}; | ||
|
||
function readConfig(project) { | ||
if (project._changelogConfig) { | ||
return project._changelogConfig; | ||
} | ||
var configPath = path.join(project.root, 'config/changelog.js'); | ||
var config = {}; | ||
|
||
if (fs.existsSync(configPath)) { | ||
config = require(configPath); | ||
project._changelogConfig = config; | ||
|
||
if (!config.head) { | ||
config.head = 'master'; | ||
} | ||
|
||
return config; | ||
} | ||
|
||
throw "Error: config/changelog.js is not defined. You may need to run `ember g ember-cli-changelog`."; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It appears you primarily moved this from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dammit git. Yeah, I think it will work to do it in a rename commit and an update commit. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/*jshint node:true*/ | ||
'use strict'; | ||
|
||
var RSVP = require('rsvp'); | ||
var Promise = RSVP.Promise; // jshint ignore:line | ||
var validUrl = require('valid-url'); | ||
var readPackage = require('./../helpers/read-package'); | ||
var updatePackage = require('./../helpers/update-package'); | ||
var getConfig = require('./get-config'); | ||
var Promise = RSVP.Promise; // jshint ignore:line | ||
|
||
// expected repository url forms | ||
|
||
|
@@ -21,62 +21,61 @@ var getConfig = require('./get-config'); | |
// git@try.gogs.io:<org>/<project>.git | ||
// https://try.gogs.io/<org>/<project>.git | ||
|
||
module.exports = function getRepoInfo(project) { | ||
return getRepoURL(project).then(function(link) { | ||
var parts = link.split('/'); | ||
var projectName = parts.pop(); | ||
var org = parts.pop(); | ||
var service = getService(link); | ||
if (projectName.indexOf('.git') !== -1) { | ||
projectName = projectName.substr(0, projectName.indexOf('.git')); | ||
} | ||
|
||
return { | ||
path: link, | ||
organization: org, | ||
name: projectName, | ||
project: projectName, | ||
service: service, | ||
projectUrl: getUrlBase(link, service, org, projectName), | ||
repositoryLink: link | ||
}; | ||
}); | ||
}; | ||
|
||
module.exports = function() { | ||
var pkg = readPackage.bind(this)(); | ||
var firstStep; | ||
function getRepoURL(project) { | ||
var pkg = readPackage(project.root); | ||
|
||
if (!pkg.repository || (typeof pkg.repository !== 'string' && !pkg.repository.url)) { | ||
firstStep = promptForRepoName.call(this) | ||
return promptForRepoName(project) | ||
.then(function(repositoryLink) { | ||
updatePackage.call(this, { | ||
updatePackage(project, { | ||
repository: repositoryLink | ||
}); | ||
return repositoryLink; | ||
}.bind(this)); | ||
}); | ||
} else { | ||
firstStep = Promise.resolve(pkg.repository.url || pkg.repository); | ||
return Promise.resolve(pkg.repository.url || pkg.repository); | ||
} | ||
} | ||
|
||
return firstStep | ||
.then(function(link) { | ||
var parts = link.split('/'); | ||
var project = parts.pop(); | ||
var org = parts.pop(); | ||
var service = getService(link); | ||
if (project.indexOf('.git') !== -1) { | ||
project = project.substr(0, project.indexOf('.git')); | ||
} | ||
var p = { | ||
root: this.project.root, | ||
path: link, | ||
organization: org, | ||
name: project, | ||
project: this.project, | ||
version: pkg.version, | ||
service: service, | ||
projectUrl: getUrlBase(link, service, org, project), | ||
repositoryLink: link | ||
}; | ||
var config = getConfig.call(this, p); | ||
|
||
config.hostIsGithub = p.service === 'github'; | ||
config.hostIsBitbucket = p.service === 'bitbucket'; | ||
config.hostIsCustom = p.service === 'custom'; | ||
|
||
config.project = p; | ||
return config; | ||
}.bind(this)); | ||
}; | ||
function promptForRepoName(project) { | ||
var promptOptions = { | ||
message: "Your project's package.json file has a missing or empty 'repository'\n" + | ||
"Please type or paste the link to the repository to continue.", | ||
type: 'input', | ||
name: 'repository' | ||
}; | ||
|
||
function getService(link) { | ||
if (link.indexOf('github.com') !== -1) { | ||
return 'github'; | ||
} | ||
if (link.indexOf('bitbucket.org') !== -1) { | ||
return 'bitbucket'; | ||
} | ||
return 'custom'; | ||
project.ui.writeLine(""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks as though you've removed the "service" detection without replacing it elsewhere. |
||
return project.ui.prompt(promptOptions) | ||
.then(function(response) { | ||
if (!validUrl.isUri(response.repository)) { | ||
project.ui.writeError('Your answer does not appear to be a URL'); | ||
return promptForRepoName(project); | ||
} | ||
return response.repository; | ||
}); | ||
} | ||
|
||
function getUrlBase(link, service, org, project) { | ||
|
@@ -102,22 +101,12 @@ function getUrlBase(link, service, org, project) { | |
return [base, org, project].join('/'); | ||
} | ||
|
||
|
||
function promptForRepoName() { | ||
var promptOptions = { | ||
message: "Your project's package.json file has a missing or empty 'repository'\n" + | ||
"Please type or paste the link to the repository to continue.", | ||
type: 'input', | ||
name: 'repository' | ||
}; | ||
|
||
this.ui.writeLine(""); | ||
return this.ui.prompt(promptOptions) | ||
.then(function(response) { | ||
if (!validUrl.isUri(response.repository)) { | ||
this.ui.writeError('Your answer does not appear to be a URL'); | ||
return promptForRepoName.call(this); | ||
} | ||
return response.repository; | ||
}.bind(this)); | ||
function getService(link) { | ||
if (link.indexOf('github.com') !== -1) { | ||
return 'github'; | ||
} | ||
if (link.indexOf('bitbucket.org') !== -1) { | ||
return 'bitbucket'; | ||
} | ||
return 'custom'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage in this file was actually buggy, it was intended to be used this way:
We can account for separation of the tags in a wrapper function layer within either project if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this line so that it would reflect my other changes, but like I said before I'd like to avoid making the user add this to their
config/release.js
, so I think the issue is moot.