@hubspot/cms-dev-server 1.0.46 → 1.0.47

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
@@ -1066,8 +1066,8 @@ function hsStaticAssetPlugin() {
1066
1066
  return () => {
1067
1067
  const getDomainInfo = (req) => {
1068
1068
  const { authedPortalId, authedHublet, sslEnabled, authedEnv } = req.app.locals;
1069
- const env = authedEnv === "qa" ? "qa" : "";
1070
- const previewDomain = `${authedPortalId}.hubspotpreview${env}-${authedHublet}.com`;
1069
+ const env2 = authedEnv === "qa" ? "qa" : "";
1070
+ const previewDomain = `${authedPortalId}.hubspotpreview${env2}-${authedHublet}.com`;
1071
1071
  const protocol = sslEnabled ? "https" : "http";
1072
1072
  return { previewDomain, protocol };
1073
1073
  };
@@ -1631,7 +1631,7 @@ function trackUsage(action) {
1631
1631
  eventName: EVENT_NAME,
1632
1632
  action,
1633
1633
  nodeVersion: getNodeVersionData(),
1634
- version: "1.0.46",
1634
+ version: "1.0.47",
1635
1635
  os: getPlatform()
1636
1636
  };
1637
1637
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1649,9 +1649,9 @@ function trackUsage(action) {
1649
1649
  });
1650
1650
  return axios(config);
1651
1651
  }
1652
- var setTrackingInfo = (accountId, env) => {
1652
+ var setTrackingInfo = (accountId, env2) => {
1653
1653
  trackingAccountId = accountId;
1654
- trackingEnv = env;
1654
+ trackingEnv = env2;
1655
1655
  };
1656
1656
  function sendTrackingRequest(action) {
1657
1657
  setImmediate(async () => {
@@ -4770,10 +4770,10 @@ var mapEnabledFeaturesToGates = (enabledFeatures) => {
4770
4770
  return gates;
4771
4771
  }, []);
4772
4772
  };
4773
- async function getJsRenderingGates(portalId, env, personalAccessKey) {
4773
+ async function getJsRenderingGates(portalId, env2, personalAccessKey) {
4774
4774
  const {
4775
4775
  data: { enabledFeatures }
4776
- } = await fetchAccessToken(personalAccessKey, env, portalId);
4776
+ } = await fetchAccessToken(personalAccessKey, env2, portalId);
4777
4777
  const envGates = getGatesFromEnv();
4778
4778
  const gates = mapEnabledFeaturesToGates(enabledFeatures);
4779
4779
  const mergedGates = [...envGates, ...gates];
@@ -4781,6 +4781,120 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
4781
4781
  return mergedGates;
4782
4782
  }
4783
4783
 
4784
+ // src/lib/cliUtils.ts
4785
+ import process2 from "process";
4786
+ import os from "os";
4787
+ import tty from "tty";
4788
+ var COMPONENT_TYPES = Object.freeze({
4789
+ privateApp: "private-app",
4790
+ publicApp: "public-app",
4791
+ hublTheme: "hubl-theme"
4792
+ });
4793
+ var CONFIG_FILES = {
4794
+ [COMPONENT_TYPES.privateApp]: "app.json",
4795
+ [COMPONENT_TYPES.publicApp]: "public-app.json",
4796
+ [COMPONENT_TYPES.hublTheme]: "theme.json"
4797
+ };
4798
+ function hasNewDirectoryStructure(platformVersion) {
4799
+ return parseFloat(platformVersion) >= 2025.2;
4800
+ }
4801
+ var { env } = process2;
4802
+ function translateLevel(level) {
4803
+ if (level === 0) {
4804
+ return {
4805
+ level,
4806
+ hasBasic: false,
4807
+ has256: false,
4808
+ has16m: false
4809
+ };
4810
+ }
4811
+ return {
4812
+ level,
4813
+ hasBasic: true,
4814
+ has256: level >= 2,
4815
+ has16m: level >= 3
4816
+ };
4817
+ }
4818
+ function _supportsColor(haveStream, { streamIsTTY } = {}) {
4819
+ if (haveStream && !streamIsTTY) {
4820
+ return 0;
4821
+ }
4822
+ const min = 0;
4823
+ if (env.TERM === "dumb") {
4824
+ return min;
4825
+ }
4826
+ if (hasFlag("noColor")) {
4827
+ return 0;
4828
+ }
4829
+ if (process2.platform === "win32") {
4830
+ const osRelease = os.release().split(".");
4831
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
4832
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
4833
+ }
4834
+ return 1;
4835
+ }
4836
+ if ("CI" in env) {
4837
+ if ([
4838
+ "TRAVIS",
4839
+ "CIRCLECI",
4840
+ "APPVEYOR",
4841
+ "GITLAB_CI",
4842
+ "GITHUB_ACTIONS",
4843
+ "BUILDKITE",
4844
+ "DRONE"
4845
+ ].some((sign) => sign in env) || env.CI_NAME === "codeship") {
4846
+ return 1;
4847
+ }
4848
+ return min;
4849
+ }
4850
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
4851
+ return 1;
4852
+ }
4853
+ if (env.COLORTERM === "truecolor") {
4854
+ return 3;
4855
+ }
4856
+ if ("TERM_PROGRAM" in env) {
4857
+ const version = Number.parseInt(
4858
+ (env.TERM_PROGRAM_VERSION || "").split(".")[0],
4859
+ 10
4860
+ );
4861
+ switch (env.TERM_PROGRAM) {
4862
+ case "iTerm.app":
4863
+ return version >= 3 ? 3 : 2;
4864
+ case "Apple_Terminal":
4865
+ return 2;
4866
+ }
4867
+ }
4868
+ if (/-256(color)?$/i.test(env.TERM)) {
4869
+ return 2;
4870
+ }
4871
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
4872
+ return 1;
4873
+ }
4874
+ if ("COLORTERM" in env) {
4875
+ return 1;
4876
+ }
4877
+ return min;
4878
+ }
4879
+ function createSupportsColor(stream2, options = {}) {
4880
+ const level = _supportsColor(stream2, {
4881
+ streamIsTTY: stream2 && stream2.isTTY,
4882
+ ...options
4883
+ });
4884
+ return translateLevel(level);
4885
+ }
4886
+ var supportsColor = {
4887
+ createSupportsColor,
4888
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
4889
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
4890
+ };
4891
+ function hasFlag(flag, argv = process2.argv) {
4892
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
4893
+ const position = argv.indexOf(prefix + flag);
4894
+ const terminatorPosition = argv.indexOf("--");
4895
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4896
+ }
4897
+
4784
4898
  // src/createDevServer.ts
4785
4899
  import {
4786
4900
  getEnv as getEnv3,
@@ -5323,6 +5437,43 @@ var BASE_PATH = "/";
5323
5437
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
5324
5438
  var SHADOW_PORT = 1442;
5325
5439
  var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
5440
+ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
5441
+ const pathSegments = absoluteWebRoot.replace(/\/$/, "").split("/");
5442
+ const themeFolderName = pathSegments[pathSegments.length - 1];
5443
+ if (!projectConfigPath) {
5444
+ return themeFolderName;
5445
+ }
5446
+ try {
5447
+ const projectDir = path16.dirname(projectConfigPath);
5448
+ const configContent = fs7.readFileSync(projectConfigPath, "utf8");
5449
+ const projectConfig = JSON.parse(configContent);
5450
+ const isNewStructure = hasNewDirectoryStructure(
5451
+ projectConfig.platformVersion
5452
+ );
5453
+ if (isNewStructure) {
5454
+ const srcDir = projectConfig.srcDir || "src";
5455
+ const hsmetaPath = path16.join(
5456
+ projectDir,
5457
+ srcDir,
5458
+ "theme",
5459
+ "theme-hsmeta.json"
5460
+ );
5461
+ if (fs7.existsSync(hsmetaPath)) {
5462
+ const hsmetaContent = fs7.readFileSync(hsmetaPath, "utf8");
5463
+ const hsmeta = JSON.parse(hsmetaContent);
5464
+ if (hsmeta.uid) {
5465
+ return hsmeta.uid;
5466
+ }
5467
+ }
5468
+ }
5469
+ } catch (e) {
5470
+ console.warn(
5471
+ "Could not determine project component folder from config:",
5472
+ e.message
5473
+ );
5474
+ }
5475
+ return themeFolderName;
5476
+ }
5326
5477
  async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabledOption, fieldGenEnabledOption, themePreviewOptions, fieldBuilderEnabled) {
5327
5478
  let authedPortalId = null;
5328
5479
  let authedEnv = null;
@@ -5348,13 +5499,13 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
5348
5499
  secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
5349
5500
  if (validateConfig()) {
5350
5501
  authedPortalId = getAccountId4(hubspotCliAccountNameOption);
5351
- const env = getEnv3(hubspotCliAccountNameOption);
5352
- if (!env) {
5502
+ const env2 = getEnv3(hubspotCliAccountNameOption);
5503
+ if (!env2) {
5353
5504
  throw new Error(
5354
5505
  `No environment found for account ${hubspotCliAccountNameOption} from hubspot.config.yaml`
5355
5506
  );
5356
5507
  }
5357
- authedEnv = env;
5508
+ authedEnv = env2;
5358
5509
  personalAccessKey = getAccountConfig3(authedPortalId) && getAccountConfig3(authedPortalId).personalAccessKey;
5359
5510
  if (!authedPortalId && hubspotCliAccountNameOption) {
5360
5511
  console.error(
@@ -5438,8 +5589,11 @@ Local proxy functionality and module preview routes will not work without settin
5438
5589
  authedHublet = "na1";
5439
5590
  }
5440
5591
  const absoluteWebRoot = normalizePath10(path16.resolve(process.cwd(), webRoot));
5441
- const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
5442
5592
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
5593
+ const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
5594
+ absoluteWebRoot,
5595
+ projectConfigPath
5596
+ );
5443
5597
  if (authedPortalId) {
5444
5598
  await validateHSPlatform(projectConfigPath, authedPortalId);
5445
5599
  }
package/dist/run.js CHANGED
@@ -203,6 +203,40 @@ function getIsLegacyApp(appConfig, appPath) {
203
203
  });
204
204
  return !hasAnyReactExtensions;
205
205
  }
206
+ function hasNewDirectoryStructure(platformVersion) {
207
+ return parseFloat(platformVersion) >= 2025.2;
208
+ }
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)) {
217
+ 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.`
219
+ );
220
+ process2.exit(1);
221
+ }
222
+ 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;
232
+ } catch (e) {
233
+ console.error(
234
+ `Error: Failed to read or parse theme-hsmeta.json at ${hsmetaPath}`
235
+ );
236
+ console.error(e.message);
237
+ process2.exit(1);
238
+ }
239
+ }
206
240
  async function determineSrcAndDest(webRoot2, isUsingLocalWorkspace = false) {
207
241
  let absoluteSrc;
208
242
  let dest;
@@ -229,7 +263,16 @@ async function determineSrcAndDest(webRoot2, isUsingLocalWorkspace = false) {
229
263
  const { dir: themeDir } = path.parse(themeJsonPath);
230
264
  absoluteSrc = themeDir;
231
265
  const { base: themeName } = path.parse(themeDir);
232
- dest = `@projects/${projectConfig.name}/${themeName}`;
266
+ const platformVersion = projectConfig.platformVersion || "2025.1";
267
+ const isNewStructure = hasNewDirectoryStructure(platformVersion);
268
+ if (isNewStructure) {
269
+ const srcDir = projectConfig.srcDir || "src";
270
+ const hsmeta = readThemeHsmeta(projectDir, srcDir);
271
+ const uid = hsmeta.uid;
272
+ dest = `@projects/${projectConfig.name}/${uid}`;
273
+ } else {
274
+ dest = `@projects/${projectConfig.name}/${themeName}`;
275
+ }
233
276
  } else {
234
277
  console.error("Must be run inside a project directory");
235
278
  process2.exit(1);
@@ -2154,7 +2197,7 @@ function trackUsage(action) {
2154
2197
  eventName: EVENT_NAME,
2155
2198
  action,
2156
2199
  nodeVersion: getNodeVersionData(),
2157
- version: "1.0.46",
2200
+ version: "1.0.47",
2158
2201
  os: getPlatform()
2159
2202
  };
2160
2203
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -6063,6 +6106,43 @@ var BASE_PATH = "/";
6063
6106
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
6064
6107
  var SHADOW_PORT = 1442;
6065
6108
  var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
6109
+ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
6110
+ const pathSegments = absoluteWebRoot.replace(/\/$/, "").split("/");
6111
+ const themeFolderName = pathSegments[pathSegments.length - 1];
6112
+ if (!projectConfigPath) {
6113
+ return themeFolderName;
6114
+ }
6115
+ try {
6116
+ const projectDir = path17.dirname(projectConfigPath);
6117
+ const configContent = fs8.readFileSync(projectConfigPath, "utf8");
6118
+ const projectConfig = JSON.parse(configContent);
6119
+ const isNewStructure = hasNewDirectoryStructure(
6120
+ projectConfig.platformVersion
6121
+ );
6122
+ if (isNewStructure) {
6123
+ const srcDir = projectConfig.srcDir || "src";
6124
+ const hsmetaPath = path17.join(
6125
+ projectDir,
6126
+ srcDir,
6127
+ "theme",
6128
+ "theme-hsmeta.json"
6129
+ );
6130
+ if (fs8.existsSync(hsmetaPath)) {
6131
+ const hsmetaContent = fs8.readFileSync(hsmetaPath, "utf8");
6132
+ const hsmeta = JSON.parse(hsmetaContent);
6133
+ if (hsmeta.uid) {
6134
+ return hsmeta.uid;
6135
+ }
6136
+ }
6137
+ }
6138
+ } catch (e) {
6139
+ console.warn(
6140
+ "Could not determine project component folder from config:",
6141
+ e.message
6142
+ );
6143
+ }
6144
+ return themeFolderName;
6145
+ }
6066
6146
  async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2, fieldBuilderEnabled2) {
6067
6147
  let authedPortalId = null;
6068
6148
  let authedEnv = null;
@@ -6178,8 +6258,11 @@ Local proxy functionality and module preview routes will not work without settin
6178
6258
  authedHublet = "na1";
6179
6259
  }
6180
6260
  const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot2));
6181
- const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
6182
6261
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
6262
+ const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
6263
+ absoluteWebRoot,
6264
+ projectConfigPath
6265
+ );
6183
6266
  if (authedPortalId) {
6184
6267
  await validateHSPlatform(projectConfigPath, authedPortalId);
6185
6268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,8 +29,8 @@
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": "^1.0.46",
33
- "@hubspot/local-dev-lib": "3.7.1",
32
+ "@hubspot/cms-components": "^1.0.47",
33
+ "@hubspot/local-dev-lib": "3.21.2",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
36
36
  "@radix-ui/react-dialog": "^1.1.2",
@@ -61,7 +61,7 @@
61
61
  "express": "^4.17.3",
62
62
  "html-escaper": "^3.0.3",
63
63
  "http-proxy-middleware": "^2.0.6",
64
- "inquirer": "8.2.0",
64
+ "inquirer": "^9.0.0",
65
65
  "jsdom": "^25.0.1",
66
66
  "lucide-react": "^0.454.0",
67
67
  "node-fetch": "^3.3.0",
@@ -133,5 +133,5 @@
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
136
- "gitHead": "0f7615943ac08db14aa2dc7f3fd7fc0b16844046"
136
+ "gitHead": "88d942f366b60c530e645cb391966ba05600effe"
137
137
  }
@@ -1,4 +1,4 @@
1
- export declare function hasThemeMeta(platformVersion: string): boolean;
1
+ export declare function hasNewDirectoryStructure(platformVersion: string): boolean;
2
2
  export declare function determineSrcAndDest(webRoot: string, isUsingLocalWorkspace?: boolean): Promise<{
3
3
  absoluteSrc: any;
4
4
  dest: any;