-
Notifications
You must be signed in to change notification settings - Fork 0
English Version
Before you start, you need to have a Github token ready, and you need to setup your Supabase.
-
Create your Github token.
To get lists of apps and components from GitHub, using GraphQL queries, we need access to Github- Login to github, then go to https://github.com/settings/tokens/new
- In Note, give your token a meaningful name, like 'OCE website access', so you can find it back later.
- Set the lifetime to
no expiration - Do not select any scopes.
- Click on Generate token, and copy the generated token somewhere in a text editor.
-
Setup your Supabase database
- Login on Supabase (with your github account)
- Click on New project
- Give the project a meaningful name, like 'opencomponents'
- Create a nice and long strong password. Copy this password somewhere in a text editor.
In this case, be advised to not use special characters, as they interfere with our URI - Hit Create new project
Wait till the database and API endpoints have been provisioned - Go to Settings (the cog) and click on Database. Scroll down till you see Connection string
- Click on URI, then copy this somewhere in a text editor
- Replace
[YOUR-PASSWORD]with the password that you created earlier - Scroll down to Connection Pooling
- Set Pool mode to
Session - Copy the Connection string somewhere in a text editor
After you've done your preparations, let's setup our local environment'
-
Clone the project
git clone git@github.com:texttree/oce.git -
Run package installation
cd oce && yarn -
Make a copy of
.env.local.exampleand rename it to.env.local
cp .env.local.example .env.local -
Specify environment variables
In the.env.localfile, replace the dummy environment variablesGITHUB_TOKENandDATABASE_URLwith the ones that you just created -
We use
Prismaas the ORM for the database Nothing to be done here. We might want to remove this item -
As a database, we use a cloud instance of
PostgreSQL(Supabase)
For local development, you can use the local or the cloud version ofSupabase.If you decide to run a local version of
Supabase, yourDATABASE_URLwill look something like this:
DATABASE_URL=postgresql://postgres:postgres@localhost:54322/postgres -
In order to populate the database with the needed tables, run
yarn seed -
To verify that everything was setup correctly, run the command
npx dotenv -e .env.local -- npx prisma studioin the console -
The
Prismaweb interface should start. If there are any errors, try runningnpx prisma generate -
You can now run
yarn devand navigate to http://localhost:3000. The apps and components repositories should be loaded.
On the main page, the block with components and apps will be empty, since the data is taken from the database there. -
The database is populated when the hook in the GitHub repository is triggered. To configure locally, do the following:
-
Launch the site if it is not already running:
yarn dev -
Configure
Ngrokand run on3000portngrok http 3000You will see something like this
Web Interface http://127.0.0.1:4040 Forwarding https://9a0b-43-1-42-21.eu.ngrok.io -> http://localhost:3000This is how we set up the tunnel, and all requests to
https://[URL-ID].eu.ngrok.iowill be redirected to our sitehttp://localhost:3000In
Web Interfacewe can see all incoming requests and responses from our API
-
To deploy the project, use
Netlify- Login to Netlify
- Click on Add new site, then click on Import an existing project
- Connect to Github, then pick the correct repository and branch (probably
main) -
Build command should be
yarn build, Publish directory should be.next - Click on Deploy site
Probably this deploy will fail due to missing variables
-
Setup correct deployment parameters
- Click on Site settings of the just created site
- Click on Build & deploy
- The Build image should be 'Ubuntu Focal 20.04'. If not, change it accordingly.
- In Enviroment variables, you need to create the following environment variables
- DATABASE_URL: the Supabase connection string (not the Connection Pooling one)
- GITHUB_TOKEN: the token that you created earlier
- NODE_VERSION:
16
-
Go to Deploys, then click on Trigger deploy, then Clear cache and deploy site
Note: During the initial build, prisma should run the
generatecommand. In case it doesn't, then in Build settings, change the build command tonpx prisma generate && yarn buildand deploy again. -
After the initial build is successful, we need to replace
DATABASE_URLwith theConnection poolinglink.
Just replace the variable inDATABASE_URLwith the Supabase Connection Pooling connection string -
Trigger a new deploy, as stated under 3.
- In order for your app or component to be displayed in the list, just add the topic
scripture-open-componentsfor a component orscripture-open-appsfor an app
If you want the component to display dependencies, then you need to correctly configure the repository
-
Create file
oce.json{ "name": "npm/@texttree/projector-mode-rcl", "version": "0.5.3", "date": "2022-04-14", "logo": "https://raw.githubusercontent.com/texttree/projector-mode-rcl/master/images/logo.png", "dependencies":["npm/core-js", "npm/@texttree/filter-translation-words-rcl"] }nameis the name of the package. For apps is not filled. This name will be used for binding through dependencies.Since the name may coincide in different languages, we use the prefix
js -
npm/php -
composer/ruby -
gem/python -
pip/version- the latest version of the component or appdate- date when the app or component was published (YYYY-MM-DD)logo- link to app logo. If not specified, it will be taken fromhttps://raw.githubusercontent.com/[repo]/master/images/logo.jpgdependencies- is an array of dependencies. Here we specify the names of the packages with a prefix. -
Add a webhook so that when changes are made in the
oce.jsonfile or in the description, adding topics, etc. - these changes were recorded in the databaseGo to Settings -> WebHooks -> Add Webhook
Payload URL -
https://oce-site.netlify.app/api/webhookfor production,https://[URL-ID].eu.ngrok.io/api/webhookfor local workContent type -
application/jsonWhich events would you like to trigger this webhook? -
Let me select individual events.Checking
PushesandRepositoriesAdding a webhook
-
At this moment, a ping request will pass, and the data on the repository, as well as the data from the
oce.jsonfile, will be written to the database