mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
[rrm] Lint
This commit is contained in:
parent
e3a41edd83
commit
cfd782471b
|
|
@ -15,3 +15,4 @@ build/
|
|||
coverage/
|
||||
scripts/bench/bench-*.js
|
||||
vendor/*
|
||||
**/node_modules
|
||||
|
|
|
|||
7
scripts/release-manager/.eslintrc.js
Normal file
7
scripts/release-manager/.eslintrc.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
'no-shadow': 0,
|
||||
},
|
||||
};
|
||||
|
|
@ -23,6 +23,16 @@ const PATH_TO_REPO = path.resolve('../../../react');
|
|||
// actually running the command, ensuring no accidental publishing.
|
||||
const DRY_RUN = false;
|
||||
|
||||
// Enabled commands
|
||||
const COMMANDS = [
|
||||
'init',
|
||||
'docs-prs',
|
||||
'q',
|
||||
'stable-prs',
|
||||
'version',
|
||||
'npm-publish',
|
||||
];
|
||||
|
||||
|
||||
// HELPERS
|
||||
|
||||
|
|
@ -65,7 +75,7 @@ function gitCherryPickMerge(sha) {
|
|||
// TODO: gracefully handle other cases, like possibility the commit was
|
||||
// already cherry-picked and should be skipped.
|
||||
|
||||
execInRepo(`git cherry-pick -x -m1 ${sha}`)
|
||||
execInRepo(`git cherry-pick -x -m1 ${sha}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +99,7 @@ const app = {
|
|||
} catch (e) {
|
||||
this.config = {
|
||||
token: null,
|
||||
}
|
||||
};
|
||||
console.error('Could not read .config.json. Rate limits are much stricter as a result. Run init to setup.');
|
||||
}
|
||||
|
||||
|
|
@ -109,14 +119,7 @@ const app = {
|
|||
this.getReactVersion = getReactVersion;
|
||||
|
||||
// Register commands
|
||||
[
|
||||
'init',
|
||||
'docs-prs',
|
||||
'q',
|
||||
'stable-prs',
|
||||
'version',
|
||||
'npm-publish',
|
||||
].forEach((command) => {
|
||||
COMMANDS.forEach((command) => {
|
||||
vorpal.use(require(`./commands/${command}`)(vorpal, app));
|
||||
});
|
||||
|
||||
|
|
@ -124,7 +127,7 @@ const app = {
|
|||
.history('react-release-manager')
|
||||
.delimiter('rrm \u2234')
|
||||
.show();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
app.init();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
const chalk = require('chalk');
|
||||
|
||||
const DOCS_LABEL = 'Documentation: needs merge to stable';
|
||||
const DOCS_URL = 'https://github.com/facebook/react/issues?q=label%3A%22Documentation%3A+needs+merge+to+stable%22+is%3Aclosed'
|
||||
|
||||
// FOR DOCS
|
||||
// get all issues with label
|
||||
|
|
@ -24,7 +23,7 @@ module.exports = function(vorpal, app) {
|
|||
vorpal
|
||||
.command('docs-prs')
|
||||
.description('Get list of documentation pull requests that need to be merged to the stable branch')
|
||||
.action(function (args, actionCB) {
|
||||
.action(function(args, actionCB) {
|
||||
const query = {
|
||||
labels: [DOCS_LABEL].join(), // github-api doesn't join automatically
|
||||
state: 'closed',
|
||||
|
|
@ -63,11 +62,11 @@ module.exports = function(vorpal, app) {
|
|||
richPulls.forEach((pr) => {
|
||||
// Convert merged_at to real Date for sorting
|
||||
pr.merged_at_date = new Date(pr.merged_at);
|
||||
})
|
||||
});
|
||||
|
||||
richPulls = richPulls.sort((a, b) => a.merged_at_date - b.merged_at_date);
|
||||
|
||||
this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`)
|
||||
this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`);
|
||||
richPulls.forEach((pr) => {
|
||||
this.log(`${pr.html_url}: ${chalk.bold(pr.title)}`);
|
||||
});
|
||||
|
|
@ -75,7 +74,7 @@ module.exports = function(vorpal, app) {
|
|||
this.prompt({
|
||||
name: 'merge',
|
||||
type: 'confirm',
|
||||
message: `Merge these ${richPulls.length} pull requests?`
|
||||
message: `Merge these ${richPulls.length} pull requests?`,
|
||||
}, (res) => {
|
||||
if (res.merge) {
|
||||
richPulls.forEach((pr) => {
|
||||
|
|
@ -89,7 +88,7 @@ module.exports = function(vorpal, app) {
|
|||
}, (res) => {
|
||||
if (res.push) {
|
||||
app.execInRepo('git push');
|
||||
this.log(`Pushed upstream! Removing "${DOCS_LABEL}" label from pull requests.`)
|
||||
this.log(`Pushed upstream! Removing "${DOCS_LABEL}" label from pull requests.`);
|
||||
}
|
||||
|
||||
// TODO: actually test this
|
||||
|
|
@ -109,9 +108,9 @@ module.exports = function(vorpal, app) {
|
|||
});
|
||||
|
||||
Promise.all(removeLabelsPromises).then(() => {
|
||||
this.log('Done!')
|
||||
this.log('Done!');
|
||||
actionCB();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
|
|
@ -125,4 +124,4 @@ module.exports = function(vorpal, app) {
|
|||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ module.exports = function(vorpal, options) {
|
|||
{
|
||||
name: 'token',
|
||||
type: 'input',
|
||||
message: `${chalk.bold('GitHub token?')} ${chalk.grey('(needs "repo" privs)')} `
|
||||
}
|
||||
message: `${chalk.bold('GitHub token?')} ${chalk.grey('(needs "repo" privs)')} `,
|
||||
},
|
||||
]).then((answers) => {
|
||||
fs.writeFile(FILENAME, JSON.stringify(answers, null, 2), (err) => {
|
||||
if (err) {
|
||||
|
|
@ -38,4 +38,4 @@ module.exports = function(vorpal, options) {
|
|||
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
const path = require('path');
|
||||
const semver = require('semver');
|
||||
|
||||
const chalk = require('chalk');
|
||||
const glob = require('glob');
|
||||
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ module.exports = function(vorpal, app) {
|
|||
vorpal
|
||||
.command('npm-publish')
|
||||
.description('Update the version of React, useful while publishing')
|
||||
.action(function (args) {
|
||||
.action(function(args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const currentVersion = app.getReactVersion();
|
||||
const isStable = semver.prerelease(currentVersion) === null;
|
||||
|
|
@ -33,11 +32,11 @@ module.exports = function(vorpal, app) {
|
|||
{
|
||||
type: 'confirm',
|
||||
message: 'Did you run `grunt build` or `grunt release` and bump the version number?',
|
||||
name: 'checklist'
|
||||
name: 'checklist',
|
||||
},
|
||||
]).then((answers) => {
|
||||
if (!answers.checklist) {
|
||||
return reject('Complete the build process first')
|
||||
return reject('Complete the build process first');
|
||||
}
|
||||
|
||||
// We'll grab all the tarballs and publish those directly. This
|
||||
|
|
@ -45,7 +44,7 @@ module.exports = function(vorpal, app) {
|
|||
// just npm publish pkg1.tgz && npm publish pkg2.tgz. This
|
||||
// avoided the need to cd and publish.
|
||||
const tgz = glob.sync('build/packages/*.tgz', {
|
||||
cwd: app.PATH_TO_REPO
|
||||
cwd: app.PATH_TO_REPO,
|
||||
});
|
||||
|
||||
// Just in case they didn't actually prep this.
|
||||
|
|
@ -61,14 +60,14 @@ module.exports = function(vorpal, app) {
|
|||
|
||||
if (isStable) {
|
||||
tgz.forEach((file) => {
|
||||
const pkg = path.parse(file).name
|
||||
const pkg = path.parse(file).name;
|
||||
this.log(app.execInRepo(`npm dist-tag add ${pkg}@${currentVersion} latest`));
|
||||
});
|
||||
}
|
||||
|
||||
resolve();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ module.exports = function(vorpal, config) {
|
|||
.action((args, cb) => {
|
||||
vorpal.exec('exit').then(cb);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ module.exports = function(vorpal, app) {
|
|||
vorpal
|
||||
.command('stable-prs')
|
||||
.description('Get list of stable pull requests that need to be merged to the stable branch')
|
||||
.action(function (args, actionCB) {
|
||||
.action(function(args, actionCB) {
|
||||
// TODO: stop assuming this all fits into a single
|
||||
const query = {
|
||||
milestone: MILESTONE_NUMBER,
|
||||
|
|
@ -63,7 +63,7 @@ module.exports = function(vorpal, app) {
|
|||
return true;
|
||||
}
|
||||
|
||||
return issue.labels.some((label) => LABELS[label.name])
|
||||
return issue.labels.some((label) => LABELS[label.name]);
|
||||
});
|
||||
|
||||
// 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) {
|
|||
richPulls.forEach((pr) => {
|
||||
// Convert merged_at to real Date for sorting
|
||||
pr.merged_at_date = new Date(pr.merged_at);
|
||||
})
|
||||
});
|
||||
|
||||
richPulls = richPulls.sort((a, b) => a.merged_at_date - b.merged_at_date);
|
||||
|
||||
this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`)
|
||||
this.log(`Found ${chalk.bold(richPulls.length)} pull requests:`);
|
||||
|
||||
promptForPRs.call(this, app, richPulls, 0).then(() => {
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ module.exports = function(vorpal, app) {
|
|||
|
||||
const milestonePromises = richPulls.map((pr) => {
|
||||
return app.ghissues.editIssue(pr.number, {
|
||||
milestone: TARGET_MILESTONE_NUMBER
|
||||
milestone: TARGET_MILESTONE_NUMBER,
|
||||
});
|
||||
});
|
||||
Promise.all(milestonePromises).then(actionCB);
|
||||
|
|
@ -123,7 +123,7 @@ module.exports = function(vorpal, app) {
|
|||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// TODO: pull this out to some shared place. We can reuse this for docs.
|
||||
|
|
@ -165,7 +165,7 @@ function promptForPRs(app, prs, start) {
|
|||
|
||||
// Make sure we resolve in case there were no issues
|
||||
if (!failed) {
|
||||
resolve()
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ function updateJSON(path, fields, value) {
|
|||
let data;
|
||||
try {
|
||||
data = JSON.parse(fs.readFileSync(path, 'utf8'));
|
||||
} catch(e) {
|
||||
this.log(chalk.color.red('ERROR') + ` ${path} doesn't exist… skipping.`)
|
||||
} catch (e) {
|
||||
this.log(chalk.color.red('ERROR') + ` ${path} doesn't exist… skipping.`);
|
||||
}
|
||||
fields.forEach((field) => {
|
||||
let fieldPath = field.split('.');
|
||||
|
|
@ -46,19 +46,19 @@ module.exports = function(vorpal, app) {
|
|||
vorpal
|
||||
.command('version')
|
||||
.description('Update the version of React, useful while publishing')
|
||||
.action(function (args, actionCB) {
|
||||
.action(function(args, actionCB) {
|
||||
|
||||
let currentVersion = app.getReactVersion()
|
||||
let currentVersion = app.getReactVersion();
|
||||
|
||||
// TODO: See if we can do a better job for handling pre* bumps. The ones
|
||||
// semver adds are of the form -0, but we've used -alpha.0 or -rc.0.
|
||||
// 'prerelease' will increment those properly (but otherwise has the same problem).
|
||||
// Live with it for now since it won't be super common. Write docs.
|
||||
let choices = ['prerelease' , 'patch', 'minor', 'major'].map((release) => {
|
||||
let choices = ['prerelease', 'patch', 'minor', 'major'].map((release) => {
|
||||
let version = semver.inc(currentVersion, release);
|
||||
return {
|
||||
value: version,
|
||||
name:`${chalk.bold(version)} (${release})`
|
||||
name:`${chalk.bold(version)} (${release})`,
|
||||
};
|
||||
});
|
||||
choices.push('Other');
|
||||
|
|
@ -74,8 +74,8 @@ module.exports = function(vorpal, app) {
|
|||
type: 'input',
|
||||
name: 'version',
|
||||
message: `New version (currently ${chalk.bold(currentVersion)}): `,
|
||||
when: (res) => res.version === 'Other'
|
||||
}
|
||||
when: (res) => res.version === 'Other',
|
||||
},
|
||||
]).then((res) => {
|
||||
let newVersion = semver.valid(res.version);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ module.exports = function(vorpal, app) {
|
|||
// We also need to update src/ReactVersion.js which has the version in
|
||||
// string form in JS code. We'll just do a string replace.
|
||||
|
||||
const PATH_TO_REACTVERSION = path.join(app.PATH_TO_REPO, 'src/ReactVersion.js');
|
||||
const PATH_TO_REACTVERSION = path.join(app.PATH_TO_REPO, 'src/ReactVersion.js');
|
||||
|
||||
let reactVersionContents = fs.readFileSync(PATH_TO_REACTVERSION, 'utf8');
|
||||
|
||||
|
|
@ -148,8 +148,8 @@ module.exports = function(vorpal, app) {
|
|||
app.execInRepo(`git tag v${newVersion}`);
|
||||
}
|
||||
actionCB();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user