@hubspot/cms-dev-server 0.18.14 → 0.18.15

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.
@@ -9,7 +9,7 @@ import { normalizePath as normalizePath2 } from "vite";
9
9
  import { createServer as createViteServer } from "vite";
10
10
  import { default as react } from "@vitejs/plugin-react";
11
11
 
12
- // ../cms-js-internal/dist/types-CGxfMR-y.js
12
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
13
13
  import path from "path";
14
14
  var viteRoot;
15
15
  var viteCommand;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createServer as createViteServer } from "vite";
3
3
  import { default as react } from "@vitejs/plugin-react";
4
4
 
5
- // ../cms-js-internal/dist/types-CGxfMR-y.js
5
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
6
6
  import path from "path";
7
7
  import { createHash } from "crypto";
8
8
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -223,13 +223,22 @@ function findAllModulesInRoot(webRoot) {
223
223
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
224
224
  );
225
225
  const moduleSubpaths = Object.keys(allModuleComponents);
226
+ const moduleExtensions = Object.values(allModuleComponents).map((path22) => {
227
+ const extension = (path22 == null ? void 0 : path22.split(".").pop()) || "";
228
+ return extension;
229
+ });
226
230
  const moduleNamesWithExtension = Object.values(allModuleComponents).map(
227
231
  (path22) => {
228
232
  const file = path22.replace("components/modules/", "");
229
233
  return file.includes("/index.") ? file.split("/index.")[0] : file;
230
234
  }
231
235
  );
232
- return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
236
+ return {
237
+ moduleNames,
238
+ moduleSubpaths,
239
+ moduleNamesWithExtension,
240
+ moduleExtensions
241
+ };
233
242
  }
234
243
  function findAllPartialsInRoot(webRoot) {
235
244
  const allPartialComponents = findAllComponentsIn(
@@ -1034,7 +1043,7 @@ import url2 from "url";
1034
1043
  import express3 from "express";
1035
1044
  import http3 from "http";
1036
1045
  import bodyParser from "body-parser";
1037
- import { spawn } from "child_process";
1046
+ import { spawn as spawn2 } from "child_process";
1038
1047
  import { normalizePath as normalizePath9 } from "vite";
1039
1048
  import { Transform } from "stream";
1040
1049
 
@@ -1455,7 +1464,7 @@ function trackUsage(action) {
1455
1464
  eventName: EVENT_NAME,
1456
1465
  action,
1457
1466
  nodeVersion: getNodeVersionData(),
1458
- version: "0.18.14",
1467
+ version: "0.18.15",
1459
1468
  os: getPlatform()
1460
1469
  };
1461
1470
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -4205,6 +4214,7 @@ function mapModulesData(modules, themeWebRoot, viteServer) {
4205
4214
  name,
4206
4215
  subPath: modules.moduleSubpaths[index],
4207
4216
  nameWithExtension: modules.moduleNamesWithExtension[index],
4217
+ extension: modules.moduleExtensions[index],
4208
4218
  fieldsJson
4209
4219
  };
4210
4220
  })
@@ -4219,6 +4229,7 @@ function mapPartialsData(modules) {
4219
4229
  async function getDevServerUIData(reqLocals) {
4220
4230
  const {
4221
4231
  themeWebRoot,
4232
+ authedEnv,
4222
4233
  authedPortalId,
4223
4234
  projectName,
4224
4235
  localPreviewToken,
@@ -4246,6 +4257,7 @@ async function getDevServerUIData(reqLocals) {
4246
4257
  )) || [];
4247
4258
  return {
4248
4259
  authedPortalId,
4260
+ authedEnv,
4249
4261
  projectName,
4250
4262
  modulesData: mappedModulesData,
4251
4263
  partialsData: mapPartialsData(partialsData),
@@ -4257,6 +4269,54 @@ async function getDevServerUIData(reqLocals) {
4257
4269
  }
4258
4270
  var getDevServerUIData_default = getDevServerUIData;
4259
4271
 
4272
+ // src/routes/createAppServerRoutes.ts
4273
+ import { Router as Router3 } from "express";
4274
+ import { spawn } from "child_process";
4275
+ function getOpenCommand() {
4276
+ switch (process.platform) {
4277
+ case "darwin":
4278
+ return "open";
4279
+ case "win32":
4280
+ return "start";
4281
+ default:
4282
+ return "xdg-open";
4283
+ }
4284
+ }
4285
+ async function handleGetModulePages(req, res, next) {
4286
+ const { path: path15, portalId } = req.query;
4287
+ if (!path15 || !portalId) {
4288
+ return res.status(400).json({ error: "Missing required parameters" });
4289
+ }
4290
+ try {
4291
+ const data = await fetchModulePageDependencies(
4292
+ Number(portalId),
4293
+ path15
4294
+ );
4295
+ res.json(data);
4296
+ } catch (err) {
4297
+ next(err);
4298
+ }
4299
+ }
4300
+ function handleOpenFile(req, res, next) {
4301
+ const { path: path15 } = req.query;
4302
+ if (!path15) {
4303
+ return res.status(400).json({ error: "Missing required parameters" });
4304
+ }
4305
+ try {
4306
+ const command = getOpenCommand();
4307
+ spawn(command, [path15], { detached: true }).unref();
4308
+ res.sendStatus(200);
4309
+ } catch (err) {
4310
+ next(err);
4311
+ }
4312
+ }
4313
+ function createAppServerRoutes() {
4314
+ const router = Router3();
4315
+ router.get("/module-pages", handleGetModulePages);
4316
+ router.get("/open-file", handleOpenFile);
4317
+ return router;
4318
+ }
4319
+
4260
4320
  // src/createAppServer.ts
4261
4321
  async function createAppServer(webRoot, reqLocals, port) {
4262
4322
  const app = express2();
@@ -4306,23 +4366,9 @@ async function createAppServer(webRoot, reqLocals, port) {
4306
4366
  envPrefix: "HS_"
4307
4367
  };
4308
4368
  const viteServer = await createViteServer2(viteConfig);
4369
+ app.use("/api", createAppServerRoutes());
4309
4370
  app.use(viteServer.middlewares);
4310
- app.get("/api/module-pages", async (req, res, next) => {
4311
- const { path: path15, portalId } = req.query;
4312
- if (!path15 || !portalId) {
4313
- return res.status(400).json({ error: "Missing required parameters" });
4314
- }
4315
- try {
4316
- const data = await fetchModulePageDependencies(
4317
- Number(portalId),
4318
- path15
4319
- );
4320
- res.json(data);
4321
- } catch (err) {
4322
- next(err);
4323
- }
4324
- });
4325
- app.use("*", async (req, res) => {
4371
+ app.get("/*", async (req, res) => {
4326
4372
  try {
4327
4373
  const initialProps = await getDevServerUIData_default({
4328
4374
  ...reqLocals,
@@ -4348,7 +4394,7 @@ async function createAppServer(webRoot, reqLocals, port) {
4348
4394
  res.status(500).end(e.stack);
4349
4395
  }
4350
4396
  });
4351
- app.use((err, req, res, next) => {
4397
+ app.use((err, req, res, __next) => {
4352
4398
  console.error("API Error:", err);
4353
4399
  res.status(500).json({ error: "Internal server error" });
4354
4400
  });
@@ -5194,7 +5240,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5194
5240
  const packageRoot = path14.dirname(url2.fileURLToPath(import.meta.url));
5195
5241
  const configPath = path14.resolve(packageRoot, "./storybook-main");
5196
5242
  sendTrackingRequest("start-storybook");
5197
- const storybookProcess = spawn(
5243
+ const storybookProcess = spawn2(
5198
5244
  "sb",
5199
5245
  [
5200
5246
  "dev",
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-CGxfMR-y.js
1
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -383,13 +383,22 @@ function findAllModulesInRoot(webRoot) {
383
383
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
384
384
  );
385
385
  const moduleSubpaths = Object.keys(allModuleComponents);
386
+ const moduleExtensions = Object.values(allModuleComponents).map((path2) => {
387
+ const extension = (path2 == null ? void 0 : path2.split(".").pop()) || "";
388
+ return extension;
389
+ });
386
390
  const moduleNamesWithExtension = Object.values(allModuleComponents).map(
387
391
  (path2) => {
388
392
  const file = path2.replace("components/modules/", "");
389
393
  return file.includes("/index.") ? file.split("/index.")[0] : file;
390
394
  }
391
395
  );
392
- return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
396
+ return {
397
+ moduleNames,
398
+ moduleSubpaths,
399
+ moduleNamesWithExtension,
400
+ moduleExtensions
401
+ };
393
402
  }
394
403
  function findAllPartialsInRoot(webRoot) {
395
404
  const allPartialComponents = findAllComponentsIn(
package/dist/run.js CHANGED
@@ -751,7 +751,7 @@ import url2 from "url";
751
751
  import express3 from "express";
752
752
  import http3 from "http";
753
753
  import bodyParser from "body-parser";
754
- import { spawn } from "child_process";
754
+ import { spawn as spawn2 } from "child_process";
755
755
  import { normalizePath as normalizePath9 } from "vite";
756
756
  import { Transform } from "stream";
757
757
 
@@ -795,7 +795,7 @@ function packagePath(metaUrl, projectPath) {
795
795
  );
796
796
  }
797
797
 
798
- // ../cms-js-internal/dist/types-CGxfMR-y.js
798
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
799
799
  import path3 from "path";
800
800
  import { createHash } from "crypto";
801
801
  import fs2, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1016,13 +1016,22 @@ function findAllModulesInRoot(webRoot2) {
1016
1016
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
1017
1017
  );
1018
1018
  const moduleSubpaths = Object.keys(allModuleComponents);
1019
+ const moduleExtensions = Object.values(allModuleComponents).map((path22) => {
1020
+ const extension = (path22 == null ? void 0 : path22.split(".").pop()) || "";
1021
+ return extension;
1022
+ });
1019
1023
  const moduleNamesWithExtension = Object.values(allModuleComponents).map(
1020
1024
  (path22) => {
1021
1025
  const file = path22.replace("components/modules/", "");
1022
1026
  return file.includes("/index.") ? file.split("/index.")[0] : file;
1023
1027
  }
1024
1028
  );
1025
- return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
1029
+ return {
1030
+ moduleNames,
1031
+ moduleSubpaths,
1032
+ moduleNamesWithExtension,
1033
+ moduleExtensions
1034
+ };
1026
1035
  }
1027
1036
  function findAllPartialsInRoot(webRoot2) {
1028
1037
  const allPartialComponents = findAllComponentsIn(
@@ -2064,7 +2073,7 @@ function trackUsage(action) {
2064
2073
  eventName: EVENT_NAME,
2065
2074
  action,
2066
2075
  nodeVersion: getNodeVersionData(),
2067
- version: "0.18.14",
2076
+ version: "0.18.15",
2068
2077
  os: getPlatform()
2069
2078
  };
2070
2079
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -4933,6 +4942,7 @@ function mapModulesData(modules, themeWebRoot, viteServer) {
4933
4942
  name,
4934
4943
  subPath: modules.moduleSubpaths[index],
4935
4944
  nameWithExtension: modules.moduleNamesWithExtension[index],
4945
+ extension: modules.moduleExtensions[index],
4936
4946
  fieldsJson
4937
4947
  };
4938
4948
  })
@@ -4947,6 +4957,7 @@ function mapPartialsData(modules) {
4947
4957
  async function getDevServerUIData(reqLocals) {
4948
4958
  const {
4949
4959
  themeWebRoot,
4960
+ authedEnv,
4950
4961
  authedPortalId,
4951
4962
  projectName,
4952
4963
  localPreviewToken,
@@ -4974,6 +4985,7 @@ async function getDevServerUIData(reqLocals) {
4974
4985
  )) || [];
4975
4986
  return {
4976
4987
  authedPortalId,
4988
+ authedEnv,
4977
4989
  projectName,
4978
4990
  modulesData: mappedModulesData,
4979
4991
  partialsData: mapPartialsData(partialsData),
@@ -4985,6 +4997,54 @@ async function getDevServerUIData(reqLocals) {
4985
4997
  }
4986
4998
  var getDevServerUIData_default = getDevServerUIData;
4987
4999
 
5000
+ // src/routes/createAppServerRoutes.ts
5001
+ import { Router as Router3 } from "express";
5002
+ import { spawn } from "child_process";
5003
+ function getOpenCommand() {
5004
+ switch (process.platform) {
5005
+ case "darwin":
5006
+ return "open";
5007
+ case "win32":
5008
+ return "start";
5009
+ default:
5010
+ return "xdg-open";
5011
+ }
5012
+ }
5013
+ async function handleGetModulePages(req, res, next) {
5014
+ const { path: path16, portalId } = req.query;
5015
+ if (!path16 || !portalId) {
5016
+ return res.status(400).json({ error: "Missing required parameters" });
5017
+ }
5018
+ try {
5019
+ const data = await fetchModulePageDependencies(
5020
+ Number(portalId),
5021
+ path16
5022
+ );
5023
+ res.json(data);
5024
+ } catch (err) {
5025
+ next(err);
5026
+ }
5027
+ }
5028
+ function handleOpenFile(req, res, next) {
5029
+ const { path: path16 } = req.query;
5030
+ if (!path16) {
5031
+ return res.status(400).json({ error: "Missing required parameters" });
5032
+ }
5033
+ try {
5034
+ const command = getOpenCommand();
5035
+ spawn(command, [path16], { detached: true }).unref();
5036
+ res.sendStatus(200);
5037
+ } catch (err) {
5038
+ next(err);
5039
+ }
5040
+ }
5041
+ function createAppServerRoutes() {
5042
+ const router = Router3();
5043
+ router.get("/module-pages", handleGetModulePages);
5044
+ router.get("/open-file", handleOpenFile);
5045
+ return router;
5046
+ }
5047
+
4988
5048
  // src/createAppServer.ts
4989
5049
  async function createAppServer(webRoot2, reqLocals, port) {
4990
5050
  const app = express2();
@@ -5034,23 +5094,9 @@ async function createAppServer(webRoot2, reqLocals, port) {
5034
5094
  envPrefix: "HS_"
5035
5095
  };
5036
5096
  const viteServer = await createViteServer2(viteConfig);
5097
+ app.use("/api", createAppServerRoutes());
5037
5098
  app.use(viteServer.middlewares);
5038
- app.get("/api/module-pages", async (req, res, next) => {
5039
- const { path: path16, portalId } = req.query;
5040
- if (!path16 || !portalId) {
5041
- return res.status(400).json({ error: "Missing required parameters" });
5042
- }
5043
- try {
5044
- const data = await fetchModulePageDependencies(
5045
- Number(portalId),
5046
- path16
5047
- );
5048
- res.json(data);
5049
- } catch (err) {
5050
- next(err);
5051
- }
5052
- });
5053
- app.use("*", async (req, res) => {
5099
+ app.get("/*", async (req, res) => {
5054
5100
  try {
5055
5101
  const initialProps = await getDevServerUIData_default({
5056
5102
  ...reqLocals,
@@ -5076,7 +5122,7 @@ async function createAppServer(webRoot2, reqLocals, port) {
5076
5122
  res.status(500).end(e.stack);
5077
5123
  }
5078
5124
  });
5079
- app.use((err, req, res, next) => {
5125
+ app.use((err, req, res, __next) => {
5080
5126
  console.error("API Error:", err);
5081
5127
  res.status(500).json({ error: "Internal server error" });
5082
5128
  });
@@ -5922,7 +5968,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
5922
5968
  const packageRoot = path15.dirname(url2.fileURLToPath(import.meta.url));
5923
5969
  const configPath = path15.resolve(packageRoot, "./storybook-main");
5924
5970
  sendTrackingRequest("start-storybook");
5925
- const storybookProcess = spawn(
5971
+ const storybookProcess = spawn2(
5926
5972
  "sb",
5927
5973
  [
5928
5974
  "dev",
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-CGxfMR-y.js
4
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
5
5
  function namespaceModulePropsShape(props) {
6
6
  const {
7
7
  dataQueryResult,
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // ../cms-js-internal/dist/types-CGxfMR-y.js
11
+ // ../cms-js-internal/dist/types-DGdcEHv3.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -228,13 +228,22 @@ function findAllModulesInRoot(webRoot2) {
228
228
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
229
229
  );
230
230
  const moduleSubpaths = Object.keys(allModuleComponents);
231
+ const moduleExtensions = Object.values(allModuleComponents).map((path22) => {
232
+ const extension = (path22 == null ? void 0 : path22.split(".").pop()) || "";
233
+ return extension;
234
+ });
231
235
  const moduleNamesWithExtension = Object.values(allModuleComponents).map(
232
236
  (path22) => {
233
237
  const file = path22.replace("components/modules/", "");
234
238
  return file.includes("/index.") ? file.split("/index.")[0] : file;
235
239
  }
236
240
  );
237
- return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
241
+ return {
242
+ moduleNames,
243
+ moduleSubpaths,
244
+ moduleNamesWithExtension,
245
+ moduleExtensions
246
+ };
238
247
  }
239
248
  function findAllPartialsInRoot(webRoot2) {
240
249
  const allPartialComponents = findAllComponentsIn(
@@ -300,8 +309,8 @@ function isStylesheetAsset(staticAsset) {
300
309
  return staticAsset.type === "stylesheet";
301
310
  }
302
311
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, badInlineJsChars, inlineJsEscapeChars, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, removeIndexFromPath, removeIndexOrTrailingJsFromPath, HEALTHCHECKS_ENABLED_DEFAULT, HEALTHCHECKS_STRICT_DEFAULT, BUILD_INFO_PATH, GATES, ENABLED_FEATURES_GATE_MAP, findAllComponentsIn;
303
- var init_types_CGxfMR_y = __esm({
304
- "../cms-js-internal/dist/types-CGxfMR-y.js"() {
312
+ var init_types_DGdcEHv3 = __esm({
313
+ "../cms-js-internal/dist/types-DGdcEHv3.js"() {
305
314
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
306
315
  ENTRY_POINTS_PATH = "components/partials/";
307
316
  MODULE_FOLDER_PATH = "components/modules/";
@@ -1054,8 +1063,8 @@ function renderFieldsToJson(fields, moduleName) {
1054
1063
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1055
1064
  var init_dist = __esm({
1056
1065
  "../cms-js-internal/dist/index.js"() {
1057
- init_types_CGxfMR_y();
1058
- init_types_CGxfMR_y();
1066
+ init_types_DGdcEHv3();
1067
+ init_types_DGdcEHv3();
1059
1068
  ({ setProperty, getProperty, hasProperty } = dotProp);
1060
1069
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
1061
1070
  const islandsArrayToSerialize = tweakedIslandsArray.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.18.14",
3
+ "version": "0.18.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,7 +29,7 @@
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
31
  "@babel/types": "^7.25.2",
32
- "@hubspot/cms-components": "^0.18.14",
32
+ "@hubspot/cms-components": "^0.18.15",
33
33
  "@hubspot/local-dev-lib": "2.0.1",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -130,5 +130,5 @@
130
130
  "publishConfig": {
131
131
  "access": "public"
132
132
  },
133
- "gitHead": "be9c2de0f4401294fd94f1035c66d02770d7f877"
133
+ "gitHead": "c7606b055fa33813e2b374d6699cc1ef06aede4f"
134
134
  }
@@ -3,6 +3,7 @@ export interface ModuleData {
3
3
  name: string;
4
4
  nameWithExtension: string;
5
5
  subPath?: string;
6
+ extension: string;
6
7
  fieldsJson: any;
7
8
  }
8
9
  export interface PartialData {
@@ -0,0 +1,5 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare function handleGetModulePages(req: Request, res: Response, next: NextFunction): Promise<Response<any, Record<string, any>>>;
3
+ export declare function handleOpenFile(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>>;
4
+ export declare function createAppServerRoutes(): import("express-serve-static-core").Router;
5
+ export default createAppServerRoutes;