Skip to content

Commit

Permalink
Merge pull request #591 from dzcode-io/rspack
Browse files Browse the repository at this point in the history
chore: re-writing `./web` using RSPack and tailwind
  • Loading branch information
ZibanPirate authored Sep 3, 2024
2 parents ca2dfdf + b66cef1 commit d557d10
Show file tree
Hide file tree
Showing 187 changed files with 4,794 additions and 18,886 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/cd.deploy.stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ on:
push:
tags:
- "stg-v*"
workflow_dispatch:

jobs:
install-build-deploy:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
os: [ubuntu-latest]

env:
CI: true
STAGE: staging
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SSH_ADDRESS_STG: ${{ secrets.SSH_ADDRESS_STG }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
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) }}

steps:
- name: "Git"
Expand All @@ -37,11 +37,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: "Expo"
uses: expo/expo-github-action@v8
with:
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}

- name: "Install"
shell: bash
Expand All @@ -51,7 +46,7 @@ jobs:
- name: "Bundle info"
shell: bash
run: |
yarn generate:bundle-info ${{ github.ref_name }} stage
yarn generate:bundle-info $DEPLOY_VERSION stage
- name: "Build"
shell: bash
Expand All @@ -62,7 +57,7 @@ jobs:
- name: "Sentry Release"
shell: bash
run: |
yarn generate:sentry-release ${{ github.ref_name }} stage ${{ secrets.SENTRY_AUTH_TOKEN }}
yarn generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Deploy"
shell: bash
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/cd.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
os: [ubuntu-latest]

env:
CI: true
STAGE: production
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SSH_ADDRESS_PRD: ${{ secrets.SSH_ADDRESS_PRD }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
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) }}

steps:
- name: "Git"
Expand All @@ -38,11 +37,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: "Expo"
uses: expo/expo-github-action@v8
with:
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}

- name: "Install"
shell: bash
Expand All @@ -52,13 +46,13 @@ jobs:
- name: "Version"
shell: bash
run: |
yarn version:apply ${{ github.ref_name }}
yarn version:push ${{ github.ref_name }}
yarn version:apply $DEPLOY_VERSION
yarn version:push $DEPLOY_VERSION
- name: "Bundle info"
shell: bash
run: |
yarn generate:bundle-info ${{ github.ref_name }} production
yarn generate:bundle-info $DEPLOY_VERSION production
- name: "Build"
shell: bash
Expand All @@ -69,7 +63,7 @@ jobs:
- name: "Sentry Release"
shell: bash
run: |
yarn generate:sentry-release ${{ github.ref_name }} production ${{ secrets.SENTRY_AUTH_TOKEN }}
yarn generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Deploy"
shell: bash
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/ci.main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false

Expand Down Expand Up @@ -67,13 +67,6 @@ jobs:
name: codecov-data
directory: ./data
fail_ci_if_error: false # put it back to true once we have tests in ./data
- uses: codecov/codecov-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: mobile
name: codecov-mobile
directory: ./mobile
fail_ci_if_error: true
- uses: codecov/codecov-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
Expand All @@ -88,19 +81,13 @@ jobs:
name: codecov-utils
directory: ./packages/utils
fail_ci_if_error: true
- uses: codecov/codecov-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: ui
name: codecov-ui
directory: ./packages/ui
fail_ci_if_error: true

- name: "Misc"
shell: bash
run: |
yarn lerna run bundle:alone --scope @dzcode.io/web
yarn lerna run generate:sitemap --scope @dzcode.io/web
yarn lerna run generate:htmls --scope @dzcode.io/web
env:
CI: true
2 changes: 1 addition & 1 deletion .github/workflows/ci.pr.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
os: [ubuntu-latest]
browser: [chrome, firefox, edge]
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["javascript"]
node-version: [18.x]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
language: ["javascript", "typescript"]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
node-version: [20.x]

steps:
- name: "Git"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ If you use VSCode, please make sure to have a `.vscode/settings.json` file with

```json
{
"files.associations": {
"*.css": "tailwindcss"
},
"prettier.configPath": "packages/tooling/.prettierrc",
"eslint.options": { "overrideConfigFile": "packages/tooling/.eslintrc.json" },
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll.eslint": "always",
"source.fixAll.ts": "always"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion api/oracle-cloud/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:20
# Create app directory
WORKDIR /usr/src/repo

Expand Down
7 changes: 4 additions & 3 deletions api/oracle-cloud/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// can be ran locally from ./api:
// SSH_ADDRESS_STG="[email protected]" SSH_PATH="path/to/private/ssh/key" yarn deploy:stg

import { execSync } from "child_process";
import { copySync, existsSync } from "fs-extra";
import { join } from "path";
Expand Down Expand Up @@ -82,8 +85,6 @@ logs = execSync(
console.log("✅ New code uploaded.");

console.log("\n⚙️ Starting up the app");
logs = execSync(
sshPrefix + '"sudo docker-compose -f ' + appPath + '/docker-compose.yml up -d --build"',
);
logs = execSync(sshPrefix + '"cd ' + appPath + ' && docker compose up -d --build"');
console.log(String(logs));
console.log("✅ Deployment successful.");
4 changes: 2 additions & 2 deletions api/oracle-cloud/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ services:
ports:
- "80:7070"
env_file:
- /home/opc/app-env/api.env
- /home/ubuntu/app-env/api.env
volumes:
- /home/opc/app-data/api/fetch_cache:/usr/src/repo/api/fetch_cache
- /home/ubuntu/app-data/api/fetch_cache:/usr/src/repo/api/fetch_cache
6 changes: 3 additions & 3 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
},
"scripts": {
"build": "lerna run build:alone [email protected]/api --include-dependencies --stream",
"build:alone": "tsc",
"build:alone:watch": "tsc --watch --preserveWatchOutput",
"build:alone": "tspc",
"build:alone:watch": "tspc --watch --preserveWatchOutput",
"build:watch": "lerna run build:alone:watch [email protected]/api --include-dependencies --parallel",
"clean": "lerna run clean:alone [email protected]/api --include-dependencies --stream",
"clean:alone": "rimraf dist coverage fetch_cache oracle-cloud/build",
Expand All @@ -80,7 +80,7 @@
"lint:fix:alone": "yarn lint:eslint --fix . && yarn lint:prettier --write .",
"lint:prettier": "prettier --config ../packages/tooling/.prettierrc --ignore-path ../packages/tooling/.prettierignore --loglevel warn",
"lint:ts-prune": "ts-node ../packages/tooling/setup-ts-prune.ts && ts-prune --error",
"lint:tsc": "tsc --noEmit",
"lint:tsc": "tspc --noEmit",
"start": "node dist/app/index.js",
"start:dev": "ts-node ../packages/tooling/nodemon.ts @dzcode.io/api && nodemon dist/app/index.js",
"test": "yarn build && yarn test:alone",
Expand Down
6 changes: 6 additions & 0 deletions api/src/contribution/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export class ContributionRepository {
)
).reduce((pV, cV) => [...pV, ...cV], []);
if (filterFn) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contributions = contributions.filter(filterFn);
}
contributions = contributions.sort(
Expand All @@ -93,11 +95,15 @@ export class ContributionRepository {
this.pushUniqueOption([{ name: project.slug, label: project.name }], filters[0].options);

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

this.pushUniqueOption(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
labels.map((label) => ({ name: label })),
filters[2].options,
);
Expand Down
47 changes: 1 addition & 46 deletions api/src/project/controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AccountEntity } from "@dzcode.io/models/dist/account";
import { Controller, Get } from "routing-controllers";
import { OpenAPI, ResponseSchema } from "routing-controllers-openapi";
import { DataService } from "src/data/service";
Expand Down Expand Up @@ -26,52 +25,8 @@ export class ProjectController {
// get projects from /data folder:
const projects = await this.dataService.listProjects();

// fetch info about these projects from github:
const infoRichProjects: GetProjectsResponseDto["projects"] = await Promise.all(
projects.map(async (project) => {
const { repositories } = project;
return {
...project,
repositories: await Promise.all(
repositories.map(async ({ provider, owner, repository }) => {
let contributionCount = 0;
let contributors: AccountEntity[] = [];
let languages: string[] = [];
try {
[contributionCount, contributors, languages] = await Promise.all([
(await this.githubService.listRepositoryIssues({ owner, repository })).length,
await Promise.all(
(
await this.githubService.listRepositoryContributors({ owner, repository })
).map(async ({ login }) => {
const githubUser = await this.githubService.getUser({ username: login });
return this.githubService.githubUserToAccountEntity(githubUser);
}),
),
await this.githubService.listRepositoryLanguages({ owner, repository }),
]);
} catch (error) {
this.loggerService.error({
message: `Failed to fetch rich info for project: ${owner}/${repository}`,
meta: { owner, repository, error },
});
}

return {
provider,
owner,
repository,
stats: { contributionCount, languages },
contributors,
};
}),
),
};
}),
);

return {
projects: infoRichProjects,
projects,
};
}
}
6 changes: 1 addition & 5 deletions api/src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,5 @@ import { GeneralResponseDto } from "src/app/types";
export class GetProjectsResponseDto extends GeneralResponseDto {
@ValidateNested({ each: true })
@Type(() => ProjectEntity)
// @TODO-ZM: find a way to DRY this, eg:
// projects!: Model<ProjectEntity, 'repositories' | 'repositories.contributors' | 'repositories.stats'>[]
projects!: Array<
Model<ProjectEntity> & { repositories: Model<RepositoryEntity, "contributors" | "stats">[] }
>;
projects!: Array<Model<ProjectEntity> & { repositories: Model<RepositoryEntity>[] }>;
}
2 changes: 1 addition & 1 deletion api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@dzcode.io/tooling/tsconfig.json",
"extends": "../packages/tooling/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"baseUrl": "."
Expand Down
2 changes: 1 addition & 1 deletion data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.1.4",
"cpx": "^1.5.0",
"firebase-tools": "^9.1.0"
"firebase-tools": "^13.16.0"
},
"engines": {
"node": ">=16",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*", "api", "data", "web", "mobile"],
"packages": ["packages/*", "api", "data", "web"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
Expand Down
Loading

0 comments on commit d557d10

Please sign in to comment.