From: Timmy Willison Date: Tue, 6 Feb 2024 15:16:05 +0000 (-0500) Subject: Release: use buildDefaultFiles directly and pass version (#5409) X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ba6ba5a4c179a48647eb37ed909754163822fad9;p=jquery.git Release: use buildDefaultFiles directly and pass version (#5409) - also add the ability to pass VERSION in env to test final builds - adjust sha regex to account for lack of shas - set the version on the dist package.json Close gh-5408 --- diff --git a/build/release.js b/build/release.js index fb1d444b4..b778ca244 100644 --- a/build/release.js +++ b/build/release.js @@ -18,6 +18,7 @@ module.exports = function( Release ) { ]; const cdn = require( "./release/cdn" ); const dist = require( "./release/dist" ); + const { buildDefaultFiles } = require( "./tasks/build" ); const npmTags = Release.npmTags; @@ -41,8 +42,8 @@ module.exports = function( Release ) { * committed before creating the tag. * @param {Function} callback */ - generateArtifacts: function( callback ) { - Release.exec( "npm run build:all" ); + generateArtifacts: async function( callback ) { + await buildDefaultFiles( { version: Release.newVersion } ); cdn.makeReleaseCopies( Release ); Release._setSrcVersion(); diff --git a/build/release/dist.js b/build/release/dist.js index e85ffd359..c06c6c656 100644 --- a/build/release/dist.js +++ b/build/release/dist.js @@ -108,6 +108,7 @@ module.exports = function( Release, files, complete ) { delete packageJson.devDependencies; delete packageJson.dependencies; delete packageJson.commitplease; + packageJson.version = Release.newVersion; await fs.writeFile( `${ Release.dir.dist }/package.json`, JSON.stringify( packageJson, null, 2 ) diff --git a/build/tasks/build.js b/build/tasks/build.js index e07c26155..e6fa4632d 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -320,7 +320,9 @@ async function build( { await minify( { filename, dir } ); } -async function buildDefaultFiles( { version } = {} ) { +async function buildDefaultFiles( { + version = process.env.VERSION +} = {} ) { await Promise.all( [ build( { version } ), build( { filename: "jquery.slim.js", slim: true, version } ) diff --git a/build/tasks/compare_size.mjs b/build/tasks/compare_size.mjs index 879a18f93..c8e55bb42 100644 --- a/build/tasks/compare_size.mjs +++ b/build/tasks/compare_size.mjs @@ -109,7 +109,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) { // Remove the short SHA and .dirty from comparisons. // The short SHA so commits can be compared against each other // and .dirty to compare with the existing branch during development. - const sha = /jQuery v\d+.\d+.\d+(?:-\w+)?\+(?:slim.)?([^ \.]+(?:\.dirty)?)/.exec( contents )[ 1 ]; + const sha = /jQuery v\d+.\d+.\d+(?:-\w+)?(?:\+|\+slim\.)?([^ \.]+(?:\.dirty)?)?/.exec( contents )[ 1 ]; contents = contents.replace( new RegExp( sha, "g" ), "" ); const size = Buffer.byteLength( contents, "utf8" );