mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Release: Use an in-repository dist README fixture
Use a dist README fixture kept in the jQuery repository instead of modifying
an existing one. This makes the jQuery repository the single source of truth
when it comes to jQuery releases and it makes it easier to make changes to
README without worrying how it will affect older jQuery lines.
The commit also ES6ifies build/release.js & build/release/dist.js
Closes gh-4614
(cherry picked from commit 358b769a00
)
This commit is contained in:
parent
0fdfdd8290
commit
524bcf39da
62
build/fixtures/README.md
Normal file
62
build/fixtures/README.md
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# jQuery
|
||||||
|
|
||||||
|
> jQuery is a fast, small, and feature-rich JavaScript library.
|
||||||
|
|
||||||
|
For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
|
||||||
|
For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
|
||||||
|
|
||||||
|
If upgrading, please see the [blog post for @VERSION](@BLOG_POST_LINK). This includes notable differences from the previous version and a more readable changelog.
|
||||||
|
|
||||||
|
## Including jQuery
|
||||||
|
|
||||||
|
Below are some of the most common ways to include jQuery.
|
||||||
|
|
||||||
|
### Browser
|
||||||
|
|
||||||
|
#### Script tag
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://code.jquery.com/jquery-@VERSION.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Babel
|
||||||
|
|
||||||
|
[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import $ from "jquery";
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Browserify/Webpack
|
||||||
|
|
||||||
|
There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...
|
||||||
|
|
||||||
|
```js
|
||||||
|
var $ = require( "jquery" );
|
||||||
|
```
|
||||||
|
|
||||||
|
#### AMD (Asynchronous Module Definition)
|
||||||
|
|
||||||
|
AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
|
||||||
|
|
||||||
|
```js
|
||||||
|
define( [ "jquery" ], function( $ ) {
|
||||||
|
|
||||||
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
|
### Node
|
||||||
|
|
||||||
|
To include jQuery in [Node](nodejs.org), first install with npm.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install jquery
|
||||||
|
```
|
||||||
|
|
||||||
|
For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { JSDOM } = require( "jsdom" );
|
||||||
|
const { window } = new JSDOM( "" );
|
||||||
|
const $ = require( "jquery" )( window );
|
||||||
|
```
|
@ -4,24 +4,23 @@ var fs = require( "fs" );
|
|||||||
|
|
||||||
module.exports = function( Release ) {
|
module.exports = function( Release ) {
|
||||||
|
|
||||||
var
|
const distFiles = [
|
||||||
distFiles = [
|
"dist/jquery.js",
|
||||||
"dist/jquery.js",
|
"dist/jquery.min.js",
|
||||||
"dist/jquery.min.js",
|
"dist/jquery.min.map",
|
||||||
"dist/jquery.min.map",
|
"dist/jquery.slim.js",
|
||||||
"dist/jquery.slim.js",
|
"dist/jquery.slim.min.js",
|
||||||
"dist/jquery.slim.min.js",
|
"dist/jquery.slim.min.map"
|
||||||
"dist/jquery.slim.min.map"
|
];
|
||||||
],
|
const filesToCommit = [
|
||||||
filesToCommit = [
|
...distFiles,
|
||||||
...distFiles,
|
"src/core.js"
|
||||||
"src/core.js"
|
];
|
||||||
],
|
const cdn = require( "./release/cdn" );
|
||||||
cdn = require( "./release/cdn" ),
|
const dist = require( "./release/dist" );
|
||||||
dist = require( "./release/dist" ),
|
const ensureSizzle = require( "./release/ensure-sizzle" );
|
||||||
ensureSizzle = require( "./release/ensure-sizzle" ),
|
|
||||||
|
|
||||||
npmTags = Release.npmTags;
|
const npmTags = Release.npmTags;
|
||||||
|
|
||||||
Release.define( {
|
Release.define( {
|
||||||
npmPublish: true,
|
npmPublish: true,
|
||||||
@ -90,6 +89,7 @@ module.exports = function( Release ) {
|
|||||||
module.exports.dependencies = [
|
module.exports.dependencies = [
|
||||||
"archiver@1.3.0",
|
"archiver@1.3.0",
|
||||||
"shelljs@0.7.7",
|
"shelljs@0.7.7",
|
||||||
|
"inquirer@7.0.4",
|
||||||
"npm@4.4.1",
|
"npm@4.4.1",
|
||||||
"chalk@1.1.3"
|
"chalk@1.1.3"
|
||||||
];
|
];
|
||||||
|
@ -2,32 +2,32 @@
|
|||||||
|
|
||||||
module.exports = function( Release, files, complete ) {
|
module.exports = function( Release, files, complete ) {
|
||||||
|
|
||||||
var
|
const fs = require( "fs" ).promises;
|
||||||
fs = require( "fs" ),
|
const shell = require( "shelljs" );
|
||||||
shell = require( "shelljs" ),
|
const inquirer = require( "inquirer" );
|
||||||
pkg = require( Release.dir.repo + "/package.json" ),
|
const pkg = require( `${ Release.dir.repo }/package.json` );
|
||||||
distRemote = Release.remote
|
const distRemote = Release.remote
|
||||||
|
|
||||||
// For local and github dists
|
// For local and github dists
|
||||||
.replace( /jquery(\.git|$)/, "jquery-dist$1" ),
|
.replace( /jquery(\.git|$)/, "jquery-dist$1" );
|
||||||
|
|
||||||
// These files are included with the distribution
|
// These files are included with the distribution
|
||||||
extras = [
|
const extras = [
|
||||||
"src",
|
"src",
|
||||||
"LICENSE.txt",
|
"LICENSE.txt",
|
||||||
"AUTHORS.txt",
|
"AUTHORS.txt",
|
||||||
"package.json"
|
"package.json"
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the distribution repo
|
* Clone the distribution repo
|
||||||
*/
|
*/
|
||||||
function clone() {
|
function clone() {
|
||||||
Release.chdir( Release.dir.base );
|
Release.chdir( Release.dir.base );
|
||||||
Release.dir.dist = Release.dir.base + "/dist";
|
Release.dir.dist = `${ Release.dir.base }/dist`;
|
||||||
|
|
||||||
console.log( "Using distribution repo: ", distRemote );
|
console.log( "Using distribution repo: ", distRemote );
|
||||||
Release.exec( "git clone " + distRemote + " " + Release.dir.dist,
|
Release.exec( `git clone ${ distRemote } ${ Release.dir.dist }`,
|
||||||
"Error cloning repo." );
|
"Error cloning repo." );
|
||||||
|
|
||||||
// Distribution always works on master
|
// Distribution always works on master
|
||||||
@ -54,61 +54,65 @@ module.exports = function( Release, files, complete ) {
|
|||||||
/**
|
/**
|
||||||
* Replace the version in the README
|
* Replace the version in the README
|
||||||
* @param {string} readme
|
* @param {string} readme
|
||||||
|
* @param {string} blogPostLink
|
||||||
*/
|
*/
|
||||||
function editReadme( readme ) {
|
function editReadme( readme, blogPostLink ) {
|
||||||
var rprev = new RegExp( Release.prevVersion, "g" );
|
return readme
|
||||||
return readme.replace( rprev, Release.newVersion );
|
.replace( /@VERSION/g, Release.newVersion )
|
||||||
|
.replace( /@BLOG_POST_LINK/g, blogPostLink );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy necessary files over to the dist repo
|
* Copy necessary files over to the dist repo
|
||||||
*/
|
*/
|
||||||
function copy() {
|
async function copy() {
|
||||||
|
|
||||||
// Copy dist files
|
// Copy dist files
|
||||||
var distFolder = Release.dir.dist + "/dist",
|
const distFolder = `${ Release.dir.dist }/dist`;
|
||||||
externalFolder = Release.dir.dist + "/external",
|
const externalFolder = `${ Release.dir.dist }/external`;
|
||||||
readme = fs.readFileSync( Release.dir.dist + "/README.md", "utf8" ),
|
const readme = await fs.readFile(
|
||||||
rmIgnore = files
|
`${ Release.dir.repo }/build/fixtures/README.md`, "utf8" );
|
||||||
.concat( [
|
const rmIgnore = [ ...files, "node_modules" ]
|
||||||
"README.md",
|
.map( file => `${ Release.dir.dist }/${ file }` );
|
||||||
"node_modules"
|
|
||||||
] )
|
|
||||||
.map( function( file ) {
|
|
||||||
return Release.dir.dist + "/" + file;
|
|
||||||
} );
|
|
||||||
|
|
||||||
shell.config.globOptions = {
|
shell.config.globOptions = {
|
||||||
ignore: rmIgnore
|
ignore: rmIgnore
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { blogPostLink } = await inquirer.prompt( [ {
|
||||||
|
type: "input",
|
||||||
|
name: "blogPostLink",
|
||||||
|
message: "Enter URL of the blog post announcing the jQuery release...\n"
|
||||||
|
} ] );
|
||||||
|
|
||||||
// Remove extraneous files before copy
|
// Remove extraneous files before copy
|
||||||
shell.rm( "-rf", Release.dir.dist + "/**/*" );
|
shell.rm( "-rf", `${ Release.dir.dist }/**/*` );
|
||||||
|
|
||||||
shell.mkdir( "-p", distFolder );
|
shell.mkdir( "-p", distFolder );
|
||||||
files.forEach( function( file ) {
|
files.forEach( function( file ) {
|
||||||
shell.cp( "-f", Release.dir.repo + "/" + file, distFolder );
|
shell.cp( "-f", `${ Release.dir.repo }/${ file }`, distFolder );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Copy Sizzle
|
// Copy Sizzle
|
||||||
shell.mkdir( "-p", externalFolder );
|
shell.mkdir( "-p", externalFolder );
|
||||||
shell.cp( "-rf", Release.dir.repo + "/external/sizzle", externalFolder );
|
shell.cp( "-rf", `${ Release.dir.repo }/external/sizzle`, externalFolder );
|
||||||
|
|
||||||
// Copy other files
|
// Copy other files
|
||||||
extras.forEach( function( file ) {
|
extras.forEach( function( file ) {
|
||||||
shell.cp( "-rf", Release.dir.repo + "/" + file, Release.dir.dist );
|
shell.cp( "-rf", `${ Release.dir.repo }/${ file }`, Release.dir.dist );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Remove the wrapper from the dist repo
|
// Remove the wrapper & the ESLint config from the dist repo
|
||||||
shell.rm( "-f", Release.dir.dist + "/src/wrapper.js" );
|
shell.rm( "-f", `${ Release.dir.dist }/src/wrapper.js` );
|
||||||
|
shell.rm( "-f", `${ Release.dir.dist }/src/.eslintrc.json` );
|
||||||
|
|
||||||
// Write generated bower file
|
// Write generated bower file
|
||||||
fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );
|
await fs.writeFile( `${ Release.dir.dist }/bower.json`, generateBower() );
|
||||||
|
|
||||||
fs.writeFileSync( Release.dir.dist + "/README.md", editReadme( readme ) );
|
await fs.writeFile( `${ Release.dir.dist }/README.md`,
|
||||||
|
editReadme( readme, blogPostLink ) );
|
||||||
|
|
||||||
console.log( "Files ready to add." );
|
console.log( "Files ready to add." );
|
||||||
console.log( "Edit the dist README.md to include the latest blog post link." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,14 +122,14 @@ module.exports = function( Release, files, complete ) {
|
|||||||
console.log( "Adding files to dist..." );
|
console.log( "Adding files to dist..." );
|
||||||
Release.exec( "git add -A", "Error adding files." );
|
Release.exec( "git add -A", "Error adding files." );
|
||||||
Release.exec(
|
Release.exec(
|
||||||
"git commit -m \"Release " + Release.newVersion + "\"",
|
`git commit -m "Release ${ Release.newVersion }"`,
|
||||||
"Error committing files."
|
"Error committing files."
|
||||||
);
|
);
|
||||||
console.log();
|
console.log();
|
||||||
|
|
||||||
console.log( "Tagging release on dist..." );
|
console.log( "Tagging release on dist..." );
|
||||||
Release.exec( "git tag " + Release.newVersion,
|
Release.exec( `git tag ${ Release.newVersion }`,
|
||||||
"Error tagging " + Release.newVersion + " on dist repo." );
|
`Error tagging ${ Release.newVersion } on dist repo.` );
|
||||||
Release.tagTime = Release.exec( "git log -1 --format=\"%ad\"",
|
Release.tagTime = Release.exec( "git log -1 --format=\"%ad\"",
|
||||||
"Error getting tag timestamp." ).trim();
|
"Error getting tag timestamp." ).trim();
|
||||||
}
|
}
|
||||||
@ -137,9 +141,12 @@ module.exports = function( Release, files, complete ) {
|
|||||||
Release.chdir( Release.dir.dist );
|
Release.chdir( Release.dir.dist );
|
||||||
|
|
||||||
console.log( "Pushing release to dist repo..." );
|
console.log( "Pushing release to dist repo..." );
|
||||||
Release.exec( "git push " + ( Release.isTest ? " --dry-run " : "" ) +
|
Release.exec(
|
||||||
distRemote + " master --tags",
|
`git push ${
|
||||||
"Error pushing master and tags to git repo." );
|
Release.isTest ? " --dry-run" : ""
|
||||||
|
} ${ distRemote } master --tags`,
|
||||||
|
"Error pushing master and tags to git repo."
|
||||||
|
);
|
||||||
|
|
||||||
// Set repo for npm publish
|
// Set repo for npm publish
|
||||||
Release.dir.origRepo = Release.dir.repo;
|
Release.dir.origRepo = Release.dir.repo;
|
||||||
|
Loading…
Reference in New Issue
Block a user