Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit358b769

Browse files
authored
Release: Use an in-repository dist README fixture
Use a dist README fixture kept in the jQuery repository instead of modifyingan existing one. This makes the jQuery repository the single source of truthwhen it comes to jQuery releases and it makes it easier to make changes toREADME without worrying how it will affect older jQuery lines.The commit also ES6ifies build/release.js & build/release/dist.jsClosesgh-4614
1 parent4a7fc85 commit358b769

File tree

3 files changed

+132
-63
lines changed

3 files changed

+132
-63
lines changed

‎build/fixtures/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#jQuery
2+
3+
>jQuery is a fast, small, and feature-rich JavaScript library.
4+
5+
For information on how to get started and how to use jQuery, please see[jQuery's documentation](http://api.jquery.com/).
6+
For source files and issues, please visit the[jQuery repo](https://github.com/jquery/jquery).
7+
8+
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.
9+
10+
##Including jQuery
11+
12+
Below are some of the most common ways to include jQuery.
13+
14+
###Browser
15+
16+
####Script tag
17+
18+
```html
19+
<scriptsrc="https://code.jquery.com/jquery-@VERSION.min.js"></script>
20+
```
21+
22+
####Babel
23+
24+
[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.
25+
26+
```js
27+
import $from"jquery";
28+
```
29+
30+
####Browserify/Webpack
31+
32+
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...
33+
34+
```js
35+
var $=require("jquery" );
36+
```
37+
38+
####AMD (Asynchronous Module Definition)
39+
40+
AMD is a module format built for the browser. For more information, we recommend[require.js' documentation](http://requirejs.org/docs/whyamd.html).
41+
42+
```js
43+
define( ["jquery" ],function($ ) {
44+
45+
} );
46+
```
47+
48+
###Node
49+
50+
To include jQuery in[Node](nodejs.org), first install with npm.
51+
52+
```sh
53+
npm install jquery
54+
```
55+
56+
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.
57+
58+
```js
59+
const {JSDOM }=require("jsdom" );
60+
const {window }=newJSDOM("" );
61+
const$=require("jquery" )(window );
62+
```

‎build/release.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ var fs = require( "fs" );
44

55
module.exports=function(Release){
66

7-
var
8-
distFiles=[
9-
"dist/jquery.js",
10-
"dist/jquery.min.js",
11-
"dist/jquery.min.map",
12-
"dist/jquery.slim.js",
13-
"dist/jquery.slim.min.js",
14-
"dist/jquery.slim.min.map"
15-
],
16-
filesToCommit=[
17-
...distFiles,
18-
"src/core.js"
19-
],
20-
cdn=require("./release/cdn"),
21-
dist=require("./release/dist"),
7+
constdistFiles=[
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+
];
15+
constfilesToCommit=[
16+
...distFiles,
17+
"src/core.js"
18+
];
19+
constcdn=require("./release/cdn");
20+
constdist=require("./release/dist");
2221

23-
npmTags=Release.npmTags;
22+
constnpmTags=Release.npmTags;
2423

2524
functionsetSrcVersion(filepath){
2625
varcontents=fs.readFileSync(filepath,"utf8");
@@ -86,6 +85,7 @@ module.exports = function( Release ) {
8685
module.exports.dependencies=[
8786
"archiver@1.3.0",
8887
"shelljs@0.7.7",
88+
"inquirer@7.0.4",
8989
"npm@4.4.1",
9090
"chalk@1.1.3"
9191
];

‎build/release/dist.js

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
module.exports=function(Release,files,complete){
44

5-
var
6-
fs=require("fs"),
7-
shell=require("shelljs"),
8-
pkg=require(Release.dir.repo+"/package.json"),
9-
distRemote=Release.remote
10-
11-
// For local and github dists
12-
.replace(/jquery(\.git|$)/,"jquery-dist$1"),
13-
14-
// These files are included with the distribution
15-
extras=[
16-
"amd",
17-
"src",
18-
"LICENSE.txt",
19-
"AUTHORS.txt",
20-
"package.json"
21-
];
5+
constfs=require("fs").promises;
6+
constshell=require("shelljs");
7+
constinquirer=require("inquirer");
8+
constpkg=require(`${Release.dir.repo}/package.json`);
9+
constdistRemote=Release.remote
10+
11+
// For local and github dists
12+
.replace(/jquery(\.git|$)/,"jquery-dist$1");
13+
14+
// These files are included with the distribution
15+
constextras=[
16+
"amd",
17+
"src",
18+
"LICENSE.txt",
19+
"AUTHORS.txt",
20+
"package.json"
21+
];
2222

2323
/**
2424
* Clone the distribution repo
2525
*/
2626
functionclone(){
2727
Release.chdir(Release.dir.base);
28-
Release.dir.dist=Release.dir.base+"/dist";
28+
Release.dir.dist=`${Release.dir.base}/dist`;
2929

3030
console.log("Using distribution repo: ",distRemote);
31-
Release.exec("git clone"+distRemote+" "+Release.dir.dist,
31+
Release.exec(`git clone${distRemote}${Release.dir.dist}`,
3232
"Error cloning repo.");
3333

3434
// Distribution always works on master
@@ -55,56 +55,60 @@ module.exports = function( Release, files, complete ) {
5555
/**
5656
* Replace the version in the README
5757
*@param {string} readme
58+
*@param {string} blogPostLink
5859
*/
59-
functioneditReadme(readme){
60-
varrprev=newRegExp(Release.prevVersion,"g");
61-
returnreadme.replace(rprev,Release.newVersion);
60+
functioneditReadme(readme,blogPostLink){
61+
returnreadme
62+
.replace(/@VERSION/g,Release.newVersion)
63+
.replace(/@BLOG_POST_LINK/g,blogPostLink);
6264
}
6365

6466
/**
6567
* Copy necessary files over to the dist repo
6668
*/
67-
functioncopy(){
69+
asyncfunctioncopy(){
6870

6971
// Copy dist files
70-
vardistFolder=Release.dir.dist+"/dist",
71-
readme=fs.readFileSync(Release.dir.dist+"/README.md","utf8"),
72-
rmIgnore=files
73-
.concat([
74-
"README.md",
75-
"node_modules"
76-
])
77-
.map(function(file){
78-
returnRelease.dir.dist+"/"+file;
79-
});
72+
constdistFolder=`${Release.dir.dist}/dist`;
73+
constreadme=awaitfs.readFile(
74+
`${Release.dir.repo}/build/fixtures/README.md`,"utf8");
75+
constrmIgnore=[ ...files,"node_modules"]
76+
.map(file=>`${Release.dir.dist}/${file}`);
8077

8178
shell.config.globOptions={
8279
ignore:rmIgnore
8380
};
8481

82+
const{ blogPostLink}=awaitinquirer.prompt([{
83+
type:"input",
84+
name:"blogPostLink",
85+
message:"Enter URL of the blog post announcing the jQuery release...\n"
86+
}]);
87+
8588
// Remove extraneous files before copy
86-
shell.rm("-rf",Release.dir.dist+"/**/*");
89+
shell.rm("-rf",`${Release.dir.dist}/**/*`);
8790

8891
shell.mkdir("-p",distFolder);
8992
files.forEach(function(file){
90-
shell.cp("-f",Release.dir.repo+"/"+file,distFolder);
93+
shell.cp("-f",`${Release.dir.repo}/${file}`,distFolder);
9194
});
9295

9396
// Copy other files
9497
extras.forEach(function(file){
95-
shell.cp("-rf",Release.dir.repo+"/"+file,Release.dir.dist);
98+
shell.cp("-rf",`${Release.dir.repo}/${file}`,Release.dir.dist);
9699
});
97100

98-
// Remove the wrapper from the dist repo
99-
shell.rm("-f",Release.dir.dist+"/src/wrapper.js");
101+
// Remove the wrapper & the ESLint config from the dist repo
102+
shell.rm("-f",`${Release.dir.dist}/src/wrapper.js`);
103+
shell.rm("-f",`${Release.dir.dist}/src/.eslintrc.json`);
100104

101105
// Write generated bower file
102-
fs.writeFileSync(Release.dir.dist+"/bower.json",generateBower());
106+
awaitfs.writeFile(`${Release.dir.dist}/bower.json`,generateBower());
103107

104-
fs.writeFileSync(Release.dir.dist+"/README.md",editReadme(readme ));
108+
awaitfs.writeFile(`${Release.dir.dist}/README.md`,
109+
editReadme(readme,blogPostLink ));
105110

106111
console.log("Files ready to add.");
107-
console.log("Edit the dist README.md to include the latest blog post link.");
108112
}
109113

110114
/**
@@ -114,14 +118,14 @@ module.exports = function( Release, files, complete ) {
114118
console.log("Adding files to dist...");
115119
Release.exec("git add -A","Error adding files.");
116120
Release.exec(
117-
"git commit -m\"Release"+Release.newVersion+"\"",
121+
`git commit -m "Release${Release.newVersion}"`,
118122
"Error committing files."
119123
);
120124
console.log();
121125

122126
console.log("Tagging release on dist...");
123-
Release.exec("git tag"+Release.newVersion,
124-
"Error tagging"+Release.newVersion+"on dist repo.");
127+
Release.exec(`git tag${Release.newVersion}`,
128+
`Error tagging${Release.newVersion}on dist repo.`);
125129
Release.tagTime=Release.exec("git log -1 --format=\"%ad\"",
126130
"Error getting tag timestamp.").trim();
127131
}
@@ -133,9 +137,12 @@ module.exports = function( Release, files, complete ) {
133137
Release.chdir(Release.dir.dist);
134138

135139
console.log("Pushing release to dist repo...");
136-
Release.exec("git push "+(Release.isTest ?" --dry-run " :"")+
137-
distRemote+" master --tags",
138-
"Error pushing master and tags to git repo.");
140+
Release.exec(
141+
`git push${
142+
Release.isTest ?" --dry-run" :""
143+
}${distRemote} master --tags`,
144+
"Error pushing master and tags to git repo."
145+
);
139146

140147
// Set repo for npm publish
141148
Release.dir.origRepo=Release.dir.repo;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp