From b507c8648f701acd1c48b3c38054ad38d76fd1ca Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 6 Feb 2024 09:53:30 -0500 Subject: [PATCH] Release: use buildDefaultFiles directly and pass version - 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 --- build/release.js | 7 ++++--- build/release/dist.js | 1 + build/tasks/build.js | 5 ++++- build/tasks/compare_size.mjs | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build/release.js b/build/release.js index ff11d80cc..3cf4f31ab 100644 --- a/build/release.js +++ b/build/release.js @@ -24,6 +24,7 @@ module.exports = function( Release ) { ]; const cdn = require( "./release/cdn" ); const dist = require( "./release/dist" ); + const { buildDefaultFiles } = require( "./tasks/build" ); const npmTags = Release.npmTags; @@ -53,8 +54,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(); @@ -77,7 +78,7 @@ module.exports = function( Release ) { * Publish to distribution repo and npm * @param {Function} callback */ - dist: async callback => { + dist: async function( callback ) { await cdn.makeArchives( Release ); dist( Release, distFiles, callback ); } diff --git a/build/release/dist.js b/build/release/dist.js index ad378468f..9851262a2 100644 --- a/build/release/dist.js +++ b/build/release/dist.js @@ -119,6 +119,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 ed70fdd20..c169ce925 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -352,7 +352,10 @@ async function build( { } } -async function buildDefaultFiles( { version, watch } = {} ) { +async function buildDefaultFiles( { + version = process.env.VERSION, + watch +} = {} ) { await Promise.all( [ build( { version, watch } ), build( { filename: "jquery.slim.js", slim: true, version, watch } ), 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" );