Skip to content

Latest commit

 

History

History
109 lines (81 loc) · 4.71 KB

CONTRIBUTING.md

File metadata and controls

109 lines (81 loc) · 4.71 KB

Contributing to Firefiles

  • Please see Adding cloud providers below to contribute to our cloud providers.
  • Before jumping into a PR be sure to search existing PRs or issues for an open or closed item that relates to your submission.

Developing

The production branch is main. You can check out a new branch from main as the base-branch and start working on it.

To develop locally:

  1. Fork this repository to your own GitHub account and then clone it to your local device.

    If you don't need the whole git history, you can clone with depth 1 to reduce the download size:

    git clone --depth=1 https://github.com/faisalsayed10/firefiles
  2. Create a new branch:

    git checkout -b MY_BRANCH_NAME
    
  3. Install pnpm: https://pnpm.io/installation

  4. Install the dependencies with:

    pnpm install
    
  5. Start developing and watch for code changes:

    pnpm dev
    

Environment variables

There are some environment variables that need to be set in order to run the app properly.

COOKIE_PASSWORD=A 32-character long secret password used to encrypt cookies.
CIPHER_KEY=A randomly generated secret key used to encrypt and decrypt credentials.
RESEND_API_KEY OR SENDGRID_API_KEY=API key obtained from **resend.com** / sendgrid.com used to send emails for passwordless login
EMAIL_FROM=The email address which will be used as the email's sender (This email should be added and verified on the Resend/SendGrid dashboard).
JWT_SECRET=A randomly generated secret key to sign and verify JWT tokens (used for passwordless logins).
DATABASE_URL=A local mysql database URL.
DEPLOY_URL=http://localhost:3000

Linting

To format your code:

pnpm lint

Adding cloud providers

Adding a new cloud provider simply requires you to create a new hook in the hooks/ directory.

  • First, create a new file inside the pages/new/ directory which will be used to get the credentials for that provider. (refer to other files to get an idea)
  • Then, create a new file inside the hooks/ folder named use<YOUR_PROVIDER_NAME>.tsx.
  • You can use useS3.tsx as a starting point.
  • It must contain a context that provides the following values:
loading: boolean;
currentFolder: DriveFolder;
folders: DriveFolder[];
files: DriveFile[];
uploadingFiles: UploadingFile[];
setUploadingFiles: React.Dispatch<React.SetStateAction<UploadingFile[]>>;
addFolder: (name: string) => void;
removeFolder: (folder: DriveFolder) => Promise<void>;
addFile: (files: File[] | FileList) => Promise<void>;
removeFile: (file: DriveFile) => Promise<boolean>;

This is defined in the useBucket hook.

  • The first useEffect with the // set currentFolder comment must be used to change the current directory according to the path. You won't need to make many changes to this hook.
  • The next useEffect commented with // get files and folders must be used to populate the files and folders states according to the current directory.
  • Fill out the remaining functions like addFolder, removeFolder, addFile, and removeFile.
  • Navigate to util/globals.ts and add an object for your provider to the PROVIDERS array. (Also add a logo for the provider in the public/ directory)
  • Navigate to util/types.ts and add your provider's name to the Provider enum.
  • Finally, navigate to the useBucket hook and add a case for your provider and return that hook.
  • Also make sure to edit any provider-specific functions to make it work with your provider. (look for switch cases or if/else statements which check for the type of the provider).

Testing

Start your local development server and on your dashboard, click on the Create New Drive button. find your provider there and enter the required credentials.

Once that is done, your drive will show up on your dashboard, click on that drive and you should be able to see your files and folders which are stored in the root directory.

If you're facing any issues, bugs, or errors, try checking the console and debugging it.

Things to test:

  • Check if the files and folders are getting populated correctly.
  • Check if you can navigate inside subfolders.
  • Check if you can preview/download/upload/delete/share the files.
  • Check if you can delete an entire folder with its contents.
  • Check if you can create a folder and upload files to it.

Creating a PR

Make sure everything's working and your code is formatted and create a PR at https://github.com/faisalsayed/firefiles/pulls. Once we review your PR, we'll merge it! :)