Skip to content

Commit

Permalink
docs: update instructions on testing cards generation locally (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
takanome-dev committed Jun 20, 2023
1 parent 6e1da46 commit e152d09
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
25 changes: 25 additions & 0 deletions .env.example
@@ -0,0 +1,25 @@
# API
API_HOST=0.0.0.0
API_PORT=3001
API_DOMAIN=opengraph.opensauced.pizza
MEMORY_HEAP=200
MEMORY_RSS=3000
DISK_PERCENTAGE=0.7
DISK_SIZE=100
NODE_ENV=development
API_CODENAME=opengraph-local

# Github
GITHUB_PAT_USER=
GITHUB_PAT_PR=
GITHUB_PAT_COMMIT=

# Digital Ocean
DO_SPACES_ACCESS_KEY_ID=
DO_SPACES_SECRET_ACCESS_KEY=
DO_SPACES_PROTOCOL=https
DO_SPACES_ENDPOINT=digitaloceanspaces.com
DO_SPACES_REGION=sfo3
DO_SPACES_BUCKET_NAME=opengraph-dev
DO_SPACES_SUBDOMAIN=
DO_SPACES_CDN_DISABLED=true
36 changes: 23 additions & 13 deletions README.md
@@ -1,19 +1,21 @@
<div align="center">
<br>

[![Open Sauced](https://i.ibb.co/7jPXt0Z/logo1-92f1a87f.png)](https://opensauced.pizza)
[![Open Sauced](https://i.ibb.co/7jPXt0Z/logo1-92f1a87f.png)](https://opensauced.pizza)

# 🍕 Open Sauced OpenGraph Generator 🍕
> The path to your next Open Source contribution
# 🍕 Open Sauced OpenGraph Generator 🍕

[![Powered by Digital Ocean](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=c65a90d0956d&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)
> The path to your next Open Source contribution
[![Powered by Digital Ocean](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=c65a90d0956d&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)

[![Code Size](https://img.shields.io/github/languages/code-size/open-sauced/opengraph.opensauced.pizza?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/pulse)
[![Commits](https://img.shields.io/github/commit-activity/w/open-sauced/opengraph.opensauced.pizza?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/pulse)
[![Issues](https://img.shields.io/github/issues/open-sauced/opengraph.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/issues)
[![Releases](https://img.shields.io/github/v/release/open-sauced/opengraph.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/releases)
[![Discord](https://img.shields.io/discord/714698561081704529.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/U2peSNf23P)
[![Twitter](https://img.shields.io/twitter/follow/saucedopen?label=Follow&style=social)](https://twitter.com/saucedopen)

[![Code Size](https://img.shields.io/github/languages/code-size/open-sauced/opengraph.opensauced.pizza?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/pulse)
[![Commits](https://img.shields.io/github/commit-activity/w/open-sauced/opengraph.opensauced.pizza?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/pulse)
[![Issues](https://img.shields.io/github/issues/open-sauced/opengraph.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/issues)
[![Releases](https://img.shields.io/github/v/release/open-sauced/opengraph.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/opengraph.opensauced.pizza/releases)
[![Discord](https://img.shields.io/discord/714698561081704529.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/U2peSNf23P)
[![Twitter](https://img.shields.io/twitter/follow/saucedopen?label=Follow&style=social)](https://twitter.com/saucedopen)
</div>

## 🚀 Live release environments
Expand All @@ -31,6 +33,7 @@
## 📖 Prerequisites

In order to run the project we need the following software binaries installed on our development machines:

- [x] `node>=18.15.0`
- [x] `npm>=9.6.3`
- [ ] `docker>=20.10.23`
Expand All @@ -53,14 +56,21 @@ npm run start:dev

There are a few scripts that can be used to generate and test the social cards locally without having to deploy to the CDN. This is the way to go when developing & testing the interface for the social cards.

#### Generating user profile cards:
#### Generating user profile cards

```shell
npm run local-dev:usercards
npm run test:local:user
```

> Generates user cards for all users in the test array inside `test/local-dev/UserCards.ts` and outputs them in `dist/local-dev/` for testing.
The same goes for the other card types:

- `npm run test:local:insight` is for generating insight cards.
- `npm run test:local:highlight` is for generating highlight cards.

The output of these scripts can be found in the `dist/local-dev/` folder as well.

### 📝 Environment variables

Some environment variables are required to run the application. You can find them in the `.env.example` file. While most of them are optional, some are required to run the application.
Expand Down Expand Up @@ -137,7 +147,7 @@ We have a couple of scripts to check and adjust missing types.
In order to dry run what types would be added to `package.json`:

```shell
npm run types:auto-check
npm run types:auto-check
```

In order to add any missing types to `package.json`:
Expand Down
6 changes: 3 additions & 3 deletions src/social-card/user-card/user-card.service.ts
Expand Up @@ -77,9 +77,9 @@ export class UserCardService {
name: user.name,
langs: Array.from(Object.values(langs)).sort((a, b) => b.size - a.size),
langTotal,
repos: user.topRepositories.nodes?.filter(
repo => !repo?.isPrivate && repo?.owner.login !== username,
) as Repository[],
repos: user.topRepositories.nodes
?.filter(repo => !repo?.isPrivate && repo?.owner.login !== username)
.filter(Boolean) as Repository[],
avatarUrl: `${String(user.avatarUrl)}&size=150`,
formattedName: user.login,
};
Expand Down
2 changes: 1 addition & 1 deletion test/local-dev/HighlightCards.ts
Expand Up @@ -6,7 +6,7 @@ import { HighlightCardService } from "../../src/social-card/highlight-card/highl

const testHighlights = [102, 101, 103];

const folderPath = "dist";
const folderPath = "dist/local-dev";

async function testHighlightCards() {
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile();
Expand Down
2 changes: 1 addition & 1 deletion test/local-dev/InsightCards.ts
Expand Up @@ -6,7 +6,7 @@ import { InsightCardService } from "../../src/social-card/insight-card/insight-c

const testInsightIds = [350, 351];

const folderPath = "dist";
const folderPath = "dist/local-dev";

async function testHighlightCards() {
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile();
Expand Down
3 changes: 1 addition & 2 deletions test/local-dev/UserCards.ts
Expand Up @@ -5,8 +5,7 @@ import { existsSync } from "node:fs";
import { mkdir, writeFile } from "fs/promises";

const testUsernames = ["bdougie", "deadreyo", "defunkt", "0-vortex", "Anush008", "diivi"];

const folderPath = "dist";
const folderPath = "dist/local-dev";

async function testUserCards() {
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile();
Expand Down

0 comments on commit e152d09

Please sign in to comment.