@hubspot/cms-dev-server 1.0.6 → 1.0.7

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
@@ -596,8 +596,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
596
596
  );
597
597
  return Object.fromEntries(relativeEntries);
598
598
  }
599
- function toRelativePath(config, path16) {
600
- return path16.replace(`${config.root}/`, "");
599
+ function toRelativePath(config, path17) {
600
+ return path17.replace(`${config.root}/`, "");
601
601
  }
602
602
  function shouldAnalyzeModule(config, moduleInfo, code) {
603
603
  const [fileId, __] = moduleInfo.id.split("?");
@@ -640,11 +640,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
640
640
  let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
641
641
  let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
642
642
  traverse(sourceAst, {
643
- ImportDeclaration(path16) {
644
- if (t.isStringLiteral(path16.node.source, {
643
+ ImportDeclaration(path17) {
644
+ if (t.isStringLiteral(path17.node.source, {
645
645
  value: "@hubspot/cms-components"
646
646
  })) {
647
- for (const specifier of path16.node.specifiers) {
647
+ for (const specifier of path17.node.specifiers) {
648
648
  if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
649
649
  name: CMS_MODULE_COMPONENT_NAME
650
650
  })) {
@@ -658,14 +658,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
658
658
  }
659
659
  }
660
660
  },
661
- JSXOpeningElement(path16) {
662
- if (t.isJSXIdentifier(path16.node.name, {
661
+ JSXOpeningElement(path17) {
662
+ if (t.isJSXIdentifier(path17.node.name, {
663
663
  name: moduleComponentLocalImportName
664
664
  })) {
665
665
  let cmsModuleName;
666
666
  let cmsModulePath;
667
667
  let cmsModuleLabel;
668
- for (const prop of path16.node.attributes) {
668
+ for (const prop of path17.node.attributes) {
669
669
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
670
670
  cmsModuleName = prop.value.value;
671
671
  continue;
@@ -700,11 +700,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
700
700
  }
701
701
  contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
702
702
  }
703
- if (t.isJSXIdentifier(path16.node.name, {
703
+ if (t.isJSXIdentifier(path17.node.name, {
704
704
  name: dndAreaComponentLocalImportName
705
705
  })) {
706
706
  let dndAreaName;
707
- for (const prop of path16.node.attributes) {
707
+ for (const prop of path17.node.attributes) {
708
708
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
709
709
  dndAreaName = prop.value.value;
710
710
  continue;
@@ -1035,7 +1035,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
1035
1035
  var createViteDevServer_default = createViteDevServer;
1036
1036
 
1037
1037
  // src/createDevServer.ts
1038
- import path15 from "path";
1038
+ import path16 from "path";
1039
1039
  import url2 from "url";
1040
1040
  import express2 from "express";
1041
1041
  import http3 from "http";
@@ -1465,7 +1465,7 @@ function trackUsage(action) {
1465
1465
  eventName: EVENT_NAME,
1466
1466
  action,
1467
1467
  nodeVersion: getNodeVersionData(),
1468
- version: "1.0.6",
1468
+ version: "1.0.7",
1469
1469
  os: getPlatform()
1470
1470
  };
1471
1471
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1538,12 +1538,12 @@ var findLocalRenderPlaceholders = (body) => {
1538
1538
  );
1539
1539
  offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
1540
1540
  if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
1541
- const path16 = body.substring(
1541
+ const path17 = body.substring(
1542
1542
  startOffset + localJsRenderStartString.length,
1543
1543
  pathEndOffset
1544
1544
  );
1545
1545
  offsetSoFar = pathEndOffset + 1;
1546
- if (startOffset >= 0 && path16) {
1546
+ if (startOffset >= 0 && path17) {
1547
1547
  const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
1548
1548
  const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
1549
1549
  offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
@@ -1568,7 +1568,7 @@ var findLocalRenderPlaceholders = (body) => {
1568
1568
  result.push({
1569
1569
  startOffset,
1570
1570
  endOffset: endOffset + localJsRenderEndString.length,
1571
- path: path16,
1571
+ path: path17,
1572
1572
  json
1573
1573
  });
1574
1574
  }
@@ -1947,9 +1947,9 @@ var customColors = [
1947
1947
  ];
1948
1948
  var Converter = new AnsiToHtmlConverter({ colors: customColors });
1949
1949
  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;`;
1950
- var renderLocalError_default = (path16, error) => {
1950
+ var renderLocalError_default = (path17, error) => {
1951
1951
  const stackWithColorClasses = Converter.toHtml(error.stack);
1952
- return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path16}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
1952
+ return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path17}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
1953
1953
  };
1954
1954
 
1955
1955
  // src/proxyPage/fetchPreviewInfo.ts
@@ -3512,18 +3512,18 @@ async function fetchPreviewTemplates(accountId, previewToken) {
3512
3512
  url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
3513
3513
  })).data;
3514
3514
  }
3515
- async function fetchModuleByPath(accountId, path16) {
3515
+ async function fetchModuleByPath(accountId, path17) {
3516
3516
  return (await hsCliHttp8.get(accountId, {
3517
- url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path16}?portalId=${accountId}`
3517
+ url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path17}?portalId=${accountId}`
3518
3518
  })).data;
3519
3519
  }
3520
- async function fetchTemplateByPath(accountId, path16) {
3520
+ async function fetchTemplateByPath(accountId, path17) {
3521
3521
  return (await hsCliHttp8.get(accountId, {
3522
- url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path16}?portalId=${accountId}`
3522
+ url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path17}?portalId=${accountId}`
3523
3523
  })).data;
3524
3524
  }
3525
- async function fetchModulePageDependencies(accountId, path16) {
3526
- const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path16}`;
3525
+ async function fetchModulePageDependencies(accountId, path17) {
3526
+ const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path17}`;
3527
3527
  return (await hsCliHttp8.get(accountId, { url: url3 })).data;
3528
3528
  }
3529
3529
 
@@ -3540,9 +3540,9 @@ function isCodedFile(filePath) {
3540
3540
  return TEMPLATE_EXTENSION_REGEX.test(filePath);
3541
3541
  }
3542
3542
 
3543
- // src/routes/homeRouteHandler.tsx
3543
+ // src/routes/legacyRouteHandler.tsx
3544
3544
  import { Fragment, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
3545
- var homeRouteHandler = async (request2, response, next) => {
3545
+ var legacyRouteHandler = async (request2, response, next) => {
3546
3546
  const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
3547
3547
  if (domainToProxy) {
3548
3548
  next();
@@ -3587,7 +3587,7 @@ var homeRouteHandler = async (request2, response, next) => {
3587
3587
  );
3588
3588
  response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
3589
3589
  };
3590
- var homeRouteHandler_default = homeRouteHandler;
3590
+ var legacyRouteHandler_default = legacyRouteHandler;
3591
3591
 
3592
3592
  // src/routes/proxyPathPageRouteHandler.tsx
3593
3593
  import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
@@ -4013,8 +4013,61 @@ function buildTemplateIndex() {
4013
4013
  `);
4014
4014
  }
4015
4015
 
4016
- // src/routes/createDevServerRoutes.ts
4016
+ // src/routes/createAppServerAPIRoutes.ts
4017
+ import { Router } from "express";
4018
+ import { spawn } from "child_process";
4019
+ function getOpenCommand() {
4020
+ switch (process.platform) {
4021
+ case "darwin":
4022
+ return "open";
4023
+ case "win32":
4024
+ return "start";
4025
+ default:
4026
+ return "xdg-open";
4027
+ }
4028
+ }
4029
+ async function handleGetModulePages(req, res, next) {
4030
+ const { path: path17, portalId } = req.query;
4031
+ if (!path17 || !portalId) {
4032
+ return res.status(400).json({ error: "Missing required parameters" });
4033
+ }
4034
+ try {
4035
+ sendTrackingRequest("handle-module-dependencies");
4036
+ const data = await fetchModulePageDependencies(
4037
+ Number(portalId),
4038
+ path17
4039
+ );
4040
+ res.json(data);
4041
+ } catch (err) {
4042
+ next(err);
4043
+ }
4044
+ }
4045
+ function handleOpenFile(req, res, next) {
4046
+ const { path: path17 } = req.query;
4047
+ if (!path17) {
4048
+ return res.status(400).json({ error: "Missing required parameters" });
4049
+ }
4050
+ try {
4051
+ sendTrackingRequest("handle-open-file");
4052
+ const command = getOpenCommand();
4053
+ spawn(command, [path17], { detached: true }).unref();
4054
+ res.sendStatus(200);
4055
+ } catch (err) {
4056
+ next(err);
4057
+ }
4058
+ }
4059
+ function createAppServerAPIRoutes() {
4060
+ const router = Router();
4061
+ router.get("/module-pages", handleGetModulePages);
4062
+ router.get("/open-file", handleOpenFile);
4063
+ return router;
4064
+ }
4065
+ var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
4066
+
4067
+ // src/routes/appServerRouteHandler.ts
4017
4068
  import fs4 from "node:fs/promises";
4069
+ import path12 from "path";
4070
+ import { pathToFileURL } from "url";
4018
4071
 
4019
4072
  // src/lib/getDevServerUIData.ts
4020
4073
  import path11 from "path";
@@ -4052,13 +4105,16 @@ var templateTypeMap = {
4052
4105
  14: "Backup Unsubscribe",
4053
4106
  27: "Search Results"
4054
4107
  };
4055
- function mapReactModules(modules, themeWebRoot, viteServer) {
4108
+ function mapReactModules(modules, themeWebRoot, appViteServer) {
4056
4109
  return Promise.all(
4057
4110
  modules.moduleNames.map(async (name, index) => {
4058
4111
  const modulePath = normalizePath9(
4059
4112
  path11.resolve(themeWebRoot, "components/modules/", name)
4060
4113
  );
4061
- const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
4114
+ const fieldsJson = await renderModuleFieldsJson_default(
4115
+ appViteServer,
4116
+ modulePath
4117
+ );
4062
4118
  return {
4063
4119
  name,
4064
4120
  type: "react" /* REACT */,
@@ -4108,7 +4164,7 @@ function detectPackageManager(projectRoot) {
4108
4164
  return "pnpm";
4109
4165
  return "npm";
4110
4166
  }
4111
- async function getDevServerUIData(reqLocals, viteServer) {
4167
+ async function getDevServerUIData(appLocals) {
4112
4168
  const {
4113
4169
  themeWebRoot,
4114
4170
  authedEnv,
@@ -4117,8 +4173,9 @@ async function getDevServerUIData(reqLocals, viteServer) {
4117
4173
  localPreviewToken,
4118
4174
  webRootProjectComponentFolder,
4119
4175
  sslEnabled,
4120
- fieldBuilderEnabled
4121
- } = reqLocals;
4176
+ fieldBuilderEnabled,
4177
+ appViteServer
4178
+ } = appLocals;
4122
4179
  const packageJson = getPackageJson(themeWebRoot);
4123
4180
  const packageManager = detectPackageManager(themeWebRoot);
4124
4181
  const runCommand = packageManager === "yarn" ? "yarn" : `${packageManager} run`;
@@ -4134,7 +4191,7 @@ async function getDevServerUIData(reqLocals, viteServer) {
4134
4191
  const reactModules = await mapReactModules(
4135
4192
  modulesData,
4136
4193
  themeWebRoot,
4137
- viteServer
4194
+ appViteServer
4138
4195
  );
4139
4196
  let hubLModuleData = { objects: [] };
4140
4197
  let hubLTemplateData = { objects: [] };
@@ -4165,71 +4222,53 @@ async function getDevServerUIData(reqLocals, viteServer) {
4165
4222
  fieldBuilderEnabled
4166
4223
  };
4167
4224
  }
4168
- var getDevServerUIData_default = getDevServerUIData;
4169
4225
 
4170
- // src/routes/createAppServerRoutes.ts
4171
- import { Router } from "express";
4172
- import { spawn } from "child_process";
4173
- function getOpenCommand() {
4174
- switch (process.platform) {
4175
- case "darwin":
4176
- return "open";
4177
- case "win32":
4178
- return "start";
4179
- default:
4180
- return "xdg-open";
4181
- }
4182
- }
4183
- async function handleGetModulePages(req, res, next) {
4184
- const { path: path16, portalId } = req.query;
4185
- if (!path16 || !portalId) {
4186
- return res.status(400).json({ error: "Missing required parameters" });
4187
- }
4226
+ // src/routes/appServerRouteHandler.ts
4227
+ var isProd = true;
4228
+ var appServerRouteHandler = async (req, res, __next) => {
4188
4229
  try {
4189
- sendTrackingRequest("handle-module-dependencies");
4190
- const data = await fetchModulePageDependencies(
4191
- Number(portalId),
4192
- path16
4230
+ sendTrackingRequest("view-index-route");
4231
+ const appLocals = req.app.locals.appLocals;
4232
+ const { appWebRoot, appViteServer } = appLocals;
4233
+ const initialProps = await getDevServerUIData(appLocals);
4234
+ const url3 = req.originalUrl.replace("/", "");
4235
+ const templatePath = path12.join(appWebRoot, "index.html");
4236
+ const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
4237
+ let render;
4238
+ let template = await fs4.readFile(path12.join(templatePath), "utf-8");
4239
+ if (isProd) {
4240
+ const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
4241
+ render = ssrRender;
4242
+ } else {
4243
+ template = await appViteServer.transformIndexHtml(url3, template);
4244
+ render = (await appViteServer.ssrLoadModule(serverEntryPath)).render;
4245
+ }
4246
+ const rendered = await render(initialProps);
4247
+ const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4248
+ `<!--app-script-->`,
4249
+ `<script>window.__hsInitialProps = ${JSON.stringify(
4250
+ initialProps
4251
+ )};</script>` ?? ""
4193
4252
  );
4194
- res.json(data);
4195
- } catch (err) {
4196
- next(err);
4197
- }
4198
- }
4199
- function handleOpenFile(req, res, next) {
4200
- const { path: path16 } = req.query;
4201
- if (!path16) {
4202
- return res.status(400).json({ error: "Missing required parameters" });
4203
- }
4204
- try {
4205
- sendTrackingRequest("handle-open-file");
4206
- const command = getOpenCommand();
4207
- spawn(command, [path16], { detached: true }).unref();
4208
- res.sendStatus(200);
4209
- } catch (err) {
4210
- next(err);
4253
+ res.status(200).set({ "Content-Type": "text/html" }).send(html);
4254
+ } catch (e) {
4255
+ const { appViteServer } = req.app.locals.appLocals;
4256
+ appViteServer == null ? void 0 : appViteServer.ssrFixStacktrace(e);
4257
+ console.log(e.stack);
4258
+ res.status(500).end(e.stack);
4211
4259
  }
4212
- }
4213
- function createAppServerRoutes() {
4214
- const router = Router();
4215
- router.get("/module-pages", handleGetModulePages);
4216
- router.get("/open-file", handleOpenFile);
4217
- return router;
4218
- }
4219
- var createAppServerRoutes_default = createAppServerRoutes;
4260
+ };
4261
+ var appServerRouteHandler_default = appServerRouteHandler;
4220
4262
 
4221
4263
  // src/routes/createDevServerRoutes.ts
4222
- import path12 from "path";
4223
- import { fileURLToPath, pathToFileURL } from "url";
4224
- var __filename = fileURLToPath(import.meta.url);
4225
- var __dirname = path12.dirname(__filename);
4226
- var isProd = true;
4264
+ import path13 from "path";
4265
+ var isProd2 = true;
4227
4266
  var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
4228
4267
  (domain) => `storybook.${domain}`
4229
4268
  );
4230
- var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) => {
4269
+ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
4231
4270
  const devServerApp = Router2();
4232
- const { appServer, reqLocals } = appServerConfig || {};
4271
+ const { appViteServer, appWebRoot } = appLocals || {};
4233
4272
  devServerApp.use((request2, response, next) => {
4234
4273
  const { method, url: url3, hostname } = request2;
4235
4274
  debug(`${method}:${hostname}${url3}`);
@@ -4247,46 +4286,20 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
4247
4286
  );
4248
4287
  }
4249
4288
  devServerApp.use(urlencoded());
4250
- const appWebRoot = isProd ? path12.join(__dirname, "app") : appServerConfig == null ? void 0 : appServerConfig.appWebRoot;
4251
- if (isProd) {
4252
- const distAssetsPath = path12.join(appWebRoot, "assets");
4289
+ if (isProd2) {
4290
+ const distAssetsPath = path13.join(appWebRoot, "assets");
4253
4291
  devServerApp.use("/assets", expressStatic(distAssetsPath));
4254
4292
  } else {
4255
- devServerApp.use(appServer.middlewares);
4293
+ devServerApp.use(appViteServer.middlewares);
4256
4294
  }
4257
4295
  devServerApp.use(viteServer.middlewares);
4258
- devServerApp.use("/api", createAppServerRoutes_default());
4259
- devServerApp.get("/", async (req, res) => {
4260
- try {
4261
- sendTrackingRequest("view-index-route");
4262
- const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
4263
- const url3 = req.originalUrl.replace("/", "");
4264
- const templatePath = path12.join(appWebRoot, "index.html");
4265
- const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
4266
- let render;
4267
- let template = await fs4.readFile(path12.join(templatePath), "utf-8");
4268
- if (isProd) {
4269
- const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
4270
- render = ssrRender;
4271
- } else {
4272
- template = await appServer.transformIndexHtml(url3, template);
4273
- render = (await appServer.ssrLoadModule(serverEntryPath)).render;
4274
- }
4275
- const rendered = await render(initialProps);
4276
- const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4277
- `<!--app-script-->`,
4278
- `<script>window.__hsInitialProps = ${JSON.stringify(
4279
- initialProps
4280
- )};</script>` ?? ""
4281
- );
4282
- res.status(200).set({ "Content-Type": "text/html" }).send(html);
4283
- } catch (e) {
4284
- appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
4285
- console.log(e.stack);
4286
- res.status(500).end(e.stack);
4287
- }
4288
- });
4289
- devServerApp.get("/legacy", homeRouteHandler_default);
4296
+ devServerApp.use("/api", createAppServerAPIRoutes_default());
4297
+ if (appLocals.projectName) {
4298
+ devServerApp.get("/", appServerRouteHandler_default);
4299
+ devServerApp.get("/legacy", legacyRouteHandler_default);
4300
+ } else {
4301
+ devServerApp.get("/", legacyRouteHandler_default);
4302
+ }
4290
4303
  devServerApp.get("/proxy", proxyPathPageRouteHandler);
4291
4304
  devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
4292
4305
  devServerApp.get("/partial/:partial", partial_default);
@@ -4639,7 +4652,7 @@ async function fetchWebsiteDomainNames(portalId) {
4639
4652
  }
4640
4653
 
4641
4654
  // src/lib/validateHSPlatform.ts
4642
- import path13 from "path";
4655
+ import path14 from "path";
4643
4656
  import fs5 from "fs";
4644
4657
  import select from "@inquirer/select";
4645
4658
  import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
@@ -4651,12 +4664,12 @@ function findHSProjectJson(startPath) {
4651
4664
  let currentDir = startPath;
4652
4665
  let dirLevel = 0;
4653
4666
  const maxDirLevel = 4;
4654
- while (path13.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
4655
- const filePath = path13.join(currentDir, HSPROJECT_JSON);
4667
+ while (path14.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
4668
+ const filePath = path14.join(currentDir, HSPROJECT_JSON);
4656
4669
  if (checkFileExists(filePath)) {
4657
4670
  return filePath;
4658
4671
  }
4659
- currentDir = path13.dirname(currentDir);
4672
+ currentDir = path14.dirname(currentDir);
4660
4673
  dirLevel++;
4661
4674
  }
4662
4675
  console.log(
@@ -4962,7 +4975,7 @@ function writeFieldsType(fields, fileName, typeName) {
4962
4975
 
4963
4976
  // src/lib/watchFieldsUpdates.ts
4964
4977
  import fs6 from "fs";
4965
- import path14 from "path";
4978
+ import path15 from "path";
4966
4979
  import readline from "readline";
4967
4980
  var lastSerializedFieldsCache = {};
4968
4981
  var formatAsTypeName = (str) => {
@@ -4974,9 +4987,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
4974
4987
  const getEntryPathFromId = (id) => {
4975
4988
  return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
4976
4989
  };
4977
- const currentModuleId = path14.normalize(filePath);
4990
+ const currentModuleId = path15.normalize(filePath);
4978
4991
  const moduleEntryPath = getEntryPathFromId(currentModuleId);
4979
- const subFolderTokens = moduleEntryPath.split(path14.sep);
4992
+ const subFolderTokens = moduleEntryPath.split(path15.sep);
4980
4993
  return {
4981
4994
  inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
4982
4995
  isRootModuleFile: subFolderTokens.length === 3
@@ -5003,10 +5016,10 @@ var getIndexFile = (filePath, projectRoot) => {
5003
5016
  return void 0;
5004
5017
  if (isRootModuleFile)
5005
5018
  return { indexFilePath: filePath, isRootModuleFile };
5006
- const dir = path14.dirname(filePath);
5019
+ const dir = path15.dirname(filePath);
5007
5020
  const files = fs6.readdirSync(dir);
5008
5021
  const indexFileName = files.find((file) => file.startsWith("index."));
5009
- return indexFileName ? { indexFilePath: path14.join(dir, indexFileName), isRootModuleFile } : void 0;
5022
+ return indexFileName ? { indexFilePath: path15.join(dir, indexFileName), isRootModuleFile } : void 0;
5010
5023
  };
5011
5024
  var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
5012
5025
  let indexFile;
@@ -5030,7 +5043,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5030
5043
  if (!indexInfo)
5031
5044
  return;
5032
5045
  const { indexFilePath, isRootModuleFile } = indexInfo;
5033
- const indexFileName = path14.parse(indexFilePath).name;
5046
+ const indexFileName = path15.parse(indexFilePath).name;
5034
5047
  const isTypeFile = filePath.endsWith(".types.ts");
5035
5048
  if (isTypeFile)
5036
5049
  return;
@@ -5041,7 +5054,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5041
5054
  );
5042
5055
  if (fields) {
5043
5056
  const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
5044
- const typeFilePath = path14.join(path14.dirname(filePath), typeFileName);
5057
+ const typeFilePath = path15.join(path15.dirname(filePath), typeFileName);
5045
5058
  const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
5046
5059
  const serializedFields = JSON.stringify(fields);
5047
5060
  if (lastSerializedFields === serializedFields)
@@ -5049,7 +5062,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5049
5062
  const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
5050
5063
  if (!hasAutoGenComment)
5051
5064
  return;
5052
- const moduleFolderName = path14.basename(path14.dirname(filePath));
5065
+ const moduleFolderName = path15.basename(path15.dirname(filePath));
5053
5066
  const outputTypeName = formatAsTypeName(moduleFolderName);
5054
5067
  const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
5055
5068
  if (didSucceed) {
@@ -5065,7 +5078,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
5065
5078
  var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
5066
5079
  const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
5067
5080
  moduleSubpaths.forEach((modulePath) => {
5068
- const resolvedPath = path14.resolve(projectRoot, modulePath);
5081
+ const resolvedPath = path15.resolve(projectRoot, modulePath);
5069
5082
  maybeUpdateFields(resolvedPath, viteServer, projectRoot);
5070
5083
  });
5071
5084
  const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
@@ -5203,7 +5216,7 @@ Local proxy functionality and module preview routes will not work without settin
5203
5216
  } catch (e) {
5204
5217
  authedHublet = "na1";
5205
5218
  }
5206
- const absoluteWebRoot = normalizePath10(path15.resolve(process.cwd(), webRoot));
5219
+ const absoluteWebRoot = normalizePath10(path16.resolve(process.cwd(), webRoot));
5207
5220
  const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
5208
5221
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
5209
5222
  if (authedPortalId) {
@@ -5255,9 +5268,17 @@ Local proxy functionality and module preview routes will not work without settin
5255
5268
  expressServer.locals.domainsToProxy = domainsToProxy;
5256
5269
  expressServer.locals.localPreviewToken = _localPreviewToken;
5257
5270
  expressServer.use(bodyParser.json());
5258
- const __dirname2 = path15.dirname(url2.fileURLToPath(new URL(import.meta.url)));
5259
- const appWebRoot = normalizePath10(path15.resolve(__dirname2, "../app"));
5260
- const reqLocals = {
5271
+ const __dirname = path16.dirname(url2.fileURLToPath(new URL(import.meta.url)));
5272
+ let appWebRoot = normalizePath10(path16.resolve(__dirname, "../app"));
5273
+ if (true) {
5274
+ appWebRoot = path16.join(__dirname, "app");
5275
+ }
5276
+ const appViteServer = await createAppServer_default(
5277
+ appWebRoot,
5278
+ PORT,
5279
+ sslEnabledOption
5280
+ );
5281
+ const appLocals = {
5261
5282
  themeWebRoot: absoluteWebRoot,
5262
5283
  authedPortalId,
5263
5284
  authedEnv,
@@ -5266,24 +5287,17 @@ Local proxy functionality and module preview routes will not work without settin
5266
5287
  webRootProjectComponentFolder,
5267
5288
  localPreviewToken: _localPreviewToken,
5268
5289
  sslEnabled: sslEnabledOption,
5269
- fieldBuilderEnabled
5270
- };
5271
- const appServer = await createAppServer_default(
5290
+ fieldBuilderEnabled,
5272
5291
  appWebRoot,
5273
- PORT,
5274
- sslEnabledOption
5275
- );
5276
- const appServerConfig = {
5277
- appServer,
5278
- reqLocals,
5279
- appWebRoot
5292
+ appViteServer
5280
5293
  };
5294
+ expressServer.locals.appLocals = appLocals;
5281
5295
  expressServer.use(
5282
5296
  BASE_PATH,
5283
5297
  await createDevServerRoutes_default(
5284
5298
  viteServer,
5285
- storybook ? STORYBOOK_PORT : null,
5286
- appServerConfig
5299
+ appLocals,
5300
+ storybook ? STORYBOOK_PORT : null
5287
5301
  )
5288
5302
  );
5289
5303
  if (sslEnabledOption) {
@@ -5326,8 +5340,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5326
5340
  `
5327
5341
  );
5328
5342
  if (storybook) {
5329
- const packageRoot = path15.dirname(url2.fileURLToPath(import.meta.url));
5330
- const configPath = path15.resolve(packageRoot, "./storybook-main");
5343
+ const packageRoot = path16.dirname(url2.fileURLToPath(import.meta.url));
5344
+ const configPath = path16.resolve(packageRoot, "./storybook-main");
5331
5345
  sendTrackingRequest("start-storybook");
5332
5346
  const storybookProcess = spawn2(
5333
5347
  "sb",
@@ -5347,7 +5361,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5347
5361
  portalId: authedPortalId.toString(),
5348
5362
  hsEnv: authedEnv,
5349
5363
  hublet: authedHublet,
5350
- WEB_ROOT: path15.join(webRoot, "components")
5364
+ WEB_ROOT: path16.join(webRoot, "components")
5351
5365
  }
5352
5366
  }
5353
5367
  );