5.124.0 • Published 1 day ago

@rushstack/rush-serve-plugin v5.124.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 day ago

@rushstack/rush-serve-plugin

A Rush plugin that hooks into action execution and runs an express server to serve project outputs. Meant for use with watch-mode commands.

Supports HTTP/2, compression, CORS, and the new Access-Control-Allow-Private-Network header.

# The user invokes this command
$ rush start

What happens:

  • Rush scans for riggable rush-serve.json config files in all projects
  • Rush uses the configuration in the aforementioned files to configure an Express server to serve project outputs as static (but not cached) content
  • When a change happens to a source file, Rush's normal watch-mode machinery will rebuild all affected project phases, resulting in new files on disk
  • The next time one of these files is requested, Rush will serve the new version. Optionally, may support signals for automatic refresh.

Live Build Status via Web Socket

This plugin also provides a web socket server that notifies clients of the build status in real time. To use the server, configure the buildStatusWebSocketPath option in common/config/rush-plugins/rush-serve-plugin.json. Specifying / will make the web socket server available at wss://localhost:<port>/.

The recommended way to connect to the web socket is to serve a static HTML page from the serve plugin using the globalRouting configuration.

To use the socket:

import type {
  IWebSocketEventMessage,
  IOperationInfo,
  IRushSessionInfo,
  ReadableOperationStatus
} from '@rushstack/rush-serve-plugin/api';

const socket: WebSocket = new WebSocket(`wss://${self.location.host}${buildStatusWebSocketPath}`);

const operationsByName: Map<string, IOperationInfo> = new Map();
let buildStatus: ReadableOperationStatus = 'Ready';

function updateOperations(operations): void {
  for (const operation of operations) {
    operationsByName.set(operation.name, operation);
  }

  for (const [operationName, operation] of operationsByName) {
    // Do something with the operation
  }
}

function updateSessionInfo(sessionInfo: IRushSessionInfo): void {
  const { actionName, repositoryIdentifier } = sessionInfo;
}

function updateBuildStatus(newStatus: ReadableOperationStatus): void {
  buildStatus = newStatus;
  // Render
}

socket.addEventListener('message', (ev) => {
  const message: IWebSocketEventMessage = JSON.parse(ev.data);

  switch (message.event) {
    case 'before-execute': {
      const { operations } = message;
      updateOperations(operations);
      updateBuildStatus('Executing');
      break;
    }

    case 'status-change': {
      const { operations } = message;
      updateOperations(operations);
      break;
    }

    case 'after-execute': {
      const { status } = message;
      updateBuildStatus(status);
      break;
    }

    case 'sync': {
      operationsByName.clear();
      const { operations, status, sessionInfo } = message;
      updateOperations(operations);
      updateSessionInfo(sessionInfo);
      updateBuildStatus(status);
      break;
    }
  }
});
5.124.0

1 day ago

5.123.1

2 days ago

5.123.0

2 days ago

5.122.1

9 days ago

5.122.0

15 days ago

5.121.0

17 days ago

5.120.6

21 days ago

5.120.5

22 days ago

5.120.4

23 days ago

5.120.3

24 days ago

5.120.2

25 days ago

5.120.1

26 days ago

5.120.0

29 days ago

5.119.0

1 month ago

5.118.7

1 month ago

5.118.6

1 month ago

5.118.5

1 month ago

5.118.4

2 months ago

5.118.3

2 months ago

5.118.2

2 months ago

5.118.1

2 months ago

5.117.10

2 months ago

5.118.0

2 months ago

5.117.9

2 months ago

5.117.8

2 months ago

5.117.7

2 months ago

5.117.6

2 months ago

5.117.5

2 months ago

5.117.4

2 months ago

5.117.3

2 months ago

5.117.2

2 months ago

5.117.1

2 months ago

5.117.0

2 months ago

5.116.0

2 months ago

5.115.0

3 months ago

5.114.2

3 months ago

5.114.1

3 months ago

5.114.3

3 months ago

5.109.1-pr3481.22

3 months ago

5.114.0

3 months ago

5.112.2-pr4485.3

3 months ago

5.113.3

3 months ago

5.113.2

3 months ago

5.113.4

3 months ago

5.113.1

3 months ago

5.113.0

3 months ago

5.112.2-pr4485.2

3 months ago

5.112.2-pr4485.1

4 months ago

5.112.2-pr4485.0

4 months ago

5.112.2-pr4476.0

4 months ago

5.112.2

5 months ago

5.106.0

8 months ago

5.101.1

9 months ago

5.105.0

8 months ago

5.101.0

9 months ago

5.109.2

7 months ago

5.109.1

7 months ago

5.107.1-pr3481.20

8 months ago

5.109.1-pr3481.21

7 months ago

5.109.0

7 months ago

5.112.1

5 months ago

5.112.0

5 months ago

5.100.2

10 months ago

5.104.1

8 months ago

5.104.0

8 months ago

5.108.0

7 months ago

5.111.0

6 months ago

5.103.0

8 months ago

5.107.4

8 months ago

5.107.3

8 months ago

5.107.0

8 months ago

5.107.2

8 months ago

5.107.1

8 months ago

5.102.0-pr3949.7

8 months ago

5.102.0-pr3949.6

9 months ago

5.102.0-pr3949.5

9 months ago

5.102.0-pr3949.4

9 months ago

5.110.0

6 months ago

5.110.2

6 months ago

5.110.1

6 months ago

5.102.0

9 months ago

5.99.0

11 months ago

5.100.0-pr4132

11 months ago

5.100.0-pr4132.1

11 months ago

5.98.0

12 months ago

5.100.1

11 months ago

5.100.0

11 months ago

5.97.1

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.4.3

1 year ago

0.3.14

1 year ago

0.3.13

1 year ago

0.3.12

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.2

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.9

1 year ago

0.3.11

1 year ago

0.3.10

1 year ago

0.3.0

2 years ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

1 year ago

0.3.3

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.40

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.38

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago