@hubspot/cms-dev-server 1.0.5 → 1.0.7
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/server/serverEntry.js +1 -1
- package/dist/index.js +170 -156
- package/dist/run.js +170 -156
- package/package.json +3 -3
- package/types/lib/getDevServerUIData.d.ts +4 -2
- package/types/routes/appServerApiRouteHandler.d.ts +5 -0
- package/types/routes/appServerRouteHandler.d.ts +3 -0
- package/types/routes/createAppServerAPIRoutes.d.ts +5 -0
- package/types/routes/createDevServerRoutes.d.ts +2 -6
- package/types/routes/legacyRouteHandler.d.ts +3 -0
|
@@ -1534,7 +1534,7 @@ function useLanguageVariants() {
|
|
|
1534
1534
|
if ((languageVariantsResult == null ? void 0 : languageVariantsResult.status) === "ERROR") {
|
|
1535
1535
|
logError(languageVariantsResult.error);
|
|
1536
1536
|
}
|
|
1537
|
-
if (languageVariantsResult.status === "WARNING") {
|
|
1537
|
+
if ((languageVariantsResult == null ? void 0 : languageVariantsResult.status) === "WARNING") {
|
|
1538
1538
|
logWarn(languageVariantsResult.warning);
|
|
1539
1539
|
}
|
|
1540
1540
|
return [];
|
package/dist/index.js
CHANGED
|
@@ -596,8 +596,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
596
596
|
);
|
|
597
597
|
return Object.fromEntries(relativeEntries);
|
|
598
598
|
}
|
|
599
|
-
function toRelativePath(config,
|
|
600
|
-
return
|
|
599
|
+
function toRelativePath(config, path17) {
|
|
600
|
+
return path17.replace(`${config.root}/`, "");
|
|
601
601
|
}
|
|
602
602
|
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
603
603
|
const [fileId, __] = moduleInfo.id.split("?");
|
|
@@ -640,11 +640,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
640
640
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
641
641
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
642
642
|
traverse(sourceAst, {
|
|
643
|
-
ImportDeclaration(
|
|
644
|
-
if (t.isStringLiteral(
|
|
643
|
+
ImportDeclaration(path17) {
|
|
644
|
+
if (t.isStringLiteral(path17.node.source, {
|
|
645
645
|
value: "@hubspot/cms-components"
|
|
646
646
|
})) {
|
|
647
|
-
for (const specifier of
|
|
647
|
+
for (const specifier of path17.node.specifiers) {
|
|
648
648
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
649
649
|
name: CMS_MODULE_COMPONENT_NAME
|
|
650
650
|
})) {
|
|
@@ -658,14 +658,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
},
|
|
661
|
-
JSXOpeningElement(
|
|
662
|
-
if (t.isJSXIdentifier(
|
|
661
|
+
JSXOpeningElement(path17) {
|
|
662
|
+
if (t.isJSXIdentifier(path17.node.name, {
|
|
663
663
|
name: moduleComponentLocalImportName
|
|
664
664
|
})) {
|
|
665
665
|
let cmsModuleName;
|
|
666
666
|
let cmsModulePath;
|
|
667
667
|
let cmsModuleLabel;
|
|
668
|
-
for (const prop of
|
|
668
|
+
for (const prop of path17.node.attributes) {
|
|
669
669
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
670
670
|
cmsModuleName = prop.value.value;
|
|
671
671
|
continue;
|
|
@@ -700,11 +700,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
700
700
|
}
|
|
701
701
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
702
702
|
}
|
|
703
|
-
if (t.isJSXIdentifier(
|
|
703
|
+
if (t.isJSXIdentifier(path17.node.name, {
|
|
704
704
|
name: dndAreaComponentLocalImportName
|
|
705
705
|
})) {
|
|
706
706
|
let dndAreaName;
|
|
707
|
-
for (const prop of
|
|
707
|
+
for (const prop of path17.node.attributes) {
|
|
708
708
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
709
709
|
dndAreaName = prop.value.value;
|
|
710
710
|
continue;
|
|
@@ -1035,7 +1035,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1035
1035
|
var createViteDevServer_default = createViteDevServer;
|
|
1036
1036
|
|
|
1037
1037
|
// src/createDevServer.ts
|
|
1038
|
-
import
|
|
1038
|
+
import path16 from "path";
|
|
1039
1039
|
import url2 from "url";
|
|
1040
1040
|
import express2 from "express";
|
|
1041
1041
|
import http3 from "http";
|
|
@@ -1465,7 +1465,7 @@ function trackUsage(action) {
|
|
|
1465
1465
|
eventName: EVENT_NAME,
|
|
1466
1466
|
action,
|
|
1467
1467
|
nodeVersion: getNodeVersionData(),
|
|
1468
|
-
version: "1.0.
|
|
1468
|
+
version: "1.0.7",
|
|
1469
1469
|
os: getPlatform()
|
|
1470
1470
|
};
|
|
1471
1471
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1538,12 +1538,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1538
1538
|
);
|
|
1539
1539
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1540
1540
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1541
|
-
const
|
|
1541
|
+
const path17 = body.substring(
|
|
1542
1542
|
startOffset + localJsRenderStartString.length,
|
|
1543
1543
|
pathEndOffset
|
|
1544
1544
|
);
|
|
1545
1545
|
offsetSoFar = pathEndOffset + 1;
|
|
1546
|
-
if (startOffset >= 0 &&
|
|
1546
|
+
if (startOffset >= 0 && path17) {
|
|
1547
1547
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1548
1548
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1549
1549
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1568,7 +1568,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1568
1568
|
result.push({
|
|
1569
1569
|
startOffset,
|
|
1570
1570
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1571
|
-
path:
|
|
1571
|
+
path: path17,
|
|
1572
1572
|
json
|
|
1573
1573
|
});
|
|
1574
1574
|
}
|
|
@@ -1947,9 +1947,9 @@ var customColors = [
|
|
|
1947
1947
|
];
|
|
1948
1948
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1949
1949
|
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;`;
|
|
1950
|
-
var renderLocalError_default = (
|
|
1950
|
+
var renderLocalError_default = (path17, error) => {
|
|
1951
1951
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1952
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1952
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path17}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1953
1953
|
};
|
|
1954
1954
|
|
|
1955
1955
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -3512,18 +3512,18 @@ async function fetchPreviewTemplates(accountId, previewToken) {
|
|
|
3512
3512
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
|
|
3513
3513
|
})).data;
|
|
3514
3514
|
}
|
|
3515
|
-
async function fetchModuleByPath(accountId,
|
|
3515
|
+
async function fetchModuleByPath(accountId, path17) {
|
|
3516
3516
|
return (await hsCliHttp8.get(accountId, {
|
|
3517
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
3517
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path17}?portalId=${accountId}`
|
|
3518
3518
|
})).data;
|
|
3519
3519
|
}
|
|
3520
|
-
async function fetchTemplateByPath(accountId,
|
|
3520
|
+
async function fetchTemplateByPath(accountId, path17) {
|
|
3521
3521
|
return (await hsCliHttp8.get(accountId, {
|
|
3522
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
3522
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path17}?portalId=${accountId}`
|
|
3523
3523
|
})).data;
|
|
3524
3524
|
}
|
|
3525
|
-
async function fetchModulePageDependencies(accountId,
|
|
3526
|
-
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${
|
|
3525
|
+
async function fetchModulePageDependencies(accountId, path17) {
|
|
3526
|
+
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path17}`;
|
|
3527
3527
|
return (await hsCliHttp8.get(accountId, { url: url3 })).data;
|
|
3528
3528
|
}
|
|
3529
3529
|
|
|
@@ -3540,9 +3540,9 @@ function isCodedFile(filePath) {
|
|
|
3540
3540
|
return TEMPLATE_EXTENSION_REGEX.test(filePath);
|
|
3541
3541
|
}
|
|
3542
3542
|
|
|
3543
|
-
// src/routes/
|
|
3543
|
+
// src/routes/legacyRouteHandler.tsx
|
|
3544
3544
|
import { Fragment, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
3545
|
-
var
|
|
3545
|
+
var legacyRouteHandler = async (request2, response, next) => {
|
|
3546
3546
|
const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
|
|
3547
3547
|
if (domainToProxy) {
|
|
3548
3548
|
next();
|
|
@@ -3587,7 +3587,7 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
3587
3587
|
);
|
|
3588
3588
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
3589
3589
|
};
|
|
3590
|
-
var
|
|
3590
|
+
var legacyRouteHandler_default = legacyRouteHandler;
|
|
3591
3591
|
|
|
3592
3592
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
3593
3593
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -4013,8 +4013,61 @@ function buildTemplateIndex() {
|
|
|
4013
4013
|
`);
|
|
4014
4014
|
}
|
|
4015
4015
|
|
|
4016
|
-
// src/routes/
|
|
4016
|
+
// src/routes/createAppServerAPIRoutes.ts
|
|
4017
|
+
import { Router } from "express";
|
|
4018
|
+
import { spawn } from "child_process";
|
|
4019
|
+
function getOpenCommand() {
|
|
4020
|
+
switch (process.platform) {
|
|
4021
|
+
case "darwin":
|
|
4022
|
+
return "open";
|
|
4023
|
+
case "win32":
|
|
4024
|
+
return "start";
|
|
4025
|
+
default:
|
|
4026
|
+
return "xdg-open";
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
async function handleGetModulePages(req, res, next) {
|
|
4030
|
+
const { path: path17, portalId } = req.query;
|
|
4031
|
+
if (!path17 || !portalId) {
|
|
4032
|
+
return res.status(400).json({ error: "Missing required parameters" });
|
|
4033
|
+
}
|
|
4034
|
+
try {
|
|
4035
|
+
sendTrackingRequest("handle-module-dependencies");
|
|
4036
|
+
const data = await fetchModulePageDependencies(
|
|
4037
|
+
Number(portalId),
|
|
4038
|
+
path17
|
|
4039
|
+
);
|
|
4040
|
+
res.json(data);
|
|
4041
|
+
} catch (err) {
|
|
4042
|
+
next(err);
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
function handleOpenFile(req, res, next) {
|
|
4046
|
+
const { path: path17 } = req.query;
|
|
4047
|
+
if (!path17) {
|
|
4048
|
+
return res.status(400).json({ error: "Missing required parameters" });
|
|
4049
|
+
}
|
|
4050
|
+
try {
|
|
4051
|
+
sendTrackingRequest("handle-open-file");
|
|
4052
|
+
const command = getOpenCommand();
|
|
4053
|
+
spawn(command, [path17], { detached: true }).unref();
|
|
4054
|
+
res.sendStatus(200);
|
|
4055
|
+
} catch (err) {
|
|
4056
|
+
next(err);
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
function createAppServerAPIRoutes() {
|
|
4060
|
+
const router = Router();
|
|
4061
|
+
router.get("/module-pages", handleGetModulePages);
|
|
4062
|
+
router.get("/open-file", handleOpenFile);
|
|
4063
|
+
return router;
|
|
4064
|
+
}
|
|
4065
|
+
var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
|
|
4066
|
+
|
|
4067
|
+
// src/routes/appServerRouteHandler.ts
|
|
4017
4068
|
import fs4 from "node:fs/promises";
|
|
4069
|
+
import path12 from "path";
|
|
4070
|
+
import { pathToFileURL } from "url";
|
|
4018
4071
|
|
|
4019
4072
|
// src/lib/getDevServerUIData.ts
|
|
4020
4073
|
import path11 from "path";
|
|
@@ -4052,13 +4105,16 @@ var templateTypeMap = {
|
|
|
4052
4105
|
14: "Backup Unsubscribe",
|
|
4053
4106
|
27: "Search Results"
|
|
4054
4107
|
};
|
|
4055
|
-
function mapReactModules(modules, themeWebRoot,
|
|
4108
|
+
function mapReactModules(modules, themeWebRoot, appViteServer) {
|
|
4056
4109
|
return Promise.all(
|
|
4057
4110
|
modules.moduleNames.map(async (name, index) => {
|
|
4058
4111
|
const modulePath = normalizePath9(
|
|
4059
4112
|
path11.resolve(themeWebRoot, "components/modules/", name)
|
|
4060
4113
|
);
|
|
4061
|
-
const fieldsJson = await renderModuleFieldsJson_default(
|
|
4114
|
+
const fieldsJson = await renderModuleFieldsJson_default(
|
|
4115
|
+
appViteServer,
|
|
4116
|
+
modulePath
|
|
4117
|
+
);
|
|
4062
4118
|
return {
|
|
4063
4119
|
name,
|
|
4064
4120
|
type: "react" /* REACT */,
|
|
@@ -4108,7 +4164,7 @@ function detectPackageManager(projectRoot) {
|
|
|
4108
4164
|
return "pnpm";
|
|
4109
4165
|
return "npm";
|
|
4110
4166
|
}
|
|
4111
|
-
async function getDevServerUIData(
|
|
4167
|
+
async function getDevServerUIData(appLocals) {
|
|
4112
4168
|
const {
|
|
4113
4169
|
themeWebRoot,
|
|
4114
4170
|
authedEnv,
|
|
@@ -4117,8 +4173,9 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4117
4173
|
localPreviewToken,
|
|
4118
4174
|
webRootProjectComponentFolder,
|
|
4119
4175
|
sslEnabled,
|
|
4120
|
-
fieldBuilderEnabled
|
|
4121
|
-
|
|
4176
|
+
fieldBuilderEnabled,
|
|
4177
|
+
appViteServer
|
|
4178
|
+
} = appLocals;
|
|
4122
4179
|
const packageJson = getPackageJson(themeWebRoot);
|
|
4123
4180
|
const packageManager = detectPackageManager(themeWebRoot);
|
|
4124
4181
|
const runCommand = packageManager === "yarn" ? "yarn" : `${packageManager} run`;
|
|
@@ -4134,7 +4191,7 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4134
4191
|
const reactModules = await mapReactModules(
|
|
4135
4192
|
modulesData,
|
|
4136
4193
|
themeWebRoot,
|
|
4137
|
-
|
|
4194
|
+
appViteServer
|
|
4138
4195
|
);
|
|
4139
4196
|
let hubLModuleData = { objects: [] };
|
|
4140
4197
|
let hubLTemplateData = { objects: [] };
|
|
@@ -4165,71 +4222,53 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4165
4222
|
fieldBuilderEnabled
|
|
4166
4223
|
};
|
|
4167
4224
|
}
|
|
4168
|
-
var getDevServerUIData_default = getDevServerUIData;
|
|
4169
4225
|
|
|
4170
|
-
// src/routes/
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
function getOpenCommand() {
|
|
4174
|
-
switch (process.platform) {
|
|
4175
|
-
case "darwin":
|
|
4176
|
-
return "open";
|
|
4177
|
-
case "win32":
|
|
4178
|
-
return "start";
|
|
4179
|
-
default:
|
|
4180
|
-
return "xdg-open";
|
|
4181
|
-
}
|
|
4182
|
-
}
|
|
4183
|
-
async function handleGetModulePages(req, res, next) {
|
|
4184
|
-
const { path: path16, portalId } = req.query;
|
|
4185
|
-
if (!path16 || !portalId) {
|
|
4186
|
-
return res.status(400).json({ error: "Missing required parameters" });
|
|
4187
|
-
}
|
|
4226
|
+
// src/routes/appServerRouteHandler.ts
|
|
4227
|
+
var isProd = true;
|
|
4228
|
+
var appServerRouteHandler = async (req, res, __next) => {
|
|
4188
4229
|
try {
|
|
4189
|
-
sendTrackingRequest("
|
|
4190
|
-
const
|
|
4191
|
-
|
|
4192
|
-
|
|
4230
|
+
sendTrackingRequest("view-index-route");
|
|
4231
|
+
const appLocals = req.app.locals.appLocals;
|
|
4232
|
+
const { appWebRoot, appViteServer } = appLocals;
|
|
4233
|
+
const initialProps = await getDevServerUIData(appLocals);
|
|
4234
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4235
|
+
const templatePath = path12.join(appWebRoot, "index.html");
|
|
4236
|
+
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4237
|
+
let render;
|
|
4238
|
+
let template = await fs4.readFile(path12.join(templatePath), "utf-8");
|
|
4239
|
+
if (isProd) {
|
|
4240
|
+
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
4241
|
+
render = ssrRender;
|
|
4242
|
+
} else {
|
|
4243
|
+
template = await appViteServer.transformIndexHtml(url3, template);
|
|
4244
|
+
render = (await appViteServer.ssrLoadModule(serverEntryPath)).render;
|
|
4245
|
+
}
|
|
4246
|
+
const rendered = await render(initialProps);
|
|
4247
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4248
|
+
`<!--app-script-->`,
|
|
4249
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4250
|
+
initialProps
|
|
4251
|
+
)};</script>` ?? ""
|
|
4193
4252
|
);
|
|
4194
|
-
res.
|
|
4195
|
-
} catch (
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
const { path: path16 } = req.query;
|
|
4201
|
-
if (!path16) {
|
|
4202
|
-
return res.status(400).json({ error: "Missing required parameters" });
|
|
4203
|
-
}
|
|
4204
|
-
try {
|
|
4205
|
-
sendTrackingRequest("handle-open-file");
|
|
4206
|
-
const command = getOpenCommand();
|
|
4207
|
-
spawn(command, [path16], { detached: true }).unref();
|
|
4208
|
-
res.sendStatus(200);
|
|
4209
|
-
} catch (err) {
|
|
4210
|
-
next(err);
|
|
4253
|
+
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4254
|
+
} catch (e) {
|
|
4255
|
+
const { appViteServer } = req.app.locals.appLocals;
|
|
4256
|
+
appViteServer == null ? void 0 : appViteServer.ssrFixStacktrace(e);
|
|
4257
|
+
console.log(e.stack);
|
|
4258
|
+
res.status(500).end(e.stack);
|
|
4211
4259
|
}
|
|
4212
|
-
}
|
|
4213
|
-
|
|
4214
|
-
const router = Router();
|
|
4215
|
-
router.get("/module-pages", handleGetModulePages);
|
|
4216
|
-
router.get("/open-file", handleOpenFile);
|
|
4217
|
-
return router;
|
|
4218
|
-
}
|
|
4219
|
-
var createAppServerRoutes_default = createAppServerRoutes;
|
|
4260
|
+
};
|
|
4261
|
+
var appServerRouteHandler_default = appServerRouteHandler;
|
|
4220
4262
|
|
|
4221
4263
|
// src/routes/createDevServerRoutes.ts
|
|
4222
|
-
import
|
|
4223
|
-
|
|
4224
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
4225
|
-
var __dirname = path12.dirname(__filename);
|
|
4226
|
-
var isProd = true;
|
|
4264
|
+
import path13 from "path";
|
|
4265
|
+
var isProd2 = true;
|
|
4227
4266
|
var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
|
|
4228
4267
|
(domain) => `storybook.${domain}`
|
|
4229
4268
|
);
|
|
4230
|
-
var createDevServerRoutes = async (viteServer,
|
|
4269
|
+
var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
|
|
4231
4270
|
const devServerApp = Router2();
|
|
4232
|
-
const {
|
|
4271
|
+
const { appViteServer, appWebRoot } = appLocals || {};
|
|
4233
4272
|
devServerApp.use((request2, response, next) => {
|
|
4234
4273
|
const { method, url: url3, hostname } = request2;
|
|
4235
4274
|
debug(`${method}:${hostname}${url3}`);
|
|
@@ -4247,46 +4286,20 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4247
4286
|
);
|
|
4248
4287
|
}
|
|
4249
4288
|
devServerApp.use(urlencoded());
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
const distAssetsPath = path12.join(appWebRoot, "assets");
|
|
4289
|
+
if (isProd2) {
|
|
4290
|
+
const distAssetsPath = path13.join(appWebRoot, "assets");
|
|
4253
4291
|
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4254
4292
|
} else {
|
|
4255
|
-
devServerApp.use(
|
|
4293
|
+
devServerApp.use(appViteServer.middlewares);
|
|
4256
4294
|
}
|
|
4257
4295
|
devServerApp.use(viteServer.middlewares);
|
|
4258
|
-
devServerApp.use("/api",
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4266
|
-
let render;
|
|
4267
|
-
let template = await fs4.readFile(path12.join(templatePath), "utf-8");
|
|
4268
|
-
if (isProd) {
|
|
4269
|
-
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
4270
|
-
render = ssrRender;
|
|
4271
|
-
} else {
|
|
4272
|
-
template = await appServer.transformIndexHtml(url3, template);
|
|
4273
|
-
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
4274
|
-
}
|
|
4275
|
-
const rendered = await render(initialProps);
|
|
4276
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4277
|
-
`<!--app-script-->`,
|
|
4278
|
-
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4279
|
-
initialProps
|
|
4280
|
-
)};</script>` ?? ""
|
|
4281
|
-
);
|
|
4282
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4283
|
-
} catch (e) {
|
|
4284
|
-
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
4285
|
-
console.log(e.stack);
|
|
4286
|
-
res.status(500).end(e.stack);
|
|
4287
|
-
}
|
|
4288
|
-
});
|
|
4289
|
-
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
4296
|
+
devServerApp.use("/api", createAppServerAPIRoutes_default());
|
|
4297
|
+
if (appLocals.projectName) {
|
|
4298
|
+
devServerApp.get("/", appServerRouteHandler_default);
|
|
4299
|
+
devServerApp.get("/legacy", legacyRouteHandler_default);
|
|
4300
|
+
} else {
|
|
4301
|
+
devServerApp.get("/", legacyRouteHandler_default);
|
|
4302
|
+
}
|
|
4290
4303
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
4291
4304
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
4292
4305
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -4639,7 +4652,7 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
4639
4652
|
}
|
|
4640
4653
|
|
|
4641
4654
|
// src/lib/validateHSPlatform.ts
|
|
4642
|
-
import
|
|
4655
|
+
import path14 from "path";
|
|
4643
4656
|
import fs5 from "fs";
|
|
4644
4657
|
import select from "@inquirer/select";
|
|
4645
4658
|
import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
|
|
@@ -4651,12 +4664,12 @@ function findHSProjectJson(startPath) {
|
|
|
4651
4664
|
let currentDir = startPath;
|
|
4652
4665
|
let dirLevel = 0;
|
|
4653
4666
|
const maxDirLevel = 4;
|
|
4654
|
-
while (
|
|
4655
|
-
const filePath =
|
|
4667
|
+
while (path14.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
4668
|
+
const filePath = path14.join(currentDir, HSPROJECT_JSON);
|
|
4656
4669
|
if (checkFileExists(filePath)) {
|
|
4657
4670
|
return filePath;
|
|
4658
4671
|
}
|
|
4659
|
-
currentDir =
|
|
4672
|
+
currentDir = path14.dirname(currentDir);
|
|
4660
4673
|
dirLevel++;
|
|
4661
4674
|
}
|
|
4662
4675
|
console.log(
|
|
@@ -4962,7 +4975,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
4962
4975
|
|
|
4963
4976
|
// src/lib/watchFieldsUpdates.ts
|
|
4964
4977
|
import fs6 from "fs";
|
|
4965
|
-
import
|
|
4978
|
+
import path15 from "path";
|
|
4966
4979
|
import readline from "readline";
|
|
4967
4980
|
var lastSerializedFieldsCache = {};
|
|
4968
4981
|
var formatAsTypeName = (str) => {
|
|
@@ -4974,9 +4987,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
4974
4987
|
const getEntryPathFromId = (id) => {
|
|
4975
4988
|
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
|
|
4976
4989
|
};
|
|
4977
|
-
const currentModuleId =
|
|
4990
|
+
const currentModuleId = path15.normalize(filePath);
|
|
4978
4991
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
4979
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
4992
|
+
const subFolderTokens = moduleEntryPath.split(path15.sep);
|
|
4980
4993
|
return {
|
|
4981
4994
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
4982
4995
|
isRootModuleFile: subFolderTokens.length === 3
|
|
@@ -5003,10 +5016,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5003
5016
|
return void 0;
|
|
5004
5017
|
if (isRootModuleFile)
|
|
5005
5018
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5006
|
-
const dir =
|
|
5019
|
+
const dir = path15.dirname(filePath);
|
|
5007
5020
|
const files = fs6.readdirSync(dir);
|
|
5008
5021
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5009
|
-
return indexFileName ? { indexFilePath:
|
|
5022
|
+
return indexFileName ? { indexFilePath: path15.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5010
5023
|
};
|
|
5011
5024
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
5012
5025
|
let indexFile;
|
|
@@ -5030,7 +5043,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5030
5043
|
if (!indexInfo)
|
|
5031
5044
|
return;
|
|
5032
5045
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
5033
|
-
const indexFileName =
|
|
5046
|
+
const indexFileName = path15.parse(indexFilePath).name;
|
|
5034
5047
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
5035
5048
|
if (isTypeFile)
|
|
5036
5049
|
return;
|
|
@@ -5041,7 +5054,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5041
5054
|
);
|
|
5042
5055
|
if (fields) {
|
|
5043
5056
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
5044
|
-
const typeFilePath =
|
|
5057
|
+
const typeFilePath = path15.join(path15.dirname(filePath), typeFileName);
|
|
5045
5058
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
5046
5059
|
const serializedFields = JSON.stringify(fields);
|
|
5047
5060
|
if (lastSerializedFields === serializedFields)
|
|
@@ -5049,7 +5062,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5049
5062
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
5050
5063
|
if (!hasAutoGenComment)
|
|
5051
5064
|
return;
|
|
5052
|
-
const moduleFolderName =
|
|
5065
|
+
const moduleFolderName = path15.basename(path15.dirname(filePath));
|
|
5053
5066
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
5054
5067
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
5055
5068
|
if (didSucceed) {
|
|
@@ -5065,7 +5078,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5065
5078
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
5066
5079
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
5067
5080
|
moduleSubpaths.forEach((modulePath) => {
|
|
5068
|
-
const resolvedPath =
|
|
5081
|
+
const resolvedPath = path15.resolve(projectRoot, modulePath);
|
|
5069
5082
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
5070
5083
|
});
|
|
5071
5084
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -5203,7 +5216,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5203
5216
|
} catch (e) {
|
|
5204
5217
|
authedHublet = "na1";
|
|
5205
5218
|
}
|
|
5206
|
-
const absoluteWebRoot = normalizePath10(
|
|
5219
|
+
const absoluteWebRoot = normalizePath10(path16.resolve(process.cwd(), webRoot));
|
|
5207
5220
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
5208
5221
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
5209
5222
|
if (authedPortalId) {
|
|
@@ -5255,9 +5268,17 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5255
5268
|
expressServer.locals.domainsToProxy = domainsToProxy;
|
|
5256
5269
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5257
5270
|
expressServer.use(bodyParser.json());
|
|
5258
|
-
const
|
|
5259
|
-
|
|
5260
|
-
|
|
5271
|
+
const __dirname = path16.dirname(url2.fileURLToPath(new URL(import.meta.url)));
|
|
5272
|
+
let appWebRoot = normalizePath10(path16.resolve(__dirname, "../app"));
|
|
5273
|
+
if (true) {
|
|
5274
|
+
appWebRoot = path16.join(__dirname, "app");
|
|
5275
|
+
}
|
|
5276
|
+
const appViteServer = await createAppServer_default(
|
|
5277
|
+
appWebRoot,
|
|
5278
|
+
PORT,
|
|
5279
|
+
sslEnabledOption
|
|
5280
|
+
);
|
|
5281
|
+
const appLocals = {
|
|
5261
5282
|
themeWebRoot: absoluteWebRoot,
|
|
5262
5283
|
authedPortalId,
|
|
5263
5284
|
authedEnv,
|
|
@@ -5266,24 +5287,17 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5266
5287
|
webRootProjectComponentFolder,
|
|
5267
5288
|
localPreviewToken: _localPreviewToken,
|
|
5268
5289
|
sslEnabled: sslEnabledOption,
|
|
5269
|
-
fieldBuilderEnabled
|
|
5270
|
-
};
|
|
5271
|
-
const appServer = await createAppServer_default(
|
|
5290
|
+
fieldBuilderEnabled,
|
|
5272
5291
|
appWebRoot,
|
|
5273
|
-
|
|
5274
|
-
sslEnabledOption
|
|
5275
|
-
);
|
|
5276
|
-
const appServerConfig = {
|
|
5277
|
-
appServer,
|
|
5278
|
-
reqLocals,
|
|
5279
|
-
appWebRoot
|
|
5292
|
+
appViteServer
|
|
5280
5293
|
};
|
|
5294
|
+
expressServer.locals.appLocals = appLocals;
|
|
5281
5295
|
expressServer.use(
|
|
5282
5296
|
BASE_PATH,
|
|
5283
5297
|
await createDevServerRoutes_default(
|
|
5284
5298
|
viteServer,
|
|
5285
|
-
|
|
5286
|
-
|
|
5299
|
+
appLocals,
|
|
5300
|
+
storybook ? STORYBOOK_PORT : null
|
|
5287
5301
|
)
|
|
5288
5302
|
);
|
|
5289
5303
|
if (sslEnabledOption) {
|
|
@@ -5326,8 +5340,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5326
5340
|
`
|
|
5327
5341
|
);
|
|
5328
5342
|
if (storybook) {
|
|
5329
|
-
const packageRoot =
|
|
5330
|
-
const configPath =
|
|
5343
|
+
const packageRoot = path16.dirname(url2.fileURLToPath(import.meta.url));
|
|
5344
|
+
const configPath = path16.resolve(packageRoot, "./storybook-main");
|
|
5331
5345
|
sendTrackingRequest("start-storybook");
|
|
5332
5346
|
const storybookProcess = spawn2(
|
|
5333
5347
|
"sb",
|
|
@@ -5347,7 +5361,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5347
5361
|
portalId: authedPortalId.toString(),
|
|
5348
5362
|
hsEnv: authedEnv,
|
|
5349
5363
|
hublet: authedHublet,
|
|
5350
|
-
WEB_ROOT:
|
|
5364
|
+
WEB_ROOT: path16.join(webRoot, "components")
|
|
5351
5365
|
}
|
|
5352
5366
|
}
|
|
5353
5367
|
);
|
package/dist/run.js
CHANGED
|
@@ -758,7 +758,7 @@ async function buildThemePreviewOptions(webRoot2, isUsingLocalWorkspace = false)
|
|
|
758
758
|
}
|
|
759
759
|
|
|
760
760
|
// src/createDevServer.ts
|
|
761
|
-
import
|
|
761
|
+
import path17 from "path";
|
|
762
762
|
import url2 from "url";
|
|
763
763
|
import express2 from "express";
|
|
764
764
|
import http3 from "http";
|
|
@@ -1405,8 +1405,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
1405
1405
|
);
|
|
1406
1406
|
return Object.fromEntries(relativeEntries);
|
|
1407
1407
|
}
|
|
1408
|
-
function toRelativePath(config,
|
|
1409
|
-
return
|
|
1408
|
+
function toRelativePath(config, path18) {
|
|
1409
|
+
return path18.replace(`${config.root}/`, "");
|
|
1410
1410
|
}
|
|
1411
1411
|
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
1412
1412
|
const [fileId, __] = moduleInfo.id.split("?");
|
|
@@ -1449,11 +1449,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1449
1449
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
1450
1450
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
1451
1451
|
traverse(sourceAst, {
|
|
1452
|
-
ImportDeclaration(
|
|
1453
|
-
if (t.isStringLiteral(
|
|
1452
|
+
ImportDeclaration(path18) {
|
|
1453
|
+
if (t.isStringLiteral(path18.node.source, {
|
|
1454
1454
|
value: "@hubspot/cms-components"
|
|
1455
1455
|
})) {
|
|
1456
|
-
for (const specifier of
|
|
1456
|
+
for (const specifier of path18.node.specifiers) {
|
|
1457
1457
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
1458
1458
|
name: CMS_MODULE_COMPONENT_NAME
|
|
1459
1459
|
})) {
|
|
@@ -1467,14 +1467,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
1469
|
},
|
|
1470
|
-
JSXOpeningElement(
|
|
1471
|
-
if (t.isJSXIdentifier(
|
|
1470
|
+
JSXOpeningElement(path18) {
|
|
1471
|
+
if (t.isJSXIdentifier(path18.node.name, {
|
|
1472
1472
|
name: moduleComponentLocalImportName
|
|
1473
1473
|
})) {
|
|
1474
1474
|
let cmsModuleName;
|
|
1475
1475
|
let cmsModulePath;
|
|
1476
1476
|
let cmsModuleLabel;
|
|
1477
|
-
for (const prop of
|
|
1477
|
+
for (const prop of path18.node.attributes) {
|
|
1478
1478
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1479
1479
|
cmsModuleName = prop.value.value;
|
|
1480
1480
|
continue;
|
|
@@ -1509,11 +1509,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1509
1509
|
}
|
|
1510
1510
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
1511
1511
|
}
|
|
1512
|
-
if (t.isJSXIdentifier(
|
|
1512
|
+
if (t.isJSXIdentifier(path18.node.name, {
|
|
1513
1513
|
name: dndAreaComponentLocalImportName
|
|
1514
1514
|
})) {
|
|
1515
1515
|
let dndAreaName;
|
|
1516
|
-
for (const prop of
|
|
1516
|
+
for (const prop of path18.node.attributes) {
|
|
1517
1517
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1518
1518
|
dndAreaName = prop.value.value;
|
|
1519
1519
|
continue;
|
|
@@ -2097,7 +2097,7 @@ function trackUsage(action) {
|
|
|
2097
2097
|
eventName: EVENT_NAME,
|
|
2098
2098
|
action,
|
|
2099
2099
|
nodeVersion: getNodeVersionData(),
|
|
2100
|
-
version: "1.0.
|
|
2100
|
+
version: "1.0.7",
|
|
2101
2101
|
os: getPlatform()
|
|
2102
2102
|
};
|
|
2103
2103
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -2170,12 +2170,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2170
2170
|
);
|
|
2171
2171
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
2172
2172
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
2173
|
-
const
|
|
2173
|
+
const path18 = body.substring(
|
|
2174
2174
|
startOffset + localJsRenderStartString.length,
|
|
2175
2175
|
pathEndOffset
|
|
2176
2176
|
);
|
|
2177
2177
|
offsetSoFar = pathEndOffset + 1;
|
|
2178
|
-
if (startOffset >= 0 &&
|
|
2178
|
+
if (startOffset >= 0 && path18) {
|
|
2179
2179
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
2180
2180
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
2181
2181
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -2200,7 +2200,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2200
2200
|
result.push({
|
|
2201
2201
|
startOffset,
|
|
2202
2202
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
2203
|
-
path:
|
|
2203
|
+
path: path18,
|
|
2204
2204
|
json
|
|
2205
2205
|
});
|
|
2206
2206
|
}
|
|
@@ -2579,9 +2579,9 @@ var customColors = [
|
|
|
2579
2579
|
];
|
|
2580
2580
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
2581
2581
|
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;`;
|
|
2582
|
-
var renderLocalError_default = (
|
|
2582
|
+
var renderLocalError_default = (path18, error) => {
|
|
2583
2583
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
2584
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
2584
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path18}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
2585
2585
|
};
|
|
2586
2586
|
|
|
2587
2587
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -4144,18 +4144,18 @@ async function fetchPreviewTemplates(accountId, previewToken) {
|
|
|
4144
4144
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
|
|
4145
4145
|
})).data;
|
|
4146
4146
|
}
|
|
4147
|
-
async function fetchModuleByPath(accountId,
|
|
4147
|
+
async function fetchModuleByPath(accountId, path18) {
|
|
4148
4148
|
return (await hsCliHttp8.get(accountId, {
|
|
4149
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
4149
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path18}?portalId=${accountId}`
|
|
4150
4150
|
})).data;
|
|
4151
4151
|
}
|
|
4152
|
-
async function fetchTemplateByPath(accountId,
|
|
4152
|
+
async function fetchTemplateByPath(accountId, path18) {
|
|
4153
4153
|
return (await hsCliHttp8.get(accountId, {
|
|
4154
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
4154
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path18}?portalId=${accountId}`
|
|
4155
4155
|
})).data;
|
|
4156
4156
|
}
|
|
4157
|
-
async function fetchModulePageDependencies(accountId,
|
|
4158
|
-
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${
|
|
4157
|
+
async function fetchModulePageDependencies(accountId, path18) {
|
|
4158
|
+
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path18}`;
|
|
4159
4159
|
return (await hsCliHttp8.get(accountId, { url: url3 })).data;
|
|
4160
4160
|
}
|
|
4161
4161
|
|
|
@@ -4172,9 +4172,9 @@ function isCodedFile(filePath) {
|
|
|
4172
4172
|
return TEMPLATE_EXTENSION_REGEX.test(filePath);
|
|
4173
4173
|
}
|
|
4174
4174
|
|
|
4175
|
-
// src/routes/
|
|
4175
|
+
// src/routes/legacyRouteHandler.tsx
|
|
4176
4176
|
import { Fragment, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4177
|
-
var
|
|
4177
|
+
var legacyRouteHandler = async (request2, response, next) => {
|
|
4178
4178
|
const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
|
|
4179
4179
|
if (domainToProxy) {
|
|
4180
4180
|
next();
|
|
@@ -4219,7 +4219,7 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
4219
4219
|
);
|
|
4220
4220
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
4221
4221
|
};
|
|
4222
|
-
var
|
|
4222
|
+
var legacyRouteHandler_default = legacyRouteHandler;
|
|
4223
4223
|
|
|
4224
4224
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
4225
4225
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -4645,8 +4645,61 @@ function buildTemplateIndex() {
|
|
|
4645
4645
|
`);
|
|
4646
4646
|
}
|
|
4647
4647
|
|
|
4648
|
-
// src/routes/
|
|
4648
|
+
// src/routes/createAppServerAPIRoutes.ts
|
|
4649
|
+
import { Router } from "express";
|
|
4650
|
+
import { spawn } from "child_process";
|
|
4651
|
+
function getOpenCommand() {
|
|
4652
|
+
switch (process.platform) {
|
|
4653
|
+
case "darwin":
|
|
4654
|
+
return "open";
|
|
4655
|
+
case "win32":
|
|
4656
|
+
return "start";
|
|
4657
|
+
default:
|
|
4658
|
+
return "xdg-open";
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
async function handleGetModulePages(req, res, next) {
|
|
4662
|
+
const { path: path18, portalId } = req.query;
|
|
4663
|
+
if (!path18 || !portalId) {
|
|
4664
|
+
return res.status(400).json({ error: "Missing required parameters" });
|
|
4665
|
+
}
|
|
4666
|
+
try {
|
|
4667
|
+
sendTrackingRequest("handle-module-dependencies");
|
|
4668
|
+
const data = await fetchModulePageDependencies(
|
|
4669
|
+
Number(portalId),
|
|
4670
|
+
path18
|
|
4671
|
+
);
|
|
4672
|
+
res.json(data);
|
|
4673
|
+
} catch (err) {
|
|
4674
|
+
next(err);
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
function handleOpenFile(req, res, next) {
|
|
4678
|
+
const { path: path18 } = req.query;
|
|
4679
|
+
if (!path18) {
|
|
4680
|
+
return res.status(400).json({ error: "Missing required parameters" });
|
|
4681
|
+
}
|
|
4682
|
+
try {
|
|
4683
|
+
sendTrackingRequest("handle-open-file");
|
|
4684
|
+
const command = getOpenCommand();
|
|
4685
|
+
spawn(command, [path18], { detached: true }).unref();
|
|
4686
|
+
res.sendStatus(200);
|
|
4687
|
+
} catch (err) {
|
|
4688
|
+
next(err);
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
function createAppServerAPIRoutes() {
|
|
4692
|
+
const router = Router();
|
|
4693
|
+
router.get("/module-pages", handleGetModulePages);
|
|
4694
|
+
router.get("/open-file", handleOpenFile);
|
|
4695
|
+
return router;
|
|
4696
|
+
}
|
|
4697
|
+
var createAppServerAPIRoutes_default = createAppServerAPIRoutes;
|
|
4698
|
+
|
|
4699
|
+
// src/routes/appServerRouteHandler.ts
|
|
4649
4700
|
import fs5 from "node:fs/promises";
|
|
4701
|
+
import path13 from "path";
|
|
4702
|
+
import { pathToFileURL } from "url";
|
|
4650
4703
|
|
|
4651
4704
|
// src/lib/getDevServerUIData.ts
|
|
4652
4705
|
import path12 from "path";
|
|
@@ -4792,13 +4845,16 @@ var templateTypeMap = {
|
|
|
4792
4845
|
14: "Backup Unsubscribe",
|
|
4793
4846
|
27: "Search Results"
|
|
4794
4847
|
};
|
|
4795
|
-
function mapReactModules(modules, themeWebRoot,
|
|
4848
|
+
function mapReactModules(modules, themeWebRoot, appViteServer) {
|
|
4796
4849
|
return Promise.all(
|
|
4797
4850
|
modules.moduleNames.map(async (name, index) => {
|
|
4798
4851
|
const modulePath = normalizePath9(
|
|
4799
4852
|
path12.resolve(themeWebRoot, "components/modules/", name)
|
|
4800
4853
|
);
|
|
4801
|
-
const fieldsJson = await renderModuleFieldsJson_default(
|
|
4854
|
+
const fieldsJson = await renderModuleFieldsJson_default(
|
|
4855
|
+
appViteServer,
|
|
4856
|
+
modulePath
|
|
4857
|
+
);
|
|
4802
4858
|
return {
|
|
4803
4859
|
name,
|
|
4804
4860
|
type: "react" /* REACT */,
|
|
@@ -4848,7 +4904,7 @@ function detectPackageManager(projectRoot) {
|
|
|
4848
4904
|
return "pnpm";
|
|
4849
4905
|
return "npm";
|
|
4850
4906
|
}
|
|
4851
|
-
async function getDevServerUIData(
|
|
4907
|
+
async function getDevServerUIData(appLocals) {
|
|
4852
4908
|
const {
|
|
4853
4909
|
themeWebRoot,
|
|
4854
4910
|
authedEnv,
|
|
@@ -4857,8 +4913,9 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4857
4913
|
localPreviewToken,
|
|
4858
4914
|
webRootProjectComponentFolder,
|
|
4859
4915
|
sslEnabled,
|
|
4860
|
-
fieldBuilderEnabled: fieldBuilderEnabled2
|
|
4861
|
-
|
|
4916
|
+
fieldBuilderEnabled: fieldBuilderEnabled2,
|
|
4917
|
+
appViteServer
|
|
4918
|
+
} = appLocals;
|
|
4862
4919
|
const packageJson = getPackageJson(themeWebRoot);
|
|
4863
4920
|
const packageManager = detectPackageManager(themeWebRoot);
|
|
4864
4921
|
const runCommand = packageManager === "yarn" ? "yarn" : `${packageManager} run`;
|
|
@@ -4874,7 +4931,7 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4874
4931
|
const reactModules = await mapReactModules(
|
|
4875
4932
|
modulesData,
|
|
4876
4933
|
themeWebRoot,
|
|
4877
|
-
|
|
4934
|
+
appViteServer
|
|
4878
4935
|
);
|
|
4879
4936
|
let hubLModuleData = { objects: [] };
|
|
4880
4937
|
let hubLTemplateData = { objects: [] };
|
|
@@ -4905,71 +4962,53 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4905
4962
|
fieldBuilderEnabled: fieldBuilderEnabled2
|
|
4906
4963
|
};
|
|
4907
4964
|
}
|
|
4908
|
-
var getDevServerUIData_default = getDevServerUIData;
|
|
4909
4965
|
|
|
4910
|
-
// src/routes/
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
function getOpenCommand() {
|
|
4914
|
-
switch (process.platform) {
|
|
4915
|
-
case "darwin":
|
|
4916
|
-
return "open";
|
|
4917
|
-
case "win32":
|
|
4918
|
-
return "start";
|
|
4919
|
-
default:
|
|
4920
|
-
return "xdg-open";
|
|
4921
|
-
}
|
|
4922
|
-
}
|
|
4923
|
-
async function handleGetModulePages(req, res, next) {
|
|
4924
|
-
const { path: path17, portalId } = req.query;
|
|
4925
|
-
if (!path17 || !portalId) {
|
|
4926
|
-
return res.status(400).json({ error: "Missing required parameters" });
|
|
4927
|
-
}
|
|
4966
|
+
// src/routes/appServerRouteHandler.ts
|
|
4967
|
+
var isProd = true;
|
|
4968
|
+
var appServerRouteHandler = async (req, res, __next) => {
|
|
4928
4969
|
try {
|
|
4929
|
-
sendTrackingRequest("
|
|
4930
|
-
const
|
|
4931
|
-
|
|
4932
|
-
|
|
4970
|
+
sendTrackingRequest("view-index-route");
|
|
4971
|
+
const appLocals = req.app.locals.appLocals;
|
|
4972
|
+
const { appWebRoot, appViteServer } = appLocals;
|
|
4973
|
+
const initialProps = await getDevServerUIData(appLocals);
|
|
4974
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4975
|
+
const templatePath = path13.join(appWebRoot, "index.html");
|
|
4976
|
+
const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
|
|
4977
|
+
let render;
|
|
4978
|
+
let template = await fs5.readFile(path13.join(templatePath), "utf-8");
|
|
4979
|
+
if (isProd) {
|
|
4980
|
+
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
4981
|
+
render = ssrRender;
|
|
4982
|
+
} else {
|
|
4983
|
+
template = await appViteServer.transformIndexHtml(url3, template);
|
|
4984
|
+
render = (await appViteServer.ssrLoadModule(serverEntryPath)).render;
|
|
4985
|
+
}
|
|
4986
|
+
const rendered = await render(initialProps);
|
|
4987
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4988
|
+
`<!--app-script-->`,
|
|
4989
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4990
|
+
initialProps
|
|
4991
|
+
)};</script>` ?? ""
|
|
4933
4992
|
);
|
|
4934
|
-
res.
|
|
4935
|
-
} catch (
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
const { path: path17 } = req.query;
|
|
4941
|
-
if (!path17) {
|
|
4942
|
-
return res.status(400).json({ error: "Missing required parameters" });
|
|
4943
|
-
}
|
|
4944
|
-
try {
|
|
4945
|
-
sendTrackingRequest("handle-open-file");
|
|
4946
|
-
const command = getOpenCommand();
|
|
4947
|
-
spawn(command, [path17], { detached: true }).unref();
|
|
4948
|
-
res.sendStatus(200);
|
|
4949
|
-
} catch (err) {
|
|
4950
|
-
next(err);
|
|
4993
|
+
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4994
|
+
} catch (e) {
|
|
4995
|
+
const { appViteServer } = req.app.locals.appLocals;
|
|
4996
|
+
appViteServer == null ? void 0 : appViteServer.ssrFixStacktrace(e);
|
|
4997
|
+
console.log(e.stack);
|
|
4998
|
+
res.status(500).end(e.stack);
|
|
4951
4999
|
}
|
|
4952
|
-
}
|
|
4953
|
-
|
|
4954
|
-
const router = Router();
|
|
4955
|
-
router.get("/module-pages", handleGetModulePages);
|
|
4956
|
-
router.get("/open-file", handleOpenFile);
|
|
4957
|
-
return router;
|
|
4958
|
-
}
|
|
4959
|
-
var createAppServerRoutes_default = createAppServerRoutes;
|
|
5000
|
+
};
|
|
5001
|
+
var appServerRouteHandler_default = appServerRouteHandler;
|
|
4960
5002
|
|
|
4961
5003
|
// src/routes/createDevServerRoutes.ts
|
|
4962
|
-
import
|
|
4963
|
-
|
|
4964
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
4965
|
-
var __dirname = path13.dirname(__filename);
|
|
4966
|
-
var isProd = true;
|
|
5004
|
+
import path14 from "path";
|
|
5005
|
+
var isProd2 = true;
|
|
4967
5006
|
var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
|
|
4968
5007
|
(domain2) => `storybook.${domain2}`
|
|
4969
5008
|
);
|
|
4970
|
-
var createDevServerRoutes = async (viteServer,
|
|
5009
|
+
var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
|
|
4971
5010
|
const devServerApp = Router2();
|
|
4972
|
-
const {
|
|
5011
|
+
const { appViteServer, appWebRoot } = appLocals || {};
|
|
4973
5012
|
devServerApp.use((request2, response, next) => {
|
|
4974
5013
|
const { method, url: url3, hostname } = request2;
|
|
4975
5014
|
debug(`${method}:${hostname}${url3}`);
|
|
@@ -4987,46 +5026,20 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4987
5026
|
);
|
|
4988
5027
|
}
|
|
4989
5028
|
devServerApp.use(urlencoded());
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
const distAssetsPath = path13.join(appWebRoot, "assets");
|
|
5029
|
+
if (isProd2) {
|
|
5030
|
+
const distAssetsPath = path14.join(appWebRoot, "assets");
|
|
4993
5031
|
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4994
5032
|
} else {
|
|
4995
|
-
devServerApp.use(
|
|
5033
|
+
devServerApp.use(appViteServer.middlewares);
|
|
4996
5034
|
}
|
|
4997
5035
|
devServerApp.use(viteServer.middlewares);
|
|
4998
|
-
devServerApp.use("/api",
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
|
|
5006
|
-
let render;
|
|
5007
|
-
let template = await fs5.readFile(path13.join(templatePath), "utf-8");
|
|
5008
|
-
if (isProd) {
|
|
5009
|
-
const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
|
|
5010
|
-
render = ssrRender;
|
|
5011
|
-
} else {
|
|
5012
|
-
template = await appServer.transformIndexHtml(url3, template);
|
|
5013
|
-
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
5014
|
-
}
|
|
5015
|
-
const rendered = await render(initialProps);
|
|
5016
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
5017
|
-
`<!--app-script-->`,
|
|
5018
|
-
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
5019
|
-
initialProps
|
|
5020
|
-
)};</script>` ?? ""
|
|
5021
|
-
);
|
|
5022
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
5023
|
-
} catch (e) {
|
|
5024
|
-
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
5025
|
-
console.log(e.stack);
|
|
5026
|
-
res.status(500).end(e.stack);
|
|
5027
|
-
}
|
|
5028
|
-
});
|
|
5029
|
-
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
5036
|
+
devServerApp.use("/api", createAppServerAPIRoutes_default());
|
|
5037
|
+
if (appLocals.projectName) {
|
|
5038
|
+
devServerApp.get("/", appServerRouteHandler_default);
|
|
5039
|
+
devServerApp.get("/legacy", legacyRouteHandler_default);
|
|
5040
|
+
} else {
|
|
5041
|
+
devServerApp.get("/", legacyRouteHandler_default);
|
|
5042
|
+
}
|
|
5030
5043
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
5031
5044
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
5032
5045
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -5379,7 +5392,7 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5379
5392
|
}
|
|
5380
5393
|
|
|
5381
5394
|
// src/lib/validateHSPlatform.ts
|
|
5382
|
-
import
|
|
5395
|
+
import path15 from "path";
|
|
5383
5396
|
import fs6 from "fs";
|
|
5384
5397
|
import select from "@inquirer/select";
|
|
5385
5398
|
import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
|
|
@@ -5391,12 +5404,12 @@ function findHSProjectJson(startPath) {
|
|
|
5391
5404
|
let currentDir = startPath;
|
|
5392
5405
|
let dirLevel = 0;
|
|
5393
5406
|
const maxDirLevel = 4;
|
|
5394
|
-
while (
|
|
5395
|
-
const filePath =
|
|
5407
|
+
while (path15.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
5408
|
+
const filePath = path15.join(currentDir, HSPROJECT_JSON);
|
|
5396
5409
|
if (checkFileExists(filePath)) {
|
|
5397
5410
|
return filePath;
|
|
5398
5411
|
}
|
|
5399
|
-
currentDir =
|
|
5412
|
+
currentDir = path15.dirname(currentDir);
|
|
5400
5413
|
dirLevel++;
|
|
5401
5414
|
}
|
|
5402
5415
|
console.log(
|
|
@@ -5702,7 +5715,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5702
5715
|
|
|
5703
5716
|
// src/lib/watchFieldsUpdates.ts
|
|
5704
5717
|
import fs7 from "fs";
|
|
5705
|
-
import
|
|
5718
|
+
import path16 from "path";
|
|
5706
5719
|
import readline from "readline";
|
|
5707
5720
|
var lastSerializedFieldsCache = {};
|
|
5708
5721
|
var formatAsTypeName = (str) => {
|
|
@@ -5714,9 +5727,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
5714
5727
|
const getEntryPathFromId = (id) => {
|
|
5715
5728
|
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
|
|
5716
5729
|
};
|
|
5717
|
-
const currentModuleId =
|
|
5730
|
+
const currentModuleId = path16.normalize(filePath);
|
|
5718
5731
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
5719
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
5732
|
+
const subFolderTokens = moduleEntryPath.split(path16.sep);
|
|
5720
5733
|
return {
|
|
5721
5734
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
5722
5735
|
isRootModuleFile: subFolderTokens.length === 3
|
|
@@ -5743,10 +5756,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5743
5756
|
return void 0;
|
|
5744
5757
|
if (isRootModuleFile)
|
|
5745
5758
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5746
|
-
const dir =
|
|
5759
|
+
const dir = path16.dirname(filePath);
|
|
5747
5760
|
const files = fs7.readdirSync(dir);
|
|
5748
5761
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5749
|
-
return indexFileName ? { indexFilePath:
|
|
5762
|
+
return indexFileName ? { indexFilePath: path16.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5750
5763
|
};
|
|
5751
5764
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
5752
5765
|
let indexFile;
|
|
@@ -5770,7 +5783,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5770
5783
|
if (!indexInfo)
|
|
5771
5784
|
return;
|
|
5772
5785
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
5773
|
-
const indexFileName =
|
|
5786
|
+
const indexFileName = path16.parse(indexFilePath).name;
|
|
5774
5787
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
5775
5788
|
if (isTypeFile)
|
|
5776
5789
|
return;
|
|
@@ -5781,7 +5794,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5781
5794
|
);
|
|
5782
5795
|
if (fields) {
|
|
5783
5796
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
5784
|
-
const typeFilePath =
|
|
5797
|
+
const typeFilePath = path16.join(path16.dirname(filePath), typeFileName);
|
|
5785
5798
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
5786
5799
|
const serializedFields = JSON.stringify(fields);
|
|
5787
5800
|
if (lastSerializedFields === serializedFields)
|
|
@@ -5789,7 +5802,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5789
5802
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
5790
5803
|
if (!hasAutoGenComment)
|
|
5791
5804
|
return;
|
|
5792
|
-
const moduleFolderName =
|
|
5805
|
+
const moduleFolderName = path16.basename(path16.dirname(filePath));
|
|
5793
5806
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
5794
5807
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
5795
5808
|
if (didSucceed) {
|
|
@@ -5805,7 +5818,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5805
5818
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
5806
5819
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
5807
5820
|
moduleSubpaths.forEach((modulePath) => {
|
|
5808
|
-
const resolvedPath =
|
|
5821
|
+
const resolvedPath = path16.resolve(projectRoot, modulePath);
|
|
5809
5822
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
5810
5823
|
});
|
|
5811
5824
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -5943,7 +5956,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5943
5956
|
} catch (e) {
|
|
5944
5957
|
authedHublet = "na1";
|
|
5945
5958
|
}
|
|
5946
|
-
const absoluteWebRoot = normalizePath10(
|
|
5959
|
+
const absoluteWebRoot = normalizePath10(path17.resolve(process.cwd(), webRoot2));
|
|
5947
5960
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
5948
5961
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
5949
5962
|
if (authedPortalId) {
|
|
@@ -5995,9 +6008,17 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5995
6008
|
expressServer.locals.domainsToProxy = domainsToProxy;
|
|
5996
6009
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5997
6010
|
expressServer.use(bodyParser.json());
|
|
5998
|
-
const
|
|
5999
|
-
|
|
6000
|
-
|
|
6011
|
+
const __dirname = path17.dirname(url2.fileURLToPath(new URL(import.meta.url)));
|
|
6012
|
+
let appWebRoot = normalizePath10(path17.resolve(__dirname, "../app"));
|
|
6013
|
+
if (true) {
|
|
6014
|
+
appWebRoot = path17.join(__dirname, "app");
|
|
6015
|
+
}
|
|
6016
|
+
const appViteServer = await createAppServer_default(
|
|
6017
|
+
appWebRoot,
|
|
6018
|
+
PORT,
|
|
6019
|
+
sslEnabledOption2
|
|
6020
|
+
);
|
|
6021
|
+
const appLocals = {
|
|
6001
6022
|
themeWebRoot: absoluteWebRoot,
|
|
6002
6023
|
authedPortalId,
|
|
6003
6024
|
authedEnv,
|
|
@@ -6006,24 +6027,17 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
6006
6027
|
webRootProjectComponentFolder,
|
|
6007
6028
|
localPreviewToken: _localPreviewToken,
|
|
6008
6029
|
sslEnabled: sslEnabledOption2,
|
|
6009
|
-
fieldBuilderEnabled: fieldBuilderEnabled2
|
|
6010
|
-
};
|
|
6011
|
-
const appServer = await createAppServer_default(
|
|
6030
|
+
fieldBuilderEnabled: fieldBuilderEnabled2,
|
|
6012
6031
|
appWebRoot,
|
|
6013
|
-
|
|
6014
|
-
sslEnabledOption2
|
|
6015
|
-
);
|
|
6016
|
-
const appServerConfig = {
|
|
6017
|
-
appServer,
|
|
6018
|
-
reqLocals,
|
|
6019
|
-
appWebRoot
|
|
6032
|
+
appViteServer
|
|
6020
6033
|
};
|
|
6034
|
+
expressServer.locals.appLocals = appLocals;
|
|
6021
6035
|
expressServer.use(
|
|
6022
6036
|
BASE_PATH,
|
|
6023
6037
|
await createDevServerRoutes_default(
|
|
6024
6038
|
viteServer,
|
|
6025
|
-
|
|
6026
|
-
|
|
6039
|
+
appLocals,
|
|
6040
|
+
storybook2 ? STORYBOOK_PORT : null
|
|
6027
6041
|
)
|
|
6028
6042
|
);
|
|
6029
6043
|
if (sslEnabledOption2) {
|
|
@@ -6066,8 +6080,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
6066
6080
|
`
|
|
6067
6081
|
);
|
|
6068
6082
|
if (storybook2) {
|
|
6069
|
-
const packageRoot =
|
|
6070
|
-
const configPath =
|
|
6083
|
+
const packageRoot = path17.dirname(url2.fileURLToPath(import.meta.url));
|
|
6084
|
+
const configPath = path17.resolve(packageRoot, "./storybook-main");
|
|
6071
6085
|
sendTrackingRequest("start-storybook");
|
|
6072
6086
|
const storybookProcess = spawn2(
|
|
6073
6087
|
"sb",
|
|
@@ -6087,7 +6101,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
6087
6101
|
portalId: authedPortalId.toString(),
|
|
6088
6102
|
hsEnv: authedEnv,
|
|
6089
6103
|
hublet: authedHublet,
|
|
6090
|
-
WEB_ROOT:
|
|
6104
|
+
WEB_ROOT: path17.join(webRoot2, "components")
|
|
6091
6105
|
}
|
|
6092
6106
|
}
|
|
6093
6107
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
31
|
"@babel/types": "^7.25.2",
|
|
32
|
-
"@hubspot/cms-components": "^1.0.
|
|
32
|
+
"@hubspot/cms-components": "^1.0.7",
|
|
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",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"publishConfig": {
|
|
132
132
|
"access": "public"
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "46df6c8d1a6a0ae518ace99d475d736e02d63b73"
|
|
135
135
|
}
|
|
@@ -39,7 +39,7 @@ export interface DevServerUIData {
|
|
|
39
39
|
fieldBuilderEnabled: boolean;
|
|
40
40
|
[key: string]: any;
|
|
41
41
|
}
|
|
42
|
-
export interface
|
|
42
|
+
export interface AppLocals {
|
|
43
43
|
themeWebRoot: string;
|
|
44
44
|
authedPortalId: number;
|
|
45
45
|
authedEnv: string;
|
|
@@ -49,7 +49,9 @@ export interface RequestLocals {
|
|
|
49
49
|
localPreviewToken: string;
|
|
50
50
|
sslEnabled: boolean;
|
|
51
51
|
fieldBuilderEnabled: boolean;
|
|
52
|
+
appWebRoot: string;
|
|
53
|
+
appViteServer: ViteDevServer;
|
|
52
54
|
}
|
|
53
55
|
export declare const templateTypeMap: Record<number, string>;
|
|
54
|
-
export declare function getDevServerUIData(
|
|
56
|
+
export declare function getDevServerUIData(appLocals: AppLocals): Promise<DevServerUIData>;
|
|
55
57
|
export default getDevServerUIData;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
export declare function handleGetModulePages(req: Request, res: Response, next: NextFunction): Promise<Response<any, Record<string, any>>>;
|
|
3
|
+
export declare function handleOpenFile(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>>;
|
|
4
|
+
export declare function appServerApiRouteHandler(): import("express-serve-static-core").Router;
|
|
5
|
+
export default appServerApiRouteHandler;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
export declare function handleGetModulePages(req: Request, res: Response, next: NextFunction): Promise<Response<any, Record<string, any>>>;
|
|
3
|
+
export declare function handleOpenFile(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>>;
|
|
4
|
+
export declare function createAppServerAPIRoutes(): import("express-serve-static-core").Router;
|
|
5
|
+
export default createAppServerAPIRoutes;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { ViteDevServer } from 'vite';
|
|
2
|
-
import {
|
|
3
|
-
declare const createDevServerRoutes: (viteServer: ViteDevServer, storybookPort?: number
|
|
4
|
-
appServer?: ViteDevServer;
|
|
5
|
-
reqLocals?: RequestLocals;
|
|
6
|
-
appWebRoot?: string;
|
|
7
|
-
}) => Promise<import("express-serve-static-core").Router>;
|
|
2
|
+
import { AppLocals } from '../lib/getDevServerUIData.js';
|
|
3
|
+
declare const createDevServerRoutes: (viteServer: ViteDevServer, appLocals: AppLocals, storybookPort?: number) => Promise<import("express-serve-static-core").Router>;
|
|
8
4
|
export default createDevServerRoutes;
|