@travetto/cli 4.0.0-rc.7 → 4.0.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.
Files changed (2) hide show
  1. package/README.md +14 -2
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -459,10 +459,12 @@ If the goal is to run a more complex application, which may include depending on
459
459
 
460
460
  **Code: Simple Run Target**
461
461
  ```typescript
462
+ import { Env } from '@travetto/base';
462
463
  import { DependencyRegistry } from '@travetto/di';
463
464
  import { CliCommand, CliCommandShape, CliUtil } from '@travetto/cli';
464
465
 
465
466
  import { ServerHandle } from '../src/types';
467
+ import { RestNetUtil } from '../src/util/net';
466
468
 
467
469
  /**
468
470
  * Run a rest server as an application
@@ -479,6 +481,9 @@ export class RunRestCommand implements CliCommandShape {
479
481
  /** Port to run on */
480
482
  port?: number;
481
483
 
484
+ /** Kill conflicting port owner */
485
+ killConflict?: boolean;
486
+
482
487
  preMain(): void {
483
488
  if (this.port) {
484
489
  process.env.REST_PORT = `${this.port}`;
@@ -489,9 +494,16 @@ export class RunRestCommand implements CliCommandShape {
489
494
  if (await CliUtil.debugIfIpc(this) || await CliUtil.runWithRestart(this)) {
490
495
  return;
491
496
  }
492
-
493
497
  const { RestApplication } = await import('../src/application/rest.js');
494
- return DependencyRegistry.runInstance(RestApplication);
498
+ try {
499
+ return await DependencyRegistry.runInstance(RestApplication);
500
+ } catch (err) {
501
+ if (RestNetUtil.isInuseError(err) && !Env.production && this.killConflict) {
502
+ await RestNetUtil.freePort(err.port);
503
+ return await DependencyRegistry.runInstance(RestApplication);
504
+ }
505
+ throw err;
506
+ }
495
507
  }
496
508
  }
497
509
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "4.0.0-rc.7",
3
+ "version": "4.0.0",
4
4
  "description": "CLI infrastructure for Travetto framework",
5
5
  "keywords": [
6
6
  "cli",
@@ -29,8 +29,8 @@
29
29
  "directory": "module/cli"
30
30
  },
31
31
  "dependencies": {
32
- "@travetto/schema": "^4.0.0-rc.7",
33
- "@travetto/terminal": "^4.0.0-rc.7"
32
+ "@travetto/schema": "^4.0.0",
33
+ "@travetto/terminal": "^4.0.0"
34
34
  },
35
35
  "travetto": {
36
36
  "displayName": "Command Line Interface",