Skip to content

Commit

Permalink
Merge branch 'release/2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
noud-github committed Jan 5, 2023
2 parents 7e30db9 + 2d02c24 commit 1b139e1
Show file tree
Hide file tree
Showing 13 changed files with 713 additions and 19 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,9 @@ update-changelog-to-latest: {

## Release History

### 2.4
- breaking change, the date format used in `update-changelog-to-latest` and `update-changelog-with-latest-pr` is changed from `November 29th, 2022` to `2022-10-29`

### 2.3
- Adds `update-changelog-to-latest` Grunt task & config.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@yoast/grunt-plugin-tasks",
"description": "Custom Yoast grunt tasks",
"version": "2.3.0",
"version": "2.4.0",
"homepage": "https://github.com/Yoast/",
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,7 +36,7 @@
"grunt-contrib-uglify": "^4.0.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "^21.0.0",
"grunt-glotpress": "https://github.com/Yoast/grunt-glotpress.git#master",
"grunt-glotpress": "https://github.com/Yoast/grunt-glotpress.git#main",
"grunt-postcss": "^0.9.0",
"grunt-replace": "^1.0.1",
"grunt-rtlcss": "^2.0.2",
Expand Down
13 changes: 4 additions & 9 deletions tasks/update-changelog-to-latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ module.exports = function( grunt ) {
}
}

if ( grunt.file.exists( options.changelogToInject ) ) {
grunt.log.writeln( "input file not found" );
done();
}

// Add n8n log here!!!
const n8nChangelog = grunt.file.read( options.changelogToInject );

Expand Down Expand Up @@ -167,11 +162,11 @@ module.exports = function( grunt ) {
d.setDate( d.getDate() + ( 2 + options.daysToAddForNextRelease - d.getDay() ) );
}
const ye = new Intl.DateTimeFormat( "en", { year: "numeric" } ).format( d );
const mo = new Intl.DateTimeFormat( "en", { month: "long" } ).format( d );
const da = new Intl.DateTimeFormat( "en", { day: "numeric" } ).format( d );
const datestring = `${mo} ${format( da )}, ${ye}`;
const mo = new Intl.DateTimeFormat( "en", { month: "2-digit" } ).format( d );
const da = new Intl.DateTimeFormat( "en", { day: "2-digit" } ).format( d );
const datestring = `${ye}-${mo}-${da}`;
// eslint-disable-next-line max-len

console.log( datestring );
var newChangelog = options.newHeadertemplate.replace( new RegExp( "VERSIONNUMBER" ), changelogVersionNumber );
newChangelog = newChangelog.replace( new RegExp( "DATESTRING" ), datestring ) + n8nChangelog;

Expand Down
6 changes: 3 additions & 3 deletions tasks/update-changelog-with-latest-pr-texts.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ module.exports = function( grunt ) {
d.setDate( d.getDate() + ( 2 + options.daysToAddForNextRelease - d.getDay() ) );
}
const ye = new Intl.DateTimeFormat( "en", { year: "numeric" } ).format( d );
const mo = new Intl.DateTimeFormat( "en", { month: "long" } ).format( d );
const da = new Intl.DateTimeFormat( "en", { day: "numeric" } ).format( d );
const datestring = `${mo} ${format( da )}, ${ye}`;
const mo = new Intl.DateTimeFormat( "en", { month: "2-digit" } ).format( d );
const da = new Intl.DateTimeFormat( "en", { day: "2-digit" } ).format( d );
const datestring = `${ye}-${mo}-${da}`;
// eslint-disable-next-line max-len
changelogBuilder.parseChancelogLines( options.defaultChangelogEntries.replace( new RegExp( "VERSIONNUMBER" ), changelogVersionNumber ) );

Expand Down
2 changes: 1 addition & 1 deletion test/expected/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 16.0: April 5th, 2022
### 16.0: 2023-1-17
Enhancements:
* test left over entry.

Expand Down
2 changes: 1 addition & 1 deletion test/expected/changelog3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 16.0: April 5th, 2022
### 16.0: 2023-01-17
Bugfixes:

* Fixes a bug where the word 'minute/minutes' would be in the user language, instead of the site language, for the estimated reading time block in the frontend.
Expand Down
2 changes: 1 addition & 1 deletion test/expected/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Your question has most likely been answered on our help center: [yoast.com/help/
== Changelog ==

= 16.0 =
Release Date: April 5th, 2022
Release Date: 2023-1-17

Bugfixes:

Expand Down
2 changes: 1 addition & 1 deletion test/expected/readme4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Your question has most likely been answered on our help center: [yoast.com/help/
== Changelog ==

= 16.7 =
Release Date: April 5th, 2022
Release Date: 2023-1-17

Enhancements:

Expand Down
289 changes: 289 additions & 0 deletions test/expected/readme7.txt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/fixtures/n8nchangelog1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#### Bugfixes

* Fixes a bug where the word 'minute/minutes' would be in the user language, instead of the site language, for the estimated reading time block in the frontend.

#### Other

* Bumps the minimum required Yoast SEO version to 18.4.
* Sets minimum required WordPress version to 5.8.

298 changes: 298 additions & 0 deletions test/fixtures/readme7.txt

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions test/update-changelog-7-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* eslint-disable no-useless-escape */
/* eslint-disable no-useless-concat */
/**
* A unit test for 'set-version.js'.
*
* Copies the fixtures to the temp folder and runs set-version.
* After that the (fixture) files in the temp folder get compared with the expected folder.
*/


const grunt = require( "grunt" );
const runTask = require( "grunt-run-task" );
const tempFilePath = [ "tmp/readme7.txt" ];
const expectedFilePath = [ "test/expected/readme7.txt" ];
const srcWikimdfile = "test/fixtures/n8nchangelog1.txt";
const dstWikimdfile = "./.tmp/n8nchangelog1.txt";
const noOfFiles = Math.min( tempFilePath.length, expectedFilePath.length );
let ChanceLogTask;

exports.testChangeLog9Command = {
/**
* @param {function} done Function to execute when done.
* @returns {void}
*/
setUp: function( done ) {
// Load the tasks so they can be run
runTask.loadTasks( "tasks" );
// Setup the file's to run the test on
for ( let i = 0; i < noOfFiles; i++ ) {
const fixturePath = expectedFilePath[ i ].replace( "expected", "fixtures" );
grunt.log.writeln( "\n [" + ( i + 1 ) + "/" + noOfFiles + "] Copying '" + fixturePath + "' to '" + tempFilePath[ i ] + "'" );
grunt.file.copy( fixturePath, tempFilePath[ i ] );
}
grunt.file.mkdir( "./tmp" );
grunt.file.copy( srcWikimdfile, dstWikimdfile );
grunt.log.writeln( "setup is done!" );

runTask.option( "plugin-version", "19.12" );
ChanceLogTask = runTask.task( "update-changelog-to-latest", {
"wordpress-seo": {
options: {
// Free header:
// = 15.7 =
// Release Date: January 26th, 2021
readmeFile: "tmp/readme7.txt",
changelogToInject: "./.tmp/n8nchangelog1.txt",
releaseInChangelog: /[=] \d+\.\d+(\.\d+)? =/g,
matchChangelogHeader: /[=]= Changelog ==\n\n/ig,
newHeadertemplate: "== Changelog ==\n\n" + "= " + "VERSIONNUMBER" + " =\n\nRelease date: " + "DATESTRING" + "\n",
matchCorrectHeader: "= " + "VERSIONNUMBER" + " =(.|\\n)*?\\n(?=(\\n#### \\w\+?\\n|= \\d+[\.\\d]+|= Earlier versions =))",
matchCorrectLines: "= " + "VERSIONNUMBER" + " =(.|\\n)*?(?=(= \\d+[\.\\d]+ =|= Earlier versions =))",
matchCleanedChangelog: "= " + "VERSIONNUMBER" + "(.|\\n)*= Earlier versions =",
replaceCleanedChangelog: "= Earlier versions =",
pluginSlug: "wordpress-seo",
defaultChangelogEntries: "",
useANewLineAfterHeader: true,
commitChangelog: false,
},
},
} );

ChanceLogTask.run( function() {
done();
} );
},
/**
* @param {object} test Test object
* @returns {void}
*/
testChanceLogtask: function( test ) {
/**
* Runs the test assertions to verify the 2 files are identical if the files given as parameters exist.
*
* @param {string} file1 The file path to compare to file2.
* @param {string} file2 The file path to compare to file1.
*
* @returns {void}.
*/
function compareFiles( file1, file2 ) {
if ( grunt.file.exists( file1 ) && grunt.file.exists( file2 ) ) {
const actual = grunt.file.read( file1 );
const expected = grunt.file.read( file2 );
test.deepEqual( actual, expected, "Compare the file '" + file1 + "' with '" + file2 + "'" );
return;
}
grunt.fail.warn( "Expected files not found" );
}

const task = "update-changelog-to-latest";
if ( grunt.task.exists( task ) ) {
for ( let i = 0; i < noOfFiles; i++ ) {
compareFiles( tempFilePath[ i ], expectedFilePath[ i ] );
}
} else {
grunt.fail.warn( "The task " + task + "does not exist" );
}
test.done();
},
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ grunt-eslint@^21.0.0:
chalk "^2.1.0"
eslint "^5.0.0"

"grunt-glotpress@https://github.com/Yoast/grunt-glotpress.git#master":
"grunt-glotpress@https://github.com/Yoast/grunt-glotpress.git#main":
version "0.3.0"
resolved "https://github.com/Yoast/grunt-glotpress.git#e6ccc69c2532d126f5d8a30397ffd012e55b6eec"
dependencies:
Expand Down

0 comments on commit 1b139e1

Please sign in to comment.