Skip to content

Commit

Permalink
chore: simplify project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wufe committed Nov 26, 2023
1 parent 5c9bdb4 commit 499b0d5
Show file tree
Hide file tree
Showing 229 changed files with 54 additions and 87 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Use Node.js 14.x
go-version: 1.21
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- run: yarn
- name: Install statik
run: go get github.com/rakyll/statik
- name: Build
run: yarn build:prod
- name: Test
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,6 @@ db
__debug_bin

/.db
/.idea
/.idea
/pkg/services/static/*
!/pkg/services/static/.gitkeep
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "packages/server/third_party/polo-pro"]
path = packages/server/third_party/polo-pro
[submodule "third_party/polo-pro"]
path = third_party/polo-pro
url = git@github.com:Wufe/polo-pro.git
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
publicPath: '/_polo_/public/',
filename: isDevelopment ? '[name].js' : '[name].[fullhash].js',
chunkFilename: isDevelopment ? '[id]-chunk.js' : '[id]-chunk.[fullhash].js',
path: path.resolve(cwd, 'public')
path: path.resolve(cwd, 'pkg/services/static')
},
devtool: 'source-map',
resolve: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
publicPath: '/_polo_/public/',
filename: '[name].[fullhash].js',
chunkFilename: '[name].[fullhash].js',
path: path.resolve(cwd, 'public')
path: path.resolve(cwd, 'pkg/services/static')
},
devtool: 'source-map',
resolve: {
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions packages/server/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/wufe/polo

go 1.18
go 1.21

require (
github.com/1lann/udp-forward v0.0.0-20191015034046-6b774a53ea39
Expand All @@ -13,7 +13,6 @@ require (
github.com/kennygrant/sanitize v1.2.4
github.com/logrusorgru/aurora/v3 v3.0.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/rakyll/statik v0.1.7
github.com/sasha-s/go-deadlock v0.2.0
github.com/sirupsen/logrus v1.7.0
go.uber.org/dig v1.10.0
Expand Down
2 changes: 0 additions & 2 deletions packages/server/go.sum → go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y=
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions lerna.json

This file was deleted.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"workspaces": {
"packages": [
"packages/*"
"client/*"
],
"nohoist": [
"**/tailwindcss",
Expand All @@ -17,32 +17,33 @@
},
"scripts": {
"dev": "cross-env POLO_CWD=$INIT_CWD run-p dev:server serve",
"dev:server": "yarn workspace @polo/server dev",
"dev:server": "nodemon --watch . --ext 'go' --signal SIGTERM --exec 'yarn start:server'",
"start:server": "cross-env GO_ENV=development go run cmd/server/main.go",
"build:docker": "docker build -t polo:local -f ./docker/Dockerfile .",
"build:client": "cross-env NODE_ENV=development webpack --config webpack.config.js",
"build:client:prod": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"build:prod": "run-s clean build:client:prod build:server:prod",
"build:server:prod": "run-s build:server:prod:restore build:server:prod:statik build:server:prod:application",
"build:server:prod:restore": "yarn workspace @polo/server go:restore",
"build:server:prod:statik": "statik -p=services -dest=./packages/server/pkg -src=./public",
"build:server:prod:application": "yarn workspace @polo/server build:server:prod:application",
"clean": "run-p clean:root clean:server",
"clean:root": "rimraf dist public release",
"clean:server": "yarn workspace @polo/server clean",
"build:server:prod": "go build -o dist/polo cmd/server/main.go",
"clean": "run-p clean:root",
"clean:root": "rimraf dist pkg/services/static release",
"pro:link": "zx scripts/link-pro.mjs",
"pro:unlink": "zx scripts/unlink-pro.mjs",
"serve": "cross-env TAILWIND_MODE=watch node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js serve",
"build:release": "run-s clean build:client:prod build:server:prod:restore build:server:prod:statik build:release:windows build:release:macos build:release:linux",
"build:release:windows": "yarn workspace @polo/server build:release:windows",
"build:release:macos": "yarn workspace @polo/server build:release:macos",
"build:release:linux": "yarn workspace @polo/server build:release:linux",
"test": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test",
"test:file": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:file",
"test:watch": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:watch",
"test:trace": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:trace",
"test:trace:watch": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:trace:watch",
"test:prod": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:prod",
"test:prod:watch": "cross-env POLO_CWD=$INIT_CWD yarn workspace @polo/server test:prod:watch",
"build:release": "run-s clean build:client:prod build:release:windows build:release:macos build:release:linux",
"build:release:windows": "cross-env GOOS=windows GOARCH=amd64 go build -o release/polo-windows-amd64.exe cmd/server/main.go",
"build:release:macos": "run-s build:release:macos:amd64 build:release:macos:arm64",
"build:release:macos:amd64": "cross-env GOOS=darwin GOARCH=amd64 go build -ldflags \"-X github.com/wufe/polo/pkg/storage.configurationFolder=/usr/local/etc/polo\" -o release/polo-darwin-amd64 cmd/server/main.go",
"build:release:macos:arm64": "cross-env GOOS=darwin GOARCH=arm64 go build -ldflags \"-X github.com/wufe/polo/pkg/storage.configurationFolder=/usr/local/etc/polo\" -o release/polo-darwin-arm64 cmd/server/main.go",
"build:release:linux": "run-s build:release:linux:amd64 build:release:linux:arm64",
"build:release:linux:amd64": "cross-env GOOS=linux GOARCH=amd64 go build -ldflags \"-X github.com/wufe/polo/pkg/storage.configurationFolder=/etc/polo\" -o release/polo-linux-amd64 cmd/server/main.go",
"build:release:linux:arm64": "cross-env GOOS=linux GOARCH=arm64 go build -ldflags \"-X github.com/wufe/polo/pkg/storage.configurationFolder=/etc/polo\" -o release/polo-linux-arm64 cmd/server/main.go",
"test": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development go test -v ./cmd/tests/...",
"test:file": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development go test -v",
"test:watch": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development gow test -v ./cmd/tests/...",
"test:trace": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development POLO_DIAGNOSTICS=true go test -v ./cmd/tests/...",
"test:trace:watch": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development POLO_DIAGNOSTICS=true gow test -v ./cmd/tests/...",
"test:prod": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development go test ./cmd/tests/...",
"test:prod:watch": "cross-env POLO_CWD=$INIT_CWD GO_ENV=development gow test ./cmd/tests/...",
"prepare": "zx ./scripts/prepare.mjs"
},
"devDependencies": {
Expand All @@ -52,7 +53,6 @@
"cross-env": "^7.0.3",
"cz-conventional-changelog": "3.3.0",
"husky": "^7.0.0",
"lerna": "^4.0.0",
"nodemon": "^2.0.15",
"npm-run-all": "^4.1.5",
"webpack": "^5.70.0",
Expand Down
27 changes: 0 additions & 27 deletions packages/server/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/server/third_party/polo-pro
Submodule polo-pro deleted from dc8c72
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ func (h *Handler) serveStatic(st *services.StaticService) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
if !h.isDev {

fileServer := http.FileServer(st.FileSystem)
//fileServer := http.FileServer(st.FileSystem)
fileServer := http.FileServer(http.FS(st.FileSystem))

w.Header().Set("Cache-Control", "public, max-age=604800, immutable")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package services

import (
"embed"
"fmt"
"github.com/wufe/polo/pkg/logging"
"github.com/wufe/polo/pkg/utils"
"io/fs"
"io/ioutil"
"net/http"
"time"

"github.com/rakyll/statik/fs"
"github.com/wufe/polo/pkg/logging"
"github.com/wufe/polo/pkg/utils"
)

//go:embed static/*
var static embed.FS

type StaticService struct {
utils.RWLocker
isDev bool
devServer string
FileSystem http.FileSystem
FileSystem fs.FS
sessionHelperContent string
log logging.Logger
}
Expand Down Expand Up @@ -65,7 +68,7 @@ func (s *StaticService) LoadSessionHelper() {
}
}()
} else {
file, err := s.FileSystem.Open("/session-helper.html")
file, err := s.FileSystem.Open("session-helper.html")
if err != nil {
s.log.Errorf("Error while getting session helper: %s", err.Error())
} else {
Expand All @@ -81,21 +84,21 @@ func (s *StaticService) LoadSessionHelper() {
}

func (s *StaticService) GetManager() []byte {
file, err := s.FileSystem.Open("/manager.html")
file, err := s.FileSystem.Open("manager.html")
content, err := ioutil.ReadAll(file)
if err != nil {
s.log.Errorf("Could not read /manager.html")
s.log.Errorf("Could not read manager.html")
return nil
}
return content
}

func (s *StaticService) initStaticFileSystem() {
if !s.isDev {
fileSystem, err := fs.New()
var err error
s.FileSystem, err = fs.Sub(static, "static")
if err != nil {
panic(err)
}
s.FileSystem = fileSystem
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/link-pro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'zx/globals';
const cwd = process.cwd();

const poloProSrcPath = path.resolve(cwd, '../polo-pro');
const poloProDestPath = path.resolve(cwd, 'packages/server/third_party/polo-pro');
const poloProDestPath = path.resolve(cwd, 'third_party/polo-pro');
const poloSettingsPath = path.resolve(cwd, '.vscode/settings.json');

if (!fs.existsSync(poloProSrcPath))
Expand Down
2 changes: 1 addition & 1 deletion scripts/unlink-pro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'zx/globals';

const cwd = process.cwd();

const poloProDestPath = path.resolve(cwd, 'packages/server/third_party/polo-pro');
const poloProDestPath = path.resolve(cwd, 'third_party/polo-pro');
const poloSettingsPath = path.resolve(cwd, '.vscode/settings.json');

// Removing link to source folder
Expand Down
7 changes: 4 additions & 3 deletions testserver.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
global:
host: 0.0.0.0
port: 7777
debug: true
applications:
- name: Test Server
remote: "https://github.com/wufe/polo-testserver"
remote: /Users/simonebembi/Projects/polo-testserver
disable_terminal_prompt: false
is_default: true
commands:
Expand All @@ -23,8 +24,8 @@ applications:
startup:
retries: 5
branches:
- test: ^dev$
watch: false
- test: ^main$
watch: true
main: true
- test: feature/my-watched-feature
watch: false
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const manager = require('./packages/manager/webpack.config');
const helper = require('./packages/helper/webpack.config');
const manager = require('./client/manager/webpack.config');
const helper = require('./client/helper/webpack.config');

module.exports = [
manager,
Expand Down

0 comments on commit 499b0d5

Please sign in to comment.