this repo has no description smallweb.run
smallweb
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

add support for additional denoArgs

pomdtr 8028cf6d 9939a323

+26 -16
+1
app/app.go
··· 23 23 Entrypoint string `json:"entrypoint,omitempty"` 24 24 Root string `json:"root,omitempty"` 25 25 Crons []CronJob `json:"crons,omitempty"` 26 + DenoArgs []string `json:"deno_args,omitempty"` 26 27 } 27 28 28 29 type CronJob struct {
+7
schemas/manifest.schema.json
··· 33 33 } 34 34 } 35 35 } 36 + }, 37 + "denoArgs": { 38 + "description": "An array of additional arguments to pass to the deno run/serve command", 39 + "type": "array", 40 + "items": { 41 + "type": "string" 42 + } 36 43 } 37 44 } 38 45 }
+18 -16
worker/worker.go
··· 106 106 107 107 var upgrader = websocket.Upgrader{} // use default options 108 108 109 - func (me *Worker) Flags(a app.App, deno string, allowRun ...string) []string { 110 - flags := []string{ 109 + func (me *Worker) DenoArgs(a app.App, deno string, allowRun ...string) []string { 110 + args := []string{ 111 111 "--allow-net", 112 112 "--allow-import", 113 113 "--allow-env", ··· 118 118 "--quiet", 119 119 } 120 120 121 + args = append(args, a.Config.DenoArgs...) 122 + 121 123 if a.Admin { 122 - flags = append( 123 - flags, 124 + args = append( 125 + args, 124 126 fmt.Sprintf("--allow-read=%s,%s,%s", me.RootDir, sandboxPath, deno), 125 127 fmt.Sprintf("--allow-write=%s", me.RootDir), 126 128 ) 127 129 if len(allowRun) > 0 { 128 - flags = append(flags, fmt.Sprintf("--allow-run=%s", strings.Join(allowRun, ","))) 130 + args = append(args, fmt.Sprintf("--allow-run=%s", strings.Join(allowRun, ","))) 129 131 } 130 132 131 133 } else { ··· 141 143 target = filepath.Join(filepath.Dir(root), target) 142 144 } 143 145 144 - flags = append( 145 - flags, 146 + args = append( 147 + args, 146 148 fmt.Sprintf("--allow-read=%s,%s,%s,%s", root, target, sandboxPath, deno), 147 149 fmt.Sprintf("--allow-write=%s,%s", filepath.Join(root, "data"), filepath.Join(target, "data")), 148 150 ) 149 151 } else { 150 - flags = append( 151 - flags, 152 + args = append( 153 + args, 152 154 fmt.Sprintf("--allow-read=%s,%s,%s", root, sandboxPath, deno), 153 155 fmt.Sprintf("--allow-write=%s", filepath.Join(root, "data")), 154 156 ) 155 157 } 156 158 157 159 if len(allowRun) > 0 { 158 - flags = append(flags, fmt.Sprintf("--allow-run=%s", strings.Join(allowRun, ","))) 160 + args = append(args, fmt.Sprintf("--allow-run=%s", strings.Join(allowRun, ","))) 159 161 } 160 162 161 163 } 162 164 163 165 if configPath := filepath.Join(a.Dir, "deno.json"); utils.FileExists(configPath) { 164 - flags = append(flags, "--config", configPath) 166 + args = append(args, "--config", configPath) 165 167 } else if configPath := filepath.Join(a.Dir, "deno.jsonc"); utils.FileExists(configPath) { 166 - flags = append(flags, "--config", configPath) 168 + args = append(args, "--config", configPath) 167 169 } 168 170 169 - return flags 171 + return args 170 172 } 171 173 172 174 func (me *Worker) Start() error { ··· 182 184 } 183 185 184 186 args := []string{"run"} 185 - args = append(args, me.Flags(me.App, deno)...) 187 + args = append(args, me.DenoArgs(me.App, deno)...) 186 188 input := strings.Builder{} 187 189 encoder := json.NewEncoder(&input) 188 190 encoder.SetEscapeHTML(false) ··· 495 497 496 498 denoArgs := []string{"run"} 497 499 if runtime.GOOS == "darwin" { 498 - denoArgs = append(denoArgs, me.Flags(me.App, deno, "open")...) 500 + denoArgs = append(denoArgs, me.DenoArgs(me.App, deno, "open")...) 499 501 } else { 500 - denoArgs = append(denoArgs, me.Flags(me.App, deno, "xdg-open")...) 502 + denoArgs = append(denoArgs, me.DenoArgs(me.App, deno, "xdg-open")...) 501 503 } 502 504 503 505 input := strings.Builder{}