@ms-cloudpack/cli 0.74.5 → 0.74.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAmH/C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAgI/C,CAAC"}
@@ -9,6 +9,8 @@ import { trackSession } from './trackSession.js';
9
9
  import { getCliStartTime } from '../../utilities/getCliStartTime.js';
10
10
  import { createApiServer } from '../../utilities/createApiServer.js';
11
11
  import { resolveCloudpackInternalPath } from '../../utilities/resolveCloudpackInternalPath.js';
12
+ import { getDomain, parseHttpsConfig } from '@ms-cloudpack/create-express-app';
13
+ import { handleKnownParseHttpsErrors } from '../../utilities/handleKnownParseHttpsErrors.js';
12
14
  /**
13
15
  * Defines the "start" verb entry point.
14
16
  */
@@ -17,6 +19,19 @@ export const execute = async (params) => {
17
19
  console.log('App path:', yellow(appPath));
18
20
  console.log('Bundle mode:', yellow(options.mode));
19
21
  await runPrerequisites(params);
22
+ // If the user has specified https options in the config, parse them at start.
23
+ // This makes sure that the HTTPS configuration is ready before starting the servers and shows errors early.
24
+ // We need to do this after prerequisites are run, in case users setup their certs there.
25
+ if (config?.server?.https) {
26
+ try {
27
+ const domain = getDomain(config.server.domain);
28
+ config.server.parsedHttps = await parseHttpsConfig({ domain, https: config.server.https, cwd: appPath });
29
+ }
30
+ catch (err) {
31
+ handleKnownParseHttpsErrors({ err, projectName: path.basename(appPath) });
32
+ throw err;
33
+ }
34
+ }
20
35
  const overlayPath = await resolveCloudpackInternalPath({
21
36
  packageName: '@ms-cloudpack/overlay',
22
37
  importMetaUrl: import.meta.url,
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAgC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI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,GAAG,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;gBACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAG,GAAyB,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;gBACjF,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,IAAI,CAAC,CAAC,kCAAkC;AACjD,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import { createApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCliStartTime } from '../../utilities/getCliStartTime.js';\nimport { createApiServer } from '../../utilities/createApiServer.js';\nimport { resolveCloudpackInternalPath } from '../../utilities/resolveCloudpackInternalPath.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { appPath, config, options, autoDispose } = params;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n await runPrerequisites(params);\n\n const overlayPath = await resolveCloudpackInternalPath({\n packageName: '@ms-cloudpack/overlay',\n importMetaUrl: import.meta.url,\n });\n\n const shouldUseRemoteCache = config.features?.enableCloudHosted || config.features?.enableRemoteCacheDownloads;\n const apiContext = autoDispose(\n await createApiContext({\n ...params,\n remoteCacheClientLoginMethod: shouldUseRemoteCache ? options.login : undefined,\n additionalPaths: overlayPath ? [overlayPath] : undefined,\n }),\n );\n const { packages, session, telemetryClient } = 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 (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer({ port: options.apiServerPort }, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({ name: definition.name, version: definition.version }, apiContext);\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\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 await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n // Log the time elapsed from when the CLI started until the browser is ready to be opened.\n await telemetryClient.tracer.startActiveSpan(\n 'TIME_TO_OPEN_BROWSER',\n { startTime: getCliStartTime(), attributes: { open: options.open } },\n () => {\n // Open the browser.\n if (options.open === false) {\n console.log('Please open the browser manually to:', defaultUrl);\n } else {\n let urlToOpen: string;\n if (typeof options.open === 'string') {\n // If the string doesn't start with http or https, pick a protocol based on config.server.https\n if (!options.open.startsWith('http://') && !options.open.startsWith('https://')) {\n urlToOpen = `${config.server?.https ? 'https' : 'http'}://${options.open}`;\n } else {\n urlToOpen = options.open;\n }\n } else {\n // Use the default path from the config with the first domain.\n urlToOpen = defaultUrl;\n }\n\n void openBrowser({ url: urlToOpen }, apiContext).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n }\n },\n );\n\n return null; // the command should keep running\n};\n\n// cspell:ignore Prereqs\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAE7F;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAgC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MA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AC3B,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACN,IAAI,SAAiB,CAAC;YACtB,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,+FAA+F;gBAC/F,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oBAChF,SAAS,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;gBAC7E,CAAC;qBAAM,CAAC;oBACN,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;gBAC3B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,8DAA8D;gBAC9D,SAAS,GAAG,UAAU,CAAC;YACzB,CAAC;YAED,KAAK,WAAW,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;gBACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAG,GAAyB,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;gBACjF,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,IAAI,CAAC,CAAC,kCAAkC;AACjD,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import { createApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCliStartTime } from '../../utilities/getCliStartTime.js';\nimport { createApiServer } from '../../utilities/createApiServer.js';\nimport { resolveCloudpackInternalPath } from '../../utilities/resolveCloudpackInternalPath.js';\nimport { getDomain, parseHttpsConfig } from '@ms-cloudpack/create-express-app';\nimport { handleKnownParseHttpsErrors } from '../../utilities/handleKnownParseHttpsErrors.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { appPath, config, options, autoDispose } = params;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n await runPrerequisites(params);\n\n // If the user has specified https options in the config, parse them at start.\n // This makes sure that the HTTPS configuration is ready before starting the servers and shows errors early.\n // We need to do this after prerequisites are run, in case users setup their certs there.\n if (config?.server?.https) {\n try {\n const domain = getDomain(config.server.domain);\n config.server.parsedHttps = await parseHttpsConfig({ domain, https: config.server.https, cwd: appPath });\n } catch (err) {\n handleKnownParseHttpsErrors({ err, projectName: path.basename(appPath) });\n throw err;\n }\n }\n\n const overlayPath = await resolveCloudpackInternalPath({\n packageName: '@ms-cloudpack/overlay',\n importMetaUrl: import.meta.url,\n });\n\n const shouldUseRemoteCache = config.features?.enableCloudHosted || config.features?.enableRemoteCacheDownloads;\n const apiContext = autoDispose(\n await createApiContext({\n ...params,\n remoteCacheClientLoginMethod: shouldUseRemoteCache ? options.login : undefined,\n additionalPaths: overlayPath ? [overlayPath] : undefined,\n }),\n );\n const { packages, session, telemetryClient } = 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 (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer({ port: options.apiServerPort }, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({ name: definition.name, version: definition.version }, apiContext);\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\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 await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n // Log the time elapsed from when the CLI started until the browser is ready to be opened.\n await telemetryClient.tracer.startActiveSpan(\n 'TIME_TO_OPEN_BROWSER',\n { startTime: getCliStartTime(), attributes: { open: options.open } },\n () => {\n // Open the browser.\n if (options.open === false) {\n console.log('Please open the browser manually to:', defaultUrl);\n } else {\n let urlToOpen: string;\n if (typeof options.open === 'string') {\n // If the string doesn't start with http or https, pick a protocol based on config.server.https\n if (!options.open.startsWith('http://') && !options.open.startsWith('https://')) {\n urlToOpen = `${config.server?.https ? 'https' : 'http'}://${options.open}`;\n } else {\n urlToOpen = options.open;\n }\n } else {\n // Use the default path from the config with the first domain.\n urlToOpen = defaultUrl;\n }\n\n void openBrowser({ url: urlToOpen }, apiContext).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n }\n },\n );\n\n return null; // the command should keep running\n};\n\n// cspell:ignore Prereqs\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Handle known parse https errors.
3
+ */
4
+ export declare function handleKnownParseHttpsErrors(params: {
5
+ err: unknown;
6
+ projectName: string;
7
+ }): void;
8
+ //# sourceMappingURL=handleKnownParseHttpsErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleKnownParseHttpsErrors.d.ts","sourceRoot":"","sources":["../../src/utilities/handleKnownParseHttpsErrors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAoB/F"}
@@ -0,0 +1,30 @@
1
+ import { bold, cyan } from '@ms-cloudpack/task-reporter';
2
+ /**
3
+ * Handle known parse https errors.
4
+ */
5
+ export function handleKnownParseHttpsErrors(params) {
6
+ const { err } = params;
7
+ if (!err || !(err instanceof Error)) {
8
+ // If the error is not an instance of Error, we can't handle it.
9
+ return;
10
+ }
11
+ // If a known error occurs, we can provide a more user-friendly message.
12
+ // and we can also suppress the stack trace for these errors because it's not useful to the user.
13
+ if (err.message.startsWith('The specified certificate to be used for the web server is missing')) {
14
+ err.message = `Cloudpack could not start because ${lowerCaseFirstLetter(err.message)}`;
15
+ err.stack = undefined;
16
+ }
17
+ else if (err.message.startsWith('No certificate found for the domain')) {
18
+ err.message =
19
+ `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\n\n` +
20
+ `Run "${cyan(bold('cloudpack setup'))}" to create the required certificate and try start again.`;
21
+ err.stack = undefined;
22
+ }
23
+ else if (err.message === 'Must provide at least one domain in "domain" option to get certificate paths.') {
24
+ err.message = `Cloudpack could not start because the "domain" option was not provided or was empty. \nThis is a Cloudpack bug, please report it!`;
25
+ }
26
+ }
27
+ function lowerCaseFirstLetter(str) {
28
+ return str.charAt(0).toLowerCase() + str.slice(1);
29
+ }
30
+ //# sourceMappingURL=handleKnownParseHttpsErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleKnownParseHttpsErrors.js","sourceRoot":"","sources":["../../src/utilities/handleKnownParseHttpsErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAA6C;IACvF,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE,CAAC;QACpC,gEAAgE;QAChE,OAAO;IACT,CAAC;IAED,wEAAwE;IACxE,iGAAiG;IACjG,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,oEAAoE,CAAC,EAAE,CAAC;QACjG,GAAG,CAAC,OAAO,GAAG,qCAAqC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACvF,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IACxB,CAAC;SAAM,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,qCAAqC,CAAC,EAAE,CAAC;QACzE,GAAG,CAAC,OAAO;YACT,gGAAgG;gBAChG,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,2DAA2D,CAAC;QACnG,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IACxB,CAAC;SAAM,IAAI,GAAG,CAAC,OAAO,KAAK,+EAA+E,EAAE,CAAC;QAC3G,GAAG,CAAC,OAAO,GAAG,mIAAmI,CAAC;IACpJ,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { bold, cyan } from '@ms-cloudpack/task-reporter';\n\n/**\n * Handle known parse https errors.\n */\nexport function handleKnownParseHttpsErrors(params: { err: unknown; projectName: string }): void {\n const { err } = params;\n if (!err || !(err instanceof Error)) {\n // If the error is not an instance of Error, we can't handle it.\n return;\n }\n\n // If a known error occurs, we can provide a more user-friendly message.\n // and we can also suppress the stack trace for these errors because it's not useful to the user.\n if (err.message.startsWith('The specified certificate to be used for the web server is missing')) {\n err.message = `Cloudpack could not start because ${lowerCaseFirstLetter(err.message)}`;\n err.stack = undefined;\n } else if (err.message.startsWith('No certificate found for the domain')) {\n err.message =\n `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.`;\n err.stack = undefined;\n } else if (err.message === 'Must provide at least one domain in \"domain\" option to get certificate paths.') {\n err.message = `Cloudpack could not start because the \"domain\" option was not provided or was empty. \\nThis is a Cloudpack bug, please report it!`;\n }\n}\n\nfunction lowerCaseFirstLetter(str: string): string {\n return str.charAt(0).toLowerCase() + str.slice(1);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.74.5",
3
+ "version": "0.74.6",
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,23 +10,24 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.63.2",
14
- "@ms-cloudpack/app-server": "^0.18.5",
15
- "@ms-cloudpack/bundler": "^0.25.4",
16
- "@ms-cloudpack/bundler-capabilities": "^0.2.24",
17
- "@ms-cloudpack/common-types": "^0.24.18",
18
- "@ms-cloudpack/config": "^0.35.5",
13
+ "@ms-cloudpack/api-server": "^0.63.3",
14
+ "@ms-cloudpack/app-server": "^0.18.6",
15
+ "@ms-cloudpack/bundler": "^0.25.5",
16
+ "@ms-cloudpack/bundler-capabilities": "^0.2.25",
17
+ "@ms-cloudpack/common-types": "^0.24.19",
18
+ "@ms-cloudpack/config": "^0.35.6",
19
+ "@ms-cloudpack/create-express-app": "^1.10.33",
19
20
  "@ms-cloudpack/environment": "^0.1.1",
20
21
  "@ms-cloudpack/json-utilities": "^0.1.10",
21
- "@ms-cloudpack/link-proxy": "^0.2.4",
22
- "@ms-cloudpack/overlay": "^0.19.0",
23
- "@ms-cloudpack/package-utilities": "^12.3.7",
22
+ "@ms-cloudpack/link-proxy": "^0.2.5",
23
+ "@ms-cloudpack/overlay": "^0.19.1",
24
+ "@ms-cloudpack/package-utilities": "^12.3.8",
24
25
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
25
- "@ms-cloudpack/path-utilities": "^3.1.3",
26
- "@ms-cloudpack/remote-cache": "^0.11.16",
27
- "@ms-cloudpack/setup-utilities": "^0.5.25",
26
+ "@ms-cloudpack/path-utilities": "^3.1.4",
27
+ "@ms-cloudpack/remote-cache": "^0.11.17",
28
+ "@ms-cloudpack/setup-utilities": "^0.5.26",
28
29
  "@ms-cloudpack/task-reporter": "^0.16.3",
29
- "@ms-cloudpack/telemetry": "^0.11.19",
30
+ "@ms-cloudpack/telemetry": "^0.11.20",
30
31
  "@yarnpkg/lockfile": "^1.1.0",
31
32
  "commander": "^13.0.0",
32
33
  "cross-spawn": "^7.0.3",
@@ -39,7 +40,7 @@
39
40
  "workspace-tools": "^0.38.0"
40
41
  },
41
42
  "devDependencies": {
42
- "@ms-cloudpack/common-types": "^0.24.18",
43
+ "@ms-cloudpack/common-types": "^0.24.19",
43
44
  "@ms-cloudpack/common-types-browser": "^0.6.0",
44
45
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
45
46
  "@ms-cloudpack/scripts": "^0.0.1",