@rip-lang/server 0.7.9 → 0.7.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.rip +32 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/server",
3
- "version": "0.7.9",
3
+ "version": "0.7.10",
4
4
  "description": "Pure Rip application server — multi-worker, hot reload, HTTPS, mDNS",
5
5
  "type": "module",
6
6
  "main": "server.rip",
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
- if tok.includes('@')
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
- console.error 'Usage: bun server.rip [flags] <app-path>'
218
- console.error ' bun server.rip [flags] <app-path>@<alias1>,<alias2>,...'
219
- process.exit(2)
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