Skip to content

Commit a0a9040

Browse files
authored
Merge pull request #5780 from plotly/draft-release-notes
Commit PR notes to draftlogs and add scripts to provide draft release notes and empty draftlogs
2 parents 2104e4d + d17e77c commit a0a9040

9 files changed

+190
-36
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ Thanks for your interest in plotly.js!
99
### Features, Bug fixes, and others:
1010

1111
Before opening a pull request, developer should:
12+
1. make sure they are not on the `master` branch of their fork as using `master` for a pull request would make it difficult to fetch `upstream` changes.
13+
2. fetch latest changes from `upstream/master` into your fork i.e. `origin/master` then pull `origin/master` from you local `master`.
14+
3. then `git rebase master` their local dev branch off the latest `master` which should be sync with `upstream/master` at this time.
15+
4. make sure to **not** `git add` the `dist/` folder (the `dist/` is updated only on version bumps).
16+
5. make sure to commit changes to the `package-lock.json` file (if any new dependency required).
17+
6. provide a title and write an overview of what the PR attempts to do with a link to the issue they are trying to address.
18+
7. select the _Allow edits from maintainers_ option (see this [article](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) for more details).
1219

13-
- `git rebase` their local branch off the latest `master`,
14-
- make sure to **not** `git add` the `dist/` folder (the `dist/` is updated only on version bumps),
15-
- make sure to commit changes to the `package-lock.json` file (if any new dependency required),
16-
- write an overview of what the PR attempts to do,
17-
- select the _Allow edits from maintainers_ option (see this [article](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) for more details).
18-
19-
Note that it is forbidden to force push (i.e. `git push -f`) to remote branches associated with opened pull requests. Force pushes make it hard for maintainers to keep track of updates. Therefore, if required, please `git merge master` into your PR branch instead of `git rebase master`.
20+
After opening a pull request, developer:
21+
- should create a new small markdown log file using the PR number e.g. `1010_fix.md` or `1010_add.md` inside `draftlogs` folder as described in this [README](https://github.com/plotly/plotly.js/blob/master/draftlogs/README.md), commit it and push.
22+
- should **not** force push (i.e. `git push -f`) to remote branches associated with opened pull requests. Force pushes make it hard for maintainers to keep track of updates. Therefore, if required, please fetch `upstream/master` and "merge" with master instead of "rebase".

Diff for: draftlogs/5779_fix.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Improve README for ES6 module import [[#5779](https://github.com/plotly/plotly.js/pull/5779)],
2+
with thanks to @andreafonso for the contribution!

Diff for: draftlogs/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Directory of draft logs to help prepare the upcoming [CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md)
2+
3+
Every pull request should add at least one markdown file to this directory.
4+
The filename must start with a number, preferably the PR number, followed by one of these:
5+
1. `_fix.md` to propose a bug fix
6+
2. `_add.md` to propose new features
7+
3. `_remove.md` to propose a feature removal
8+
4. `_change.md` to propose a minor/major change
9+
5. `_deprecate.md` to propose a feature be deprecated
10+
11+
If your PR falls into more than one category - for example adding a new feature and changing an existing feature - you should include each in a separate file.
12+
13+
### Example filename and content for PR numbered 5546 for adding a new feature
14+
- filename: `5546_add.md`
15+
- content:
16+
```
17+
- Add `icicle` trace type [[#5546](https://github.com/plotly/plotly.js/pull/5546)]
18+
```
19+
which would render
20+
- Add `icicle` trace type [[#5546](https://github.com/plotly/plotly.js/pull/5546)]
21+
22+
> Please start your single-line or multiple lined message with a verb. You could basically use the PR description while providing a link to the PR similar to the above example is appreciated too.

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
"stats": "node tasks/stats.js",
2828
"find-strings": "node tasks/find_locale_strings.js",
2929
"preprocess": "node tasks/preprocess.js",
30-
"build": "node tasks/empty_dist.js && npm run preprocess && npm run find-strings && npm run bundle && npm run extra-bundles && npm run stats",
31-
"cibuild": "node tasks/empty_dist.js && npm run preprocess && node tasks/cibundle.js",
30+
"use-draftlogs": "node tasks/use_draftlogs.js",
31+
"empty-draftlogs": "node tasks/empty_draftlogs.js",
32+
"empty-dist": "node tasks/empty_dist.js",
33+
"build": "npm run empty-dist && npm run preprocess && npm run find-strings && npm run bundle && npm run extra-bundles && npm run stats",
34+
"cibuild": "npm run empty-dist && npm run preprocess && node tasks/cibundle.js",
3235
"watch": "node tasks/watch.js",
3336
"lint": "eslint --version && eslint .",
3437
"lint-fix": "eslint . --fix || true",

Diff for: tasks/empty_dist.js

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
1-
var path = require('path');
2-
var fs = require('fs-extra');
3-
var common = require('./util/common');
41
var constants = require('./util/constants');
2+
var makeEmptyDirectory = require('./util/make_empty_directory');
3+
var emptyDir = makeEmptyDirectory.emptyDir;
4+
var makeDir = makeEmptyDirectory.makeDir;
55

66
var dist = constants.pathToDist; // dist
77
var distTopojson = constants.pathToTopojsonDist; // dist/topojson
8+
89
// main
910
emptyDir(distTopojson);
1011
emptyDir(dist);
1112
makeDir(dist);
1213
makeDir(distTopojson);
13-
14-
function emptyDir(dir) {
15-
if(common.doesDirExist(dir)) {
16-
console.log('empty ' + dir);
17-
try {
18-
var allFiles = fs.readdirSync(dir);
19-
allFiles.forEach(function(file) {
20-
// remove file
21-
fs.unlinkSync(path.join(dir, file));
22-
});
23-
24-
fs.rmdirSync(dir);
25-
} catch(err) {
26-
console.error(err);
27-
}
28-
}
29-
}
30-
31-
function makeDir(dir) {
32-
if(!common.doesDirExist(dir)) {
33-
// create folder
34-
fs.mkdirSync(dir);
35-
}
36-
}

Diff for: tasks/empty_draftlogs.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var constants = require('./util/constants');
2+
var makeEmptyDirectory = require('./util/make_empty_directory');
3+
var emptyDir = makeEmptyDirectory.emptyDir;
4+
var makeDir = makeEmptyDirectory.makeDir;
5+
6+
var pathToDraftlogs = constants.pathToDraftlogs;
7+
8+
var chZero = '0'.charCodeAt(0);
9+
var chNine = '9'.charCodeAt(0);
10+
11+
function startsWithNumber(v) {
12+
var ch = v.charCodeAt(0);
13+
return chZero <= ch && ch <= chNine;
14+
}
15+
16+
// main
17+
emptyDir(pathToDraftlogs, { filter: startsWithNumber });
18+
makeDir(pathToDraftlogs);

Diff for: tasks/use_draftlogs.js

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var constants = require('./util/constants');
4+
5+
var pathToDraftlogs = constants.pathToDraftlogs;
6+
var pathToChangelog = constants.pathToChangelog;
7+
8+
var chZero = '0'.charCodeAt(0);
9+
var chNine = '9'.charCodeAt(0);
10+
11+
function startsWithNumber(v) {
12+
var ch = v.charCodeAt(0);
13+
return chZero <= ch && ch <= chNine;
14+
}
15+
16+
var allLogs = fs.readdirSync(pathToDraftlogs).filter(startsWithNumber);
17+
18+
var len = allLogs.length;
19+
if(!len) return;
20+
21+
var writeAfterMe = 'where X.Y.Z is the semver of most recent plotly.js release.';
22+
var changelog = fs.readFileSync(pathToChangelog).toString().split(writeAfterMe);
23+
var head = changelog[0];
24+
var foot = changelog[1];
25+
26+
var all = {
27+
Added: [],
28+
Removed: [],
29+
Deprecated: [],
30+
Changed: [],
31+
Fixed: []
32+
};
33+
34+
var ENTER = '\n';
35+
36+
var skippedFiles = [];
37+
for(var i = 0; i < len; i++) {
38+
var filename = allLogs[i];
39+
var message = fs.readFileSync(path.join(pathToDraftlogs, filename), { encoding: 'utf-8' }).toString();
40+
// trim empty lines
41+
message = message.split(ENTER).filter(function(e) { return !!e; }).join(ENTER);
42+
43+
if(filename.endsWith('_add.md')) {
44+
all.Added.push(message);
45+
} else if(filename.endsWith('_remove.md')) {
46+
all.Removed.push(message);
47+
} else if(filename.endsWith('_deprecate.md')) {
48+
all.Deprecated.push(message);
49+
} else if(filename.endsWith('_change.md')) {
50+
all.Changed.push(message);
51+
} else if(filename.endsWith('_fix.md')) {
52+
all.Fixed.push(message);
53+
} else {
54+
skippedFiles.push(filename);
55+
}
56+
}
57+
58+
var draftNewChangelog = [
59+
head + writeAfterMe,
60+
'',
61+
'## [X.Y.Z] -- UNRELEASED'
62+
];
63+
64+
var append = function(key) {
65+
var newMessages = all[key];
66+
if(!newMessages.length) return;
67+
draftNewChangelog.push('');
68+
draftNewChangelog.push('### ' + key);
69+
draftNewChangelog.push(newMessages.join(ENTER));
70+
};
71+
72+
append('Added');
73+
append('Removed');
74+
append('Deprecated');
75+
append('Changed');
76+
append('Fixed');
77+
78+
draftNewChangelog.push(foot);
79+
80+
fs.writeFileSync(pathToChangelog, draftNewChangelog.join(ENTER), { encoding: 'utf-8' });
81+
82+
if(skippedFiles.length) {
83+
throw JSON.stringify({
84+
'skippedFiles': skippedFiles
85+
}, null, 2);
86+
}

Diff for: tasks/util/constants.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var pathToSrc = path.join(pathToRoot, 'src/');
77
var pathToLib = path.join(pathToRoot, 'lib/');
88
var pathToImageTest = path.join(pathToRoot, 'test/image');
99
var pathToStrictD3Module = path.join(pathToRoot, 'test/strict-d3.js');
10+
var pathToDraftlogs = path.join(pathToRoot, 'draftlogs/');
1011
var pathToDist = path.join(pathToRoot, 'dist/');
1112
var pathToBuild = path.join(pathToRoot, 'build/');
1213

@@ -168,6 +169,8 @@ module.exports = {
168169
pathToLib: pathToLib,
169170
pathToBuild: pathToBuild,
170171
pathToDist: pathToDist,
172+
pathToDraftlogs: pathToDraftlogs,
173+
pathToChangelog: path.join(pathToRoot, 'CHANGELOG.md'),
171174

172175
partialBundleTraces: partialBundleTraces,
173176

Diff for: tasks/util/make_empty_directory.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var path = require('path');
2+
var fs = require('fs-extra');
3+
var common = require('./common');
4+
5+
module.exports = {
6+
emptyDir: emptyDir,
7+
makeDir: makeDir
8+
};
9+
10+
function emptyDir(dir, opts) {
11+
if(common.doesDirExist(dir)) {
12+
console.log('empty ' + dir);
13+
try {
14+
var allFiles = fs.readdirSync(dir);
15+
var hasFilter = false;
16+
if(opts && opts.filter) {
17+
hasFilter = true;
18+
allFiles = allFiles.filter(opts.filter);
19+
}
20+
21+
allFiles.forEach(function(file) {
22+
// remove file
23+
fs.unlinkSync(path.join(dir, file));
24+
});
25+
26+
if(!hasFilter) {
27+
fs.rmdirSync(dir);
28+
}
29+
} catch(err) {
30+
console.error(err);
31+
}
32+
}
33+
}
34+
35+
function makeDir(dir) {
36+
if(!common.doesDirExist(dir)) {
37+
// create folder
38+
fs.mkdirSync(dir);
39+
}
40+
}

0 commit comments

Comments
 (0)