2020-01-13 15:06:32 +00:00
|
|
|
'use strict';
|
|
|
|
const chalk = require( 'chalk' );
|
|
|
|
const promptly = require( 'promptly' );
|
|
|
|
const { REPO, pkg } = require( '../config' );
|
|
|
|
const { make } = require( '../common' );
|
|
|
|
const { fetchAllPullRequests } = require( './requests' );
|
|
|
|
|
|
|
|
/* eslint no-console: 0 */
|
2020-01-28 13:47:26 +00:00
|
|
|
let ready = false;
|
2020-01-13 15:06:32 +00:00
|
|
|
|
|
|
|
const makeChangeLog = async () => {
|
2023-08-23 13:30:35 +00:00
|
|
|
if ( ! pkg.changelog.githubToken ) {
|
2020-01-28 13:47:26 +00:00
|
|
|
console.log(
|
|
|
|
chalk.yellow(
|
|
|
|
'This program requires an api token. You can create one here: '
|
|
|
|
) + 'https://github.com/settings/tokens'
|
|
|
|
);
|
|
|
|
console.log( '' );
|
|
|
|
console.log(
|
|
|
|
chalk.yellow(
|
|
|
|
'Token scope will require read permissions on public_repo, admin:org, and user.'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
console.log( '' );
|
|
|
|
console.log(
|
|
|
|
chalk.yellow(
|
2023-08-23 13:30:35 +00:00
|
|
|
'Export the token as variable called GITHUB_TOKEN from your bash profile.'
|
2020-01-28 13:47:26 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
console.log( '' );
|
2020-01-13 15:06:32 +00:00
|
|
|
|
2020-01-28 13:47:26 +00:00
|
|
|
ready = await promptly.confirm( 'Are you ready to continue? ' );
|
|
|
|
} else {
|
2023-08-23 13:30:35 +00:00
|
|
|
console.log( chalk.green( 'Detected GITHUB_TOKEN is set.' ) );
|
2020-01-28 13:47:26 +00:00
|
|
|
ready = true;
|
|
|
|
}
|
2020-01-13 15:06:32 +00:00
|
|
|
|
|
|
|
if ( ready ) {
|
|
|
|
console.log( '' );
|
|
|
|
console.log(
|
|
|
|
chalk.yellow(
|
|
|
|
'In order to generate the changelog, you will have to provide a version number to retrieve the PRs from.'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
console.log( '' );
|
|
|
|
console.log(
|
|
|
|
chalk.yellow( 'Write it as it appears in the milestones page: ' ) +
|
|
|
|
`https://github.com/${ REPO }/milestones`
|
|
|
|
);
|
|
|
|
console.log( '' );
|
|
|
|
const version = await promptly.prompt( 'Version number: ' );
|
|
|
|
console.log( '' );
|
|
|
|
console.log(
|
|
|
|
chalk.green(
|
|
|
|
'Here is the generated changelog. Be sure to remove entries ' +
|
|
|
|
`not intended for a ${ pkg.title } release.`
|
|
|
|
)
|
|
|
|
);
|
|
|
|
console.log( '' );
|
|
|
|
make( fetchAllPullRequests, version );
|
|
|
|
} else {
|
|
|
|
console.log( '' );
|
|
|
|
console.log( chalk.yellow( 'Ok, see you soon.' ) );
|
|
|
|
console.log( '' );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
makeChangeLog,
|
|
|
|
};
|