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 8d586cc commit 51dc37d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
19 changes: 19 additions & 0 deletions client/packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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 dotenv from "dotenv";
import chalk from "chalk";
import { program, Option } from "commander";
Expand Down Expand Up @@ -1064,12 +1065,30 @@ 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) {
return;
}

console.log("Planning...");

const prodPerms = await fetchJson({
path: `/dash/apps/${appId}/perms/pull`,
debugName: "Perms pull",
errorMessage: "Failed to pull perms.",
});

if (!prodPerms.ok) 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?",
);
Expand Down
1 change: 1 addition & 0 deletions client/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dotenv": "^16.3.1",
"env-paths": "^3.0.0",
"inquirer": "^10.1.6",
"json-diff": "^1.0.6",
"open": "^10.1.0",
"ora": "^8.1.1",
"pkg-dir": "^8.0.0",
Expand Down
38 changes: 38 additions & 0 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51dc37d

Please sign in to comment.