permitio / permit-cli

A command line utility from Permit.io to work with everything IAM and Authorization. A one-stop-shop to manage all your Authorization tools (OPA, OpenFGA, Cedar, OPAL, AVP...) as well as the Permit Service.
20 stars 27 forks source link

Permit Environment Management Commands #18

Open gemanor opened 3 weeks ago

gemanor commented 3 weeks ago

We want to create a set of commands that will help users manage their Permit environments. The following is the skeleton of the commands required in this issue:

Acceptance criteria:

gemanor commented 3 weeks ago

/bounty 250

algora-pbc[bot] commented 3 weeks ago

💎 $250 bounty • Permit.io

Steps to solve:

  1. Start working: Comment /attempt #18 with your implementation plan
  2. Submit work: Create a pull request including /claim #18 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to permitio/permit-cli!

Add a bounty • Share on socials

Attempt Started (GMT+0) Solution
🟢 @35C4n0r Oct 28, 2024, 4:09:08 PM WIP
🔴 @Rutik7066 Nov 6, 2024, 3:26:01 PM WIP
🟢 @vishwamartur Nov 15, 2024, 6:50:58 AM WIP
35C4n0r commented 3 weeks ago

/attempt #18

Algora profile Completed bounties Tech Active attempts Options
@35C4n0r 30 bounties from 5 projects
Python, TypeScript,
HTML & more
﹟6
Cancel attempt
Abiji-2020 commented 3 weeks ago

@35C4n0r can we collaborate on this issue

35C4n0r commented 3 weeks ago

@35C4n0r can we collaborate on this issue

Sorry @Abiji-2020, I prefer working solo :)

gemanor commented 3 weeks ago

@35C4n0r In order to assign you to the issue, I would kindly ask that you share your progress on the issue and the design of your components/lib files for review. I will assign you after the design review.

35C4n0r commented 3 weeks ago

@gemanor Since this issue depends on https://github.com/permitio/permit-cli/issues/13, I'll finish #13 first, then write a proposal for this. Let me know if that works! :)

gemanor commented 2 weeks ago

Works, but please try to write a proposal ASAP so I can assign you to it

35C4n0r commented 2 weeks ago

@gemanor here is my proposal for this one =)

Rutik7066 commented 2 weeks ago

@gemanor I have one proposal for Login, sign-up, Environment management, separate error handling, testing including unit and e2e and for the overall app.

permit-cli Project Structure using CLEAN code practices

src/

The working directory for the entire application, containing all the source code files.

  • cli.tsx: The main entry point of the CLI app, responsible for initializing the app and parsing commands.

  • cmd/: Contains the components for handling specific commands, including parsing and business logic. Each command has its own file, such as login.tsx and environment.tsx.

  • hooks/: Stores custom hooks, which can be reused for various functions like managing state, API calls, or UI updates.

  • services/: Includes files for API communication and business logic. This folder contains modules like login.ts, environment.ts, and keychain.ts to handle relevant app functionalities.

  • utils/: Holds helper functions for common tasks, such as logging, data formatting, or file manipulation.

  • errors/: Contains custom error handling classes to standardize error management across the app, such as AppError.ts, ApiCallError.ts, and others for specific use cases like authentication or validation.

  • types/: Contains TypeScript types used across the app for APIs, commands, and other logic to ensure consistency and type safety.

  • config/: Stores configuration files, including environment and app-specific settings, allowing easy configuration management.

  • testing/: Contains unit and integration tests to ensure that individual modules and services are working as expected.

  • e2e/: Includes end-to-end tests for simulating real-world use cases and validating the CLI app's overall functionality.

  • components/: Holds global React components (if any are used for a Node.js CLI) that are shared across different parts of the app.

  • constants.ts: Defines app-wide constants used across multiple modules to avoid duplication and maintain consistency.

This structure follows best practices for organizing a Node.js CLI app, ensuring clear separation of concerns, ease of maintenance, and scalability.

Rutik7066 commented 2 weeks ago

/attempt #18

Algora profile Completed bounties Tech Active attempts Options
@Rutik7066 10 bounties from 7 projects
Go, Rust,
MDX & more
Cancel attempt
gemanor commented 2 weeks ago

Hey @Rutik7066, as you saw, @35C4n0r already submitted a proposal for this one and PR for the other login flow. We are currently working on a first-come, first-serve model, so we will continue with him at this point.

Also, we have already based our structure on the Pastel structure recommendation, so there is no need for extra best practices for organizing the Node.js CLI app.

I'm more than inviting you to submit bounties on other PRs in this repo, or get back to that in a week in case @35C4n0r will have to cancel his attempt.

gemanor commented 2 weeks ago

@35C4n0r The proposal looks good, and you've approved continuing with it.

Two comments:

  • The hook should be useMemberAPI because user is a different term in Permit (the end user who gets authorized)
  • The copy environment API should copy and switch to the new one but does not require --project because the environment can be copied only inside projects. Please take a look at the following API doc and propose the command arguments. https://api.permit.io/v2/redoc#tag/Environments/operation/copy_environment
  • Pay attention to the fact that you'll maybe have to grab a project token when switching environments (as we are now storing only the environment key). Please also include the design for it in the proposal.

As usual, please try to bring it ASAP so I can assign it to you.

Rutik7066 commented 2 weeks ago

@gemanor no problem. I just want to ask one thing that I have also raised the pr for the login and sign up flow https://github.com/permitio/permit-cli/pull/27. Will that be accepted. In that pr I have not changed the structure just solved the issue.

Rutik7066 commented 2 weeks ago

@35C4n0r can we collaborate?

35C4n0r commented 2 weeks ago

@gemanor, thanks for the feedback, here is the revised proposal:

gemanor commented 2 weeks ago

@35C4n0r sounds good to me

35C4n0r commented 2 weeks ago

Thanks @gemanor, I'll start working on it right away, my work will be based of the branch here https://github.com/permitio/permit-cli/pull/28.

vishwamartur commented 1 week ago

/attempt #18