Browse Source

Setting up new Hugo-based client development flow

master
Mobius K 10 months ago
parent
commit
79cc4bc7ec
  1. 2
      .editorconfig
  2. 2
      .gitignore
  3. 68
      Makefile
  4. 6
      babel.config.js
  5. 2
      bluetooth-class
  6. 14
      config.development.yaml
  7. 30
      config.yaml
  8. 1903
      package-lock.json
  9. 4
      package.json
  10. 2
      portfolio
  11. 18
      shared/scripts/error-monitor.ts
  12. 0
      shared/static/.well-known/security.txt
  13. 0
      shared/static/robots.txt
  14. 11
      shared/static/service-worker.js

2
.editorconfig

@ -24,6 +24,6 @@ insert_final_newline = true
trim_trailing_whitespace = true
# Specific settings just for YAML files
[*.yml]
[{*.yml, *.yaml}]
indent_style = space
indent_size = 2

2
.gitignore

@ -15,6 +15,8 @@ node_modules
# Build system
cli/*.js
hugo_stats.json
resources
# Runtime
*.sqlite3

68
Makefile

@ -0,0 +1,68 @@
# Command line variable building with check for a project flag specified
build = $(if $(project),/srv/$(project), $(error Provide project name))
# When this Makefile run was called
date = $(shell date +%s)
# Directory for public assets to be placed in for a given build
public = $(build)/public
# How to wait for file-system events
inotifywait = inotifywait -qr -e modify -e attrib -e move -e create -e delete
# Transparently calls other make targets without cluttering up the console
subTask = @make --no-print-directory
# Clean build directory to prepare for new files
clean:
rm -rf $(public)/*
# Developing client and server -----------------------------------------------
# Start a development session with auto-updates
develop: clean
$(subTask) project=$(project) clientFlags="--config config.yaml,config.development.yaml server" -j client server
# Start a client development session
client:
hugo --configDir $(project)/config --destination $(public) --noTimes $(clientFlags)
# Start a server development session
server:
@if [ -f $(project)/server/main/main.go ]; then \
while true; do \
go build -o $(build)/private/server $(project)/server/main/main.go; \
cd $(build)/private && ./server & PID=$$!; \
$(inotifywait) $(project)/server $(project)/shared shared/server; \
kill $$PID; \
done \
fi
# Run server with debug enabled, waiting for debug client to attach
server-debug:
dlv --listen localhost:2345 --headless --api-version=2 debug ./$(project)/server/main
# Releases --------------------------------------------------------------------
# Make sure an environment was supplied on the command line
check-environment:
$(if $(environment),, $(error Provide environment 'primary' or 'secondary'))
# Create a build for release
build: check-environment clean
# Build a client with the given environment
$(subTask) clientFlags="--environment $(environment)" client
# Build a server executable if one exists
if [ -f $(project)/server/main/main.go ]; then \
go build -o $(build)/server $(project)/server/main/main.go; \
fi
# Dry-run of transferring build to remote servers
transfer-check:
$(subTask) flags="n" transfer
# Transfer builds to remote servers
transfer: check-environment
rsync -aivzO$(flags) --delete --exclude 'analytics.html' --chmod=D775,F664 --chown=:$(project) $(public)/ $(environment):$(build)/public/

6
babel.config.js

@ -0,0 +1,6 @@
module.exports = {
"presets": [
"@babel/preset-typescript",
"@babel/preset-env",
],
};

2
bluetooth-class

@ -1 +1 @@
Subproject commit 2b8bf76741ddf1b9c2ef1e21dc8a3bdadf76b6d8
Subproject commit b18376e1c857886fe388cac628d15edfdba11e83

14
config.development.yaml

@ -0,0 +1,14 @@
# Minimize HTML
minify:
minifyOutput: false
# Available at $.Site.Params.<key> in templates
params:
fingerprint:
enabled: false
scss:
outputStyle: expanded # expanded (largest), nested (default), compact, or compressed (smallest)
sentry: false
ts:
minify: false
target: esnext # esnext (default, latest), es2020, es2019, ..., es2015 (aka es6), es5 (earliest)

30
config.yaml

@ -0,0 +1,30 @@
# Write hugo_stats.json to use for CSS post-processing
build:
writeStats: true
# We don't want/need these content types
disableKinds:
- RSS
- sitemap
- taxonomy
- term
# We explicitly don't want taxonomies (https://gohugo.io/content-management/taxonomies/)
ignoreErrors:
- error-disable-taxonomy
# Minimize HTML
minify:
minifyOutput: true
# Available at $.Site.Params.<key> in templates
params:
fingerprint:
enabled: true
algorithm: md5 # sha512 (largest), sha384, sha256 (default), or md5 (smallest)
scss:
outputStyle: compressed # expanded (largest), nested (default), compact, or compressed (smallest)
sentry: true
ts:
minify: true
target: es2015 # esnext (default, latest), es2020, es2019, ..., es2015 (aka es6), es5 (earliest)

1903
package-lock.json
File diff suppressed because it is too large
View File

4
package.json

@ -8,6 +8,10 @@
"uikit": "^3.5.9"
},
"devDependencies": {
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@babel/preset-typescript": "^7.12.7",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.4",

2
portfolio

@ -1 +1 @@
Subproject commit 6818b9275eb6a69f6ae33402c603d523853b9408
Subproject commit ae361686366b1f22f91c0db9d51ab400e96e6c67

18
shared/scripts/error-monitor.ts

@ -1,10 +1,4 @@
// Sentry is split off as a separate production-only module.
// It is loaded separately as part of our Rollup configuration.
// Importing Sentry from Node modules is relatively heavy in processing and size:
// import * as Sentry from "@sentry/browser";
// Instead, we can just declare Sentry and check if it's defined at run-time.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const Sentry: any;
import * as Sentry from "@sentry/browser";
/**
* Watches for script errors and sends them to Sentry for tracking
@ -17,16 +11,10 @@ export class ErrorMonitor {
* Do not create an instance of this class when that is not desired,
* for example, in development environments
*
* @param projectName Global identifier as all Sentry releases are global
* @param dsn Data source name for connection to Sentry
*/
constructor(projectName: string, dsn: string) {
if (typeof Sentry !== "undefined" && Sentry != null) {
Sentry.init({
dsn: dsn,
release: `${projectName}@replaceAtBuildWithDate`
});
}
constructor(dsn: string) {
Sentry.init({dsn: dsn});
}
}

0
shared/assets/.well-known/security.txt → shared/static/.well-known/security.txt

0
shared/assets/robots.txt → shared/static/robots.txt

11
shared/static/service-worker.js

@ -0,0 +1,11 @@
// Install the service worker and cache any files for offline use
// New service workers require a tab close and re-open to activate without this
self.addEventListener("install", function(event) {
event.waitUntil(self.skipWaiting());
});
// Activate the service worker and remove previous caches
// Un-registers itself to never be called again, hopefully
self.addEventListener("activate", function(event) {
event.waitUntil(self.registration.unregister().then());
});
Loading…
Cancel
Save