Skip to content

Commit 2efaf47

Browse files
more CI/CD
1 parent 4d0437c commit 2efaf47

19 files changed

Lines changed: 281 additions & 148 deletions

.github/workflows/build.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
prettier:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: npm
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Run Build
23+
run: npm run build
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
prettier:
10+
uses: ./.github/workflows/prettier.yaml
11+
12+
eslint:
13+
uses: /.github/workflows/eslint.yaml
14+
15+
build:
16+
uses: /.github/workflows/build.yaml

.github/workflows/eslint.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Eslint Check
2+
3+
on:
4+
workflow_call
5+
6+
jobs:
7+
prettier:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: npm
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Run Eslint Check
23+
run: npx eslint .

.github/workflows/prettier.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Prettier Check
22

33
on:
4-
pull_request:
5-
push:
6-
branches: [ "**"]
4+
workflow_call:
75

86
jobs:
97
prettier:

.github/workflows/test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
run-tests:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: npm
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run tests
24+
run: npm test -- --ci

src/app/Bauhaus/Bauhaus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export default function BauhausPage() {
66
<h1 className="text-5xl font-bold">Hello World!</h1>
77
</main>
88
);
9-
}
9+
}

src/app/Bauhaus/page.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use client';
1+
"use client";
22
import React, { useState, useEffect, useRef } from "react";
33
import BauhausPage from "./Bauhaus";
44

55
export default function Home() {
6-
return (
7-
<BauhausPage/>
8-
);
6+
return <BauhausPage />;
97
}

src/app/Terminal.js

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
//This ensures that the component is only rendered on the client side
2-
'use client';
2+
"use client";
33
import React, { useState, useEffect, useRef } from "react";
44
import { useRouter } from "next/navigation";
55
import { MdOutlineTerminal } from "react-icons/md";
66
import TerminalInput from "@/components/terminal/TerminalInput";
77
import TerminalHistory from "@/components/terminal/TerminalHistory";
8-
import AboutCommand from "@/components/terminal/commands/AboutCommand"
9-
import ContactCommand from "@/components/terminal/commands/ContactCommand"
8+
import AboutCommand from "@/components/terminal/commands/AboutCommand";
9+
import ContactCommand from "@/components/terminal/commands/ContactCommand";
1010
import SwitchUser from "@/components/terminal/commands/SwitchUser";
1111
import ShowProjects from "@/components/terminal/commands/ShowProjects";
1212
import ManCommand from "@/components/terminal/commands/ManCommand";
1313
import CowSay from "@/components/terminal/commands/CowSayCommand";
14-
import { asciiArtDesktop, asciiArtMobile } from "@/components/terminal/asciiArt";
14+
import {
15+
asciiArtDesktop,
16+
asciiArtMobile,
17+
} from "@/components/terminal/asciiArt";
1518

1619
export default function TerminalPage() {
17-
1820
const router = useRouter();
1921
const [name, switchUser] = useState("guest");
2022
const [input, setInput] = useState("");
21-
const [history, setHistory] = useState([{
22-
id: Date.now(),
23-
command: "",
24-
name: "",
25-
text: typeof window !== "undefined" && window.innerWidth < 768
26-
? asciiArtMobile
27-
: asciiArtDesktop
28-
}]);
29-
23+
const [history, setHistory] = useState([
24+
{
25+
id: Date.now(),
26+
command: "",
27+
name: "",
28+
text:
29+
typeof window !== "undefined" && window.innerWidth < 768
30+
? asciiArtMobile
31+
: asciiArtDesktop,
32+
},
33+
]);
34+
3035
const terminalRef = useRef(null);
3136
const inputRef = useRef(null);
3237

@@ -44,79 +49,87 @@ export default function TerminalPage() {
4449
command: cmd,
4550
text: "",
4651
};
47-
48-
52+
4953
if (cmd === "clear") {
50-
setHistory([{
51-
id: Date.now(),
52-
command: "",
53-
name: "",
54-
text: typeof window !== "undefined" && window.innerWidth < 768
55-
? asciiArtMobile
56-
: asciiArtDesktop
57-
}]);
54+
setHistory([
55+
{
56+
id: Date.now(),
57+
command: "",
58+
name: "",
59+
text:
60+
typeof window !== "undefined" && window.innerWidth < 768
61+
? asciiArtMobile
62+
: asciiArtDesktop,
63+
},
64+
]);
5865
setInput("");
59-
return;
66+
return;
6067
} else if (cmd === "about") {
6168
entry.text = AboutCommand;
6269
} else if (cmd === "contact") {
6370
entry.text = ContactCommand;
6471
} else if (cmd.startsWith("project")) {
6572
entry.text = ShowProjects({ cmd });
6673
} else if (cmd.startsWith("su")) {
67-
entry.text = SwitchUser({ cmd, switchUser});
74+
entry.text = SwitchUser({ cmd, switchUser });
6875
} else if (cmd.startsWith("man")) {
6976
entry.text = ManCommand({ cmd });
7077
} else if (cmd.startsWith("cowsay")) {
7178
entry.text = CowSay({ cmd });
72-
} else if (cmd === "whoami"){
73-
entry.text = name
79+
} else if (cmd === "whoami") {
80+
entry.text = name;
7481
} else {
7582
entry.text = `Command not found: ${cmd}`;
7683
}
7784

7885
entry.name = name;
79-
setHistory(prev => [...prev, entry]);
86+
setHistory((prev) => [...prev, entry]);
8087
setInput("");
81-
}
88+
};
8289

83-
const onKeyDown = (e) => {
90+
const onKeyDown = (e) => {
8491
if (e.key === "Enter") {
8592
handleCommand(input.trim());
8693
}
8794
};
8895

89-
return(
90-
<div className="min-h-screen bg-black text-white p-4 font-mono"
96+
return (
97+
<div
98+
className="min-h-screen bg-black text-white p-4 font-mono"
9199
style={{
92100
maxWidth: "100vw",
93101
overflowX: "auto",
94-
fontSize: "1em"
95-
}}>
102+
fontSize: "1em",
103+
}}
104+
>
96105
<div className="flex items-center justify-between mb-4">
97106
<h1 className="text-2xl">Finn van Montfort's Portfolio</h1>
98107
<button
99108
aria-label="Switch to Bauhaus"
100109
onClick={() => router.push("/Bauhaus")}
101-
><MdOutlineTerminal size={32} className="text-white hover:text-green-400 transition-colors" /></button>
102-
110+
>
111+
<MdOutlineTerminal
112+
size={32}
113+
className="text-white hover:text-green-400 transition-colors"
114+
/>
115+
</button>
103116
</div>
104117
<div
105118
ref={terminalRef}
106119
className="mt-2 w-full overflow-x-auto whitespace-pre-wrap"
107120
style={{ maxWidth: "100%", height: "60vh", position: "relative" }}
108121
>
109122
<div text="white" className="mt-2">
110-
<TerminalHistory history={history} />
123+
<TerminalHistory history={history} />
111124
<TerminalInput
112125
name={name}
113126
input={input}
114-
onChange={e => setInput(e.target.value)}
127+
onChange={(e) => setInput(e.target.value)}
115128
onKeyDown={onKeyDown}
116129
inputRef={inputRef}
117130
/>
118131
</div>
119132
</div>
120133
</div>
121-
)
122-
}
134+
);
135+
}

src/app/page.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use client';
1+
"use client";
22
import React, { useState, useEffect, useRef } from "react";
33
import TerminalPage from "./Terminal";
44

55
export default function Home() {
6-
return (
7-
<TerminalPage/>
8-
);
6+
return <TerminalPage />;
97
}

src/components/terminal/TerminalHistory.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,39 @@ export default function TerminalHistory({ history }) {
55
return (
66
<>
77
{history.map((entry, i) => (
8-
<div key={i} style={{ fontFamily: "monospace", fontSize: "1rem", marginBottom: "0.2rem" }}>
8+
<div
9+
key={i}
10+
style={{
11+
fontFamily: "monospace",
12+
fontSize: "1rem",
13+
marginBottom: "0.2rem",
14+
}}
15+
>
916
{entry.command && (
1017
<div style={{ display: "flex", alignItems: "center" }}>
11-
<span style={{ color: "limegreen", marginRight: "0.5rem" }}>{entry.name}@portfolio:~$</span>
18+
<span style={{ color: "limegreen", marginRight: "0.5rem" }}>
19+
{entry.name}@portfolio:~$
20+
</span>
1221
<span>{entry.command}</span>
1322
</div>
1423
)}
1524
{entry.text && (
16-
<div style={{
17-
color: "#ccc",
18-
whiteSpace: "pre-wrap",
19-
lineHeight: entry.text === asciiArtDesktop || entry.text === asciiArtMobile ? "1" : "normal"
20-
}}>
25+
<div
26+
style={{
27+
color: "#ccc",
28+
whiteSpace: "pre-wrap",
29+
lineHeight:
30+
entry.text === asciiArtDesktop ||
31+
entry.text === asciiArtMobile
32+
? "1"
33+
: "normal",
34+
}}
35+
>
2136
{entry.text}
2237
</div>
2338
)}
2439
</div>
2540
))}
2641
</>
2742
);
28-
}
43+
}

0 commit comments

Comments
 (0)