Skip to content

Commit

Permalink
Migrate to Vite (#40)
Browse files Browse the repository at this point in the history
* Replace CRA with Vite, starter code runs; add new linters stuff

* Update backend with secret scanning

* Replace references to CRA with Vite in writeup

* Replace Jest with Vitest, update writeup + CI

* Upgrade Husky in backend

* `npm install` in backend
  • Loading branch information
wllmwu authored Apr 29, 2024
1 parent 96eed84 commit abbbd44
Show file tree
Hide file tree
Showing 41 changed files with 6,039 additions and 34,521 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/jest-tests.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run tests
on:
pull_request:
branches: main
push:
branches: main
jobs:
frontend:
name: Frontend tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Run tests
working-directory: frontend
run: |
npm ci
npm run test -- run
3 changes: 2 additions & 1 deletion .husky/lint-config.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This config file is sourced by the pre-commit script.
# shellcheck disable=SC2034,SC2148

# Change 1 to 0 to disable linting.
enabled=1

# Directories containing Node.js projects to be linted, separated by spaces.
# Directories containing JavaScript projects to be linted, separated by spaces.
node_dirs='backend frontend'

# Command used to run a lint check.
Expand Down
13 changes: 10 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# produces a "cannot spawn" error with a bash shebang, since it uses dash.
# However, dash is not available on many Unix-like systems.

# shellcheck disable=SC2317

log() {
echo "${0}: ${*}" >&2
}
Expand Down Expand Up @@ -61,7 +63,7 @@ ask_yes_no() {
fi

while :; do
printf "${0}: ${prompt}"
printf "%s: %s" "${0}" "${prompt}"
read -r selection
selection="$(parse_yes_no "${selection}")"

Expand All @@ -86,7 +88,7 @@ ask_yes_no() {
explain_no_verify() {
log "If you wish to bypass the lint check entirely,"
log "use the following command:"
log " git commit --no-verify"
log " NO_LINT=1 git commit"
}

dir_check() {
Expand Down Expand Up @@ -176,12 +178,17 @@ cancel() {

main() {
config_file="$(dirname "${0}")/lint-config.sh"

# shellcheck source=./lint-config.sh
if ! . "${config_file}"; then
error "Error while sourcing config file '${config_file}'."
exit 1
fi

if [ "${enabled}" -eq 0 ]; then
secret_scan_script="$(dirname "${0}")/../.secret-scan/secret-scan.js"
node "${secret_scan_script}" || exit

if [ "${enabled}" = 0 ] || [ "${NO_LINT}" = 1 ]; then
warn "Lint check has been disabled."
exit 0
fi
Expand Down
3 changes: 3 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
secret_scan_script="$(dirname "${0}")/../.secret-scan/secret-scan.js"
node "${secret_scan_script}"
2 changes: 2 additions & 0 deletions .secret-scan/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/secret-scan-cache.json
/secret-scan-report.json
27 changes: 27 additions & 0 deletions .secret-scan/secret-scan-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"//": [
"Regexes used to scan the repository contents for secrets.",
"If possible, try to make the regex match the entire secret, or",
"allowedStrings might not work as expected. For example, if a regex",
"matches only 'mongodb', this string by itself does not contain any of the",
"strings in the allowlist, so it will still be flagged."
],
"secretRegexes": {
"mongodbUrl": "mongodb([+]srv)?://[^\\s]+",
"firebaseJsonPrivateKeyFile": "-----BEGIN PRIVATE KEY-----[^\\s]+"
},
"//": [
"To prevent a particular string from being flagged, add it (or a substring",
"of it) to this array. This can be useful if your repository contains an",
"example of what a credential should look like, a development credential",
"(e.g. a database on localhost), or a previously leaked credential that",
"has already been revoked. Obviously, do not put active credentials here."
],
"allowedStrings": ["mongodb://127.0.0.1", "mongodb://localhost"],
"//": [
"Do not check for secrets in these files. You should almost always use",
"allowedStrings instead of this. We only add this config because it",
"naturally contains things that look like secrets, but aren't."
],
"skippedFiles": [".secret-scan/secret-scan-config.json"]
}
Loading

0 comments on commit abbbd44

Please sign in to comment.