Core: Move the factory to separate exports
[jquery.git] / build / release.js
blobf4509931a98fb1fd2c673b43526ca1f09d07689a
1 "use strict";
3 var fs = require( "fs" );
5 module.exports = function( Release ) {
7         const distFiles = [
8                 "dist/jquery.js",
9                 "dist/jquery.min.js",
10                 "dist/jquery.min.map",
11                 "dist/jquery.slim.js",
12                 "dist/jquery.slim.min.js",
13                 "dist/jquery.slim.min.map",
14                 "dist-module/jquery.module.js",
15                 "dist-module/jquery.module.min.js",
16                 "dist-module/jquery.module.min.map",
17                 "dist-module/jquery.slim.module.js",
18                 "dist-module/jquery.slim.module.min.js",
19                 "dist-module/jquery.slim.module.min.map"
20         ];
21         const filesToCommit = [
22                 ...distFiles,
23                 "src/core.js"
24         ];
25         const cdn = require( "./release/cdn" );
26         const dist = require( "./release/dist" );
28         const npmTags = Release.npmTags;
30         function setSrcVersion( filepath ) {
31                 var contents = fs.readFileSync( filepath, "utf8" );
32                 contents = contents.replace( /@VERSION/g, Release.newVersion );
33                 fs.writeFileSync( filepath, contents, "utf8" );
34         }
36         Release.define( {
37                 npmPublish: true,
38                 issueTracker: "github",
40                 /**
41                  * Set the version in the src folder for distributing ES modules.
42                  */
43                 _setSrcVersion: function() {
44                         setSrcVersion( `${ __dirname }/../src/core.js` );
45                 },
47                 /**
48                  * Generates any release artifacts that should be included in the release.
49                  * The callback must be invoked with an array of files that should be
50                  * committed before creating the tag.
51                  * @param {Function} callback
52                  */
53                 generateArtifacts: function( callback ) {
54                         Release.exec( "npx grunt" );
56                         cdn.makeReleaseCopies( Release );
57                         Release._setSrcVersion();
58                         callback( filesToCommit );
59                 },
61                 /**
62                  * Acts as insertion point for restoring Release.dir.repo
63                  * It was changed to reuse npm publish code in jquery-release
64                  * for publishing the distribution repo instead
65                  */
66                 npmTags: function() {
68                         // origRepo is not defined if dist was skipped
69                         Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
70                         return npmTags();
71                 },
73                 /**
74                  * Publish to distribution repo and npm
75                  * @param {Function} callback
76                  */
77                 dist: async callback => {
78                         await cdn.makeArchives( Release );
79                         dist( Release, distFiles, callback );
80                 }
81         } );
84 module.exports.dependencies = [
85         "archiver@5.2.0",
86         "shelljs@0.8.4",
87         "inquirer@8.0.0"