Skip to content

Commit

Permalink
Restore utility files
Browse files Browse the repository at this point in the history
Signed-off-by: cph101 <[email protected]>
  • Loading branch information
cph101 committed Apr 19, 2024
1 parent a1e5d29 commit 2fa12e4
Show file tree
Hide file tree
Showing 19 changed files with 480 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Decrypt, Build, Deploy

on:
push:
branches:
- main
paths-ignore:
- ./**.md
workflow_dispatch:

concurrency: # Does this stuff even work?
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pages: write
id-token: write

jobs:
decrypt:
name: 🔐 Decrypt
runs-on: ubuntu-latest
outputs:
current_date: ${{ steps.get_date.outputs.CURRENT_DATE }}
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Setup Node
uses: actions/[email protected]

- name: Install dependencies
run: npm install

- name: Decrypt with OpenSSL
env:
WEB_SOURCE_PASS: ${{ secrets.WEB_SOURCE_PASS }} # There's nothing you can do >:)
run: openssl enc -d -aes-256-cbc -in source_encrypted.enc -out src.zip -pass env:WEB_SOURCE_PASS

- name: Unzip decrypted source
run: unzip -o -qq src.zip

- name: Get date
id: get_date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT

- name: Save source
uses: actions/cache/save@v3
with:
path: ./src
key: decrypted-source-${{ steps.get_date.outputs.CURRENT_DATE }}

build:
name: 🛠️ Build
runs-on: ubuntu-latest
needs: decrypt

steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Setup Node
uses: actions/[email protected]

- name: Restore cached source
uses: actions/cache/restore@v3
with:
path: ./src
key: decrypted-source-${{ needs.decrypt.outputs.current_date }}

- name: Install dependencies
run: npm install

- name: Compile CSS
run: npm run css

- name: Build project
run: npm run build

- name: Create 404 page
run: cp ./dist/{index.html,404.html}

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload build files
uses: actions/[email protected]
with:
name: Compiled site
path: ./dist

deploy:
name: 📤 Deploy
runs-on: ubuntu-latest
needs: build
environment: GitHub Pages (Vite)
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]
with:
artifact_name: Compiled site
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
src/
src.zip
node_modules/
dist/
.replit
replit.nix
package-lock.json
latest.log
CNAME
yarn.lock
sec/
/.breakpoints
/.cache
/.idea
/.upm
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# My new website

## Features

- Blazing fast loading speed (don't ask me how)
- Blog (not yet lol)
- You can't steal the source code >:)
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/gif" href="/profile.gif" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/minecraftia" type="text/css">
<style lang="sass">
@import url("./src/compiled.scss")
</style>
<script>
const global = {};
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<!-- Good luck reverse engineering this... !-->
</body>
</html>
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "cph101-website",
"version": "1.0.0",
"description": "Figure it out yourself, sherlock",
"main": "index.js",
"scripts": {
"dev": "vite",
"css": "npx postcss ./src/main.scss -o ./src/compiled.scss",
"build": "vite build",
"remote": "node production.js remote",
"decrypt": "node production.js decrypt",
"encrypt": "node production.js encrypt"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@vitejs/plugin-react": "^4.2.0",
"child_process": "^1.0.2",
"daisyui": "^4.4.14",
"postcss-import": "^16.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.4.3",
"three": "^0.132.2",
"typescript": "^5.2.2",
"vite": "^5.0.10"
},
"dependencies": {
"@loadable/component": "^5.15.3",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@uiw/react-markdown-preview": "^5.0.3",
"autoprefixer": "^10.4.19",
"clsx": "^2.1.0",
"colors": "^1.4.0",
"firebase": "^10.6.0",
"framer-motion": "^11.0.24",
"from": "^0.1.7",
"gl-react": "^5.2.0",
"gl-react-dom": "^5.2.1",
"hoist-non-react-statics": "^3.3.2",
"import": "^0.0.6",
"mermaid": "^10.6.1",
"postcss": "^8.4.38",
"postcss-cli": "^11.0.0",
"postcss-scss": "^4.0.9",
"raf": "^3.4.1",
"React": "npm:react@^18.2.0",
"react-head": "^3.4.2",
"react-iframe": "^1.8.5",
"react-router-dom": "^6.20.1",
"rehype-rewrite": "^4.0.2",
"sass": "^1.69.5",
"tailwind-merge": "^2.2.2",
"three": "^0.132.2",
"use-elapsed-time": "^3.0.4"
}
}
8 changes: 8 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
parser: 'postcss-scss',
plugins: {
'postcss-import': {},
tailwindcss: {},
autoprefixer: {},
}
}
153 changes: 153 additions & 0 deletions production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const fs = require("fs");

function fancyLog(text, type = "success") {
let logText;
if (type === "success") {
logText = `\x1b[0;32m✓ ${text}\x1b[0m`;
} else if (type === "warn") {
logText = `\x1b[0;33m⚠ ${text}\x1b[0m`;
} else {
logText = `\x1b[0;31m× Error: ${text}\x1b[0m`;
}
console.log(logText);
}

async function question(text) {
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise((resolve) => {
readline.question(text, (answer) => {
readline.close();
resolve(answer.trim());
});
});
}

async function executeCommand(command, options = {}, successMessage) {
try {
let commandThrewFatalError = false;
const { stdout, stderr } = await exec(command);

if (stderr && Object.keys(options).length > 0) {
const specialKeys = Object.keys(options);
let errorHandled = false;

for (const line of stderr.split("\n")) {
let errorFlagged = false;

for (const opkey of specialKeys) {
if (line.includes(opkey) && options[opkey] !== "ignore") {
let plainlog = options[opkey].split("---")[0];
let type = options[opkey].split("---")[1] || "error";

if (type !== "warn") {
commandThrewFatalError = true;
}
fancyLog(plainlog, type);
errorFlagged = true;
break; // Exit loop since the error was flagged
}
}

if (!errorFlagged && !errorHandled) {
// Unhandled fatal error
let commandname = command.split(" ")[0];
fs.appendFileSync("latest.log", options[opkey] !== "ignore" ? stderr.trim() + "\n" : `'${commandname}' logged to stderr but was ignored\n`);
commandThrewFatalError = options[opkey] !== "ignore";
fancyLog(options[opkey] !== "ignore" ? `'${commandname}' threw a fatal unhandled error, check latest.log` : `${commandname} logged to stderr but was ignored`, "error");
errorHandled = true;
}
}
}

if (!commandThrewFatalError && successMessage) {
fancyLog(successMessage, "success");
}
} catch (flies) {
// Prevent errors escalating to shell/console
}
}



async function remoteCommand(webSourcePass) {
await executeCommand(
"find ./src -name '.DS_Store' -type f -delete 2>/dev/null",
);
const response = await question("Are you sure you want to proceed? (y/n): ");
if (response === "y") {
await executeCommand("zip -r src.zip ./src -x '*.DS_Store'");
await executeCommand(
`openssl enc -aes-256-cbc -salt -in src.zip -out source_encrypted.enc -pass pass:${webSourcePass}`,
{ deprecated: "Encryption method is deprecated---warn", better:"ignore" },
"Encryption succeeded",
);
await executeCommand("rm src.zip");
await executeCommand(
`git commit -a -m "${await question("Enter a custom commit message: ")}"`,
{},
"Files successfully committed",
);
await executeCommand(
"git push 2>&1 >/dev/null",
{
hint: "ignore",
To: "ignore",
rejected: "Upstream changes, rebase might be required---warn",
"failed to push": "Push failed",
},
"Files successfully pushed",
);
}
}

async function decryptCommand(webSourcePass) {
await executeCommand(
`openssl enc -d -aes-256-cbc -in source_encrypted.enc -out src.zip -pass pass:${webSourcePass}`,
{ deprecated: "Encryption method is deprecated---warn" },
"Decryption succeeded",
);
await executeCommand("unzip src.zip");
await executeCommand("rm src.zip");
}

async function encryptCommand(webSourcePass) {
await executeCommand("zip -r src.zip ./src -x '*.DS_Store'");
await executeCommand(
`openssl enc -aes-256-cbc -salt -in src.zip -out source_encrypted.enc -pass pass:${webSourcePass}`,
{ deprecated: "Encryption method is deprecated---warn" },
"Encryption succeeded",
);
await executeCommand("rm src.zip");
}

const args = process.argv.slice(2);
const command = args[0];

(async () => {
let webSourcePass =
process.env.web_source_pass ||
process.env["web_source_pass"] ||
(await question("Enter encryption password: "));

await executeCommand("rm latest.log", "ignore");

switch (command) {
case "remote":
await remoteCommand(webSourcePass);
break;
case "decrypt":
await decryptCommand(webSourcePass);
break;
case "encrypt":
await encryptCommand(webSourcePass);
break;
default:
fancyLog("You're in my website, and I'm in your walls >:]", "warn");
break;
}
})();
15 changes: 15 additions & 0 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/panorama_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/profile.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source_encrypted.enc
Binary file not shown.
Loading

0 comments on commit 2fa12e4

Please sign in to comment.