Skip to content

Commit

Permalink
roar
Browse files Browse the repository at this point in the history
  • Loading branch information
stopachka committed Nov 26, 2024
1 parent 51dc37d commit 3485af9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions client/packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import version from "./src/version.js";
import { mkdir, writeFile, readFile, stat } from "fs/promises";
import { join } from "path";
import { randomUUID } from "crypto";
import jsonDiff from "json-diff";
import jsonDiff, { diff } from "json-diff";
import dotenv from "dotenv";
import chalk from "chalk";
import { program, Option } from "commander";
Expand Down Expand Up @@ -1065,10 +1065,6 @@ async function pushSchema(appId, opts) {
return true;
}

function printPermChanges(prodPerms, candidatePerms) {
console.log(jsonDiff.diffString(prodPerms, candidatePerms));
}

async function pushPerms(appId) {
const perms = await readLocalPermsFileWithErrorLogging();
if (!perms) {
Expand All @@ -1085,14 +1081,17 @@ async function pushPerms(appId) {

if (!prodPerms.ok) return;

const diffedStr = jsonDiff.diffString(prodPerms.data.perms, perms)
if (!diffedStr.length) {
console.log("There are no changes to apply.");
return;
}

console.log("The following changes will be applied to your perms:");

printPermChanges(prodPerms.data.perms, perms);

const ok = await promptOk(
"Pushing permissions rules. This will immediately replace your production rules. OK to proceed?",
);
if (!ok) return;
console.log(diffedStr);

const okPush = await promptOk("OK to proceed?");
if (!okPush) return;

const permsRes = await fetchJson({
method: "POST",
Expand Down

0 comments on commit 3485af9

Please sign in to comment.