-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add --admin and --env flags to base44 exec #435
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
Open
netanelgilad
wants to merge
2
commits into
main
Choose a base branch
from
feat/exec-admin-env-flags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−6
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ function readStdin(): Promise<string> { | |
| } | ||
|
|
||
| async function execAction( | ||
| options: { admin?: boolean; env?: string }, | ||
| isNonInteractive: boolean, | ||
| ): Promise<RunCommandResult> { | ||
| const noInputError = new InvalidInputError( | ||
|
|
@@ -43,7 +44,12 @@ async function execAction( | |
| throw noInputError; | ||
| } | ||
|
|
||
| const { exitCode } = await runScript({ appId: getAppConfig().id, code }); | ||
| const { exitCode } = await runScript({ | ||
| appId: getAppConfig().id, | ||
| code, | ||
| admin: options.admin, | ||
| dataEnv: options.env, | ||
| }); | ||
|
|
||
| if (exitCode !== 0) { | ||
| process.exitCode = exitCode; | ||
|
|
@@ -57,6 +63,14 @@ export function getExecCommand(): Command { | |
| .description( | ||
| "Run a script with the Base44 SDK pre-authenticated as the current user", | ||
| ) | ||
| .option( | ||
| "--admin", | ||
| "Run with admin privileges (bypass RLS). Requires app owner/editor role.", | ||
| ) | ||
| .option( | ||
| "--env <environment>", | ||
| "Data environment to use (dev, share, or production). Defaults to production.", | ||
| ) | ||
|
Comment on lines
+70
to
+73
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this? is this a documented feature? for example with is dev vs shared?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .addHelpText( | ||
| "after", | ||
| ` | ||
|
|
@@ -65,9 +79,17 @@ Examples: | |
| $ cat ./script.ts | base44 exec | ||
|
|
||
| Inline script: | ||
| $ echo "const users = await base44.entities.User.list()" | base44 exec`, | ||
| $ echo "const users = await base44.entities.User.list()" | base44 exec | ||
|
|
||
| Run with admin privileges (bypass RLS): | ||
| $ echo "const all = await base44.entities.Task.list()" | base44 exec --admin`, | ||
| ) | ||
| .action(async (_options: unknown, command: Base44Command) => { | ||
| return await execAction(command.isNonInteractive); | ||
| }); | ||
| .action( | ||
| async ( | ||
| options: { admin?: boolean; env?: string }, | ||
| command: Base44Command, | ||
| ) => { | ||
| return await execAction(options, command.isNonInteractive); | ||
| }, | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should be specific and call this --skip-rls or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, just thinking how not to "scare" users /agetns with such a name to the flag. @claude got a good idea for a flag name?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @netanelgilad's task in 21s —— View job
Here are a few flag name ideas that convey elevated access without being alarming:
--privileged--full-access--unrestricted--as-owner--bypass-filtersMy recommendation:
--privilegedIt's already familiar to developers from tools like Docker (
docker run --privileged), signals that the user is opting into elevated permissions intentionally, and is less alarming than--adminor--skip-rls. It also doesn't expose the internal "RLS" terminology to users who may not know what that means.Runner-up:
--full-access— if you want something even more self-documenting for non-technical users or agents reading the help text.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kfirstri I don't have any strong opinion here, got something you liked here?