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

Permit Environment Management Commands #18

Open
gemanor opened this issue Oct 28, 2024 · 20 comments · May be fixed by #37
Open

Permit Environment Management Commands #18

gemanor opened this issue Oct 28, 2024 · 20 comments · May be fixed by #37
Assignees

Comments

@gemanor
Copy link
Collaborator

gemanor commented Oct 28, 2024

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:

  • permit env select - selecting a different environment and storing the relevant key. This should incorporate with the following issue and use the same components: Refactoring Login Flow and Handling Errors #13
  • permit env copy - will allow users to copy their existing logged-in environment to a new environment and change their active environment to it
  • permit env member will allow users to add more members to their environment with proper roles

Acceptance criteria:

  • All the above flows are impkemented
  • Unit test coverage of 90%
  • e2e test of the basic flow of each
@gemanor
Copy link
Collaborator Author

gemanor commented Oct 28, 2024

/bounty 250

Copy link

algora-pbc bot commented Oct 28, 2024

💎 $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 bountyShare on socials

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

@35C4n0r
Copy link

35C4n0r commented Oct 28, 2024

/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
Copy link
Contributor

@35C4n0r can we collaborate on this issue

@35C4n0r
Copy link

35C4n0r commented Oct 28, 2024

@35C4n0r can we collaborate on this issue

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

@gemanor
Copy link
Collaborator Author

gemanor commented Oct 31, 2024

@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
Copy link

35C4n0r commented Oct 31, 2024

@gemanor Since this issue depends on #13, I'll finish #13 first, then write a proposal for this. Let me know if that works! :)

@gemanor
Copy link
Collaborator Author

gemanor commented Nov 3, 2024

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

@35C4n0r
Copy link

35C4n0r commented Nov 6, 2024

@gemanor here is my proposal for this one =)

@Rutik7066
Copy link

Rutik7066 commented Nov 6, 2024

@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
Copy link

Rutik7066 commented Nov 6, 2024

/attempt #18

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

@gemanor
Copy link
Collaborator Author

gemanor commented Nov 7, 2024

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
Copy link
Collaborator Author

gemanor commented Nov 7, 2024

@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
Copy link

Rutik7066 commented Nov 7, 2024

@gemanor no problem. I just want to ask one thing that I have also raised the pr for the login and sign up flow #27. Will that be accepted. In that pr I have not changed the structure just solved the issue.

@Rutik7066
Copy link

@35C4n0r can we collaborate?

@35C4n0r
Copy link

35C4n0r commented Nov 7, 2024

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

@gemanor
Copy link
Collaborator Author

gemanor commented Nov 7, 2024

@35C4n0r sounds good to me

@35C4n0r
Copy link

35C4n0r commented Nov 7, 2024

Thanks @gemanor, I'll start working on it right away, my work will be based of the branch here #28.

@vishwamartur
Copy link

vishwamartur commented Nov 15, 2024

/attempt #18

vishwamartur added a commit to vishwamartur/permit-cli that referenced this issue Nov 15, 2024
Related to permitio#18

Implement environment management commands for Permit CLI.

* Add `env.tsx` in `source/commands` directory to implement the required commands:
  - `permit env select` uses the existing component from permitio#28.
  - `permit env copy` takes user input via a component and flags: `--target`, `--conflictStrategy`, and `--scope`.
  - `permit env member` uses a new `useMemberApi` hook to add users with roles.
* Create a hook to get a project-level access token with write permissions for `permit env copy`.
* Add `useMemberApi.ts` to create a new hook to add users with roles interactively or via flags.
* Add `useProjectToken.ts` to create a hook to get a project-level access token with write permissions.
* Add unit tests in `env.test.tsx` for `permit env select`, `permit env copy`, and `permit env member` commands.
* Add e2e tests in `env.e2e.tsx` for the basic flow of each command to validate their functionality.
vishwamartur added a commit to vishwamartur/permit-cli that referenced this issue Nov 15, 2024
Related to permitio#18

Implement environment management commands for Permit CLI.

* Add `env.tsx` in `source/commands` directory to implement the required commands:
  - `permit env select` uses the existing component from permitio#28.
  - `permit env copy` takes user input via a component and flags: `--target`, `--conflictStrategy`, and `--scope`.
  - `permit env member` uses a new `useMemberApi` hook to add users with roles.
* Create a hook to get a project-level access token with write permissions for `permit env copy`.
* Add `useMemberApi.ts` to create a new hook to add users with roles interactively or via flags.
* Add `useProjectToken.ts` to create a hook to get a project-level access token with write permissions.
* Add unit tests in `env.test.tsx` for `permit env select`, `permit env copy`, and `permit env member` commands.
* Add e2e tests in `env.e2e.tsx` for the basic flow of each command to validate their functionality.

Signed-off-by: Vishwanath Martur <[email protected]>
@35C4n0r 35C4n0r linked a pull request Nov 24, 2024 that will close this issue
Copy link

algora-pbc bot commented Nov 24, 2024

💡 @35C4n0r submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants