Skip to content

Commit

Permalink
patch: feat enhancement + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BRAVO68WEB committed Jan 4, 2024
1 parent 3594d4b commit 1671533
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 28 deletions.
4 changes: 0 additions & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ runs:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install dependencies
shell: bash
run: pnpm i

- name: Restore Turborepo Cache
uses: actions/cache@v3
with:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/build-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Build and Release Desktop Client
on:
workflow_dispatch:
inputs:
serverip:
default: '0.0.0.0:4000'
server_url:
default: 'http://127.0.0.1:4000'
required: false
type: string
description: 'Server IP (with port) for RCS CTF API Server'
description: 'Server URL (with port) for RCS CTF API Server'
release_version:
default: '0.0.0-dev'
required: false
Expand Down Expand Up @@ -53,11 +53,14 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/setup

- name: Copy before build
run: |
cd packages/deployer-url
node entrypoint.js ${{ github.event.inputs.serverip }}
bash bootstrap.sh ${{ github.event.inputs.server_url }}
- name: Install dependencies
shell: bash
run: pnpm i

- name: Build
run: pnpm build:client
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup

- name: Run before install
run: |
bash bootstrap.sh http://127.0.0.1:4000
- name: Install dependencies
shell: bash
run: pnpm i

- name: Install Dependencies
run: pnpm build
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"type": "module",
"scripts": {
"dev": "vite",
"dev:client": "cross-env VITE_CL_MODE=client vite",
"build": "vite build",
"build:client": "cross-env MODE=client vite build",
"build:client": "cross-env VITE_CL_MODE=client vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/libs/api.client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ip from "deployer-url"
import customhost from "deployer-url"
import axios from 'axios';

let url;
export let url;

if (import.meta.env.MODE == "client") {
url = ip;
if (import.meta.env.VITE_CL_MODE == "client") {
url = customhost;
} else {
url = import.meta.env.VITE_API_URL;
}
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/pages/about.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '../App.css'
import 'react-toastify/dist/ReactToastify.css';
import Navbar from '../components/navbar';
import { url } from '../libs/api.client';

function Home() {
return (
Expand All @@ -16,6 +17,11 @@ function Home() {
<div className="action-card">
<a href="https://www.youtube.com/watch?v=9Pzj7Aj25lw">How to use the scoreboard</a>
</div>

<h2>API URL</h2>
<div className="action-card">
{url}
</div>
</div>
</>
)
Expand Down
4 changes: 4 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cd packages/deployer-url || exit
node entrypoint.js "$@"
1 change: 1 addition & 0 deletions packages/deployer-url/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
host.js
1 change: 0 additions & 1 deletion packages/deployer-url/config.json

This file was deleted.

14 changes: 10 additions & 4 deletions packages/deployer-url/entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import fs from 'node:fs';
/* eslint-disable unicorn/prefer-node-protocol */
import fs from "fs";

const processargs = process.argv.slice(2);
const ip = processargs[0];
const host = processargs[0];

fs.writeFileSync('./config.json', JSON.stringify({ ip }));
let data = `
let hostname = "${host}";
export default hostname;
`;

console.log("Deployer URL set to " + ip + ".");
fs.writeFileSync('./host.js', data);

console.log("Deployer URL set to " + host + ".");
5 changes: 0 additions & 5 deletions packages/deployer-url/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/deployer-url/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "deployer-url",
"version": "1.0.0",
"main": "index.js",
"main": "host.js",
"license": "MIT",
"type": "module"
}
2 changes: 1 addition & 1 deletion scripts/build-client.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

cd apps/web || exit
pnpm run build
pnpm run build:client
cd ../..
mkdir -p apps/desktop/dist
cp -r apps/web/dist/* apps/desktop/dist
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"extends": "@bravo68web/tsconfig/base.json"
"extends": "@bravo68web/tsconfig/base.json",
"exclude": [
"apps/web",
"apps/desktop/dist",
"packages/api/dist",
"packages/deployer-url",
]
}

0 comments on commit 1671533

Please sign in to comment.