@hubspot/cms-dev-server 1.2.32 → 1.2.34
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/app/index.html +2 -2
- package/dist/generateJsonFromJsx.js +3 -3
- package/dist/index.js +226 -130
- package/dist/internalSsr.js +6 -6
- package/dist/island-runtime.js +38 -23
- package/dist/run.js +315 -219
- package/dist/storybook/index.js +1 -1
- package/dist/storybook-main/main.js +10 -10
- package/package.json +5 -5
- package/types/lib/hsmetaUtils.d.ts +3 -0
- package/types/lib/renderModulePreview.d.ts +4 -1
- /package/dist/app/assets/{index-tvg7JxpD.js → index-BhmkOPU4.js} +0 -0
- /package/dist/app/assets/{index-PcyCbkys.css → index-CbQ-tZoN.css} +0 -0
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createServer as createViteServer } from "vite";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import { default as react } from "@vitejs/plugin-react";
|
|
5
5
|
|
|
6
|
-
// ../cms-js-internal/dist/types-
|
|
6
|
+
// ../cms-js-internal/dist/types-BEz622C8.js
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { createHash } from "crypto";
|
|
9
9
|
import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
@@ -118,7 +118,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
118
118
|
idWithNoParam,
|
|
119
119
|
componentExtension
|
|
120
120
|
);
|
|
121
|
-
const modulePath =
|
|
121
|
+
const modulePath = path.relative(viteRoot, idWithNoParam);
|
|
122
122
|
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
123
123
|
if (islandsSet) {
|
|
124
124
|
islandsSet.add(moduleId);
|
|
@@ -237,10 +237,20 @@ function getCMSAssetConfig(webRoot) {
|
|
|
237
237
|
);
|
|
238
238
|
return parsedConfig;
|
|
239
239
|
}
|
|
240
|
+
function getCMSAssetConfigIfExists(webRoot) {
|
|
241
|
+
try {
|
|
242
|
+
return getCMSAssetConfig(webRoot);
|
|
243
|
+
} catch (e) {
|
|
244
|
+
console.error(
|
|
245
|
+
`Error finding or parsing cms-assets.json in ${webRoot}, but ignoring for now`
|
|
246
|
+
);
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
240
250
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
241
251
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
242
|
-
"cms:jsr:
|
|
243
|
-
"
|
|
252
|
+
"cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
|
|
253
|
+
"PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
|
|
244
254
|
};
|
|
245
255
|
function isUngatedFor(gates, gate) {
|
|
246
256
|
return gates.includes(gate);
|
|
@@ -663,8 +673,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
663
673
|
);
|
|
664
674
|
return Object.fromEntries(relativeEntries);
|
|
665
675
|
}
|
|
666
|
-
function toRelativePath(config,
|
|
667
|
-
return
|
|
676
|
+
function toRelativePath(config, path18) {
|
|
677
|
+
return path18.replace(`${config.root}/`, "");
|
|
668
678
|
}
|
|
669
679
|
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
670
680
|
const [fileId, __] = moduleInfo.id.split("?");
|
|
@@ -707,11 +717,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
707
717
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
708
718
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
709
719
|
traverse(sourceAst, {
|
|
710
|
-
ImportDeclaration(
|
|
711
|
-
if (t.isStringLiteral(
|
|
720
|
+
ImportDeclaration(path18) {
|
|
721
|
+
if (t.isStringLiteral(path18.node.source, {
|
|
712
722
|
value: "@hubspot/cms-components"
|
|
713
723
|
})) {
|
|
714
|
-
for (const specifier of
|
|
724
|
+
for (const specifier of path18.node.specifiers) {
|
|
715
725
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
716
726
|
name: CMS_MODULE_COMPONENT_NAME
|
|
717
727
|
})) {
|
|
@@ -725,14 +735,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
725
735
|
}
|
|
726
736
|
}
|
|
727
737
|
},
|
|
728
|
-
JSXOpeningElement(
|
|
729
|
-
if (t.isJSXIdentifier(
|
|
738
|
+
JSXOpeningElement(path18) {
|
|
739
|
+
if (t.isJSXIdentifier(path18.node.name, {
|
|
730
740
|
name: moduleComponentLocalImportName
|
|
731
741
|
})) {
|
|
732
742
|
let cmsModuleName;
|
|
733
743
|
let cmsModulePath;
|
|
734
744
|
let cmsModuleLabel;
|
|
735
|
-
for (const prop of
|
|
745
|
+
for (const prop of path18.node.attributes) {
|
|
736
746
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
737
747
|
cmsModuleName = prop.value.value;
|
|
738
748
|
continue;
|
|
@@ -767,11 +777,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
767
777
|
}
|
|
768
778
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
769
779
|
}
|
|
770
|
-
if (t.isJSXIdentifier(
|
|
780
|
+
if (t.isJSXIdentifier(path18.node.name, {
|
|
771
781
|
name: dndAreaComponentLocalImportName
|
|
772
782
|
})) {
|
|
773
783
|
let dndAreaName;
|
|
774
|
-
for (const prop of
|
|
784
|
+
for (const prop of path18.node.attributes) {
|
|
775
785
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
776
786
|
dndAreaName = prop.value.value;
|
|
777
787
|
continue;
|
|
@@ -1173,7 +1183,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1173
1183
|
}),
|
|
1174
1184
|
clientIslandEntryPlugin(),
|
|
1175
1185
|
resolveIslandPlugin(),
|
|
1176
|
-
|
|
1186
|
+
viteCommonjs(),
|
|
1177
1187
|
devSecretsPlugin(secretNames),
|
|
1178
1188
|
noncePlaceholderPlugin()
|
|
1179
1189
|
] : [];
|
|
@@ -1210,8 +1220,8 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1210
1220
|
var createViteDevServer_default = createViteDevServer;
|
|
1211
1221
|
|
|
1212
1222
|
// src/createDevServer.ts
|
|
1213
|
-
import
|
|
1214
|
-
import
|
|
1223
|
+
import path17 from "path";
|
|
1224
|
+
import fs8 from "fs";
|
|
1215
1225
|
import url2 from "url";
|
|
1216
1226
|
import express2 from "express";
|
|
1217
1227
|
import http3 from "http";
|
|
@@ -1631,7 +1641,7 @@ function trackUsage(action) {
|
|
|
1631
1641
|
eventName: EVENT_NAME,
|
|
1632
1642
|
action,
|
|
1633
1643
|
nodeVersion: getNodeVersionData(),
|
|
1634
|
-
version: "1.2.
|
|
1644
|
+
version: "1.2.34",
|
|
1635
1645
|
os: getPlatform()
|
|
1636
1646
|
};
|
|
1637
1647
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1704,12 +1714,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1704
1714
|
);
|
|
1705
1715
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1706
1716
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1707
|
-
const
|
|
1717
|
+
const path18 = body.substring(
|
|
1708
1718
|
startOffset + localJsRenderStartString.length,
|
|
1709
1719
|
pathEndOffset
|
|
1710
1720
|
);
|
|
1711
1721
|
offsetSoFar = pathEndOffset + 1;
|
|
1712
|
-
if (startOffset >= 0 &&
|
|
1722
|
+
if (startOffset >= 0 && path18) {
|
|
1713
1723
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1714
1724
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1715
1725
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1734,7 +1744,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1734
1744
|
result.push({
|
|
1735
1745
|
startOffset,
|
|
1736
1746
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1737
|
-
path:
|
|
1747
|
+
path: path18,
|
|
1738
1748
|
json
|
|
1739
1749
|
});
|
|
1740
1750
|
}
|
|
@@ -2113,9 +2123,9 @@ var customColors = [
|
|
|
2113
2123
|
];
|
|
2114
2124
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
2115
2125
|
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;`;
|
|
2116
|
-
var renderLocalError_default = (
|
|
2126
|
+
var renderLocalError_default = (path18, error) => {
|
|
2117
2127
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
2118
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
2128
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path18}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
2119
2129
|
};
|
|
2120
2130
|
|
|
2121
2131
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2912,8 +2922,51 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
|
|
|
2912
2922
|
import { getConfigAccountIfExists as getConfigAccountIfExists3 } from "@hubspot/local-dev-lib/config";
|
|
2913
2923
|
import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
|
|
2914
2924
|
import jsdom from "jsdom";
|
|
2925
|
+
var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
|
|
2926
|
+
async function signGetUrl(authedPortalId, unsignedUrl) {
|
|
2927
|
+
const urlWithPortalId = new URL(unsignedUrl);
|
|
2928
|
+
urlWithPortalId.searchParams.set("portalId", `${authedPortalId}`);
|
|
2929
|
+
const response = await hsCliHttp7.post(authedPortalId, {
|
|
2930
|
+
url: "/url-signer-rest/v1/signing",
|
|
2931
|
+
headers: {
|
|
2932
|
+
"Content-Type": "application/json",
|
|
2933
|
+
Accept: "application/json"
|
|
2934
|
+
},
|
|
2935
|
+
data: JSON.stringify({
|
|
2936
|
+
unsignedUrl: urlWithPortalId.toString(),
|
|
2937
|
+
httpMethod: "GET"
|
|
2938
|
+
})
|
|
2939
|
+
});
|
|
2940
|
+
return response.data.signedUrl;
|
|
2941
|
+
}
|
|
2942
|
+
async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
|
|
2943
|
+
if (!isUngatedFor(gates, URL_SIGNING_GATE)) {
|
|
2944
|
+
const { data } = await hsCliHttp7.get(authedPortalId, {
|
|
2945
|
+
url: unsignedUrl,
|
|
2946
|
+
headers
|
|
2947
|
+
});
|
|
2948
|
+
return data;
|
|
2949
|
+
}
|
|
2950
|
+
const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
|
|
2951
|
+
const authHeaders = {};
|
|
2952
|
+
const accountConfig = getConfigAccountIfExists3(authedPortalId);
|
|
2953
|
+
if (accountConfig && accountConfig.authType === "personalaccesskey") {
|
|
2954
|
+
const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
|
|
2955
|
+
authHeaders["Authorization"] = `Bearer ${accessToken}`;
|
|
2956
|
+
}
|
|
2957
|
+
const response = await fetch(signedUrl, {
|
|
2958
|
+
method: "GET",
|
|
2959
|
+
headers: { ...headers, ...authHeaders }
|
|
2960
|
+
});
|
|
2961
|
+
if (!response.ok) {
|
|
2962
|
+
throw new Error(
|
|
2963
|
+
`Preview GET failed: ${response.status} ${response.statusText}`
|
|
2964
|
+
);
|
|
2965
|
+
}
|
|
2966
|
+
return await response.text();
|
|
2967
|
+
}
|
|
2915
2968
|
var { JSDOM } = jsdom;
|
|
2916
|
-
async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
|
|
2969
|
+
async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
|
|
2917
2970
|
const moduleInfoQueryParams = new URLSearchParams({
|
|
2918
2971
|
portalId: `${authedPortalId}`
|
|
2919
2972
|
});
|
|
@@ -2928,8 +2981,6 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
|
|
|
2928
2981
|
"User-Agent": "HubSpot CMS Dev Server"
|
|
2929
2982
|
}
|
|
2930
2983
|
})).data;
|
|
2931
|
-
const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
2932
|
-
process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
|
|
2933
2984
|
const queryParams = new URLSearchParams({
|
|
2934
2985
|
portalId: `${authedPortalId}`,
|
|
2935
2986
|
hsLocalProxy: `${true}`,
|
|
@@ -2937,20 +2988,34 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
|
|
|
2937
2988
|
hsLoginVerifyDisabled: `${true}`,
|
|
2938
2989
|
module_id: moduleInfo.moduleId
|
|
2939
2990
|
});
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2991
|
+
const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
|
|
2992
|
+
const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
2993
|
+
const needsDomainOverride = !isUngatedFor(gates, URL_SIGNING_GATE);
|
|
2994
|
+
if (needsDomainOverride) {
|
|
2995
|
+
process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
|
|
2996
|
+
}
|
|
2997
|
+
let modulePreviewHtml;
|
|
2998
|
+
try {
|
|
2999
|
+
modulePreviewHtml = await signedGet(
|
|
3000
|
+
authedPortalId,
|
|
3001
|
+
cosRenderingUrl,
|
|
3002
|
+
{
|
|
3003
|
+
["content-type"]: "application/x-www-form-urlencoded",
|
|
3004
|
+
["Accept"]: "text/html",
|
|
3005
|
+
referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
|
|
3006
|
+
cookie: cookieValue,
|
|
3007
|
+
"User-Agent": "HubSpot CMS Dev Server"
|
|
3008
|
+
},
|
|
3009
|
+
gates
|
|
3010
|
+
);
|
|
3011
|
+
} finally {
|
|
3012
|
+
if (needsDomainOverride) {
|
|
3013
|
+
if (previousHubApiDomainOverride) {
|
|
3014
|
+
process.env.HUBAPI_DOMAIN_OVERRIDE = previousHubApiDomainOverride;
|
|
3015
|
+
} else {
|
|
3016
|
+
delete process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
3017
|
+
}
|
|
2948
3018
|
}
|
|
2949
|
-
})).data;
|
|
2950
|
-
if (currentHubApiDomainOverride) {
|
|
2951
|
-
process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
|
|
2952
|
-
} else {
|
|
2953
|
-
delete process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
2954
3019
|
}
|
|
2955
3020
|
const dom = new JSDOM(modulePreviewHtml);
|
|
2956
3021
|
const modulePreviewContent = dom.window.document.querySelector(
|
|
@@ -3193,7 +3258,8 @@ var partialRouteHandler = async (request, response) => {
|
|
|
3193
3258
|
remoteModule.path,
|
|
3194
3259
|
authedPortalId,
|
|
3195
3260
|
authedEnv,
|
|
3196
|
-
request.get("COOKIE")
|
|
3261
|
+
request.get("COOKIE"),
|
|
3262
|
+
jsRenderingGates
|
|
3197
3263
|
).then((result) => ({
|
|
3198
3264
|
remoteModule,
|
|
3199
3265
|
result
|
|
@@ -3727,18 +3793,18 @@ async function fetchPreviewTemplates(accountId, previewToken, limit = 250) {
|
|
|
3727
3793
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}&limit=${limit}`
|
|
3728
3794
|
})).data;
|
|
3729
3795
|
}
|
|
3730
|
-
async function fetchModuleByPath(accountId,
|
|
3796
|
+
async function fetchModuleByPath(accountId, path18) {
|
|
3731
3797
|
return (await hsCliHttp8.get(accountId, {
|
|
3732
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
3798
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path18}?portalId=${accountId}`
|
|
3733
3799
|
})).data;
|
|
3734
3800
|
}
|
|
3735
|
-
async function fetchTemplateByPath(accountId,
|
|
3801
|
+
async function fetchTemplateByPath(accountId, path18) {
|
|
3736
3802
|
return (await hsCliHttp8.get(accountId, {
|
|
3737
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
3803
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path18}?portalId=${accountId}`
|
|
3738
3804
|
})).data;
|
|
3739
3805
|
}
|
|
3740
|
-
async function fetchModulePageDependencies(accountId,
|
|
3741
|
-
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${
|
|
3806
|
+
async function fetchModulePageDependencies(accountId, path18) {
|
|
3807
|
+
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path18}`;
|
|
3742
3808
|
return (await hsCliHttp8.get(accountId, { url: url3 })).data;
|
|
3743
3809
|
}
|
|
3744
3810
|
|
|
@@ -4080,21 +4146,27 @@ ${e.stack}`);
|
|
|
4080
4146
|
var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
|
|
4081
4147
|
|
|
4082
4148
|
// src/routes/hublModuleRouteHandler.ts
|
|
4083
|
-
import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
|
|
4084
4149
|
var hublModuleRouteHandler = async (request, response) => {
|
|
4085
4150
|
sendTrackingRequest("view-hubl-module-route");
|
|
4086
|
-
const { authedPortalId, localPreviewToken } = request.app.locals;
|
|
4151
|
+
const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
|
|
4087
4152
|
const { modulePath } = request.params;
|
|
4088
4153
|
if (!modulePath) {
|
|
4089
4154
|
response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
|
|
4090
4155
|
return;
|
|
4091
4156
|
}
|
|
4092
|
-
const
|
|
4157
|
+
const projectPrefix = projectName ? "@projects/" : "";
|
|
4158
|
+
const calculatedPath = `@preview/${localPreviewToken}/${projectPrefix}${modulePath}.module`;
|
|
4093
4159
|
let customWidgetInfo;
|
|
4094
4160
|
try {
|
|
4095
4161
|
customWidgetInfo = await fetchModuleByPath(authedPortalId, calculatedPath);
|
|
4096
4162
|
} catch (err) {
|
|
4097
|
-
console.
|
|
4163
|
+
console.error(`Failed to fetch module data for ${calculatedPath}: ${err}`);
|
|
4164
|
+
response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(err));
|
|
4165
|
+
return;
|
|
4166
|
+
}
|
|
4167
|
+
if (!customWidgetInfo || !("moduleId" in customWidgetInfo)) {
|
|
4168
|
+
response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(null));
|
|
4169
|
+
return;
|
|
4098
4170
|
}
|
|
4099
4171
|
const params = {
|
|
4100
4172
|
module_id: customWidgetInfo.moduleId,
|
|
@@ -4102,13 +4174,9 @@ var hublModuleRouteHandler = async (request, response) => {
|
|
|
4102
4174
|
updated: Date.now(),
|
|
4103
4175
|
...request.query
|
|
4104
4176
|
};
|
|
4105
|
-
const previewUrl =
|
|
4177
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4106
4178
|
try {
|
|
4107
|
-
const result =
|
|
4108
|
-
baseURL: previewUrl.origin,
|
|
4109
|
-
url: previewUrl.pathname,
|
|
4110
|
-
params
|
|
4111
|
-
})).data;
|
|
4179
|
+
const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
|
|
4112
4180
|
const html = addRefreshScript(result);
|
|
4113
4181
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
4114
4182
|
} catch (err) {
|
|
@@ -4130,7 +4198,6 @@ var buildModuleIndex = () => buildHTMLResponse(`
|
|
|
4130
4198
|
`);
|
|
4131
4199
|
|
|
4132
4200
|
// src/routes/hublTemplateRouteHandler.ts
|
|
4133
|
-
import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
|
|
4134
4201
|
import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
|
|
4135
4202
|
import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
|
|
4136
4203
|
var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
|
|
@@ -4181,14 +4248,15 @@ var templateRouteHandler = async (request, response) => {
|
|
|
4181
4248
|
hsCacheBuster: Date.now().toString(),
|
|
4182
4249
|
...request.query
|
|
4183
4250
|
};
|
|
4184
|
-
const previewUrl =
|
|
4251
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4185
4252
|
const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
|
|
4186
4253
|
try {
|
|
4187
|
-
const result =
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4254
|
+
const result = await signedGet(
|
|
4255
|
+
authedPortalId,
|
|
4256
|
+
previewUrl,
|
|
4257
|
+
{},
|
|
4258
|
+
jsRenderingGates
|
|
4259
|
+
);
|
|
4192
4260
|
const pageHtml = addRefreshScript(result);
|
|
4193
4261
|
const finalHtml = pageHtml.replace(
|
|
4194
4262
|
HUBSPOT_PREVIEW_BASE_TAG_REGEX,
|
|
@@ -4207,6 +4275,7 @@ var templateRouteHandler = async (request, response) => {
|
|
|
4207
4275
|
false
|
|
4208
4276
|
);
|
|
4209
4277
|
} catch (err) {
|
|
4278
|
+
console.error("Template route error:", err);
|
|
4210
4279
|
response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
|
|
4211
4280
|
}
|
|
4212
4281
|
};
|
|
@@ -4241,15 +4310,15 @@ function getOpenCommand() {
|
|
|
4241
4310
|
}
|
|
4242
4311
|
}
|
|
4243
4312
|
async function handleGetModulePages(req, res, next) {
|
|
4244
|
-
const { path:
|
|
4245
|
-
if (!
|
|
4313
|
+
const { path: path18, portalId } = req.query;
|
|
4314
|
+
if (!path18 || !portalId) {
|
|
4246
4315
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4247
4316
|
}
|
|
4248
4317
|
try {
|
|
4249
4318
|
sendTrackingRequest("handle-module-dependencies");
|
|
4250
4319
|
const data = await fetchModulePageDependencies(
|
|
4251
4320
|
Number(portalId),
|
|
4252
|
-
|
|
4321
|
+
path18
|
|
4253
4322
|
);
|
|
4254
4323
|
res.json(data);
|
|
4255
4324
|
} catch (err) {
|
|
@@ -4257,14 +4326,14 @@ async function handleGetModulePages(req, res, next) {
|
|
|
4257
4326
|
}
|
|
4258
4327
|
}
|
|
4259
4328
|
function handleOpenFile(req, res, next) {
|
|
4260
|
-
const { path:
|
|
4261
|
-
if (!
|
|
4329
|
+
const { path: path18 } = req.query;
|
|
4330
|
+
if (!path18) {
|
|
4262
4331
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4263
4332
|
}
|
|
4264
4333
|
try {
|
|
4265
4334
|
sendTrackingRequest("handle-open-file");
|
|
4266
4335
|
const command = getOpenCommand();
|
|
4267
|
-
spawn(command, [
|
|
4336
|
+
spawn(command, [path18], { detached: true }).unref();
|
|
4268
4337
|
res.sendStatus(200);
|
|
4269
4338
|
} catch (err) {
|
|
4270
4339
|
next(err);
|
|
@@ -4288,10 +4357,10 @@ import path11 from "path";
|
|
|
4288
4357
|
import { normalizePath as normalizePath9 } from "vite";
|
|
4289
4358
|
|
|
4290
4359
|
// src/api/project.ts
|
|
4291
|
-
import { http as
|
|
4360
|
+
import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
|
|
4292
4361
|
var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
|
|
4293
4362
|
async function fetchProjectByName(accountId, projectName) {
|
|
4294
|
-
return (await
|
|
4363
|
+
return (await hsCliHttp9.get(accountId, {
|
|
4295
4364
|
url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
|
|
4296
4365
|
})).data;
|
|
4297
4366
|
}
|
|
@@ -4785,6 +4854,47 @@ async function getJsRenderingGates(portalId, env2, personalAccessKey) {
|
|
|
4785
4854
|
return mergedGates;
|
|
4786
4855
|
}
|
|
4787
4856
|
|
|
4857
|
+
// src/lib/hsmetaUtils.ts
|
|
4858
|
+
import path14 from "path";
|
|
4859
|
+
import fs5 from "fs";
|
|
4860
|
+
var HSMETA_FILENAMES = [
|
|
4861
|
+
"theme-hsmeta.json",
|
|
4862
|
+
"cms-assets-hsmeta.json"
|
|
4863
|
+
];
|
|
4864
|
+
function getSubdirectories(dirPath) {
|
|
4865
|
+
try {
|
|
4866
|
+
return fs5.readdirSync(dirPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
4867
|
+
} catch {
|
|
4868
|
+
return [];
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
function hsmetaCandidatePaths(srcPath) {
|
|
4872
|
+
const subdirs = getSubdirectories(srcPath);
|
|
4873
|
+
return subdirs.flatMap(
|
|
4874
|
+
(subdir) => HSMETA_FILENAMES.map((filename) => path14.join(srcPath, subdir, filename))
|
|
4875
|
+
);
|
|
4876
|
+
}
|
|
4877
|
+
function tryParseUid(hsmetaPath) {
|
|
4878
|
+
try {
|
|
4879
|
+
const hsmeta = JSON.parse(fs5.readFileSync(hsmetaPath, "utf8"));
|
|
4880
|
+
return hsmeta.uid ?? null;
|
|
4881
|
+
} catch (parseErr) {
|
|
4882
|
+
console.warn(`Could not parse ${hsmetaPath}:`, parseErr.message);
|
|
4883
|
+
return null;
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
function findHsmetaUid(projectDir, srcDir) {
|
|
4887
|
+
const srcPath = path14.join(projectDir, srcDir);
|
|
4888
|
+
for (const candidatePath of hsmetaCandidatePaths(srcPath)) {
|
|
4889
|
+
if (!fs5.existsSync(candidatePath))
|
|
4890
|
+
continue;
|
|
4891
|
+
const uid = tryParseUid(candidatePath);
|
|
4892
|
+
if (uid)
|
|
4893
|
+
return uid;
|
|
4894
|
+
}
|
|
4895
|
+
return null;
|
|
4896
|
+
}
|
|
4897
|
+
|
|
4788
4898
|
// src/lib/cliUtils.ts
|
|
4789
4899
|
import process2 from "process";
|
|
4790
4900
|
import os from "os";
|
|
@@ -4909,7 +5019,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
|
|
|
4909
5019
|
import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
|
|
4910
5020
|
|
|
4911
5021
|
// src/proxyPage/fetchDomains.ts
|
|
4912
|
-
import { http as
|
|
5022
|
+
import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
|
|
4913
5023
|
|
|
4914
5024
|
// src/lib/errors.ts
|
|
4915
5025
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -4967,7 +5077,7 @@ function handleSecretsError(error) {
|
|
|
4967
5077
|
// src/proxyPage/fetchDomains.ts
|
|
4968
5078
|
async function fetchDomains(portalId) {
|
|
4969
5079
|
try {
|
|
4970
|
-
const result = (await
|
|
5080
|
+
const result = (await hsCliHttp10.get(portalId, {
|
|
4971
5081
|
url: `/cms/v3/domains`,
|
|
4972
5082
|
params: { portalId },
|
|
4973
5083
|
responseType: "json"
|
|
@@ -4990,24 +5100,24 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
4990
5100
|
}
|
|
4991
5101
|
|
|
4992
5102
|
// src/lib/validateHSPlatform.ts
|
|
4993
|
-
import
|
|
4994
|
-
import
|
|
5103
|
+
import path15 from "path";
|
|
5104
|
+
import fs6 from "fs";
|
|
4995
5105
|
import select from "@inquirer/select";
|
|
4996
|
-
import { http as
|
|
5106
|
+
import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
|
|
4997
5107
|
var HSPROJECT_JSON = "hsproject.json";
|
|
4998
5108
|
function checkFileExists(filePath) {
|
|
4999
|
-
return
|
|
5109
|
+
return fs6.existsSync(filePath) && fs6.statSync(filePath).isFile();
|
|
5000
5110
|
}
|
|
5001
5111
|
function findHSProjectJson(startPath) {
|
|
5002
5112
|
let currentDir = startPath;
|
|
5003
5113
|
let dirLevel = 0;
|
|
5004
5114
|
const maxDirLevel = 4;
|
|
5005
|
-
while (
|
|
5006
|
-
const filePath =
|
|
5115
|
+
while (path15.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
5116
|
+
const filePath = path15.join(currentDir, HSPROJECT_JSON);
|
|
5007
5117
|
if (checkFileExists(filePath)) {
|
|
5008
5118
|
return filePath;
|
|
5009
5119
|
}
|
|
5010
|
-
currentDir =
|
|
5120
|
+
currentDir = path15.dirname(currentDir);
|
|
5011
5121
|
dirLevel++;
|
|
5012
5122
|
}
|
|
5013
5123
|
console.log(
|
|
@@ -5022,12 +5132,12 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5022
5132
|
);
|
|
5023
5133
|
return false;
|
|
5024
5134
|
}
|
|
5025
|
-
const hsProjectJSONContents =
|
|
5135
|
+
const hsProjectJSONContents = fs6.readFileSync(projectConfigPath, "utf8");
|
|
5026
5136
|
const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
|
|
5027
5137
|
const { platformVersion } = hsProjectJSONData;
|
|
5028
5138
|
let platformVersionResult;
|
|
5029
5139
|
try {
|
|
5030
|
-
platformVersionResult = (await
|
|
5140
|
+
platformVersionResult = (await hsCliHttp11.get(portalId, {
|
|
5031
5141
|
url: `developer/projects/v1/platformVersion`,
|
|
5032
5142
|
responseType: "json"
|
|
5033
5143
|
})).data;
|
|
@@ -5050,7 +5160,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5050
5160
|
});
|
|
5051
5161
|
hsProjectJSONData.platformVersion = answer;
|
|
5052
5162
|
try {
|
|
5053
|
-
|
|
5163
|
+
fs6.writeFileSync(
|
|
5054
5164
|
projectConfigPath,
|
|
5055
5165
|
JSON.stringify(hsProjectJSONData, void 0, 2),
|
|
5056
5166
|
"utf8"
|
|
@@ -5067,7 +5177,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5067
5177
|
}
|
|
5068
5178
|
|
|
5069
5179
|
// src/createDevServer.ts
|
|
5070
|
-
import { http as
|
|
5180
|
+
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
5071
5181
|
|
|
5072
5182
|
// ../cms-js-internal/dist/buildFieldsTypes.js
|
|
5073
5183
|
import { writeFileSync } from "fs";
|
|
@@ -5312,8 +5422,8 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5312
5422
|
}
|
|
5313
5423
|
|
|
5314
5424
|
// src/lib/watchFieldsUpdates.ts
|
|
5315
|
-
import
|
|
5316
|
-
import
|
|
5425
|
+
import fs7 from "fs";
|
|
5426
|
+
import path16 from "path";
|
|
5317
5427
|
import readline from "readline";
|
|
5318
5428
|
var lastSerializedFieldsCache = {};
|
|
5319
5429
|
var formatAsTypeName = (str) => {
|
|
@@ -5323,20 +5433,20 @@ var formatAsTypeName = (str) => {
|
|
|
5323
5433
|
};
|
|
5324
5434
|
var isInModulesFolder = (filePath, projectRoot) => {
|
|
5325
5435
|
const getEntryPathFromId = (id) => {
|
|
5326
|
-
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}${
|
|
5436
|
+
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}${path16.sep}`, "") : "";
|
|
5327
5437
|
};
|
|
5328
|
-
const currentModuleId =
|
|
5438
|
+
const currentModuleId = path16.normalize(filePath);
|
|
5329
5439
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
5330
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
5440
|
+
const subFolderTokens = moduleEntryPath.split(path16.sep);
|
|
5331
5441
|
return {
|
|
5332
5442
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
5333
5443
|
isRootModuleFile: subFolderTokens.length === 3
|
|
5334
5444
|
};
|
|
5335
5445
|
};
|
|
5336
5446
|
var fileContainsAutoGenComment = async (filePath) => {
|
|
5337
|
-
if (!
|
|
5447
|
+
if (!fs7.existsSync(filePath))
|
|
5338
5448
|
return true;
|
|
5339
|
-
const stream2 =
|
|
5449
|
+
const stream2 = fs7.createReadStream(filePath);
|
|
5340
5450
|
const reader = readline.createInterface({ input: stream2 });
|
|
5341
5451
|
const firstLine = await new Promise(
|
|
5342
5452
|
(resolve2) => reader.once("line", (line) => resolve2(line.trim()))
|
|
@@ -5354,10 +5464,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5354
5464
|
return void 0;
|
|
5355
5465
|
if (isRootModuleFile)
|
|
5356
5466
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5357
|
-
const dir =
|
|
5358
|
-
const files =
|
|
5467
|
+
const dir = path16.dirname(filePath);
|
|
5468
|
+
const files = fs7.readdirSync(dir);
|
|
5359
5469
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5360
|
-
return indexFileName ? { indexFilePath:
|
|
5470
|
+
return indexFileName ? { indexFilePath: path16.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5361
5471
|
};
|
|
5362
5472
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
5363
5473
|
let indexFile;
|
|
@@ -5381,7 +5491,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5381
5491
|
if (!indexInfo)
|
|
5382
5492
|
return;
|
|
5383
5493
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
5384
|
-
const indexFileName =
|
|
5494
|
+
const indexFileName = path16.parse(indexFilePath).name;
|
|
5385
5495
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
5386
5496
|
if (isTypeFile)
|
|
5387
5497
|
return;
|
|
@@ -5392,7 +5502,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5392
5502
|
);
|
|
5393
5503
|
if (fields) {
|
|
5394
5504
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
5395
|
-
const typeFilePath =
|
|
5505
|
+
const typeFilePath = path16.join(path16.dirname(filePath), typeFileName);
|
|
5396
5506
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
5397
5507
|
const serializedFields = JSON.stringify(fields);
|
|
5398
5508
|
if (lastSerializedFields === serializedFields)
|
|
@@ -5400,7 +5510,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5400
5510
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
5401
5511
|
if (!hasAutoGenComment)
|
|
5402
5512
|
return;
|
|
5403
|
-
const moduleFolderName =
|
|
5513
|
+
const moduleFolderName = path16.basename(path16.dirname(filePath));
|
|
5404
5514
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
5405
5515
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
5406
5516
|
if (didSucceed) {
|
|
@@ -5416,7 +5526,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5416
5526
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
5417
5527
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
5418
5528
|
moduleSubpaths.forEach((modulePath) => {
|
|
5419
|
-
const resolvedPath =
|
|
5529
|
+
const resolvedPath = path16.resolve(projectRoot, modulePath);
|
|
5420
5530
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
5421
5531
|
});
|
|
5422
5532
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -5447,27 +5557,13 @@ function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
|
|
|
5447
5557
|
return themeFolderName;
|
|
5448
5558
|
}
|
|
5449
5559
|
try {
|
|
5450
|
-
const projectDir =
|
|
5451
|
-
const configContent =
|
|
5560
|
+
const projectDir = path17.dirname(projectConfigPath);
|
|
5561
|
+
const configContent = fs8.readFileSync(projectConfigPath, "utf8");
|
|
5452
5562
|
const projectConfig = JSON.parse(configContent);
|
|
5453
|
-
|
|
5454
|
-
projectConfig.platformVersion
|
|
5455
|
-
);
|
|
5456
|
-
if (isNewStructure) {
|
|
5563
|
+
if (hasNewDirectoryStructure(projectConfig.platformVersion)) {
|
|
5457
5564
|
const srcDir = projectConfig.srcDir || "src";
|
|
5458
|
-
const
|
|
5459
|
-
|
|
5460
|
-
srcDir,
|
|
5461
|
-
"theme",
|
|
5462
|
-
"theme-hsmeta.json"
|
|
5463
|
-
);
|
|
5464
|
-
if (fs7.existsSync(hsmetaPath)) {
|
|
5465
|
-
const hsmetaContent = fs7.readFileSync(hsmetaPath, "utf8");
|
|
5466
|
-
const hsmeta = JSON.parse(hsmetaContent);
|
|
5467
|
-
if (hsmeta.uid) {
|
|
5468
|
-
return hsmeta.uid;
|
|
5469
|
-
}
|
|
5470
|
-
}
|
|
5565
|
+
const uid = findHsmetaUid(projectDir, srcDir);
|
|
5566
|
+
return uid ?? projectConfig.name;
|
|
5471
5567
|
}
|
|
5472
5568
|
} catch (e) {
|
|
5473
5569
|
console.warn(
|
|
@@ -5500,7 +5596,7 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
|
|
|
5500
5596
|
`Loading HS auth (account = ${hubspotCliAccountNameOption}) configuration.`
|
|
5501
5597
|
);
|
|
5502
5598
|
}
|
|
5503
|
-
const cmsAssetConfig =
|
|
5599
|
+
const cmsAssetConfig = getCMSAssetConfigIfExists(webRoot);
|
|
5504
5600
|
secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
|
|
5505
5601
|
const { isValid } = validateConfig();
|
|
5506
5602
|
if (isValid) {
|
|
@@ -5588,14 +5684,14 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5588
5684
|
}
|
|
5589
5685
|
let authedHublet;
|
|
5590
5686
|
try {
|
|
5591
|
-
const accountInformation = (await
|
|
5687
|
+
const accountInformation = (await hsCliHttp12.get(authedPortalId, {
|
|
5592
5688
|
url: "/account-info/v3/details"
|
|
5593
5689
|
})).data;
|
|
5594
5690
|
authedHublet = accountInformation.dataHostingLocation;
|
|
5595
5691
|
} catch (e) {
|
|
5596
5692
|
authedHublet = "na1";
|
|
5597
5693
|
}
|
|
5598
|
-
const absoluteWebRoot = normalizePath10(
|
|
5694
|
+
const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot));
|
|
5599
5695
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
5600
5696
|
const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
|
|
5601
5697
|
absoluteWebRoot,
|
|
@@ -5624,7 +5720,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5624
5720
|
secretNames
|
|
5625
5721
|
);
|
|
5626
5722
|
if (fieldGenEnabledOption) {
|
|
5627
|
-
const normalizedAbsoluteWebRoot =
|
|
5723
|
+
const normalizedAbsoluteWebRoot = path17.normalize(absoluteWebRoot);
|
|
5628
5724
|
startFieldsTypeGenWatcher(viteServer, normalizedAbsoluteWebRoot);
|
|
5629
5725
|
}
|
|
5630
5726
|
const viteHTTPSConfig = viteServer.config.server.https;
|
|
@@ -5649,10 +5745,10 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5649
5745
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5650
5746
|
expressServer.locals.sslEnabled = sslEnabledOption;
|
|
5651
5747
|
expressServer.use(bodyParser.json());
|
|
5652
|
-
const __dirname =
|
|
5653
|
-
let appWebRoot = normalizePath10(
|
|
5748
|
+
const __dirname = path17.dirname(url2.fileURLToPath(new URL(import.meta.url)));
|
|
5749
|
+
let appWebRoot = normalizePath10(path17.resolve(__dirname, "../app"));
|
|
5654
5750
|
if (true) {
|
|
5655
|
-
appWebRoot =
|
|
5751
|
+
appWebRoot = path17.join(__dirname, "app");
|
|
5656
5752
|
}
|
|
5657
5753
|
const appViteServer = await createAppServer_default(
|
|
5658
5754
|
appWebRoot,
|
|
@@ -5722,17 +5818,17 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
5722
5818
|
`;
|
|
5723
5819
|
console.log(startMessage);
|
|
5724
5820
|
if (storybook) {
|
|
5725
|
-
const packageRoot =
|
|
5726
|
-
const configPath =
|
|
5821
|
+
const packageRoot = path17.dirname(url2.fileURLToPath(import.meta.url));
|
|
5822
|
+
const configPath = path17.resolve(packageRoot, "./storybook-main");
|
|
5727
5823
|
sendTrackingRequest("start-storybook");
|
|
5728
5824
|
let storybookBin;
|
|
5729
5825
|
try {
|
|
5730
5826
|
const sbPackagePath = await import.meta.resolve("storybook/package.json");
|
|
5731
|
-
const sbPackageDir =
|
|
5827
|
+
const sbPackageDir = path17.dirname(url2.fileURLToPath(sbPackagePath));
|
|
5732
5828
|
const packageJson = JSON.parse(
|
|
5733
|
-
|
|
5829
|
+
fs8.readFileSync(path17.join(sbPackageDir, "package.json"), "utf-8")
|
|
5734
5830
|
);
|
|
5735
|
-
storybookBin =
|
|
5831
|
+
storybookBin = path17.join(
|
|
5736
5832
|
sbPackageDir,
|
|
5737
5833
|
packageJson.bin.storybook || packageJson.bin
|
|
5738
5834
|
);
|
|
@@ -5769,7 +5865,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
5769
5865
|
portalId: authedPortalId.toString(),
|
|
5770
5866
|
hsEnv: authedEnv,
|
|
5771
5867
|
hublet: authedHublet,
|
|
5772
|
-
WEB_ROOT:
|
|
5868
|
+
WEB_ROOT: path17.join(webRoot, "components")
|
|
5773
5869
|
},
|
|
5774
5870
|
stdio: "inherit"
|
|
5775
5871
|
}
|