Skip to content

Commit

Permalink
Merge eda7c1a into c4254d7
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Jun 28, 2018
2 parents c4254d7 + eda7c1a commit 5fe92bb
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 81 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ CKEditor 5 development tools packages

Tests:

```
```bash
npm test
```

Code coverage:
Tests with Debug mode:

```bash
DEBUG=true npm test
```

Test a single package:

```bash
./node_modules/.bin/mocha packages/ckeditor5-dev-env/tests/* --recursive
```

Code coverage:

```bash
npm run coverage
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"husky": "^0.14.3",
"istanbul": "^0.4.4",
"lerna": "^2.2.0",
"lint-staged": "^7.0.0",
"lint-staged": "^7.2.0",
"mocha": "^5.0.5"
},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ const transformCommitFunction = require( '../utils/transform-commit/transformcom
* should be generated.
*
* @param {String|null} [newVersion=null] A version for which changelog will be generated.
* @param {Object} [options={}] Additional options.
* @param {Boolean} [options.skipLinks=false] If set on true, links to release or commits will be omitted.
* @returns {Promise}
*/
module.exports = function generateChangelogForSinglePackage( newVersion = null ) {
module.exports = function generateChangelogForSinglePackage( newVersion = null, options = {} ) {
const log = logger();
const packageJson = getPackageJson();

Expand Down Expand Up @@ -74,7 +76,8 @@ module.exports = function generateChangelogForSinglePackage( newVersion = null )
tagName,
isInternalRelease,
newTagName: 'v' + version,
transformCommit: transformCommitFunction
transformCommit: transformCommitFunction,
skipLinks: !!options.skipLinks
};

return generateChangelogFromCommits( changelogOptions )
Expand Down
36 changes: 19 additions & 17 deletions packages/ckeditor5-dev-env/lib/release-tools/templates/commit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
{{~title}}
{{~/if}}

{{~!-- commit link --}} {{#if @root.linkReferences~}}
([{{hash}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.commit}}/{{hash}}))
{{~else}}
{{~hash}}
{{~/if}}
{{~#unless @root.skipCommitsLink}}
{{~!-- commit link --}} {{#if @root.linkReferences~}}
([{{hash}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.commit}}/{{hash}}))
{{~else}}
{{~hash}}
{{~/if}}
{{/unless}}
{{#if body}}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## {{#if @root.linkCompare~}}
## {{#unless @root.skipCompareLink~}}
[{{version}}](
{{~#if @root.repository~}}
{{~#if @root.host}}
Expand All @@ -14,6 +14,6 @@
/compare/{{previousTag}}...{{currentTag}})
{{~else}}
{{~version}}
{{~/if}}
{{~/unless}}
{{~#if date}} ({{date}})
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Internal changes only (updated dependencies, documentation, etc.).
{{#each commitGroups}}
### {{title}}

{{#if (lookup ../additionalNotes title)}}
{{ lookup ../additionalNotes title }}
{{#if (lookup @root.additionalNotes title)}}
{{ lookup @root.additionalNotes title }}

{{/if}}
{{#each commits}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const { additionalCommitNotes } = require( './transform-commit/transform-commit-
* @param {Boolean} [options.doNotSave=false] If set on `true`, changes will be resolved in returned promise
* instead of saving in CHANGELOG file.
* @param {Boolean} [options.additionalNotes=false] If set on `true, each category will contain additional description.
* @param {Boolean} [options.skipLinks=false] If set on true, links to release or commits will be omitted.
* @returns {Promise}
*/
module.exports = function generateChangelogFromCommits( options ) {
Expand All @@ -45,6 +46,8 @@ module.exports = function generateChangelogFromCommits( options ) {
displayLogs: false,
isInternalRelease: options.isInternalRelease || false,
additionalNotes: {},
skipCommitsLink: Boolean( options.skipLinks ),
skipCompareLink: Boolean( options.skipLinks )
};

if ( options.additionalNotes ) {
Expand All @@ -59,14 +62,23 @@ module.exports = function generateChangelogFromCommits( options ) {

const writerOptions = getWriterOptions( options.transformCommit );

/* istanbul ignore next */
if ( process.env.DEBUG ) {
// Displays the final `context` which will be used to generate the changelog.
// It contains grouped commits, repository details, etc.
writerOptions.debug = getDebugFuntion();
}

conventionalChangelog( {}, context, gitRawCommitsOpts, parserOptions, writerOptions )
.pipe( saveChangelogPipe( options.version, resolve, options.doNotSave ) );
.pipe( changelogPipe( options.version, resolve, {
doNotSave: options.doNotSave
} ) );
} );
};

function saveChangelogPipe( version, done, doNotSave = false ) {
function changelogPipe( version, done, options ) {
return stream.noop( changes => {
if ( doNotSave ) {
if ( options.doNotSave ) {
return done( changes.toString() );
}

Expand All @@ -85,3 +97,9 @@ function saveChangelogPipe( version, done, doNotSave = false ) {
done( version );
} );
}

function getDebugFuntion() {
return ( ...params ) => {
console.log( ...params );
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ describe( 'dev-env/release-tools/tasks', () => {
tagName: 'v0.5.0',
newTagName: 'v1.0.0',
transformCommit: stubs.transformCommit,
isInternalRelease: false
isInternalRelease: false,
skipLinks: false
} );

expect( stubs.logger.info.calledThrice ).to.equal( true );
Expand Down Expand Up @@ -115,7 +116,8 @@ describe( 'dev-env/release-tools/tasks', () => {
tagName: null,
newTagName: 'v0.1.0',
transformCommit: stubs.transformCommit,
isInternalRelease: false
isInternalRelease: false,
skipLinks: false
} );

expect( stubs.getNewReleaseType.calledOnce ).to.equal( true );
Expand Down Expand Up @@ -177,7 +179,30 @@ describe( 'dev-env/release-tools/tasks', () => {
tagName: 'v0.0.1',
newTagName: 'v0.0.2',
transformCommit: stubs.transformCommit,
isInternalRelease: true
isInternalRelease: true,
skipLinks: false
} );
} );
} );

it( 'passes the "skipLinks" option to the changelog generator', () => {
stubs.getNewReleaseType.returns( Promise.resolve( {
releaseType: 'minor'
} ) );
stubs.cli.provideVersion.returns( Promise.resolve( '0.1.0' ) );
stubs.versionUtils.getLastFromChangelog.returns( null );
stubs.generateChangelogFromCommits.returns( Promise.resolve() );

return generateChangelogForSinglePackage( null, { skipLinks: true } )
.then( () => {
expect( stubs.generateChangelogFromCommits.calledOnce ).to.equal( true );
expect( stubs.generateChangelogFromCommits.firstCall.args[ 0 ] ).to.deep.equal( {
version: '0.1.0',
tagName: null,
newTagName: 'v0.1.0',
transformCommit: stubs.transformCommit,
isInternalRelease: false,
skipLinks: true
} );
} );
} );
Expand Down
14 changes: 12 additions & 2 deletions packages/ckeditor5-dev-env/tests/release-tools/templates/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ describe( 'dev-env/release-tools/changelog/templates', () => {
repository: 'repository',
commit: 'commit',
issue: 'issues',
linkReferences: true
linkReferences: true,
skipCommitsLink: false
};
templateOptions = {
data: {
root: rootOptions
root: rootOptions,
}
};
} );
Expand Down Expand Up @@ -86,5 +87,14 @@ describe( 'dev-env/release-tools/changelog/templates', () => {
'\n\n Some paragraph.\n\n * List Item 1.\n * List Item 2.';
expect( template( data, templateOptions ) ).to.equal( expectedEntry + '\n' );
} );

it( 'hides the commit hash', () => {
rootOptions.skipCommitsLink = true;

const data = { subject: 'Test', hash: '1234qwe' };

const expectedEntry = '* Test';
expect( template( data, templateOptions ) ).to.equal( expectedEntry + '\n' );
} );
} );
} );

0 comments on commit 5fe92bb

Please sign in to comment.