Skip to content

Commit d557d10

Browse files
authored
Merge pull request #591 from dzcode-io/rspack
chore: re-writing `./web` using RSPack and tailwind
2 parents ca2dfdf + b66cef1 commit d557d10

File tree

187 files changed

+4794
-18886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+4794
-18886
lines changed

.github/workflows/cd.deploy.stg.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ on:
44
push:
55
tags:
66
- "stg-v*"
7+
workflow_dispatch:
78

89
jobs:
910
install-build-deploy:
1011
runs-on: ${{ matrix.os }}
1112

1213
strategy:
1314
matrix:
14-
node-version: [18.x]
15+
node-version: [20.x]
1516
os: [ubuntu-latest]
1617

1718
env:
1819
CI: true
1920
STAGE: staging
20-
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
2121
SSH_ADDRESS_STG: ${{ secrets.SSH_ADDRESS_STG }}
2222
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
23-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
23+
DEPLOY_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || format('stg-0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
2424

2525
steps:
2626
- name: "Git"
@@ -37,11 +37,6 @@ jobs:
3737
with:
3838
node-version: ${{ matrix.node-version }}
3939
cache: "yarn"
40-
- name: "Expo"
41-
uses: expo/expo-github-action@v8
42-
with:
43-
expo-version: 4.x
44-
token: ${{ secrets.EXPO_TOKEN }}
4540

4641
- name: "Install"
4742
shell: bash
@@ -51,7 +46,7 @@ jobs:
5146
- name: "Bundle info"
5247
shell: bash
5348
run: |
54-
yarn generate:bundle-info ${{ github.ref_name }} stage
49+
yarn generate:bundle-info $DEPLOY_VERSION stage
5550
5651
- name: "Build"
5752
shell: bash
@@ -62,7 +57,7 @@ jobs:
6257
- name: "Sentry Release"
6358
shell: bash
6459
run: |
65-
yarn generate:sentry-release ${{ github.ref_name }} stage ${{ secrets.SENTRY_AUTH_TOKEN }}
60+
yarn generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
6661
6762
- name: "Deploy"
6863
shell: bash

.github/workflows/cd.deploy.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.x]
14+
node-version: [20.x]
1515
os: [ubuntu-latest]
1616

1717
env:
1818
CI: true
1919
STAGE: production
20-
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
2120
SSH_ADDRESS_PRD: ${{ secrets.SSH_ADDRESS_PRD }}
2221
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
23-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
22+
DEPLOY_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || format('0.0.0-{0}-{1}-{2}', github.ref_name, github.run_number, github.run_attempt) }}
2423

2524
steps:
2625
- name: "Git"
@@ -38,11 +37,6 @@ jobs:
3837
with:
3938
node-version: ${{ matrix.node-version }}
4039
cache: "yarn"
41-
- name: "Expo"
42-
uses: expo/expo-github-action@v8
43-
with:
44-
expo-version: 4.x
45-
token: ${{ secrets.EXPO_TOKEN }}
4640

4741
- name: "Install"
4842
shell: bash
@@ -52,13 +46,13 @@ jobs:
5246
- name: "Version"
5347
shell: bash
5448
run: |
55-
yarn version:apply ${{ github.ref_name }}
56-
yarn version:push ${{ github.ref_name }}
49+
yarn version:apply $DEPLOY_VERSION
50+
yarn version:push $DEPLOY_VERSION
5751
5852
- name: "Bundle info"
5953
shell: bash
6054
run: |
61-
yarn generate:bundle-info ${{ github.ref_name }} production
55+
yarn generate:bundle-info $DEPLOY_VERSION production
6256
6357
- name: "Build"
6458
shell: bash
@@ -69,7 +63,7 @@ jobs:
6963
- name: "Sentry Release"
7064
shell: bash
7165
run: |
72-
yarn generate:sentry-release ${{ github.ref_name }} production ${{ secrets.SENTRY_AUTH_TOKEN }}
66+
yarn generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
7367
7468
- name: "Deploy"
7569
shell: bash

.github/workflows/ci.main.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.x]
14+
node-version: [20.x]
1515
os: [macos-latest, ubuntu-latest, windows-latest]
1616
fail-fast: false
1717

@@ -67,13 +67,6 @@ jobs:
6767
name: codecov-data
6868
directory: ./data
6969
fail_ci_if_error: false # put it back to true once we have tests in ./data
70-
- uses: codecov/codecov-action@v3
71-
if: ${{ matrix.os == 'ubuntu-latest' }}
72-
with:
73-
flags: mobile
74-
name: codecov-mobile
75-
directory: ./mobile
76-
fail_ci_if_error: true
7770
- uses: codecov/codecov-action@v3
7871
if: ${{ matrix.os == 'ubuntu-latest' }}
7972
with:
@@ -88,19 +81,13 @@ jobs:
8881
name: codecov-utils
8982
directory: ./packages/utils
9083
fail_ci_if_error: true
91-
- uses: codecov/codecov-action@v3
92-
if: ${{ matrix.os == 'ubuntu-latest' }}
93-
with:
94-
flags: ui
95-
name: codecov-ui
96-
directory: ./packages/ui
97-
fail_ci_if_error: true
9884

9985
- name: "Misc"
10086
shell: bash
10187
run: |
10288
yarn lerna run bundle:alone --scope @dzcode.io/web
10389
yarn lerna run generate:sitemap --scope @dzcode.io/web
90+
yarn lerna run generate:htmls --scope @dzcode.io/web
10491
10592
env:
10693
CI: true

.github/workflows/ci.pr.e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [18.x]
12+
node-version: [20.x]
1313
os: [ubuntu-latest]
1414
browser: [chrome, firefox, edge]
1515
fail-fast: false

.github/workflows/ci.pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [18.x]
12+
node-version: [20.x]
1313
os: [macos-latest, ubuntu-latest, windows-latest]
1414
fail-fast: false
1515

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: ["javascript"]
36-
node-version: [18.x]
37-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35+
language: ["javascript", "typescript"]
3836
# Learn more about CodeQL language support at https://git.io/codeql-language-support
37+
node-version: [20.x]
3938

4039
steps:
4140
- name: "Git"

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ If you use VSCode, please make sure to have a `.vscode/settings.json` file with
9595

9696
```json
9797
{
98+
"files.associations": {
99+
"*.css": "tailwindcss"
100+
},
98101
"prettier.configPath": "packages/tooling/.prettierrc",
99102
"eslint.options": { "overrideConfigFile": "packages/tooling/.eslintrc.json" },
100103
"editor.codeActionsOnSave": {
101-
"source.fixAll": true
104+
"source.fixAll.eslint": "always",
105+
"source.fixAll.ts": "always"
102106
}
103107
}
104108
```

api/oracle-cloud/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16
1+
FROM node:20
22
# Create app directory
33
WORKDIR /usr/src/repo
44

api/oracle-cloud/deploy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// can be ran locally from ./api:
2+
// SSH_ADDRESS_STG="root@x.x.x.x" SSH_PATH="path/to/private/ssh/key" yarn deploy:stg
3+
14
import { execSync } from "child_process";
25
import { copySync, existsSync } from "fs-extra";
36
import { join } from "path";
@@ -82,8 +85,6 @@ logs = execSync(
8285
console.log("✅ New code uploaded.");
8386

8487
console.log("\n⚙️ Starting up the app");
85-
logs = execSync(
86-
sshPrefix + '"sudo docker-compose -f ' + appPath + '/docker-compose.yml up -d --build"',
87-
);
88+
logs = execSync(sshPrefix + '"cd ' + appPath + ' && docker compose up -d --build"');
8889
console.log(String(logs));
8990
console.log("✅ Deployment successful.");

api/oracle-cloud/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ services:
66
ports:
77
- "80:7070"
88
env_file:
9-
- /home/opc/app-env/api.env
9+
- /home/ubuntu/app-env/api.env
1010
volumes:
11-
- /home/opc/app-data/api/fetch_cache:/usr/src/repo/api/fetch_cache
11+
- /home/ubuntu/app-data/api/fetch_cache:/usr/src/repo/api/fetch_cache

api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
},
6565
"scripts": {
6666
"build": "lerna run build:alone --scope=@dzcode.io/api --include-dependencies --stream",
67-
"build:alone": "tsc",
68-
"build:alone:watch": "tsc --watch --preserveWatchOutput",
67+
"build:alone": "tspc",
68+
"build:alone:watch": "tspc --watch --preserveWatchOutput",
6969
"build:watch": "lerna run build:alone:watch --scope=@dzcode.io/api --include-dependencies --parallel",
7070
"clean": "lerna run clean:alone --scope=@dzcode.io/api --include-dependencies --stream",
7171
"clean:alone": "rimraf dist coverage fetch_cache oracle-cloud/build",
@@ -80,7 +80,7 @@
8080
"lint:fix:alone": "yarn lint:eslint --fix . && yarn lint:prettier --write .",
8181
"lint:prettier": "prettier --config ../packages/tooling/.prettierrc --ignore-path ../packages/tooling/.prettierignore --loglevel warn",
8282
"lint:ts-prune": "ts-node ../packages/tooling/setup-ts-prune.ts && ts-prune --error",
83-
"lint:tsc": "tsc --noEmit",
83+
"lint:tsc": "tspc --noEmit",
8484
"start": "node dist/app/index.js",
8585
"start:dev": "ts-node ../packages/tooling/nodemon.ts @dzcode.io/api && nodemon dist/app/index.js",
8686
"test": "yarn build && yarn test:alone",

api/src/contribution/repository.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export class ContributionRepository {
8181
)
8282
).reduce((pV, cV) => [...pV, ...cV], []);
8383
if (filterFn) {
84+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
85+
// @ts-ignore
8486
contributions = contributions.filter(filterFn);
8587
}
8688
contributions = contributions.sort(
@@ -93,11 +95,15 @@ export class ContributionRepository {
9395
this.pushUniqueOption([{ name: project.slug, label: project.name }], filters[0].options);
9496

9597
this.pushUniqueOption(
98+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
99+
// @ts-ignore
96100
languages.map((language) => ({ name: language })),
97101
filters[1].options,
98102
);
99103

100104
this.pushUniqueOption(
105+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
106+
// @ts-ignore
101107
labels.map((label) => ({ name: label })),
102108
filters[2].options,
103109
);

api/src/project/controller.ts

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { AccountEntity } from "@dzcode.io/models/dist/account";
21
import { Controller, Get } from "routing-controllers";
32
import { OpenAPI, ResponseSchema } from "routing-controllers-openapi";
43
import { DataService } from "src/data/service";
@@ -26,52 +25,8 @@ export class ProjectController {
2625
// get projects from /data folder:
2726
const projects = await this.dataService.listProjects();
2827

29-
// fetch info about these projects from github:
30-
const infoRichProjects: GetProjectsResponseDto["projects"] = await Promise.all(
31-
projects.map(async (project) => {
32-
const { repositories } = project;
33-
return {
34-
...project,
35-
repositories: await Promise.all(
36-
repositories.map(async ({ provider, owner, repository }) => {
37-
let contributionCount = 0;
38-
let contributors: AccountEntity[] = [];
39-
let languages: string[] = [];
40-
try {
41-
[contributionCount, contributors, languages] = await Promise.all([
42-
(await this.githubService.listRepositoryIssues({ owner, repository })).length,
43-
await Promise.all(
44-
(
45-
await this.githubService.listRepositoryContributors({ owner, repository })
46-
).map(async ({ login }) => {
47-
const githubUser = await this.githubService.getUser({ username: login });
48-
return this.githubService.githubUserToAccountEntity(githubUser);
49-
}),
50-
),
51-
await this.githubService.listRepositoryLanguages({ owner, repository }),
52-
]);
53-
} catch (error) {
54-
this.loggerService.error({
55-
message: `Failed to fetch rich info for project: ${owner}/${repository}`,
56-
meta: { owner, repository, error },
57-
});
58-
}
59-
60-
return {
61-
provider,
62-
owner,
63-
repository,
64-
stats: { contributionCount, languages },
65-
contributors,
66-
};
67-
}),
68-
),
69-
};
70-
}),
71-
);
72-
7328
return {
74-
projects: infoRichProjects,
29+
projects,
7530
};
7631
}
7732
}

api/src/project/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ import { GeneralResponseDto } from "src/app/types";
88
export class GetProjectsResponseDto extends GeneralResponseDto {
99
@ValidateNested({ each: true })
1010
@Type(() => ProjectEntity)
11-
// @TODO-ZM: find a way to DRY this, eg:
12-
// projects!: Model<ProjectEntity, 'repositories' | 'repositories.contributors' | 'repositories.stats'>[]
13-
projects!: Array<
14-
Model<ProjectEntity> & { repositories: Model<RepositoryEntity, "contributors" | "stats">[] }
15-
>;
11+
projects!: Array<Model<ProjectEntity> & { repositories: Model<RepositoryEntity>[] }>;
1612
}

api/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "@dzcode.io/tooling/tsconfig.json",
2+
"extends": "../packages/tooling/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "dist",
55
"baseUrl": "."

data/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@types/fs-extra": "^9.0.13",
2020
"@types/glob": "^7.1.4",
2121
"cpx": "^1.5.0",
22-
"firebase-tools": "^9.1.0"
22+
"firebase-tools": "^13.16.0"
2323
},
2424
"engines": {
2525
"node": ">=16",

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"packages": ["packages/*", "api", "data", "web", "mobile"],
2+
"packages": ["packages/*", "api", "data", "web"],
33
"version": "independent",
44
"npmClient": "yarn",
55
"useWorkspaces": true

0 commit comments

Comments
 (0)