Skip to content

Commit

Permalink
fix: OTP input not working
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Apr 22, 2021
1 parent 8591aaa commit ded9a9e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/cli-core/GitUtilities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');

const execa = require('execa');
const gitDefaultBranch = require('git-default-branch');
const slash = require('slash');

function hasTag(tag) {
Expand All @@ -18,6 +19,8 @@ const repoName = (name) => name.replace(/^@.+\//, '');

exports.repoName = repoName;

exports.getDefaultBranch = () => gitDefaultBranch();

exports.getRemoteUrl = (cwd) =>
execa('git', ['config', 'remote.origin.url'], { cwd })
.then((r) => r.stdout)
Expand Down
1 change: 1 addition & 0 deletions packages/cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"chalk": "^4.0.0",
"execa": "^5.0.0",
"fs-extra": "^9.1.0",
"git-default-branch": "^1.0.0",
"globby": "^11.0.2",
"inquirer": "^7.3.3",
"is-ci": "^2.0.0",
Expand Down
22 changes: 16 additions & 6 deletions packages/rollout/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ConsoleUtilities = require('@4c/cli-core/ConsoleUtilities');
const GitUtilities = require('@4c/cli-core/GitUtilities');
const PromptUtilities = require('@4c/cli-core/PromptUtilities');
const { createAltPublishDir } = require('@4c/file-butler');
const exitHook = require('async-exit-hook');
const chalk = require('chalk');
const execa = require('execa');
const fs = require('fs-extra');
Expand All @@ -28,11 +29,13 @@ async function runLifecycle(script, pkg) {
}

let rolledBack = false;
async function maybeRollbackGit(tag, skipGit, skipVersion) {
async function maybeRollbackGit(tag, skipGit, skipVersion, prompt = true) {
if (skipGit || rolledBack) return;
const confirmed = await PromptUtilities.confirm(
'There was a problem publishing, do you want to rollback the git operations?',
);
const confirmed =
!prompt ||
(await PromptUtilities.confirm(
'There was a problem publishing, do you want to rollback the git operations?',
));

rolledBack = true;
if (!confirmed) return;
Expand Down Expand Up @@ -142,7 +145,7 @@ async function npmPublish(pkgJson, options) {
args.push('--access', isPublic ? 'public' : 'restricted');
}

const child = await execa('npm', args, { stdio: [0, 1, 'pipe'] });
const child = await execa('npm', args);

if (publishDir) {
await runLifecycle('publish', pkgJson);
Expand Down Expand Up @@ -231,7 +234,7 @@ const handler = async (argv) => {
skipVersion,
conventionalCommits,
public: isPublic,
allowBranch = ['master'],
allowBranch = ['main', 'master'],
} = { ...packageJson.release, ...argv };

let { publishDir, nextVersion: version } = argv;
Expand Down Expand Up @@ -305,6 +308,7 @@ const handler = async (argv) => {
},
{
title: 'Running tests',
skip: () => skipChecks,
task: () => exec('npm', ['test']),
},
]);
Expand Down Expand Up @@ -334,6 +338,12 @@ const handler = async (argv) => {
const gitTag = `v${nextVersion}`;

try {
exitHook((callback = () => {}) => {
maybeRollbackGit(gitTag, skipGit, skipVersion, false).then(() =>
callback(),
);
});

await runTasks([
{
title: isSameVersion
Expand Down
1 change: 1 addition & 0 deletions packages/rollout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@4c/cli-core": "^2.2.0",
"@4c/file-butler": "^4.2.0",
"async-exit-hook": "^2.0.1",
"chalk": "^4.0.0",
"conventional-changelog": "^3.1.24",
"conventional-recommended-bump": "^6.1.0",
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,11 @@ async-each@^1.0.1:
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==

async-exit-hook@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/async-exit-hook/-/async-exit-hook-2.0.1.tgz#8bd8b024b0ec9b1c01cccb9af9db29bd717dfaf3"
integrity sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==

async-limiter@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
Expand Down Expand Up @@ -5896,6 +5901,11 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

git-default-branch@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/git-default-branch/-/git-default-branch-1.0.0.tgz#5e6eeb3ac9e4c89500514d53b0f8773183c80b6d"
integrity sha512-/eBj13g+SDiPnRMO82wTCA6P0Xi413TWSeyjf5Qj/vdLzn7iXROotuElMF4fNxNlL7TMbUjUW1EHjd3E9OAItQ==

git-raw-commits@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.0.tgz#d92addf74440c14bcc5c83ecce3fb7f8a79118b5"
Expand Down

0 comments on commit ded9a9e

Please sign in to comment.