@ms-cloudpack/cli 0.0.6 → 0.1.1

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 CHANGED
@@ -2,7 +2,94 @@
2
2
  "name": "@ms-cloudpack/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Sat, 14 May 2022 04:35:56 GMT",
5
+ "date": "Sat, 21 May 2022 00:31:20 GMT",
6
+ "tag": "@ms-cloudpack/cli_v0.1.1",
7
+ "version": "0.1.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "dzearing@microsoft.com",
12
+ "package": "@ms-cloudpack/cli",
13
+ "commit": "c26c7bcc7abda501d07180598e3da003b435b03b",
14
+ "comment": "Adding call to burn import map on the page and placeholder html rendering logic."
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@ms-cloudpack/cli",
19
+ "comment": "Bump @ms-cloudpack/bundler to v0.1.1",
20
+ "commit": "c26c7bcc7abda501d07180598e3da003b435b03b"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@ms-cloudpack/cli",
25
+ "comment": "Bump @ms-cloudpack/package-utilities to v0.3.0",
26
+ "commit": "c26c7bcc7abda501d07180598e3da003b435b03b"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Fri, 20 May 2022 04:26:15 GMT",
33
+ "tag": "@ms-cloudpack/cli_v0.1.0",
34
+ "version": "0.1.0",
35
+ "comments": {
36
+ "minor": [
37
+ {
38
+ "author": "dzearing@microsoft.com",
39
+ "package": "@ms-cloudpack/cli",
40
+ "commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77",
41
+ "comment": "Integrating ori-api"
42
+ },
43
+ {
44
+ "author": "beachball",
45
+ "package": "@ms-cloudpack/cli",
46
+ "comment": "Bump @ms-cloudpack/bundler to v0.1.0",
47
+ "commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77"
48
+ },
49
+ {
50
+ "author": "beachball",
51
+ "package": "@ms-cloudpack/cli",
52
+ "comment": "Bump @ms-cloudpack/create-express-app to v0.1.0",
53
+ "commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77"
54
+ },
55
+ {
56
+ "author": "beachball",
57
+ "package": "@ms-cloudpack/cli",
58
+ "comment": "Bump @ms-cloudpack/package-utilities to v0.2.0",
59
+ "commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77"
60
+ },
61
+ {
62
+ "author": "beachball",
63
+ "package": "@ms-cloudpack/cli",
64
+ "comment": "Bump @ms-cloudpack/path-utilities to v0.2.0",
65
+ "commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77"
66
+ }
67
+ ]
68
+ }
69
+ },
70
+ {
71
+ "date": "Thu, 19 May 2022 21:04:02 GMT",
72
+ "tag": "@ms-cloudpack/cli_v0.0.7",
73
+ "version": "0.0.7",
74
+ "comments": {
75
+ "patch": [
76
+ {
77
+ "author": "beachball",
78
+ "package": "@ms-cloudpack/cli",
79
+ "comment": "Bump @ms-cloudpack/bundler to v0.0.7",
80
+ "commit": "9bd9230fc985c94b2ad7d32a1abadada2fa75852"
81
+ },
82
+ {
83
+ "author": "beachball",
84
+ "package": "@ms-cloudpack/cli",
85
+ "comment": "Bump @ms-cloudpack/package-utilities to v0.1.7",
86
+ "commit": "9bd9230fc985c94b2ad7d32a1abadada2fa75852"
87
+ }
88
+ ]
89
+ }
90
+ },
91
+ {
92
+ "date": "Sat, 14 May 2022 04:36:11 GMT",
6
93
  "tag": "@ms-cloudpack/cli_v0.0.6",
7
94
  "version": "0.0.6",
8
95
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,43 @@
1
1
  # Change Log - @ms-cloudpack/cli
2
2
 
3
- This log was last generated on Sat, 14 May 2022 04:35:56 GMT and should not be manually modified.
3
+ This log was last generated on Sat, 21 May 2022 00:31:20 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.1.1
8
+
9
+ Sat, 21 May 2022 00:31:20 GMT
10
+
11
+ ### Patches
12
+
13
+ - Adding call to burn import map on the page and placeholder html rendering logic. (dzearing@microsoft.com)
14
+ - Bump @ms-cloudpack/bundler to v0.1.1
15
+ - Bump @ms-cloudpack/package-utilities to v0.3.0
16
+
17
+ ## 0.1.0
18
+
19
+ Fri, 20 May 2022 04:26:15 GMT
20
+
21
+ ### Minor changes
22
+
23
+ - Integrating ori-api (dzearing@microsoft.com)
24
+ - Bump @ms-cloudpack/bundler to v0.1.0
25
+ - Bump @ms-cloudpack/create-express-app to v0.1.0
26
+ - Bump @ms-cloudpack/package-utilities to v0.2.0
27
+ - Bump @ms-cloudpack/path-utilities to v0.2.0
28
+
29
+ ## 0.0.7
30
+
31
+ Thu, 19 May 2022 21:04:02 GMT
32
+
33
+ ### Patches
34
+
35
+ - Bump @ms-cloudpack/bundler to v0.0.7
36
+ - Bump @ms-cloudpack/package-utilities to v0.1.7
37
+
7
38
  ## 0.0.6
8
39
 
9
- Sat, 14 May 2022 04:35:56 GMT
40
+ Sat, 14 May 2022 04:36:11 GMT
10
41
 
11
42
  ### Patches
12
43
 
@@ -0,0 +1,5 @@
1
+ import type { Session } from './types.js';
2
+ export interface SessionOptions {
3
+ appPath: string;
4
+ }
5
+ export declare function createSession(options: SessionOptions): Promise<Session>;
@@ -0,0 +1,21 @@
1
+ import { v4 as uuid } from 'uuid';
2
+ import { createResolveMap } from '@ms-cloudpack/package-utilities';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ export async function createSession(options) {
6
+ const { appPath } = options;
7
+ const id = uuid();
8
+ // Grab the installed dependency locations.
9
+ console.log(`Resolving dependencies...`);
10
+ const resolveMap = await createResolveMap({ appPath });
11
+ fs.writeFileSync(path.join(process.cwd(), 'resolve-map.json'), JSON.stringify(resolveMap, null, 2));
12
+ console.log(`Resolved dependencies. (${Object.keys(resolveMap).length} total)`);
13
+ return {
14
+ id,
15
+ appPath,
16
+ type: 'web-app',
17
+ mode: 'library',
18
+ resolveMap,
19
+ };
20
+ }
21
+ //# sourceMappingURL=createSession.js.map
@@ -0,0 +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;AACnE,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,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,UAAU,GAAG,MAAM,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEvD,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,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC;IAEhF,OAAO;QACL,EAAE;QACF,OAAO;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
+ /* Defines the "start" verb. */
1
2
  export function init(command) {
2
3
  command
3
4
  .command('start')
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC9D,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAEA,+BAA+B;AAC/B,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC9D,CAAC"}
@@ -1 +1,4 @@
1
+ /**
2
+ * Defines the "start" verb entry point.
3
+ */
1
4
  export declare function start(): Promise<void>;
@@ -1,26 +1,23 @@
1
+ import { createSession } from './createSession.js';
1
2
  import { startBundleServer } from './startBundleServer.js';
2
- import { openBrowser } from './openBrowser.js';
3
3
  import { startAppServer } from './startAppServer.js';
4
- import { v4 as uuid } from 'uuid';
4
+ import { openBrowser } from './openBrowser.js';
5
+ /**
6
+ * Defines the "start" verb entry point.
7
+ */
5
8
  export async function start() {
6
9
  const appPath = process.cwd();
7
- const id = uuid();
8
10
  // Initialize session definition.
9
- const session = {
10
- id,
11
- appPath,
12
- type: 'web-app',
13
- mode: 'library',
14
- };
15
- // Start the bundle and html server for this session.
16
- const [bundleServer, appServer] = await Promise.all([startBundleServer(session), startAppServer()]);
11
+ const session = await createSession({ appPath });
12
+ const bundleServer = await startBundleServer(session);
13
+ const appServer = await startAppServer(session, `http://localhost:${bundleServer.port}`);
17
14
  // Close things on completion.
18
15
  process.on('SIGINT', async function () {
19
16
  bundleServer.close();
20
17
  appServer.close();
21
18
  process.exit(0);
22
19
  });
23
- // Open the browser.
20
+ // TODO: Uncomment when app server is added back. Open the browser.
24
21
  openBrowser(`http://localhost:${appServer.port}`);
25
22
  }
26
23
  //# sourceMappingURL=start.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAElB,iCAAiC;IACjC,MAAM,OAAO,GAAY;QACvB,EAAE;QACF,OAAO;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;KAChB,CAAC;IAEF,qDAAqD;IACrD,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAEpG,8BAA8B;IAC9B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK;QACxB,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,SAAS,CAAC,KAAK,EAAE,CAAC;QAClB,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"}
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;AAE/C;;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;IACjD,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,oBAAoB,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAEzF,8BAA8B;IAC9B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK;QACxB,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,SAAS,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,mEAAmE;IACnE,WAAW,CAAC,oBAAoB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
+ import type { Session } from './types.js';
2
3
  /**
3
4
  * The app server hosts the appropriate routes for the web app, primarily returning html content
4
5
  * which loads resources from the bundle server.
@@ -7,7 +8,7 @@
7
8
  * can support whichever routes the app needs, while the bundle server can provide package
8
9
  * assets in various forms using its own routing.
9
10
  */
10
- export declare function startAppServer(): Promise<{
11
+ export declare function startAppServer(session: Session, bundleServerUrl: string): Promise<{
11
12
  close: () => import("http").Server;
12
13
  port: number;
13
14
  }>;
@@ -1,6 +1,7 @@
1
1
  // import type { Session } from './types.js';
2
2
  import path from 'path';
3
3
  import { slash } from '@ms-cloudpack/path-utilities';
4
+ import { createImportMap } from '@ms-cloudpack/package-utilities';
4
5
  import { createExpressApp } from '@ms-cloudpack/create-express-app';
5
6
  /**
6
7
  * The app server hosts the appropriate routes for the web app, primarily returning html content
@@ -10,14 +11,27 @@ import { createExpressApp } from '@ms-cloudpack/create-express-app';
10
11
  * can support whichever routes the app needs, while the bundle server can provide package
11
12
  * assets in various forms using its own routing.
12
13
  */
13
- export async function startAppServer() {
14
+ export async function startAppServer(session, bundleServerUrl) {
15
+ const importMap = await createImportMap(session.resolveMap, bundleServerUrl);
14
16
  const { server, port } = await createExpressApp([5000, 5001, 5002, 5003], (app) => {
15
17
  // Set up the express app routes.
16
18
  app.get('*', async (req, res) => {
17
19
  const requestPath = slash(req.path.substring(1));
18
20
  const requestExt = path.extname(requestPath);
21
+ const entryScript = `${bundleServerUrl}/session/app/lib/index.js`; // getEntryScript(requestPath);
19
22
  console.log(`App server: Request: ${requestPath}, ext: ${requestExt}, ${port}`);
20
- res.send(`<html><body>hello</body></html>`);
23
+ res.cookie('cloudpack-session-id', session.id);
24
+ res.set('Content-Security-Policy', `connect-src 'self' ws:;`);
25
+ res.send(`
26
+ <html>
27
+ <head>
28
+ <script type="importmap">${JSON.stringify(importMap, null, 2)}</script>
29
+ </head>
30
+ <body>
31
+ <script type="module" src="${entryScript}"></script>
32
+ </body>
33
+ </html>
34
+ `);
21
35
  });
22
36
  });
23
37
  return {
@@ -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,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,gBAAgB,CAAC,CAAC,IAAI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,EAAE;QAChF,iCAAiC;QACjC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;YAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC7C,MAAM,WAAW,GAAG,GAAG,eAAe,2BAA2B,CAAC,CAAC,+BAA+B;YAElG,OAAO,CAAC,GAAG,CAAC,wBAAwB,WAAW,UAAU,UAAU,KAAK,IAAI,EAAE,CAAC,CAAC;YAEhF,GAAG,CAAC,MAAM,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;YAC/C,GAAG,CAAC,GAAG,CAAC,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;YAE9D,GAAG,CAAC,IAAI,CAAC;;;qCAGsB,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;;;uCAGhC,WAAW;;;OAG3C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,63 +1,70 @@
1
1
  import { bundlePackage } from '@ms-cloudpack/bundler';
2
2
  import { createExpressApp } from '@ms-cloudpack/create-express-app';
3
3
  import { readJson, writeJsonSync } from '@ms-cloudpack/json-utilities';
4
- import { createResolveMap, isExternalPackage } from '@ms-cloudpack/package-utilities';
4
+ import { isExternalPackage } from '@ms-cloudpack/package-utilities';
5
5
  import { slash } from '@ms-cloudpack/path-utilities';
6
6
  import filenamify from 'filenamify';
7
- import { ensureDir } from 'fs-extra';
7
+ import fsExtra from 'fs-extra';
8
8
  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
+ const { ensureDir } = fsExtra;
12
13
  const bundleLookupPath = path.join(os.tmpdir(), 'cloudpack-output', 'all-bundles.json');
13
14
  export async function startBundleServer(session) {
14
- const { appPath } = session;
15
- const bundleActions = (await readJson(bundleLookupPath)) || {};
16
- const pendingActions = {};
17
- // Grab the installed dependency locations.
18
- console.log(`BundleServer: Resolving dependencies...`);
19
- const { resolveMap, stats } = await createResolveMap({ appPath });
20
- console.log(`BundleServer: Resolved dependencies.`, stats);
15
+ const createdBundles = (await readJson(bundleLookupPath)) || {};
16
+ const pendingBundles = {};
17
+ const { resolveMap } = session;
21
18
  const { server, port } = await createExpressApp([5500, 5501, 5502, 5503], (app) => {
22
19
  // Set up the express app routes.
23
20
  app.get('*', async (req, res) => {
24
21
  const requestPath = slash(req.path.substring(1));
25
- const requestExt = path.extname(requestPath);
26
- const requestInfo = parseRequestInfo(requestPath);
27
- const packagePath = resolveMap[requestInfo.packageName]?.path;
22
+ const { packageName, version, filePath } = parseRequestInfo(requestPath);
23
+ const packagePath = resolveMap[`${packageName}@${version}`]?.path;
28
24
  const isExternal = isExternalPackage(packagePath);
29
25
  const force = req.query.force;
30
- console.log(`BundleServer: Request: "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
31
- // If there are invalid arguments, 400.
32
- if (!requestPath || !requestExt || !requestInfo.packageName || !requestInfo.version) {
33
- console.log(`BundleServer: Response (400): "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
26
+ console.log(`BundleServer: Request: "${packageName}@${version}${filePath}"`);
27
+ // If the package is missing, invalid arguments.
28
+ if (!requestPath || !packageName) {
29
+ console.log(`BundleServer: Response (400): "${packageName}@${version}${filePath}"`);
34
30
  res.status(400).send(`Requests must be in the format "/{packageName}@{version}/path/file.ext".`);
35
31
  return;
36
32
  }
33
+ // If the version is missing, redirect to the primary version.
34
+ if (!version) {
35
+ const resolvedPackage = resolveMap[packageName];
36
+ if (!resolvedPackage) {
37
+ console.log(`BundleServer: Response (404): Unrecognized package "${packageName}"`);
38
+ res.status(404).send(`Unrecognized package "${packageName}".`);
39
+ return;
40
+ }
41
+ res.redirect(`/${packageName}@${resolvedPackage.version}/${filePath}`);
42
+ return;
43
+ }
37
44
  // If it's an unrecognized package, 404.
38
45
  if (!packagePath) {
39
- console.log(`BundleServer: Response (404): "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
46
+ console.log(`BundleServer: Response (404): "${packageName}@${version}${filePath}"`);
40
47
  res.status(404).send(`The requested package "${packagePath}" is not available.`);
41
48
  return;
42
49
  }
43
50
  // Create an identifier for the bundle.
44
51
  const bundleId = hash({
45
- name: requestInfo.packageName,
46
- version: isExternal ? requestInfo.version : packagePath,
52
+ name: packageName,
53
+ version: isExternal ? version : packagePath,
47
54
  mode: session.mode,
48
55
  });
49
56
  // Derive where the output should be.
50
- const outputPath = path.join(os.tmpdir(), 'cloudpack-output', `${filenamify(requestInfo.packageName)}-${session.mode}-${requestInfo.version}-${bundleId}`);
51
- let action = bundleActions[bundleId];
57
+ const outputPath = path.join(os.tmpdir(), 'cloudpack-output', `${filenamify(packageName)}-${session.mode}-${version}-${bundleId}`);
58
+ let action = createdBundles[bundleId];
52
59
  // If we haven't completed this bundle, enqueue it or piggyback on an existing run.
53
60
  if (!action || force) {
54
- let pendingAction = pendingActions[bundleId];
61
+ let pendingAction = pendingBundles[bundleId];
55
62
  // Either latch on to a pending request or create a new one.
56
63
  if (!pendingAction) {
57
- pendingAction = pendingActions[bundleId] = new Promise((resolve) => {
58
- // Define a helper function so that we can await on async operations.
64
+ pendingAction = pendingBundles[bundleId] = new Promise((resolve) => {
65
+ // Async helper so that we can await and call resolve.
59
66
  async function createBundle() {
60
- console.log(`BundleServer: No previous action found, bundling: "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
67
+ console.log(`BundleServer: No previous action found, bundling: "${packageName}@${version}${filePath}"`);
61
68
  await ensureDir(outputPath);
62
69
  const bundlerResult = await bundlePackage({
63
70
  packagePath,
@@ -65,44 +72,46 @@ export async function startBundleServer(session) {
65
72
  outputType: 'library',
66
73
  });
67
74
  console.log(`BundleServer: Bundle complete: ${outputPath}`);
68
- bundleActions[bundleId] = {
75
+ createdBundles[bundleId] = {
69
76
  id: bundleId,
70
- packageName: requestInfo.packageName,
71
- packageVersion: requestInfo.version,
77
+ packageName: packageName,
78
+ packageVersion: version,
79
+ packagePath,
72
80
  outputPath,
73
81
  result: bundlerResult.errors?.length == 0 ? 'success' : 'errors',
74
82
  errors: bundlerResult.errors,
75
83
  warnings: bundlerResult.warnings,
76
84
  };
77
- delete pendingActions[bundleId];
78
- return bundleActions[bundleId];
85
+ delete pendingBundles[bundleId];
86
+ return createdBundles[bundleId];
79
87
  }
80
88
  // Call the async function and tie it in with the promise.
81
89
  createBundle().then(resolve);
82
90
  });
83
91
  }
84
92
  else {
85
- console.log(`BundleServer: Previous action found, waiting: "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
93
+ console.log(`BundleServer: Previous action found, waiting: "${packageName}@${version}${filePath}"`);
86
94
  }
87
95
  action = await pendingAction;
88
96
  }
89
97
  else {
90
- console.log(`BundleServer: Bundle cached, returning: "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
98
+ console.log(`BundleServer: Bundle cached, returning: "${packageName}@${version}${filePath}"`);
91
99
  }
92
100
  // At this point we should have an action compeleted.
93
101
  if (action.result === 'errors') {
94
102
  res.status(500).type('json').send(action);
95
103
  }
96
104
  else {
97
- console.log(`BundleServer: Bundle returning: "${requestInfo.packageName}@${requestInfo.version}${requestInfo.filePath}"`);
105
+ console.log(`BundleServer: Bundle returning: "${packageName}@${version}${filePath}"`);
98
106
  // Try to return the result.
99
- res.sendFile(path.join(outputPath, requestInfo.filePath));
107
+ res.sendFile(path.join(outputPath, filePath));
100
108
  }
101
109
  });
102
110
  });
111
+ console.log(`Bundle server started (http://localhost:${port})`);
103
112
  return {
104
113
  close: () => {
105
- writeJsonSync(bundleLookupPath, bundleActions);
114
+ writeJsonSync(bundleLookupPath, createdBundles);
106
115
  server.close();
107
116
  },
108
117
  port,
@@ -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;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AAexF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAgB;IACtD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,aAAa,GAAiC,CAAC,MAAM,QAAQ,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,MAAM,cAAc,GAA0C,EAAE,CAAC;IAEjE,2CAA2C;IAC3C,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAEvD,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAA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,CAAC;aAC9B;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,4CAA4C,WAAW,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC;aAC/F;YAED,qDAAqD;YACrD,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;gBAC9B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC3C;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,oCAAoC,WAAW,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC;gBACtF,4BAA4B;gBAC5B,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,2CAA2C,IAAI,GAAG,CAAC,CAAC;IAEhE,OAAO;QACL,KAAK,EAAE,GAAG,EAAE;YACV,aAAa,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;YAChD,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { ResolveMap } from '@ms-cloudpack/package-utilities';
1
2
  export interface Session {
2
3
  /**
3
4
  * The session id, used for identifying
@@ -21,4 +22,8 @@ export interface Session {
21
22
  * the browser.
22
23
  */
23
24
  mode: 'library' | 'development' | 'production';
25
+ /**
26
+ * Used to resolve packages in the dependency graph.
27
+ */
28
+ resolveMap: ResolveMap;
24
29
  }
@@ -0,0 +1 @@
1
+ export declare function getVersion(): string;
@@ -0,0 +1,10 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { findPackageRoot } from '@ms-cloudpack/path-utilities';
4
+ import { readJsonSync } from '@ms-cloudpack/json-utilities';
5
+ export function getVersion() {
6
+ const packageJSONpath = path.join(findPackageRoot(path.dirname(fileURLToPath(import.meta.url))), 'package.json');
7
+ const definition = readJsonSync(packageJSONpath);
8
+ return definition.version;
9
+ }
10
+ //# sourceMappingURL=getVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVersion.js","sourceRoot":"","sources":["../src/getVersion.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,MAAM,UAAU,UAAU;IACxB,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACjH,MAAM,UAAU,GAAG,YAAY,CAAC,eAAe,CAAsB,CAAC;IAEtE,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1,5 @@
1
+ /**
2
+ * Entry point for the cloudpack CLI. Resolves all commands defined
3
+ * within the "./commands" folder.
4
+ */
1
5
  export declare function start(): Promise<void>;
package/lib/index.js CHANGED
@@ -2,15 +2,23 @@ import { Command } from 'commander';
2
2
  import glob from 'glob';
3
3
  import path from 'path';
4
4
  import { fileURLToPath, pathToFileURL } from 'url';
5
+ import { getVersion } from './getVersion.js';
5
6
  const currentPath = path.dirname(fileURLToPath(import.meta.url));
7
+ /**
8
+ * Entry point for the cloudpack CLI. Resolves all commands defined
9
+ * within the "./commands" folder.
10
+ */
6
11
  export async function start() {
7
12
  const program = new Command();
8
- program.name('cloudpack').usage('<command> [options]');
13
+ program.name('cloudpack').version(getVersion()).usage('<command> [options]');
9
14
  const commands = glob.sync('commands/*/index.js', { cwd: currentPath });
10
15
  for (const commandPath of commands) {
11
16
  const command = await import(pathToFileURL(path.resolve(currentPath, commandPath)).toString());
12
17
  command.init(program);
13
18
  }
14
19
  program.parse(process.argv);
20
+ if (program.args.length === 0) {
21
+ program.help();
22
+ }
15
23
  }
16
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAExE,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE;QAClC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE/F,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACvB;IAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAE7E,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAExE,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE;QAClC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE/F,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACvB;IAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;KAChB;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.0.6",
3
+ "version": "0.1.1",
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,11 @@
16
16
  "cloudpack": "./lib/cloudpack.js"
17
17
  },
18
18
  "dependencies": {
19
- "@ms-cloudpack/bundler": "^0.0.6",
20
- "@ms-cloudpack/create-express-app": "^0.0.2",
19
+ "@ms-cloudpack/bundler": "^0.1.1",
20
+ "@ms-cloudpack/create-express-app": "^0.1.0",
21
21
  "@ms-cloudpack/json-utilities": "^0.0.3",
22
- "@ms-cloudpack/package-utilities": "^0.1.6",
23
- "@ms-cloudpack/path-utilities": "^0.1.0",
22
+ "@ms-cloudpack/package-utilities": "^0.3.0",
23
+ "@ms-cloudpack/path-utilities": "^0.2.0",
24
24
  "commander": "^9.1.0",
25
25
  "filenamify": "^5.1.0",
26
26
  "fs-extra": "^10.1.0",
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.24.0"
9
- }
10
- ]
11
- }