arcane-os 0.11.2 → 0.12.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/toolchain.mjs CHANGED
@@ -13,7 +13,9 @@ import {loadArcaneIntegratedProvider} from './integrated-provider-loader.mjs';
13
13
  import {startDevServer} from './dev-server.mjs';
14
14
  import {generateImportMap,readApplicationTestImportMapContext} from './import-map.mjs';
15
15
  import {withWorkspaceOperationLock} from './workspace-operation-lock.mjs';
16
+ import {refreshAppPackageProjection} from './app-descriptor.mjs';
16
17
  import {
18
+ discoverApps as discoverPackagerApps,
17
19
  inspectApp as inspectPackagedApp,
18
20
  packageApp,
19
21
  verifyApp
@@ -444,18 +446,65 @@ export async function checkApplication(options={}){
444
446
  };
445
447
  }
446
448
 
447
- export async function developApplication(options={}){
448
- assertApplicationScope(options,'Development serving');
449
- const prepared=await preparedWorkspace({...options,allowMissingManagedImportMap:true});
450
- await withWorkspaceOperationLock({
451
- workspaceRoot:prepared.workspaceRoot,
452
- operation:'dev-refresh',
453
- signal:options.signal,
454
- onEvent:options.onEvent
455
- },workspaceOperationLease=>refreshPreparedImportMap(prepared,{
456
- ...options,
457
- workspaceOperationLease
458
- }));
449
+ export async function developApplication(options = {}) {
450
+ assertApplicationScope(options, 'Development serving');
451
+ throwIfAborted(options.signal);
452
+ const profile = await inspectWorkspaceProfile(options.workspaceRoot);
453
+ const appIds = await discoverPackagerApps(
454
+ {workspaceRoot: profile.workspaceRoot}
455
+ );
456
+ let appId = options.appId;
457
+ if (appId !== undefined && (!is.string(appId) || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(appId))) {
458
+ throw new ArcaneError(ERROR_CODES.usage, `Invalid app id: ${String(appId)}.`);
459
+ }
460
+ if (appId) {
461
+ if (!appIds.includes(appId)) {
462
+ throw new ArcaneError(
463
+ ERROR_CODES.workspaceInvalid,
464
+ `Unknown app "${appId}". Available apps: ${appIds.join(', ') || '[none]'}.`
465
+ );
466
+ }
467
+ } else if (appIds.length === 1) {
468
+ [appId] = appIds;
469
+ } else if (appIds.length === 0) {
470
+ throw new ArcaneError(ERROR_CODES.workspaceInvalid, 'No Arcane applications were found under apps/.');
471
+ } else {
472
+ throw new ArcaneError(
473
+ ERROR_CODES.usage,
474
+ `This workspace contains multiple apps; select one explicitly: ${appIds.join(', ')}.`
475
+ );
476
+ }
477
+ const prepared = await withWorkspaceOperationLock(
478
+ {
479
+ workspaceRoot: profile.workspaceRoot,
480
+ operation: 'dev-refresh',
481
+ signal: options.signal,
482
+ onEvent: options.onEvent
483
+ },
484
+ async function refreshDevelopmentWorkspace(workspaceOperationLease) {
485
+ await refreshAppPackageProjection(
486
+ {
487
+ workspaceRoot: profile.workspaceRoot,
488
+ appId,
489
+ signal: options.signal,
490
+ onEvent: options.onEvent
491
+ }
492
+ );
493
+ const current = await preparedWorkspace(
494
+ {
495
+ ...options,
496
+ workspaceRoot: profile.workspaceRoot,
497
+ appId,
498
+ allowMissingManagedImportMap: true
499
+ }
500
+ );
501
+ await refreshPreparedImportMap(
502
+ current,
503
+ {...options, workspaceOperationLease}
504
+ );
505
+ return current;
506
+ }
507
+ );
459
508
  const server=await startDevServer({
460
509
  workspaceRoot:prepared.workspaceRoot,
461
510
  appId:prepared.appId,
@@ -466,6 +515,7 @@ export async function developApplication(options={}){
466
515
  }),
467
516
  host:options.host,
468
517
  port:options.port,
518
+ httpPort:options.httpPort,
469
519
  https:options.https,
470
520
  tls:options.tls,
471
521
  certPath:options.certPath,