Skip to content

Commit

Permalink
Release script updates (#2582)
Browse files Browse the repository at this point in the history
* 2fa prompt

* build-docs memory
  • Loading branch information
thompsongl authored Dec 2, 2019
1 parent 705de53 commit 06fc9a6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "webpack-dev-server --port 8030 --inline --hot --config=src-docs/webpack.config.js",
"test-docker": "docker pull $npm_package_docker_image && docker run --rm -i -e GIT_COMMITTER_NAME=test -e GIT_COMMITTER_EMAIL=test --user=$(id -u):$(id -g) -e HOME=/tmp -v $(pwd):/app -w /app $npm_package_docker_image bash -c 'npm config set spin false && /opt/yarn*/bin/yarn && npm run test && npm run build'",
"sync-docs": "node ./scripts/docs-sync.js",
"build-docs": "cross-env NODE_ENV=production webpack --config=src-docs/webpack.config.js",
"build-docs": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 webpack --config=src-docs/webpack.config.js",
"build": "yarn extract-i18n-strings && node ./scripts/compile-clean.js && node ./scripts/compile-eui.js && node ./scripts/compile-scss.js $npm_package_name",
"compile-icons": "node ./scripts/compile-icons.js && prettier --write --loglevel=warn \"./src/components/icon/assets/**/*.js\"",
"extract-i18n-strings": "node ./scripts/babel/fetch-i18n-strings",
Expand Down
43 changes: 41 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ const humanReadableTypes = {
// push the version commit & tag to upstream
execSync('git push upstream --tags', execOptions);

// prompt user for npm 2FA
const otp = await getOneTimePassword();

// publish new version to npm
execSync('npm publish', execOptions);
execSync(`npm publish --otp=${otp}`, execOptions);

// update docs, git commit, git push
execSync('npm run sync-docs', execOptions);
Expand All @@ -75,7 +78,7 @@ async function getVersionTypeFromChangelog() {

// Sanity check, if the changelog contains "No public interface changes"then we shouldn't be releasing
if (changelog.indexOf('No public interface changes') !== -1) {
console.error(`Unable to release: CHANGELOG.md indicates "No public interface changes"`);
console.error('Unable to release: CHANGELOG.md indicates "No public interface changes"');
process.exit(1);
}

Expand Down Expand Up @@ -153,3 +156,39 @@ async function promptUserForVersionType() {
);
});
}

async function getOneTimePassword() {
const version = require('../package.json').version
console.log(chalk.magenta(`Preparing to publish @elastic/eui@${version} to npm registry`));
console.log('');
console.log(chalk.magenta('The @elastic organization requires membership and 2FA to publish'));
console.log(chalk.magenta('What is your one-time password?'));

return await promptUserForOneTimePassword();
}

async function promptUserForOneTimePassword() {
return new Promise((resolve, reject) => {
prompt.message = '';
prompt.delimiter = '';
prompt.start();
prompt.get(
{
properties: {
otp: {
description: 'Enter password:',
message: 'One-time password is required',
required: true
},
}
},
(err, { otp }) => {
if (err) {
reject(err);
} else {
resolve(otp);
}
}
);
});
}

0 comments on commit 06fc9a6

Please sign in to comment.