[rrm] Lint
Paul O’Shannessy committed
Jul 22, 2016 at 13:38 UTC
cfd782471bbf59f908f91fea6b69db6af3d10987
9 files changed
+60
-51
.eslintignore
+1
@@ -15,3 +15,4 @@ build/
15
coverage/
16
scripts/bench/bench-*.js
17
vendor/*
18
+**/node_modules
scripts/release-manager/.eslintrc.js
new
+7
@@ -0,0 +1,7 @@
1
+'use strict';
2
+
3
+module.exports = {
4
+ rules: {
5
+ 'no-shadow': 0,
6
+ },
7
+};
scripts/release-manager/cli.js
+15
-12
@@ -23,6 +23,16 @@ const PATH_TO_REPO = path.resolve('../../../react');
23
// actually running the command, ensuring no accidental publishing.
24
const DRY_RUN = false;
25
26
+// Enabled commands
27
+const COMMANDS = [
28
+ 'init',
29
+ 'docs-prs',
30
+ 'q',
31
+ 'stable-prs',
32
+ 'version',
33
+ 'npm-publish',
34
+];
35
+
36
37
// HELPERS
38
@@ -65,7 +75,7 @@ function gitCherryPickMerge(sha) {
75
// TODO: gracefully handle other cases, like possibility the commit was
76
// already cherry-picked and should be skipped.
77
68
- execInRepo(`git cherry-pick -x -m1 ${sha}`)
78
+ execInRepo(`git cherry-pick -x -m1 ${sha}`);
79
}
80
}
81
@@ -89,7 +99,7 @@ const app = {
99
} catch (e) {
100
this.config = {
101
token: null,
92
- }
102
+ };
103
console.error('Could not read .config.json. Rate limits are much stricter as a result. Run init to setup.');
104
}
105
@@ -109,14 +119,7 @@ const app = {
119
this.getReactVersion = getReactVersion;
120
121
// Register commands
112
- [
113
- 'init',
114
- 'docs-prs',
115
- 'q',
116
- 'stable-prs',
117
- 'version',
118
- 'npm-publish',
119
- ].forEach((command) => {
122
+ COMMANDS.forEach((command) => {
123
vorpal.use(require(`./commands/${command}`)(vorpal, app));
124
});
125
@@ -124,7 +127,7 @@ const app = {
127
.history('react-release-manager')
128
.delimiter('rrm \u2234')
129
.show();
127
- }
128
-}
130
+ },
131
+};
132
133
app.init();
scripts/release-manager/commands/docs-prs.js
+8
-9
@@ -3,7 +3,6 @@
3
const chalk = require('chalk');
4
5
const DOCS_LABEL = 'Documentation: needs merge to stable';
6
-const DOCS_URL = 'https://github.com/facebook/react/issues?q=label%3A%22Documentation%3A+needs+merge+to+stable%22+is%3Aclosed'
6
7
// FOR DOCS
8
// get all issues with label
@@ -24,7 +23,7 @@ module.exports = function(vorpal, app) {
23
vorpal
24
.command('docs-prs')
25
.description('Get list of documentation pull requests that need to be merged to the stable branch')
27
- .action(function (args, actionCB) {
26
+ .action(function(args, actionCB) {
27
const query = {
28
labels: [DOCS_LABEL].join(), // github-api doesn't join automatically
29
state: 'closed',
@@ -63,11 +62,11 @@ module.exports = function(vorpal, app) {
62
richPulls.forEach((pr) => {
63
// Convert merged_at to real Date for sorting
64
pr.merged_at_date = new Date(pr.merged_at);
66
- })
65
+ });
66
67
richPulls = richPulls.sort((a, b) => a.merged_at_date - b.merged_at_date);
68
70
- this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`)
69
+ this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`);
70
richPulls.forEach((pr) => {
71
this.log(`${pr.html_url}: ${chalk.bold(pr.title)}`);
72
});
@@ -75,7 +74,7 @@ module.exports = function(vorpal, app) {
74
this.prompt({
75
name: 'merge',
76
type: 'confirm',
78
- message: `Merge these ${richPulls.length} pull requests?`
77
+ message: `Merge these ${richPulls.length} pull requests?`,
78
}, (res) => {
79
if (res.merge) {
80
richPulls.forEach((pr) => {
@@ -89,7 +88,7 @@ module.exports = function(vorpal, app) {
88
}, (res) => {
89
if (res.push) {
90
app.execInRepo('git push');
92
- this.log(`Pushed upstream! Removing "${DOCS_LABEL}" label from pull requests.`)
91
+ this.log(`Pushed upstream! Removing "${DOCS_LABEL}" label from pull requests.`);
92
}
93
94
// TODO: actually test this
@@ -109,9 +108,9 @@ module.exports = function(vorpal, app) {
108
});
109
110
Promise.all(removeLabelsPromises).then(() => {
112
- this.log('Done!')
111
+ this.log('Done!');
112
actionCB();
114
- })
113
+ });
114
});
115
116
} else {
@@ -125,4 +124,4 @@ module.exports = function(vorpal, app) {
124
});
125
126
});
128
-}
127
+};
scripts/release-manager/commands/init.js
+3
-3
@@ -25,8 +25,8 @@ module.exports = function(vorpal, options) {
25
{
26
name: 'token',
27
type: 'input',
28
- message: `${chalk.bold('GitHub token?')} ${chalk.grey('(needs "repo" privs)')} `
29
- }
28
+ message: `${chalk.bold('GitHub token?')} ${chalk.grey('(needs "repo" privs)')} `,
29
+ },
30
]).then((answers) => {
31
fs.writeFile(FILENAME, JSON.stringify(answers, null, 2), (err) => {
32
if (err) {
@@ -38,4 +38,4 @@ module.exports = function(vorpal, options) {
38
39
});
40
});
41
-}
41
+};
scripts/release-manager/commands/npm-publish.js
+7
-8
@@ -10,7 +10,6 @@
10
const path = require('path');
11
const semver = require('semver');
12
13
-const chalk = require('chalk');
13
const glob = require('glob');
14
15
@@ -18,7 +17,7 @@ module.exports = function(vorpal, app) {
17
vorpal
18
.command('npm-publish')
19
.description('Update the version of React, useful while publishing')
21
- .action(function (args) {
20
+ .action(function(args) {
21
return new Promise((resolve, reject) => {
22
const currentVersion = app.getReactVersion();
23
const isStable = semver.prerelease(currentVersion) === null;
@@ -33,11 +32,11 @@ module.exports = function(vorpal, app) {
32
{
33
type: 'confirm',
34
message: 'Did you run `grunt build` or `grunt release` and bump the version number?',
36
- name: 'checklist'
35
+ name: 'checklist',
36
},
37
]).then((answers) => {
38
if (!answers.checklist) {
40
- return reject('Complete the build process first')
39
+ return reject('Complete the build process first');
40
}
41
42
// We'll grab all the tarballs and publish those directly. This
@@ -45,7 +44,7 @@ module.exports = function(vorpal, app) {
44
// just npm publish pkg1.tgz && npm publish pkg2.tgz. This
45
// avoided the need to cd and publish.
46
const tgz = glob.sync('build/packages/*.tgz', {
48
- cwd: app.PATH_TO_REPO
47
+ cwd: app.PATH_TO_REPO,
48
});
49
50
// Just in case they didn't actually prep this.
@@ -61,14 +60,14 @@ module.exports = function(vorpal, app) {
60
61
if (isStable) {
62
tgz.forEach((file) => {
64
- const pkg = path.parse(file).name
63
+ const pkg = path.parse(file).name;
64
this.log(app.execInRepo(`npm dist-tag add ${pkg}@${currentVersion} latest`));
65
});
66
}
67
68
resolve();
70
- })
69
+ });
70
});
71
72
});
74
-}
73
+};
scripts/release-manager/commands/q.js
+1
-1
@@ -11,4 +11,4 @@ module.exports = function(vorpal, config) {
11
.action((args, cb) => {
12
vorpal.exec('exit').then(cb);
13
});
14
-}
14
+};
scripts/release-manager/commands/stable-prs.js
+7
-7
@@ -34,7 +34,7 @@ module.exports = function(vorpal, app) {
34
vorpal
35
.command('stable-prs')
36
.description('Get list of stable pull requests that need to be merged to the stable branch')
37
- .action(function (args, actionCB) {
37
+ .action(function(args, actionCB) {
38
// TODO: stop assuming this all fits into a single
39
const query = {
40
milestone: MILESTONE_NUMBER,
@@ -63,7 +63,7 @@ module.exports = function(vorpal, app) {
63
return true;
64
}
65
66
- return issue.labels.some((label) => LABELS[label.name])
66
+ return issue.labels.some((label) => LABELS[label.name]);
67
});
68
69
// We don't enough data about the pull request (merge sha or merge time) so we
@@ -98,11 +98,11 @@ module.exports = function(vorpal, app) {
98
richPulls.forEach((pr) => {
99
// Convert merged_at to real Date for sorting
100
pr.merged_at_date = new Date(pr.merged_at);
101
- })
101
+ });
102
103
richPulls = richPulls.sort((a, b) => a.merged_at_date - b.merged_at_date);
104
105
- this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`)
105
+ this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`);
106
107
promptForPRs.call(this, app, richPulls, 0).then(() => {
108
@@ -113,7 +113,7 @@ module.exports = function(vorpal, app) {
113
114
const milestonePromises = richPulls.map((pr) => {
115
return app.ghissues.editIssue(pr.number, {
116
- milestone: TARGET_MILESTONE_NUMBER
116
+ milestone: TARGET_MILESTONE_NUMBER,
117
});
118
});
119
Promise.all(milestonePromises).then(actionCB);
@@ -123,7 +123,7 @@ module.exports = function(vorpal, app) {
123
});
124
125
});
126
-}
126
+};
127
128
129
// TODO: pull this out to some shared place. We can reuse this for docs.
@@ -165,7 +165,7 @@ function promptForPRs(app, prs, start) {
165
166
// Make sure we resolve in case there were no issues
167
if (!failed) {
168
- resolve()
168
+ resolve();
169
}
170
});
171
});
scripts/release-manager/commands/version.js
+11
-11
@@ -25,8 +25,8 @@ function updateJSON(path, fields, value) {
25
let data;
26
try {
27
data = JSON.parse(fs.readFileSync(path, 'utf8'));
28
- } catch(e) {
29
- this.log(chalk.color.red('ERROR') + ` ${path} doesn't exist… skipping.`)
28
+ } catch (e) {
29
+ this.log(chalk.color.red('ERROR') + ` ${path} doesn't exist… skipping.`);
30
}
31
fields.forEach((field) => {
32
let fieldPath = field.split('.');
@@ -46,19 +46,19 @@ module.exports = function(vorpal, app) {
46
vorpal
47
.command('version')
48
.description('Update the version of React, useful while publishing')
49
- .action(function (args, actionCB) {
49
+ .action(function(args, actionCB) {
50
51
- let currentVersion = app.getReactVersion()
51
+ let currentVersion = app.getReactVersion();
52
53
// TODO: See if we can do a better job for handling pre* bumps. The ones
54
// semver adds are of the form -0, but we've used -alpha.0 or -rc.0.
55
// 'prerelease' will increment those properly (but otherwise has the same problem).
56
// Live with it for now since it won't be super common. Write docs.
57
- let choices = ['prerelease' , 'patch', 'minor', 'major'].map((release) => {
57
+ let choices = ['prerelease', 'patch', 'minor', 'major'].map((release) => {
58
let version = semver.inc(currentVersion, release);
59
return {
60
value: version,
61
- name:`${chalk.bold(version)} (${release})`
61
+ name:`${chalk.bold(version)} (${release})`,
62
};
63
});
64
choices.push('Other');
@@ -74,8 +74,8 @@ module.exports = function(vorpal, app) {
74
type: 'input',
75
name: 'version',
76
message: `New version (currently ${chalk.bold(currentVersion)}): `,
77
- when: (res) => res.version === 'Other'
78
- }
77
+ when: (res) => res.version === 'Other',
78
+ },
79
]).then((res) => {
80
let newVersion = semver.valid(res.version);
81
@@ -118,7 +118,7 @@ module.exports = function(vorpal, app) {
118
// We also need to update src/ReactVersion.js which has the version in
119
// string form in JS code. We'll just do a string replace.
120
121
- const PATH_TO_REACTVERSION = path.join(app.PATH_TO_REPO, 'src/ReactVersion.js');
121
+ const PATH_TO_REACTVERSION = path.join(app.PATH_TO_REPO, 'src/ReactVersion.js');
122
123
let reactVersionContents = fs.readFileSync(PATH_TO_REACTVERSION, 'utf8');
124
@@ -148,8 +148,8 @@ module.exports = function(vorpal, app) {
148
app.execInRepo(`git tag v${newVersion}`);
149
}
150
actionCB();
151
- })
151
+ });
152
});
153
154
});
155
-}
155
+};