arcane-os 0.11.3 → 0.13.0

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/src/cli/main.mjs CHANGED
@@ -18,6 +18,7 @@ const VALUE_OPTIONS=new Set([
18
18
  'arcane-root',
19
19
  'host',
20
20
  'port',
21
+ 'http-port',
21
22
  'cert',
22
23
  'key',
23
24
  'target',
@@ -64,7 +65,7 @@ Usage:
64
65
  ${CLI_NAME} upgrade [--workspace <directory>] [--app <id>]
65
66
  ${CLI_NAME} doctor [--workspace <directory>] [--arcane-root <directory>]
66
67
  ${CLI_NAME} import-map [--workspace <directory>] [--app <id>]
67
- ${CLI_NAME} dev [--app <id>] [--public] [--https] [--cert <pem>] [--key <pem>] [--host <address>] [--port 8000] [--sdk-runtime-source <sdk-root>]
68
+ ${CLI_NAME} dev [--app <id>] [--public] [--https] [--cert <pem>] [--key <pem>] [--host <address>] [--port 8000] [--http-port 0] [--sdk-runtime-source <sdk-root>]
68
69
  ${CLI_NAME} test [--app <id>] [--scope app]
69
70
  ${CLI_NAME} test --scope shared --test-file <repo-relative.test.mjs>
70
71
  ${CLI_NAME} check [--app <id>] [--scope app] [--skip-tests]
@@ -76,7 +77,7 @@ Usage:
76
77
  ${CLI_NAME} native-doctor --target <native-target> --arcane-root <directory>
77
78
  ${CLI_NAME} native-prepare --target <native-target> --arcane-root <directory>
78
79
  ${CLI_NAME} build --target <target> [--arcane-root <directory>] [--output-root <directory>] [--format <format>] [--signing <mode>]
79
- ${CLI_NAME} run [--target <target>] [--app <id>] [--arcane-root <directory>] [--output-root <directory>] [--format <format>] [--signing <mode>]
80
+ ${CLI_NAME} run [--target <target>] [--app <id>] [--cert <pem>] [--key <pem>] [--port 8000] [--http-port 0] [--arcane-root <directory>] [--output-root <directory>] [--format <format>] [--signing <mode>]
80
81
  ${CLI_NAME} update-check
81
82
  ${CLI_NAME} targets
82
83
  ${CLI_NAME} repo status|pull|push
@@ -88,9 +89,10 @@ Usage:
88
89
 
89
90
  Development:
90
91
  --public Serve HTTPS on all IPv4 interfaces (0.0.0.0) and print network URLs.
91
- --https Use HTTPS with .arcane/dev/server-cert.pem and server-key.pem.
92
+ --https Accepted for compatibility; Arcane browser serving always uses HTTPS.
92
93
  --cert <pem> --key <pem> Use an existing certificate pair; paths are relative to the workspace.
93
94
  --host <address> Override the bind address; takes precedence over --public.
95
+ --http-port <port> Browser dev/run HTTP redirect port; 0 selects an available port (default).
94
96
  --sdk-runtime-source <sdk-root> Dev-only live SDK checkout; omitted preserves the workspace runtime mode.
95
97
 
96
98
  Global:
@@ -456,9 +458,25 @@ function operationOptions(command,parsed,cwd){
456
458
  if(flags.has('public')&&command!=='dev'){
457
459
  usage('--public is supported only by dev.');
458
460
  }
459
- if((flags.has('https')||values.cert!==undefined||values.key!==undefined)&&command!=='dev'){
460
- usage('--https, --cert, and --key are supported only by dev.');
461
+ const browserServing = command === 'dev'
462
+ || (command === 'run' && (values.target ?? 'browser') === 'browser');
463
+ if ((flags.has('https') || values.cert !== undefined || values.key !== undefined) && !browserServing) {
464
+ usage('--https, --cert, and --key are supported only by dev and run --target browser.');
461
465
  }
466
+ if (values['http-port'] !== undefined && !browserServing) {
467
+ usage('--http-port is supported only by dev and run --target browser.');
468
+ }
469
+ if (browserServing && (values.cert === undefined) !== (values.key === undefined)) {
470
+ usage('Arcane HTTPS serving requires --cert and --key together.');
471
+ }
472
+ const browserServerOptions = browserServing ? {
473
+ https: true,
474
+ httpPort: readPort(values['http-port'], 0),
475
+ ...(values.cert === undefined ? {} : {
476
+ certPath: path.resolve(workspaceRoot, values.cert),
477
+ keyPath: path.resolve(workspaceRoot, values.key)
478
+ })
479
+ } : {};
462
480
  if(flags.has('overwrite')&&command!=='bundle'){
463
481
  usage('--overwrite is supported only by bundle.');
464
482
  }
@@ -518,18 +536,11 @@ function operationOptions(command,parsed,cwd){
518
536
  }
519
537
  if(command==='dev'){
520
538
  noExtraPositionals(command,positionals);
521
- if((values.cert===undefined)!==(values.key===undefined)){
522
- usage('HTTPS development requires --cert and --key together.');
523
- }
524
539
  return {
525
540
  ...common,
541
+ ...browserServerOptions,
526
542
  host:values.host??(flags.has('public')?'0.0.0.0':'127.0.0.1'),
527
543
  port:readPort(values.port,8000),
528
- https:flags.has('public')||flags.has('https')||values.cert!==undefined,
529
- ...(values.cert===undefined?{}:{
530
- certPath:path.resolve(workspaceRoot,values.cert),
531
- keyPath:path.resolve(workspaceRoot,values.key)
532
- }),
533
544
  ...(values['sdk-runtime-source']===undefined?{}:{
534
545
  sdkRuntimeSourceRoot:path.resolve(cwd,values['sdk-runtime-source'])
535
546
  })
@@ -609,6 +620,7 @@ function operationOptions(command,parsed,cwd){
609
620
  noExtraPositionals(command,positionals);
610
621
  return {
611
622
  ...common,
623
+ ...browserServerOptions,
612
624
  target:values.target??'browser',
613
625
  arcaneRoot:values['arcane-root']?path.resolve(cwd,values['arcane-root']):undefined,
614
626
  outputRoot:values['output-root']?path.resolve(cwd,values['output-root']):undefined,
@@ -853,6 +865,9 @@ function serverSummary(result){
853
865
  host:result.host,
854
866
  port:result.port,
855
867
  url:result.url,
868
+ ...(result.httpPort===undefined?{}:{httpPort:result.httpPort}),
869
+ ...(result.httpOrigin===undefined?{}:{httpOrigin:result.httpOrigin}),
870
+ ...(result.httpUrl===undefined?{}:{httpUrl:result.httpUrl}),
856
871
  ...(result.protocol===undefined?{}:{protocol:result.protocol}),
857
872
  ...(result.networkUrls===undefined?{}:{networkUrls:result.networkUrls}),
858
873
  ...(result.callerAuthentication
@@ -867,6 +882,7 @@ function serverSummary(result){
867
882
  async function waitForServer(result,signal,reporter){
868
883
  const readyMessage=[
869
884
  `Development server ready at ${result.url}`,
885
+ ...(result.httpUrl ? [`HTTP redirect: ${result.httpUrl}`] : []),
870
886
  ...(result.networkUrls??[]).map(function networkAddress(url){return `Network: ${url}`;})
871
887
  ].join('\n');
872
888
  reporter.emit('server.ready',serverSummary(result),readyMessage);