@hubspot/cms-dev-server 0.18.7 → 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/index.js CHANGED
@@ -307,7 +307,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
307
307
  hydrateOn,
308
308
  clientOnly,
309
309
  priority,
310
- url: url4,
310
+ url: url3,
311
311
  sharedStateID,
312
312
  supplementalFieldValues,
313
313
  wrapperModuleId,
@@ -321,7 +321,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
321
321
  clientOnly,
322
322
  priority,
323
323
  props,
324
- url: url4
324
+ url: url3
325
325
  };
326
326
  if (sharedStateID) {
327
327
  output.sharedStateID = sharedStateID;
@@ -578,8 +578,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
578
578
  );
579
579
  return Object.fromEntries(relativeEntries);
580
580
  }
581
- function toRelativePath(config, path14) {
582
- return path14.replace(config.root, "");
581
+ function toRelativePath(config, path13) {
582
+ return path13.replace(config.root, "");
583
583
  }
584
584
  function shouldSkipModule(config, moduleInfo, code) {
585
585
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -617,11 +617,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
617
617
  let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
618
618
  let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
619
619
  traverse(sourceAst, {
620
- ImportDeclaration(path14) {
621
- if (t.isStringLiteral(path14.node.source, {
620
+ ImportDeclaration(path13) {
621
+ if (t.isStringLiteral(path13.node.source, {
622
622
  value: "@hubspot/cms-components"
623
623
  })) {
624
- for (const specifier of path14.node.specifiers) {
624
+ for (const specifier of path13.node.specifiers) {
625
625
  if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
626
626
  name: CMS_MODULE_COMPONENT_NAME
627
627
  })) {
@@ -635,14 +635,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
635
635
  }
636
636
  }
637
637
  },
638
- JSXOpeningElement(path14) {
639
- if (t.isJSXIdentifier(path14.node.name, {
638
+ JSXOpeningElement(path13) {
639
+ if (t.isJSXIdentifier(path13.node.name, {
640
640
  name: moduleComponentLocalImportName
641
641
  })) {
642
642
  let cmsModuleName;
643
643
  let cmsModulePath;
644
644
  let cmsModuleLabel;
645
- for (const prop of path14.node.attributes) {
645
+ for (const prop of path13.node.attributes) {
646
646
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
647
647
  cmsModuleName = prop.value.value;
648
648
  continue;
@@ -677,11 +677,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
677
677
  }
678
678
  contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
679
679
  }
680
- if (t.isJSXIdentifier(path14.node.name, {
680
+ if (t.isJSXIdentifier(path13.node.name, {
681
681
  name: dndAreaComponentLocalImportName
682
682
  })) {
683
683
  let dndAreaName;
684
- for (const prop of path14.node.attributes) {
684
+ for (const prop of path13.node.attributes) {
685
685
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
686
686
  dndAreaName = prop.value.value;
687
687
  continue;
@@ -1023,8 +1023,8 @@ Custom origin: ${process.env.VITE_ORIGIN}
1023
1023
  var createViteDevServer_default = createViteDevServer;
1024
1024
 
1025
1025
  // src/createDevServer.ts
1026
- import path13 from "path";
1027
- import url3 from "url";
1026
+ import path12 from "path";
1027
+ import url2 from "url";
1028
1028
  import express3 from "express";
1029
1029
  import http3 from "http";
1030
1030
  import bodyParser from "body-parser";
@@ -1319,9 +1319,9 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
1319
1319
  );
1320
1320
  return htmlTemplate;
1321
1321
  };
1322
- var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, title, renderContext, viteServer, jsRenderingGates) => {
1322
+ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, jsRenderingGates) => {
1323
1323
  let htmlTemplate;
1324
- const prettyPrint = isDebugUrlString2(url4);
1324
+ const prettyPrint = isDebugUrlString2(url3);
1325
1325
  const serverMessages = criticalDevErrorsToServerMessages_default(
1326
1326
  renderContext.criticalDevErrors
1327
1327
  );
@@ -1371,7 +1371,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, tit
1371
1371
  `${globalScriptBlock}${serverLogScript}`
1372
1372
  );
1373
1373
  }
1374
- return viteServer.transformIndexHtml(url4, htmlTemplate);
1374
+ return viteServer.transformIndexHtml(url3, htmlTemplate);
1375
1375
  };
1376
1376
  var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, gates, prettyPrint) => {
1377
1377
  const internalSsrPath = packagePath(import.meta.url, "internalSsr");
@@ -1449,12 +1449,12 @@ function trackUsage(action) {
1449
1449
  eventName: EVENT_NAME,
1450
1450
  action,
1451
1451
  nodeVersion: getNodeVersionData(),
1452
- version: "0.18.7",
1452
+ version: "0.18.9",
1453
1453
  os: getPlatform()
1454
1454
  };
1455
- const url4 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
1455
+ const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
1456
1456
  const baseRequestOptions = {
1457
- url: url4,
1457
+ url: url3,
1458
1458
  data: usageEvent
1459
1459
  };
1460
1460
  if (isAuthedWithPersonalAccessKey) {
@@ -1522,12 +1522,12 @@ var findLocalRenderPlaceholders = (body) => {
1522
1522
  );
1523
1523
  offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
1524
1524
  if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
1525
- const path14 = body.substring(
1525
+ const path13 = body.substring(
1526
1526
  startOffset + localJsRenderStartString.length,
1527
1527
  pathEndOffset
1528
1528
  );
1529
1529
  offsetSoFar = pathEndOffset + 1;
1530
- if (startOffset >= 0 && path14) {
1530
+ if (startOffset >= 0 && path13) {
1531
1531
  const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
1532
1532
  const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
1533
1533
  offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
@@ -1552,7 +1552,7 @@ var findLocalRenderPlaceholders = (body) => {
1552
1552
  result.push({
1553
1553
  startOffset,
1554
1554
  endOffset: endOffset + localJsRenderEndString.length,
1555
- path: path14,
1555
+ path: path13,
1556
1556
  json
1557
1557
  });
1558
1558
  }
@@ -1929,9 +1929,9 @@ var customColors = [
1929
1929
  ];
1930
1930
  var Converter = new AnsiToHtmlConverter({ colors: customColors });
1931
1931
  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;`;
1932
- var renderLocalError_default = (path14, error) => {
1932
+ var renderLocalError_default = (path13, error) => {
1933
1933
  const stackWithColorClasses = Converter.toHtml(error.stack);
1934
- return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path14}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
1934
+ return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path13}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
1935
1935
  };
1936
1936
 
1937
1937
  // src/proxyPage/fetchPreviewInfo.ts
@@ -2340,17 +2340,17 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
2340
2340
  return placeholderPath;
2341
2341
  }
2342
2342
  var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates, cookieHeader, localPreviewToken) => {
2343
- const url4 = new URL(urlToProxy);
2344
- const renderPreviewLocally = url4.searchParams.has("renderPreviewLocally");
2343
+ const url3 = new URL(urlToProxy);
2344
+ const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
2345
2345
  let proxiedQueryParams = {};
2346
- let baseURL = url4.origin;
2347
- let pathname = url4.pathname;
2346
+ let baseURL = url3.origin;
2347
+ let pathname = url3.pathname;
2348
2348
  const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
2349
- const queryKeys = Array.from(url4.searchParams.keys()).filter(
2349
+ const queryKeys = Array.from(url3.searchParams.keys()).filter(
2350
2350
  (queryKey) => !PARAMS_TO_IGNORE.includes(queryKey)
2351
2351
  );
2352
2352
  for (const queryKey of queryKeys) {
2353
- const values = url4.searchParams.getAll(queryKey);
2353
+ const values = url3.searchParams.getAll(queryKey);
2354
2354
  if (values.length > 1) {
2355
2355
  proxiedQueryParams[queryKey] = values;
2356
2356
  } else {
@@ -2366,9 +2366,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
2366
2366
  hsLoginVerifyDisabled: `${true}`
2367
2367
  };
2368
2368
  if (renderPreviewLocally) {
2369
- proxiedQueryParams.hsDebugOverridePublicHost = url4.host;
2369
+ proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
2370
2370
  baseURL = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
2371
- pathname = `/cos-rendering/v1/public${url4.pathname}`;
2371
+ pathname = `/cos-rendering/v1/public${url3.pathname}`;
2372
2372
  }
2373
2373
  if (localPreviewToken) {
2374
2374
  proxiedQueryParams = {
@@ -3196,16 +3196,16 @@ var module_default = moduleRouteHandler;
3196
3196
  import http from "http";
3197
3197
  import https from "https";
3198
3198
  import { getAccountId as getAccountId2 } from "@hubspot/local-dev-lib/config";
3199
- async function requestPage(url4, redirects = 0, originalUrl) {
3199
+ async function requestPage(url3, redirects = 0, originalUrl) {
3200
3200
  if (redirects > 5) {
3201
3201
  throw new Error(
3202
3202
  `Hit too many redirects to HEAD requests for ${originalUrl}`
3203
3203
  );
3204
3204
  }
3205
3205
  return new Promise((resolve2, reject) => {
3206
- const protocolAPI = url4.startsWith("https://") ? https : http;
3206
+ const protocolAPI = url3.startsWith("https://") ? https : http;
3207
3207
  protocolAPI.request(
3208
- url4,
3208
+ url3,
3209
3209
  {
3210
3210
  method: "HEAD",
3211
3211
  headers: {
@@ -3232,12 +3232,12 @@ async function requestPage(url4, redirects = 0, originalUrl) {
3232
3232
  }
3233
3233
  }
3234
3234
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
3235
- console.log(`Redirecting to ${res.headers.location} (from ${url4})`);
3235
+ console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
3236
3236
  return resolve2(
3237
3237
  requestPage(
3238
3238
  res.headers.location,
3239
3239
  redirects + 1,
3240
- originalUrl ?? url4
3240
+ originalUrl ?? url3
3241
3241
  )
3242
3242
  );
3243
3243
  }
@@ -3255,11 +3255,11 @@ async function requestPage(url4, redirects = 0, originalUrl) {
3255
3255
  }).end();
3256
3256
  });
3257
3257
  }
3258
- async function fetchContentMetadata(url4, portalId) {
3259
- const { portalIdHeader, contentId, res } = await requestPage(url4);
3258
+ async function fetchContentMetadata(url3, portalId) {
3259
+ const { portalIdHeader, contentId, res } = await requestPage(url3);
3260
3260
  if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
3261
3261
  throw new Error(
3262
- `There were multiple hub ID or content ID headers in the HEAD request to ${url4}`
3262
+ `There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
3263
3263
  );
3264
3264
  } else {
3265
3265
  const portalIdFromResponse = parseInt(portalIdHeader, 10);
@@ -3271,15 +3271,15 @@ async function fetchContentMetadata(url4, portalId) {
3271
3271
  }
3272
3272
  if (res.statusCode !== 200 && !(portalIdFromResponse && pageAccount && contentId)) {
3273
3273
  throw new Error(
3274
- `${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.` : ""}`
3274
+ `${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.` : ""}`
3275
3275
  );
3276
3276
  } else if (!portalId || !contentId) {
3277
3277
  throw new Error(
3278
- `Missing hub ID or content ID headers on HEAD request to ${url4}`
3278
+ `Missing hub ID or content ID headers on HEAD request to ${url3}`
3279
3279
  );
3280
3280
  } else if (isNaN(portalId)) {
3281
3281
  throw new Error(
3282
- `Hub ID from the HEAD request is not a number: '${portalId}' (${url4})`
3282
+ `Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
3283
3283
  );
3284
3284
  }
3285
3285
  const hublet = "na1";
@@ -3405,14 +3405,14 @@ async function fetchPreviewTemplates(accountId, previewToken) {
3405
3405
  url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
3406
3406
  })).data;
3407
3407
  }
3408
- async function fetchModuleByPath(accountId, path14) {
3408
+ async function fetchModuleByPath(accountId, path13) {
3409
3409
  return (await hsCliHttp8.get(accountId, {
3410
- url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path14}?portalId=${accountId}`
3410
+ url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path13}?portalId=${accountId}`
3411
3411
  })).data;
3412
3412
  }
3413
- async function fetchTemplateByPath(accountId, path14) {
3413
+ async function fetchTemplateByPath(accountId, path13) {
3414
3414
  return (await hsCliHttp8.get(accountId, {
3415
- url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path14}?portalId=${accountId}`
3415
+ url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path13}?portalId=${accountId}`
3416
3416
  })).data;
3417
3417
  }
3418
3418
 
@@ -3869,8 +3869,8 @@ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
3869
3869
  var createDevServerRoutes = async (viteServer, storybookPort) => {
3870
3870
  const devServerApp = Router();
3871
3871
  devServerApp.use((request2, response, next) => {
3872
- const { method, url: url4, hostname } = request2;
3873
- debug(`${method}:${hostname}${url4}`);
3872
+ const { method, url: url3, hostname } = request2;
3873
+ debug(`${method}:${hostname}${url3}`);
3874
3874
  next();
3875
3875
  });
3876
3876
  if (storybookPort) {
@@ -3919,9 +3919,6 @@ import express from "express";
3919
3919
  import { Router as Router2 } from "express";
3920
3920
  import { getAccountId as getAccountId3, getEnv as getEnv3 } from "@hubspot/local-dev-lib/config";
3921
3921
  import cors from "cors";
3922
- import { exec } from "child_process";
3923
- import path10 from "path";
3924
- import url2 from "url";
3925
3922
  import { buildStaticEnvConfig as buildStaticEnvConfig6 } from "@hubspot/cms-components";
3926
3923
  function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
3927
3924
  return async function shadowDevServerCheckHandler(request2, response) {
@@ -3997,40 +3994,6 @@ ${error.stack}`
3997
3994
  }
3998
3995
  };
3999
3996
  }
4000
- function getRunTestsHandler() {
4001
- return async function runTestsHandler(request2, response) {
4002
- const cmsDevServerPath = path10.join(
4003
- path10.dirname(url2.fileURLToPath(import.meta.url)),
4004
- "../.."
4005
- );
4006
- exec("npm run test", { cwd: cmsDevServerPath }, (error, stdout, stderr) => {
4007
- if (error) {
4008
- response.status(500).json({ error: stderr });
4009
- return;
4010
- }
4011
- response.status(200).json({ response: stdout });
4012
- });
4013
- };
4014
- }
4015
- function getRunBuildHandler() {
4016
- return async function runTestsHandler(request2, response) {
4017
- const cmsDevServerPath = path10.join(
4018
- path10.dirname(url2.fileURLToPath(import.meta.url)),
4019
- "../.."
4020
- );
4021
- exec(
4022
- "npm run build",
4023
- { cwd: cmsDevServerPath },
4024
- (error, stdout, stderr) => {
4025
- if (error) {
4026
- response.status(500).json({ error: stderr });
4027
- return;
4028
- }
4029
- response.status(200).json({ response: stdout });
4030
- }
4031
- );
4032
- };
4033
- }
4034
3997
  async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
4035
3998
  const shadowDevServerRoutes = Router2();
4036
3999
  shadowDevServerRoutes.get(
@@ -4038,8 +4001,6 @@ async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
4038
4001
  cors(),
4039
4002
  getShadowDevServerCheckHandler(devServerPort, projectName, gates)
4040
4003
  );
4041
- shadowDevServerRoutes.get("/test", cors(), getRunTestsHandler());
4042
- shadowDevServerRoutes.get("/build", cors(), getRunBuildHandler());
4043
4004
  return shadowDevServerRoutes;
4044
4005
  }
4045
4006
 
@@ -4086,7 +4047,25 @@ import fs3 from "node:fs/promises";
4086
4047
  import express2 from "express";
4087
4048
  import { createServer as createViteServer2 } from "vite";
4088
4049
  import { default as react2 } from "@vitejs/plugin-react";
4089
- async function createAppServer(webRoot, port) {
4050
+
4051
+ // src/lib/getDevServerUIData.ts
4052
+ function getReactModules(themeWebRoot) {
4053
+ const { moduleNames } = findAllModulesInRoot(themeWebRoot);
4054
+ return moduleNames;
4055
+ }
4056
+ function getDevServerUIData(reqLocals) {
4057
+ const { themeWebRoot, authedPortalId, projectName } = reqLocals;
4058
+ const moduleNames = getReactModules(themeWebRoot);
4059
+ return {
4060
+ authedPortalId,
4061
+ projectName,
4062
+ moduleNames
4063
+ };
4064
+ }
4065
+ var getDevServerUIData_default = getDevServerUIData;
4066
+
4067
+ // src/createAppServer.ts
4068
+ async function createAppServer(webRoot, reqLocals, port) {
4090
4069
  const app = express2();
4091
4070
  const origin = `http://hslocal.net:${port}`;
4092
4071
  const viteConfig = {
@@ -4133,14 +4112,20 @@ async function createAppServer(webRoot, port) {
4133
4112
  app.use(viteServer.middlewares);
4134
4113
  app.use("*", async (req, res) => {
4135
4114
  try {
4136
- const url4 = req.originalUrl.replace("/", "");
4115
+ const inititialProps = getDevServerUIData_default(reqLocals);
4116
+ const url3 = req.originalUrl.replace("/", "");
4137
4117
  let template = await fs3.readFile("./app/index.html", "utf-8");
4138
- template = await viteServer.transformIndexHtml(url4, template);
4118
+ template = await viteServer.transformIndexHtml(url3, template);
4139
4119
  const { render } = await viteServer.ssrLoadModule(
4140
4120
  "./app/serverEntry.tsx"
4141
4121
  );
4142
- const rendered = await render(url4);
4143
- const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "");
4122
+ const rendered = await render(inititialProps);
4123
+ const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4124
+ `<!--app-script-->`,
4125
+ `<script>window.__hsInitialProps = ${JSON.stringify(
4126
+ inititialProps
4127
+ )}</script>` ?? ""
4128
+ );
4144
4129
  res.status(200).set({ "Content-Type": "text/html" }).send(html);
4145
4130
  } catch (e) {
4146
4131
  viteServer == null ? void 0 : viteServer.ssrFixStacktrace(e);
@@ -4314,7 +4299,7 @@ async function fetchWebsiteDomainNames(portalId) {
4314
4299
  }
4315
4300
 
4316
4301
  // src/lib/validateHSPlatform.ts
4317
- import path11 from "path";
4302
+ import path10 from "path";
4318
4303
  import fs4 from "fs";
4319
4304
  import select from "@inquirer/select";
4320
4305
  import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
@@ -4326,12 +4311,12 @@ function findHSProjectJson(startPath) {
4326
4311
  let currentDir = startPath;
4327
4312
  let dirLevel = 0;
4328
4313
  const maxDirLevel = 4;
4329
- while (path11.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
4330
- const filePath = path11.join(currentDir, HSPROJECT_JSON);
4314
+ while (path10.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
4315
+ const filePath = path10.join(currentDir, HSPROJECT_JSON);
4331
4316
  if (checkFileExists(filePath)) {
4332
4317
  return filePath;
4333
4318
  }
4334
- currentDir = path11.dirname(currentDir);
4319
+ currentDir = path10.dirname(currentDir);
4335
4320
  dirLevel++;
4336
4321
  }
4337
4322
  console.log(
@@ -4637,7 +4622,7 @@ function writeFieldsType(fields, fileName, typeName) {
4637
4622
 
4638
4623
  // src/lib/watchFieldsUpdates.ts
4639
4624
  import fs5 from "fs";
4640
- import path12 from "path";
4625
+ import path11 from "path";
4641
4626
  import readline from "readline";
4642
4627
  var lastSerializedFieldsCache = {};
4643
4628
  var formatAsTypeName = (str) => {
@@ -4649,9 +4634,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
4649
4634
  const getEntryPathFromId = (id) => {
4650
4635
  return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
4651
4636
  };
4652
- const currentModuleId = path12.normalize(filePath);
4637
+ const currentModuleId = path11.normalize(filePath);
4653
4638
  const moduleEntryPath = getEntryPathFromId(currentModuleId);
4654
- const subFolderTokens = moduleEntryPath.split(path12.sep);
4639
+ const subFolderTokens = moduleEntryPath.split(path11.sep);
4655
4640
  return {
4656
4641
  inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
4657
4642
  isRootModuleFile: subFolderTokens.length === 3
@@ -4678,10 +4663,10 @@ var getIndexFile = (filePath, projectRoot) => {
4678
4663
  return void 0;
4679
4664
  if (isRootModuleFile)
4680
4665
  return { indexFilePath: filePath, isRootModuleFile };
4681
- const dir = path12.dirname(filePath);
4666
+ const dir = path11.dirname(filePath);
4682
4667
  const files = fs5.readdirSync(dir);
4683
4668
  const indexFileName = files.find((file) => file.startsWith("index."));
4684
- return indexFileName ? { indexFilePath: path12.join(dir, indexFileName), isRootModuleFile } : void 0;
4669
+ return indexFileName ? { indexFilePath: path11.join(dir, indexFileName), isRootModuleFile } : void 0;
4685
4670
  };
4686
4671
  var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
4687
4672
  let indexFile;
@@ -4705,7 +4690,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
4705
4690
  if (!indexInfo)
4706
4691
  return;
4707
4692
  const { indexFilePath, isRootModuleFile } = indexInfo;
4708
- const indexFileName = path12.parse(indexFilePath).name;
4693
+ const indexFileName = path11.parse(indexFilePath).name;
4709
4694
  const isTypeFile = filePath.endsWith(".types.ts");
4710
4695
  if (isTypeFile)
4711
4696
  return;
@@ -4716,7 +4701,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
4716
4701
  );
4717
4702
  if (fields) {
4718
4703
  const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
4719
- const typeFilePath = path12.join(path12.dirname(filePath), typeFileName);
4704
+ const typeFilePath = path11.join(path11.dirname(filePath), typeFileName);
4720
4705
  const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
4721
4706
  const serializedFields = JSON.stringify(fields);
4722
4707
  if (lastSerializedFields === serializedFields)
@@ -4724,7 +4709,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
4724
4709
  const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
4725
4710
  if (!hasAutoGenComment)
4726
4711
  return;
4727
- const moduleFolderName = path12.basename(path12.dirname(filePath));
4712
+ const moduleFolderName = path11.basename(path11.dirname(filePath));
4728
4713
  const outputTypeName = formatAsTypeName(moduleFolderName);
4729
4714
  const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
4730
4715
  if (didSucceed) {
@@ -4740,7 +4725,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
4740
4725
  var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
4741
4726
  const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
4742
4727
  moduleSubpaths.forEach((modulePath) => {
4743
- const resolvedPath = path12.resolve(projectRoot, modulePath);
4728
+ const resolvedPath = path11.resolve(projectRoot, modulePath);
4744
4729
  maybeUpdateFields(resolvedPath, viteServer, projectRoot);
4745
4730
  });
4746
4731
  const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
@@ -4878,7 +4863,7 @@ Local proxy functionality and module preview routes will not work without settin
4878
4863
  } catch (e) {
4879
4864
  authedHublet = "na1";
4880
4865
  }
4881
- const absoluteWebRoot = normalizePath7(path13.resolve(process.cwd(), webRoot));
4866
+ const absoluteWebRoot = normalizePath7(path12.resolve(process.cwd(), webRoot));
4882
4867
  const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
4883
4868
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
4884
4869
  if (authedPortalId) {
@@ -4970,16 +4955,24 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
4970
4955
  `
4971
4956
  );
4972
4957
  if (showUI) {
4973
- const appWebRoot = path13.join(
4974
- path13.dirname(url3.fileURLToPath(import.meta.url)),
4958
+ const appWebRoot = path12.join(
4959
+ path12.dirname(url2.fileURLToPath(import.meta.url)),
4975
4960
  "../app"
4976
4961
  );
4977
- const appServer = await createAppServer_default(appWebRoot, PORT + 1);
4962
+ const reqLocals = {
4963
+ themeWebRoot: absoluteWebRoot,
4964
+ authedPortalId,
4965
+ authedEnv,
4966
+ authedHublet,
4967
+ projectName,
4968
+ webRootProjectComponentFolder
4969
+ };
4970
+ const appServer = await createAppServer_default(appWebRoot, reqLocals, PORT + 1);
4978
4971
  httpServers.push(appServer);
4979
4972
  }
4980
4973
  if (storybook) {
4981
- const packageRoot = path13.dirname(url3.fileURLToPath(import.meta.url));
4982
- const configPath = path13.resolve(packageRoot, "./storybook-main");
4974
+ const packageRoot = path12.dirname(url2.fileURLToPath(import.meta.url));
4975
+ const configPath = path12.resolve(packageRoot, "./storybook-main");
4983
4976
  sendTrackingRequest("start-storybook");
4984
4977
  const storybookProcess = spawn(
4985
4978
  "sb",
@@ -4999,7 +4992,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
4999
4992
  portalId: authedPortalId.toString(),
5000
4993
  hsEnv: authedEnv,
5001
4994
  hublet: authedHublet,
5002
- WEB_ROOT: path13.join(webRoot, "components")
4995
+ WEB_ROOT: path12.join(webRoot, "components")
5003
4996
  }
5004
4997
  }
5005
4998
  );