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

fix(docs): improve instructions for local development #263

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 57 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ All official plugin are install and preconfigured
To build the App in mobile, run

```bash
pnpm install
pnpm mobile
```

Expand All @@ -112,62 +113,92 @@ Go to [Netlify](https://app.netlify.com/start) and select your clone, `OK` along

### Development

Start each local server in a separate terminal.
You will need to start each local server in separate terminals.

#### Start local Supabase DB
Before you continue, you need to have these installed:
- [Docker](https://www.docker.com/)
- [pnpm](https://pnpm.js.org/)
- [Supabase CLI](https://supabase.com/docs/guides/cli)

> You need to have [Docker](https://www.docker.com/) installed.
> You need to have Supabase CLI (`npm install supabase --save-dev`) installed.
You can install the `supabase` CLI globally with `pnpm install supabase -g` and you can invoke `supabase` from anywhere.

Alternatively, you can install the CLI inside this repo with `pnpm install supabase --save-dev` but to invoke it use: `./node_modules/supabase/bin/supabase`.

The rest of this guide assumes that you installed the `supabase` CLI globally.


#### Start Supabase DB Locally

Start the Supabase DB:
```bash
supabase start
```
Replace in `configs.json`
`supa_anon.local` the key by the one logged in the terminal `anon key`
Run the front with

#### Start local Supabase db and Functions
If the command completed successfully, your console output should be similar to the output below:
```bash
Started supabase local development setup.

API URL: http://localhost:54321
GraphQL URL: http://localhost:54321/graphql/v1
DB URL: postgresql://postgres:postgres@localhost:54322/postgres
Studio URL: http://localhost:54323
Inbucket URL: http://localhost:54324
JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
anon key: xxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXx.xxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXx
service_role key: xxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXx.xxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxXxxxxxXxxxxxX
```



#### Start Supabase DB and Functions Locally

You need docker running.
You need make sure Docker is running.
```bash
pnpm install
pnpm backend
```

#### Start local Front
#### Start Frontend Locally

In the second terminal run this to generate the necessary netlify functions.
Before starting the frontend, make sure you replace the value of `supa_anon.local` inside the file `configs.json` with the value of `anon key`. If `supabase` is already running, you can also obtain `anon key` from the output of `supabase status`.


In another terminal, run this to generate the necessary Netlify functions:

```bash
pnpm serve
export BRANCH=local

pnpm generate:node_serverless
```

Then start the server
```bash
pnpm generate:node_serverless
pnpm serve
```

#### Login

Visit http://localhost:8881
Visit http://localhost:5173

Use the demo credentials.
Account: test@capgo.app
Password: testtest
There are two login credentials you can use:

This account has some demo data in it.
If the data is not fresh just reset the db with `supabase db reset` the seed has been made in the way the data is always fresh.
| Account | Username | Password |
|---------|----------|----------|
| Demo User | test@capgo.app | testtest |
| Admin User | admin@capgo.app | adminadmin |

The admin account is
Account: admin@capgo.app
Password: adminadmin
The *demo user* account has some demo data in it.
If the data is not fresh just reset the db with `supabase db reset`. The seed has been made in the way the data is always fresh.

This user will be admin so he can impersonate other users.
The *admin user* has admininstrative rights so he can impersonate other users.
You can find the menu for that in the account section.

#### Supabase db reset

You need docker running.
This will seed the db with the demo data again.
#### Supabase DB Reset

Make sure you have Docker running.

This will seed the DB with demo data again.
```bash
pnpm reset
```
24 changes: 4 additions & 20 deletions supabase/migrations/20230321023005_create_base_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ DROP TYPE IF EXISTS public.match_plan;
DROP TYPE IF EXISTS public.key_mode;
DROP TYPE IF EXISTS public.app_mode;

--
-- Name: supabase_migrations; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA supabase_migrations;


ALTER SCHEMA supabase_migrations OWNER TO postgres;
Expand Down Expand Up @@ -631,11 +626,10 @@ CREATE FUNCTION public.count_all_apps() RETURNS integer
LANGUAGE plpgsql
AS $$
Begin
RETURN (SELECT COUNT(*) FROM (
SELECT app_id FROM apps
UNION
SELECT DISTINCT app_id FROM store_apps where (onprem = true or capgo = true) and url != ''
) AS temp);
RETURN (SELECT
(SELECT COUNT(*) FROM apps)+
(SELECT COUNT(*) FROM (SELECT DISTINCT app_id FROM store_apps where onprem = true or capgo = true) AS temp)
AS SumCount);
End;
$$;

Expand Down Expand Up @@ -4063,16 +4057,6 @@ GRANT ALL ON TABLE public.stats TO authenticated;
GRANT ALL ON TABLE public.stats TO service_role;


--
-- Name: SEQUENCE stats_id_seq; Type: ACL; Schema: public; Owner: supabase_admin
--

GRANT ALL ON SEQUENCE public.stats_id_seq TO postgres;
GRANT ALL ON SEQUENCE public.stats_id_seq TO anon;
GRANT ALL ON SEQUENCE public.stats_id_seq TO authenticated;
GRANT ALL ON SEQUENCE public.stats_id_seq TO service_role;


--
-- Name: TABLE store_apps; Type: ACL; Schema: public; Owner: supabase_admin
--
Expand Down
3 changes: 0 additions & 3 deletions supabase/migrations/20230406040323_create_opti_logs.sql

This file was deleted.

12 changes: 0 additions & 12 deletions supabase/migrations/20230410160256_create_app_live.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,3 @@ CREATE TABLE "public"."app_live" (
);

CREATE TRIGGER handle_updated_at BEFORE UPDATE ON public.app_live FOR EACH ROW EXECUTE FUNCTION extensions.moddatetime('updated_at');

CREATE POLICY "All self user to all" ON "public"."app_live"
AS PERMISSIVE FOR ALL
TO authenticated
USING (((uid() = id) OR is_admin(uid())))
WITH CHECK (((uid() = id) OR is_admin(uid())))

CREATE POLICY "Allow APIKEY to delete" ON "public"."app_live"
AS PERMISSIVE FOR ALL
TO anon
USING ((is_allowed_capgkey(((current_setting('request.headers'::text, true))::json ->> 'capgkey'::text), '{write,all}'::key_mode[]) AND is_allowed_action(((current_setting('request.headers'::text, true))::json ->> 'capgkey'::text))))
WITH CHECK ((is_allowed_capgkey(((current_setting('request.headers'::text, true))::json ->> 'capgkey'::text), '{write,all}'::key_mode[]) AND is_allowed_action(((current_setting('request.headers'::text, true))::json ->> 'capgkey'::text))))
113 changes: 0 additions & 113 deletions supabase/migrations/20230619105940_orgs.sql

This file was deleted.

5 changes: 0 additions & 5 deletions supabase/migrations/20230726140052_on_user_delete.sql

This file was deleted.

Loading