Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
No results found
Select Git revision
  • master
1 result
Show changes

Commits on Source 2

16 files
+ 240
33
Compare changes
  • Side-by-side
  • Inline

Files

+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ include $(MAKEFILE_IMPORT_PATH)directories-standard.mk
#include $(MAKEFILE_IMPORT_PATH)jsdoc.mk
include $(MAKEFILE_IMPORT_PATH)output.mk
include $(MAKEFILE_IMPORT_PATH)placeholder.mk
#include $(MAKEFILE_IMPORT_PATH)s3.mk
include $(MAKEFILE_IMPORT_PATH)s3.mk
#include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk
#include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk
include $(MAKEFILE_IMPORT_PATH)go.mk

README.md

0 → 100644
+89 −0
Original line number Diff line number Diff line
# A small, self-contained, cross-platform web server for development

This tool helps to serve files.

## Install

Conan is a binary file that must be stored in a directory.
The files can be found [here](http://download.schukai.com/tools/conan/).


```bash
wget -O ~/.local/bin/conan http://download.schukai.com/tools/conan/conan-linux-amd64
## For Linux, the execution bit must still be set.
chmod u+x ~/.local/bin/conan
```

## Commands

### General Parameters

#### Configuration

```yaml
Server:
  
  # The hostname or IP address of the server (CONAN_SERVER_HOST)
  # Domain, IP or hostname of the server
  # Host: localhost:8080
  
  # The port of the server (CONAN_SERVER_ADDRESS)
  # Address: localhost
  
  # The port of the server (CONAN_SERVER_PORT)
  # Port: 8080
  
  # 
  Path:
    # The path to the server (CONAN_SERVER_WEB_PATH)  
    Web: web
    
  Watch:
    - Path: src
      Command: /bin/bash -c "npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}"
      Exclude:
        - ~$
        - ^\.
    - Path: web
      Exclude:
        - ~$
        - ^\.
    
  Flags:
    FollowSymlinks: true
    

```

### Server

Start server and deliver files.

```bash
conan server serve
```

Start with configuration file.

```bash
conan server start --config config.yaml
```

### Help

There is help on the command line for each individual command.

```bash
conan --help
```

## Change Log

- Version 1.0
    - Initial release


## License # Credits

- Icons Font Face - https://fontawesome.com/
- Bootstrap 5 - http://getbootstrap.com/
Original line number Diff line number Diff line
package command

import (
	"fmt"
	"gitlab.schukai.com/oss/utilities/conan/configuration"
	"gitlab.schukai.com/oss/utilities/conan/logging"
	"gitlab.schukai.com/oss/utilities/conan/server"
	"os"
	"path"
)

type ServerServeCommand struct {
@@ -11,26 +14,37 @@ type ServerServeCommand struct {
	Address   string   `long:"address" short:"a" description:"Address to serve on"`
	WebPath   string   `long:"web-path" short:"e" description:"Path to web files"`
	WatchPath string   `long:"watch-path" short:"w" description:"Path to watch for changes"`
	Exclude   string `long:"exclude" short:"x" description:"Exclude pattern"`
	Exclude   []string `long:"exclude" short:"x" description:"Exclude pattern"`
}

func (r *ServerServeCommand) execute() {

	logging.InitLogger()

	configuration.SetServerPort(r.Port)
	configuration.SetServerAddress(r.Address)
	configuration.SetServerWebPath(r.WebPath)

	fmt.Printf("Serving on %s:%s\n", r.WatchPath, r.Exclude)

	var w string
	if r.WatchPath != "" {
		w = r.WatchPath
		if !path.IsAbs(w) {
			wd, err := os.Getwd()
			if err != nil {
				logging.LogError("ServerServeCommand error %s", err.Error())
				return
			}
			w = path.Join(wd, w)
		}

		configuration.AddWatch(configuration.Watch{
			Path: r.WatchPath,
			Exclude: []string{
				r.Exclude,
			},
			Path:    w,
			Exclude: r.Exclude,
		})
	}

	logging.InitLogger()

	server.Start()

}
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ func injectHandler(next http.Handler) http.Handler {

			p, err := os.ReadFile(path)
			if err != nil {
				logging.LogError("injectHandler error %s", err.Error())
				logging.LogError("InjectHandler error %s", err.Error())
				return
			}

@@ -54,6 +54,7 @@ func init() {
    <script type="module">

        try {
            let died = false;
            let counter = 0;
            let socket
            let url = ""
@@ -79,6 +80,11 @@ func init() {
                socket = new WebSocket(url)

                socket.onopen = function (e) {
                    
                    if (died===true ){
                        window.location.reload();
                    }
                    
                    console.log("[conan] Connection established");
                    counter = 0
                };
@@ -97,12 +103,13 @@ func init() {
                        console.log("[conan] Connection closed cleanly, code=" + event?.code + " reason=" + event?.reason + "");
                    } else {
                        console.error("[conan] Connection died");
                        died = true
                        setTimeout(connectWebsocket, 3000*counter)
                    }
                };

                socket.onerror = function (error) {
                    console.error("[conan] " + error?.message);
                    console.error("[conan] error", error);
                };

            }
Original line number Diff line number Diff line
@@ -116,8 +116,6 @@ func executeWatchAction(watchPath string) {
		r, err := result.String()
		logging.LogDebug("%s", r)

		websocket.SendReloadMessage()

		if err != nil {
			logging.LogError("watching: execute watch action error: %v", err.Error())
			continue
@@ -201,9 +199,13 @@ func InitWatch() {
		})
	}

	c := path.Join(configuration.GetConfigurationPath(), constants.ConfigFileName)

	if _, err := os.Stat(c); err == nil {
		watchList = append(watchList, configuration.Watch{
			Path: path.Join(configuration.GetConfigurationPath(), constants.ConfigFileName),
		})
	}

	for _, w := range watchList {
		scanPath(w.Path)
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import (
	"gitlab.schukai.com/oss/utilities/conan/logging"
	"log"
	"net/http"
	"sync"
	"time"
)

var (
@@ -14,7 +16,7 @@ var (
)

func SendMessageToAll(message []byte) {

	logging.LogInfo("sending message to all")
	for _, conn := range connections {
		conn.WriteMessage(websocket.TextMessage, message)
	}
@@ -30,8 +32,35 @@ func closeConnection(session string) error {
	return nil
}

func SendReloadMessage() {
var timerMutex *sync.Mutex
var waitForReload bool

func init() {
	timerMutex = &sync.Mutex{}
	waitForReload = false
}

func doReload() {
	timerMutex.Lock()
	defer timerMutex.Unlock()

	SendMessageToAll([]byte("reload"))
	waitForReload = false
}

func SendReloadMessage() {

	timerMutex.Lock()
	defer timerMutex.Unlock()

	if waitForReload {
		return
	}

	time.AfterFunc(time.Second, doReload)
	logging.LogInfo("timer ...")
	waitForReload = true

}

func GetWebsocketHandler() http.Handler {
@@ -49,7 +78,6 @@ func GetWebsocketHandler() http.Handler {

		conn.SetCloseHandler(func(code int, text string) error {
			return closeConnection(session)

		})

		connections[session] = conn
+50 −0
Original line number Diff line number Diff line
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="index.css" rel="stylesheet">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <title>Download Portal schukai GmbH</title>
</head>
<body>


<div class="d-flex flex-column align-items-center justify-content-center"
     style="height:100vh;">

    <div class="text-center">
        <a href="https://www.schukai.com" class="text-decoration-none text-white text-decoration"><img
                src="https://cdn.alvine.io/image/logo/schukai-rot.svg" width="300px"></a>
        <br>

        <div class="card mt-5">
            <div class="card-header">
                Conan
            </div>
            <ul class="list-group">
                <li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-386">conan-linux-386</a>
                </li>
                <li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-amd64">conan-linux-amd64</a>
                </li>
                <li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-arm">conan-linux-arm</a>
                </li>
                <li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-arm64">conan-linux-arm64</a>
                </li>
                <li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-windows">conan-windows</a>
                </li>
            </ul>
        </div>

        <p class="mt-5">
            <a href="https://about.schukai.com/de/impressum/" class="text-decoration-none text-decoration"
               style="color:#c10000">Imprint</a></p>
    </div>
</div>
<script src="index.js"></script>
</body>
</html>
+7 −0

File added.

Preview size limit exceeded, changes collapsed.

Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ Server:
    
  Watch:
    - Path: src
      Command: /bin/bash -c "PATH=$PATH:/home/volker.schukai/.nvm/versions/node/v18.8.0/bin; npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}"
      Command: /bin/bash -c "npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}"
      Exclude:
        - ~$
        - ^\.
Original line number Diff line number Diff line
document.addEventListener("DOMContentLoaded", () => {
    document.querySelector("#app").innerHTML = "Hello!!! World?!";
    let text="how are you doing?"
    document.querySelector("#app").innerHTML = text;
})
// Language: javascript   
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
    <script src="scripts/bundle.js"></script>
</head>
<body>
    <h1>Hello ...ddd</h1>

    <h1>Hello Developer!?</h1>
    <div id="app"></div>
</body>
Original line number Diff line number Diff line
(() => {
  // src/main.js
  document.addEventListener("DOMContentLoaded", () => {
    document.querySelector("#app").innerHTML = "Hello!!! World?!";
    let text = "how are you doing?";
    document.querySelector("#app").innerHTML = text;
  });
})();
//# sourceMappingURL=bundle.js.map
Original line number Diff line number Diff line
{
  "version": 3,
  "sources": ["../../src/main.js"],
  "sourcesContent": ["document.addEventListener(\"DOMContentLoaded\", () => {\n    document.querySelector(\"#app\").innerHTML = \"Hello!!! World?!\";\n})\n// Language: javascript   "],
  "mappings": ";;AAAA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,aAAS,cAAc,MAAM,EAAE,YAAY;AAAA,EAC/C,CAAC;",
  "sourcesContent": ["document.addEventListener(\"DOMContentLoaded\", () => {\n    let text=\"how are you doing?\"\n    document.querySelector(\"#app\").innerHTML = text;\n})\n// Language: javascript   \n"],
  "mappings": ";;AAAA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,QAAI,OAAK;AACT,aAAS,cAAc,MAAM,EAAE,YAAY;AAAA,EAC/C,CAAC;",
  "names": []
}
Original line number Diff line number Diff line
@@ -18,3 +18,5 @@ deploy: compile
## overview-to-s3
overview-to-s3:
	$(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.html $(UPLOAD_TOOL_URL)
	$(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.css $(UPLOAD_TOOL_URL)
	$(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.js $(UPLOAD_TOOL_URL)
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
{"version":"0.1.19"}
{"version":"0.1.36"}