Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luwol03 authored Jun 13, 2022
2 parents c11391e + c32b3d3 commit f8f3047
Show file tree
Hide file tree
Showing 125 changed files with 12,611 additions and 4,503 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 14
cache: "npm"
# cache: "npm"

- name: Install dependencies
run: npm i
Expand All @@ -46,7 +46,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 14
cache: "npm"
# cache: "npm"

- name: Install dependencies
run: npm i
Expand Down
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "stylelint-config-sass-guidelines",
"extends": ["stylelint-config-sass-guidelines", "stylelint-config-recess-order"],
"rules": {
"order/properties-alphabetical-order": null,
"max-nesting-depth": 4,
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
This changelog goes through all the changes that have been made in each release on the
[vocascan-frontend](https://github.com/vocascan/vocascan-frontend).

## [v1.3.0](https://github.com/vocascan/vocascan-frontend/releases/tag/v1.3.0) - 2022.06.13

In this version, some new features have been added that make it easier to use. Now you can switch between the two predefined light and dark mode themes or load your own themes into your self-hosted frontend instance. Additionally, the frontend has been made responsive to make Vocascan more comfortable to use on mobile devices. Last but not least, a custom blocking of unverified users has been built into the frontend and backend to make it easier to find spam accounts.

- Features
- email verification popup (#116)
- Theme system (#111)
- Add vocabsearch to "All Vocabs" screen (#110)
- Refactors
- Responsive design SCSS (#115)
- About page update (#117)

## [v1.2.1](https://github.com/vocascan/vocascan-frontend/releases/tag/v1.2.1) - 2022.01.29

This release of vocascan-frontend fixes the country flags in firefox and the linebreaks in the vocab card description. The new password complexity indicator will force secure passwords to the users.
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:14-alpine AS builder
WORKDIR /app

COPY package.json .
COPY package-lock.json .

RUN npm install

Expand Down
99 changes: 52 additions & 47 deletions docker/generate-config.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,73 @@
const fs = require("fs");
const path = require("path");

const configPath = path.resolve("/usr/share/nginx/html/config.js");

console.log("Pre-start: Generating config file…");

let content = "";
try {
content = fs.readFileSync(configPath, { encoding: "utf-8" });
} catch {
console.log(
`Pre-start: ⚠️ No existing config file found under "${configPath}".`
const readConfig = () => {
if (!fs.existsSync(configPath)) {
console.warn(
`Pre-start: ⚠️ No existing config file found under "${configPath}".`
);
process.exit();
}
const content = fs.readFileSync(configPath, "utf-8");
const existing = content.match(
/window\.VOCASCAN_CONFIG\s*=\s*JSON.parse\(`([\s\S]*)`\)/
);
}
if (!existing || existing.length < 2) {
console.warn("Pre-start: ⚠️ Could not find existing config in config.js");
process.exit();
}
return JSON.parse(existing[1]);
};

const writeConfig = (config) => {
const json = JSON.stringify(config, null, 4);
const newContent = `window.VOCASCAN_CONFIG = JSON.parse(\`${json}\`);\n`;
fs.writeFileSync(configPath, newContent, "utf-8");
};

const convertToNativeType = (input) => {
if (["true", "false"].includes(input)) {
return input === "true";
}

if (!Number.isNaN(+input)) {
return +input;
if (!Number.isNaN(parseInt(input))) {
return parseInt(input);
}

return input;
};

const envVars = Object.entries(process.env).reduce((acc, [key, value]) => {
if (key.startsWith("VOCASCAN_")) {
acc[key.replace(/^VOCASCAN_/, "")] = convertToNativeType(value);
}
const htmlPath =
process.env.NODE_ENV === "development"
? path.resolve(__dirname, "..", "public")
: "/usr/share/nginx/html";
const configPath = path.resolve(htmlPath, "config.js");
const themesPath = path.resolve(htmlPath, "themes");

return acc;
}, {});
console.log("Pre-start: Generating config file…");

const existing = content.match(/window\.VOCASCAN_CONFIG *= *(\{[\s\S]*\})/);
let existingConfig = {};
const config = readConfig();

if (existing && existing[1]) {
// evaluate to get the object string as object
// eslint-disable-next-line no-eval
existingConfig = eval(`(${existing[1]})`);
}

const newContent = `window.VOCASCAN_CONFIG = ${JSON.stringify(
{ ...existingConfig, ...envVars },
null,
2
).replace(
/ {2}"(.*)": (".*"|[^,\n]*),?/gm,
(_, key, value) => ` ${key}: ${value.replace(/^"(.*)"$/, "'$1'")},`
)};\n`;
Object.entries(process.env).forEach(([key, value]) => {
if (key.startsWith("VOCASCAN_")) {
config[key.replace(/^VOCASCAN_/, "")] = convertToNativeType(value);
}
});

try {
fs.writeFileSync(configPath, newContent, { encoding: "utf-8", flag: "w" });
console.log(
`Pre-start: ✓ Wrote config file successfully to "${configPath}".`
if (fs.existsSync(themesPath) && fs.lstatSync(themesPath).isDirectory()) {
const themes = Object.fromEntries(
fs
.readdirSync(themesPath)
.map((theme) => [
theme.replace(/(themes\/|.css)/g, ""),
`themes/${theme}`,
])
);
} catch (error) {
if (error.code === "ENOENT") {
console.error(
`Pre-start: X Could not write config file to "${configPath}".`
);
} else {
throw error;
}
config.themes = { ...config.themes, ...themes };
}

writeConfig(config);

console.log(
`Pre-start: ✓ Successfully written config file to "${configPath}".`
);
Loading

0 comments on commit f8f3047

Please sign in to comment.