@ms-cloudpack/cli 0.61.0 → 0.61.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.
@@ -0,0 +1,3 @@
1
+ import type { Session } from '@ms-cloudpack/api-server';
2
+ export declare function createMockSession(id?: string): Session;
3
+ //# sourceMappingURL=createMockSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMockSession.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,wBAAgB,iBAAiB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAqBtD"}
@@ -0,0 +1,23 @@
1
+ export function createMockSession(id) {
2
+ return {
3
+ id: id || 'session-id',
4
+ appPath: '/path/to/app',
5
+ config: { generated: {} },
6
+ projectName: 'app',
7
+ type: 'web-app',
8
+ mode: 'library',
9
+ resolveMap: {},
10
+ sequence: 0,
11
+ urls: {
12
+ appServer: '',
13
+ apiServer: '',
14
+ bundleServer: '',
15
+ },
16
+ targetVersions: {},
17
+ sessionVersion: 1,
18
+ incrementSessionVersion: () => { },
19
+ incrementTargetVersion: () => { },
20
+ importMap: { imports: {} },
21
+ };
22
+ }
23
+ //# sourceMappingURL=createMockSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMockSession.js","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,EAAW;IAC3C,OAAO;QACL,EAAE,EAAE,EAAE,IAAI,YAAY;QACtB,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QACzB,WAAW,EAAE,KAAK;QAClB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE;YACJ,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;SACjB;QACD,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,CAAC;QACjB,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;QACjC,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;QAChC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\n\nexport function createMockSession(id?: string): Session {\n return {\n id: id || 'session-id',\n appPath: '/path/to/app',\n config: { generated: {} },\n projectName: 'app',\n type: 'web-app',\n mode: 'library',\n resolveMap: {},\n sequence: 0,\n urls: {\n appServer: '',\n apiServer: '',\n bundleServer: '',\n },\n targetVersions: {},\n sessionVersion: 1,\n incrementSessionVersion: () => {},\n incrementTargetVersion: () => {},\n importMap: { imports: {} },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,8BAA8B,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAe5D,wDAAwD;AACxD,wBAAsB,WAAW,kBAKhC;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAqH/C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,8BAA8B,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAgB5D,wDAAwD;AACxD,wBAAsB,WAAW,kBAKhC;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CA2H/C,CAAC"}
@@ -8,6 +8,7 @@ import { getStartingAppPath } from './getStartingAppPath.js';
8
8
  import { openBrowser } from './openBrowser.js';
9
9
  import { runPrerequisites } from '../../utilities/runPrerequisites.js';
10
10
  import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';
11
+ import { trackSession } from './trackSession.js';
11
12
  let exitFunction;
12
13
  /** Stop all started cloudpack instances, for testing */
13
14
  export async function stopServers() {
@@ -55,6 +56,7 @@ export const execute = async (params) => {
55
56
  const { startApiServer } = await import('@ms-cloudpack/api-server');
56
57
  // Start api server for tracking status and handling remote requests.
57
58
  const apiServer = await startApiServer(apiContext);
59
+ session.urls.apiServer = apiServer.url;
58
60
  // Kick off bundling app package as soon as api server is ready.
59
61
  void ensurePackageBundled({
60
62
  input: { name: definition.name, version: definition.version },
@@ -65,24 +67,27 @@ export const execute = async (params) => {
65
67
  const bundleServer = await startBundleServer({
66
68
  context: {
67
69
  ...apiContext,
68
- apiServer,
69
70
  disableCache: !options.cache,
70
71
  },
71
72
  });
73
+ session.urls.bundleServer = bundleServer.url;
72
74
  // Finally start the app server.
73
75
  const { startAppServer } = await import('@ms-cloudpack/app-server');
74
76
  const appServer = await startAppServer({
75
77
  session,
76
78
  definition,
77
- bundleServer,
78
- apiServer,
79
79
  config,
80
80
  reporter,
81
81
  packages,
82
82
  packageImportPaths,
83
83
  packageHashes: apiContext.packageHashes,
84
84
  });
85
+ session.urls.appServer = appServer.url;
86
+ // Save the session to active sessions.
87
+ const sessionTracker = await trackSession(session);
85
88
  const cleanup = async () => {
89
+ // Stop tracking the session.
90
+ await sessionTracker.close();
86
91
  const servers = [
87
92
  ['appServer', appServer],
88
93
  ['apiServer', apiServer],
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC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AAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAChD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAClC,YAAY,GAAG,IAAI,CAAC;IAEpB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpF,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;IAEpE,oBAAoB;IACpB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACpC,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import type { CommandAction, CommandActionParams } from '../../types/CommandAction.js';\nimport type { StartOptions } from './types/StartOptions.js';\n\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { resolve } from '@ms-cloudpack/package-utilities';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\n\nlet exitFunction: CommandActionParams<StartOptions>['exit'] | undefined;\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, reporter, autoDispose, exit } = params;\n const appPath = await getStartingAppPath(cwd, options.app);\n const { config, telemetryClient } = await initialize({ appPath });\n\n console.log('App path:', yellow(appPath));\n\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath: await resolve('@ms-cloudpack/overlay', path.dirname(fileURLToPath(import.meta.url))),\n }),\n );\n const { packages, session, packageImportPaths } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer(apiContext);\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('@ms-cloudpack/bundle-server');\n const bundleServer = await startBundleServer({\n context: {\n ...apiContext,\n apiServer,\n disableCache: !options.cache,\n },\n });\n\n // Finally start the app server.\n const { startAppServer } = await import('@ms-cloudpack/app-server');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n reporter,\n packages,\n packageImportPaths,\n packageHashes: apiContext.packageHashes,\n });\n\n const cleanup = async () => {\n const servers = [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ];\n\n await Promise.all(\n servers.map(async ([name, server]) => {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n console.info(`Closed ${name}: ${server.url}`);\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n exitFunction = exit;\n\n const defaultUrl = new URL(config.devServer?.defaultPath || '', appServer.url).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO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AAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import type { CommandAction, CommandActionParams } from '../../types/CommandAction.js';\nimport type { StartOptions } from './types/StartOptions.js';\n\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { resolve } from '@ms-cloudpack/package-utilities';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { trackSession } from './trackSession.js';\n\nlet exitFunction: CommandActionParams<StartOptions>['exit'] | undefined;\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, reporter, autoDispose, exit } = params;\n const appPath = await getStartingAppPath(cwd, options.app);\n const { config, telemetryClient } = await initialize({ appPath });\n\n console.log('App path:', yellow(appPath));\n\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath: await resolve('@ms-cloudpack/overlay', path.dirname(fileURLToPath(import.meta.url))),\n }),\n );\n const { packages, session, packageImportPaths } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer(apiContext);\n session.urls.apiServer = apiServer.url;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('@ms-cloudpack/bundle-server');\n const bundleServer = await startBundleServer({\n context: {\n ...apiContext,\n disableCache: !options.cache,\n },\n });\n session.urls.bundleServer = bundleServer.url;\n\n // Finally start the app server.\n const { startAppServer } = await import('@ms-cloudpack/app-server');\n const appServer = await startAppServer({\n session,\n definition,\n config,\n reporter,\n packages,\n packageImportPaths,\n packageHashes: apiContext.packageHashes,\n });\n session.urls.appServer = appServer.url;\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n const servers = [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ];\n\n await Promise.all(\n servers.map(async ([name, server]) => {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n console.info(`Closed ${name}: ${server.url}`);\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n exitFunction = exit;\n\n const defaultUrl = new URL(config.devServer?.defaultPath || '', appServer.url).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\n"]}
@@ -0,0 +1,11 @@
1
+ import type { Session } from '@ms-cloudpack/api-server';
2
+ /**
3
+ * Tracks active sessions to disk as they are started. This gives us a way to enumerate
4
+ * all active sessions for scenarios like better error messages when sessions are already
5
+ * running for a given path, or for the link verb where we want to manipulate an active
6
+ * running session.
7
+ */
8
+ export declare function trackSession(session: Session): Promise<{
9
+ close(): Promise<void>;
10
+ }>;
11
+ //# sourceMappingURL=trackSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAKxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO;;GAUlD"}
@@ -0,0 +1,19 @@
1
+ import { getSessionPath } from '@ms-cloudpack/api-server';
2
+ import { writeJson } from '@ms-cloudpack/json-utilities';
3
+ import { rm } from 'fs/promises';
4
+ /**
5
+ * Tracks active sessions to disk as they are started. This gives us a way to enumerate
6
+ * all active sessions for scenarios like better error messages when sessions are already
7
+ * running for a given path, or for the link verb where we want to manipulate an active
8
+ * running session.
9
+ */
10
+ export async function trackSession(session) {
11
+ const activeSessionPath = getSessionPath(session);
12
+ await writeJson(activeSessionPath, session);
13
+ return {
14
+ async close() {
15
+ await rm(activeSessionPath);
16
+ },
17
+ };
18
+ }
19
+ //# sourceMappingURL=trackSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAElD,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,EAAE,CAAC,iBAAiB,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getSessionPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session) {\n const activeSessionPath = getSessionPath(session);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n await rm(activeSessionPath);\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.61.0",
3
+ "version": "0.61.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",
@@ -10,16 +10,16 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.41.0",
14
- "@ms-cloudpack/app-server": "^0.4.4",
15
- "@ms-cloudpack/bundle-server": "^0.2.61",
16
- "@ms-cloudpack/common-types": "^0.4.0",
17
- "@ms-cloudpack/config": "^0.20.1",
13
+ "@ms-cloudpack/api-server": "^0.42.0",
14
+ "@ms-cloudpack/app-server": "^0.5.0",
15
+ "@ms-cloudpack/bundle-server": "^0.3.0",
16
+ "@ms-cloudpack/common-types": "^0.5.0",
17
+ "@ms-cloudpack/config": "^0.20.2",
18
18
  "@ms-cloudpack/feature-flags": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.4",
20
- "@ms-cloudpack/overlay": "^0.16.110",
21
- "@ms-cloudpack/package-utilities": "^7.4.0",
22
- "@ms-cloudpack/path-utilities": "^2.7.5",
20
+ "@ms-cloudpack/overlay": "^0.16.111",
21
+ "@ms-cloudpack/package-utilities": "^7.4.1",
22
+ "@ms-cloudpack/path-utilities": "^2.7.6",
23
23
  "@ms-cloudpack/remote-cache": "^0.7.2",
24
24
  "@ms-cloudpack/task-reporter": "^0.14.0",
25
25
  "@ms-cloudpack/telemetry": "^0.5.1",
@@ -34,7 +34,7 @@
34
34
  "workspace-tools": "^0.36.4"
35
35
  },
36
36
  "devDependencies": {
37
- "@ms-cloudpack/common-types": "^0.4.0",
37
+ "@ms-cloudpack/common-types": "^0.5.0",
38
38
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
39
39
  "@ms-cloudpack/scripts": "^0.0.1",
40
40
  "@ms-cloudpack/test-utilities": "^0.5.0",