Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-5593: Allow users to push non-logical changes #278

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/commands/schema/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class PushSchemaCommand extends SchemaCommand {
}),
};

async confirm() {
const resp = await ux.prompt("Accept and push the changes?", {
async confirm(msg) {
const resp = await ux.prompt(msg, {
default: "no",
});
if (["yes", "y"].includes(resp.toLowerCase())) {
Expand All @@ -22,7 +22,7 @@ class PushSchemaCommand extends SchemaCommand {
return false;
}
console.log("Please type 'yes' or 'no'");
return this.confirm();
return this.confirm(msg);
}

async run() {
Expand Down Expand Up @@ -52,13 +52,15 @@ class PushSchemaCommand extends SchemaCommand {
if (json.error) {
this.error(json.error.message);
}
if (!json.diff) {
this.log("No changes to push");
this.exit(0);
let msg = "Accept and push changes?"
if (json.diff) {
this.log(`Proposed diff:\n`);
this.log(json.diff);
} else {
this.log("No logical changes.");
msg = "Push file contents anyway?"
}
this.log(`Proposed diff:\n`);
this.log(json.diff);
if (await this.confirm()) {
if (await this.confirm(msg)) {
const res = await fetch(
`${urlbase}/schema/1/update?version=${json.version}`,
{
Expand All @@ -72,7 +74,7 @@ class PushSchemaCommand extends SchemaCommand {
this.error(json0.error.message);
}
} else {
this.log("Change cancelled");
this.log("Push cancelled");
}
}
} catch (err) {
Expand Down