@ms-cloudpack/cli 0.2.13 → 0.4.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/CHANGELOG.json +84 -1
- package/CHANGELOG.md +35 -2
- package/lib/commands/start/createSession.js +7 -3
- package/lib/commands/start/createSession.js.map +1 -1
- package/lib/commands/start/start.js +14 -5
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/start/startApiServer.d.ts +53 -0
- package/lib/commands/start/startApiServer.js +147 -0
- package/lib/commands/start/startApiServer.js.map +1 -0
- package/lib/commands/start/startAppServer.d.ts +7 -1
- package/lib/commands/start/startAppServer.js +51 -17
- package/lib/commands/start/startAppServer.js.map +1 -1
- package/lib/commands/start/startBundleServer.d.ts +14 -3
- package/lib/commands/start/startBundleServer.js +162 -38
- package/lib/commands/start/startBundleServer.js.map +1 -1
- package/package.json +7 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,90 @@
|
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Sat, 13 Aug 2022 08:13:57 GMT",
|
|
6
|
+
"tag": "@ms-cloudpack/cli_v0.4.0",
|
|
7
|
+
"version": "0.4.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "dzearing@microsoft.com",
|
|
12
|
+
"package": "@ms-cloudpack/cli",
|
|
13
|
+
"commit": "69781360664cac5e13e889efa2dc02bc55a60315",
|
|
14
|
+
"comment": "Updates to the CLI to host the overlay."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@ms-cloudpack/cli",
|
|
19
|
+
"comment": "Bump @ms-cloudpack/bundler to v0.3.2",
|
|
20
|
+
"commit": "64ce73b69d840630fd4330720cdd5141f664535c"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@ms-cloudpack/cli",
|
|
25
|
+
"comment": "Bump @ms-cloudpack/overlay to v0.1.0",
|
|
26
|
+
"commit": "64ce73b69d840630fd4330720cdd5141f664535c"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"patch": [
|
|
30
|
+
{
|
|
31
|
+
"author": "email not defined",
|
|
32
|
+
"package": "@ms-cloudpack/cli",
|
|
33
|
+
"commit": "de8a826010b5c4db76b73057199dc860e2f59c36",
|
|
34
|
+
"comment": "Pin devDependencies to 2.1.3"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"date": "Fri, 12 Aug 2022 08:12:39 GMT",
|
|
41
|
+
"tag": "@ms-cloudpack/cli_v0.3.1",
|
|
42
|
+
"version": "0.3.1",
|
|
43
|
+
"comments": {
|
|
44
|
+
"patch": [
|
|
45
|
+
{
|
|
46
|
+
"author": "beachball",
|
|
47
|
+
"package": "@ms-cloudpack/cli",
|
|
48
|
+
"comment": "Bump @ms-cloudpack/bundler to v0.3.1",
|
|
49
|
+
"commit": "06b0e23a9cff634baf090a7310f9af625ca3922e"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"author": "beachball",
|
|
53
|
+
"package": "@ms-cloudpack/cli",
|
|
54
|
+
"comment": "Bump @ms-cloudpack/data-bus to v0.1.0",
|
|
55
|
+
"commit": "06b0e23a9cff634baf090a7310f9af625ca3922e"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"author": "beachball",
|
|
59
|
+
"package": "@ms-cloudpack/cli",
|
|
60
|
+
"comment": "Bump @ms-cloudpack/package-utilities to v0.6.1",
|
|
61
|
+
"commit": "06b0e23a9cff634baf090a7310f9af625ca3922e"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"date": "Sat, 06 Aug 2022 08:15:40 GMT",
|
|
68
|
+
"tag": "@ms-cloudpack/cli_v0.3.0",
|
|
69
|
+
"version": "0.3.0",
|
|
70
|
+
"comments": {
|
|
71
|
+
"minor": [
|
|
72
|
+
{
|
|
73
|
+
"author": "dzearing@microsoft.com",
|
|
74
|
+
"package": "@ms-cloudpack/cli",
|
|
75
|
+
"commit": "70b5e51ee1e2bbb80d6b6fef1dbbf819d3634a0b",
|
|
76
|
+
"comment": "Adding api server and overlay integration."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"author": "beachball",
|
|
80
|
+
"package": "@ms-cloudpack/cli",
|
|
81
|
+
"comment": "Bump @ms-cloudpack/bundler to v0.3.0",
|
|
82
|
+
"commit": "b51ce22d9bb8d691916c1d41cf201b76ebd82bfa"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"date": "Fri, 05 Aug 2022 08:12:21 GMT",
|
|
6
89
|
"tag": "@ms-cloudpack/cli_v0.2.13",
|
|
7
90
|
"version": "0.2.13",
|
|
8
91
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
# Change Log - @ms-cloudpack/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 13 Aug 2022 08:13:57 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.4.0
|
|
8
|
+
|
|
9
|
+
Sat, 13 Aug 2022 08:13:57 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Updates to the CLI to host the overlay. (dzearing@microsoft.com)
|
|
14
|
+
- Bump @ms-cloudpack/bundler to v0.3.2
|
|
15
|
+
- Bump @ms-cloudpack/overlay to v0.1.0
|
|
16
|
+
|
|
17
|
+
### Patches
|
|
18
|
+
|
|
19
|
+
- Pin devDependencies to 2.1.3 (email not defined)
|
|
20
|
+
|
|
21
|
+
## 0.3.1
|
|
22
|
+
|
|
23
|
+
Fri, 12 Aug 2022 08:12:39 GMT
|
|
24
|
+
|
|
25
|
+
### Patches
|
|
26
|
+
|
|
27
|
+
- Bump @ms-cloudpack/bundler to v0.3.1
|
|
28
|
+
- Bump @ms-cloudpack/data-bus to v0.1.0
|
|
29
|
+
- Bump @ms-cloudpack/package-utilities to v0.6.1
|
|
30
|
+
|
|
31
|
+
## 0.3.0
|
|
32
|
+
|
|
33
|
+
Sat, 06 Aug 2022 08:15:40 GMT
|
|
34
|
+
|
|
35
|
+
### Minor changes
|
|
36
|
+
|
|
37
|
+
- Adding api server and overlay integration. (dzearing@microsoft.com)
|
|
38
|
+
- Bump @ms-cloudpack/bundler to v0.3.0
|
|
39
|
+
|
|
7
40
|
## 0.2.13
|
|
8
41
|
|
|
9
|
-
Fri, 05 Aug 2022 08:12:
|
|
42
|
+
Fri, 05 Aug 2022 08:12:21 GMT
|
|
10
43
|
|
|
11
44
|
### Patches
|
|
12
45
|
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
|
-
import { createResolveMap } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
import { createResolveMap, resolve } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
const dashboardPackageName = '@ms-cloudpack/overlay';
|
|
7
|
+
const dashboardPackagePath = (await resolve(dashboardPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';
|
|
5
8
|
export async function createSession(options) {
|
|
6
9
|
const { appPath } = options;
|
|
7
10
|
const id = uuid();
|
|
8
11
|
// Grab the installed dependency locations.
|
|
9
12
|
console.log(`Resolving dependencies...`);
|
|
10
|
-
const
|
|
13
|
+
const startTime = new Date().getTime();
|
|
14
|
+
const resolveMap = await createResolveMap({ appPath, additionalPaths: [dashboardPackagePath] });
|
|
11
15
|
fs.writeFileSync(path.join(process.cwd(), 'resolve-map.json'), JSON.stringify(resolveMap, null, 2));
|
|
12
|
-
console.log(`Resolved dependencies. (${Object.keys(resolveMap).length} total)`);
|
|
16
|
+
console.log(`Resolved dependencies. (${Object.keys(resolveMap).length} total, ${new Date().getTime() - startTime}ms)`);
|
|
13
17
|
return {
|
|
14
18
|
id,
|
|
15
19
|
appPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AACrD,MAAM,oBAAoB,GAAG,CAAC,MAAM,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAMvH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAuB;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAElB,2CAA2C;IAC3C,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAEzC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;IAEhG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAEpG,OAAO,CAAC,GAAG,CACT,2BAA2B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,WAAW,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,KAAK,CAC1G,CAAC;IAEF,OAAO;QACL,EAAE;QACF,OAAO;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { createSession } from './createSession.js';
|
|
|
2
2
|
import { startBundleServer } from './startBundleServer.js';
|
|
3
3
|
import { startAppServer } from './startAppServer.js';
|
|
4
4
|
import { openBrowser } from './openBrowser.js';
|
|
5
|
+
import { startApiServer } from './startApiServer.js';
|
|
5
6
|
/**
|
|
6
7
|
* Defines the "start" verb entry point.
|
|
7
8
|
*/
|
|
@@ -9,12 +10,20 @@ export async function start() {
|
|
|
9
10
|
const appPath = process.cwd();
|
|
10
11
|
// Initialize session definition.
|
|
11
12
|
const session = await createSession({ appPath });
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
//
|
|
13
|
+
// Start api server for tracking status and handling remote requests.
|
|
14
|
+
const apiServer = await startApiServer({ session });
|
|
15
|
+
// Then start bundle and app servers for hosting the app.
|
|
16
|
+
const bundleServer = await startBundleServer({ session, apiServer });
|
|
17
|
+
const appServer = await startAppServer({
|
|
18
|
+
session,
|
|
19
|
+
bundleServer,
|
|
20
|
+
apiServer,
|
|
21
|
+
});
|
|
22
|
+
// Setup cleanup and close things on completion.
|
|
15
23
|
process.on('SIGINT', async function () {
|
|
16
|
-
bundleServer.close();
|
|
17
|
-
appServer.close();
|
|
24
|
+
await bundleServer.close();
|
|
25
|
+
await appServer.close();
|
|
26
|
+
await apiServer.close();
|
|
18
27
|
process.exit(0);
|
|
19
28
|
});
|
|
20
29
|
// Open the browser.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE9B,iCAAiC;IACjC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEjD,qEAAqE;IACrE,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpD,yDAAyD;IACzD,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IACrE,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC;QACrC,OAAO;QACP,YAAY;QACZ,SAAS;KACV,CAAC,CAAC;IAEH,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK;QACxB,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,oBAAoB;IACpB,WAAW,CAAC,oBAAoB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Session } from './types.js';
|
|
2
|
+
export interface SessionStats {
|
|
3
|
+
status: 'idle' | 'pending';
|
|
4
|
+
remainingTasks: number;
|
|
5
|
+
totalTasks: number;
|
|
6
|
+
totalErrors: number;
|
|
7
|
+
totalWarnings: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiServer {
|
|
10
|
+
url: string;
|
|
11
|
+
port: number;
|
|
12
|
+
notifyReload: () => void;
|
|
13
|
+
reportStart: (options: TaskStartDescription) => void;
|
|
14
|
+
reportEnd: (options: TaskEndDescription) => void;
|
|
15
|
+
close: () => void;
|
|
16
|
+
}
|
|
17
|
+
interface TaskError {
|
|
18
|
+
message: string;
|
|
19
|
+
pluginName: string;
|
|
20
|
+
stack: string;
|
|
21
|
+
fileLocation: string;
|
|
22
|
+
lineNumber: number;
|
|
23
|
+
columnNumber: number;
|
|
24
|
+
}
|
|
25
|
+
interface TaskStartDescription {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
inputPath: string;
|
|
29
|
+
outputPath: string;
|
|
30
|
+
}
|
|
31
|
+
interface TaskEndDescription {
|
|
32
|
+
id: string;
|
|
33
|
+
errors?: TaskError[];
|
|
34
|
+
warnings?: TaskError[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The api server handles the data pub/sub (for things like reporting build status)
|
|
38
|
+
* and hosting the dashboard verb backend (for executing actions like loading vscode,
|
|
39
|
+
* changing dependencies, connecting new projects to the running session, etc.)
|
|
40
|
+
*
|
|
41
|
+
* Each time `cloudpack start` is run, an api server will start up for that session. The
|
|
42
|
+
* hosted web page will have a "cloudpack-api-server" header which points
|
|
43
|
+
* to the websocket server.
|
|
44
|
+
*
|
|
45
|
+
* The bundle server will call the api server to publish build status updates.
|
|
46
|
+
*
|
|
47
|
+
* The app server will burn the api server url on the host html, so that client-side
|
|
48
|
+
* javascript can connect and subscribe to page changes.
|
|
49
|
+
*/
|
|
50
|
+
export declare function startApiServer({ session }: {
|
|
51
|
+
session: Session;
|
|
52
|
+
}): Promise<ApiServer>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import getPort from 'get-port';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import WebSocket, { WebSocketServer } from 'ws';
|
|
5
|
+
import { createDataBus } from '@ms-cloudpack/data-bus';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
/**
|
|
8
|
+
* The api server handles the data pub/sub (for things like reporting build status)
|
|
9
|
+
* and hosting the dashboard verb backend (for executing actions like loading vscode,
|
|
10
|
+
* changing dependencies, connecting new projects to the running session, etc.)
|
|
11
|
+
*
|
|
12
|
+
* Each time `cloudpack start` is run, an api server will start up for that session. The
|
|
13
|
+
* hosted web page will have a "cloudpack-api-server" header which points
|
|
14
|
+
* to the websocket server.
|
|
15
|
+
*
|
|
16
|
+
* The bundle server will call the api server to publish build status updates.
|
|
17
|
+
*
|
|
18
|
+
* The app server will burn the api server url on the host html, so that client-side
|
|
19
|
+
* javascript can connect and subscribe to page changes.
|
|
20
|
+
*/
|
|
21
|
+
export async function startApiServer({ session }) {
|
|
22
|
+
const port = await getPort({ port: [9890, 9891, 9892, 9893] });
|
|
23
|
+
const bus = createDataBus();
|
|
24
|
+
const sessionStats = {
|
|
25
|
+
status: 'idle',
|
|
26
|
+
remainingTasks: 0,
|
|
27
|
+
totalTasks: 0,
|
|
28
|
+
totalErrors: 0,
|
|
29
|
+
totalWarnings: 0,
|
|
30
|
+
};
|
|
31
|
+
const allTasks = new Map();
|
|
32
|
+
bus.publish([session.id, 'status'], sessionStats);
|
|
33
|
+
// Create a websocket server which listens for subscriptions and verb requests,
|
|
34
|
+
// and broadcasts the data to all connected clients.
|
|
35
|
+
const server = new WebSocketServer({ port }, () => {
|
|
36
|
+
// console.log(`ApiServer: Started on port ${port}`);
|
|
37
|
+
}).on('connection', (socket) => {
|
|
38
|
+
const disposables = new Map();
|
|
39
|
+
// console.log('ApiServer: Client connected');
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
function sendMessage(message) {
|
|
42
|
+
socket.send(JSON.stringify(message, null, 2));
|
|
43
|
+
}
|
|
44
|
+
socket
|
|
45
|
+
.on('message', async (rawData) => {
|
|
46
|
+
const request = JSON.parse(rawData.toString());
|
|
47
|
+
// console.log(`ApiServer: Received message: ${JSON.stringify(request, null, 2)}`);
|
|
48
|
+
switch (request.type) {
|
|
49
|
+
case 'subscribe': {
|
|
50
|
+
const { path: subscriptionPath, id } = request.data;
|
|
51
|
+
disposables.set(id, bus.subscribe(subscriptionPath,
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
(data) => sendMessage({ type: 'notify', id, path: subscriptionPath, data })));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case 'unsubscribe': {
|
|
57
|
+
const { id } = request.data;
|
|
58
|
+
if (id) {
|
|
59
|
+
const dispose = disposables.get(id);
|
|
60
|
+
if (dispose) {
|
|
61
|
+
dispose();
|
|
62
|
+
disposables.delete(id);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case 'openSource': {
|
|
68
|
+
const { rootPath, relativePath = '', line, column } = request.data;
|
|
69
|
+
const fullPath = path.join(rootPath, relativePath);
|
|
70
|
+
console.log(`Opening VSCode with path: ${fullPath}`);
|
|
71
|
+
execSync(`code --goto ${fullPath}:${line}:${column}`, { cwd: process.cwd() });
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'open': {
|
|
75
|
+
const { rootPath, relativePath = '' } = request.data;
|
|
76
|
+
const fullPath = path.join(rootPath, relativePath);
|
|
77
|
+
console.log(`Opening path: ${fullPath}`);
|
|
78
|
+
const openCommand = os.platform() == 'win32' ? 'start' : 'open';
|
|
79
|
+
execSync(`${openCommand} ${fullPath}`, { cwd: process.cwd() });
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.on('close', () => {
|
|
85
|
+
for (const d of disposables.values()) {
|
|
86
|
+
d();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
url: `ws://localhost:${port}`,
|
|
92
|
+
port,
|
|
93
|
+
notifyReload: () => {
|
|
94
|
+
server.clients.forEach((socket) => {
|
|
95
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
96
|
+
socket.send(JSON.stringify({
|
|
97
|
+
type: 'reload',
|
|
98
|
+
data: { sessionId: session.id },
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
reportStart(taskStart) {
|
|
104
|
+
const previousResult = allTasks.get(taskStart.id);
|
|
105
|
+
const now = new Date().getTime();
|
|
106
|
+
if (!previousResult) {
|
|
107
|
+
sessionStats.totalTasks++;
|
|
108
|
+
}
|
|
109
|
+
if (previousResult?.status === 'complete') {
|
|
110
|
+
sessionStats.totalErrors -= previousResult.errors?.length || 0;
|
|
111
|
+
sessionStats.totalWarnings -= previousResult.warnings?.length || 0;
|
|
112
|
+
}
|
|
113
|
+
sessionStats.remainingTasks++;
|
|
114
|
+
sessionStats.status = 'pending';
|
|
115
|
+
allTasks.set(taskStart.id, {
|
|
116
|
+
...taskStart,
|
|
117
|
+
status: 'pending',
|
|
118
|
+
startTime: now,
|
|
119
|
+
});
|
|
120
|
+
bus.publish([session.id, 'status'], sessionStats);
|
|
121
|
+
bus.publish([session.id, 'status-details'], { tasks: Array.from(allTasks.values()) });
|
|
122
|
+
},
|
|
123
|
+
reportEnd: (end) => {
|
|
124
|
+
const previousResult = allTasks.get(end.id);
|
|
125
|
+
const now = new Date().getTime();
|
|
126
|
+
if (previousResult) {
|
|
127
|
+
sessionStats.remainingTasks--;
|
|
128
|
+
sessionStats.totalErrors += end.errors?.length || 0;
|
|
129
|
+
sessionStats.totalWarnings += end.warnings?.length || 0;
|
|
130
|
+
allTasks.set(end.id, {
|
|
131
|
+
...previousResult,
|
|
132
|
+
...end,
|
|
133
|
+
status: 'complete',
|
|
134
|
+
durationMilliseconds: now - previousResult.startTime,
|
|
135
|
+
lastUpdated: now,
|
|
136
|
+
});
|
|
137
|
+
if (sessionStats.remainingTasks === 0) {
|
|
138
|
+
sessionStats.status = 'idle';
|
|
139
|
+
}
|
|
140
|
+
bus.publish([session.id, 'status'], sessionStats);
|
|
141
|
+
bus.publish([session.id, 'status-details'], { tasks: Array.from(allTasks.values()) });
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
close: () => server.close(),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=startApiServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startApiServer.js","sourceRoot":"","sources":["../../../src/commands/start/startApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO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C;gBACpD,YAAY,CAAC,aAAa,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;gBAExD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE;oBACnB,GAAG,cAAc;oBACjB,GAAG,GAAG;oBACN,MAAM,EAAE,UAAU;oBAClB,oBAAoB,EAAE,GAAG,GAAG,cAAc,CAAC,SAAS;oBACpD,WAAW,EAAE,GAAG;iBACjB,CAAC,CAAC;gBAEH,IAAI,YAAY,CAAC,cAAc,KAAK,CAAC,EAAE;oBACrC,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;iBAC9B;gBAED,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;gBAClD,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;aACvF;QACH,CAAC;QAED,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { Session } from './types.js';
|
|
3
|
+
import type { ApiServer } from './startApiServer.js';
|
|
4
|
+
import type { BundleServer } from './startBundleServer.js';
|
|
3
5
|
/**
|
|
4
6
|
* The app server hosts the appropriate routes for the web app, primarily returning html content
|
|
5
7
|
* which loads resources from the bundle server.
|
|
@@ -8,7 +10,11 @@ import type { Session } from './types.js';
|
|
|
8
10
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
9
11
|
* assets in various forms using its own routing.
|
|
10
12
|
*/
|
|
11
|
-
export declare function startAppServer(session
|
|
13
|
+
export declare function startAppServer({ session, bundleServer, apiServer, }: {
|
|
14
|
+
session: Session;
|
|
15
|
+
bundleServer: BundleServer;
|
|
16
|
+
apiServer: ApiServer;
|
|
17
|
+
}): Promise<{
|
|
12
18
|
close: () => import("http").Server;
|
|
13
19
|
port: number;
|
|
14
20
|
}>;
|
|
@@ -3,6 +3,10 @@ import path from 'path';
|
|
|
3
3
|
import { slash } from '@ms-cloudpack/path-utilities';
|
|
4
4
|
import { createImportMap, getPackageDefinition } from '@ms-cloudpack/package-utilities';
|
|
5
5
|
import { createExpressApp } from '@ms-cloudpack/create-express-app';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
const log = (messages) => {
|
|
8
|
+
// console.log(`BundleServer:`, ...messages);
|
|
9
|
+
};
|
|
6
10
|
/**
|
|
7
11
|
* The app server hosts the appropriate routes for the web app, primarily returning html content
|
|
8
12
|
* which loads resources from the bundle server.
|
|
@@ -11,32 +15,41 @@ import { createExpressApp } from '@ms-cloudpack/create-express-app';
|
|
|
11
15
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
12
16
|
* assets in various forms using its own routing.
|
|
13
17
|
*/
|
|
14
|
-
export async function startAppServer(session,
|
|
15
|
-
const importMap = await createImportMap(session.resolveMap,
|
|
18
|
+
export async function startAppServer({ session, bundleServer, apiServer, }) {
|
|
19
|
+
const importMap = await createImportMap(session.resolveMap, bundleServer.url);
|
|
16
20
|
const definition = await getPackageDefinition(session.appPath, true);
|
|
21
|
+
const dashboardClientScript = importMap.imports['@ms-cloudpack/overlay'];
|
|
22
|
+
const dashboardScript = importMap.imports['@ms-cloudpack/overlay'];
|
|
17
23
|
const { server, port } = await createExpressApp([5000, 5001, 5002, 5003], (app) => {
|
|
18
24
|
// Set up the express app routes.
|
|
19
|
-
app
|
|
25
|
+
app
|
|
26
|
+
.get('/__/dashboard', (req, res) => {
|
|
27
|
+
sendHtmlResponse({
|
|
28
|
+
session,
|
|
29
|
+
title: 'Cloudpack dashboard',
|
|
30
|
+
importMap,
|
|
31
|
+
apiServer,
|
|
32
|
+
bodyScripts: [dashboardClientScript, dashboardScript],
|
|
33
|
+
res,
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
.get('*', async (req, res) => {
|
|
20
37
|
if (!definition) {
|
|
21
38
|
res.status(500).send(`There was no package.json located at "${session.appPath}".`);
|
|
22
39
|
return;
|
|
23
40
|
}
|
|
24
41
|
const requestPath = slash(req.path.substring(1));
|
|
25
42
|
const requestExt = path.extname(requestPath);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<body>
|
|
37
|
-
<script type="module" src="${entryScript}"></script>
|
|
38
|
-
</body>
|
|
39
|
-
</html>`);
|
|
43
|
+
const entryScript = importMap.imports[definition.name || ''];
|
|
44
|
+
log(`App server: Request: ${requestPath}, ext: ${requestExt}, ${port}`);
|
|
45
|
+
sendHtmlResponse({
|
|
46
|
+
session,
|
|
47
|
+
title: definition.name || '',
|
|
48
|
+
importMap,
|
|
49
|
+
apiServer,
|
|
50
|
+
bodyScripts: [dashboardClientScript, entryScript],
|
|
51
|
+
res,
|
|
52
|
+
});
|
|
40
53
|
});
|
|
41
54
|
});
|
|
42
55
|
return {
|
|
@@ -44,4 +57,25 @@ export async function startAppServer(session, bundleServerUrl) {
|
|
|
44
57
|
port,
|
|
45
58
|
};
|
|
46
59
|
}
|
|
60
|
+
function sendHtmlResponse({ session, title, importMap, apiServer, headScripts, bodyScripts, res, }) {
|
|
61
|
+
res.header('Content-Type', 'text/html');
|
|
62
|
+
res.header('Cache-Control', 'no-cache');
|
|
63
|
+
res.header('Content-Security-Policy', `connect-src 'self' ws:;`);
|
|
64
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
65
|
+
res.cookie('cloudpack-session-id', session.id);
|
|
66
|
+
res.cookie('cloudpack-api-url', apiServer.url);
|
|
67
|
+
res.send([
|
|
68
|
+
`<!DOCTYPE html>`,
|
|
69
|
+
`<html>`,
|
|
70
|
+
`<head>`,
|
|
71
|
+
`<title>${title}</title>`,
|
|
72
|
+
`<script type="importmap">${JSON.stringify(importMap, null, 2)}</script>`,
|
|
73
|
+
headScripts?.map((scriptUrl) => `<script type="module" src="${scriptUrl}"></script>`).join('\n') || '',
|
|
74
|
+
`</head>`,
|
|
75
|
+
`<body>`,
|
|
76
|
+
bodyScripts?.map((scriptUrl) => `<script type="module" src="${scriptUrl}" async></script>`).join('\n') || '',
|
|
77
|
+
`</body>`,
|
|
78
|
+
`</html>`,
|
|
79
|
+
].join('\n'));
|
|
80
|
+
}
|
|
47
81
|
//# sourceMappingURL=startAppServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../src/commands/start/startAppServer.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../src/commands/start/startAppServer.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAkB,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAA+B,MAAM,kCAAkC,CAAC;AAKjG,6DAA6D;AAC7D,MAAM,GAAG,GAAG,CAAC,QAAiB,EAAE,EAAE;IAChC,6CAA6C;AAC/C,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,GAKV;IACC,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,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C,CAAC,SAAS,EAAE,EAAE,CAAC,8BAA8B,SAAS,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QAC5G,SAAS;QACT,SAAS;KACV,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { Session } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { ApiServer } from './startApiServer.js';
|
|
3
|
+
export interface BundleServer {
|
|
4
|
+
url: string;
|
|
4
5
|
port: number;
|
|
5
|
-
|
|
6
|
+
close: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The bundle server handles package requests and returns bundled resources.
|
|
10
|
+
* Resources are bundled on demand and cached locally to avoid re-bundling
|
|
11
|
+
* on each request.
|
|
12
|
+
*/
|
|
13
|
+
export declare function startBundleServer({ session, apiServer, }: {
|
|
14
|
+
session: Session;
|
|
15
|
+
apiServer: ApiServer;
|
|
16
|
+
}): Promise<BundleServer>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bundlePackage } from '@ms-cloudpack/bundler';
|
|
2
2
|
import { createExpressApp } from '@ms-cloudpack/create-express-app';
|
|
3
|
-
import { readJson,
|
|
3
|
+
import { readJson, writeJson } from '@ms-cloudpack/json-utilities';
|
|
4
4
|
import { isExternalPackage } from '@ms-cloudpack/package-utilities';
|
|
5
5
|
import { isFolder, slash } from '@ms-cloudpack/path-utilities';
|
|
6
6
|
import filenamify from 'filenamify';
|
|
@@ -9,10 +9,19 @@ import hash from 'object-hash';
|
|
|
9
9
|
import os from 'os';
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import { parseRequestInfo } from './parseRequestInfo.js';
|
|
12
|
+
import chokidar from 'chokidar';
|
|
12
13
|
const { ensureDir } = fsExtra;
|
|
13
|
-
const bundleLookupPath = path.join(os.tmpdir(), 'cloudpack-output', 'all-bundles.json');
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// const bundleLookupPath = path.join(os.tmpdir(), 'cloudpack-output', 'all-bundles.json');
|
|
15
|
+
const log = (...messages) => {
|
|
16
|
+
console.log(`BundleServer:`, ...messages);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The bundle server handles package requests and returns bundled resources.
|
|
20
|
+
* Resources are bundled on demand and cached locally to avoid re-bundling
|
|
21
|
+
* on each request.
|
|
22
|
+
*/
|
|
23
|
+
export async function startBundleServer({ session, apiServer, }) {
|
|
24
|
+
const createdBundles = {};
|
|
16
25
|
const pendingBundles = {};
|
|
17
26
|
const { resolveMap } = session;
|
|
18
27
|
const { server, port } = await createExpressApp([5500, 5501, 5502, 5503], (app) => {
|
|
@@ -25,10 +34,10 @@ export async function startBundleServer(session) {
|
|
|
25
34
|
? packageEntry?.path
|
|
26
35
|
: packageEntry?.scopedVersions?.[version]?.path;
|
|
27
36
|
const force = req.query.force !== undefined;
|
|
28
|
-
|
|
37
|
+
log(`Request: "${packageName}@${version}${filePath}"`);
|
|
29
38
|
// If the package is missing, invalid arguments.
|
|
30
39
|
if (!requestPath || !packageName) {
|
|
31
|
-
|
|
40
|
+
log(`Response (400): "${packageName}@${version}${filePath}"`);
|
|
32
41
|
res.status(400).send(`Requests must be in the format "/{packageName}@{version}/path/file.ext".`);
|
|
33
42
|
return;
|
|
34
43
|
}
|
|
@@ -36,7 +45,7 @@ export async function startBundleServer(session) {
|
|
|
36
45
|
if (!version) {
|
|
37
46
|
const resolvedPackage = resolveMap[packageName];
|
|
38
47
|
if (!resolvedPackage) {
|
|
39
|
-
|
|
48
|
+
log(`Response (404): Unrecognized package "${packageName}"`);
|
|
40
49
|
res.status(404).send(`Unrecognized package "${packageName}".`);
|
|
41
50
|
return;
|
|
42
51
|
}
|
|
@@ -45,7 +54,7 @@ export async function startBundleServer(session) {
|
|
|
45
54
|
}
|
|
46
55
|
// If it's an unrecognized package, 404.
|
|
47
56
|
if (!packagePath) {
|
|
48
|
-
|
|
57
|
+
log(`BundleServer: Response (404): "${packageName}@${version}${filePath}"`);
|
|
49
58
|
res
|
|
50
59
|
.status(404)
|
|
51
60
|
.send(`The requested package "${packageName}@${version}${filePath}" was not found in the resolve map.`);
|
|
@@ -61,7 +70,7 @@ export async function startBundleServer(session) {
|
|
|
61
70
|
// Derive where the output should be.
|
|
62
71
|
const outputPath = path.join(os.tmpdir(), 'cloudpack-output', `${filenamify(packageName)}-${version}-${bundleId}`);
|
|
63
72
|
let action = createdBundles[bundleId];
|
|
64
|
-
// Clear the created bundle if the folder doesn't exist.
|
|
73
|
+
// Clear the created bundle if we think the bundle was created, but the folder doesn't exist.
|
|
65
74
|
if (action && !isFolder(outputPath)) {
|
|
66
75
|
action = undefined;
|
|
67
76
|
delete createdBundles[bundleId];
|
|
@@ -72,67 +81,182 @@ export async function startBundleServer(session) {
|
|
|
72
81
|
// Either latch on to a pending request or create a new one.
|
|
73
82
|
if (!pendingAction) {
|
|
74
83
|
pendingAction = pendingBundles[bundleId] = new Promise((resolve) => {
|
|
84
|
+
const bundleRequest = {
|
|
85
|
+
id: bundleId,
|
|
86
|
+
packageName,
|
|
87
|
+
version: version,
|
|
88
|
+
packagePath,
|
|
89
|
+
outputPath,
|
|
90
|
+
isExternal,
|
|
91
|
+
};
|
|
75
92
|
// Async helper so that we can await and call resolve.
|
|
76
93
|
async function createBundle() {
|
|
94
|
+
// Start tracking work.
|
|
95
|
+
apiServer.reportStart({
|
|
96
|
+
id: bundleId,
|
|
97
|
+
name: `Bundle ${packageName}@${version}`,
|
|
98
|
+
inputPath: packagePath || '',
|
|
99
|
+
outputPath,
|
|
100
|
+
});
|
|
77
101
|
try {
|
|
78
|
-
|
|
102
|
+
log(`No previous action found, bundling: "${packageName}@${version}"`);
|
|
79
103
|
await ensureDir(outputPath);
|
|
104
|
+
log(`Finished ensureDir: "${packageName}@${version}"`);
|
|
80
105
|
// This check shouldn't be required because we throw above if packagePath is undefined,
|
|
81
106
|
// but TypeScript insists it is necessary.
|
|
82
107
|
if (packagePath) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
packageName: packageName,
|
|
92
|
-
packageVersion: version,
|
|
93
|
-
packagePath,
|
|
94
|
-
outputPath,
|
|
95
|
-
result: bundlerResult.errors?.length == 0 ? 'success' : 'errors',
|
|
96
|
-
errors: bundlerResult.errors,
|
|
97
|
-
warnings: bundlerResult.warnings,
|
|
98
|
-
};
|
|
108
|
+
log(`Trying to bundle "${packageName}@${version}"`);
|
|
109
|
+
await bundle(bundleRequest, force);
|
|
110
|
+
// If this is going to be incremental, start a watcher to re-bundle when source
|
|
111
|
+
// changes.
|
|
112
|
+
if (!isExternal) {
|
|
113
|
+
initializeFileWatcher(session, bundleId, outputPath, bundleRequest, pendingBundles, apiServer);
|
|
114
|
+
log(`Bundle complete: ${outputPath}`);
|
|
115
|
+
}
|
|
99
116
|
}
|
|
100
117
|
}
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
catch (_) {
|
|
119
|
+
/* no-op */
|
|
103
120
|
}
|
|
104
|
-
return createdBundles[bundleId];
|
|
105
121
|
}
|
|
106
122
|
// Call the async function and tie it in with the promise.
|
|
107
|
-
createBundle().then(
|
|
123
|
+
createBundle().then(() => {
|
|
124
|
+
// If an existing bundle was created, dispose.
|
|
125
|
+
if (createdBundles[bundleId]) {
|
|
126
|
+
createdBundles[bundleId].dispose?.();
|
|
127
|
+
}
|
|
128
|
+
createdBundles[bundleId] = bundleRequest;
|
|
129
|
+
delete pendingBundles[bundleId];
|
|
130
|
+
// TODO: errors and warnings typings don't match up. We need to reconcile.
|
|
131
|
+
apiServer.reportEnd({
|
|
132
|
+
id: bundleId,
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
errors: bundleRequest.result?.errors,
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
warnings: bundleRequest.result?.warnings,
|
|
137
|
+
});
|
|
138
|
+
resolve(bundleRequest);
|
|
139
|
+
});
|
|
108
140
|
});
|
|
109
141
|
}
|
|
110
142
|
else {
|
|
111
|
-
|
|
143
|
+
log(`BundleServer: Previous action found, waiting: "${packageName}@${version}${filePath}"`);
|
|
112
144
|
}
|
|
113
145
|
action = await pendingAction;
|
|
114
146
|
}
|
|
115
147
|
else {
|
|
116
|
-
|
|
148
|
+
log(`BundleServer: Bundle cached, returning: "${packageName}@${version}${filePath}"`);
|
|
149
|
+
}
|
|
150
|
+
// If this is a pre-built local package we haven't set up for incremental builds, set it up.
|
|
151
|
+
if (!isExternal && !action.dispose) {
|
|
152
|
+
initializeFileWatcher(session, bundleId, outputPath, action, pendingBundles, apiServer);
|
|
117
153
|
}
|
|
118
|
-
// At this point we should have an action
|
|
119
|
-
if (action.result
|
|
154
|
+
// At this point we should have an action completed.
|
|
155
|
+
if ((action.result?.errors?.length || 0) > 0) {
|
|
120
156
|
res.status(500).type('json').send(action);
|
|
121
157
|
}
|
|
122
158
|
else {
|
|
123
|
-
|
|
159
|
+
log(`BundleServer: Bundle returning: "${packageName}@${version}${filePath}"`);
|
|
124
160
|
// Try to return the result.
|
|
161
|
+
if (isExternal) {
|
|
162
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
163
|
+
}
|
|
125
164
|
res.sendFile(path.join(outputPath, filePath));
|
|
126
165
|
}
|
|
127
166
|
});
|
|
128
167
|
});
|
|
129
|
-
|
|
168
|
+
const url = `http://localhost:${port}`;
|
|
169
|
+
log(`BundleServer: started (${url})`);
|
|
130
170
|
return {
|
|
131
|
-
close: () => {
|
|
132
|
-
|
|
171
|
+
close: async () => {
|
|
172
|
+
// await writeJson(bundleLookupPath, createdBundles);
|
|
133
173
|
server.close();
|
|
134
174
|
},
|
|
135
175
|
port,
|
|
176
|
+
url,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async function bundle(bundleRequest, force) {
|
|
180
|
+
const { packagePath, outputPath, isExternal } = bundleRequest;
|
|
181
|
+
// Rehydrate the result if not incremental.
|
|
182
|
+
if (isExternal && !force) {
|
|
183
|
+
bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));
|
|
184
|
+
}
|
|
185
|
+
const isCacheUsable = bundleRequest.result?.errors?.length === 0;
|
|
186
|
+
// Only use cached result if it's successful.
|
|
187
|
+
if (!isCacheUsable) {
|
|
188
|
+
bundleRequest.result = await bundlePackage({
|
|
189
|
+
packagePath,
|
|
190
|
+
outputPath,
|
|
191
|
+
outputType: 'library',
|
|
192
|
+
incremental: !isExternal,
|
|
193
|
+
});
|
|
194
|
+
// Write the result to disk.
|
|
195
|
+
if (isExternal) {
|
|
196
|
+
await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
log(`Bundle cached, returning: "${bundleRequest.packageName}@${bundleRequest.version}"`);
|
|
201
|
+
}
|
|
202
|
+
return bundleRequest;
|
|
203
|
+
}
|
|
204
|
+
function initializeFileWatcher(session, bundleId, outputPath, bundleRequest, pendingBundles, apiServer) {
|
|
205
|
+
const { id, packageName, packagePath, version } = bundleRequest;
|
|
206
|
+
let bundleOutput = bundleRequest.result;
|
|
207
|
+
log(`Initializing file watcher for ${packageName}@${version}`);
|
|
208
|
+
// TODO: This is a bit of a hack. We should be able to use the watch API, but it doesn't seem to work.
|
|
209
|
+
const watcher = chokidar.watch(path.join(packagePath, 'src')).on('change', (event) => {
|
|
210
|
+
if (!pendingBundles[id]) {
|
|
211
|
+
bundleRequest.isRebuildRequired = true;
|
|
212
|
+
log(`Detected change "${event}", rebuilding "${packageName}@${version}"`);
|
|
213
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
214
|
+
pendingBundles[id] = new Promise(async (resolveIncremental) => {
|
|
215
|
+
do {
|
|
216
|
+
bundleRequest.isRebuildRequired = false;
|
|
217
|
+
log(`[Start] >> Bundling "${packageName}@${version}" to "${outputPath}"`);
|
|
218
|
+
// Start tracking work.
|
|
219
|
+
apiServer.reportStart({
|
|
220
|
+
id: bundleId,
|
|
221
|
+
name: `Rebundle ${packageName}@${version}`,
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
223
|
+
inputPath: packagePath,
|
|
224
|
+
outputPath,
|
|
225
|
+
});
|
|
226
|
+
if (!bundleOutput?.rebuild) {
|
|
227
|
+
bundleOutput = (await bundle(bundleRequest)).result;
|
|
228
|
+
}
|
|
229
|
+
else if (bundleOutput?.rebuild) {
|
|
230
|
+
bundleOutput = await bundleOutput.rebuild();
|
|
231
|
+
}
|
|
232
|
+
// TODO: Fix typings
|
|
233
|
+
apiServer.reportEnd({
|
|
234
|
+
id: bundleId,
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
|
+
errors: bundleOutput?.errors,
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
+
warnings: bundleOutput?.warnings,
|
|
239
|
+
});
|
|
240
|
+
log(`[ End ] << Bundled "${packageName}@${version}" (${bundleOutput?.outputFiles?.length || 0} file(s), ${bundleOutput?.errors?.length || 0} errors)`);
|
|
241
|
+
} while (bundleRequest.isRebuildRequired);
|
|
242
|
+
delete pendingBundles[id];
|
|
243
|
+
if (!bundleOutput?.errors?.length) {
|
|
244
|
+
log(`Notifying rebuild: ${packageName}@${version}`);
|
|
245
|
+
apiServer.notifyReload();
|
|
246
|
+
}
|
|
247
|
+
resolveIncremental(bundleRequest);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
// A change was made while we were bundling. We need to wait for the current
|
|
252
|
+
// bundle to finish before we can rebuild.
|
|
253
|
+
bundleRequest.isRebuildRequired = true;
|
|
254
|
+
log(`Detected change "${event}", already waiting for "${packageName}@${version}"`);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
bundleRequest.dispose = () => {
|
|
258
|
+
watcher.close();
|
|
259
|
+
bundleOutput?.dispose?.();
|
|
136
260
|
};
|
|
137
261
|
}
|
|
138
262
|
//# sourceMappingURL=startBundleServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;AAE9B,2FAA2F;AAE3F,MAAM,GAAG,GAAG,CAAC,GAAG,QAAmB,EAAE,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC5C,CAAC,CAAC;AAwBF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,OAAO,EACP,SAAS,GAIV;IACC,MAAM,cAAc,GAA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W,IAAI,OAAO,GAAG,CAAC,CAAC;SACpF;IACH,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,OAAO,GAAG,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
"cloudpack": "./lib/cloudpack.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ms-cloudpack/bundler": "^0.2
|
|
19
|
+
"@ms-cloudpack/bundler": "^0.3.2",
|
|
20
20
|
"@ms-cloudpack/create-express-app": "^0.1.0",
|
|
21
|
+
"@ms-cloudpack/data-bus": "^0.1.0",
|
|
21
22
|
"@ms-cloudpack/json-utilities": "^0.0.3",
|
|
22
|
-
"@ms-cloudpack/
|
|
23
|
+
"@ms-cloudpack/overlay": "^0.1.0",
|
|
24
|
+
"@ms-cloudpack/package-utilities": "^0.6.1",
|
|
23
25
|
"@ms-cloudpack/path-utilities": "^0.3.1",
|
|
26
|
+
"chokidar": "^3.5.3",
|
|
24
27
|
"commander": "^9.1.0",
|
|
25
28
|
"filenamify": "^5.1.0",
|
|
26
29
|
"fs-extra": "^10.1.0",
|
|
@@ -33,6 +36,7 @@
|
|
|
33
36
|
"@ms-cloudpack/bundler-types": "*",
|
|
34
37
|
"@ms-cloudpack/eslint-config-base": "*",
|
|
35
38
|
"@ms-cloudpack/scripts": "*",
|
|
39
|
+
"@types/chokidar": "2.1.3",
|
|
36
40
|
"@types/fs-extra": "9.0.13",
|
|
37
41
|
"@types/glob": "7.2.0",
|
|
38
42
|
"@types/object-hash": "2.2.1",
|