@hubspot/cms-dev-server 0.18.8 → 0.18.10
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 +116 -114
- package/dist/run.js +118 -116
- package/package.json +6 -4
- package/types/createAppServer.d.ts +2 -1
- package/types/lib/getDevServerUIData.d.ts +21 -0
- package/types/transformJsxToJson.d.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -307,7 +307,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
307
307
|
hydrateOn,
|
|
308
308
|
clientOnly,
|
|
309
309
|
priority,
|
|
310
|
-
url:
|
|
310
|
+
url: url3,
|
|
311
311
|
sharedStateID,
|
|
312
312
|
supplementalFieldValues,
|
|
313
313
|
wrapperModuleId,
|
|
@@ -321,7 +321,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
321
321
|
clientOnly,
|
|
322
322
|
priority,
|
|
323
323
|
props,
|
|
324
|
-
url:
|
|
324
|
+
url: url3
|
|
325
325
|
};
|
|
326
326
|
if (sharedStateID) {
|
|
327
327
|
output.sharedStateID = sharedStateID;
|
|
@@ -578,8 +578,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
578
578
|
);
|
|
579
579
|
return Object.fromEntries(relativeEntries);
|
|
580
580
|
}
|
|
581
|
-
function toRelativePath(config,
|
|
582
|
-
return
|
|
581
|
+
function toRelativePath(config, path13) {
|
|
582
|
+
return path13.replace(config.root, "");
|
|
583
583
|
}
|
|
584
584
|
function shouldSkipModule(config, moduleInfo, code) {
|
|
585
585
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
@@ -617,11 +617,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
617
617
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
618
618
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
619
619
|
traverse(sourceAst, {
|
|
620
|
-
ImportDeclaration(
|
|
621
|
-
if (t.isStringLiteral(
|
|
620
|
+
ImportDeclaration(path13) {
|
|
621
|
+
if (t.isStringLiteral(path13.node.source, {
|
|
622
622
|
value: "@hubspot/cms-components"
|
|
623
623
|
})) {
|
|
624
|
-
for (const specifier of
|
|
624
|
+
for (const specifier of path13.node.specifiers) {
|
|
625
625
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
626
626
|
name: CMS_MODULE_COMPONENT_NAME
|
|
627
627
|
})) {
|
|
@@ -635,14 +635,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
},
|
|
638
|
-
JSXOpeningElement(
|
|
639
|
-
if (t.isJSXIdentifier(
|
|
638
|
+
JSXOpeningElement(path13) {
|
|
639
|
+
if (t.isJSXIdentifier(path13.node.name, {
|
|
640
640
|
name: moduleComponentLocalImportName
|
|
641
641
|
})) {
|
|
642
642
|
let cmsModuleName;
|
|
643
643
|
let cmsModulePath;
|
|
644
644
|
let cmsModuleLabel;
|
|
645
|
-
for (const prop of
|
|
645
|
+
for (const prop of path13.node.attributes) {
|
|
646
646
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
647
647
|
cmsModuleName = prop.value.value;
|
|
648
648
|
continue;
|
|
@@ -677,11 +677,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
677
677
|
}
|
|
678
678
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
679
679
|
}
|
|
680
|
-
if (t.isJSXIdentifier(
|
|
680
|
+
if (t.isJSXIdentifier(path13.node.name, {
|
|
681
681
|
name: dndAreaComponentLocalImportName
|
|
682
682
|
})) {
|
|
683
683
|
let dndAreaName;
|
|
684
|
-
for (const prop of
|
|
684
|
+
for (const prop of path13.node.attributes) {
|
|
685
685
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
686
686
|
dndAreaName = prop.value.value;
|
|
687
687
|
continue;
|
|
@@ -1023,8 +1023,8 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1023
1023
|
var createViteDevServer_default = createViteDevServer;
|
|
1024
1024
|
|
|
1025
1025
|
// src/createDevServer.ts
|
|
1026
|
-
import
|
|
1027
|
-
import
|
|
1026
|
+
import path12 from "path";
|
|
1027
|
+
import url2 from "url";
|
|
1028
1028
|
import express3 from "express";
|
|
1029
1029
|
import http3 from "http";
|
|
1030
1030
|
import bodyParser from "body-parser";
|
|
@@ -1319,9 +1319,9 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
1319
1319
|
);
|
|
1320
1320
|
return htmlTemplate;
|
|
1321
1321
|
};
|
|
1322
|
-
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath,
|
|
1322
|
+
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, jsRenderingGates) => {
|
|
1323
1323
|
let htmlTemplate;
|
|
1324
|
-
const prettyPrint = isDebugUrlString2(
|
|
1324
|
+
const prettyPrint = isDebugUrlString2(url3);
|
|
1325
1325
|
const serverMessages = criticalDevErrorsToServerMessages_default(
|
|
1326
1326
|
renderContext.criticalDevErrors
|
|
1327
1327
|
);
|
|
@@ -1371,7 +1371,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, tit
|
|
|
1371
1371
|
`${globalScriptBlock}${serverLogScript}`
|
|
1372
1372
|
);
|
|
1373
1373
|
}
|
|
1374
|
-
return viteServer.transformIndexHtml(
|
|
1374
|
+
return viteServer.transformIndexHtml(url3, htmlTemplate);
|
|
1375
1375
|
};
|
|
1376
1376
|
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, gates, prettyPrint) => {
|
|
1377
1377
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
@@ -1449,12 +1449,12 @@ function trackUsage(action) {
|
|
|
1449
1449
|
eventName: EVENT_NAME,
|
|
1450
1450
|
action,
|
|
1451
1451
|
nodeVersion: getNodeVersionData(),
|
|
1452
|
-
version: "0.18.
|
|
1452
|
+
version: "0.18.10",
|
|
1453
1453
|
os: getPlatform()
|
|
1454
1454
|
};
|
|
1455
|
-
const
|
|
1455
|
+
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
1456
1456
|
const baseRequestOptions = {
|
|
1457
|
-
url:
|
|
1457
|
+
url: url3,
|
|
1458
1458
|
data: usageEvent
|
|
1459
1459
|
};
|
|
1460
1460
|
if (isAuthedWithPersonalAccessKey) {
|
|
@@ -1522,12 +1522,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1522
1522
|
);
|
|
1523
1523
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1524
1524
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1525
|
-
const
|
|
1525
|
+
const path13 = body.substring(
|
|
1526
1526
|
startOffset + localJsRenderStartString.length,
|
|
1527
1527
|
pathEndOffset
|
|
1528
1528
|
);
|
|
1529
1529
|
offsetSoFar = pathEndOffset + 1;
|
|
1530
|
-
if (startOffset >= 0 &&
|
|
1530
|
+
if (startOffset >= 0 && path13) {
|
|
1531
1531
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1532
1532
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1533
1533
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1552,7 +1552,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1552
1552
|
result.push({
|
|
1553
1553
|
startOffset,
|
|
1554
1554
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1555
|
-
path:
|
|
1555
|
+
path: path13,
|
|
1556
1556
|
json
|
|
1557
1557
|
});
|
|
1558
1558
|
}
|
|
@@ -1929,9 +1929,9 @@ var customColors = [
|
|
|
1929
1929
|
];
|
|
1930
1930
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1931
1931
|
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;`;
|
|
1932
|
-
var renderLocalError_default = (
|
|
1932
|
+
var renderLocalError_default = (path13, error) => {
|
|
1933
1933
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1934
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1934
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path13}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1935
1935
|
};
|
|
1936
1936
|
|
|
1937
1937
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2340,17 +2340,17 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
|
|
|
2340
2340
|
return placeholderPath;
|
|
2341
2341
|
}
|
|
2342
2342
|
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates, cookieHeader, localPreviewToken) => {
|
|
2343
|
-
const
|
|
2344
|
-
const renderPreviewLocally =
|
|
2343
|
+
const url3 = new URL(urlToProxy);
|
|
2344
|
+
const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
|
|
2345
2345
|
let proxiedQueryParams = {};
|
|
2346
|
-
let baseURL =
|
|
2347
|
-
let pathname =
|
|
2346
|
+
let baseURL = url3.origin;
|
|
2347
|
+
let pathname = url3.pathname;
|
|
2348
2348
|
const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
|
|
2349
|
-
const queryKeys = Array.from(
|
|
2349
|
+
const queryKeys = Array.from(url3.searchParams.keys()).filter(
|
|
2350
2350
|
(queryKey) => !PARAMS_TO_IGNORE.includes(queryKey)
|
|
2351
2351
|
);
|
|
2352
2352
|
for (const queryKey of queryKeys) {
|
|
2353
|
-
const values =
|
|
2353
|
+
const values = url3.searchParams.getAll(queryKey);
|
|
2354
2354
|
if (values.length > 1) {
|
|
2355
2355
|
proxiedQueryParams[queryKey] = values;
|
|
2356
2356
|
} else {
|
|
@@ -2366,9 +2366,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
2366
2366
|
hsLoginVerifyDisabled: `${true}`
|
|
2367
2367
|
};
|
|
2368
2368
|
if (renderPreviewLocally) {
|
|
2369
|
-
proxiedQueryParams.hsDebugOverridePublicHost =
|
|
2369
|
+
proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
|
|
2370
2370
|
baseURL = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
|
|
2371
|
-
pathname = `/cos-rendering/v1/public${
|
|
2371
|
+
pathname = `/cos-rendering/v1/public${url3.pathname}`;
|
|
2372
2372
|
}
|
|
2373
2373
|
if (localPreviewToken) {
|
|
2374
2374
|
proxiedQueryParams = {
|
|
@@ -3196,16 +3196,16 @@ var module_default = moduleRouteHandler;
|
|
|
3196
3196
|
import http from "http";
|
|
3197
3197
|
import https from "https";
|
|
3198
3198
|
import { getAccountId as getAccountId2 } from "@hubspot/local-dev-lib/config";
|
|
3199
|
-
async function requestPage(
|
|
3199
|
+
async function requestPage(url3, redirects = 0, originalUrl) {
|
|
3200
3200
|
if (redirects > 5) {
|
|
3201
3201
|
throw new Error(
|
|
3202
3202
|
`Hit too many redirects to HEAD requests for ${originalUrl}`
|
|
3203
3203
|
);
|
|
3204
3204
|
}
|
|
3205
3205
|
return new Promise((resolve2, reject) => {
|
|
3206
|
-
const protocolAPI =
|
|
3206
|
+
const protocolAPI = url3.startsWith("https://") ? https : http;
|
|
3207
3207
|
protocolAPI.request(
|
|
3208
|
-
|
|
3208
|
+
url3,
|
|
3209
3209
|
{
|
|
3210
3210
|
method: "HEAD",
|
|
3211
3211
|
headers: {
|
|
@@ -3232,12 +3232,12 @@ async function requestPage(url4, redirects = 0, originalUrl) {
|
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
3234
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
3235
|
-
console.log(`Redirecting to ${res.headers.location} (from ${
|
|
3235
|
+
console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
|
|
3236
3236
|
return resolve2(
|
|
3237
3237
|
requestPage(
|
|
3238
3238
|
res.headers.location,
|
|
3239
3239
|
redirects + 1,
|
|
3240
|
-
originalUrl ??
|
|
3240
|
+
originalUrl ?? url3
|
|
3241
3241
|
)
|
|
3242
3242
|
);
|
|
3243
3243
|
}
|
|
@@ -3255,11 +3255,11 @@ async function requestPage(url4, redirects = 0, originalUrl) {
|
|
|
3255
3255
|
}).end();
|
|
3256
3256
|
});
|
|
3257
3257
|
}
|
|
3258
|
-
async function fetchContentMetadata(
|
|
3259
|
-
const { portalIdHeader, contentId, res } = await requestPage(
|
|
3258
|
+
async function fetchContentMetadata(url3, portalId) {
|
|
3259
|
+
const { portalIdHeader, contentId, res } = await requestPage(url3);
|
|
3260
3260
|
if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
|
|
3261
3261
|
throw new Error(
|
|
3262
|
-
`There were multiple hub ID or content ID headers in the HEAD request to ${
|
|
3262
|
+
`There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
|
|
3263
3263
|
);
|
|
3264
3264
|
} else {
|
|
3265
3265
|
const portalIdFromResponse = parseInt(portalIdHeader, 10);
|
|
@@ -3271,15 +3271,15 @@ async function fetchContentMetadata(url4, portalId) {
|
|
|
3271
3271
|
}
|
|
3272
3272
|
if (res.statusCode !== 200 && !(portalIdFromResponse && pageAccount && contentId)) {
|
|
3273
3273
|
throw new Error(
|
|
3274
|
-
`${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${
|
|
3274
|
+
`${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url3}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
|
|
3275
3275
|
);
|
|
3276
3276
|
} else if (!portalId || !contentId) {
|
|
3277
3277
|
throw new Error(
|
|
3278
|
-
`Missing hub ID or content ID headers on HEAD request to ${
|
|
3278
|
+
`Missing hub ID or content ID headers on HEAD request to ${url3}`
|
|
3279
3279
|
);
|
|
3280
3280
|
} else if (isNaN(portalId)) {
|
|
3281
3281
|
throw new Error(
|
|
3282
|
-
`Hub ID from the HEAD request is not a number: '${portalId}' (${
|
|
3282
|
+
`Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
|
|
3283
3283
|
);
|
|
3284
3284
|
}
|
|
3285
3285
|
const hublet = "na1";
|
|
@@ -3405,14 +3405,14 @@ async function fetchPreviewTemplates(accountId, previewToken) {
|
|
|
3405
3405
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
|
|
3406
3406
|
})).data;
|
|
3407
3407
|
}
|
|
3408
|
-
async function fetchModuleByPath(accountId,
|
|
3408
|
+
async function fetchModuleByPath(accountId, path13) {
|
|
3409
3409
|
return (await hsCliHttp8.get(accountId, {
|
|
3410
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
3410
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path13}?portalId=${accountId}`
|
|
3411
3411
|
})).data;
|
|
3412
3412
|
}
|
|
3413
|
-
async function fetchTemplateByPath(accountId,
|
|
3413
|
+
async function fetchTemplateByPath(accountId, path13) {
|
|
3414
3414
|
return (await hsCliHttp8.get(accountId, {
|
|
3415
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
3415
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path13}?portalId=${accountId}`
|
|
3416
3416
|
})).data;
|
|
3417
3417
|
}
|
|
3418
3418
|
|
|
@@ -3869,8 +3869,8 @@ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
|
|
|
3869
3869
|
var createDevServerRoutes = async (viteServer, storybookPort) => {
|
|
3870
3870
|
const devServerApp = Router();
|
|
3871
3871
|
devServerApp.use((request2, response, next) => {
|
|
3872
|
-
const { method, url:
|
|
3873
|
-
debug(`${method}:${hostname}${
|
|
3872
|
+
const { method, url: url3, hostname } = request2;
|
|
3873
|
+
debug(`${method}:${hostname}${url3}`);
|
|
3874
3874
|
next();
|
|
3875
3875
|
});
|
|
3876
3876
|
if (storybookPort) {
|
|
@@ -3919,9 +3919,6 @@ import express from "express";
|
|
|
3919
3919
|
import { Router as Router2 } from "express";
|
|
3920
3920
|
import { getAccountId as getAccountId3, getEnv as getEnv3 } from "@hubspot/local-dev-lib/config";
|
|
3921
3921
|
import cors from "cors";
|
|
3922
|
-
import { exec } from "child_process";
|
|
3923
|
-
import path10 from "path";
|
|
3924
|
-
import url2 from "url";
|
|
3925
3922
|
import { buildStaticEnvConfig as buildStaticEnvConfig6 } from "@hubspot/cms-components";
|
|
3926
3923
|
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
3927
3924
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
@@ -3997,40 +3994,6 @@ ${error.stack}`
|
|
|
3997
3994
|
}
|
|
3998
3995
|
};
|
|
3999
3996
|
}
|
|
4000
|
-
function getRunTestsHandler() {
|
|
4001
|
-
return async function runTestsHandler(request2, response) {
|
|
4002
|
-
const cmsDevServerPath = path10.join(
|
|
4003
|
-
path10.dirname(url2.fileURLToPath(import.meta.url)),
|
|
4004
|
-
"../.."
|
|
4005
|
-
);
|
|
4006
|
-
exec("npm run test", { cwd: cmsDevServerPath }, (error, stdout, stderr) => {
|
|
4007
|
-
if (error) {
|
|
4008
|
-
response.status(500).json({ error: stderr });
|
|
4009
|
-
return;
|
|
4010
|
-
}
|
|
4011
|
-
response.status(200).json({ response: stdout });
|
|
4012
|
-
});
|
|
4013
|
-
};
|
|
4014
|
-
}
|
|
4015
|
-
function getRunBuildHandler() {
|
|
4016
|
-
return async function runTestsHandler(request2, response) {
|
|
4017
|
-
const cmsDevServerPath = path10.join(
|
|
4018
|
-
path10.dirname(url2.fileURLToPath(import.meta.url)),
|
|
4019
|
-
"../.."
|
|
4020
|
-
);
|
|
4021
|
-
exec(
|
|
4022
|
-
"npm run build",
|
|
4023
|
-
{ cwd: cmsDevServerPath },
|
|
4024
|
-
(error, stdout, stderr) => {
|
|
4025
|
-
if (error) {
|
|
4026
|
-
response.status(500).json({ error: stderr });
|
|
4027
|
-
return;
|
|
4028
|
-
}
|
|
4029
|
-
response.status(200).json({ response: stdout });
|
|
4030
|
-
}
|
|
4031
|
-
);
|
|
4032
|
-
};
|
|
4033
|
-
}
|
|
4034
3997
|
async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
|
|
4035
3998
|
const shadowDevServerRoutes = Router2();
|
|
4036
3999
|
shadowDevServerRoutes.get(
|
|
@@ -4038,8 +4001,6 @@ async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
|
|
|
4038
4001
|
cors(),
|
|
4039
4002
|
getShadowDevServerCheckHandler(devServerPort, projectName, gates)
|
|
4040
4003
|
);
|
|
4041
|
-
shadowDevServerRoutes.get("/test", cors(), getRunTestsHandler());
|
|
4042
|
-
shadowDevServerRoutes.get("/build", cors(), getRunBuildHandler());
|
|
4043
4004
|
return shadowDevServerRoutes;
|
|
4044
4005
|
}
|
|
4045
4006
|
|
|
@@ -4086,7 +4047,33 @@ import fs3 from "node:fs/promises";
|
|
|
4086
4047
|
import express2 from "express";
|
|
4087
4048
|
import { createServer as createViteServer2 } from "vite";
|
|
4088
4049
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
4089
|
-
|
|
4050
|
+
|
|
4051
|
+
// src/lib/getDevServerUIData.ts
|
|
4052
|
+
async function getDevServerUIData(reqLocals) {
|
|
4053
|
+
const { themeWebRoot, authedPortalId, projectName, localPreviewToken } = reqLocals;
|
|
4054
|
+
const { moduleNames } = findAllModulesInRoot(themeWebRoot);
|
|
4055
|
+
const { partialNames } = findAllPartialsInRoot(themeWebRoot);
|
|
4056
|
+
const hubLModuleData = await fetchHubLModules(
|
|
4057
|
+
authedPortalId,
|
|
4058
|
+
localPreviewToken
|
|
4059
|
+
);
|
|
4060
|
+
const hubLTemplateData = await fetchPreviewTemplates(
|
|
4061
|
+
authedPortalId,
|
|
4062
|
+
localPreviewToken
|
|
4063
|
+
);
|
|
4064
|
+
return {
|
|
4065
|
+
authedPortalId,
|
|
4066
|
+
projectName,
|
|
4067
|
+
moduleNames,
|
|
4068
|
+
partialNames,
|
|
4069
|
+
hubLModules: (hubLModuleData == null ? void 0 : hubLModuleData.objects) || [],
|
|
4070
|
+
hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
var getDevServerUIData_default = getDevServerUIData;
|
|
4074
|
+
|
|
4075
|
+
// src/createAppServer.ts
|
|
4076
|
+
async function createAppServer(webRoot, reqLocals, port) {
|
|
4090
4077
|
const app = express2();
|
|
4091
4078
|
const origin = `http://hslocal.net:${port}`;
|
|
4092
4079
|
const viteConfig = {
|
|
@@ -4133,14 +4120,20 @@ async function createAppServer(webRoot, port) {
|
|
|
4133
4120
|
app.use(viteServer.middlewares);
|
|
4134
4121
|
app.use("*", async (req, res) => {
|
|
4135
4122
|
try {
|
|
4136
|
-
const
|
|
4123
|
+
const inititialProps = await getDevServerUIData_default(reqLocals);
|
|
4124
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4137
4125
|
let template = await fs3.readFile("./app/index.html", "utf-8");
|
|
4138
|
-
template = await viteServer.transformIndexHtml(
|
|
4126
|
+
template = await viteServer.transformIndexHtml(url3, template);
|
|
4139
4127
|
const { render } = await viteServer.ssrLoadModule(
|
|
4140
4128
|
"./app/serverEntry.tsx"
|
|
4141
4129
|
);
|
|
4142
|
-
const rendered = await render(
|
|
4143
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "")
|
|
4130
|
+
const rendered = await render(inititialProps);
|
|
4131
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4132
|
+
`<!--app-script-->`,
|
|
4133
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4134
|
+
inititialProps
|
|
4135
|
+
)}</script>` ?? ""
|
|
4136
|
+
);
|
|
4144
4137
|
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4145
4138
|
} catch (e) {
|
|
4146
4139
|
viteServer == null ? void 0 : viteServer.ssrFixStacktrace(e);
|
|
@@ -4314,7 +4307,7 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
4314
4307
|
}
|
|
4315
4308
|
|
|
4316
4309
|
// src/lib/validateHSPlatform.ts
|
|
4317
|
-
import
|
|
4310
|
+
import path10 from "path";
|
|
4318
4311
|
import fs4 from "fs";
|
|
4319
4312
|
import select from "@inquirer/select";
|
|
4320
4313
|
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
@@ -4326,12 +4319,12 @@ function findHSProjectJson(startPath) {
|
|
|
4326
4319
|
let currentDir = startPath;
|
|
4327
4320
|
let dirLevel = 0;
|
|
4328
4321
|
const maxDirLevel = 4;
|
|
4329
|
-
while (
|
|
4330
|
-
const filePath =
|
|
4322
|
+
while (path10.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
4323
|
+
const filePath = path10.join(currentDir, HSPROJECT_JSON);
|
|
4331
4324
|
if (checkFileExists(filePath)) {
|
|
4332
4325
|
return filePath;
|
|
4333
4326
|
}
|
|
4334
|
-
currentDir =
|
|
4327
|
+
currentDir = path10.dirname(currentDir);
|
|
4335
4328
|
dirLevel++;
|
|
4336
4329
|
}
|
|
4337
4330
|
console.log(
|
|
@@ -4637,7 +4630,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
4637
4630
|
|
|
4638
4631
|
// src/lib/watchFieldsUpdates.ts
|
|
4639
4632
|
import fs5 from "fs";
|
|
4640
|
-
import
|
|
4633
|
+
import path11 from "path";
|
|
4641
4634
|
import readline from "readline";
|
|
4642
4635
|
var lastSerializedFieldsCache = {};
|
|
4643
4636
|
var formatAsTypeName = (str) => {
|
|
@@ -4649,9 +4642,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
4649
4642
|
const getEntryPathFromId = (id) => {
|
|
4650
4643
|
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
|
|
4651
4644
|
};
|
|
4652
|
-
const currentModuleId =
|
|
4645
|
+
const currentModuleId = path11.normalize(filePath);
|
|
4653
4646
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
4654
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
4647
|
+
const subFolderTokens = moduleEntryPath.split(path11.sep);
|
|
4655
4648
|
return {
|
|
4656
4649
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
4657
4650
|
isRootModuleFile: subFolderTokens.length === 3
|
|
@@ -4678,10 +4671,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
4678
4671
|
return void 0;
|
|
4679
4672
|
if (isRootModuleFile)
|
|
4680
4673
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
4681
|
-
const dir =
|
|
4674
|
+
const dir = path11.dirname(filePath);
|
|
4682
4675
|
const files = fs5.readdirSync(dir);
|
|
4683
4676
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
4684
|
-
return indexFileName ? { indexFilePath:
|
|
4677
|
+
return indexFileName ? { indexFilePath: path11.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
4685
4678
|
};
|
|
4686
4679
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
4687
4680
|
let indexFile;
|
|
@@ -4705,7 +4698,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
4705
4698
|
if (!indexInfo)
|
|
4706
4699
|
return;
|
|
4707
4700
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
4708
|
-
const indexFileName =
|
|
4701
|
+
const indexFileName = path11.parse(indexFilePath).name;
|
|
4709
4702
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
4710
4703
|
if (isTypeFile)
|
|
4711
4704
|
return;
|
|
@@ -4716,7 +4709,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
4716
4709
|
);
|
|
4717
4710
|
if (fields) {
|
|
4718
4711
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
4719
|
-
const typeFilePath =
|
|
4712
|
+
const typeFilePath = path11.join(path11.dirname(filePath), typeFileName);
|
|
4720
4713
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
4721
4714
|
const serializedFields = JSON.stringify(fields);
|
|
4722
4715
|
if (lastSerializedFields === serializedFields)
|
|
@@ -4724,7 +4717,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
4724
4717
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
4725
4718
|
if (!hasAutoGenComment)
|
|
4726
4719
|
return;
|
|
4727
|
-
const moduleFolderName =
|
|
4720
|
+
const moduleFolderName = path11.basename(path11.dirname(filePath));
|
|
4728
4721
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
4729
4722
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
4730
4723
|
if (didSucceed) {
|
|
@@ -4740,7 +4733,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
4740
4733
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
4741
4734
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
4742
4735
|
moduleSubpaths.forEach((modulePath) => {
|
|
4743
|
-
const resolvedPath =
|
|
4736
|
+
const resolvedPath = path11.resolve(projectRoot, modulePath);
|
|
4744
4737
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
4745
4738
|
});
|
|
4746
4739
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -4878,7 +4871,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
4878
4871
|
} catch (e) {
|
|
4879
4872
|
authedHublet = "na1";
|
|
4880
4873
|
}
|
|
4881
|
-
const absoluteWebRoot = normalizePath7(
|
|
4874
|
+
const absoluteWebRoot = normalizePath7(path12.resolve(process.cwd(), webRoot));
|
|
4882
4875
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
4883
4876
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
4884
4877
|
if (authedPortalId) {
|
|
@@ -4970,16 +4963,25 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
4970
4963
|
`
|
|
4971
4964
|
);
|
|
4972
4965
|
if (showUI) {
|
|
4973
|
-
const appWebRoot =
|
|
4974
|
-
|
|
4966
|
+
const appWebRoot = path12.join(
|
|
4967
|
+
path12.dirname(url2.fileURLToPath(import.meta.url)),
|
|
4975
4968
|
"../app"
|
|
4976
4969
|
);
|
|
4977
|
-
const
|
|
4970
|
+
const reqLocals = {
|
|
4971
|
+
themeWebRoot: absoluteWebRoot,
|
|
4972
|
+
authedPortalId,
|
|
4973
|
+
authedEnv,
|
|
4974
|
+
authedHublet,
|
|
4975
|
+
projectName,
|
|
4976
|
+
webRootProjectComponentFolder,
|
|
4977
|
+
localPreviewToken: _localPreviewToken
|
|
4978
|
+
};
|
|
4979
|
+
const appServer = await createAppServer_default(appWebRoot, reqLocals, PORT + 1);
|
|
4978
4980
|
httpServers.push(appServer);
|
|
4979
4981
|
}
|
|
4980
4982
|
if (storybook) {
|
|
4981
|
-
const packageRoot =
|
|
4982
|
-
const configPath =
|
|
4983
|
+
const packageRoot = path12.dirname(url2.fileURLToPath(import.meta.url));
|
|
4984
|
+
const configPath = path12.resolve(packageRoot, "./storybook-main");
|
|
4983
4985
|
sendTrackingRequest("start-storybook");
|
|
4984
4986
|
const storybookProcess = spawn(
|
|
4985
4987
|
"sb",
|
|
@@ -4999,7 +5001,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
4999
5001
|
portalId: authedPortalId.toString(),
|
|
5000
5002
|
hsEnv: authedEnv,
|
|
5001
5003
|
hublet: authedHublet,
|
|
5002
|
-
WEB_ROOT:
|
|
5004
|
+
WEB_ROOT: path12.join(webRoot, "components")
|
|
5003
5005
|
}
|
|
5004
5006
|
}
|
|
5005
5007
|
);
|
package/dist/run.js
CHANGED
|
@@ -530,9 +530,9 @@ function getTerminalUISupport() {
|
|
|
530
530
|
function uiLine() {
|
|
531
531
|
logger.log("-".repeat(50));
|
|
532
532
|
}
|
|
533
|
-
function uiLink(linkText,
|
|
533
|
+
function uiLink(linkText, url3) {
|
|
534
534
|
const terminalUISupport = getTerminalUISupport();
|
|
535
|
-
const encodedUrl = encodeURI(
|
|
535
|
+
const encodedUrl = encodeURI(url3);
|
|
536
536
|
if (terminalUISupport.hyperlinks) {
|
|
537
537
|
const CLOSE_SEQUENCE = "\x1B]8;;\x07";
|
|
538
538
|
const result = [
|
|
@@ -741,8 +741,8 @@ async function buildThemePreviewOptions(webRoot2) {
|
|
|
741
741
|
}
|
|
742
742
|
|
|
743
743
|
// src/createDevServer.ts
|
|
744
|
-
import
|
|
745
|
-
import
|
|
744
|
+
import path13 from "path";
|
|
745
|
+
import url2 from "url";
|
|
746
746
|
import express3 from "express";
|
|
747
747
|
import http3 from "http";
|
|
748
748
|
import bodyParser from "body-parser";
|
|
@@ -1095,7 +1095,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
1095
1095
|
hydrateOn,
|
|
1096
1096
|
clientOnly,
|
|
1097
1097
|
priority,
|
|
1098
|
-
url:
|
|
1098
|
+
url: url3,
|
|
1099
1099
|
sharedStateID,
|
|
1100
1100
|
supplementalFieldValues,
|
|
1101
1101
|
wrapperModuleId,
|
|
@@ -1109,7 +1109,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
1109
1109
|
clientOnly,
|
|
1110
1110
|
priority,
|
|
1111
1111
|
props,
|
|
1112
|
-
url:
|
|
1112
|
+
url: url3
|
|
1113
1113
|
};
|
|
1114
1114
|
if (sharedStateID) {
|
|
1115
1115
|
output.sharedStateID = sharedStateID;
|
|
@@ -1366,8 +1366,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
1366
1366
|
);
|
|
1367
1367
|
return Object.fromEntries(relativeEntries);
|
|
1368
1368
|
}
|
|
1369
|
-
function toRelativePath(config,
|
|
1370
|
-
return
|
|
1369
|
+
function toRelativePath(config, path14) {
|
|
1370
|
+
return path14.replace(config.root, "");
|
|
1371
1371
|
}
|
|
1372
1372
|
function shouldSkipModule(config, moduleInfo, code) {
|
|
1373
1373
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
@@ -1405,11 +1405,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1405
1405
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
1406
1406
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
1407
1407
|
traverse(sourceAst, {
|
|
1408
|
-
ImportDeclaration(
|
|
1409
|
-
if (t.isStringLiteral(
|
|
1408
|
+
ImportDeclaration(path14) {
|
|
1409
|
+
if (t.isStringLiteral(path14.node.source, {
|
|
1410
1410
|
value: "@hubspot/cms-components"
|
|
1411
1411
|
})) {
|
|
1412
|
-
for (const specifier of
|
|
1412
|
+
for (const specifier of path14.node.specifiers) {
|
|
1413
1413
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
1414
1414
|
name: CMS_MODULE_COMPONENT_NAME
|
|
1415
1415
|
})) {
|
|
@@ -1423,14 +1423,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
1425
|
},
|
|
1426
|
-
JSXOpeningElement(
|
|
1427
|
-
if (t.isJSXIdentifier(
|
|
1426
|
+
JSXOpeningElement(path14) {
|
|
1427
|
+
if (t.isJSXIdentifier(path14.node.name, {
|
|
1428
1428
|
name: moduleComponentLocalImportName
|
|
1429
1429
|
})) {
|
|
1430
1430
|
let cmsModuleName;
|
|
1431
1431
|
let cmsModulePath;
|
|
1432
1432
|
let cmsModuleLabel;
|
|
1433
|
-
for (const prop of
|
|
1433
|
+
for (const prop of path14.node.attributes) {
|
|
1434
1434
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1435
1435
|
cmsModuleName = prop.value.value;
|
|
1436
1436
|
continue;
|
|
@@ -1465,11 +1465,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
1467
1467
|
}
|
|
1468
|
-
if (t.isJSXIdentifier(
|
|
1468
|
+
if (t.isJSXIdentifier(path14.node.name, {
|
|
1469
1469
|
name: dndAreaComponentLocalImportName
|
|
1470
1470
|
})) {
|
|
1471
1471
|
let dndAreaName;
|
|
1472
|
-
for (const prop of
|
|
1472
|
+
for (const prop of path14.node.attributes) {
|
|
1473
1473
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1474
1474
|
dndAreaName = prop.value.value;
|
|
1475
1475
|
continue;
|
|
@@ -1940,9 +1940,9 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
1940
1940
|
);
|
|
1941
1941
|
return htmlTemplate;
|
|
1942
1942
|
};
|
|
1943
|
-
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath,
|
|
1943
|
+
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, jsRenderingGates) => {
|
|
1944
1944
|
let htmlTemplate;
|
|
1945
|
-
const prettyPrint = isDebugUrlString2(
|
|
1945
|
+
const prettyPrint = isDebugUrlString2(url3);
|
|
1946
1946
|
const serverMessages = criticalDevErrorsToServerMessages_default(
|
|
1947
1947
|
renderContext.criticalDevErrors
|
|
1948
1948
|
);
|
|
@@ -1992,7 +1992,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url4, tit
|
|
|
1992
1992
|
`${globalScriptBlock}${serverLogScript}`
|
|
1993
1993
|
);
|
|
1994
1994
|
}
|
|
1995
|
-
return viteServer.transformIndexHtml(
|
|
1995
|
+
return viteServer.transformIndexHtml(url3, htmlTemplate);
|
|
1996
1996
|
};
|
|
1997
1997
|
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, gates, prettyPrint) => {
|
|
1998
1998
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
@@ -2053,12 +2053,12 @@ function trackUsage(action) {
|
|
|
2053
2053
|
eventName: EVENT_NAME,
|
|
2054
2054
|
action,
|
|
2055
2055
|
nodeVersion: getNodeVersionData(),
|
|
2056
|
-
version: "0.18.
|
|
2056
|
+
version: "0.18.10",
|
|
2057
2057
|
os: getPlatform()
|
|
2058
2058
|
};
|
|
2059
|
-
const
|
|
2059
|
+
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
2060
2060
|
const baseRequestOptions = {
|
|
2061
|
-
url:
|
|
2061
|
+
url: url3,
|
|
2062
2062
|
data: usageEvent
|
|
2063
2063
|
};
|
|
2064
2064
|
if (isAuthedWithPersonalAccessKey) {
|
|
@@ -2126,12 +2126,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2126
2126
|
);
|
|
2127
2127
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
2128
2128
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
2129
|
-
const
|
|
2129
|
+
const path14 = body.substring(
|
|
2130
2130
|
startOffset + localJsRenderStartString.length,
|
|
2131
2131
|
pathEndOffset
|
|
2132
2132
|
);
|
|
2133
2133
|
offsetSoFar = pathEndOffset + 1;
|
|
2134
|
-
if (startOffset >= 0 &&
|
|
2134
|
+
if (startOffset >= 0 && path14) {
|
|
2135
2135
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
2136
2136
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
2137
2137
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -2156,7 +2156,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2156
2156
|
result.push({
|
|
2157
2157
|
startOffset,
|
|
2158
2158
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
2159
|
-
path:
|
|
2159
|
+
path: path14,
|
|
2160
2160
|
json
|
|
2161
2161
|
});
|
|
2162
2162
|
}
|
|
@@ -2533,9 +2533,9 @@ var customColors = [
|
|
|
2533
2533
|
];
|
|
2534
2534
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
2535
2535
|
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;`;
|
|
2536
|
-
var renderLocalError_default = (
|
|
2536
|
+
var renderLocalError_default = (path14, error) => {
|
|
2537
2537
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
2538
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
2538
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path14}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
2539
2539
|
};
|
|
2540
2540
|
|
|
2541
2541
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2944,17 +2944,17 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
|
|
|
2944
2944
|
return placeholderPath;
|
|
2945
2945
|
}
|
|
2946
2946
|
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates, cookieHeader, localPreviewToken) => {
|
|
2947
|
-
const
|
|
2948
|
-
const renderPreviewLocally =
|
|
2947
|
+
const url3 = new URL(urlToProxy);
|
|
2948
|
+
const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
|
|
2949
2949
|
let proxiedQueryParams = {};
|
|
2950
|
-
let baseURL =
|
|
2951
|
-
let pathname =
|
|
2950
|
+
let baseURL = url3.origin;
|
|
2951
|
+
let pathname = url3.pathname;
|
|
2952
2952
|
const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
|
|
2953
|
-
const queryKeys = Array.from(
|
|
2953
|
+
const queryKeys = Array.from(url3.searchParams.keys()).filter(
|
|
2954
2954
|
(queryKey) => !PARAMS_TO_IGNORE.includes(queryKey)
|
|
2955
2955
|
);
|
|
2956
2956
|
for (const queryKey of queryKeys) {
|
|
2957
|
-
const values =
|
|
2957
|
+
const values = url3.searchParams.getAll(queryKey);
|
|
2958
2958
|
if (values.length > 1) {
|
|
2959
2959
|
proxiedQueryParams[queryKey] = values;
|
|
2960
2960
|
} else {
|
|
@@ -2970,9 +2970,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
2970
2970
|
hsLoginVerifyDisabled: `${true}`
|
|
2971
2971
|
};
|
|
2972
2972
|
if (renderPreviewLocally) {
|
|
2973
|
-
proxiedQueryParams.hsDebugOverridePublicHost =
|
|
2973
|
+
proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
|
|
2974
2974
|
baseURL = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
|
|
2975
|
-
pathname = `/cos-rendering/v1/public${
|
|
2975
|
+
pathname = `/cos-rendering/v1/public${url3.pathname}`;
|
|
2976
2976
|
}
|
|
2977
2977
|
if (localPreviewToken) {
|
|
2978
2978
|
proxiedQueryParams = {
|
|
@@ -3800,16 +3800,16 @@ var module_default = moduleRouteHandler;
|
|
|
3800
3800
|
import http from "http";
|
|
3801
3801
|
import https from "https";
|
|
3802
3802
|
import { getAccountId as getAccountId2 } from "@hubspot/local-dev-lib/config";
|
|
3803
|
-
async function requestPage(
|
|
3803
|
+
async function requestPage(url3, redirects = 0, originalUrl) {
|
|
3804
3804
|
if (redirects > 5) {
|
|
3805
3805
|
throw new Error(
|
|
3806
3806
|
`Hit too many redirects to HEAD requests for ${originalUrl}`
|
|
3807
3807
|
);
|
|
3808
3808
|
}
|
|
3809
3809
|
return new Promise((resolve3, reject) => {
|
|
3810
|
-
const protocolAPI =
|
|
3810
|
+
const protocolAPI = url3.startsWith("https://") ? https : http;
|
|
3811
3811
|
protocolAPI.request(
|
|
3812
|
-
|
|
3812
|
+
url3,
|
|
3813
3813
|
{
|
|
3814
3814
|
method: "HEAD",
|
|
3815
3815
|
headers: {
|
|
@@ -3836,12 +3836,12 @@ async function requestPage(url4, redirects = 0, originalUrl) {
|
|
|
3836
3836
|
}
|
|
3837
3837
|
}
|
|
3838
3838
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
3839
|
-
console.log(`Redirecting to ${res.headers.location} (from ${
|
|
3839
|
+
console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
|
|
3840
3840
|
return resolve3(
|
|
3841
3841
|
requestPage(
|
|
3842
3842
|
res.headers.location,
|
|
3843
3843
|
redirects + 1,
|
|
3844
|
-
originalUrl ??
|
|
3844
|
+
originalUrl ?? url3
|
|
3845
3845
|
)
|
|
3846
3846
|
);
|
|
3847
3847
|
}
|
|
@@ -3859,11 +3859,11 @@ async function requestPage(url4, redirects = 0, originalUrl) {
|
|
|
3859
3859
|
}).end();
|
|
3860
3860
|
});
|
|
3861
3861
|
}
|
|
3862
|
-
async function fetchContentMetadata(
|
|
3863
|
-
const { portalIdHeader, contentId, res } = await requestPage(
|
|
3862
|
+
async function fetchContentMetadata(url3, portalId) {
|
|
3863
|
+
const { portalIdHeader, contentId, res } = await requestPage(url3);
|
|
3864
3864
|
if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
|
|
3865
3865
|
throw new Error(
|
|
3866
|
-
`There were multiple hub ID or content ID headers in the HEAD request to ${
|
|
3866
|
+
`There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
|
|
3867
3867
|
);
|
|
3868
3868
|
} else {
|
|
3869
3869
|
const portalIdFromResponse = parseInt(portalIdHeader, 10);
|
|
@@ -3875,15 +3875,15 @@ async function fetchContentMetadata(url4, portalId) {
|
|
|
3875
3875
|
}
|
|
3876
3876
|
if (res.statusCode !== 200 && !(portalIdFromResponse && pageAccount && contentId)) {
|
|
3877
3877
|
throw new Error(
|
|
3878
|
-
`${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${
|
|
3878
|
+
`${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url3}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
|
|
3879
3879
|
);
|
|
3880
3880
|
} else if (!portalId || !contentId) {
|
|
3881
3881
|
throw new Error(
|
|
3882
|
-
`Missing hub ID or content ID headers on HEAD request to ${
|
|
3882
|
+
`Missing hub ID or content ID headers on HEAD request to ${url3}`
|
|
3883
3883
|
);
|
|
3884
3884
|
} else if (isNaN(portalId)) {
|
|
3885
3885
|
throw new Error(
|
|
3886
|
-
`Hub ID from the HEAD request is not a number: '${portalId}' (${
|
|
3886
|
+
`Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
|
|
3887
3887
|
);
|
|
3888
3888
|
}
|
|
3889
3889
|
const hublet = "na1";
|
|
@@ -4009,14 +4009,14 @@ async function fetchPreviewTemplates(accountId, previewToken) {
|
|
|
4009
4009
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
|
|
4010
4010
|
})).data;
|
|
4011
4011
|
}
|
|
4012
|
-
async function fetchModuleByPath(accountId,
|
|
4012
|
+
async function fetchModuleByPath(accountId, path14) {
|
|
4013
4013
|
return (await hsCliHttp8.get(accountId, {
|
|
4014
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
4014
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path14}?portalId=${accountId}`
|
|
4015
4015
|
})).data;
|
|
4016
4016
|
}
|
|
4017
|
-
async function fetchTemplateByPath(accountId,
|
|
4017
|
+
async function fetchTemplateByPath(accountId, path14) {
|
|
4018
4018
|
return (await hsCliHttp8.get(accountId, {
|
|
4019
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
4019
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path14}?portalId=${accountId}`
|
|
4020
4020
|
})).data;
|
|
4021
4021
|
}
|
|
4022
4022
|
|
|
@@ -4473,8 +4473,8 @@ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
|
|
|
4473
4473
|
var createDevServerRoutes = async (viteServer, storybookPort) => {
|
|
4474
4474
|
const devServerApp = Router();
|
|
4475
4475
|
devServerApp.use((request2, response, next) => {
|
|
4476
|
-
const { method, url:
|
|
4477
|
-
debug(`${method}:${hostname}${
|
|
4476
|
+
const { method, url: url3, hostname } = request2;
|
|
4477
|
+
debug(`${method}:${hostname}${url3}`);
|
|
4478
4478
|
next();
|
|
4479
4479
|
});
|
|
4480
4480
|
if (storybookPort) {
|
|
@@ -4523,9 +4523,6 @@ import express from "express";
|
|
|
4523
4523
|
import { Router as Router2 } from "express";
|
|
4524
4524
|
import { getAccountId as getAccountId3, getEnv as getEnv3 } from "@hubspot/local-dev-lib/config";
|
|
4525
4525
|
import cors from "cors";
|
|
4526
|
-
import { exec } from "child_process";
|
|
4527
|
-
import path11 from "path";
|
|
4528
|
-
import url2 from "url";
|
|
4529
4526
|
import { buildStaticEnvConfig as buildStaticEnvConfig6 } from "@hubspot/cms-components";
|
|
4530
4527
|
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
4531
4528
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
@@ -4601,40 +4598,6 @@ ${error.stack}`
|
|
|
4601
4598
|
}
|
|
4602
4599
|
};
|
|
4603
4600
|
}
|
|
4604
|
-
function getRunTestsHandler() {
|
|
4605
|
-
return async function runTestsHandler(request2, response) {
|
|
4606
|
-
const cmsDevServerPath = path11.join(
|
|
4607
|
-
path11.dirname(url2.fileURLToPath(import.meta.url)),
|
|
4608
|
-
"../.."
|
|
4609
|
-
);
|
|
4610
|
-
exec("npm run test", { cwd: cmsDevServerPath }, (error, stdout, stderr) => {
|
|
4611
|
-
if (error) {
|
|
4612
|
-
response.status(500).json({ error: stderr });
|
|
4613
|
-
return;
|
|
4614
|
-
}
|
|
4615
|
-
response.status(200).json({ response: stdout });
|
|
4616
|
-
});
|
|
4617
|
-
};
|
|
4618
|
-
}
|
|
4619
|
-
function getRunBuildHandler() {
|
|
4620
|
-
return async function runTestsHandler(request2, response) {
|
|
4621
|
-
const cmsDevServerPath = path11.join(
|
|
4622
|
-
path11.dirname(url2.fileURLToPath(import.meta.url)),
|
|
4623
|
-
"../.."
|
|
4624
|
-
);
|
|
4625
|
-
exec(
|
|
4626
|
-
"npm run build",
|
|
4627
|
-
{ cwd: cmsDevServerPath },
|
|
4628
|
-
(error, stdout, stderr) => {
|
|
4629
|
-
if (error) {
|
|
4630
|
-
response.status(500).json({ error: stderr });
|
|
4631
|
-
return;
|
|
4632
|
-
}
|
|
4633
|
-
response.status(200).json({ response: stdout });
|
|
4634
|
-
}
|
|
4635
|
-
);
|
|
4636
|
-
};
|
|
4637
|
-
}
|
|
4638
4601
|
async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
|
|
4639
4602
|
const shadowDevServerRoutes = Router2();
|
|
4640
4603
|
shadowDevServerRoutes.get(
|
|
@@ -4642,8 +4605,6 @@ async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
|
|
|
4642
4605
|
cors(),
|
|
4643
4606
|
getShadowDevServerCheckHandler(devServerPort, projectName, gates)
|
|
4644
4607
|
);
|
|
4645
|
-
shadowDevServerRoutes.get("/test", cors(), getRunTestsHandler());
|
|
4646
|
-
shadowDevServerRoutes.get("/build", cors(), getRunBuildHandler());
|
|
4647
4608
|
return shadowDevServerRoutes;
|
|
4648
4609
|
}
|
|
4649
4610
|
|
|
@@ -4809,7 +4770,33 @@ import fs4 from "node:fs/promises";
|
|
|
4809
4770
|
import express2 from "express";
|
|
4810
4771
|
import { createServer as createViteServer2 } from "vite";
|
|
4811
4772
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
4812
|
-
|
|
4773
|
+
|
|
4774
|
+
// src/lib/getDevServerUIData.ts
|
|
4775
|
+
async function getDevServerUIData(reqLocals) {
|
|
4776
|
+
const { themeWebRoot, authedPortalId, projectName, localPreviewToken } = reqLocals;
|
|
4777
|
+
const { moduleNames } = findAllModulesInRoot(themeWebRoot);
|
|
4778
|
+
const { partialNames } = findAllPartialsInRoot(themeWebRoot);
|
|
4779
|
+
const hubLModuleData = await fetchHubLModules(
|
|
4780
|
+
authedPortalId,
|
|
4781
|
+
localPreviewToken
|
|
4782
|
+
);
|
|
4783
|
+
const hubLTemplateData = await fetchPreviewTemplates(
|
|
4784
|
+
authedPortalId,
|
|
4785
|
+
localPreviewToken
|
|
4786
|
+
);
|
|
4787
|
+
return {
|
|
4788
|
+
authedPortalId,
|
|
4789
|
+
projectName,
|
|
4790
|
+
moduleNames,
|
|
4791
|
+
partialNames,
|
|
4792
|
+
hubLModules: (hubLModuleData == null ? void 0 : hubLModuleData.objects) || [],
|
|
4793
|
+
hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []
|
|
4794
|
+
};
|
|
4795
|
+
}
|
|
4796
|
+
var getDevServerUIData_default = getDevServerUIData;
|
|
4797
|
+
|
|
4798
|
+
// src/createAppServer.ts
|
|
4799
|
+
async function createAppServer(webRoot2, reqLocals, port) {
|
|
4813
4800
|
const app = express2();
|
|
4814
4801
|
const origin = `http://hslocal.net:${port}`;
|
|
4815
4802
|
const viteConfig = {
|
|
@@ -4856,14 +4843,20 @@ async function createAppServer(webRoot2, port) {
|
|
|
4856
4843
|
app.use(viteServer.middlewares);
|
|
4857
4844
|
app.use("*", async (req, res) => {
|
|
4858
4845
|
try {
|
|
4859
|
-
const
|
|
4846
|
+
const inititialProps = await getDevServerUIData_default(reqLocals);
|
|
4847
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4860
4848
|
let template = await fs4.readFile("./app/index.html", "utf-8");
|
|
4861
|
-
template = await viteServer.transformIndexHtml(
|
|
4849
|
+
template = await viteServer.transformIndexHtml(url3, template);
|
|
4862
4850
|
const { render } = await viteServer.ssrLoadModule(
|
|
4863
4851
|
"./app/serverEntry.tsx"
|
|
4864
4852
|
);
|
|
4865
|
-
const rendered = await render(
|
|
4866
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "")
|
|
4853
|
+
const rendered = await render(inititialProps);
|
|
4854
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4855
|
+
`<!--app-script-->`,
|
|
4856
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4857
|
+
inititialProps
|
|
4858
|
+
)}</script>` ?? ""
|
|
4859
|
+
);
|
|
4867
4860
|
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4868
4861
|
} catch (e) {
|
|
4869
4862
|
viteServer == null ? void 0 : viteServer.ssrFixStacktrace(e);
|
|
@@ -5037,7 +5030,7 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5037
5030
|
}
|
|
5038
5031
|
|
|
5039
5032
|
// src/lib/validateHSPlatform.ts
|
|
5040
|
-
import
|
|
5033
|
+
import path11 from "path";
|
|
5041
5034
|
import fs5 from "fs";
|
|
5042
5035
|
import select from "@inquirer/select";
|
|
5043
5036
|
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
@@ -5049,12 +5042,12 @@ function findHSProjectJson(startPath) {
|
|
|
5049
5042
|
let currentDir = startPath;
|
|
5050
5043
|
let dirLevel = 0;
|
|
5051
5044
|
const maxDirLevel = 4;
|
|
5052
|
-
while (
|
|
5053
|
-
const filePath =
|
|
5045
|
+
while (path11.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
5046
|
+
const filePath = path11.join(currentDir, HSPROJECT_JSON);
|
|
5054
5047
|
if (checkFileExists(filePath)) {
|
|
5055
5048
|
return filePath;
|
|
5056
5049
|
}
|
|
5057
|
-
currentDir =
|
|
5050
|
+
currentDir = path11.dirname(currentDir);
|
|
5058
5051
|
dirLevel++;
|
|
5059
5052
|
}
|
|
5060
5053
|
console.log(
|
|
@@ -5360,7 +5353,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5360
5353
|
|
|
5361
5354
|
// src/lib/watchFieldsUpdates.ts
|
|
5362
5355
|
import fs6 from "fs";
|
|
5363
|
-
import
|
|
5356
|
+
import path12 from "path";
|
|
5364
5357
|
import readline from "readline";
|
|
5365
5358
|
var lastSerializedFieldsCache = {};
|
|
5366
5359
|
var formatAsTypeName = (str) => {
|
|
@@ -5372,9 +5365,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
5372
5365
|
const getEntryPathFromId = (id) => {
|
|
5373
5366
|
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
|
|
5374
5367
|
};
|
|
5375
|
-
const currentModuleId =
|
|
5368
|
+
const currentModuleId = path12.normalize(filePath);
|
|
5376
5369
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
5377
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
5370
|
+
const subFolderTokens = moduleEntryPath.split(path12.sep);
|
|
5378
5371
|
return {
|
|
5379
5372
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
5380
5373
|
isRootModuleFile: subFolderTokens.length === 3
|
|
@@ -5401,10 +5394,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5401
5394
|
return void 0;
|
|
5402
5395
|
if (isRootModuleFile)
|
|
5403
5396
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5404
|
-
const dir =
|
|
5397
|
+
const dir = path12.dirname(filePath);
|
|
5405
5398
|
const files = fs6.readdirSync(dir);
|
|
5406
5399
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5407
|
-
return indexFileName ? { indexFilePath:
|
|
5400
|
+
return indexFileName ? { indexFilePath: path12.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5408
5401
|
};
|
|
5409
5402
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
5410
5403
|
let indexFile;
|
|
@@ -5428,7 +5421,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5428
5421
|
if (!indexInfo)
|
|
5429
5422
|
return;
|
|
5430
5423
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
5431
|
-
const indexFileName =
|
|
5424
|
+
const indexFileName = path12.parse(indexFilePath).name;
|
|
5432
5425
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
5433
5426
|
if (isTypeFile)
|
|
5434
5427
|
return;
|
|
@@ -5439,7 +5432,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5439
5432
|
);
|
|
5440
5433
|
if (fields) {
|
|
5441
5434
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
5442
|
-
const typeFilePath =
|
|
5435
|
+
const typeFilePath = path12.join(path12.dirname(filePath), typeFileName);
|
|
5443
5436
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
5444
5437
|
const serializedFields = JSON.stringify(fields);
|
|
5445
5438
|
if (lastSerializedFields === serializedFields)
|
|
@@ -5447,7 +5440,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5447
5440
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
5448
5441
|
if (!hasAutoGenComment)
|
|
5449
5442
|
return;
|
|
5450
|
-
const moduleFolderName =
|
|
5443
|
+
const moduleFolderName = path12.basename(path12.dirname(filePath));
|
|
5451
5444
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
5452
5445
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
5453
5446
|
if (didSucceed) {
|
|
@@ -5463,7 +5456,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5463
5456
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
5464
5457
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
5465
5458
|
moduleSubpaths.forEach((modulePath) => {
|
|
5466
|
-
const resolvedPath =
|
|
5459
|
+
const resolvedPath = path12.resolve(projectRoot, modulePath);
|
|
5467
5460
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
5468
5461
|
});
|
|
5469
5462
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -5601,7 +5594,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5601
5594
|
} catch (e) {
|
|
5602
5595
|
authedHublet = "na1";
|
|
5603
5596
|
}
|
|
5604
|
-
const absoluteWebRoot = normalizePath7(
|
|
5597
|
+
const absoluteWebRoot = normalizePath7(path13.resolve(process.cwd(), webRoot2));
|
|
5605
5598
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
5606
5599
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
5607
5600
|
if (authedPortalId) {
|
|
@@ -5693,16 +5686,25 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5693
5686
|
`
|
|
5694
5687
|
);
|
|
5695
5688
|
if (showUI) {
|
|
5696
|
-
const appWebRoot =
|
|
5697
|
-
|
|
5689
|
+
const appWebRoot = path13.join(
|
|
5690
|
+
path13.dirname(url2.fileURLToPath(import.meta.url)),
|
|
5698
5691
|
"../app"
|
|
5699
5692
|
);
|
|
5700
|
-
const
|
|
5693
|
+
const reqLocals = {
|
|
5694
|
+
themeWebRoot: absoluteWebRoot,
|
|
5695
|
+
authedPortalId,
|
|
5696
|
+
authedEnv,
|
|
5697
|
+
authedHublet,
|
|
5698
|
+
projectName,
|
|
5699
|
+
webRootProjectComponentFolder,
|
|
5700
|
+
localPreviewToken: _localPreviewToken
|
|
5701
|
+
};
|
|
5702
|
+
const appServer = await createAppServer_default(appWebRoot, reqLocals, PORT + 1);
|
|
5701
5703
|
httpServers.push(appServer);
|
|
5702
5704
|
}
|
|
5703
5705
|
if (storybook2) {
|
|
5704
|
-
const packageRoot =
|
|
5705
|
-
const configPath =
|
|
5706
|
+
const packageRoot = path13.dirname(url2.fileURLToPath(import.meta.url));
|
|
5707
|
+
const configPath = path13.resolve(packageRoot, "./storybook-main");
|
|
5706
5708
|
sendTrackingRequest("start-storybook");
|
|
5707
5709
|
const storybookProcess = spawn(
|
|
5708
5710
|
"sb",
|
|
@@ -5722,7 +5724,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5722
5724
|
portalId: authedPortalId.toString(),
|
|
5723
5725
|
hsEnv: authedEnv,
|
|
5724
5726
|
hublet: authedHublet,
|
|
5725
|
-
WEB_ROOT:
|
|
5727
|
+
WEB_ROOT: path13.join(webRoot2, "components")
|
|
5726
5728
|
}
|
|
5727
5729
|
}
|
|
5728
5730
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,12 +29,13 @@
|
|
|
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.
|
|
32
|
+
"@hubspot/cms-components": "^0.18.10",
|
|
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",
|
|
36
36
|
"@radix-ui/react-separator": "^1.1.0",
|
|
37
37
|
"@radix-ui/react-slot": "^1.1.0",
|
|
38
|
+
"@radix-ui/react-tooltip": "^1.1.4",
|
|
38
39
|
"@storybook/addon-actions": "7.1.1",
|
|
39
40
|
"@storybook/addon-essentials": "7.1.1",
|
|
40
41
|
"@storybook/addon-interactions": "7.1.1",
|
|
@@ -53,9 +54,11 @@
|
|
|
53
54
|
"clsx": "^2.1.1",
|
|
54
55
|
"cors": "^2.8.5",
|
|
55
56
|
"debug": "^4.3.4",
|
|
57
|
+
"dot-prop": "^9.0.0",
|
|
56
58
|
"express": "^4.17.3",
|
|
57
59
|
"html-escaper": "^3.0.3",
|
|
58
60
|
"http-proxy-middleware": "^2.0.6",
|
|
61
|
+
"inquirer": "8.2.0",
|
|
59
62
|
"jsdom": "^25.0.1",
|
|
60
63
|
"lucide-react": "^0.454.0",
|
|
61
64
|
"node-fetch": "^3.3.0",
|
|
@@ -78,7 +81,6 @@
|
|
|
78
81
|
"@types/react-dom": "^18.0.0",
|
|
79
82
|
"autoprefixer": "^10.4.20",
|
|
80
83
|
"copyfiles": "^2.4.1",
|
|
81
|
-
"dot-prop": "^9.0.0",
|
|
82
84
|
"esbuild": "^0.16.17",
|
|
83
85
|
"fs-extra": "^11.2.0",
|
|
84
86
|
"nodemon": "^2.0.15",
|
|
@@ -128,5 +130,5 @@
|
|
|
128
130
|
"publishConfig": {
|
|
129
131
|
"access": "public"
|
|
130
132
|
},
|
|
131
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "8a28e311b6ff9484f2a72052341c10d7d1b7f7ff"
|
|
132
134
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { RequestLocals } from './lib/getDevServerUIData.js';
|
|
2
|
+
declare function createAppServer(webRoot: any, reqLocals: RequestLocals, port: any): Promise<import("express-serve-static-core").Express>;
|
|
2
3
|
export default createAppServer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HubLModule, HubLTemplate } from '../api/designmanager.js';
|
|
2
|
+
export interface DevServerUIData {
|
|
3
|
+
authedPortalId: number;
|
|
4
|
+
projectName: string;
|
|
5
|
+
moduleNames: string[];
|
|
6
|
+
partialNames: string[];
|
|
7
|
+
hubLModules: HubLModule[];
|
|
8
|
+
hubLTemplates: HubLTemplate[];
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface RequestLocals {
|
|
12
|
+
themeWebRoot: string;
|
|
13
|
+
authedPortalId: number;
|
|
14
|
+
authedEnv: string;
|
|
15
|
+
authedHublet: string;
|
|
16
|
+
projectName: string;
|
|
17
|
+
webRootProjectComponentFolder: string;
|
|
18
|
+
localPreviewToken: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function getDevServerUIData(reqLocals: RequestLocals): Promise<DevServerUIData>;
|
|
21
|
+
export default getDevServerUIData;
|