@hubspot/cms-dev-server 0.18.8 → 0.18.9

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/dist/run.js CHANGED
@@ -530,9 +530,9 @@ function getTerminalUISupport() {
530
530
  function uiLine() {
531
531
  logger.log("-".repeat(50));
532
532
  }
533
- function uiLink(linkText, url4) {
533
+ function uiLink(linkText, url3) {
534
534
  const terminalUISupport = getTerminalUISupport();
535
- const encodedUrl = encodeURI(url4);
535
+ const encodedUrl = encodeURI(url3);
536
536
  if (terminalUISupport.hyperlinks) {
537
537
  const CLOSE_SEQUENCE = "\x1B]8;;\x07";
538
538
  const result = [
@@ -741,8 +741,8 @@ async function buildThemePreviewOptions(webRoot2) {
741
741
  }
742
742
 
743
743
  // src/createDevServer.ts
744
- import path14 from "path";
745
- import url3 from "url";
744
+ import path13 from "path";
745
+ import url2 from "url";
746
746
  import express3 from "express";
747
747
  import http3 from "http";
748
748
  import bodyParser from "body-parser";
@@ -1095,7 +1095,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
1095
1095
  hydrateOn,
1096
1096
  clientOnly,
1097
1097
  priority,
1098
- url: url4,
1098
+ url: url3,
1099
1099
  sharedStateID,
1100
1100
  supplementalFieldValues,
1101
1101
  wrapperModuleId,
@@ -1109,7 +1109,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
1109
1109
  clientOnly,
1110
1110
  priority,
1111
1111
  props,
1112
- url: url4
1112
+ url: url3
1113
1113
  };
1114
1114
  if (sharedStateID) {
1115
1115
  output.sharedStateID = sharedStateID;
@@ -1366,8 +1366,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
1366
1366
  );
1367
1367
  return Object.fromEntries(relativeEntries);
1368
1368
  }
1369
- function toRelativePath(config, path15) {
1370
- return path15.replace(config.root, "");
1369
+ function toRelativePath(config, path14) {
1370
+ return path14.replace(config.root, "");
1371
1371
  }
1372
1372
  function shouldSkipModule(config, moduleInfo, code) {
1373
1373
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -1405,11 +1405,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1405
1405
  let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
1406
1406
  let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
1407
1407
  traverse(sourceAst, {
1408
- ImportDeclaration(path15) {
1409
- if (t.isStringLiteral(path15.node.source, {
1408
+ ImportDeclaration(path14) {
1409
+ if (t.isStringLiteral(path14.node.source, {
1410
1410
  value: "@hubspot/cms-components"
1411
1411
  })) {
1412
- for (const specifier of path15.node.specifiers) {
1412
+ for (const specifier of path14.node.specifiers) {
1413
1413
  if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
1414
1414
  name: CMS_MODULE_COMPONENT_NAME
1415
1415
  })) {
@@ -1423,14 +1423,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1423
1423
  }
1424
1424
  }
1425
1425
  },
1426
- JSXOpeningElement(path15) {
1427
- if (t.isJSXIdentifier(path15.node.name, {
1426
+ JSXOpeningElement(path14) {
1427
+ if (t.isJSXIdentifier(path14.node.name, {
1428
1428
  name: moduleComponentLocalImportName
1429
1429
  })) {
1430
1430
  let cmsModuleName;
1431
1431
  let cmsModulePath;
1432
1432
  let cmsModuleLabel;
1433
- for (const prop of path15.node.attributes) {
1433
+ for (const prop of path14.node.attributes) {
1434
1434
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
1435
1435
  cmsModuleName = prop.value.value;
1436
1436
  continue;
@@ -1465,11 +1465,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1465
1465
  }
1466
1466
  contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
1467
1467
  }
1468
- if (t.isJSXIdentifier(path15.node.name, {
1468
+ if (t.isJSXIdentifier(path14.node.name, {
1469
1469
  name: dndAreaComponentLocalImportName
1470
1470
  })) {
1471
1471
  let dndAreaName;
1472
- for (const prop of path15.node.attributes) {
1472
+ for (const prop of path14.node.attributes) {
1473
1473
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
1474
1474
  dndAreaName = prop.value.value;
1475
1475
  continue;
@@ -1940,9 +1940,9 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
1940
1940
  );
1941
1941
  return htmlTemplate;
1942
1942
  };
1943
- var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, title, renderContext, viteServer, jsRenderingGates) => {
1943
+ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, jsRenderingGates) => {
1944
1944
  let htmlTemplate;
1945
- const prettyPrint = isDebugUrlString2(url4);
1945
+ const prettyPrint = isDebugUrlString2(url3);
1946
1946
  const serverMessages = criticalDevErrorsToServerMessages_default(
1947
1947
  renderContext.criticalDevErrors
1948
1948
  );
@@ -1992,7 +1992,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, tit
1992
1992
  `${globalScriptBlock}${serverLogScript}`
1993
1993
  );
1994
1994
  }
1995
- return viteServer.transformIndexHtml(url4, htmlTemplate);
1995
+ return viteServer.transformIndexHtml(url3, htmlTemplate);
1996
1996
  };
1997
1997
  var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, gates, prettyPrint) => {
1998
1998
  const internalSsrPath = packagePath(import.meta.url, "internalSsr");
@@ -2053,12 +2053,12 @@ function trackUsage(action) {
2053
2053
  eventName: EVENT_NAME,
2054
2054
  action,
2055
2055
  nodeVersion: getNodeVersionData(),
2056
- version: "0.18.8",
2056
+ version: "0.18.9",
2057
2057
  os: getPlatform()
2058
2058
  };
2059
- const url4 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
2059
+ const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
2060
2060
  const baseRequestOptions = {
2061
- url: url4,
2061
+ url: url3,
2062
2062
  data: usageEvent
2063
2063
  };
2064
2064
  if (isAuthedWithPersonalAccessKey) {
@@ -2126,12 +2126,12 @@ var findLocalRenderPlaceholders = (body) => {
2126
2126
  );
2127
2127
  offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
2128
2128
  if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
2129
- const path15 = body.substring(
2129
+ const path14 = body.substring(
2130
2130
  startOffset + localJsRenderStartString.length,
2131
2131
  pathEndOffset
2132
2132
  );
2133
2133
  offsetSoFar = pathEndOffset + 1;
2134
- if (startOffset >= 0 && path15) {
2134
+ if (startOffset >= 0 && path14) {
2135
2135
  const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
2136
2136
  const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
2137
2137
  offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
@@ -2156,7 +2156,7 @@ var findLocalRenderPlaceholders = (body) => {
2156
2156
  result.push({
2157
2157
  startOffset,
2158
2158
  endOffset: endOffset + localJsRenderEndString.length,
2159
- path: path15,
2159
+ path: path14,
2160
2160
  json
2161
2161
  });
2162
2162
  }
@@ -2533,9 +2533,9 @@ var customColors = [
2533
2533
  ];
2534
2534
  var Converter = new AnsiToHtmlConverter({ colors: customColors });
2535
2535
  var darkErrorStyles = `background-color: #222; color: #ccc; padding: 0.5em; font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;`;
2536
- var renderLocalError_default = (path15, error) => {
2536
+ var renderLocalError_default = (path14, error) => {
2537
2537
  const stackWithColorClasses = Converter.toHtml(error.stack);
2538
- return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path15}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
2538
+ return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path14}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
2539
2539
  };
2540
2540
 
2541
2541
  // src/proxyPage/fetchPreviewInfo.ts
@@ -2944,17 +2944,17 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
2944
2944
  return placeholderPath;
2945
2945
  }
2946
2946
  var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates, cookieHeader, localPreviewToken) => {
2947
- const url4 = new URL(urlToProxy);
2948
- const renderPreviewLocally = url4.searchParams.has("renderPreviewLocally");
2947
+ const url3 = new URL(urlToProxy);
2948
+ const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
2949
2949
  let proxiedQueryParams = {};
2950
- let baseURL = url4.origin;
2951
- let pathname = url4.pathname;
2950
+ let baseURL = url3.origin;
2951
+ let pathname = url3.pathname;
2952
2952
  const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
2953
- const queryKeys = Array.from(url4.searchParams.keys()).filter(
2953
+ const queryKeys = Array.from(url3.searchParams.keys()).filter(
2954
2954
  (queryKey) => !PARAMS_TO_IGNORE.includes(queryKey)
2955
2955
  );
2956
2956
  for (const queryKey of queryKeys) {
2957
- const values = url4.searchParams.getAll(queryKey);
2957
+ const values = url3.searchParams.getAll(queryKey);
2958
2958
  if (values.length > 1) {
2959
2959
  proxiedQueryParams[queryKey] = values;
2960
2960
  } else {
@@ -2970,9 +2970,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
2970
2970
  hsLoginVerifyDisabled: `${true}`
2971
2971
  };
2972
2972
  if (renderPreviewLocally) {
2973
- proxiedQueryParams.hsDebugOverridePublicHost = url4.host;
2973
+ proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
2974
2974
  baseURL = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
2975
- pathname = `/cos-rendering/v1/public${url4.pathname}`;
2975
+ pathname = `/cos-rendering/v1/public${url3.pathname}`;
2976
2976
  }
2977
2977
  if (localPreviewToken) {
2978
2978
  proxiedQueryParams = {
@@ -3800,16 +3800,16 @@ var module_default = moduleRouteHandler;
3800
3800
  import http from "http";
3801
3801
  import https from "https";
3802
3802
  import { getAccountId as getAccountId2 } from "@hubspot/local-dev-lib/config";
3803
- async function requestPage(url4, redirects = 0, originalUrl) {
3803
+ async function requestPage(url3, redirects = 0, originalUrl) {
3804
3804
  if (redirects > 5) {
3805
3805
  throw new Error(
3806
3806
  `Hit too many redirects to HEAD requests for ${originalUrl}`
3807
3807
  );
3808
3808
  }
3809
3809
  return new Promise((resolve3, reject) => {
3810
- const protocolAPI = url4.startsWith("https://") ? https : http;
3810
+ const protocolAPI = url3.startsWith("https://") ? https : http;
3811
3811
  protocolAPI.request(
3812
- url4,
3812
+ url3,
3813
3813
  {
3814
3814
  method: "HEAD",
3815
3815
  headers: {
@@ -3836,12 +3836,12 @@ async function requestPage(url4, redirects = 0, originalUrl) {
3836
3836
  }
3837
3837
  }
3838
3838
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
3839
- console.log(`Redirecting to ${res.headers.location} (from ${url4})`);
3839
+ console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
3840
3840
  return resolve3(
3841
3841
  requestPage(
3842
3842
  res.headers.location,
3843
3843
  redirects + 1,
3844
- originalUrl ?? url4
3844
+ originalUrl ?? url3
3845
3845
  )
3846
3846
  );
3847
3847
  }
@@ -3859,11 +3859,11 @@ async function requestPage(url4, redirects = 0, originalUrl) {
3859
3859
  }).end();
3860
3860
  });
3861
3861
  }
3862
- async function fetchContentMetadata(url4, portalId) {
3863
- const { portalIdHeader, contentId, res } = await requestPage(url4);
3862
+ async function fetchContentMetadata(url3, portalId) {
3863
+ const { portalIdHeader, contentId, res } = await requestPage(url3);
3864
3864
  if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
3865
3865
  throw new Error(
3866
- `There were multiple hub ID or content ID headers in the HEAD request to ${url4}`
3866
+ `There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
3867
3867
  );
3868
3868
  } else {
3869
3869
  const portalIdFromResponse = parseInt(portalIdHeader, 10);
@@ -3875,15 +3875,15 @@ async function fetchContentMetadata(url4, portalId) {
3875
3875
  }
3876
3876
  if (res.statusCode !== 200 && !(portalIdFromResponse && pageAccount && contentId)) {
3877
3877
  throw new Error(
3878
- `${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url4}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
3878
+ `${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url3}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
3879
3879
  );
3880
3880
  } else if (!portalId || !contentId) {
3881
3881
  throw new Error(
3882
- `Missing hub ID or content ID headers on HEAD request to ${url4}`
3882
+ `Missing hub ID or content ID headers on HEAD request to ${url3}`
3883
3883
  );
3884
3884
  } else if (isNaN(portalId)) {
3885
3885
  throw new Error(
3886
- `Hub ID from the HEAD request is not a number: '${portalId}' (${url4})`
3886
+ `Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
3887
3887
  );
3888
3888
  }
3889
3889
  const hublet = "na1";
@@ -4009,14 +4009,14 @@ async function fetchPreviewTemplates(accountId, previewToken) {
4009
4009
  url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
4010
4010
  })).data;
4011
4011
  }
4012
- async function fetchModuleByPath(accountId, path15) {
4012
+ async function fetchModuleByPath(accountId, path14) {
4013
4013
  return (await hsCliHttp8.get(accountId, {
4014
- url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path15}?portalId=${accountId}`
4014
+ url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path14}?portalId=${accountId}`
4015
4015
  })).data;
4016
4016
  }
4017
- async function fetchTemplateByPath(accountId, path15) {
4017
+ async function fetchTemplateByPath(accountId, path14) {
4018
4018
  return (await hsCliHttp8.get(accountId, {
4019
- url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path15}?portalId=${accountId}`
4019
+ url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path14}?portalId=${accountId}`
4020
4020
  })).data;
4021
4021
  }
4022
4022
 
@@ -4473,8 +4473,8 @@ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
4473
4473
  var createDevServerRoutes = async (viteServer, storybookPort) => {
4474
4474
  const devServerApp = Router();
4475
4475
  devServerApp.use((request2, response, next) => {
4476
- const { method, url: url4, hostname } = request2;
4477
- debug(`${method}:${hostname}${url4}`);
4476
+ const { method, url: url3, hostname } = request2;
4477
+ debug(`${method}:${hostname}${url3}`);
4478
4478
  next();
4479
4479
  });
4480
4480
  if (storybookPort) {
@@ -4523,9 +4523,6 @@ import express from "express";
4523
4523
  import { Router as Router2 } from "express";
4524
4524
  import { getAccountId as getAccountId3, getEnv as getEnv3 } from "@hubspot/local-dev-lib/config";
4525
4525
  import cors from "cors";
4526
- import { exec } from "child_process";
4527
- import path11 from "path";
4528
- import url2 from "url";
4529
4526
  import { buildStaticEnvConfig as buildStaticEnvConfig6 } from "@hubspot/cms-components";
4530
4527
  function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
4531
4528
  return async function shadowDevServerCheckHandler(request2, response) {
@@ -4601,40 +4598,6 @@ ${error.stack}`
4601
4598
  }
4602
4599
  };
4603
4600
  }
4604
- function getRunTestsHandler() {
4605
- return async function runTestsHandler(request2, response) {
4606
- const cmsDevServerPath = path11.join(
4607
- path11.dirname(url2.fileURLToPath(import.meta.url)),
4608
- "../.."
4609
- );
4610
- exec("npm run test", { cwd: cmsDevServerPath }, (error, stdout, stderr) => {
4611
- if (error) {
4612
- response.status(500).json({ error: stderr });
4613
- return;
4614
- }
4615
- response.status(200).json({ response: stdout });
4616
- });
4617
- };
4618
- }
4619
- function getRunBuildHandler() {
4620
- return async function runTestsHandler(request2, response) {
4621
- const cmsDevServerPath = path11.join(
4622
- path11.dirname(url2.fileURLToPath(import.meta.url)),
4623
- "../.."
4624
- );
4625
- exec(
4626
- "npm run build",
4627
- { cwd: cmsDevServerPath },
4628
- (error, stdout, stderr) => {
4629
- if (error) {
4630
- response.status(500).json({ error: stderr });
4631
- return;
4632
- }
4633
- response.status(200).json({ response: stdout });
4634
- }
4635
- );
4636
- };
4637
- }
4638
4601
  async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
4639
4602
  const shadowDevServerRoutes = Router2();
4640
4603
  shadowDevServerRoutes.get(
@@ -4642,8 +4605,6 @@ async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
4642
4605
  cors(),
4643
4606
  getShadowDevServerCheckHandler(devServerPort, projectName, gates)
4644
4607
  );
4645
- shadowDevServerRoutes.get("/test", cors(), getRunTestsHandler());
4646
- shadowDevServerRoutes.get("/build", cors(), getRunBuildHandler());
4647
4608
  return shadowDevServerRoutes;
4648
4609
  }
4649
4610
 
@@ -4809,7 +4770,25 @@ import fs4 from "node:fs/promises";
4809
4770
  import express2 from "express";
4810
4771
  import { createServer as createViteServer2 } from "vite";
4811
4772
  import { default as react2 } from "@vitejs/plugin-react";
4812
- async function createAppServer(webRoot2, port) {
4773
+
4774
+ // src/lib/getDevServerUIData.ts
4775
+ function getReactModules(themeWebRoot) {
4776
+ const { moduleNames } = findAllModulesInRoot(themeWebRoot);
4777
+ return moduleNames;
4778
+ }
4779
+ function getDevServerUIData(reqLocals) {
4780
+ const { themeWebRoot, authedPortalId, projectName } = reqLocals;
4781
+ const moduleNames = getReactModules(themeWebRoot);
4782
+ return {
4783
+ authedPortalId,
4784
+ projectName,
4785
+ moduleNames
4786
+ };
4787
+ }
4788
+ var getDevServerUIData_default = getDevServerUIData;
4789
+
4790
+ // src/createAppServer.ts
4791
+ async function createAppServer(webRoot2, reqLocals, port) {
4813
4792
  const app = express2();
4814
4793
  const origin = `http://hslocal.net:${port}`;
4815
4794
  const viteConfig = {
@@ -4856,14 +4835,20 @@ async function createAppServer(webRoot2, port) {
4856
4835
  app.use(viteServer.middlewares);
4857
4836
  app.use("*", async (req, res) => {
4858
4837
  try {
4859
- const url4 = req.originalUrl.replace("/", "");
4838
+ const inititialProps = getDevServerUIData_default(reqLocals);
4839
+ const url3 = req.originalUrl.replace("/", "");
4860
4840
  let template = await fs4.readFile("./app/index.html", "utf-8");
4861
- template = await viteServer.transformIndexHtml(url4, template);
4841
+ template = await viteServer.transformIndexHtml(url3, template);
4862
4842
  const { render } = await viteServer.ssrLoadModule(
4863
4843
  "./app/serverEntry.tsx"
4864
4844
  );
4865
- const rendered = await render(url4);
4866
- const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "");
4845
+ const rendered = await render(inititialProps);
4846
+ const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4847
+ `<!--app-script-->`,
4848
+ `<script>window.__hsInitialProps = ${JSON.stringify(
4849
+ inititialProps
4850
+ )}</script>` ?? ""
4851
+ );
4867
4852
  res.status(200).set({ "Content-Type": "text/html" }).send(html);
4868
4853
  } catch (e) {
4869
4854
  viteServer == null ? void 0 : viteServer.ssrFixStacktrace(e);
@@ -5037,7 +5022,7 @@ async function fetchWebsiteDomainNames(portalId) {
5037
5022
  }
5038
5023
 
5039
5024
  // src/lib/validateHSPlatform.ts
5040
- import path12 from "path";
5025
+ import path11 from "path";
5041
5026
  import fs5 from "fs";
5042
5027
  import select from "@inquirer/select";
5043
5028
  import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
@@ -5049,12 +5034,12 @@ function findHSProjectJson(startPath) {
5049
5034
  let currentDir = startPath;
5050
5035
  let dirLevel = 0;
5051
5036
  const maxDirLevel = 4;
5052
- while (path12.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
5053
- const filePath = path12.join(currentDir, HSPROJECT_JSON);
5037
+ while (path11.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
5038
+ const filePath = path11.join(currentDir, HSPROJECT_JSON);
5054
5039
  if (checkFileExists(filePath)) {
5055
5040
  return filePath;
5056
5041
  }
5057
- currentDir = path12.dirname(currentDir);
5042
+ currentDir = path11.dirname(currentDir);
5058
5043
  dirLevel++;
5059
5044
  }
5060
5045
  console.log(
@@ -5360,7 +5345,7 @@ function writeFieldsType(fields, fileName, typeName) {
5360
5345
 
5361
5346
  // src/lib/watchFieldsUpdates.ts
5362
5347
  import fs6 from "fs";
5363
- import path13 from "path";
5348
+ import path12 from "path";
5364
5349
  import readline from "readline";
5365
5350
  var lastSerializedFieldsCache = {};
5366
5351
  var formatAsTypeName = (str) => {
@@ -5372,9 +5357,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
5372
5357
  const getEntryPathFromId = (id) => {
5373
5358
  return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
5374
5359
  };
5375
- const currentModuleId = path13.normalize(filePath);
5360
+ const currentModuleId = path12.normalize(filePath);
5376
5361
  const moduleEntryPath = getEntryPathFromId(currentModuleId);
5377
- const subFolderTokens = moduleEntryPath.split(path13.sep);
5362
+ const subFolderTokens = moduleEntryPath.split(path12.sep);
5378
5363
  return {
5379
5364
  inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
5380
5365
  isRootModuleFile: subFolderTokens.length === 3
@@ -5401,10 +5386,10 @@ var getIndexFile = (filePath, projectRoot) => {
5401
5386
  return void 0;
5402
5387
  if (isRootModuleFile)
5403
5388
  return { indexFilePath: filePath, isRootModuleFile };
5404
- const dir = path13.dirname(filePath);
5389
+ const dir = path12.dirname(filePath);
5405
5390
  const files = fs6.readdirSync(dir);
5406
5391
  const indexFileName = files.find((file) => file.startsWith("index."));
5407
- return indexFileName ? { indexFilePath: path13.join(dir, indexFileName), isRootModuleFile } : void 0;
5392
+ return indexFileName ? { indexFilePath: path12.join(dir, indexFileName), isRootModuleFile } : void 0;
5408
5393
  };
5409
5394
  var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
5410
5395
  let indexFile;
@@ -5428,7 +5413,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5428
5413
  if (!indexInfo)
5429
5414
  return;
5430
5415
  const { indexFilePath, isRootModuleFile } = indexInfo;
5431
- const indexFileName = path13.parse(indexFilePath).name;
5416
+ const indexFileName = path12.parse(indexFilePath).name;
5432
5417
  const isTypeFile = filePath.endsWith(".types.ts");
5433
5418
  if (isTypeFile)
5434
5419
  return;
@@ -5439,7 +5424,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5439
5424
  );
5440
5425
  if (fields) {
5441
5426
  const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
5442
- const typeFilePath = path13.join(path13.dirname(filePath), typeFileName);
5427
+ const typeFilePath = path12.join(path12.dirname(filePath), typeFileName);
5443
5428
  const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
5444
5429
  const serializedFields = JSON.stringify(fields);
5445
5430
  if (lastSerializedFields === serializedFields)
@@ -5447,7 +5432,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5447
5432
  const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
5448
5433
  if (!hasAutoGenComment)
5449
5434
  return;
5450
- const moduleFolderName = path13.basename(path13.dirname(filePath));
5435
+ const moduleFolderName = path12.basename(path12.dirname(filePath));
5451
5436
  const outputTypeName = formatAsTypeName(moduleFolderName);
5452
5437
  const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
5453
5438
  if (didSucceed) {
@@ -5463,7 +5448,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5463
5448
  var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
5464
5449
  const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
5465
5450
  moduleSubpaths.forEach((modulePath) => {
5466
- const resolvedPath = path13.resolve(projectRoot, modulePath);
5451
+ const resolvedPath = path12.resolve(projectRoot, modulePath);
5467
5452
  maybeUpdateFields(resolvedPath, viteServer, projectRoot);
5468
5453
  });
5469
5454
  const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
@@ -5601,7 +5586,7 @@ Local proxy functionality and module preview routes will not work without settin
5601
5586
  } catch (e) {
5602
5587
  authedHublet = "na1";
5603
5588
  }
5604
- const absoluteWebRoot = normalizePath7(path14.resolve(process.cwd(), webRoot2));
5589
+ const absoluteWebRoot = normalizePath7(path13.resolve(process.cwd(), webRoot2));
5605
5590
  const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
5606
5591
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
5607
5592
  if (authedPortalId) {
@@ -5693,16 +5678,24 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5693
5678
  `
5694
5679
  );
5695
5680
  if (showUI) {
5696
- const appWebRoot = path14.join(
5697
- path14.dirname(url3.fileURLToPath(import.meta.url)),
5681
+ const appWebRoot = path13.join(
5682
+ path13.dirname(url2.fileURLToPath(import.meta.url)),
5698
5683
  "../app"
5699
5684
  );
5700
- const appServer = await createAppServer_default(appWebRoot, PORT + 1);
5685
+ const reqLocals = {
5686
+ themeWebRoot: absoluteWebRoot,
5687
+ authedPortalId,
5688
+ authedEnv,
5689
+ authedHublet,
5690
+ projectName,
5691
+ webRootProjectComponentFolder
5692
+ };
5693
+ const appServer = await createAppServer_default(appWebRoot, reqLocals, PORT + 1);
5701
5694
  httpServers.push(appServer);
5702
5695
  }
5703
5696
  if (storybook2) {
5704
- const packageRoot = path14.dirname(url3.fileURLToPath(import.meta.url));
5705
- const configPath = path14.resolve(packageRoot, "./storybook-main");
5697
+ const packageRoot = path13.dirname(url2.fileURLToPath(import.meta.url));
5698
+ const configPath = path13.resolve(packageRoot, "./storybook-main");
5706
5699
  sendTrackingRequest("start-storybook");
5707
5700
  const storybookProcess = spawn(
5708
5701
  "sb",
@@ -5722,7 +5715,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5722
5715
  portalId: authedPortalId.toString(),
5723
5716
  hsEnv: authedEnv,
5724
5717
  hublet: authedHublet,
5725
- WEB_ROOT: path14.join(webRoot2, "components")
5718
+ WEB_ROOT: path13.join(webRoot2, "components")
5726
5719
  }
5727
5720
  }
5728
5721
  );