Skip to content

Commit

Permalink
docs: fix changelog format, trim changelog starting from first release
Browse files Browse the repository at this point in the history
  • Loading branch information
GerkinDev committed Jul 23, 2022
1 parent cc38392 commit 86cb221
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 123 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ junit.xml

docs/
*.GENERATED*
!*.GENERATED*.patch
!*.GENERATED*.patch
tools/sync-proto-modules/.changelog-cache.json
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@



# 0.22.0 (2022-02-23)
## 0.22.0 (2022-02-23)



Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-code-blocks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ No notable changes were done in this version.
* **dep: @knodes/typedoc-pluginutils**: fix `wrapError`, add helper `catchWrap` ([350fc9b](https://github.com/KnodesCommunity/typedoc-plugins/commit/350fc9b9281fce5b7bd7c98253af4a4ef8f66d79))


# 0.22.0 (2022-02-23)
## 0.22.0 (2022-02-23)


## 0.0.1 (2022-02-23)
**First release**


No notable changes were done in this version.
32 changes: 1 addition & 31 deletions packages/plugin-monorepo-readmes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,7 @@ No notable changes were done in this version.
## [0.22.2](https://github.com/KnodesCommunity/typedoc-plugins/compare/v0.22.1...v0.22.2) (2022-03-06)


No notable changes were done in this version.


## 0.22.1 (2022-03-04)
**First release**


No notable changes were done in this version.


### Bug Fixes

* **monorepo**: fix events order, bind TypeDoc prototypes to watch custom events ([83ee577](https://github.com/KnodesCommunity/typedoc-plugins/commit/83ee5776cea435fd4b5d155d1bd96f99737a5063))
* **monorepo**: various reflection path resolution fixes, better test code blocks ([314f173](https://github.com/KnodesCommunity/typedoc-plugins/commit/314f173d5430f452a9924569db8f38575337c638))


### Features

* add plugin ([7c9bc9c](https://github.com/KnodesCommunity/typedoc-plugins/commit/7c9bc9c167211a0201a54559c0f75ee5fc249f12))
* **dep: @knodes/typedoc-pluginutils**: add `name` getter on plugin ([335095a](https://github.com/KnodesCommunity/typedoc-plugins/commit/335095a976ecedab7d1cbb64a2a1de0e4e5e7b79))
* **dep: @knodes/typedoc-pluginutils**: add better support for modules in path reflection resolution ([ff0f7c7](https://github.com/KnodesCommunity/typedoc-plugins/commit/ff0f7c790c627a8308c00c8d5426d402657d11fa))
* **dep: @knodes/typedoc-pluginutils**: add option group, add resolvePackageFile ([878baf8](https://github.com/KnodesCommunity/typedoc-plugins/commit/878baf8f713cd1f307bcde2a909ae0257d835d73))
* **dep: @knodes/typedoc-pluginutils**: add package ([f6894ad](https://github.com/KnodesCommunity/typedoc-plugins/commit/f6894ad003e7f4336407238bc6dea1fd4d9c9101))
* **dep: @knodes/typedoc-pluginutils**: add PathReflectionResolver, add plugin.relativeToRoot, use in MarkdownReplacer ([40eb1a1](https://github.com/KnodesCommunity/typedoc-plugins/commit/40eb1a1c2dca89cae27625f4234316166c652706))
* **dep: @knodes/typedoc-pluginutils**: add rootDir on plugin, add CurrentPageMemo, add MarkdownReplacer, improve Logger ([200f52f](https://github.com/KnodesCommunity/typedoc-plugins/commit/200f52f8417865734c19ed6bc8d91128a2902abe))
* **dep: @knodes/typedoc-pluginutils**: add source map support in markdown replacer ([57e5e39](https://github.com/KnodesCommunity/typedoc-plugins/commit/57e5e3925725e58677038d9b2dc9943ac42b0c96))
* **dep: @knodes/typedoc-pluginutils**: fix `wrapError`, add helper `catchWrap` ([350fc9b](https://github.com/KnodesCommunity/typedoc-plugins/commit/350fc9b9281fce5b7bd7c98253af4a4ef8f66d79))


# 0.22.0 (2022-02-23)


## 0.0.1 (2022-02-23)


42 changes: 2 additions & 40 deletions packages/plugin-pages/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,50 +84,12 @@ No notable changes were done in this version.
## [0.22.2](https://github.com/KnodesCommunity/typedoc-plugins/compare/v0.22.1...v0.22.2) (2022-03-06)


No notable changes were done in this version.


### Bug Fixes

* include missing `static` folder in package files ([1889d89](https://github.com/KnodesCommunity/typedoc-plugins/commit/1889d8919b90bb8716bd9b6d97962bab5ad17132))


## 0.22.1 (2022-03-04)
**First release**


No notable changes were done in this version.


### Bug Fixes

* **monorepo**: fix events order, bind TypeDoc prototypes to watch custom events ([83ee577](https://github.com/KnodesCommunity/typedoc-plugins/commit/83ee5776cea435fd4b5d155d1bd96f99737a5063))
* **monorepo**: various reflection path resolution fixes, better test code blocks ([314f173](https://github.com/KnodesCommunity/typedoc-plugins/commit/314f173d5430f452a9924569db8f38575337c638))


### Features

* add plugin ([2434d33](https://github.com/KnodesCommunity/typedoc-plugins/commit/2434d33399ec66e3c876e2a54cfa8a66bae77966))
* add search support ([08242d4](https://github.com/KnodesCommunity/typedoc-plugins/commit/08242d4449c84dd9bdf3af7c9c98dee496c15d59))
* add support for plugin-scoped log level ([48984d5](https://github.com/KnodesCommunity/typedoc-plugins/commit/48984d5aa67bde7c660e731200a0171b11f8e5a6))
* allow relative resolution of pages, add `~~` alias, change render link signature ([8676ae4](https://github.com/KnodesCommunity/typedoc-plugins/commit/8676ae47f068a1b6ec76f4dd245e80f5e08e2d09))
* fallback default theme: add css file, stylize menu entries ([4bc43f0](https://github.com/KnodesCommunity/typedoc-plugins/commit/4bc43f011496c971f73ae5230f79f30c806a66d0))
* remove `workspace` node field (attach to module by name), various tweaks & fixes ([31e906a](https://github.com/KnodesCommunity/typedoc-plugins/commit/31e906abeba79a39d6d31b4c2fd3686d2e0f15a0))
* strip empty groups with a warning message ([3a7733d](https://github.com/KnodesCommunity/typedoc-plugins/commit/3a7733d0a0f07f374ef367ecc723390d7d0550df))
* use new option format, fix issue with pages ordering, rework theme plugins ([0afdf9d](https://github.com/KnodesCommunity/typedoc-plugins/commit/0afdf9deb168f3330d3ee7e8c5ffdba81dc4f2ba))
* validate pages option ([1634a2e](https://github.com/KnodesCommunity/typedoc-plugins/commit/1634a2ee40b97dfff9c81f4574e9ca72c8df47fc))
* **dep: @knodes/typedoc-pluginutils**: add `name` getter on plugin ([335095a](https://github.com/KnodesCommunity/typedoc-plugins/commit/335095a976ecedab7d1cbb64a2a1de0e4e5e7b79))
* **dep: @knodes/typedoc-pluginutils**: add better support for modules in path reflection resolution ([ff0f7c7](https://github.com/KnodesCommunity/typedoc-plugins/commit/ff0f7c790c627a8308c00c8d5426d402657d11fa))
* **dep: @knodes/typedoc-pluginutils**: add option group, add resolvePackageFile ([878baf8](https://github.com/KnodesCommunity/typedoc-plugins/commit/878baf8f713cd1f307bcde2a909ae0257d835d73))
* **dep: @knodes/typedoc-pluginutils**: add package ([f6894ad](https://github.com/KnodesCommunity/typedoc-plugins/commit/f6894ad003e7f4336407238bc6dea1fd4d9c9101))
* **dep: @knodes/typedoc-pluginutils**: add PathReflectionResolver, add plugin.relativeToRoot, use in MarkdownReplacer ([40eb1a1](https://github.com/KnodesCommunity/typedoc-plugins/commit/40eb1a1c2dca89cae27625f4234316166c652706))
* **dep: @knodes/typedoc-pluginutils**: add rootDir on plugin, add CurrentPageMemo, add MarkdownReplacer, improve Logger ([200f52f](https://github.com/KnodesCommunity/typedoc-plugins/commit/200f52f8417865734c19ed6bc8d91128a2902abe))
* **dep: @knodes/typedoc-pluginutils**: add source map support in markdown replacer ([57e5e39](https://github.com/KnodesCommunity/typedoc-plugins/commit/57e5e3925725e58677038d9b2dc9943ac42b0c96))
* **dep: @knodes/typedoc-pluginutils**: fix `wrapError`, add helper `catchWrap` ([350fc9b](https://github.com/KnodesCommunity/typedoc-plugins/commit/350fc9b9281fce5b7bd7c98253af4a4ef8f66d79))


# 0.22.0 (2022-02-23)


## 0.0.1 (2022-02-23)


* include missing `static` folder in package files ([1889d89](https://github.com/KnodesCommunity/typedoc-plugins/commit/1889d8919b90bb8716bd9b6d97962bab5ad17132))
5 changes: 3 additions & 2 deletions packages/plugintestbed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ No notable changes were done in this version.
* add package ([fac9bfb](https://github.com/KnodesCommunity/typedoc-plugins/commit/fac9bfb31b40a52de790a990c7b5bc71dd354580))


# 0.22.0 (2022-02-23)
## 0.22.0 (2022-02-23)


## 0.0.1 (2022-02-23)
No notable changes were done in this version.


## 0.0.1 (2022-02-23)
31 changes: 1 addition & 30 deletions packages/pluginutils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,36 +78,7 @@ No notable changes were done in this version.
## [0.22.2](https://github.com/KnodesCommunity/typedoc-plugins/compare/v0.22.1...v0.22.2) (2022-03-06)


No notable changes were done in this version.


## 0.22.1 (2022-03-04)
**First release**


No notable changes were done in this version.


### Bug Fixes

* **monorepo**: fix events order, bind TypeDoc prototypes to watch custom events ([83ee577](https://github.com/KnodesCommunity/typedoc-plugins/commit/83ee5776cea435fd4b5d155d1bd96f99737a5063))
* **monorepo**: various reflection path resolution fixes, better test code blocks ([314f173](https://github.com/KnodesCommunity/typedoc-plugins/commit/314f173d5430f452a9924569db8f38575337c638))


### Features

* add `name` getter on plugin ([335095a](https://github.com/KnodesCommunity/typedoc-plugins/commit/335095a976ecedab7d1cbb64a2a1de0e4e5e7b79))
* add better support for modules in path reflection resolution ([ff0f7c7](https://github.com/KnodesCommunity/typedoc-plugins/commit/ff0f7c790c627a8308c00c8d5426d402657d11fa))
* add option group, add resolvePackageFile ([878baf8](https://github.com/KnodesCommunity/typedoc-plugins/commit/878baf8f713cd1f307bcde2a909ae0257d835d73))
* add package ([f6894ad](https://github.com/KnodesCommunity/typedoc-plugins/commit/f6894ad003e7f4336407238bc6dea1fd4d9c9101))
* add PathReflectionResolver, add plugin.relativeToRoot, use in MarkdownReplacer ([40eb1a1](https://github.com/KnodesCommunity/typedoc-plugins/commit/40eb1a1c2dca89cae27625f4234316166c652706))
* add rootDir on plugin, add CurrentPageMemo, add MarkdownReplacer, improve Logger ([200f52f](https://github.com/KnodesCommunity/typedoc-plugins/commit/200f52f8417865734c19ed6bc8d91128a2902abe))
* add source map support in markdown replacer ([57e5e39](https://github.com/KnodesCommunity/typedoc-plugins/commit/57e5e3925725e58677038d9b2dc9943ac42b0c96))
* fix `wrapError`, add helper `catchWrap` ([350fc9b](https://github.com/KnodesCommunity/typedoc-plugins/commit/350fc9b9281fce5b7bd7c98253af4a4ef8f66d79))


# 0.22.0 (2022-02-23)


## 0.0.1 (2022-02-23)


53 changes: 43 additions & 10 deletions tools/sync-proto-modules/changelog.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
const { readFile } = require( 'fs/promises' );
const { readFile, writeFile } = require( 'fs/promises' );
const { resolve } = require( 'path' );

const { isString } = require( 'lodash' );
const { isString, escapeRegExp } = require( 'lodash' );

const { resolveRoot } = require( '../utils' );
const { syncFile } = require( './utils' );
const { resolveRoot, spawn, captureStream } = require( '../utils' );
const { syncFile, tryReadFile } = require( './utils' );

const getOldestVersion = async pkgName => {
try {
const out = await spawn( 'npm', [ 'show', pkgName, 'versions', '--json' ], { stdio: [ null, captureStream(), captureStream() ] } );
const versions = JSON.parse( out.stdout );
return versions[0];
} catch( e ){
if( e.code === 1 && e.stderr.match( new RegExp( `404\\s+'${escapeRegExp( pkgName )}@latest' is not in this registry.` ) ) ){
return null;
}
throw e;
}
};

/**
* @param {boolean} checkOnly
* @returns {import('./utils').ProtoHandler<string[]>}
* @returns {import('./utils').ProtoHandler<{changelog: string[], oldestVersionCache: Record<string, string|undefined>>}
*/
module.exports.changelog = async checkOnly => ( {
setup: async () => ( await readFile( resolve( __dirname, '../../CHANGELOG.md' ), 'utf-8' ) ).split( '\n' ),
run: async ( _, project, projects, ___, fullChangelogStrs ) => {
const { path, pkgJson, id } = project;
setup: async ( _, projects ) => ( {
changelog: ( await readFile( resolve( __dirname, '../../CHANGELOG.md' ), 'utf-8' ) ).split( '\n' ),
oldestVersionCache: Object.assign(
Object.fromEntries( projects.filter( p => p.pkgJson.private ).map( p => [ p.pkgName, '0.0.0' ] ) ),
JSON.parse( await tryReadFile( resolve( __dirname, '.changelog-cache.json' ) ) ?? '{}' ),
),
} ),
run: async ( _, project, projects, ___, { changelog: fullChangelogStrs, oldestVersionCache } ) => {
const { path, pkgJson, pkgName, id } = project;
if( !( pkgName in oldestVersionCache ) ){
oldestVersionCache[pkgName] = await getOldestVersion( pkgName );
if( !oldestVersionCache[pkgName] ){
delete oldestVersionCache[pkgName];
}
}
const packagesIds = projects.map( p => ( { isDep: p.pkgName in ( pkgJson.dependencies ?? {} ), ...p } ) );
const pkgChangelog = fullChangelogStrs
const pkgChangelogFull = fullChangelogStrs
.map( l => {
const match = l.match( /^\* (?:\*\*(.*?)\*\*: )?(.*)/ );
if( match ){
Expand All @@ -42,6 +67,14 @@ module.exports.changelog = async checkOnly => ( {
.replace( /^### .*(\n*)^(?=#)/gm, '' )
.replace( /^(## .*)(\n*)^(?=##)/gm, '$1\n\n\nNo notable changes were done in this version.\n\n\n' )
.replace( /\n{4,}/g, '\n\n\n' );
await syncFile( checkOnly, resolveRoot( path, 'CHANGELOG.md' ), pkgChangelog );
const firstVersion = oldestVersionCache[pkgName];
const pkgChangelogFromFirstVersion = firstVersion ?
pkgChangelogFull.replace(
new RegExp( `(\n## .*\\W?${escapeRegExp( firstVersion )}\\W.*)\n((?:.|\n)*?\n)(## (.|\n)*)$` ),
'$1\n\n\n**First release**\n$2' ) :
pkgChangelogFull;
const changelogPath = resolveRoot( path, 'CHANGELOG.md' );
await syncFile( checkOnly, changelogPath, `${pkgChangelogFromFirstVersion.trim() }\n` );
},
tearDown: ( _, __, ___, { oldestVersionCache } ) => writeFile( resolve( __dirname, '.changelog-cache.json' ), JSON.stringify( oldestVersionCache, null, 4 ), 'utf-8' ),
} );
20 changes: 14 additions & 6 deletions tools/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ const spawn = ( cmd, args, opts = {} ) => new Promise( ( res, rej ) => {
stdio[1] instanceof Writable && p.stdout.pipe( stdio[1] );
stdio[2] instanceof Writable && p.stderr.pipe( stdio[2] );
}
p.on( 'close', code => code !== 0 ?
rej( new Error( `Exit code ${code}: ${JSON.stringify( {
cmd: [ cmd, ...args ],
cwd: opts.cwd,
} )}` ) ) : res( omitBy( {
p.on( 'close', code => {
const out = omitBy( {
stdout: stdio?.[1]?.CAPTURE === true ? stdio[1].read() : undefined,
stderr: stdio?.[2]?.CAPTURE === true ? stdio[2].read() : undefined,
}, isNil ) ) );
code,
}, isNil );
if( code !== 0 ) {
const err = new Error( `Exit code ${code}: ${JSON.stringify( {
cmd: [ cmd, ...args ],
cwd: opts.cwd,
} )}` );
return rej( Object.assign( err, out ) );
} else {
return res( out );
}
} );
} );
module.exports.spawn = spawn;

Expand Down

0 comments on commit 86cb221

Please sign in to comment.