@hubspot/cms-dev-server 1.2.60 → 1.2.62
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/.DS_Store +0 -0
- package/dist/css/webDefaultStyles.css +149 -0
- package/dist/index.js +38 -28
- package/dist/run.js +34 -24
- package/package.json +4 -4
- package/types/lib/debugAuth.d.ts +2 -0
- package/types/lib/localComponentsLoader.d.ts +2 -0
- package/types/lib/viteAssetHandler.d.ts +15 -0
- package/types/plugins/hubspotStaticAssetPlugin.d.ts +2 -0
- package/types/plugins/remoteAssetsPlugin.d.ts +7 -0
- package/types/plugins/requestSigningPlugin.d.ts +6 -0
- package/types/routes/createAppServerRoutes.d.ts +5 -0
- package/types/routes/homeRouteHandler.d.ts +3 -0
package/dist/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* Mirror of web-default-templates/src/styles/main.css */
|
|
2
|
+
/* Normalize */
|
|
3
|
+
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
|
4
|
+
|
|
5
|
+
html {
|
|
6
|
+
-webkit-text-size-adjust: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
sub,
|
|
14
|
+
sup {
|
|
15
|
+
font-size: 75%;
|
|
16
|
+
line-height: 0;
|
|
17
|
+
position: relative;
|
|
18
|
+
vertical-align: baseline;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
sub {
|
|
22
|
+
bottom: -0.25em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
sup {
|
|
26
|
+
top: -0.5em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* CSS Variables */
|
|
30
|
+
|
|
31
|
+
:root {
|
|
32
|
+
--hs-heading-fontSizeMultiplier: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (width < 768px) {
|
|
36
|
+
:root {
|
|
37
|
+
--hs-heading-fontSizeMultiplier: 0.8;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-hs-breakpoint-name="mobile"] {
|
|
42
|
+
--hs-heading-fontSizeMultiplier: 0.8;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Typography */
|
|
46
|
+
|
|
47
|
+
body {
|
|
48
|
+
font-family: var(--hs-paragraph-fontFamily);
|
|
49
|
+
font-size: var(--hs-paragraph-fontSize);
|
|
50
|
+
font-style: var(--hs-paragraph-fontStyle);
|
|
51
|
+
font-weight: var(--hs-paragraph-fontWeight);
|
|
52
|
+
line-height: var(--hs-paragraph-lineHeight);
|
|
53
|
+
overflow-wrap: break-word;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
html[lang^='ja'] body,
|
|
57
|
+
html[lang^='zh'] body,
|
|
58
|
+
html[lang^='ko'] body {
|
|
59
|
+
line-break: strict;
|
|
60
|
+
overflow-wrap: normal;
|
|
61
|
+
word-break: break-all;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
a:not([data-button-variant]) {
|
|
65
|
+
text-decoration: var(--hs-link-textDecoration);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
a:not([data-button-variant]):hover,
|
|
69
|
+
a:not([data-button-variant]):focus-visible {
|
|
70
|
+
text-decoration: var(--hs-link-textDecoration-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
a:not([data-button-variant]):focus-visible {
|
|
74
|
+
outline: 2px solid Highlight;
|
|
75
|
+
outline-offset: 2px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, [data-button-variant]) {
|
|
79
|
+
font-weight: var(--hs-link-fontWeight);
|
|
80
|
+
font-style: var(--hs-link-fontStyle);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, [data-button-variant]):hover,
|
|
84
|
+
a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, [data-button-variant]):focus-visible {
|
|
85
|
+
font-weight: var(--hs-link-fontWeight-hover);
|
|
86
|
+
font-style: var(--hs-link-fontStyle-hover);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
h1,
|
|
90
|
+
h2,
|
|
91
|
+
h3,
|
|
92
|
+
h4,
|
|
93
|
+
h5,
|
|
94
|
+
h6 {
|
|
95
|
+
font-family: var(--hs-headings-fontFamily);
|
|
96
|
+
letter-spacing: var(--hs-headings-letterSpacing);
|
|
97
|
+
line-height: var(--hs-headings-lineHeight);
|
|
98
|
+
text-transform: var(--hs-headings-textTransform);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
h1 {
|
|
102
|
+
font-size: calc(var(--hs-heading1-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
103
|
+
font-style: var(--hs-heading1-fontStyle);
|
|
104
|
+
font-weight: var(--hs-heading1-fontWeight);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
h2 {
|
|
108
|
+
font-size: calc(var(--hs-heading2-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
109
|
+
font-style: var(--hs-heading2-fontStyle);
|
|
110
|
+
font-weight: var(--hs-heading2-fontWeight);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
h3 {
|
|
114
|
+
font-size: calc(var(--hs-heading3-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
115
|
+
font-style: var(--hs-heading3-fontStyle);
|
|
116
|
+
font-weight: var(--hs-heading3-fontWeight);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
h4 {
|
|
120
|
+
font-size: calc(var(--hs-heading4-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
121
|
+
font-style: var(--hs-heading4-fontStyle);
|
|
122
|
+
font-weight: var(--hs-heading4-fontWeight);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
h5 {
|
|
126
|
+
font-size: calc(var(--hs-heading5-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
127
|
+
font-style: var(--hs-heading5-fontStyle);
|
|
128
|
+
font-weight: var(--hs-heading5-fontWeight);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
h6 {
|
|
132
|
+
font-size: calc(var(--hs-heading6-fontSize) * var(--hs-heading-fontSizeMultiplier));
|
|
133
|
+
font-style: var(--hs-heading6-fontStyle);
|
|
134
|
+
font-weight: var(--hs-heading6-fontWeight);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
blockquote {
|
|
138
|
+
font-family: var(--hs-blockquote-fontFamily);
|
|
139
|
+
font-size: var(--hs-blockquote-fontSize);
|
|
140
|
+
font-style: var(--hs-blockquote-fontStyle);
|
|
141
|
+
font-weight: var(--hs-blockquote-fontWeight);
|
|
142
|
+
line-height: var(--hs-blockquote-lineHeight);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* Layout */
|
|
146
|
+
|
|
147
|
+
*, *::before, *::after {
|
|
148
|
+
box-sizing: border-box;
|
|
149
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1230,7 +1230,7 @@ var createViteDevServer_default = createViteDevServer;
|
|
|
1230
1230
|
|
|
1231
1231
|
// src/createDevServer.ts
|
|
1232
1232
|
import path17 from "path";
|
|
1233
|
-
import
|
|
1233
|
+
import fs9 from "fs";
|
|
1234
1234
|
import url2 from "url";
|
|
1235
1235
|
import express2 from "express";
|
|
1236
1236
|
import http3 from "http";
|
|
@@ -1651,7 +1651,7 @@ function trackUsage(action) {
|
|
|
1651
1651
|
eventName: EVENT_NAME,
|
|
1652
1652
|
action,
|
|
1653
1653
|
nodeVersion: getNodeVersionData(),
|
|
1654
|
-
version: "1.2.
|
|
1654
|
+
version: "1.2.62",
|
|
1655
1655
|
os: getPlatform()
|
|
1656
1656
|
};
|
|
1657
1657
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1691,6 +1691,7 @@ function sendTrackingRequest(action) {
|
|
|
1691
1691
|
|
|
1692
1692
|
// src/lib/renderModulePreview.ts
|
|
1693
1693
|
import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components";
|
|
1694
|
+
import fs3 from "fs";
|
|
1694
1695
|
import path6 from "path";
|
|
1695
1696
|
import { normalizePath as normalizePath4 } from "vite";
|
|
1696
1697
|
|
|
@@ -1936,10 +1937,6 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1936
1937
|
hublData,
|
|
1937
1938
|
moduleName
|
|
1938
1939
|
} = moduleProps;
|
|
1939
|
-
const ungatedForServerSideProps = isUngatedFor(
|
|
1940
|
-
environmentConfig.getGates(),
|
|
1941
|
-
"CMS:JSRenderer:GetServerSideProps"
|
|
1942
|
-
);
|
|
1943
1940
|
const messagesForBrowser = [];
|
|
1944
1941
|
let componentModule;
|
|
1945
1942
|
let dataQueryResult;
|
|
@@ -2022,7 +2019,7 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
2022
2019
|
hublData,
|
|
2023
2020
|
moduleName
|
|
2024
2021
|
});
|
|
2025
|
-
if (
|
|
2022
|
+
if (componentModule.getServerSideProps) {
|
|
2026
2023
|
if (!getModuleDataDependecyTypeFrom || !filterToModuleDataDepsIncludedIn) {
|
|
2027
2024
|
throw new Error(
|
|
2028
2025
|
`Need to upgrade to @hubspot/cms-components 0.15.x or higher to use getServerSideProps`
|
|
@@ -3072,6 +3069,15 @@ function extractRelevantCss(cssText) {
|
|
|
3072
3069
|
|
|
3073
3070
|
// src/lib/renderModulePreview.ts
|
|
3074
3071
|
import jsdom from "jsdom";
|
|
3072
|
+
var _webDefaultStylesCss = null;
|
|
3073
|
+
function getWebDefaultStylesCss(metaUrl) {
|
|
3074
|
+
if (_webDefaultStylesCss === null) {
|
|
3075
|
+
const cssPath = packagePath(metaUrl, "css/webDefaultStyles.css");
|
|
3076
|
+
const css = fs3.readFileSync(cssPath, "utf-8");
|
|
3077
|
+
_webDefaultStylesCss = `<style data-hs-styles="web-defaults">${css}</style>`;
|
|
3078
|
+
}
|
|
3079
|
+
return _webDefaultStylesCss;
|
|
3080
|
+
}
|
|
3075
3081
|
var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
|
|
3076
3082
|
async function signGetUrl(authedPortalId, unsignedUrl) {
|
|
3077
3083
|
const urlWithPortalId = new URL(unsignedUrl);
|
|
@@ -3144,7 +3150,8 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
|
|
|
3144
3150
|
hsLocalProxy: `${true}`,
|
|
3145
3151
|
localProxySchemaVersion: "2",
|
|
3146
3152
|
hsLoginVerifyDisabled: `${true}`,
|
|
3147
|
-
module_id: moduleInfo.moduleId
|
|
3153
|
+
module_id: moduleInfo.moduleId,
|
|
3154
|
+
buffer_theme: `${true}`
|
|
3148
3155
|
});
|
|
3149
3156
|
const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
|
|
3150
3157
|
const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
@@ -3269,6 +3276,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3269
3276
|
hsLocalProxy: `${true}`,
|
|
3270
3277
|
localProxySchemaVersion: "2",
|
|
3271
3278
|
portalId: `${authedPortalId}`,
|
|
3279
|
+
buffer_theme: `${true}`,
|
|
3272
3280
|
...meta.editor_version === "2.0" ? { editor_version: "2.0" } : {}
|
|
3273
3281
|
});
|
|
3274
3282
|
const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
@@ -3310,7 +3318,9 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3310
3318
|
previewDom.window.document.querySelectorAll("head style")
|
|
3311
3319
|
).map((element) => element.textContent || "").join("\n");
|
|
3312
3320
|
const filteredCss = extractRelevantCss(allStyleContent);
|
|
3313
|
-
const
|
|
3321
|
+
const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
|
|
3322
|
+
const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
|
|
3323
|
+
const globalStylesCss = [themeVariablesCss, webDefaultStylesCss].filter(Boolean).join("\n");
|
|
3314
3324
|
const renderResult = await renderComponentForPlaceholder(
|
|
3315
3325
|
0,
|
|
3316
3326
|
localRenderPlaceholders[0],
|
|
@@ -4517,7 +4527,7 @@ function createAppServerAPIRoutes() {
|
|
|
4517
4527
|
var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
|
|
4518
4528
|
|
|
4519
4529
|
// src/routes/appServerRouteHandler.ts
|
|
4520
|
-
import
|
|
4530
|
+
import fs5 from "node:fs/promises";
|
|
4521
4531
|
import path12 from "path";
|
|
4522
4532
|
import { pathToFileURL } from "url";
|
|
4523
4533
|
|
|
@@ -4535,7 +4545,7 @@ async function fetchProjectByName(accountId, projectName) {
|
|
|
4535
4545
|
}
|
|
4536
4546
|
|
|
4537
4547
|
// src/lib/getDevServerUIData.ts
|
|
4538
|
-
import
|
|
4548
|
+
import fs4 from "node:fs";
|
|
4539
4549
|
var templateTypeMap = {
|
|
4540
4550
|
// Standard templates
|
|
4541
4551
|
4: "Page",
|
|
@@ -4607,9 +4617,9 @@ function normalizeTemplatesData(templates, projectName) {
|
|
|
4607
4617
|
});
|
|
4608
4618
|
}
|
|
4609
4619
|
function detectPackageManager(projectRoot) {
|
|
4610
|
-
if (
|
|
4620
|
+
if (fs4.existsSync(path11.join(projectRoot, "yarn.lock")))
|
|
4611
4621
|
return "yarn";
|
|
4612
|
-
if (
|
|
4622
|
+
if (fs4.existsSync(path11.join(projectRoot, "pnpm-lock.yaml")))
|
|
4613
4623
|
return "pnpm";
|
|
4614
4624
|
return "npm";
|
|
4615
4625
|
}
|
|
@@ -4696,7 +4706,7 @@ var appServerRouteHandler = async (req, res, __next) => {
|
|
|
4696
4706
|
const templatePath = path12.join(appWebRoot, "index.html");
|
|
4697
4707
|
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4698
4708
|
let render;
|
|
4699
|
-
let template = await
|
|
4709
|
+
let template = await fs5.readFile(path12.join(templatePath), "utf-8");
|
|
4700
4710
|
if (isProd) {
|
|
4701
4711
|
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
4702
4712
|
render = ssrRender;
|
|
@@ -5024,14 +5034,14 @@ async function getJsRenderingGates(portalId, env2, personalAccessKey) {
|
|
|
5024
5034
|
|
|
5025
5035
|
// src/lib/hsmetaUtils.ts
|
|
5026
5036
|
import path14 from "path";
|
|
5027
|
-
import
|
|
5037
|
+
import fs6 from "fs";
|
|
5028
5038
|
var HSMETA_FILENAMES = [
|
|
5029
5039
|
"theme-hsmeta.json",
|
|
5030
5040
|
"cms-assets-hsmeta.json"
|
|
5031
5041
|
];
|
|
5032
5042
|
function getSubdirectories(dirPath) {
|
|
5033
5043
|
try {
|
|
5034
|
-
return
|
|
5044
|
+
return fs6.readdirSync(dirPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
5035
5045
|
} catch {
|
|
5036
5046
|
return [];
|
|
5037
5047
|
}
|
|
@@ -5044,7 +5054,7 @@ function hsmetaCandidatePaths(srcPath) {
|
|
|
5044
5054
|
}
|
|
5045
5055
|
function tryParseUid(hsmetaPath) {
|
|
5046
5056
|
try {
|
|
5047
|
-
const hsmeta = JSON.parse(
|
|
5057
|
+
const hsmeta = JSON.parse(fs6.readFileSync(hsmetaPath, "utf8"));
|
|
5048
5058
|
return hsmeta.uid ?? null;
|
|
5049
5059
|
} catch (parseErr) {
|
|
5050
5060
|
console.warn(`Could not parse ${hsmetaPath}:`, parseErr.message);
|
|
@@ -5054,7 +5064,7 @@ function tryParseUid(hsmetaPath) {
|
|
|
5054
5064
|
function findHsmetaUid(projectDir, srcDir) {
|
|
5055
5065
|
const srcPath = path14.join(projectDir, srcDir);
|
|
5056
5066
|
for (const candidatePath of hsmetaCandidatePaths(srcPath)) {
|
|
5057
|
-
if (!
|
|
5067
|
+
if (!fs6.existsSync(candidatePath))
|
|
5058
5068
|
continue;
|
|
5059
5069
|
const uid = tryParseUid(candidatePath);
|
|
5060
5070
|
if (uid)
|
|
@@ -5269,12 +5279,12 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5269
5279
|
|
|
5270
5280
|
// src/lib/validateHSPlatform.ts
|
|
5271
5281
|
import path15 from "path";
|
|
5272
|
-
import
|
|
5282
|
+
import fs7 from "fs";
|
|
5273
5283
|
import select from "@inquirer/select";
|
|
5274
5284
|
import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
|
|
5275
5285
|
var HSPROJECT_JSON = "hsproject.json";
|
|
5276
5286
|
function checkFileExists(filePath) {
|
|
5277
|
-
return
|
|
5287
|
+
return fs7.existsSync(filePath) && fs7.statSync(filePath).isFile();
|
|
5278
5288
|
}
|
|
5279
5289
|
function findHSProjectJson(startPath) {
|
|
5280
5290
|
let currentDir = startPath;
|
|
@@ -5300,7 +5310,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5300
5310
|
);
|
|
5301
5311
|
return false;
|
|
5302
5312
|
}
|
|
5303
|
-
const hsProjectJSONContents =
|
|
5313
|
+
const hsProjectJSONContents = fs7.readFileSync(projectConfigPath, "utf8");
|
|
5304
5314
|
const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
|
|
5305
5315
|
const { platformVersion } = hsProjectJSONData;
|
|
5306
5316
|
let platformVersionResult;
|
|
@@ -5328,7 +5338,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5328
5338
|
});
|
|
5329
5339
|
hsProjectJSONData.platformVersion = answer;
|
|
5330
5340
|
try {
|
|
5331
|
-
|
|
5341
|
+
fs7.writeFileSync(
|
|
5332
5342
|
projectConfigPath,
|
|
5333
5343
|
JSON.stringify(hsProjectJSONData, void 0, 2),
|
|
5334
5344
|
"utf8"
|
|
@@ -5590,7 +5600,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5590
5600
|
}
|
|
5591
5601
|
|
|
5592
5602
|
// src/lib/watchFieldsUpdates.ts
|
|
5593
|
-
import
|
|
5603
|
+
import fs8 from "fs";
|
|
5594
5604
|
import path16 from "path";
|
|
5595
5605
|
import readline from "readline";
|
|
5596
5606
|
var lastSerializedFieldsCache = {};
|
|
@@ -5612,9 +5622,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
5612
5622
|
};
|
|
5613
5623
|
};
|
|
5614
5624
|
var fileContainsAutoGenComment = async (filePath) => {
|
|
5615
|
-
if (!
|
|
5625
|
+
if (!fs8.existsSync(filePath))
|
|
5616
5626
|
return true;
|
|
5617
|
-
const stream2 =
|
|
5627
|
+
const stream2 = fs8.createReadStream(filePath);
|
|
5618
5628
|
const reader = readline.createInterface({ input: stream2 });
|
|
5619
5629
|
const firstLine = await new Promise(
|
|
5620
5630
|
(resolve2) => reader.once("line", (line) => resolve2(line.trim()))
|
|
@@ -5633,7 +5643,7 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5633
5643
|
if (isRootModuleFile)
|
|
5634
5644
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5635
5645
|
const dir = path16.dirname(filePath);
|
|
5636
|
-
const files =
|
|
5646
|
+
const files = fs8.readdirSync(dir);
|
|
5637
5647
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5638
5648
|
return indexFileName ? { indexFilePath: path16.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5639
5649
|
};
|
|
@@ -5726,7 +5736,7 @@ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
|
|
|
5726
5736
|
}
|
|
5727
5737
|
try {
|
|
5728
5738
|
const projectDir = path17.dirname(projectConfigPath);
|
|
5729
|
-
const configContent =
|
|
5739
|
+
const configContent = fs9.readFileSync(projectConfigPath, "utf8");
|
|
5730
5740
|
const projectConfig = JSON.parse(configContent);
|
|
5731
5741
|
if (hasNewDirectoryStructure(projectConfig.platformVersion)) {
|
|
5732
5742
|
const srcDir = projectConfig.srcDir || "src";
|
|
@@ -5996,7 +6006,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
5996
6006
|
const sbPackagePath = await import.meta.resolve("storybook/package.json");
|
|
5997
6007
|
const sbPackageDir = path17.dirname(url2.fileURLToPath(sbPackagePath));
|
|
5998
6008
|
const packageJson = JSON.parse(
|
|
5999
|
-
|
|
6009
|
+
fs9.readFileSync(path17.join(sbPackageDir, "package.json"), "utf-8")
|
|
6000
6010
|
);
|
|
6001
6011
|
storybookBin = path17.join(
|
|
6002
6012
|
sbPackageDir,
|
package/dist/run.js
CHANGED
|
@@ -843,7 +843,7 @@ async function buildThemePreviewOptions(webRoot2, isUsingLocalWorkspace = false)
|
|
|
843
843
|
|
|
844
844
|
// src/createDevServer.ts
|
|
845
845
|
import path18 from "path";
|
|
846
|
-
import
|
|
846
|
+
import fs10 from "fs";
|
|
847
847
|
import url2 from "url";
|
|
848
848
|
import express2 from "express";
|
|
849
849
|
import http3 from "http";
|
|
@@ -2256,7 +2256,7 @@ function trackUsage(action) {
|
|
|
2256
2256
|
eventName: EVENT_NAME,
|
|
2257
2257
|
action,
|
|
2258
2258
|
nodeVersion: getNodeVersionData(),
|
|
2259
|
-
version: "1.2.
|
|
2259
|
+
version: "1.2.62",
|
|
2260
2260
|
os: getPlatform()
|
|
2261
2261
|
};
|
|
2262
2262
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -2296,6 +2296,7 @@ function sendTrackingRequest(action) {
|
|
|
2296
2296
|
|
|
2297
2297
|
// src/lib/renderModulePreview.ts
|
|
2298
2298
|
import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components";
|
|
2299
|
+
import fs5 from "fs";
|
|
2299
2300
|
import path8 from "path";
|
|
2300
2301
|
import { normalizePath as normalizePath4 } from "vite";
|
|
2301
2302
|
|
|
@@ -2541,10 +2542,6 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
2541
2542
|
hublData,
|
|
2542
2543
|
moduleName
|
|
2543
2544
|
} = moduleProps;
|
|
2544
|
-
const ungatedForServerSideProps = isUngatedFor(
|
|
2545
|
-
environmentConfig.getGates(),
|
|
2546
|
-
"CMS:JSRenderer:GetServerSideProps"
|
|
2547
|
-
);
|
|
2548
2545
|
const messagesForBrowser = [];
|
|
2549
2546
|
let componentModule;
|
|
2550
2547
|
let dataQueryResult;
|
|
@@ -2627,7 +2624,7 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
2627
2624
|
hublData,
|
|
2628
2625
|
moduleName
|
|
2629
2626
|
});
|
|
2630
|
-
if (
|
|
2627
|
+
if (componentModule.getServerSideProps) {
|
|
2631
2628
|
if (!getModuleDataDependecyTypeFrom || !filterToModuleDataDepsIncludedIn) {
|
|
2632
2629
|
throw new Error(
|
|
2633
2630
|
`Need to upgrade to @hubspot/cms-components 0.15.x or higher to use getServerSideProps`
|
|
@@ -3677,6 +3674,15 @@ function extractRelevantCss(cssText) {
|
|
|
3677
3674
|
|
|
3678
3675
|
// src/lib/renderModulePreview.ts
|
|
3679
3676
|
import jsdom from "jsdom";
|
|
3677
|
+
var _webDefaultStylesCss = null;
|
|
3678
|
+
function getWebDefaultStylesCss(metaUrl) {
|
|
3679
|
+
if (_webDefaultStylesCss === null) {
|
|
3680
|
+
const cssPath = packagePath(metaUrl, "css/webDefaultStyles.css");
|
|
3681
|
+
const css = fs5.readFileSync(cssPath, "utf-8");
|
|
3682
|
+
_webDefaultStylesCss = `<style data-hs-styles="web-defaults">${css}</style>`;
|
|
3683
|
+
}
|
|
3684
|
+
return _webDefaultStylesCss;
|
|
3685
|
+
}
|
|
3680
3686
|
var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
|
|
3681
3687
|
async function signGetUrl(authedPortalId, unsignedUrl) {
|
|
3682
3688
|
const urlWithPortalId = new URL(unsignedUrl);
|
|
@@ -3749,7 +3755,8 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
|
|
|
3749
3755
|
hsLocalProxy: `${true}`,
|
|
3750
3756
|
localProxySchemaVersion: "2",
|
|
3751
3757
|
hsLoginVerifyDisabled: `${true}`,
|
|
3752
|
-
module_id: moduleInfo.moduleId
|
|
3758
|
+
module_id: moduleInfo.moduleId,
|
|
3759
|
+
buffer_theme: `${true}`
|
|
3753
3760
|
});
|
|
3754
3761
|
const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
|
|
3755
3762
|
const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
@@ -3874,6 +3881,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3874
3881
|
hsLocalProxy: `${true}`,
|
|
3875
3882
|
localProxySchemaVersion: "2",
|
|
3876
3883
|
portalId: `${authedPortalId}`,
|
|
3884
|
+
buffer_theme: `${true}`,
|
|
3877
3885
|
...meta.editor_version === "2.0" ? { editor_version: "2.0" } : {}
|
|
3878
3886
|
});
|
|
3879
3887
|
const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
@@ -3915,7 +3923,9 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3915
3923
|
previewDom.window.document.querySelectorAll("head style")
|
|
3916
3924
|
).map((element) => element.textContent || "").join("\n");
|
|
3917
3925
|
const filteredCss = extractRelevantCss(allStyleContent);
|
|
3918
|
-
const
|
|
3926
|
+
const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
|
|
3927
|
+
const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
|
|
3928
|
+
const globalStylesCss = [themeVariablesCss, webDefaultStylesCss].filter(Boolean).join("\n");
|
|
3919
3929
|
const renderResult = await renderComponentForPlaceholder(
|
|
3920
3930
|
0,
|
|
3921
3931
|
localRenderPlaceholders[0],
|
|
@@ -5122,7 +5132,7 @@ function createAppServerAPIRoutes() {
|
|
|
5122
5132
|
var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
|
|
5123
5133
|
|
|
5124
5134
|
// src/routes/appServerRouteHandler.ts
|
|
5125
|
-
import
|
|
5135
|
+
import fs7 from "node:fs/promises";
|
|
5126
5136
|
import path14 from "path";
|
|
5127
5137
|
import { pathToFileURL } from "url";
|
|
5128
5138
|
|
|
@@ -5359,7 +5369,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
5359
5369
|
var createViteDevServer_default = createViteDevServer;
|
|
5360
5370
|
|
|
5361
5371
|
// src/lib/getDevServerUIData.ts
|
|
5362
|
-
import
|
|
5372
|
+
import fs6 from "node:fs";
|
|
5363
5373
|
var templateTypeMap = {
|
|
5364
5374
|
// Standard templates
|
|
5365
5375
|
4: "Page",
|
|
@@ -5431,9 +5441,9 @@ function normalizeTemplatesData(templates, projectName) {
|
|
|
5431
5441
|
});
|
|
5432
5442
|
}
|
|
5433
5443
|
function detectPackageManager(projectRoot) {
|
|
5434
|
-
if (
|
|
5444
|
+
if (fs6.existsSync(path13.join(projectRoot, "yarn.lock")))
|
|
5435
5445
|
return "yarn";
|
|
5436
|
-
if (
|
|
5446
|
+
if (fs6.existsSync(path13.join(projectRoot, "pnpm-lock.yaml")))
|
|
5437
5447
|
return "pnpm";
|
|
5438
5448
|
return "npm";
|
|
5439
5449
|
}
|
|
@@ -5520,7 +5530,7 @@ var appServerRouteHandler = async (req, res, __next) => {
|
|
|
5520
5530
|
const templatePath = path14.join(appWebRoot, "index.html");
|
|
5521
5531
|
const serverEntryPath = isProd ? path14.join(appWebRoot, "server/serverEntry.js") : path14.join(appWebRoot, "serverEntry.tsx");
|
|
5522
5532
|
let render;
|
|
5523
|
-
let template = await
|
|
5533
|
+
let template = await fs7.readFile(path14.join(templatePath), "utf-8");
|
|
5524
5534
|
if (isProd) {
|
|
5525
5535
|
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
5526
5536
|
render = ssrRender;
|
|
@@ -5938,12 +5948,12 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5938
5948
|
|
|
5939
5949
|
// src/lib/validateHSPlatform.ts
|
|
5940
5950
|
import path16 from "path";
|
|
5941
|
-
import
|
|
5951
|
+
import fs8 from "fs";
|
|
5942
5952
|
import select from "@inquirer/select";
|
|
5943
5953
|
import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
|
|
5944
5954
|
var HSPROJECT_JSON = "hsproject.json";
|
|
5945
5955
|
function checkFileExists(filePath) {
|
|
5946
|
-
return
|
|
5956
|
+
return fs8.existsSync(filePath) && fs8.statSync(filePath).isFile();
|
|
5947
5957
|
}
|
|
5948
5958
|
function findHSProjectJson(startPath) {
|
|
5949
5959
|
let currentDir = startPath;
|
|
@@ -5969,7 +5979,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5969
5979
|
);
|
|
5970
5980
|
return false;
|
|
5971
5981
|
}
|
|
5972
|
-
const hsProjectJSONContents =
|
|
5982
|
+
const hsProjectJSONContents = fs8.readFileSync(projectConfigPath, "utf8");
|
|
5973
5983
|
const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
|
|
5974
5984
|
const { platformVersion } = hsProjectJSONData;
|
|
5975
5985
|
let platformVersionResult;
|
|
@@ -5997,7 +6007,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5997
6007
|
});
|
|
5998
6008
|
hsProjectJSONData.platformVersion = answer;
|
|
5999
6009
|
try {
|
|
6000
|
-
|
|
6010
|
+
fs8.writeFileSync(
|
|
6001
6011
|
projectConfigPath,
|
|
6002
6012
|
JSON.stringify(hsProjectJSONData, void 0, 2),
|
|
6003
6013
|
"utf8"
|
|
@@ -6259,7 +6269,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
6259
6269
|
}
|
|
6260
6270
|
|
|
6261
6271
|
// src/lib/watchFieldsUpdates.ts
|
|
6262
|
-
import
|
|
6272
|
+
import fs9 from "fs";
|
|
6263
6273
|
import path17 from "path";
|
|
6264
6274
|
import readline from "readline";
|
|
6265
6275
|
var lastSerializedFieldsCache = {};
|
|
@@ -6281,9 +6291,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
6281
6291
|
};
|
|
6282
6292
|
};
|
|
6283
6293
|
var fileContainsAutoGenComment = async (filePath) => {
|
|
6284
|
-
if (!
|
|
6294
|
+
if (!fs9.existsSync(filePath))
|
|
6285
6295
|
return true;
|
|
6286
|
-
const stream2 =
|
|
6296
|
+
const stream2 = fs9.createReadStream(filePath);
|
|
6287
6297
|
const reader = readline.createInterface({ input: stream2 });
|
|
6288
6298
|
const firstLine = await new Promise(
|
|
6289
6299
|
(resolve3) => reader.once("line", (line) => resolve3(line.trim()))
|
|
@@ -6302,7 +6312,7 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
6302
6312
|
if (isRootModuleFile)
|
|
6303
6313
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
6304
6314
|
const dir = path17.dirname(filePath);
|
|
6305
|
-
const files =
|
|
6315
|
+
const files = fs9.readdirSync(dir);
|
|
6306
6316
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
6307
6317
|
return indexFileName ? { indexFilePath: path17.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
6308
6318
|
};
|
|
@@ -6395,7 +6405,7 @@ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
|
|
|
6395
6405
|
}
|
|
6396
6406
|
try {
|
|
6397
6407
|
const projectDir = path18.dirname(projectConfigPath);
|
|
6398
|
-
const configContent =
|
|
6408
|
+
const configContent = fs10.readFileSync(projectConfigPath, "utf8");
|
|
6399
6409
|
const projectConfig = JSON.parse(configContent);
|
|
6400
6410
|
if (hasNewDirectoryStructure(projectConfig.platformVersion)) {
|
|
6401
6411
|
const srcDir = projectConfig.srcDir || "src";
|
|
@@ -6665,7 +6675,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
6665
6675
|
const sbPackagePath = await import.meta.resolve("storybook/package.json");
|
|
6666
6676
|
const sbPackageDir = path18.dirname(url2.fileURLToPath(sbPackagePath));
|
|
6667
6677
|
const packageJson = JSON.parse(
|
|
6668
|
-
|
|
6678
|
+
fs10.readFileSync(path18.join(sbPackageDir, "package.json"), "utf-8")
|
|
6669
6679
|
);
|
|
6670
6680
|
storybookBin = path18.join(
|
|
6671
6681
|
sbPackageDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.62",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc -noEmit && yarn run copy-html && yarn build-types && node scripts/build.mjs && npm run publint",
|
|
11
11
|
"build:watch": "nodemon --exec 'yarn build'",
|
|
12
|
-
"copy-html": "copyfiles -u 1 'src/html/**' 'dist'",
|
|
12
|
+
"copy-html": "copyfiles -u 1 'src/html/**' 'src/css/**' 'dist'",
|
|
13
13
|
"build-types": "tsc --project tsconfig.types.json",
|
|
14
14
|
"clean": "tsc --build --clean",
|
|
15
15
|
"dev": "nodemon --no-stdin --exec 'yarn start'",
|
|
@@ -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": "^1.2.
|
|
32
|
+
"@hubspot/cms-components": "^1.2.62",
|
|
33
33
|
"@hubspot/local-dev-lib": "5.8.2",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"publishConfig": {
|
|
136
136
|
"access": "public"
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "09647aaa9bc9c976ab73dd86ab7bd30e3b57ed4d"
|
|
139
139
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Processes HTML to find remote assets and replace with Vite-managed URLs
|
|
4
|
+
*/
|
|
5
|
+
export declare function processRemoteAssets(html: string, viteServer: ViteDevServer): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Vite plugin to handle remote assets
|
|
8
|
+
*/
|
|
9
|
+
export declare function remoteAssetsPlugin(): {
|
|
10
|
+
name: string;
|
|
11
|
+
apply: "serve";
|
|
12
|
+
configResolved(config: any): void;
|
|
13
|
+
resolveId(id: string): string;
|
|
14
|
+
load(id: string): Promise<string>;
|
|
15
|
+
};
|
|
@@ -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;
|