@hubspot/cms-dev-server 1.2.77 → 1.2.78

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.
@@ -10,7 +10,7 @@ import { createServer as createViteServer } from "vite";
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-B-d4FeeE.js
13
+ // ../cms-js-internal/dist/types-Dvw_fW6p.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
package/dist/index.js CHANGED
@@ -1,9 +1,119 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __esm = (fn, res) => function __init() {
4
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
+ };
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+
11
+ // ../node_modules/@inquirer/select/dist/esm/index.mjs
12
+ var esm_exports = {};
13
+ __export(esm_exports, {
14
+ Separator: () => Separator,
15
+ default: () => esm_default
16
+ });
17
+ import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, useMemo, isEnterKey, isUpKey, isDownKey, isNumberKey, Separator, makeTheme } from "@inquirer/core";
18
+ import chalk from "chalk";
19
+ import figures from "figures";
20
+ import ansiEscapes from "ansi-escapes";
21
+ function isSelectable(item) {
22
+ return !Separator.isSeparator(item) && !item.disabled;
23
+ }
24
+ var selectTheme, esm_default;
25
+ var init_esm = __esm({
26
+ "../node_modules/@inquirer/select/dist/esm/index.mjs"() {
27
+ selectTheme = {
28
+ icon: { cursor: figures.pointer },
29
+ style: { disabled: (text) => chalk.dim(`- ${text}`) }
30
+ };
31
+ esm_default = createPrompt((config, done) => {
32
+ const { choices: items, loop = true, pageSize = 7 } = config;
33
+ const firstRender = useRef(true);
34
+ const theme = makeTheme(selectTheme, config.theme);
35
+ const prefix = usePrefix({ theme });
36
+ const [status, setStatus] = useState("pending");
37
+ const bounds = useMemo(() => {
38
+ const first = items.findIndex(isSelectable);
39
+ const last = items.length - 1 - [...items].reverse().findIndex(isSelectable);
40
+ if (first < 0)
41
+ throw new Error("[select prompt] No selectable choices. All choices are disabled.");
42
+ return { first, last };
43
+ }, [items]);
44
+ const defaultItemIndex = useMemo(() => {
45
+ if (!("default" in config))
46
+ return -1;
47
+ return items.findIndex((item) => isSelectable(item) && item.value === config.default);
48
+ }, [config.default, items]);
49
+ const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
50
+ const selectedChoice = items[active];
51
+ useKeypress((key) => {
52
+ if (isEnterKey(key)) {
53
+ setStatus("done");
54
+ done(selectedChoice.value);
55
+ } else if (isUpKey(key) || isDownKey(key)) {
56
+ if (loop || isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
57
+ const offset = isUpKey(key) ? -1 : 1;
58
+ let next = active;
59
+ do {
60
+ next = (next + offset + items.length) % items.length;
61
+ } while (!isSelectable(items[next]));
62
+ setActive(next);
63
+ }
64
+ } else if (isNumberKey(key)) {
65
+ const position = Number(key.name) - 1;
66
+ const item = items[position];
67
+ if (item != null && isSelectable(item)) {
68
+ setActive(position);
69
+ }
70
+ }
71
+ });
72
+ const message = theme.style.message(config.message);
73
+ let helpTip;
74
+ if (firstRender.current && items.length <= pageSize) {
75
+ firstRender.current = false;
76
+ helpTip = theme.style.help("(Use arrow keys)");
77
+ }
78
+ const page = usePagination({
79
+ items,
80
+ active,
81
+ renderItem({ item, isActive }) {
82
+ if (Separator.isSeparator(item)) {
83
+ return ` ${item.separator}`;
84
+ }
85
+ const line = item.name || item.value;
86
+ if (item.disabled) {
87
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
88
+ return theme.style.disabled(`${line} ${disabledLabel}`);
89
+ }
90
+ const color = isActive ? theme.style.highlight : (x) => x;
91
+ const cursor = isActive ? theme.icon.cursor : ` `;
92
+ return color(`${cursor} ${line}`);
93
+ },
94
+ pageSize,
95
+ loop,
96
+ theme
97
+ });
98
+ if (status === "done") {
99
+ const answer = selectedChoice.name || // TODO: Could we enforce that at the type level? Name should be defined for non-string values.
100
+ String(selectedChoice.value);
101
+ return `${prefix} ${message} ${theme.style.answer(answer)}`;
102
+ }
103
+ const choiceDescription = selectedChoice.description ? `
104
+ ${selectedChoice.description}` : ``;
105
+ return `${[prefix, message, helpTip].filter(Boolean).join(" ")}
106
+ ${page}${choiceDescription}${ansiEscapes.cursorHide}`;
107
+ });
108
+ }
109
+ });
110
+
1
111
  // src/createViteDevServer.ts
2
112
  import { createServer as createViteServer } from "vite";
3
113
  import { createRequire } from "module";
4
114
  import { default as react } from "@vitejs/plugin-react";
5
115
 
6
- // ../cms-js-internal/dist/types-B-d4FeeE.js
116
+ // ../cms-js-internal/dist/types-Dvw_fW6p.js
7
117
  import path from "path";
8
118
  import { createHash } from "crypto";
9
119
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -254,6 +364,13 @@ function isFullHeightPreviewEnabled(config) {
254
364
  }
255
365
  return false;
256
366
  }
367
+ function isLocalUiDisabled(config) {
368
+ var _a;
369
+ if ("devServer" in config) {
370
+ return ((_a = config.devServer) == null ? void 0 : _a.disableLocalUi) ?? false;
371
+ }
372
+ return false;
373
+ }
257
374
  var ENABLED_FEATURES_GATE_MAP = {
258
375
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
259
376
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
@@ -1650,7 +1767,7 @@ function trackUsage(action) {
1650
1767
  eventName: EVENT_NAME,
1651
1768
  action,
1652
1769
  nodeVersion: getNodeVersionData(),
1653
- version: "1.2.77",
1770
+ version: "1.2.78",
1654
1771
  os: getPlatform()
1655
1772
  };
1656
1773
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3090,8 +3207,84 @@ function extractRelevantCss(cssText) {
3090
3207
  return output;
3091
3208
  }
3092
3209
 
3210
+ // src/lib/htmlExtract.ts
3211
+ import { parse as parse2, serializeOuter } from "parse5";
3212
+ function parseHtml(html) {
3213
+ return parse2(html);
3214
+ }
3215
+ function isElement(node) {
3216
+ return typeof node.tagName === "string";
3217
+ }
3218
+ function getAttr(node, name) {
3219
+ var _a, _b;
3220
+ return (_b = (_a = node.attrs) == null ? void 0 : _a.find((a) => a.name === name)) == null ? void 0 : _b.value;
3221
+ }
3222
+ function findFirst(node, predicate) {
3223
+ if (predicate(node))
3224
+ return node;
3225
+ if (node.childNodes) {
3226
+ for (const child of node.childNodes) {
3227
+ const match = findFirst(child, predicate);
3228
+ if (match)
3229
+ return match;
3230
+ }
3231
+ }
3232
+ return null;
3233
+ }
3234
+ function findAll(node, predicate) {
3235
+ const out = [];
3236
+ const visit = (n) => {
3237
+ var _a;
3238
+ if (predicate(n))
3239
+ out.push(n);
3240
+ (_a = n.childNodes) == null ? void 0 : _a.forEach(visit);
3241
+ };
3242
+ visit(node);
3243
+ return out;
3244
+ }
3245
+ function textContent(node) {
3246
+ let out = "";
3247
+ const visit = (n) => {
3248
+ var _a;
3249
+ if (n.nodeName === "#text" && typeof n.value === "string")
3250
+ out += n.value;
3251
+ (_a = n.childNodes) == null ? void 0 : _a.forEach(visit);
3252
+ };
3253
+ visit(node);
3254
+ return out;
3255
+ }
3256
+ function hasAncestor(node, predicate) {
3257
+ let p = node.parentNode;
3258
+ while (p) {
3259
+ if (predicate(p))
3260
+ return true;
3261
+ p = p.parentNode ?? null;
3262
+ }
3263
+ return false;
3264
+ }
3265
+ function extractModuleOuterHtml(root) {
3266
+ const el = findFirst(
3267
+ root,
3268
+ (n) => isElement(n) && n.tagName === "div" && getAttr(n, "data-hs-cos-type") === "module"
3269
+ );
3270
+ if (!el) {
3271
+ throw new Error(
3272
+ 'module node (div[data-hs-cos-type="module"]) not found in preview HTML'
3273
+ );
3274
+ }
3275
+ return serializeOuter(el);
3276
+ }
3277
+ function extractStyleText(root, opts = {}) {
3278
+ let styles = findAll(root, (n) => isElement(n) && n.tagName === "style");
3279
+ if (opts.headOnly) {
3280
+ styles = styles.filter(
3281
+ (s) => hasAncestor(s, (a) => isElement(a) && a.tagName === "head")
3282
+ );
3283
+ }
3284
+ return styles.map((s) => textContent(s)).join("\n");
3285
+ }
3286
+
3093
3287
  // src/lib/renderModulePreview.ts
3094
- import jsdom from "jsdom";
3095
3288
  var DEFAULT_SECTION_VARIANT = "section1";
3096
3289
  var _webDefaultStylesCss = null;
3097
3290
  function getWebDefaultStylesCss(metaUrl) {
@@ -3153,7 +3346,6 @@ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
3153
3346
  }
3154
3347
  return await response.text();
3155
3348
  }
3156
- var { JSDOM } = jsdom;
3157
3349
  async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
3158
3350
  const moduleInfoQueryParams = new URLSearchParams({
3159
3351
  portalId: `${authedPortalId}`
@@ -3206,13 +3398,9 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3206
3398
  }
3207
3399
  }
3208
3400
  }
3209
- const dom = new JSDOM(modulePreviewHtml);
3210
- const modulePreviewContent = dom.window.document.querySelector(
3211
- 'div[data-hs-cos-type="module"]'
3212
- ).outerHTML;
3213
- const allStyleContent = Array.from(
3214
- dom.window.document.querySelectorAll("style")
3215
- ).map((element) => element.textContent || "").join("\n");
3401
+ const previewDoc = parseHtml(modulePreviewHtml);
3402
+ const modulePreviewContent = extractModuleOuterHtml(previewDoc);
3403
+ const allStyleContent = extractStyleText(previewDoc);
3216
3404
  const filteredCss = extractRelevantCss(allStyleContent);
3217
3405
  const cssNeeded = filteredCss ? `<style>${filteredCss}</style>` : "";
3218
3406
  return { html: modulePreviewContent, cssNeeded };
@@ -3337,10 +3525,9 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
3337
3525
  );
3338
3526
  }
3339
3527
  localRenderPlaceholders[0].json.props.fieldValues = localFieldValues;
3340
- const previewDom = new JSDOM(templatePreview);
3341
- const allStyleContent = Array.from(
3342
- previewDom.window.document.querySelectorAll("head style")
3343
- ).map((element) => element.textContent || "").join("\n");
3528
+ const allStyleContent = extractStyleText(parseHtml(templatePreview), {
3529
+ headOnly: true
3530
+ });
3344
3531
  const filteredCss = extractRelevantCss(allStyleContent);
3345
3532
  const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
3346
3533
  const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
@@ -4679,7 +4866,7 @@ async function getDevServerUIData(appLocals) {
4679
4866
  runCommand: `${runCommand} ${scriptName}`
4680
4867
  })
4681
4868
  ) : [];
4682
- reactModules = projectName ? await mapReactModules(modulesData, themeWebRoot, appViteServer) : [];
4869
+ reactModules = projectName && appViteServer ? await mapReactModules(modulesData, themeWebRoot, appViteServer) : [];
4683
4870
  }
4684
4871
  let hubLModuleData = { objects: [] };
4685
4872
  let hubLTemplateData = { objects: [] };
@@ -4738,6 +4925,11 @@ var appServerRouteHandler = async (req, res, __next) => {
4738
4925
  const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
4739
4926
  render = ssrRender;
4740
4927
  } else {
4928
+ if (!appViteServer) {
4929
+ throw new Error(
4930
+ "appViteServer is required to render the dev server UI in development"
4931
+ );
4932
+ }
4741
4933
  template = await appViteServer.transformIndexHtml(url3, template);
4742
4934
  render = (await appViteServer.ssrLoadModule(serverEntryPath)).render;
4743
4935
  }
@@ -4788,12 +4980,14 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
4788
4980
  if (isProd2) {
4789
4981
  const distAssetsPath = path13.join(appWebRoot, "assets");
4790
4982
  devServerApp.use("/assets", expressStatic(distAssetsPath));
4791
- } else {
4983
+ } else if (appViteServer) {
4792
4984
  devServerApp.use("/local", appViteServer.middlewares);
4793
4985
  }
4794
4986
  devServerApp.use(viteServer.middlewares);
4795
4987
  devServerApp.use("/api", createAppServerAPIRoutes_default());
4796
- devServerApp.get("/", appServerRouteHandler_default);
4988
+ if (appViteServer) {
4989
+ devServerApp.get("/", appServerRouteHandler_default);
4990
+ }
4797
4991
  devServerApp.get("/legacy", legacyRouteHandler_default);
4798
4992
  devServerApp.get("/proxy", proxyPathPageRouteHandler);
4799
4993
  devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
@@ -4899,7 +5093,7 @@ async function createShadowDevServerRoutes(devServerPort, themePath) {
4899
5093
 
4900
5094
  // src/shadowDevServer/startShadowDevServer.ts
4901
5095
  var testNetServer = net.createServer();
4902
- async function startShadowDevServer(devServerPort, shadowPort, themePath) {
5096
+ async function startShadowDevServer(devServerPort, shadowPort, themePath, host) {
4903
5097
  const portIsTaken = await new Promise((res, rej) => {
4904
5098
  console.log(`Starting proxy link server on port ${shadowPort}`);
4905
5099
  testNetServer.once("error", (err) => {
@@ -4918,13 +5112,13 @@ async function startShadowDevServer(devServerPort, shadowPort, themePath) {
4918
5112
  testNetServer.once("close", () => {
4919
5113
  res(false);
4920
5114
  });
4921
- testNetServer.listen(shadowPort);
5115
+ testNetServer.listen(shadowPort, host);
4922
5116
  });
4923
5117
  if (portIsTaken) {
4924
5118
  return;
4925
5119
  }
4926
5120
  const shadowDevServer = express();
4927
- shadowDevServer.listen(shadowPort);
5121
+ shadowDevServer.listen(shadowPort, host);
4928
5122
  shadowDevServer.use(
4929
5123
  "/",
4930
5124
  await createShadowDevServerRoutes(devServerPort, themePath)
@@ -5307,7 +5501,6 @@ async function fetchWebsiteDomainNames(portalId) {
5307
5501
  // src/lib/validateHSPlatform.ts
5308
5502
  import path15 from "path";
5309
5503
  import fs7 from "fs";
5310
- import select from "@inquirer/select";
5311
5504
  import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5312
5505
  var HSPROJECT_JSON = "hsproject.json";
5313
5506
  function checkFileExists(filePath) {
@@ -5330,7 +5523,7 @@ function findHSProjectJson(startPath) {
5330
5523
  );
5331
5524
  return null;
5332
5525
  }
5333
- async function validateHSPlatform(projectConfigPath, portalId) {
5526
+ async function validateHSPlatform(projectConfigPath, portalId, deferSelection) {
5334
5527
  if (projectConfigPath === null) {
5335
5528
  console.log(
5336
5529
  `Unable to find local ${HSPROJECT_JSON}, skipping platform version validation.`
@@ -5354,29 +5547,37 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5354
5547
  return false;
5355
5548
  }
5356
5549
  if (platformVersion === void 0 || !platformVersionResult.activePlatformVersions.includes(platformVersion)) {
5357
- const answer = await select({
5358
- message: 'Your local "hsproject.json" does not have a valid platform version, please select a valid platform version. You can read more about Platform Versioning here https://developers.hubspot.com/docs/platform/platform-versioning',
5359
- choices: platformVersionResult.activePlatformVersions.map(
5360
- (versionNumber) => ({
5361
- name: versionNumber,
5362
- value: versionNumber
5363
- })
5364
- )
5365
- });
5366
- hsProjectJSONData.platformVersion = answer;
5367
- try {
5368
- fs7.writeFileSync(
5369
- projectConfigPath,
5370
- JSON.stringify(hsProjectJSONData, void 0, 2),
5371
- "utf8"
5372
- );
5373
- return true;
5374
- } catch (e) {
5375
- console.error(
5376
- `unable to write updated valid platform version, please make sure platformVersion in "${HSPROJECT_JSON}" is one of ${platformVersionResult.activePlatformVersions}`
5377
- );
5550
+ const promptAndWrite = async () => {
5551
+ const { default: select } = await Promise.resolve().then(() => (init_esm(), esm_exports));
5552
+ const answer = await select({
5553
+ message: 'Your local "hsproject.json" does not have a valid platform version, please select a valid platform version. You can read more about Platform Versioning here https://developers.hubspot.com/docs/platform/platform-versioning',
5554
+ choices: platformVersionResult.activePlatformVersions.map(
5555
+ (versionNumber) => ({
5556
+ name: versionNumber,
5557
+ value: versionNumber
5558
+ })
5559
+ )
5560
+ });
5561
+ hsProjectJSONData.platformVersion = answer;
5562
+ try {
5563
+ fs7.writeFileSync(
5564
+ projectConfigPath,
5565
+ JSON.stringify(hsProjectJSONData, void 0, 2),
5566
+ "utf8"
5567
+ );
5568
+ return true;
5569
+ } catch (e) {
5570
+ console.error(
5571
+ `unable to write updated valid platform version, please make sure platformVersion in "${HSPROJECT_JSON}" is one of ${platformVersionResult.activePlatformVersions}`
5572
+ );
5573
+ return false;
5574
+ }
5575
+ };
5576
+ if (deferSelection) {
5577
+ deferSelection(promptAndWrite);
5378
5578
  return false;
5379
5579
  }
5580
+ return promptAndWrite();
5380
5581
  }
5381
5582
  return true;
5382
5583
  }
@@ -5754,6 +5955,7 @@ function getSecretNamesFromConfig(config) {
5754
5955
  // src/createDevServer.ts
5755
5956
  var BASE_PATH = "/";
5756
5957
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
5958
+ var DEV_SERVER_HOST = process.env.CMS_DEV_SERVER_HOST || "127.0.0.1";
5757
5959
  var SHADOW_PORT = 1442;
5758
5960
  var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
5759
5961
  function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
@@ -5823,22 +6025,46 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
5823
6025
  }
5824
6026
  authedEnv = env2;
5825
6027
  personalAccessKey = (account == null ? void 0 : account.authType) === PERSONAL_ACCESS_KEY_AUTH_METHOD.value ? account == null ? void 0 : account.personalAccessKey : null;
5826
- if (personalAccessKey) {
6028
+ } else {
6029
+ console.warn(
6030
+ `Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
6031
+ If needed you can refer to another config file with --config.
6032
+
6033
+ Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded due to missing account data.`
6034
+ );
6035
+ secretNames = secretNamesFromConfig;
6036
+ }
6037
+ setTrackingInfo(authedPortalId, authedEnv);
6038
+ sendTrackingRequest("start-dev-server");
6039
+ const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot));
6040
+ const projectConfigPath = findHSProjectJson(absoluteWebRoot);
6041
+ const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
6042
+ absoluteWebRoot,
6043
+ projectConfigPath
6044
+ );
6045
+ let domainsToProxy = [];
6046
+ let authedHublet = "na1";
6047
+ let platformVersionPrompt = null;
6048
+ const bootTasks = [];
6049
+ if (isValid && personalAccessKey) {
6050
+ const portalId = authedPortalId;
6051
+ const env2 = authedEnv;
6052
+ const pak = personalAccessKey;
6053
+ bootTasks.push(async () => {
5827
6054
  try {
5828
- jsRenderingGates = await getJsRenderingGates(
5829
- authedPortalId,
5830
- authedEnv,
5831
- personalAccessKey
5832
- );
6055
+ jsRenderingGates = await getJsRenderingGates(portalId, env2, pak);
5833
6056
  } catch (e) {
5834
6057
  console.warn(
5835
6058
  `Unable to get gating information. Gated features will not be available in the local dev server.`
5836
6059
  );
5837
6060
  }
5838
- }
5839
- if (cmsAssetConfig) {
6061
+ });
6062
+ }
6063
+ if (isValid && cmsAssetConfig) {
6064
+ const portalId = authedPortalId;
6065
+ bootTasks.push(async () => {
5840
6066
  try {
5841
- const secretsResponse = (await fetchSecrets(authedPortalId)).data;
6067
+ const secretsResponse = (await fetchSecrets(portalId)).data;
5842
6068
  if (secretNamesFromConfig && secretsResponse) {
5843
6069
  secretNames = secretsResponse.results.filter(
5844
6070
  (secretName) => secretNamesFromConfig.includes(secretName)
@@ -5858,54 +6084,51 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
5858
6084
  handleSecretsError(e);
5859
6085
  console.log(e);
5860
6086
  }
5861
- }
5862
- } else {
5863
- console.warn(
5864
- `Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
5865
- If needed you can refer to another config file with --config.
5866
-
5867
- Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded due to missing account data.`
5868
- );
5869
- secretNames = secretNamesFromConfig;
6087
+ });
5870
6088
  }
5871
- setTrackingInfo(authedPortalId, authedEnv);
5872
- sendTrackingRequest("start-dev-server");
5873
- let domainsToProxy = [];
5874
6089
  if (authedPortalId) {
5875
- try {
5876
- const portalDomains = await fetchWebsiteDomainNames(authedPortalId);
5877
- domainsToProxy = (process.env.DOMAINS_TO_PROXY || "").split(",").filter((d) => !!d);
5878
- domainsToProxy = [...domainsToProxy, ...portalDomains];
5879
- } catch (e) {
5880
- if (e instanceof MissingScopeError) {
5881
- logMissingScopeWarning(e);
5882
- } else {
5883
- const failedDomainFetchMessages = [
5884
- "Failed to fetch the portal's domains, as a result:",
5885
- "- HTTPS proxying won't work with them.",
5886
- "- Proxying to serverless functions won't work."
5887
- ].map((msg) => wrapMessageInColor("yellow", msg)).join("\n");
5888
- console.warn(failedDomainFetchMessages);
6090
+ const portalId = authedPortalId;
6091
+ bootTasks.push(async () => {
6092
+ try {
6093
+ const portalDomains = await fetchWebsiteDomainNames(portalId);
6094
+ domainsToProxy = (process.env.DOMAINS_TO_PROXY || "").split(",").filter((d) => !!d);
6095
+ domainsToProxy = [...domainsToProxy, ...portalDomains];
6096
+ } catch (e) {
6097
+ if (e instanceof MissingScopeError) {
6098
+ logMissingScopeWarning(e);
6099
+ } else {
6100
+ const failedDomainFetchMessages = [
6101
+ "Failed to fetch the portal's domains, as a result:",
6102
+ "- HTTPS proxying won't work with them.",
6103
+ "- Proxying to serverless functions won't work."
6104
+ ].map((msg) => wrapMessageInColor("yellow", msg)).join("\n");
6105
+ console.warn(failedDomainFetchMessages);
6106
+ }
5889
6107
  }
5890
- }
5891
- }
5892
- let authedHublet;
5893
- try {
5894
- const accountInformation = (await hsCliHttp12.get(authedPortalId, {
5895
- url: "/account-info/v3/details"
5896
- })).data;
5897
- authedHublet = accountInformation.dataHostingLocation;
5898
- } catch (e) {
5899
- authedHublet = "na1";
6108
+ });
6109
+ bootTasks.push(async () => {
6110
+ try {
6111
+ const accountInformation = (await hsCliHttp12.get(portalId, {
6112
+ url: "/account-info/v3/details"
6113
+ })).data;
6114
+ authedHublet = accountInformation.dataHostingLocation;
6115
+ } catch (e) {
6116
+ authedHublet = "na1";
6117
+ }
6118
+ });
6119
+ bootTasks.push(async () => {
6120
+ await validateHSPlatform(
6121
+ projectConfigPath,
6122
+ portalId,
6123
+ (promptAndWrite) => {
6124
+ platformVersionPrompt = promptAndWrite;
6125
+ }
6126
+ );
6127
+ });
5900
6128
  }
5901
- const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot));
5902
- const projectConfigPath = findHSProjectJson(absoluteWebRoot);
5903
- const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
5904
- absoluteWebRoot,
5905
- projectConfigPath
5906
- );
5907
- if (authedPortalId) {
5908
- await validateHSPlatform(projectConfigPath, authedPortalId);
6129
+ await Promise.all(bootTasks.map((task) => task()));
6130
+ if (platformVersionPrompt) {
6131
+ await platformVersionPrompt();
5909
6132
  }
5910
6133
  let _localPreviewToken = null;
5911
6134
  let _tokenStatus;
@@ -5958,11 +6181,8 @@ Local proxy functionality and module preview routes will not work without settin
5958
6181
  if (true) {
5959
6182
  appWebRoot = path17.join(__dirname, "app");
5960
6183
  }
5961
- const appViteServer = await createAppServer_default(
5962
- appWebRoot,
5963
- PORT,
5964
- sslEnabledOption
5965
- );
6184
+ const skipUiServer = isLocalUiDisabled(cmsAssetConfig);
6185
+ const appViteServer = skipUiServer ? null : await createAppServer_default(appWebRoot, PORT, sslEnabledOption);
5966
6186
  const appLocals = {
5967
6187
  themeWebRoot: absoluteWebRoot,
5968
6188
  authedPortalId,
@@ -5991,7 +6211,7 @@ Local proxy functionality and module preview routes will not work without settin
5991
6211
  { key: httpsKey, cert: httpsCert },
5992
6212
  expressServer
5993
6213
  );
5994
- server.listen(PORT);
6214
+ server.listen(PORT, DEV_SERVER_HOST);
5995
6215
  httpServers.push(server);
5996
6216
  httpServers.push(innerHTTPServer);
5997
6217
  httpServers.push(innerHTTPSServer);
@@ -6001,14 +6221,15 @@ Local proxy functionality and module preview routes will not work without settin
6001
6221
  }
6002
6222
  } else {
6003
6223
  const httpServer = http3.createServer(expressServer);
6004
- httpServer.listen(PORT);
6224
+ httpServer.listen(PORT, DEV_SERVER_HOST);
6005
6225
  httpServers.push(httpServer);
6006
6226
  }
6007
6227
  if (!process.env.IN_CODESANDBOX && !process.env.CODESANDBOX_HOST) {
6008
6228
  startShadowDevServer(
6009
6229
  PORT,
6010
6230
  SHADOW_PORT,
6011
- themePreviewOptions ? themePreviewOptions.dest : ""
6231
+ themePreviewOptions ? themePreviewOptions.dest : "",
6232
+ DEV_SERVER_HOST
6012
6233
  );
6013
6234
  }
6014
6235
  let extraServerInfo = "";
@@ -6100,7 +6321,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6100
6321
  return Promise.allSettled([
6101
6322
  ...serverClosePromises,
6102
6323
  viteServer.close(),
6103
- appViteServer.close()
6324
+ appViteServer ? appViteServer.close() : Promise.resolve()
6104
6325
  ]);
6105
6326
  }
6106
6327
  };
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-B-d4FeeE.js
1
+ // ../cms-js-internal/dist/types-Dvw_fW6p.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -373,6 +373,13 @@ function isFullHeightPreviewEnabled(config) {
373
373
  }
374
374
  return false;
375
375
  }
376
+ function isLocalUiDisabled(config) {
377
+ var _a;
378
+ if ("devServer" in config) {
379
+ return ((_a = config.devServer) == null ? void 0 : _a.disableLocalUi) ?? false;
380
+ }
381
+ return false;
382
+ }
376
383
  var BUILD_INFO_PATH = "/build-info.json";
377
384
  function getBuildInfo(buildDir) {
378
385
  try {
@@ -1294,6 +1301,7 @@ export {
1294
1301
  hasComponentExtension,
1295
1302
  includesHublDataReference,
1296
1303
  isFullHeightPreviewEnabled,
1304
+ isLocalUiDisabled,
1297
1305
  isStorybookStory,
1298
1306
  isStylesheetAsset,
1299
1307
  isUngatedFor,