@rip-lang/server 0.7.9 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.rip +73 -4
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -188,6 +188,11 @@ parseFlags = (argv) ->
|
|
|
188
188
|
appPathInput = null
|
|
189
189
|
appAliases = []
|
|
190
190
|
|
|
191
|
+
# Check if token looks like a flag
|
|
192
|
+
isFlag = (tok) ->
|
|
193
|
+
tok.startsWith('-') or tok.startsWith('--') or /^\d+$/.test(tok) or tok in ['http', 'https']
|
|
194
|
+
|
|
195
|
+
# Try to resolve a token as an app path
|
|
191
196
|
tryResolveApp = (tok) ->
|
|
192
197
|
looksLikePath = tok.includes('/') or tok.startsWith('.') or isAbsolute(tok) or tok.endsWith('.rip') or tok.endsWith('.ts')
|
|
193
198
|
return undefined unless looksLikePath
|
|
@@ -200,23 +205,46 @@ parseFlags = (argv) ->
|
|
|
200
205
|
for i in [2...argv.length]
|
|
201
206
|
tok = argv[i]
|
|
202
207
|
unless appPathInput
|
|
203
|
-
|
|
208
|
+
# Handle path@alias syntax
|
|
209
|
+
if tok.includes('@') and not tok.startsWith('-')
|
|
204
210
|
[pathPart, aliasesPart] = tok.split('@')
|
|
205
211
|
maybe = tryResolveApp(pathPart)
|
|
206
212
|
if maybe
|
|
207
213
|
appPathInput = maybe
|
|
208
214
|
appAliases = aliasesPart.split(',').map((a) -> a.trim()).filter((a) -> a)
|
|
209
215
|
continue
|
|
216
|
+
# pathPart might be an alias, not a path - check if entry exists in cwd
|
|
217
|
+
else if not pathPart.includes('/') and not pathPart.startsWith('.')
|
|
218
|
+
appAliases = [pathPart].concat(aliasesPart.split(',').map((a) -> a.trim()).filter((a) -> a))
|
|
219
|
+
continue
|
|
220
|
+
|
|
221
|
+
# Try as path first
|
|
210
222
|
maybe = tryResolveApp(tok)
|
|
211
223
|
if maybe
|
|
212
224
|
appPathInput = maybe
|
|
213
225
|
continue
|
|
226
|
+
|
|
227
|
+
# If not a flag and not a path, treat as app name/alias
|
|
228
|
+
unless isFlag(tok)
|
|
229
|
+
appAliases.push(tok)
|
|
230
|
+
continue
|
|
231
|
+
|
|
214
232
|
rawFlags.add(tok)
|
|
215
233
|
|
|
234
|
+
# Default to current directory if no path specified
|
|
216
235
|
unless appPathInput
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
236
|
+
cwd = process.cwd()
|
|
237
|
+
indexRip = join(cwd, 'index.rip')
|
|
238
|
+
indexTs = join(cwd, 'index.ts')
|
|
239
|
+
if existsSync(indexRip)
|
|
240
|
+
appPathInput = indexRip
|
|
241
|
+
else if existsSync(indexTs)
|
|
242
|
+
appPathInput = indexTs
|
|
243
|
+
else
|
|
244
|
+
console.error 'No app entry found. Looked for index.rip or index.ts in current directory.'
|
|
245
|
+
console.error 'Usage: rip-server [flags] [app-path] [app-name]'
|
|
246
|
+
console.error ' rip-server [flags] [app-path]@<alias1>,<alias2>,...'
|
|
247
|
+
process.exit(2)
|
|
220
248
|
|
|
221
249
|
getKV = (prefix) ->
|
|
222
250
|
for f from rawFlags
|
|
@@ -1047,6 +1075,47 @@ main = ->
|
|
|
1047
1075
|
console.log 'rip-server (version unknown)'
|
|
1048
1076
|
return
|
|
1049
1077
|
|
|
1078
|
+
# Help flag
|
|
1079
|
+
if '--help' in process.argv or '-h' in process.argv
|
|
1080
|
+
console.log """
|
|
1081
|
+
rip-server - Pure Rip application server
|
|
1082
|
+
|
|
1083
|
+
Usage:
|
|
1084
|
+
rip-server [options] [app-path] [app-name]
|
|
1085
|
+
rip-server [options] [app-path]@<alias1>,<alias2>,...
|
|
1086
|
+
|
|
1087
|
+
Options:
|
|
1088
|
+
-h, --help Show this help
|
|
1089
|
+
-v, --version Show version
|
|
1090
|
+
-w, --watch Watch *.rip files for changes (hot reload)
|
|
1091
|
+
-w=<glob> Watch custom glob pattern (e.g., -w=*.ts)
|
|
1092
|
+
--static Disable hot reload
|
|
1093
|
+
--env=<mode> Set environment (dev, production)
|
|
1094
|
+
--debug Enable debug logging
|
|
1095
|
+
|
|
1096
|
+
Network:
|
|
1097
|
+
http HTTP only (no TLS)
|
|
1098
|
+
https HTTPS with auto TLS (default)
|
|
1099
|
+
<port> Listen on specific port
|
|
1100
|
+
--cert=<path> TLS certificate file
|
|
1101
|
+
--key=<path> TLS key file
|
|
1102
|
+
--auto-tls Generate TLS cert via mkcert
|
|
1103
|
+
--hsts Enable HSTS header
|
|
1104
|
+
--no-redirect-http Don't redirect HTTP to HTTPS
|
|
1105
|
+
|
|
1106
|
+
Workers:
|
|
1107
|
+
w:<n> Number of workers (default: cores/2)
|
|
1108
|
+
w:auto One worker per core
|
|
1109
|
+
r:<n>,<s>s Restart policy: max requests, max seconds
|
|
1110
|
+
|
|
1111
|
+
Examples:
|
|
1112
|
+
rip-server Start with ./index.rip
|
|
1113
|
+
rip-server -w Start with file watching
|
|
1114
|
+
rip-server myapp Start with app name "myapp"
|
|
1115
|
+
rip-server api -w 8080 Watch mode on port 8080
|
|
1116
|
+
"""
|
|
1117
|
+
return
|
|
1118
|
+
|
|
1050
1119
|
# Helper functions for subcommands
|
|
1051
1120
|
getKV = (prefix) ->
|
|
1052
1121
|
for tok in process.argv
|