Skip to content

Commit

Permalink
fix: pass interactive flag to all prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Sep 10, 2024
1 parent 255ef5f commit 6c3a817
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@subsquid/cli",
"description": "squid cli tool",
"version": "3.0.0-beta.5",
"version": "3.0.0-beta.6",
"license": "GPL-3.0-or-later",
"repository": "[email protected]:subsquid/squid-cli.git",
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ export default class Deploy extends DeployCommand {
* Squid exists we should check running deploys
*/
if (target) {
const attached = await this.promptAttachToDeploy(target);
const attached = await this.promptAttachToDeploy(target, { interactive });
if (attached) return;
}

/**
* Squid exists we should ask for update
*/
if (target && !force) {
const update = await this.promptUpdateSquid(target);
const update = await this.promptUpdateSquid(target, { interactive });
if (!update) return;
}

Expand All @@ -244,7 +244,7 @@ export default class Deploy extends DeployCommand {
*/
const hasTag = !!target?.tags.find((t) => t.name === addTag) || tag === addTag;
if (addTag && !force && !hasTag) {
const add = await this.promptAddTag({ organization, name, tag: addTag });
const add = await this.promptAddTag({ organization, name, tag: addTag }, { interactive });
if (!add) return;
}

Expand Down
15 changes: 11 additions & 4 deletions src/deploy-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ export abstract class DeployCommand extends CliCommand {
deploy: Deployment | undefined;
logsPrinted = 0;

async promptAttachToDeploy(squid: Squid) {
async promptAttachToDeploy(squid: Squid, { interactive }: { interactive?: boolean } = {}) {
if (!squid.lastDeploy) return false;
if (squid.status !== 'DEPLOYING') return false;

const warning = `Squid "${formatSquidReference(squid)}" is being deploying.
You can not run deploys on the same squid in parallel`;

if (!interactive) {
this.error(warning);
}

this.warn(warning);

switch (squid.lastDeploy.type) {
// we should react only for running deploy
case 'DEPLOY':
const { confirm } = await inquirer.prompt([
{
name: 'confirm',
type: 'confirm',
message: `Squid "${formatSquidReference(squid)}" is being deploying.
You can not run deploys on the same squid in parallel.
Do you want to attach to the running deploy process?`,
message: `Do you want to attach to the running deploy process?`,
},
]);
if (!confirm) return false;
Expand Down

0 comments on commit 6c3a817

Please sign in to comment.