@hubspot/cms-dev-server 1.2.33 → 1.2.35

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
@@ -38,8 +38,8 @@ import cliProgress from "cli-progress";
38
38
  import { FILE_UPLOAD_RESULT_TYPES } from "@hubspot/local-dev-lib/constants/files";
39
39
 
40
40
  // src/lib/cliUtils.ts
41
- import fs from "fs";
42
- import path from "path";
41
+ import fs2 from "fs";
42
+ import path2 from "path";
43
43
  import { walk } from "@hubspot/local-dev-lib/fs";
44
44
  import { createIgnoreFilter } from "@hubspot/local-dev-lib/ignoreRules";
45
45
  import { isAllowedExtension } from "@hubspot/local-dev-lib/path";
@@ -50,6 +50,49 @@ import { getThemeJSONPath } from "@hubspot/local-dev-lib/cms/themes";
50
50
  import findup from "findup-sync";
51
51
  import { getAbsoluteFilePath } from "@hubspot/local-dev-lib/path";
52
52
  import { logger } from "@hubspot/local-dev-lib/logger";
53
+
54
+ // src/lib/hsmetaUtils.ts
55
+ import path from "path";
56
+ import fs from "fs";
57
+ var HSMETA_FILENAMES = [
58
+ "theme-hsmeta.json",
59
+ "cms-assets-hsmeta.json"
60
+ ];
61
+ function getSubdirectories(dirPath) {
62
+ try {
63
+ return fs.readdirSync(dirPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
64
+ } catch {
65
+ return [];
66
+ }
67
+ }
68
+ function hsmetaCandidatePaths(srcPath) {
69
+ const subdirs = getSubdirectories(srcPath);
70
+ return subdirs.flatMap(
71
+ (subdir) => HSMETA_FILENAMES.map((filename) => path.join(srcPath, subdir, filename))
72
+ );
73
+ }
74
+ function tryParseUid(hsmetaPath) {
75
+ try {
76
+ const hsmeta = JSON.parse(fs.readFileSync(hsmetaPath, "utf8"));
77
+ return hsmeta.uid ?? null;
78
+ } catch (parseErr) {
79
+ console.warn(`Could not parse ${hsmetaPath}:`, parseErr.message);
80
+ return null;
81
+ }
82
+ }
83
+ function findHsmetaUid(projectDir, srcDir) {
84
+ const srcPath = path.join(projectDir, srcDir);
85
+ for (const candidatePath of hsmetaCandidatePaths(srcPath)) {
86
+ if (!fs.existsSync(candidatePath))
87
+ continue;
88
+ const uid = tryParseUid(candidatePath);
89
+ if (uid)
90
+ return uid;
91
+ }
92
+ return null;
93
+ }
94
+
95
+ // src/lib/cliUtils.ts
53
96
  import {
54
97
  isHubSpotHttpError,
55
98
  isSystemError,
@@ -88,7 +131,7 @@ function previewProjectPrompt(themeComponents) {
88
131
  message: "[--theme] Select which theme to preview.",
89
132
  type: "list",
90
133
  choices: themeComponents.map((t2) => {
91
- const themeName = path.basename(t2.path);
134
+ const themeName = path2.basename(t2.path);
92
135
  return {
93
136
  name: themeName,
94
137
  value: t2.path
@@ -105,7 +148,7 @@ var getProjectConfig = async (_dir, isUsingLocalWorkspace = false) => {
105
148
  }
106
149
  const PROJECT_CONFIG_FILE = "hsproject.json";
107
150
  return findup(PROJECT_CONFIG_FILE, {
108
- cwd: path.resolve(__dir),
151
+ cwd: path2.resolve(__dir),
109
152
  nocase: true
110
153
  });
111
154
  };
@@ -114,10 +157,10 @@ var getProjectConfig = async (_dir, isUsingLocalWorkspace = false) => {
114
157
  return { projectConfig: null, projectDir: null };
115
158
  }
116
159
  try {
117
- const config = fs.readFileSync(configPath, "utf8");
160
+ const config = fs2.readFileSync(configPath, "utf8");
118
161
  const projectConfig = JSON.parse(config);
119
162
  return {
120
- projectDir: path.dirname(configPath),
163
+ projectDir: path2.dirname(configPath),
121
164
  projectConfig
122
165
  };
123
166
  } catch (e) {
@@ -127,7 +170,7 @@ var getProjectConfig = async (_dir, isUsingLocalWorkspace = false) => {
127
170
  function loadConfigFile(configPath) {
128
171
  if (configPath) {
129
172
  try {
130
- const source = fs.readFileSync(configPath);
173
+ const source = fs2.readFileSync(configPath);
131
174
  const parsedConfig = JSON.parse(source);
132
175
  return parsedConfig;
133
176
  } catch (e) {
@@ -153,7 +196,7 @@ async function findProjectComponents(projectSourceDir) {
153
196
  console.error(e);
154
197
  }
155
198
  projectFiles.forEach((projectFile) => {
156
- const { base, dir } = path.parse(projectFile);
199
+ const { base, dir } = path2.parse(projectFile);
157
200
  if (Object.values(CONFIG_FILES).includes(base)) {
158
201
  const parsedAppConfig = loadConfigFile(projectFile);
159
202
  if (parsedAppConfig) {
@@ -179,7 +222,7 @@ function getAppCardConfigs(appConfig, appPath) {
179
222
  if (cards) {
180
223
  cards.forEach(({ file }) => {
181
224
  if (typeof file === "string") {
182
- const cardConfigPath = path.join(appPath, file);
225
+ const cardConfigPath = path2.join(appPath, file);
183
226
  const cardConfig = loadConfigFile(cardConfigPath);
184
227
  if (cardConfig) {
185
228
  cardConfigs.push(cardConfig);
@@ -206,36 +249,34 @@ function getIsLegacyApp(appConfig, appPath) {
206
249
  function hasNewDirectoryStructure(platformVersion) {
207
250
  return parseFloat(platformVersion) >= 2025.2;
208
251
  }
209
- function readThemeHsmeta(projectDir, srcDir = "src") {
210
- const hsmetaPath = path.join(
211
- projectDir,
212
- srcDir,
213
- "theme",
214
- "theme-hsmeta.json"
215
- );
216
- if (!fs.existsSync(hsmetaPath)) {
252
+ function findAndReadHsmeta(projectDir, srcDir = "src") {
253
+ const srcPath = path2.join(projectDir, srcDir);
254
+ const candidates = hsmetaCandidatePaths(srcPath);
255
+ const hsmetaPath = candidates.find((p) => fs2.existsSync(p));
256
+ if (!hsmetaPath) {
217
257
  console.error(
218
- `Error: theme-hsmeta.json not found at expected path: ${hsmetaPath}. For platformVersion 2025.2 and higher, the project structure requires a theme-hsmeta.json file.`
258
+ `Error: No hsmeta file (theme-hsmeta.json or cms-assets-hsmeta.json) found in any subdirectory of ${srcPath}. For platformVersion 2025.2 and higher, the project structure requires an hsmeta file.`
219
259
  );
220
260
  process2.exit(1);
221
261
  }
262
+ const hsmetaFilename = path2.basename(hsmetaPath);
263
+ let hsmeta;
222
264
  try {
223
- const hsmetaContent = fs.readFileSync(hsmetaPath, "utf8");
224
- const hsmeta = JSON.parse(hsmetaContent);
225
- if (!hsmeta.uid) {
226
- console.error(
227
- `Error: theme-hsmeta.json at ${hsmetaPath} is missing required 'uid' field.`
228
- );
229
- process2.exit(1);
230
- }
231
- return hsmeta;
265
+ hsmeta = JSON.parse(fs2.readFileSync(hsmetaPath, "utf8"));
232
266
  } catch (e) {
233
267
  console.error(
234
- `Error: Failed to read or parse theme-hsmeta.json at ${hsmetaPath}`
268
+ `Error: Failed to read or parse ${hsmetaFilename} at ${hsmetaPath}`
235
269
  );
236
270
  console.error(e.message);
237
271
  process2.exit(1);
238
272
  }
273
+ if (!hsmeta.uid) {
274
+ console.error(
275
+ `Error: ${hsmetaFilename} at ${hsmetaPath} is missing required 'uid' field.`
276
+ );
277
+ process2.exit(1);
278
+ }
279
+ return hsmeta;
239
280
  }
240
281
  async function determineSrcAndDest(webRoot2, isUsingLocalWorkspace = false) {
241
282
  let absoluteSrc;
@@ -260,14 +301,14 @@ async function determineSrcAndDest(webRoot2, isUsingLocalWorkspace = false) {
260
301
  const answer = await previewProjectPrompt(themeComponents);
261
302
  themeJsonPath = `${answer.themeComponentPath}/theme.json`;
262
303
  }
263
- const { dir: themeDir } = path.parse(themeJsonPath);
304
+ const { dir: themeDir } = path2.parse(themeJsonPath);
264
305
  absoluteSrc = themeDir;
265
- const { base: themeName } = path.parse(themeDir);
306
+ const { base: themeName } = path2.parse(themeDir);
266
307
  const platformVersion = projectConfig.platformVersion || "2025.1";
267
308
  const isNewStructure = hasNewDirectoryStructure(platformVersion);
268
309
  if (isNewStructure) {
269
310
  const srcDir = projectConfig.srcDir || "src";
270
- const hsmeta = readThemeHsmeta(projectDir, srcDir);
311
+ const hsmeta = findAndReadHsmeta(projectDir, srcDir);
271
312
  const uid = hsmeta.uid;
272
313
  dest = `@projects/${projectConfig.name}/${uid}`;
273
314
  } else {
@@ -298,7 +339,7 @@ async function getUploadableFileList(src, convertFields) {
298
339
  const uploadableFiles = [];
299
340
  let skipFiles = [];
300
341
  for (const filePath of allowedFiles) {
301
- const fileName = path.basename(filePath);
342
+ const fileName = path2.basename(filePath);
302
343
  if (skipFiles.includes(filePath))
303
344
  continue;
304
345
  const isConvertable = isConvertableFieldJs(src, filePath, convertFields);
@@ -322,15 +363,15 @@ function promptUser(promptConfig) {
322
363
  }
323
364
  async function fieldsJsPrompt(filePath, projectDir, skipFiles = []) {
324
365
  const FIELDS_FILES = ["fields.json", "fields.js", "fields.cjs", "fields.mjs"];
325
- const dirName = path.dirname(filePath);
326
- const fileChoices = fs.readdirSync(dirName).filter((file) => FIELDS_FILES.includes(file)).map((file) => path.resolve(dirName, file)).filter((file) => !skipFiles.includes(file));
366
+ const dirName = path2.dirname(filePath);
367
+ const fileChoices = fs2.readdirSync(dirName).filter((file) => FIELDS_FILES.includes(file)).map((file) => path2.resolve(dirName, file)).filter((file) => !skipFiles.includes(file));
327
368
  if (!fileChoices.length)
328
369
  return [filePath, []];
329
370
  if (fileChoices.length === 1)
330
371
  return [fileChoices[0], []];
331
372
  projectDir = projectDir.substring(0, projectDir.lastIndexOf("/"));
332
373
  const projectDirRegex = new RegExp(`^${escapeRegExp(projectDir)}`);
333
- const fileDir = path.dirname(fileChoices[0]).replace(projectDirRegex, "");
374
+ const fileDir = path2.dirname(fileChoices[0]).replace(projectDirRegex, "");
334
375
  const selection = [];
335
376
  fileChoices.forEach((fileChoice) => {
336
377
  selection.push({
@@ -801,8 +842,8 @@ async function buildThemePreviewOptions(webRoot2, isUsingLocalWorkspace = false)
801
842
  }
802
843
 
803
844
  // src/createDevServer.ts
804
- import path17 from "path";
805
- import fs8 from "fs";
845
+ import path18 from "path";
846
+ import fs9 from "fs";
806
847
  import url2 from "url";
807
848
  import express2 from "express";
808
849
  import http3 from "http";
@@ -817,9 +858,10 @@ import {
817
858
  static as expressStatic
818
859
  } from "express";
819
860
  import { createProxyMiddleware as createProxyMiddleware2 } from "http-proxy-middleware";
861
+ import cors from "cors";
820
862
 
821
863
  // src/routes/partial.ts
822
- import path8 from "path";
864
+ import path9 from "path";
823
865
  import { normalizePath as normalizePath5 } from "vite";
824
866
 
825
867
  // src/lib/fullOriginalUrlFromRequest.ts
@@ -836,28 +878,28 @@ import {
836
878
  } from "react-dom/server";
837
879
 
838
880
  // src/lib/packagePath.ts
839
- import path2 from "path";
881
+ import path3 from "path";
840
882
  import url from "url";
841
883
  import { normalizePath } from "vite";
842
884
  function packagePath(metaUrl, projectPath) {
843
885
  if (true) {
844
886
  return normalizePath(
845
- path2.resolve(path2.dirname(url.fileURLToPath(metaUrl)), projectPath)
887
+ path3.resolve(path3.dirname(url.fileURLToPath(metaUrl)), projectPath)
846
888
  );
847
889
  }
848
- const parentDirPath = normalizePath(path2.dirname(url.fileURLToPath(metaUrl)));
890
+ const parentDirPath = normalizePath(path3.dirname(url.fileURLToPath(metaUrl)));
849
891
  const subPath = parentDirPath.replace(/^.+cms-dev-server\/src\//, "");
850
892
  const subPathParentDirs = subPath.split("/").map(() => "..");
851
- return path2.resolve(
852
- path2.dirname(url.fileURLToPath(metaUrl)),
853
- path2.join(...subPathParentDirs, projectPath)
893
+ return path3.resolve(
894
+ path3.dirname(url.fileURLToPath(metaUrl)),
895
+ path3.join(...subPathParentDirs, projectPath)
854
896
  );
855
897
  }
856
898
 
857
- // ../cms-js-internal/dist/types-BsFs0N9P.js
858
- import path3 from "path";
899
+ // ../cms-js-internal/dist/types-BEz622C8.js
900
+ import path4 from "path";
859
901
  import { createHash } from "crypto";
860
- import fs2, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
902
+ import fs3, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
861
903
  import { join as join2 } from "path/posix";
862
904
  var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
863
905
  var ENTRY_POINTS_PATH = "components/partials/";
@@ -964,12 +1006,12 @@ function resolveIslandPlugin(islandsSet) {
964
1006
  if (id.endsWith("?island") || id.endsWith("?client")) {
965
1007
  const [idWithNoParam] = id.split("?");
966
1008
  const islandModuleImportPath = `${idWithNoParam}?client-entry`;
967
- const componentExtension = path3.extname(idWithNoParam);
968
- const componentFilenameWithNoExtension = path3.basename(
1009
+ const componentExtension = path4.extname(idWithNoParam);
1010
+ const componentFilenameWithNoExtension = path4.basename(
969
1011
  idWithNoParam,
970
1012
  componentExtension
971
1013
  );
972
- const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
1014
+ const modulePath = path4.relative(viteRoot, idWithNoParam);
973
1015
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
974
1016
  if (islandsSet) {
975
1017
  islandsSet.add(moduleId);
@@ -1063,7 +1105,7 @@ var hasComponentExtension = (componentPath) => {
1063
1105
  return !!getComponentExtension(componentPath);
1064
1106
  };
1065
1107
  var isStorybookStory = (componentPath) => {
1066
- return !!path3.basename(componentPath, path3.extname(componentPath)).endsWith(".stories");
1108
+ return !!path4.basename(componentPath, path4.extname(componentPath)).endsWith(".stories");
1067
1109
  };
1068
1110
  var removeComponentExtension = (componentPath) => {
1069
1111
  const ext = getComponentExtension(componentPath);
@@ -1080,18 +1122,28 @@ function getEntryPointHashWithIndexSuffix(entryPoint, index) {
1080
1122
  return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;
1081
1123
  }
1082
1124
  function getCMSAssetConfig(webRoot2) {
1083
- const cmsAssetsPath = path3.join(webRoot2, "cms-assets.json");
1084
- const cmsThemePath = path3.join(webRoot2, "theme.json");
1085
- const configPathToUse = fs2.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;
1125
+ const cmsAssetsPath = path4.join(webRoot2, "cms-assets.json");
1126
+ const cmsThemePath = path4.join(webRoot2, "theme.json");
1127
+ const configPathToUse = fs3.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;
1086
1128
  const parsedConfig = JSON.parse(
1087
- fs2.readFileSync(configPathToUse).toString()
1129
+ fs3.readFileSync(configPathToUse).toString()
1088
1130
  );
1089
1131
  return parsedConfig;
1090
1132
  }
1133
+ function getCMSAssetConfigIfExists(webRoot2) {
1134
+ try {
1135
+ return getCMSAssetConfig(webRoot2);
1136
+ } catch (e) {
1137
+ console.error(
1138
+ `Error finding or parsing cms-assets.json in ${webRoot2}, but ignoring for now`
1139
+ );
1140
+ return {};
1141
+ }
1142
+ }
1091
1143
  var ENABLED_FEATURES_GATE_MAP = {
1092
1144
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1093
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
1094
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
1145
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1146
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
1095
1147
  };
1096
1148
  function isUngatedFor(gates, gate) {
1097
1149
  return gates.includes(gate);
@@ -1514,8 +1566,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
1514
1566
  );
1515
1567
  return Object.fromEntries(relativeEntries);
1516
1568
  }
1517
- function toRelativePath(config, path18) {
1518
- return path18.replace(`${config.root}/`, "");
1569
+ function toRelativePath(config, path19) {
1570
+ return path19.replace(`${config.root}/`, "");
1519
1571
  }
1520
1572
  function shouldAnalyzeModule(config, moduleInfo, code) {
1521
1573
  const [fileId, __] = moduleInfo.id.split("?");
@@ -1558,11 +1610,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1558
1610
  let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
1559
1611
  let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
1560
1612
  traverse(sourceAst, {
1561
- ImportDeclaration(path18) {
1562
- if (t.isStringLiteral(path18.node.source, {
1613
+ ImportDeclaration(path19) {
1614
+ if (t.isStringLiteral(path19.node.source, {
1563
1615
  value: "@hubspot/cms-components"
1564
1616
  })) {
1565
- for (const specifier of path18.node.specifiers) {
1617
+ for (const specifier of path19.node.specifiers) {
1566
1618
  if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
1567
1619
  name: CMS_MODULE_COMPONENT_NAME
1568
1620
  })) {
@@ -1576,14 +1628,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1576
1628
  }
1577
1629
  }
1578
1630
  },
1579
- JSXOpeningElement(path18) {
1580
- if (t.isJSXIdentifier(path18.node.name, {
1631
+ JSXOpeningElement(path19) {
1632
+ if (t.isJSXIdentifier(path19.node.name, {
1581
1633
  name: moduleComponentLocalImportName
1582
1634
  })) {
1583
1635
  let cmsModuleName;
1584
1636
  let cmsModulePath;
1585
1637
  let cmsModuleLabel;
1586
- for (const prop of path18.node.attributes) {
1638
+ for (const prop of path19.node.attributes) {
1587
1639
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
1588
1640
  cmsModuleName = prop.value.value;
1589
1641
  continue;
@@ -1618,11 +1670,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
1618
1670
  }
1619
1671
  contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
1620
1672
  }
1621
- if (t.isJSXIdentifier(path18.node.name, {
1673
+ if (t.isJSXIdentifier(path19.node.name, {
1622
1674
  name: dndAreaComponentLocalImportName
1623
1675
  })) {
1624
1676
  let dndAreaName;
1625
- for (const prop of path18.node.attributes) {
1677
+ for (const prop of path19.node.attributes) {
1626
1678
  if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
1627
1679
  dndAreaName = prop.value.value;
1628
1680
  continue;
@@ -2197,7 +2249,7 @@ function trackUsage(action) {
2197
2249
  eventName: EVENT_NAME,
2198
2250
  action,
2199
2251
  nodeVersion: getNodeVersionData(),
2200
- version: "1.2.17",
2252
+ version: "1.2.35",
2201
2253
  os: getPlatform()
2202
2254
  };
2203
2255
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2237,11 +2289,11 @@ function sendTrackingRequest(action) {
2237
2289
 
2238
2290
  // src/lib/renderModulePreview.ts
2239
2291
  import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components";
2240
- import path7 from "path";
2292
+ import path8 from "path";
2241
2293
  import { normalizePath as normalizePath4 } from "vite";
2242
2294
 
2243
2295
  // src/lib/proxyHelpers.ts
2244
- import fs3 from "fs";
2296
+ import fs4 from "fs";
2245
2297
  import { resolve as resolve2 } from "path";
2246
2298
  import { unescape } from "html-escaper";
2247
2299
  var localJsRenderStartString = '<!-- proxy local render of "';
@@ -2270,12 +2322,12 @@ var findLocalRenderPlaceholders = (body) => {
2270
2322
  );
2271
2323
  offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
2272
2324
  if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
2273
- const path18 = body.substring(
2325
+ const path19 = body.substring(
2274
2326
  startOffset + localJsRenderStartString.length,
2275
2327
  pathEndOffset
2276
2328
  );
2277
2329
  offsetSoFar = pathEndOffset + 1;
2278
- if (startOffset >= 0 && path18) {
2330
+ if (startOffset >= 0 && path19) {
2279
2331
  const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
2280
2332
  const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
2281
2333
  offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
@@ -2300,7 +2352,7 @@ var findLocalRenderPlaceholders = (body) => {
2300
2352
  result.push({
2301
2353
  startOffset,
2302
2354
  endOffset: endOffset + localJsRenderEndString.length,
2303
- path: path18,
2355
+ path: path19,
2304
2356
  json
2305
2357
  });
2306
2358
  }
@@ -2320,7 +2372,7 @@ var findLocalRenderPlaceholders = (body) => {
2320
2372
  };
2321
2373
  var getHSProjectConfig = (hsProjectConfigPath) => {
2322
2374
  try {
2323
- return JSON.parse(fs3.readFileSync(hsProjectConfigPath, "utf8"));
2375
+ return JSON.parse(fs4.readFileSync(hsProjectConfigPath, "utf8"));
2324
2376
  } catch (e) {
2325
2377
  console.warn(
2326
2378
  `Missing hsproject.json file (${resolve2(hsProjectConfigPath)}): `,
@@ -2338,7 +2390,7 @@ var getProjectNameFromHSConfig = (hsProjectConfigPath) => {
2338
2390
  };
2339
2391
 
2340
2392
  // src/proxyPage/proxyPage.ts
2341
- import path6 from "path";
2393
+ import path7 from "path";
2342
2394
  import { normalizePath as normalizePath3 } from "vite";
2343
2395
  import { getConfigAccountIfExists as getConfigAccountIfExists3 } from "@hubspot/local-dev-lib/config";
2344
2396
  import { http as hsCliHttp6 } from "@hubspot/local-dev-lib/http";
@@ -2679,9 +2731,9 @@ var customColors = [
2679
2731
  ];
2680
2732
  var Converter = new AnsiToHtmlConverter({ colors: customColors });
2681
2733
  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;`;
2682
- var renderLocalError_default = (path18, error) => {
2734
+ var renderLocalError_default = (path19, error) => {
2683
2735
  const stackWithColorClasses = Converter.toHtml(error.stack);
2684
- return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path18}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
2736
+ return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path19}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
2685
2737
  };
2686
2738
 
2687
2739
  // src/proxyPage/fetchPreviewInfo.ts
@@ -2770,7 +2822,7 @@ function diffDeveloperFileHashes(accountId, token, fileHashes) {
2770
2822
  // src/fileManager.ts
2771
2823
  import { uploadFolder } from "@hubspot/local-dev-lib/cms/uploadFolder";
2772
2824
  import chokidar from "chokidar";
2773
- import path4 from "path";
2825
+ import path5 from "path";
2774
2826
  import { shouldIgnoreFile } from "@hubspot/local-dev-lib/ignoreRules";
2775
2827
  import {
2776
2828
  convertToUnixPath,
@@ -2802,7 +2854,7 @@ async function initialPreviewBufferUpload(accountId, src, dest, filePaths, uploa
2802
2854
  {},
2803
2855
  rest,
2804
2856
  filePaths.map(
2805
- (filePath) => filePath.replaceAll(path4.sep, path4.posix.sep)
2857
+ (filePath) => filePath.replaceAll(path5.sep, path5.posix.sep)
2806
2858
  )
2807
2859
  );
2808
2860
  onFinishCallback(results);
@@ -2867,7 +2919,7 @@ function buildUploadFileToPreviewBufferCallback(accountId, src, dest) {
2867
2919
  console.debug(`Skipping ${filePath} due to an ignore rule`);
2868
2920
  return;
2869
2921
  }
2870
- if (path4.dirname(filePath) === src && ["theme.json", "fields.json"].includes(path4.basename(filePath))) {
2922
+ if (path5.dirname(filePath) === src && ["theme.json", "fields.json"].includes(path5.basename(filePath))) {
2871
2923
  console.warn(`Editing of theme fields or meta is not yet supported.`);
2872
2924
  return;
2873
2925
  }
@@ -2883,7 +2935,7 @@ function buildDeleteFileFromPreviewBufferCallback(accountId, src, dest, type) {
2883
2935
  }
2884
2936
  if (type === "file") {
2885
2937
  const moduleChild = isModuleFolderChild(filePath);
2886
- const filename = path4.basename(filePath);
2938
+ const filename = path5.basename(filePath);
2887
2939
  if (moduleChild && filename === "meta.json") {
2888
2940
  return;
2889
2941
  }
@@ -2897,7 +2949,7 @@ function getDesignManagerPath(src, dest, file) {
2897
2949
  const normalizedFile = normalizePath2(file);
2898
2950
  const regex = new RegExp(`^${escapeRegExp2(normalizedSrc)}`);
2899
2951
  const relativePath = normalizedFile.replace(regex, "");
2900
- return convertToUnixPath(path4.join(dest, relativePath));
2952
+ return convertToUnixPath(path5.join(dest, relativePath));
2901
2953
  }
2902
2954
  async function uploadFile(accountId, src, dest) {
2903
2955
  console.debug(`Attempting to upload file "${src}" to "${dest}"`);
@@ -2938,11 +2990,11 @@ function isModuleFolderChild(filePath) {
2938
2990
  const pathParts = splitLocalPath(filePath);
2939
2991
  if (pathParts.length <= 1)
2940
2992
  return false;
2941
- return pathParts.slice(0, pathParts.length - 1).some((part) => getExt(path4.normalize(part)) === MODULE_EXTENSION);
2993
+ return pathParts.slice(0, pathParts.length - 1).some((part) => getExt(path5.normalize(part)) === MODULE_EXTENSION);
2942
2994
  }
2943
2995
 
2944
2996
  // src/lib/previewUtils.ts
2945
- import path5 from "path";
2997
+ import path6 from "path";
2946
2998
  var removePreviewPrefix = (t2) => t2.split("/").slice(2).join("/");
2947
2999
  var getPreviewUrl = (request, queryParams) => {
2948
3000
  const { authedPortalId, authedEnv, authedHublet, sslEnabled } = request.app.locals;
@@ -3004,8 +3056,8 @@ function buildDevFileHashTable(src, dest, filePaths) {
3004
3056
  return filePaths.reduce((acc, filePath) => {
3005
3057
  const relativePath = relative(src, filePath);
3006
3058
  const destPath = join3(dest, relativePath).replaceAll(
3007
- path5.sep,
3008
- path5.posix.sep
3059
+ path6.sep,
3060
+ path6.posix.sep
3009
3061
  );
3010
3062
  acc[`/${destPath}`] = getMd5Hash(filePath);
3011
3063
  return acc;
@@ -3030,7 +3082,7 @@ async function initiatePreviewSession(authedPortalId, absoluteWebRoot, themePrev
3030
3082
  const { dest, filePaths, startProgressBar } = themePreviewOptions2;
3031
3083
  const absoluteDest = `@preview/${token}/${dest}`;
3032
3084
  const nonJSRFilePaths = filePaths.filter(
3033
- (filePath) => !filePath.startsWith(path5.join(absoluteWebRoot, "components"))
3085
+ (filePath) => !filePath.startsWith(path6.join(absoluteWebRoot, "components"))
3034
3086
  );
3035
3087
  if (tokenStatus === "NEW") {
3036
3088
  console.log("Uploading for a new session...");
@@ -3064,8 +3116,8 @@ async function initiatePreviewSession(authedPortalId, absoluteWebRoot, themePrev
3064
3116
  /*, deletedFiles */
3065
3117
  } = diffRes;
3066
3118
  const filesToUpload = [...changedFiles, ...addedFiles].map((filePath) => {
3067
- const relPath = path5.relative(absoluteDest, filePath.substring(1));
3068
- return path5.join(absoluteWebRoot, relPath);
3119
+ const relPath = path6.relative(absoluteDest, filePath.substring(1));
3120
+ return path6.join(absoluteWebRoot, relPath);
3069
3121
  });
3070
3122
  if (filesToUpload.length) {
3071
3123
  const uploadOptions = startProgressBar(filesToUpload.length);
@@ -3203,7 +3255,7 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
3203
3255
  );
3204
3256
  }
3205
3257
  const resolvedPath = normalizePath3(
3206
- path6.resolve(webRoot2, partialPath, componentFileName)
3258
+ path7.resolve(webRoot2, partialPath, componentFileName)
3207
3259
  );
3208
3260
  const entryPointPath = [
3209
3261
  "@projects",
@@ -3478,8 +3530,51 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
3478
3530
  import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
3479
3531
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
3480
3532
  import jsdom from "jsdom";
3533
+ var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
3534
+ async function signGetUrl(authedPortalId, unsignedUrl) {
3535
+ const urlWithPortalId = new URL(unsignedUrl);
3536
+ urlWithPortalId.searchParams.set("portalId", `${authedPortalId}`);
3537
+ const response = await hsCliHttp7.post(authedPortalId, {
3538
+ url: "/url-signer-rest/v1/signing",
3539
+ headers: {
3540
+ "Content-Type": "application/json",
3541
+ Accept: "application/json"
3542
+ },
3543
+ data: JSON.stringify({
3544
+ unsignedUrl: urlWithPortalId.toString(),
3545
+ httpMethod: "GET"
3546
+ })
3547
+ });
3548
+ return response.data.signedUrl;
3549
+ }
3550
+ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
3551
+ if (!isUngatedFor(gates, URL_SIGNING_GATE)) {
3552
+ const { data } = await hsCliHttp7.get(authedPortalId, {
3553
+ url: unsignedUrl,
3554
+ headers
3555
+ });
3556
+ return data;
3557
+ }
3558
+ const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
3559
+ const authHeaders = {};
3560
+ const accountConfig = getConfigAccountIfExists4(authedPortalId);
3561
+ if (accountConfig && accountConfig.authType === "personalaccesskey") {
3562
+ const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3563
+ authHeaders["Authorization"] = `Bearer ${accessToken}`;
3564
+ }
3565
+ const response = await fetch(signedUrl, {
3566
+ method: "GET",
3567
+ headers: { ...headers, ...authHeaders }
3568
+ });
3569
+ if (!response.ok) {
3570
+ throw new Error(
3571
+ `Preview GET failed: ${response.status} ${response.statusText}`
3572
+ );
3573
+ }
3574
+ return await response.text();
3575
+ }
3481
3576
  var { JSDOM } = jsdom;
3482
- async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
3577
+ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
3483
3578
  const moduleInfoQueryParams = new URLSearchParams({
3484
3579
  portalId: `${authedPortalId}`
3485
3580
  });
@@ -3494,8 +3589,6 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3494
3589
  "User-Agent": "HubSpot CMS Dev Server"
3495
3590
  }
3496
3591
  })).data;
3497
- const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
3498
- process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
3499
3592
  const queryParams = new URLSearchParams({
3500
3593
  portalId: `${authedPortalId}`,
3501
3594
  hsLocalProxy: `${true}`,
@@ -3503,20 +3596,34 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3503
3596
  hsLoginVerifyDisabled: `${true}`,
3504
3597
  module_id: moduleInfo.moduleId
3505
3598
  });
3506
- const modulePreviewHtml = (await hsCliHttp7.get(authedPortalId, {
3507
- url: `/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`,
3508
- headers: {
3509
- ["content-type"]: "application/x-www-form-urlencoded",
3510
- ["Accept"]: "text/html",
3511
- referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3512
- cookie: cookieValue,
3513
- "User-Agent": "HubSpot CMS Dev Server"
3599
+ const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
3600
+ const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
3601
+ const needsDomainOverride = !isUngatedFor(gates, URL_SIGNING_GATE);
3602
+ if (needsDomainOverride) {
3603
+ process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
3604
+ }
3605
+ let modulePreviewHtml;
3606
+ try {
3607
+ modulePreviewHtml = await signedGet(
3608
+ authedPortalId,
3609
+ cosRenderingUrl,
3610
+ {
3611
+ ["content-type"]: "application/x-www-form-urlencoded",
3612
+ ["Accept"]: "text/html",
3613
+ referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3614
+ cookie: cookieValue,
3615
+ "User-Agent": "HubSpot CMS Dev Server"
3616
+ },
3617
+ gates
3618
+ );
3619
+ } finally {
3620
+ if (needsDomainOverride) {
3621
+ if (previousHubApiDomainOverride) {
3622
+ process.env.HUBAPI_DOMAIN_OVERRIDE = previousHubApiDomainOverride;
3623
+ } else {
3624
+ delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3625
+ }
3514
3626
  }
3515
- })).data;
3516
- if (currentHubApiDomainOverride) {
3517
- process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
3518
- } else {
3519
- delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3520
3627
  }
3521
3628
  const dom = new JSDOM(modulePreviewHtml);
3522
3629
  const modulePreviewContent = dom.window.document.querySelector(
@@ -3551,7 +3658,7 @@ async function signUrl(authedPortalId, unsignedUrl, requestBody) {
3551
3658
  }
3552
3659
  async function renderLocalProjectModulePreview(moduleName, authedPortalId, authedEnv, authedHublet, webRoot2, viteServer, jsRenderingGates, projectName, projectComponentPath, fullOriginalUrl, cookieValue, fieldOverrides = {}) {
3553
3660
  const modulePath = normalizePath4(
3554
- path7.resolve(webRoot2, "components/modules/", moduleName)
3661
+ path8.resolve(webRoot2, "components/modules/", moduleName)
3555
3662
  );
3556
3663
  const basePath = `preview/${getEntryPointBasePath(modulePath)}`;
3557
3664
  const environmentConfig = buildStaticEnvConfig2(
@@ -3688,7 +3795,7 @@ var partialRouteHandler = async (request, response) => {
3688
3795
  "html/baseTemplate.html"
3689
3796
  );
3690
3797
  const partialPath = normalizePath5(
3691
- path8.resolve(webRoot2, "components/partials/", partialName)
3798
+ path9.resolve(webRoot2, "components/partials/", partialName)
3692
3799
  );
3693
3800
  const entrypointPath = normalizePath5(
3694
3801
  [
@@ -3759,7 +3866,8 @@ var partialRouteHandler = async (request, response) => {
3759
3866
  remoteModule.path,
3760
3867
  authedPortalId,
3761
3868
  authedEnv,
3762
- request.get("COOKIE")
3869
+ request.get("COOKIE"),
3870
+ jsRenderingGates
3763
3871
  ).then((result) => ({
3764
3872
  remoteModule,
3765
3873
  result
@@ -3774,7 +3882,7 @@ var partialRouteHandler = async (request, response) => {
3774
3882
  continue;
3775
3883
  localProjectModulePreviewPromises.push(
3776
3884
  renderLocalProjectModulePreview(
3777
- path8.basename(localProjectModule.path),
3885
+ path9.basename(localProjectModule.path),
3778
3886
  authedPortalId,
3779
3887
  authedEnv,
3780
3888
  authedHublet,
@@ -3912,7 +4020,7 @@ var linksToAllModulesRouteHandler_default = linksToAllModuleRouteHandler;
3912
4020
 
3913
4021
  // src/routes/module.ts
3914
4022
  import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
3915
- import path9 from "path";
4023
+ import path10 from "path";
3916
4024
  import { normalizePath as normalizePath6 } from "vite";
3917
4025
  var moduleRouteHandler = async (request, response) => {
3918
4026
  sendTrackingRequest("view-module-route");
@@ -3932,7 +4040,7 @@ var moduleRouteHandler = async (request, response) => {
3932
4040
  "html/baseTemplate.html"
3933
4041
  );
3934
4042
  const modulePath = normalizePath6(
3935
- path9.resolve(webRoot2, "components/modules/", moduleName)
4043
+ path10.resolve(webRoot2, "components/modules/", moduleName)
3936
4044
  );
3937
4045
  const entrypointPath = normalizePath6(
3938
4046
  [
@@ -4013,7 +4121,7 @@ ${e.stack}`);
4013
4121
  var module_default = moduleRouteHandler;
4014
4122
 
4015
4123
  // src/routes/moduleFieldsJson.ts
4016
- import path10 from "path";
4124
+ import path11 from "path";
4017
4125
  import { normalizePath as normalizePath7 } from "vite";
4018
4126
 
4019
4127
  // src/lib/renderModuleFieldsJson.ts
@@ -4067,7 +4175,7 @@ var moduleFieldsJsonRouteHandler = async (request, response) => {
4067
4175
  const { webRoot: webRoot2, viteServer } = request.app.locals;
4068
4176
  const { moduleName } = request.params;
4069
4177
  const modulePath = normalizePath7(
4070
- path10.resolve(webRoot2, "components/modules/", moduleName)
4178
+ path11.resolve(webRoot2, "components/modules/", moduleName)
4071
4179
  );
4072
4180
  const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
4073
4181
  return response.status(200).set({ "Content-Type": "application/json" }).json(fieldsJson);
@@ -4293,18 +4401,18 @@ async function fetchPreviewTemplates(accountId, previewToken, limit = 250) {
4293
4401
  url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}&limit=${limit}`
4294
4402
  })).data;
4295
4403
  }
4296
- async function fetchModuleByPath(accountId, path18) {
4404
+ async function fetchModuleByPath(accountId, path19) {
4297
4405
  return (await hsCliHttp8.get(accountId, {
4298
- url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path18}?portalId=${accountId}`
4406
+ url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path19}?portalId=${accountId}`
4299
4407
  })).data;
4300
4408
  }
4301
- async function fetchTemplateByPath(accountId, path18) {
4409
+ async function fetchTemplateByPath(accountId, path19) {
4302
4410
  return (await hsCliHttp8.get(accountId, {
4303
- url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path18}?portalId=${accountId}`
4411
+ url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path19}?portalId=${accountId}`
4304
4412
  })).data;
4305
4413
  }
4306
- async function fetchModulePageDependencies(accountId, path18) {
4307
- const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path18}`;
4414
+ async function fetchModulePageDependencies(accountId, path19) {
4415
+ const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path19}`;
4308
4416
  return (await hsCliHttp8.get(accountId, { url: url3 })).data;
4309
4417
  }
4310
4418
 
@@ -4540,7 +4648,7 @@ function proxyServerlessRequest(req, res, next) {
4540
4648
  }
4541
4649
 
4542
4650
  // src/routes/modulePreviewRouteHandler.ts
4543
- import path11 from "path";
4651
+ import path12 from "path";
4544
4652
  import { normalizePath as normalizePath8 } from "vite";
4545
4653
  async function modulePreviewRouteHandler(request, response) {
4546
4654
  sendTrackingRequest("view-module-preview-route");
@@ -4556,7 +4664,7 @@ async function modulePreviewRouteHandler(request, response) {
4556
4664
  } = request.app.locals;
4557
4665
  const moduleName = request.params.moduleName;
4558
4666
  const modulePath = normalizePath8(
4559
- path11.resolve(webRoot2, "components/modules/", moduleName)
4667
+ path12.resolve(webRoot2, "components/modules/", moduleName)
4560
4668
  );
4561
4669
  const PREVIEWER_APP_PARAM = "hsPreviewerApp";
4562
4670
  let fieldOverrides = {};
@@ -4646,21 +4754,27 @@ ${e.stack}`);
4646
4754
  var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4647
4755
 
4648
4756
  // src/routes/hublModuleRouteHandler.ts
4649
- import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4650
4757
  var hublModuleRouteHandler = async (request, response) => {
4651
4758
  sendTrackingRequest("view-hubl-module-route");
4652
- const { authedPortalId, localPreviewToken } = request.app.locals;
4759
+ const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
4653
4760
  const { modulePath } = request.params;
4654
4761
  if (!modulePath) {
4655
4762
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
4656
4763
  return;
4657
4764
  }
4658
- const calculatedPath = `@preview/${localPreviewToken}/@projects/${modulePath}.module`;
4765
+ const projectPrefix = projectName ? "@projects/" : "";
4766
+ const calculatedPath = `@preview/${localPreviewToken}/${projectPrefix}${modulePath}.module`;
4659
4767
  let customWidgetInfo;
4660
4768
  try {
4661
4769
  customWidgetInfo = await fetchModuleByPath(authedPortalId, calculatedPath);
4662
4770
  } catch (err) {
4663
- console.log(`Failed to fetch module data for ${calculatedPath}`);
4771
+ console.error(`Failed to fetch module data for ${calculatedPath}: ${err}`);
4772
+ response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(err));
4773
+ return;
4774
+ }
4775
+ if (!customWidgetInfo || !("moduleId" in customWidgetInfo)) {
4776
+ response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(null));
4777
+ return;
4664
4778
  }
4665
4779
  const params = {
4666
4780
  module_id: customWidgetInfo.moduleId,
@@ -4668,13 +4782,9 @@ var hublModuleRouteHandler = async (request, response) => {
4668
4782
  updated: Date.now(),
4669
4783
  ...request.query
4670
4784
  };
4671
- const previewUrl = new URL(getPreviewUrl(request, params));
4785
+ const previewUrl = getPreviewUrl(request, params);
4672
4786
  try {
4673
- const result = (await hsCliHttp9.get(authedPortalId, {
4674
- baseURL: previewUrl.origin,
4675
- url: previewUrl.pathname,
4676
- params
4677
- })).data;
4787
+ const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
4678
4788
  const html = addRefreshScript(result);
4679
4789
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
4680
4790
  } catch (err) {
@@ -4696,7 +4806,6 @@ var buildModuleIndex = () => buildHTMLResponse(`
4696
4806
  `);
4697
4807
 
4698
4808
  // src/routes/hublTemplateRouteHandler.ts
4699
- import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4700
4809
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4701
4810
  import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
4702
4811
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
@@ -4747,14 +4856,15 @@ var templateRouteHandler = async (request, response) => {
4747
4856
  hsCacheBuster: Date.now().toString(),
4748
4857
  ...request.query
4749
4858
  };
4750
- const previewUrl = new URL(getPreviewUrl(request, params));
4859
+ const previewUrl = getPreviewUrl(request, params);
4751
4860
  const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4752
4861
  try {
4753
- const result = (await hsCliHttp10.get(authedPortalId, {
4754
- baseURL: previewUrl.origin,
4755
- url: previewUrl.pathname,
4756
- params
4757
- })).data;
4862
+ const result = await signedGet(
4863
+ authedPortalId,
4864
+ previewUrl,
4865
+ {},
4866
+ jsRenderingGates
4867
+ );
4758
4868
  const pageHtml = addRefreshScript(result);
4759
4869
  const finalHtml = pageHtml.replace(
4760
4870
  HUBSPOT_PREVIEW_BASE_TAG_REGEX,
@@ -4773,6 +4883,7 @@ var templateRouteHandler = async (request, response) => {
4773
4883
  false
4774
4884
  );
4775
4885
  } catch (err) {
4886
+ console.error("Template route error:", err);
4776
4887
  response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
4777
4888
  }
4778
4889
  };
@@ -4807,15 +4918,15 @@ function getOpenCommand() {
4807
4918
  }
4808
4919
  }
4809
4920
  async function handleGetModulePages(req, res, next) {
4810
- const { path: path18, portalId } = req.query;
4811
- if (!path18 || !portalId) {
4921
+ const { path: path19, portalId } = req.query;
4922
+ if (!path19 || !portalId) {
4812
4923
  return res.status(400).json({ error: "Missing required parameters" });
4813
4924
  }
4814
4925
  try {
4815
4926
  sendTrackingRequest("handle-module-dependencies");
4816
4927
  const data = await fetchModulePageDependencies(
4817
4928
  Number(portalId),
4818
- path18
4929
+ path19
4819
4930
  );
4820
4931
  res.json(data);
4821
4932
  } catch (err) {
@@ -4823,14 +4934,14 @@ async function handleGetModulePages(req, res, next) {
4823
4934
  }
4824
4935
  }
4825
4936
  function handleOpenFile(req, res, next) {
4826
- const { path: path18 } = req.query;
4827
- if (!path18) {
4937
+ const { path: path19 } = req.query;
4938
+ if (!path19) {
4828
4939
  return res.status(400).json({ error: "Missing required parameters" });
4829
4940
  }
4830
4941
  try {
4831
4942
  sendTrackingRequest("handle-open-file");
4832
4943
  const command = getOpenCommand();
4833
- spawn(command, [path18], { detached: true }).unref();
4944
+ spawn(command, [path19], { detached: true }).unref();
4834
4945
  res.sendStatus(200);
4835
4946
  } catch (err) {
4836
4947
  next(err);
@@ -4845,19 +4956,19 @@ function createAppServerAPIRoutes() {
4845
4956
  var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
4846
4957
 
4847
4958
  // src/routes/appServerRouteHandler.ts
4848
- import fs5 from "node:fs/promises";
4849
- import path13 from "path";
4959
+ import fs6 from "node:fs/promises";
4960
+ import path14 from "path";
4850
4961
  import { pathToFileURL } from "url";
4851
4962
 
4852
4963
  // src/lib/getDevServerUIData.ts
4853
- import path12 from "path";
4964
+ import path13 from "path";
4854
4965
  import { normalizePath as normalizePath9 } from "vite";
4855
4966
 
4856
4967
  // src/api/project.ts
4857
- import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4968
+ import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4858
4969
  var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
4859
4970
  async function fetchProjectByName(accountId, projectName) {
4860
- return (await hsCliHttp11.get(accountId, {
4971
+ return (await hsCliHttp9.get(accountId, {
4861
4972
  url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
4862
4973
  })).data;
4863
4974
  }
@@ -5043,7 +5154,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
5043
5154
  }),
5044
5155
  clientIslandEntryPlugin(),
5045
5156
  resolveIslandPlugin(),
5046
- jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
5157
+ viteCommonjs(),
5047
5158
  devSecretsPlugin(secretNames),
5048
5159
  noncePlaceholderPlugin()
5049
5160
  ] : [];
@@ -5080,7 +5191,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
5080
5191
  var createViteDevServer_default = createViteDevServer;
5081
5192
 
5082
5193
  // src/lib/getDevServerUIData.ts
5083
- import fs4 from "node:fs";
5194
+ import fs5 from "node:fs";
5084
5195
  var templateTypeMap = {
5085
5196
  // Standard templates
5086
5197
  4: "Page",
@@ -5106,7 +5217,7 @@ function mapReactModules(modules, themeWebRoot, appViteServer) {
5106
5217
  return Promise.all(
5107
5218
  modules.moduleNames.map(async (name, index) => {
5108
5219
  const modulePath = normalizePath9(
5109
- path12.resolve(themeWebRoot, "components/modules/", name)
5220
+ path13.resolve(themeWebRoot, "components/modules/", name)
5110
5221
  );
5111
5222
  const fieldsJson = await renderModuleFieldsJson_default(
5112
5223
  appViteServer,
@@ -5152,9 +5263,9 @@ function normalizeTemplatesData(templates, projectName) {
5152
5263
  });
5153
5264
  }
5154
5265
  function detectPackageManager(projectRoot) {
5155
- if (fs4.existsSync(path12.join(projectRoot, "yarn.lock")))
5266
+ if (fs5.existsSync(path13.join(projectRoot, "yarn.lock")))
5156
5267
  return "yarn";
5157
- if (fs4.existsSync(path12.join(projectRoot, "pnpm-lock.yaml")))
5268
+ if (fs5.existsSync(path13.join(projectRoot, "pnpm-lock.yaml")))
5158
5269
  return "pnpm";
5159
5270
  return "npm";
5160
5271
  }
@@ -5238,10 +5349,10 @@ var appServerRouteHandler = async (req, res, __next) => {
5238
5349
  const { appWebRoot, appViteServer } = appLocals;
5239
5350
  const initialProps = await getDevServerUIData(appLocals);
5240
5351
  const url3 = req.originalUrl.replace("/", "");
5241
- const templatePath = path13.join(appWebRoot, "index.html");
5242
- const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
5352
+ const templatePath = path14.join(appWebRoot, "index.html");
5353
+ const serverEntryPath = isProd ? path14.join(appWebRoot, "server/serverEntry.js") : path14.join(appWebRoot, "serverEntry.tsx");
5243
5354
  let render;
5244
- let template = await fs5.readFile(path13.join(templatePath), "utf-8");
5355
+ let template = await fs6.readFile(path14.join(templatePath), "utf-8");
5245
5356
  if (isProd) {
5246
5357
  const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
5247
5358
  render = ssrRender;
@@ -5267,7 +5378,7 @@ var appServerRouteHandler = async (req, res, __next) => {
5267
5378
  var appServerRouteHandler_default = appServerRouteHandler;
5268
5379
 
5269
5380
  // src/routes/createDevServerRoutes.ts
5270
- import path14 from "path";
5381
+ import path15 from "path";
5271
5382
  var isProd2 = true;
5272
5383
  var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
5273
5384
  (domain2) => `storybook.${domain2}`
@@ -5280,6 +5391,7 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5280
5391
  debug(`${method}:${hostname}${url3}`);
5281
5392
  next();
5282
5393
  });
5394
+ devServerApp.use(cors());
5283
5395
  if (storybookPort) {
5284
5396
  devServerApp.use(
5285
5397
  createProxyMiddleware2(
@@ -5293,7 +5405,7 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5293
5405
  }
5294
5406
  devServerApp.use(urlencoded());
5295
5407
  if (isProd2) {
5296
- const distAssetsPath = path14.join(appWebRoot, "assets");
5408
+ const distAssetsPath = path15.join(appWebRoot, "assets");
5297
5409
  devServerApp.use("/assets", expressStatic(distAssetsPath));
5298
5410
  } else {
5299
5411
  devServerApp.use("/local", appViteServer.middlewares);
@@ -5339,7 +5451,7 @@ import express from "express";
5339
5451
  // src/shadowDevServer/createShadowDevServerRoutes.ts
5340
5452
  import { Router as Router3 } from "express";
5341
5453
  import { getConfigAccountIfExists as getConfigAccountIfExists6 } from "@hubspot/local-dev-lib/config";
5342
- import cors from "cors";
5454
+ import cors2 from "cors";
5343
5455
  function getShadowDevServerCheckHandler(devServerPort, themePath) {
5344
5456
  return async function shadowDevServerCheckHandler(request, response) {
5345
5457
  const { query } = request;
@@ -5398,7 +5510,7 @@ async function createShadowDevServerRoutes(devServerPort, themePath) {
5398
5510
  const shadowDevServerRoutes = Router3();
5399
5511
  shadowDevServerRoutes.get(
5400
5512
  "/check-if-local-dev-server",
5401
- cors(),
5513
+ cors2(),
5402
5514
  getShadowDevServerCheckHandler(devServerPort, themePath)
5403
5515
  );
5404
5516
  return shadowDevServerRoutes;
@@ -5578,7 +5690,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
5578
5690
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
5579
5691
 
5580
5692
  // src/proxyPage/fetchDomains.ts
5581
- import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5693
+ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
5582
5694
 
5583
5695
  // src/lib/errors.ts
5584
5696
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -5636,7 +5748,7 @@ function handleSecretsError(error) {
5636
5748
  // src/proxyPage/fetchDomains.ts
5637
5749
  async function fetchDomains(portalId) {
5638
5750
  try {
5639
- const result = (await hsCliHttp12.get(portalId, {
5751
+ const result = (await hsCliHttp10.get(portalId, {
5640
5752
  url: `/cms/v3/domains`,
5641
5753
  params: { portalId },
5642
5754
  responseType: "json"
@@ -5659,24 +5771,24 @@ async function fetchWebsiteDomainNames(portalId) {
5659
5771
  }
5660
5772
 
5661
5773
  // src/lib/validateHSPlatform.ts
5662
- import path15 from "path";
5663
- import fs6 from "fs";
5774
+ import path16 from "path";
5775
+ import fs7 from "fs";
5664
5776
  import select from "@inquirer/select";
5665
- import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
5777
+ import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5666
5778
  var HSPROJECT_JSON = "hsproject.json";
5667
5779
  function checkFileExists(filePath) {
5668
- return fs6.existsSync(filePath) && fs6.statSync(filePath).isFile();
5780
+ return fs7.existsSync(filePath) && fs7.statSync(filePath).isFile();
5669
5781
  }
5670
5782
  function findHSProjectJson(startPath) {
5671
5783
  let currentDir = startPath;
5672
5784
  let dirLevel = 0;
5673
5785
  const maxDirLevel = 4;
5674
- while (path15.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
5675
- const filePath = path15.join(currentDir, HSPROJECT_JSON);
5786
+ while (path16.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
5787
+ const filePath = path16.join(currentDir, HSPROJECT_JSON);
5676
5788
  if (checkFileExists(filePath)) {
5677
5789
  return filePath;
5678
5790
  }
5679
- currentDir = path15.dirname(currentDir);
5791
+ currentDir = path16.dirname(currentDir);
5680
5792
  dirLevel++;
5681
5793
  }
5682
5794
  console.log(
@@ -5691,12 +5803,12 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5691
5803
  );
5692
5804
  return false;
5693
5805
  }
5694
- const hsProjectJSONContents = fs6.readFileSync(projectConfigPath, "utf8");
5806
+ const hsProjectJSONContents = fs7.readFileSync(projectConfigPath, "utf8");
5695
5807
  const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
5696
5808
  const { platformVersion } = hsProjectJSONData;
5697
5809
  let platformVersionResult;
5698
5810
  try {
5699
- platformVersionResult = (await hsCliHttp13.get(portalId, {
5811
+ platformVersionResult = (await hsCliHttp11.get(portalId, {
5700
5812
  url: `developer/projects/v1/platformVersion`,
5701
5813
  responseType: "json"
5702
5814
  })).data;
@@ -5719,7 +5831,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5719
5831
  });
5720
5832
  hsProjectJSONData.platformVersion = answer;
5721
5833
  try {
5722
- fs6.writeFileSync(
5834
+ fs7.writeFileSync(
5723
5835
  projectConfigPath,
5724
5836
  JSON.stringify(hsProjectJSONData, void 0, 2),
5725
5837
  "utf8"
@@ -5736,7 +5848,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5736
5848
  }
5737
5849
 
5738
5850
  // src/createDevServer.ts
5739
- import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
5851
+ import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5740
5852
 
5741
5853
  // ../cms-js-internal/dist/buildFieldsTypes.js
5742
5854
  import { writeFileSync } from "fs";
@@ -5981,8 +6093,8 @@ function writeFieldsType(fields, fileName, typeName) {
5981
6093
  }
5982
6094
 
5983
6095
  // src/lib/watchFieldsUpdates.ts
5984
- import fs7 from "fs";
5985
- import path16 from "path";
6096
+ import fs8 from "fs";
6097
+ import path17 from "path";
5986
6098
  import readline from "readline";
5987
6099
  var lastSerializedFieldsCache = {};
5988
6100
  var formatAsTypeName = (str) => {
@@ -5992,20 +6104,20 @@ var formatAsTypeName = (str) => {
5992
6104
  };
5993
6105
  var isInModulesFolder = (filePath, projectRoot) => {
5994
6106
  const getEntryPathFromId = (id) => {
5995
- return id.startsWith(projectRoot) ? id.replace(`${projectRoot}${path16.sep}`, "") : "";
6107
+ return id.startsWith(projectRoot) ? id.replace(`${projectRoot}${path17.sep}`, "") : "";
5996
6108
  };
5997
- const currentModuleId = path16.normalize(filePath);
6109
+ const currentModuleId = path17.normalize(filePath);
5998
6110
  const moduleEntryPath = getEntryPathFromId(currentModuleId);
5999
- const subFolderTokens = moduleEntryPath.split(path16.sep);
6111
+ const subFolderTokens = moduleEntryPath.split(path17.sep);
6000
6112
  return {
6001
6113
  inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
6002
6114
  isRootModuleFile: subFolderTokens.length === 3
6003
6115
  };
6004
6116
  };
6005
6117
  var fileContainsAutoGenComment = async (filePath) => {
6006
- if (!fs7.existsSync(filePath))
6118
+ if (!fs8.existsSync(filePath))
6007
6119
  return true;
6008
- const stream2 = fs7.createReadStream(filePath);
6120
+ const stream2 = fs8.createReadStream(filePath);
6009
6121
  const reader = readline.createInterface({ input: stream2 });
6010
6122
  const firstLine = await new Promise(
6011
6123
  (resolve3) => reader.once("line", (line) => resolve3(line.trim()))
@@ -6023,10 +6135,10 @@ var getIndexFile = (filePath, projectRoot) => {
6023
6135
  return void 0;
6024
6136
  if (isRootModuleFile)
6025
6137
  return { indexFilePath: filePath, isRootModuleFile };
6026
- const dir = path16.dirname(filePath);
6027
- const files = fs7.readdirSync(dir);
6138
+ const dir = path17.dirname(filePath);
6139
+ const files = fs8.readdirSync(dir);
6028
6140
  const indexFileName = files.find((file) => file.startsWith("index."));
6029
- return indexFileName ? { indexFilePath: path16.join(dir, indexFileName), isRootModuleFile } : void 0;
6141
+ return indexFileName ? { indexFilePath: path17.join(dir, indexFileName), isRootModuleFile } : void 0;
6030
6142
  };
6031
6143
  var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
6032
6144
  let indexFile;
@@ -6050,7 +6162,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
6050
6162
  if (!indexInfo)
6051
6163
  return;
6052
6164
  const { indexFilePath, isRootModuleFile } = indexInfo;
6053
- const indexFileName = path16.parse(indexFilePath).name;
6165
+ const indexFileName = path17.parse(indexFilePath).name;
6054
6166
  const isTypeFile = filePath.endsWith(".types.ts");
6055
6167
  if (isTypeFile)
6056
6168
  return;
@@ -6061,7 +6173,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
6061
6173
  );
6062
6174
  if (fields) {
6063
6175
  const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
6064
- const typeFilePath = path16.join(path16.dirname(filePath), typeFileName);
6176
+ const typeFilePath = path17.join(path17.dirname(filePath), typeFileName);
6065
6177
  const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
6066
6178
  const serializedFields = JSON.stringify(fields);
6067
6179
  if (lastSerializedFields === serializedFields)
@@ -6069,7 +6181,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
6069
6181
  const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
6070
6182
  if (!hasAutoGenComment)
6071
6183
  return;
6072
- const moduleFolderName = path16.basename(path16.dirname(filePath));
6184
+ const moduleFolderName = path17.basename(path17.dirname(filePath));
6073
6185
  const outputTypeName = formatAsTypeName(moduleFolderName);
6074
6186
  const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
6075
6187
  if (didSucceed) {
@@ -6085,7 +6197,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
6085
6197
  var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
6086
6198
  const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
6087
6199
  moduleSubpaths.forEach((modulePath) => {
6088
- const resolvedPath = path16.resolve(projectRoot, modulePath);
6200
+ const resolvedPath = path17.resolve(projectRoot, modulePath);
6089
6201
  maybeUpdateFields(resolvedPath, viteServer, projectRoot);
6090
6202
  });
6091
6203
  const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
@@ -6116,27 +6228,13 @@ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
6116
6228
  return themeFolderName;
6117
6229
  }
6118
6230
  try {
6119
- const projectDir = path17.dirname(projectConfigPath);
6120
- const configContent = fs8.readFileSync(projectConfigPath, "utf8");
6231
+ const projectDir = path18.dirname(projectConfigPath);
6232
+ const configContent = fs9.readFileSync(projectConfigPath, "utf8");
6121
6233
  const projectConfig = JSON.parse(configContent);
6122
- const isNewStructure = hasNewDirectoryStructure(
6123
- projectConfig.platformVersion
6124
- );
6125
- if (isNewStructure) {
6234
+ if (hasNewDirectoryStructure(projectConfig.platformVersion)) {
6126
6235
  const srcDir = projectConfig.srcDir || "src";
6127
- const hsmetaPath = path17.join(
6128
- projectDir,
6129
- srcDir,
6130
- "theme",
6131
- "theme-hsmeta.json"
6132
- );
6133
- if (fs8.existsSync(hsmetaPath)) {
6134
- const hsmetaContent = fs8.readFileSync(hsmetaPath, "utf8");
6135
- const hsmeta = JSON.parse(hsmetaContent);
6136
- if (hsmeta.uid) {
6137
- return hsmeta.uid;
6138
- }
6139
- }
6236
+ const uid = findHsmetaUid(projectDir, srcDir);
6237
+ return uid ?? projectConfig.name;
6140
6238
  }
6141
6239
  } catch (e) {
6142
6240
  console.warn(
@@ -6169,7 +6267,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
6169
6267
  `Loading HS auth (account = ${hubspotCliAccountNameOption2}) configuration.`
6170
6268
  );
6171
6269
  }
6172
- const cmsAssetConfig = getCMSAssetConfig(webRoot2);
6270
+ const cmsAssetConfig = getCMSAssetConfigIfExists(webRoot2);
6173
6271
  secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
6174
6272
  const { isValid } = validateConfig();
6175
6273
  if (isValid) {
@@ -6257,14 +6355,14 @@ Local proxy functionality and module preview routes will not work without settin
6257
6355
  }
6258
6356
  let authedHublet;
6259
6357
  try {
6260
- const accountInformation = (await hsCliHttp14.get(authedPortalId, {
6358
+ const accountInformation = (await hsCliHttp12.get(authedPortalId, {
6261
6359
  url: "/account-info/v3/details"
6262
6360
  })).data;
6263
6361
  authedHublet = accountInformation.dataHostingLocation;
6264
6362
  } catch (e) {
6265
6363
  authedHublet = "na1";
6266
6364
  }
6267
- const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot2));
6365
+ const absoluteWebRoot = normalizePath10(path18.resolve(process.cwd(), webRoot2));
6268
6366
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
6269
6367
  const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
6270
6368
  absoluteWebRoot,
@@ -6293,7 +6391,7 @@ Local proxy functionality and module preview routes will not work without settin
6293
6391
  secretNames
6294
6392
  );
6295
6393
  if (fieldGenEnabledOption2) {
6296
- const normalizedAbsoluteWebRoot = path17.normalize(absoluteWebRoot);
6394
+ const normalizedAbsoluteWebRoot = path18.normalize(absoluteWebRoot);
6297
6395
  startFieldsTypeGenWatcher(viteServer, normalizedAbsoluteWebRoot);
6298
6396
  }
6299
6397
  const viteHTTPSConfig = viteServer.config.server.https;
@@ -6318,10 +6416,10 @@ Local proxy functionality and module preview routes will not work without settin
6318
6416
  expressServer.locals.localPreviewToken = _localPreviewToken;
6319
6417
  expressServer.locals.sslEnabled = sslEnabledOption2;
6320
6418
  expressServer.use(bodyParser.json());
6321
- const __dirname = path17.dirname(url2.fileURLToPath(new URL(import.meta.url)));
6322
- let appWebRoot = normalizePath10(path17.resolve(__dirname, "../app"));
6419
+ const __dirname = path18.dirname(url2.fileURLToPath(new URL(import.meta.url)));
6420
+ let appWebRoot = normalizePath10(path18.resolve(__dirname, "../app"));
6323
6421
  if (true) {
6324
- appWebRoot = path17.join(__dirname, "app");
6422
+ appWebRoot = path18.join(__dirname, "app");
6325
6423
  }
6326
6424
  const appViteServer = await createAppServer_default(
6327
6425
  appWebRoot,
@@ -6391,17 +6489,17 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6391
6489
  `;
6392
6490
  console.log(startMessage);
6393
6491
  if (storybook2) {
6394
- const packageRoot = path17.dirname(url2.fileURLToPath(import.meta.url));
6395
- const configPath = path17.resolve(packageRoot, "./storybook-main");
6492
+ const packageRoot = path18.dirname(url2.fileURLToPath(import.meta.url));
6493
+ const configPath = path18.resolve(packageRoot, "./storybook-main");
6396
6494
  sendTrackingRequest("start-storybook");
6397
6495
  let storybookBin;
6398
6496
  try {
6399
6497
  const sbPackagePath = await import.meta.resolve("storybook/package.json");
6400
- const sbPackageDir = path17.dirname(url2.fileURLToPath(sbPackagePath));
6498
+ const sbPackageDir = path18.dirname(url2.fileURLToPath(sbPackagePath));
6401
6499
  const packageJson = JSON.parse(
6402
- fs8.readFileSync(path17.join(sbPackageDir, "package.json"), "utf-8")
6500
+ fs9.readFileSync(path18.join(sbPackageDir, "package.json"), "utf-8")
6403
6501
  );
6404
- storybookBin = path17.join(
6502
+ storybookBin = path18.join(
6405
6503
  sbPackageDir,
6406
6504
  packageJson.bin.storybook || packageJson.bin
6407
6505
  );
@@ -6438,7 +6536,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6438
6536
  portalId: authedPortalId.toString(),
6439
6537
  hsEnv: authedEnv,
6440
6538
  hublet: authedHublet,
6441
- WEB_ROOT: path17.join(webRoot2, "components")
6539
+ WEB_ROOT: path18.join(webRoot2, "components")
6442
6540
  },
6443
6541
  stdio: "inherit"
6444
6542
  }