From f907f8c6ad490d9da6727fc99c89e4ec4cf1aa88 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 7 Mar 2025 19:15:53 -0500 Subject: [PATCH 01/11] build: add option to parse-commits utility to set git log flags --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../_tools/changelog/generate/README.md | 48 +++++- .../changelog/generate/examples/index.js | 13 +- .../_tools/changelog/generate/lib/main.js | 40 ++++- .../_tools/changelog/generate/lib/validate.js | 74 ++++++++++ .../_tools/changelog/generate/test/test.js | 33 ++++- .../changelog/generate/test/test.validate.js | 137 ++++++++++++++++++ .../_tools/changelog/parse-commits/README.md | 7 +- .../changelog/parse-commits/examples/index.js | 6 +- .../changelog/parse-commits/lib/commits.js | 11 +- .../changelog/parse-commits/lib/defaults.js | 3 +- .../changelog/parse-commits/lib/main.js | 4 +- .../changelog/parse-commits/lib/validate.js | 8 + .../parse-commits/scripts/commits.sh | 4 +- .../parse-commits/test/test.validate.js | 25 ++++ .../_tools/scripts/publish_packages.js | 4 +- 15 files changed, 390 insertions(+), 27 deletions(-) create mode 100644 lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js create mode 100644 lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index 007011a6cb82..a846d5871700 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -30,7 +30,7 @@ limitations under the License. var generate = require( '@stdlib/_tools/changelog/generate' ); ``` -#### generate( pkg\[, releaseType] ) +#### generate( pkg\[, options] ) Generates a Markdown formatted changelog for a specified package. @@ -44,13 +44,22 @@ The function returns an object with the following properties: - **content**: Markdown formatted changelog. - **releaseType**: release type (`null` if changelog is for a non-release). -To generate a changelog for an upcoming release, provide a valid release type as the second argument. +The function accepts the following `options`: + +- **releaseType**: a release type for which to generate the changelog for. +- **flags**: `git log` options used to retrieve commits to generate the changelog for. + +By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: ```javascript -var changelog = generate( '@stdlib/assert/contains', 'patch' ); +var changelog = generate( '@stdlib/assert/contains', { + 'releaseType': 'patch' +}); // returns {...} -changelog = generate( '@stdlib/assert/contains', 'minor' ); +changelog = generate( '@stdlib/assert/contains', { + 'releaseType': 'minor' +}); // returns {...} ``` @@ -66,6 +75,24 @@ The following release types are supported: - `auto`: automatically determine the release type based on parsed commit messages. - `none`: no release (equivalent to not specifying a release type). +Under the hood, the changelog leverages `git log` to retrieve the commits from which to assemble the changelog. The `flags` option allows passing any options to the `git log` command, e.g. to generate a changelog for a specified time interval or for an individual contributor. + +```js +var changelog = generate( '@stdlib/ndarray', { + 'flags': { + 'since': 'last month' + } +}); +// returns {...} + +changelog = generate( '@stdlib/ndarray', { + 'flags': { + 'author': 'Athan Reines ' + } +}); +// returns {...} +``` + @@ -92,7 +119,9 @@ var releaseType = changelog.releaseType; // returns null // Generate a changelog for a new release: -changelog = generate( '@stdlib/utils/curry', 'patch' ); +changelog = generate( '@stdlib/utils/curry', { + 'releaseType': 'patch' +}); content = changelog.content; // returns '...' @@ -103,6 +132,15 @@ releaseType = changelog.releaseType; changelog = generate( '@stdlib/string/base' ); content = changelog.content; // returns '...' + +// Generate a changelog restricted to a single author: +changelog = generate( '@stdlib/string/base', { + 'flags': { + 'author': 'Athan Reines ' + } +}); +content = changelog.content; +// returns '...' ``` diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/examples/index.js b/lib/node_modules/@stdlib/_tools/changelog/generate/examples/index.js index 43b3f5f8ead8..5c52da09fa3d 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/examples/index.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/examples/index.js @@ -31,7 +31,9 @@ console.log( releaseType ); // => null // Generate a changelog for a new release: -changelog = generate( '@stdlib/utils/curry', 'patch' ); +changelog = generate( '@stdlib/utils/curry', { + 'releaseType': 'patch' +}); content = changelog.content; console.log( content ); // => '...' @@ -45,3 +47,12 @@ changelog = generate( '@stdlib/string/base' ); content = changelog.content; console.log( content ); // => '...' + +// Generate a changelog restricted to a single author: +changelog = generate( '@stdlib/string/base', { + 'flags': { + 'author': 'Athan Reines ' + } +}); +content = changelog.content; +console.log( content ); diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js index de02c8b74f16..26381f49a7a9 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js @@ -48,6 +48,7 @@ var formatCommits = require( './format_commits.js' ); var npmReleases = require( './npm_releases.js' ); var sectionStart = require( './section_start.js' ); var sectionEnd = require( './section_end.js' ); +var validate = require( './validate.js' ); var heading = require( './heading.js' ); @@ -208,7 +209,9 @@ function packageSummaryWrapper( pkg, version, name, summary ) { * Generates a Markdown formatted changelog for a specified stdlib package. * * @param {string} pkg - package name -* @param {string} [releaseType] - release type (`patch`, `minor`, `major`, `prerelease`, `prepatch`, `preminor`, `premajor`, or `auto`) +* @param {Options} options - function options +* @param {string} [options.releaseType] - release type (`patch`, `minor`, `major`, `prerelease`, `prepatch`, `preminor`, `premajor`, or `auto`) +* @param {Options} [options.flags] - `git log` options used to retrieve commits * @throws {TypeError} must provide a string * @throws {Error} must provide a valid package name * @throws {TypeError} must provide a recognized release type @@ -227,18 +230,23 @@ function packageSummaryWrapper( pkg, version, name, summary ) { * // returns {...} * * @example -* var changelog = generate( '@stdlib/utils/curry', 'patch' ); +* var changelog = generate( '@stdlib/utils/curry', { +* 'releaseType': 'patch' +* }); * // returns {...} * * @example -* var changelog = generate( '@stdlib/utils/curry', 'major' ); +* var changelog = generate( '@stdlib/utils/curry', { +* 'releaseType': 'major' +* }); * // returns {...} */ -function generate( pkg, releaseType ) { +function generate( pkg, options ) { var isNamespacePkg; var releaseCommits; var newestRelease; var bySubpackage; + var releaseType; var nextVersion; var standalone; var unreleased; @@ -247,14 +255,24 @@ function generate( pkg, releaseType ) { var commits; var version; var summary; + var opts; var name; var str; + var err; var i; var j; if ( !isString( pkg ) ) { throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', pkg ) ); } + opts = {}; + if ( arguments.length > 1 ) { + err = validate( opts, options ); + if ( err ) { + throw err; + } + } + if ( pkg === '@stdlib' || pkg === '@stdlib/stdlib' ) { // Case: root package isNamespacePkg = true; @@ -275,9 +293,16 @@ function generate( pkg, releaseType ) { str = '# CHANGELOG\n\n'; str += '> Package changelog.\n\n'; - commits = parseCommits({ - 'dir': join( STDLIB_LIB_DIR, pkg ) - }); + if ( opts.flags ) { + commits = parseCommits({ + 'dir': join( STDLIB_LIB_DIR, pkg ), + 'flags': opts.flags + }); + } else { + commits = parseCommits({ + 'dir': join( STDLIB_LIB_DIR, pkg ) + }); + } if ( commits.length === 0 ) { throw new Error( format( 'invalid argument. Unable to parse commits for package: `%s`.', pkg ) ); } @@ -291,6 +316,7 @@ function generate( pkg, releaseType ) { commits.unreleased = []; } + releaseType = opts.releaseType; if ( releaseType === 'auto' ) { releaseType = recommendVersionBump( commits.unreleased ); diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js new file mode 100644 index 000000000000..3c33ac16253f --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isObject = require( '@stdlib/assert/is-plain-object' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Validates function options. +* +* @private +* @param {Object} opts - destination for function options +* @param {Options} options - function options +* @param {string} [options.releaseType] - release type +* @param {string} [options.flags] - `git log` options used to retrieve commits +* @returns {(Error|null)} error or null +* +* @example +* var opts = {}; +* var options = { +* 'month': '01-2025' +* }; +* var err = validate( opts, options ); +* if ( err ) { +* throw err; +* } +*/ +function validate( opts, options ) { + if ( !isObject( options ) ) { + return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + if ( hasOwnProp( options, 'releaseType' ) ) { + opts.releaseType = options.releaseType; + if ( !isString( opts.releaseType ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'releaseType', opts.releaseType ) ); + } + } + if ( hasOwnProp( options, 'flags' ) ) { + opts.flags = options.flags; + if ( !isPlainObject( opts.flags ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'flags', opts.flags ) ); + } + } + return null; +} + + +// EXPORTS // + +module.exports = validate; diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js index 9e40c88bea17..c90ae09fe038 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js @@ -101,7 +101,9 @@ tape( 'the function throws an error if provided an invalid release type', functi function badValue( value ) { return function badValue() { - generate( '@stdlib/utils/curry', value ); + generate( '@stdlib/utils/curry', { + 'releaseType': value + }); }; } }); @@ -126,17 +128,23 @@ tape( 'the function generates a changelog', function test( t ) { }); tape( 'the function generates a changelog for a new release', function test( t ) { - var out = generate( '@stdlib/utils/noop', 'patch' ); + var out = generate( '@stdlib/utils/noop', { + 'releaseType': 'patch' + }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); t.strictEqual( out.releaseType, 'patch', 'returns expected value' ); - out = generate( '@stdlib/utils/noop', 'minor' ); + out = generate( '@stdlib/utils/noop', { + 'releaseType': 'minor' + }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); t.strictEqual( out.releaseType, 'minor', 'returns expected value' ); - out = generate( '@stdlib/utils/noop', 'major' ); + out = generate( '@stdlib/utils/noop', { + 'releaseType': 'major' + }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); t.strictEqual( out.releaseType, 'major', 'returns expected value' ); @@ -145,13 +153,26 @@ tape( 'the function generates a changelog for a new release', function test( t ) }); tape( 'the function generates a changelog for a new release (auto)', function test( t ) { - var out = generate( '@stdlib/utils/noop', 'auto' ); + var out = generate( '@stdlib/utils/noop', { + 'releaseType': 'auto' + }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); - out = generate( '@stdlib/array/base/slice', 'auto' ); + out = generate( '@stdlib/array/base/slice', { + 'releaseType': 'auto' + }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); t.end(); }); + +tape( 'the function generates a changelog for a specific author', function test( t ) { + var out = generate( '@stdlib/ndarray/base', { + 'flags': '--author="Athan Reines"' + }); + t.strictEqual( isObject( out ), true, 'returns expected value' ); + t.strictEqual( typeof out.content, 'string', 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js new file mode 100644 index 000000000000..aa124f8c6fa7 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js @@ -0,0 +1,137 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var validate = require( './../lib/validate.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.equal( typeof validate, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an error if not provided an options object', function test( t ) { + var values; + var err; + var i; + + values = [ + '5', + 5, + NaN, + true, + null, + void 0, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + err = validate( {}, values[ i ] ); + t.ok( err instanceof TypeError, 'returns a type error when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns an error if provided a `releaseType` option which is not a string primitive', function test( t ) { + var values; + var err; + var i; + + values = [ + true, + 5, + NaN, + null, + void 0, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + err = validate( {}, { + 'releaseType': values[ i ] + }); + t.ok( err instanceof TypeError, 'returns a type error when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns an error if provided a `flags` option which is not a plain object', function test( t ) { + var values; + var err; + var i; + + values = [ + true, + 5, + NaN, + null, + void 0, + 'abc', + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + err = validate( {}, { + 'flags': values[ i ] + }); + t.ok( err instanceof TypeError, 'returns a type error when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `null` if all options are valid', function test( t ) { + var opts; + var err; + var obj; + + opts = { + 'releaseType': 'auto' + }; + obj = {}; + err = validate( obj, opts ); + t.equal( err, null, 'returns null' ); + t.equal( obj.copy, opts.copy, 'sets copy option' ); + t.end(); +}); + +tape( 'the function ignores unrecognized options', function test( t ) { + var opts; + var err; + var obj; + + opts = { + 'beep': 'boop', + 'a': 'b' + }; + obj = {}; + err = validate( obj, opts ); + t.equal( err, null, 'returns null' ); + t.deepEqual( obj, {}, 'does not set any properties' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md index 9a6ea4f2dd0b..a199edb51734 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md @@ -44,6 +44,7 @@ The function accepts the following `options`: - **dir**: directory for which to parse commits. May be either an absolute path or a path relative to the current working directory. Default: current working directory. - **issueURL**: issue URL. Default: `https://github.com/stdlib-js/stdlib/issues/`. - **prURL**: pull request URL. Default: `https://github.com/stdlib-js/stdlib/pull/`. +- **flags**: Options passed to invoked `git log` command to retrieve commit messages. @@ -62,7 +63,11 @@ The function accepts the following `options`: ```javascript var parseCommits = require( '@stdlib/_tools/changelog/parse-commits' ); -var commits = parseCommits(); +var commits = parseCommits({ + 'flags': { + 'since': 'last year' + } +}); // returns [...] commits = parseCommits({ diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/examples/index.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/examples/index.js index 838b1b835887..ca0831204faf 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/examples/index.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/examples/index.js @@ -20,7 +20,11 @@ var parseCommits = require( './../lib' ); -var commits = parseCommits(); +var commits = parseCommits({ + 'flags': { + 'since': 'last year' + } +}); console.log( commits ); // => [...] diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js index 7ae85551f7fd..587076353421 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js @@ -76,13 +76,15 @@ function extractYAMLBlock( str ) { * * @private * @param {string} dir - directory for which to extract commit details +* @param {string} flags - `git log` options * @returns {Array} array of commit details * * @example * var commits = extractCommits( '.' ); * // returns [...] */ -function extractCommits( dir ) { +function extractCommits( dir, flags ) { + var flagNames; var commits; var author; var parsed; @@ -110,6 +112,12 @@ function extractCommits( dir ) { cmd = join( __dirname, '..', 'scripts', 'commits.sh' ); commits = []; args = [ resolve( dir ) ]; + if ( flags ) { + flagNames = Object.keys( flags ); + for ( i = 0; i < flagNames.length; i++ ) { + args.push( '--'+flagNames[i]+'='+flags[ flagNames[ i ] ] ); + } + } try { out = spawn( cmd, args, opts ); } catch ( err ) { @@ -117,6 +125,7 @@ function extractCommits( dir ) { return commits; } out = trim( out.stdout.toString() ); + lines = out.split( GIT_COMMIT_SEP ); for ( i = 0; i < lines.length; i++ ) { if ( !lines[ i ] ) { diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/defaults.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/defaults.js index 0783ec1d2621..b95ab82a62a4 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/defaults.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/defaults.js @@ -29,7 +29,8 @@ function defaults() { return { 'issueURL': 'https://github.com/stdlib-js/stdlib/issues/', - 'prURL': 'https://github.com/stdlib-js/stdlib/pull/' + 'prURL': 'https://github.com/stdlib-js/stdlib/pull/', + 'flags': {} }; } diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js index 8a2290d476de..8a5166e5a8b0 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js @@ -45,12 +45,14 @@ var debug = logger( 'changelog:parse-commits' ); * @param {string} [options.dir] - root directory * @param {string} [options.issueURL] - issue URL * @param {string} [options.prURL] - PR URL +* @param {string} [options.flags] - `git log` options * @throws {TypeError} options argument must be an object * @throws {TypeError} must provide valid options * @returns {Array} array of conventional changelog formatted commit message objects * * @example * var resolve = require( 'path' ).resolve; +* * var out = parseCommits({ * 'dir': resolve( __dirname, '..', '..' ) * }); @@ -79,7 +81,7 @@ function parseCommits( options ) { } else { dir = cwd(); } - commits = extractCommits( dir ); + commits = extractCommits( dir, opts.flags ); out = []; for ( i = 0; i < commits.length; i++ ) { msg = commits[ i ].message; diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js index e0ac9d12c673..c0c2e603ef01 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js @@ -22,6 +22,7 @@ var isObject = require( '@stdlib/assert/is-plain-object' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var format = require( '@stdlib/string/format' ); @@ -37,6 +38,7 @@ var format = require( '@stdlib/string/format' ); * @param {string} [options.dir] - root directory * @param {string} [options.issueURL] - issue URL * @param {string} [options.prURL] - PR URL +* @param {Options} [options.flags] - `git log` options * @returns {(null|Error)} null or an error */ function validate( opts, options ) { @@ -61,6 +63,12 @@ function validate( opts, options ) { return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'prURL', opts.prURL ) ); } } + if ( hasOwnProp( options, 'flags' ) ) { + opts.flags = options.flags; + if ( !isPlainObject( opts.flags ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'flags', opts.flags ) ); + } + } return null; } diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/scripts/commits.sh b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/scripts/commits.sh index ec2094057b68..fae7c888b62c 100755 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/scripts/commits.sh +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/scripts/commits.sh @@ -35,7 +35,7 @@ if [ -z "$1" ]; then fi if [ -z "$GIT_COMMIT_SEP" ]; then - GIT_COMMIT_SEP="^---^"; # Default separator + GIT_COMMIT_SEP="^---^"; # Default separator fi -git log --name-only --no-merges --notes --pretty=format:"%H|%ad|%aN <%aE>|%B|%N|" "$1" | awk -v sep="$GIT_COMMIT_SEP" '/^$/{p=1;next} /^[0-9a-f]{40}\|/{if (p==1) print sep; p=0} {print}'; +git log "${@:2}" --name-only --no-merges --notes --pretty=format:"%H|%ad|%aN <%aE>|%B|%N|" "$1" | awk -v sep="$GIT_COMMIT_SEP" '/^$/{p=1;next} /^[0-9a-f]{40}\|/{if (p==1) print sep; p=0} {print}'; diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js index edec79b98f5c..afd2a108deeb 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js @@ -138,6 +138,31 @@ tape( 'if provided a `prURL` option which is not a `string`, the function return t.end(); }); +tape( 'the function returns an error if provided a `flags` option which is not a plain object', function test( t ) { + var values; + var err; + var i; + + values = [ + true, + 5, + NaN, + null, + void 0, + 'abc', + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + err = validate( {}, { + 'flags': values[ i ] + }); + t.ok( err instanceof TypeError, 'returns a type error when provided ' + values[ i ] ); + } + t.end(); +}); + tape( 'the function returns `null` if all options are valid', function test( t ) { var opts; var obj; diff --git a/lib/node_modules/@stdlib/_tools/scripts/publish_packages.js b/lib/node_modules/@stdlib/_tools/scripts/publish_packages.js index 61e1e1a6b2e9..bf8e0410d414 100644 --- a/lib/node_modules/@stdlib/_tools/scripts/publish_packages.js +++ b/lib/node_modules/@stdlib/_tools/scripts/publish_packages.js @@ -685,7 +685,9 @@ function publish( pkg, clbk ) { return invokeCallback( null, 'skipped' ); } - changelog = generateChangelog( '@stdlib/'+pkg, flags[ 'release-type' ] ); + changelog = generateChangelog( '@stdlib/'+pkg, { + 'releaseType': flags[ 'release-type' ] + }); releaseType = changelog.releaseType; mainJSON = readJSON( join( mainDir, 'package.json' ) ); From ef6719ed13a8d86ac0df982afb87cbc042fdb9fa Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 14 Mar 2025 22:35:10 -0400 Subject: [PATCH 02/11] build: tweak output when flags are supplied and add workflow --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../workflows/generate_monthly_changelog.yml | 136 ++++++++++++++++++ .../_tools/changelog/generate/README.md | 2 + .../_tools/changelog/generate/lib/main.js | 7 +- 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/generate_monthly_changelog.yml diff --git a/.github/workflows/generate_monthly_changelog.yml b/.github/workflows/generate_monthly_changelog.yml new file mode 100644 index 000000000000..aeb77dc3dfb8 --- /dev/null +++ b/.github/workflows/generate_monthly_changelog.yml @@ -0,0 +1,136 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Workflow name: +name: generate_monthly_changelog + +# Workflow triggers: +on: + # Run the workflow at midnight UTC on the first day of each month: + schedule: + - cron: '0 0 1 * *' + + # Allow the workflow to be manually run: + workflow_dispatch: + +# Global permissions: +permissions: + # Allow read-only access to the repository contents: + contents: read + +# Workflow jobs: +jobs: + # Generate a monthly changelog: + generate-monthly-changelog: + # Define a display name: + name: 'Generate Monthly Changelog' + + # Define the type of virtual host machine: + runs-on: ubuntu-latest + + # Workflow steps: + steps: + - name: 'Checkout source repository' + # Pin action to full length commit SHA + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + # Specify whether to remove untracked files before checking out the repository: + clean: false + + # Limit clone depth to the most recent commit: + fetch-depth: 1 + + # Token for accessing the repository: + token: ${{ secrets.STDLIB_BOT_FGPAT_REPO_READ }} + + # Avoid storing GitHub token in local Git configuration: + persist-credentials: false + + # Install Node.js: + - name: 'Install Node.js' + # Pin action to full length commit SHA + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + with: + node-version: '20' # 'lts/*' + timeout-minutes: 5 + + # Install dependencies (accounting for possible network failures, etc, when installing node module dependencies): + - name: 'Install dependencies' + run: | + make install-node-modules || make install-node-modules || make install-node-modules + timeout-minutes: 15 + + - name: 'Checkout monthly changelog repository' + # Pin action to full length commit SHA + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + # Code coverage repository: + repository: 'stdlib-js/www-blog-monthly-changelog' + + # File path to checkout to: + path: './www-blog-monthly-changelog' + + # Specify whether to remove untracked files before checking out the repository: + clean: false + + # Limit clone depth to the most recent commit: + fetch-depth: 1 + + # Token for accessing the repository: + token: ${{ secrets.STDLIB_BOT_FGPAT_REPO_READ }} + + # Avoid storing GitHub token in local Git configuration: + persist-credentials: false + + # Generate changelog for last month: + - name: 'Generate changelog for last month' + run: | + UNTIL=$(date +"%Y-%m-01") + node -e " + var generate = require( '@stdlib/_tools/changelog/generate' ); + var changelog = generate( '@stdlib', { + 'flags': { + 'since': '$UNTIL - 1 week', + 'until': '$UNTIL' + } + }); + console.log( changelog.content ); + " > ./www-blog-monthly-changelog/monthly_changelog_$UNTIL.md + + # Import GPG key to sign commits: + - name: 'Import GPG key to sign commits' + # Pin action to full length commit SHA + uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 + with: + gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + + # Commit and push changes: + - name: 'Commit and push changes' + env: + REPO_GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} + USER_NAME: stdlib-bot + run: | + cd ./www-blog-monthly-changelog + git config --local user.email "82920195+stdlib-bot@users.noreply.github.com" + git config --local user.name "stdlib-bot" + git add . + git commit -m "Add monthly changelog" || exit 0 + git push "https://$USER_NAME:$REPO_GITHUB_TOKEN@github.com/stdlib-js/www-blog-monthly-changelog.git" main diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index a846d5871700..b9c7ee017aef 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -99,6 +99,8 @@ changelog = generate( '@stdlib/ndarray', {
+- When `flags` are supplied, the generated changelog skips printing empty releases and uses a flat output format. +
diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js index 26381f49a7a9..f1e63df19126 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js @@ -341,7 +341,7 @@ function generate( pkg, options ) { } } - if ( isNamespacePkg ) { + if ( isNamespacePkg && !opts.flags ) { str += releaseSectionStart( nextVersion ); str += '## ' + ( nextVersion || 'Unreleased' ) + ' (' + formatDate() + ')\n\n'; if ( commits.unreleased.length > 0 ) { @@ -374,7 +374,7 @@ function generate( pkg, options ) { str += sectionEnd( 'release' ); } } - if ( isNamespacePkg ) { + if ( isNamespacePkg && !opts.flags ) { for ( i = releases.length-1; i >= 0; i-- ) { version = releases[ i ][ 0 ]; str += releaseSectionStart( version ); @@ -407,6 +407,9 @@ function generate( pkg, options ) { version = releases[ i ][ 0 ]; summary = releaseSummary( commits[ version ] ); if ( !summary ) { + if ( opts.flags ) { + continue; + } summary = PLACEHOLDER_SUMMARY; } str += releaseSectionStart( version ); From 7c0695e838373ad614e7e3f36c26377faf9e876e Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 19 Apr 2025 17:26:09 -0400 Subject: [PATCH 03/11] chore: apply suggestions from code review Co-authored-by: Athan Signed-off-by: Philipp Burckhardt --- .../@stdlib/_tools/changelog/generate/README.md | 10 +++++----- .../@stdlib/_tools/changelog/generate/lib/validate.js | 2 +- .../_tools/changelog/generate/test/test.validate.js | 4 ++-- .../@stdlib/_tools/changelog/parse-commits/README.md | 2 +- .../_tools/changelog/parse-commits/lib/validate.js | 2 +- .../changelog/parse-commits/test/test.validate.js | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index b9c7ee017aef..a0d685160f83 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -46,8 +46,8 @@ The function returns an object with the following properties: The function accepts the following `options`: -- **releaseType**: a release type for which to generate the changelog for. -- **flags**: `git log` options used to retrieve commits to generate the changelog for. +- **releaseType**: a release type for which to generate the changelog. +- **flags**: `git log` options used to retrieve commits from which to generate the changelog. By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: @@ -75,9 +75,9 @@ The following release types are supported: - `auto`: automatically determine the release type based on parsed commit messages. - `none`: no release (equivalent to not specifying a release type). -Under the hood, the changelog leverages `git log` to retrieve the commits from which to assemble the changelog. The `flags` option allows passing any options to the `git log` command, e.g. to generate a changelog for a specified time interval or for an individual contributor. +When generating a changelog, the function uses `git log` to retrieve the commits from which to assemble a set of changes. The `flags` option allows passing options to directly to the `git log` command (e.g., to generate a changelog for a specified time interval or for an individual contributor). -```js +```javascript var changelog = generate( '@stdlib/ndarray', { 'flags': { 'since': 'last month' @@ -99,7 +99,7 @@ changelog = generate( '@stdlib/ndarray', {
-- When `flags` are supplied, the generated changelog skips printing empty releases and uses a flat output format. +- When `flags` are supplied, the generated changelog does not include empty releases and uses a flat output format.
diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js index 3c33ac16253f..337f42aaaa98 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js @@ -62,7 +62,7 @@ function validate( opts, options ) { if ( hasOwnProp( options, 'flags' ) ) { opts.flags = options.flags; if ( !isPlainObject( opts.flags ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'flags', opts.flags ) ); + return new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'flags', opts.flags ) ); } } return null; diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js index aa124f8c6fa7..843c413f3807 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js @@ -55,7 +55,7 @@ tape( 'the function returns an error if not provided an options object', functio t.end(); }); -tape( 'the function returns an error if provided a `releaseType` option which is not a string primitive', function test( t ) { +tape( 'the function returns an error if provided a `releaseType` option which is not a string', function test( t ) { var values; var err; var i; @@ -80,7 +80,7 @@ tape( 'the function returns an error if provided a `releaseType` option which is t.end(); }); -tape( 'the function returns an error if provided a `flags` option which is not a plain object', function test( t ) { +tape( 'the function returns an error if provided a `flags` option which is not an object', function test( t ) { var values; var err; var i; diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md index a199edb51734..9c22213c77a2 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md @@ -44,7 +44,7 @@ The function accepts the following `options`: - **dir**: directory for which to parse commits. May be either an absolute path or a path relative to the current working directory. Default: current working directory. - **issueURL**: issue URL. Default: `https://github.com/stdlib-js/stdlib/issues/`. - **prURL**: pull request URL. Default: `https://github.com/stdlib-js/stdlib/pull/`. -- **flags**: Options passed to invoked `git log` command to retrieve commit messages. +- **flags**: options passed to invoked `git log` command to retrieve commit messages. diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js index c0c2e603ef01..2319abc96f6c 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/validate.js @@ -66,7 +66,7 @@ function validate( opts, options ) { if ( hasOwnProp( options, 'flags' ) ) { opts.flags = options.flags; if ( !isPlainObject( opts.flags ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a plain object. Option: `%s`.', 'flags', opts.flags ) ); + return new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'flags', opts.flags ) ); } } return null; diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js index afd2a108deeb..bf4c5366e594 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/test/test.validate.js @@ -138,7 +138,7 @@ tape( 'if provided a `prURL` option which is not a `string`, the function return t.end(); }); -tape( 'the function returns an error if provided a `flags` option which is not a plain object', function test( t ) { +tape( 'the function returns an error if provided a `flags` option which is not an object', function test( t ) { var values; var err; var i; From c3ef6331f7b9d5d70a06c9a264dac9a202572084 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 19 Apr 2025 17:31:19 -0400 Subject: [PATCH 04/11] chore: address PR review feedback --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .github/workflows/generate_monthly_changelog.yml | 2 +- .../@stdlib/_tools/changelog/generate/test/test.js | 4 +++- .../@stdlib/_tools/changelog/parse-commits/lib/commits.js | 5 +++-- .../@stdlib/_tools/changelog/parse-commits/lib/main.js | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/generate_monthly_changelog.yml b/.github/workflows/generate_monthly_changelog.yml index aeb77dc3dfb8..0233198c2636 100644 --- a/.github/workflows/generate_monthly_changelog.yml +++ b/.github/workflows/generate_monthly_changelog.yml @@ -79,7 +79,7 @@ jobs: # Pin action to full length commit SHA uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - # Code coverage repository: + # Monthly changelog repository: repository: 'stdlib-js/www-blog-monthly-changelog' # File path to checkout to: diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js index c90ae09fe038..2d59f61c72b9 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.js @@ -170,7 +170,9 @@ tape( 'the function generates a changelog for a new release (auto)', function te tape( 'the function generates a changelog for a specific author', function test( t ) { var out = generate( '@stdlib/ndarray/base', { - 'flags': '--author="Athan Reines"' + 'flags': { + 'author': 'Athan Reines ' + } }); t.strictEqual( isObject( out ), true, 'returns expected value' ); t.strictEqual( typeof out.content, 'string', 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js index 587076353421..edef1abcb0dc 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js @@ -26,6 +26,7 @@ var spawn = require( 'child_process' ).spawnSync; // eslint-disable-line node/no var logger = require( 'debug' ); var parse = require( 'yaml' ).parse; var substringAfter = require( '@stdlib/string/substring-after' ); +var objectKeys = require( '@stdlib/utils/keys' ); var replace = require( '@stdlib/string/replace' ); var trim = require( '@stdlib/string/trim' ); var filterFiles = require( './filter_files.js' ); @@ -76,7 +77,7 @@ function extractYAMLBlock( str ) { * * @private * @param {string} dir - directory for which to extract commit details -* @param {string} flags - `git log` options +* @param {Object} flags - `git log` options * @returns {Array} array of commit details * * @example @@ -113,7 +114,7 @@ function extractCommits( dir, flags ) { commits = []; args = [ resolve( dir ) ]; if ( flags ) { - flagNames = Object.keys( flags ); + flagNames = objectKeys( flags ); for ( i = 0; i < flagNames.length; i++ ) { args.push( '--'+flagNames[i]+'='+flags[ flagNames[ i ] ] ); } diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js index 8a5166e5a8b0..113a0e7ebea4 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/main.js @@ -45,7 +45,7 @@ var debug = logger( 'changelog:parse-commits' ); * @param {string} [options.dir] - root directory * @param {string} [options.issueURL] - issue URL * @param {string} [options.prURL] - PR URL -* @param {string} [options.flags] - `git log` options +* @param {Object} [options.flags] - `git log` options * @throws {TypeError} options argument must be an object * @throws {TypeError} must provide valid options * @returns {Array} array of conventional changelog formatted commit message objects From 944d15034c47bfa1cd032d642d7fd88083de3f74 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 19 Apr 2025 18:01:16 -0400 Subject: [PATCH 05/11] build: add format option to changelog generation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- .../workflows/generate_monthly_changelog.yml | 3 +- .../_tools/changelog/generate/README.md | 19 ++++++++++++ .../_tools/changelog/generate/lib/main.js | 10 +++++-- .../_tools/changelog/generate/lib/validate.js | 13 +++++++++ .../changelog/generate/test/test.validate.js | 29 ++++++++++++++++++- 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate_monthly_changelog.yml b/.github/workflows/generate_monthly_changelog.yml index 0233198c2636..8c712a6be345 100644 --- a/.github/workflows/generate_monthly_changelog.yml +++ b/.github/workflows/generate_monthly_changelog.yml @@ -107,7 +107,8 @@ jobs: 'flags': { 'since': '$UNTIL - 1 week', 'until': '$UNTIL' - } + }, + 'format': 'aggregated' }); console.log( changelog.content ); " > ./www-blog-monthly-changelog/monthly_changelog_$UNTIL.md diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index a0d685160f83..441d6283267d 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -47,6 +47,7 @@ The function returns an object with the following properties: The function accepts the following `options`: - **releaseType**: a release type for which to generate the changelog. +- **format**: whether to generate a `grouped` changelog where commits are grouped by package or `aggregated` one. - **flags**: `git log` options used to retrieve commits from which to generate the changelog. By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: @@ -75,8 +76,26 @@ The following release types are supported: - `auto`: automatically determine the release type based on parsed commit messages. - `none`: no release (equivalent to not specifying a release type). +By default, the function generates a `grouped` changelog for namespace packages and an `aggregated` changelog for non-namespace packages. To specify a desired output format, set the `format` option: + +```javascript +// Changelog grouped by individual packages: +var changelog = generate( '@stdlib/math/base/utils', { + 'format': 'grouped' +}); +// returns {...} + +// Changelog where all commits, potentially touching many different packages, are merged together: +changelog = generate( '@stdlib/math/base/utils', { + 'format': 'aggregated' +}); +// returns {...} +``` + When generating a changelog, the function uses `git log` to retrieve the commits from which to assemble a set of changes. The `flags` option allows passing options to directly to the `git log` command (e.g., to generate a changelog for a specified time interval or for an individual contributor). + + ```javascript var changelog = generate( '@stdlib/ndarray', { 'flags': { diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js index f1e63df19126..7d8ba9b5ee20 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js @@ -211,6 +211,7 @@ function packageSummaryWrapper( pkg, version, name, summary ) { * @param {string} pkg - package name * @param {Options} options - function options * @param {string} [options.releaseType] - release type (`patch`, `minor`, `major`, `prerelease`, `prepatch`, `preminor`, `premajor`, or `auto`) +* @param {string} [options.format] - output format (`grouped` or `aggregated`) * @param {Options} [options.flags] - `git log` options used to retrieve commits * @throws {TypeError} must provide a string * @throws {Error} must provide a valid package name @@ -245,6 +246,7 @@ function generate( pkg, options ) { var isNamespacePkg; var releaseCommits; var newestRelease; + var outputFormat; var bySubpackage; var releaseType; var nextVersion; @@ -272,6 +274,10 @@ function generate( pkg, options ) { throw err; } } + outputFormat = opts.format; + if ( !outputFormat ) { + outputFormat = ( isNamespacePkg ) ? 'grouped' : 'aggregated'; + } if ( pkg === '@stdlib' || pkg === '@stdlib/stdlib' ) { // Case: root package @@ -341,7 +347,7 @@ function generate( pkg, options ) { } } - if ( isNamespacePkg && !opts.flags ) { + if ( outputFormat === 'grouped' ) { str += releaseSectionStart( nextVersion ); str += '## ' + ( nextVersion || 'Unreleased' ) + ' (' + formatDate() + ')\n\n'; if ( commits.unreleased.length > 0 ) { @@ -374,7 +380,7 @@ function generate( pkg, options ) { str += sectionEnd( 'release' ); } } - if ( isNamespacePkg && !opts.flags ) { + if ( outputFormat === 'grouped' ) { for ( i = releases.length-1; i >= 0; i-- ) { version = releases[ i ][ 0 ]; str += releaseSectionStart( version ); diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js index 337f42aaaa98..71f3a70c2fd5 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js @@ -24,9 +24,15 @@ var isObject = require( '@stdlib/assert/is-plain-object' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var indexOf = require( '@stdlib/utils/index-of' ); var format = require( '@stdlib/string/format' ); +// VARIABLES // + +var FORMAT_OPTIONS = [ 'grouped', 'aggregated' ]; + + // MAIN // /** @@ -36,6 +42,7 @@ var format = require( '@stdlib/string/format' ); * @param {Object} opts - destination for function options * @param {Options} options - function options * @param {string} [options.releaseType] - release type +* @param {string} [options.format] - output format (`grouped` or `aggregated`) * @param {string} [options.flags] - `git log` options used to retrieve commits * @returns {(Error|null)} error or null * @@ -59,6 +66,12 @@ function validate( opts, options ) { return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'releaseType', opts.releaseType ) ); } } + if ( hasOwnProp( options, 'format' ) ) { + opts.format = options.format; + if ( indexOf( FORMAT_OPTIONS, opts.format ) === -1 ) { + return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', FORMAT_OPTIONS.join( '", "' ), opts.format ) ); + } + } if ( hasOwnProp( options, 'flags' ) ) { opts.flags = options.flags; if ( !isPlainObject( opts.flags ) ) { diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js index 843c413f3807..d6eb7dc762ed 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/test/test.validate.js @@ -80,6 +80,32 @@ tape( 'the function returns an error if provided a `releaseType` option which is t.end(); }); +tape( 'the function returns an error if provided a `format` option which is not a recognized format option', function test( t ) { + var values; + var err; + var i; + + values = [ + true, + 5, + NaN, + null, + void 0, + {}, + [], + function noop() {}, + 'abc' + ]; + + for ( i = 0; i < values.length; i++ ) { + err = validate( {}, { + 'format': values[ i ] + }); + t.ok( err instanceof TypeError, 'returns a type error when provided ' + values[ i ] ); + } + t.end(); +}); + tape( 'the function returns an error if provided a `flags` option which is not an object', function test( t ) { var values; var err; @@ -111,7 +137,8 @@ tape( 'the function returns `null` if all options are valid', function test( t ) var obj; opts = { - 'releaseType': 'auto' + 'releaseType': 'auto', + 'format': 'grouped' }; obj = {}; err = validate( obj, opts ); From b2fcb9bd0c2205054f86361fe2971c64cb5ee035 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 22 Apr 2025 21:23:35 -0400 Subject: [PATCH 06/11] chore: apply suggestions from code review Co-authored-by: Athan Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/_tools/changelog/generate/README.md | 5 ++++- .../@stdlib/_tools/changelog/parse-commits/README.md | 2 +- .../@stdlib/_tools/changelog/parse-commits/lib/commits.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index 441d6283267d..a9fb91f8f606 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -47,7 +47,10 @@ The function returns an object with the following properties: The function accepts the following `options`: - **releaseType**: a release type for which to generate the changelog. -- **format**: whether to generate a `grouped` changelog where commits are grouped by package or `aggregated` one. +- **format**: changelog format. Must be one of the following: + + - `'grouped'`: group commits by package. + - `'aggregated'`: TODO:add description. - **flags**: `git log` options used to retrieve commits from which to generate the changelog. By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md index 9c22213c77a2..e114ae1d8d03 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/README.md @@ -44,7 +44,7 @@ The function accepts the following `options`: - **dir**: directory for which to parse commits. May be either an absolute path or a path relative to the current working directory. Default: current working directory. - **issueURL**: issue URL. Default: `https://github.com/stdlib-js/stdlib/issues/`. - **prURL**: pull request URL. Default: `https://github.com/stdlib-js/stdlib/pull/`. -- **flags**: options passed to invoked `git log` command to retrieve commit messages. +- **flags**: options passed to `git log` when retrieving commit messages. diff --git a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js index edef1abcb0dc..feed0824bcd5 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js +++ b/lib/node_modules/@stdlib/_tools/changelog/parse-commits/lib/commits.js @@ -116,7 +116,7 @@ function extractCommits( dir, flags ) { if ( flags ) { flagNames = objectKeys( flags ); for ( i = 0; i < flagNames.length; i++ ) { - args.push( '--'+flagNames[i]+'='+flags[ flagNames[ i ] ] ); + args.push( '--'+flagNames[ i ]+'='+flags[ flagNames[ i ] ] ); } } try { From 28bf7acb62bb951892c47e8a6b79ab44d20d6e3b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 22 Apr 2025 21:33:31 -0400 Subject: [PATCH 07/11] chore: address PR review feedback --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .github/workflows/generate_monthly_changelog.yml | 5 +++-- .../@stdlib/_tools/changelog/generate/README.md | 8 ++++---- .../@stdlib/_tools/changelog/generate/lib/validate.js | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/generate_monthly_changelog.yml b/.github/workflows/generate_monthly_changelog.yml index 8c712a6be345..16c8f8bb4198 100644 --- a/.github/workflows/generate_monthly_changelog.yml +++ b/.github/workflows/generate_monthly_changelog.yml @@ -105,13 +105,14 @@ jobs: var generate = require( '@stdlib/_tools/changelog/generate' ); var changelog = generate( '@stdlib', { 'flags': { - 'since': '$UNTIL - 1 week', + 'since': '$UNTIL - 1 month', 'until': '$UNTIL' }, 'format': 'aggregated' }); console.log( changelog.content ); - " > ./www-blog-monthly-changelog/monthly_changelog_$UNTIL.md + + " > ./www-blog-monthly-changelog/monthly_changelog_${UNTIL//-/_}.md # Import GPG key to sign commits: - name: 'Import GPG key to sign commits' diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index a9fb91f8f606..cf7edb724aa9 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -47,10 +47,12 @@ The function returns an object with the following properties: The function accepts the following `options`: - **releaseType**: a release type for which to generate the changelog. + - **format**: changelog format. Must be one of the following: - `'grouped'`: group commits by package. - `'aggregated'`: TODO:add description. + - **flags**: `git log` options used to retrieve commits from which to generate the changelog. By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: @@ -97,12 +99,12 @@ changelog = generate( '@stdlib/math/base/utils', { When generating a changelog, the function uses `git log` to retrieve the commits from which to assemble a set of changes. The `flags` option allows passing options to directly to the `git log` command (e.g., to generate a changelog for a specified time interval or for an individual contributor). - + ```javascript var changelog = generate( '@stdlib/ndarray', { 'flags': { - 'since': 'last month' + 'since': 'last year' } }); // returns {...} @@ -121,8 +123,6 @@ changelog = generate( '@stdlib/ndarray', {
-- When `flags` are supplied, the generated changelog does not include empty releases and uses a flat output format. -
diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js index 71f3a70c2fd5..8203df3f9f27 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/lib/validate.js @@ -24,13 +24,14 @@ var isObject = require( '@stdlib/assert/is-plain-object' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var indexOf = require( '@stdlib/utils/index-of' ); +var contains = require( '@stdlib/array/base/assert/contains' ).factory; var format = require( '@stdlib/string/format' ); // VARIABLES // var FORMAT_OPTIONS = [ 'grouped', 'aggregated' ]; +var isFormat = contains( FORMAT_OPTIONS ); // MAIN // @@ -42,7 +43,7 @@ var FORMAT_OPTIONS = [ 'grouped', 'aggregated' ]; * @param {Object} opts - destination for function options * @param {Options} options - function options * @param {string} [options.releaseType] - release type -* @param {string} [options.format] - output format (`grouped` or `aggregated`) +* @param {string} [options.format] - output format * @param {string} [options.flags] - `git log` options used to retrieve commits * @returns {(Error|null)} error or null * @@ -68,7 +69,7 @@ function validate( opts, options ) { } if ( hasOwnProp( options, 'format' ) ) { opts.format = options.format; - if ( indexOf( FORMAT_OPTIONS, opts.format ) === -1 ) { + if ( !isFormat( opts.format ) ) { return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'format', FORMAT_OPTIONS.join( '", "' ), opts.format ) ); } } From 5a94944ab0599267b7011a835484300600f82c81 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 22 Apr 2025 21:34:22 -0400 Subject: [PATCH 08/11] chore: remove lint directive --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/_tools/changelog/generate/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index cf7edb724aa9..cc2c15b68eb2 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -99,8 +99,6 @@ changelog = generate( '@stdlib/math/base/utils', { When generating a changelog, the function uses `git log` to retrieve the commits from which to assemble a set of changes. The `flags` option allows passing options to directly to the `git log` command (e.g., to generate a changelog for a specified time interval or for an individual contributor). - - ```javascript var changelog = generate( '@stdlib/ndarray', { 'flags': { From a81d07cfce7063c46bc81719754857c0984c9b08 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 24 Apr 2025 17:39:03 -0400 Subject: [PATCH 09/11] docs: add description for aggregated format --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/_tools/changelog/generate/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index cc2c15b68eb2..fcdd2673afe0 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -51,7 +51,7 @@ The function accepts the following `options`: - **format**: changelog format. Must be one of the following: - `'grouped'`: group commits by package. - - `'aggregated'`: TODO:add description. + - `'aggregated'`: display all commits in a flat list without breaking changes up by package. - **flags**: `git log` options used to retrieve commits from which to generate the changelog. From 2250083ff0cd0a2aa5a2d1487581cef0f003eb12 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 24 Apr 2025 17:59:25 -0400 Subject: [PATCH 10/11] chore: add directives to disable running examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/_tools/changelog/generate/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index fcdd2673afe0..43d402e7fbbd 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -34,6 +34,8 @@ var generate = require( '@stdlib/_tools/changelog/generate' ); Generates a Markdown formatted changelog for a specified package. + + ```javascript var changelog = generate( '@stdlib/assert/contains' ); // returns {...} @@ -57,6 +59,8 @@ The function accepts the following `options`: By default, the changelog is generated for a non-release. To generate a changelog for an upcoming release, provide a valid release type: + + ```javascript var changelog = generate( '@stdlib/assert/contains', { 'releaseType': 'patch' @@ -83,6 +87,8 @@ The following release types are supported: By default, the function generates a `grouped` changelog for namespace packages and an `aggregated` changelog for non-namespace packages. To specify a desired output format, set the `format` option: + + ```javascript // Changelog grouped by individual packages: var changelog = generate( '@stdlib/math/base/utils', { @@ -99,6 +105,8 @@ changelog = generate( '@stdlib/math/base/utils', { When generating a changelog, the function uses `git log` to retrieve the commits from which to assemble a set of changes. The `flags` option allows passing options to directly to the `git log` command (e.g., to generate a changelog for a specified time interval or for an individual contributor). + + ```javascript var changelog = generate( '@stdlib/ndarray', { 'flags': { @@ -129,6 +137,8 @@ changelog = generate( '@stdlib/ndarray', { ## Examples + + ```javascript var generate = require( '@stdlib/_tools/changelog/generate' ); From e70076b5a1fb74e18e0190231187174ccc3031e3 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 24 Apr 2025 16:10:14 -0700 Subject: [PATCH 11/11] docs: update copy Signed-off-by: Athan --- lib/node_modules/@stdlib/_tools/changelog/generate/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md index 43d402e7fbbd..9b8ee8792450 100644 --- a/lib/node_modules/@stdlib/_tools/changelog/generate/README.md +++ b/lib/node_modules/@stdlib/_tools/changelog/generate/README.md @@ -53,7 +53,7 @@ The function accepts the following `options`: - **format**: changelog format. Must be one of the following: - `'grouped'`: group commits by package. - - `'aggregated'`: display all commits in a flat list without breaking changes up by package. + - `'aggregated'`: display all commits in a flat list without grouping commits by package. - **flags**: `git log` options used to retrieve commits from which to generate the changelog.