@hubspot/cms-dev-server 0.18.11 → 0.18.13
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 +258 -75
- package/dist/run.js +283 -93
- package/package.json +3 -4
- package/types/api/designmanager.d.ts +8 -0
- package/types/components/HubLTemplatesList.d.ts +1 -0
- package/types/createAppServer.d.ts +1 -1
- package/types/lib/getDevServerUIData.d.ts +14 -3
- package/types/lib/getFieldValuesForModule.d.ts +2 -0
- package/types/lib/renderModuleFieldsJson.d.ts +4 -0
- package/types/lib/renderModulePreview.d.ts +1 -1
- package/types/routes/moduleFieldsJson.d.ts +3 -0
package/dist/run.js
CHANGED
|
@@ -36,7 +36,7 @@ import { escapeRegExp } from "@hubspot/local-dev-lib/escapeRegExp";
|
|
|
36
36
|
import inquirer from "inquirer";
|
|
37
37
|
import { getThemeJSONPath } from "@hubspot/local-dev-lib/cms/themes";
|
|
38
38
|
import findup from "findup-sync";
|
|
39
|
-
import {
|
|
39
|
+
import { getAbsoluteFilePath } from "@hubspot/local-dev-lib/path";
|
|
40
40
|
import { logger } from "@hubspot/local-dev-lib/logger";
|
|
41
41
|
import {
|
|
42
42
|
isHubSpotHttpError,
|
|
@@ -85,22 +85,24 @@ function previewProjectPrompt(themeComponents) {
|
|
|
85
85
|
}
|
|
86
86
|
]);
|
|
87
87
|
}
|
|
88
|
-
var getProjectConfig = async (_dir) => {
|
|
88
|
+
var getProjectConfig = async (_dir, isUsingLocalWorkspace = false) => {
|
|
89
89
|
const getProjectConfigPath = (__dir) => {
|
|
90
|
-
const
|
|
90
|
+
const dir = isUsingLocalWorkspace ? __dir : getAbsoluteFilePath(__dir);
|
|
91
|
+
if (!dir) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
91
94
|
const PROJECT_CONFIG_FILE = "hsproject.json";
|
|
92
|
-
|
|
93
|
-
cwd:
|
|
95
|
+
return findup(PROJECT_CONFIG_FILE, {
|
|
96
|
+
cwd: path.resolve(__dir),
|
|
94
97
|
nocase: true
|
|
95
98
|
});
|
|
96
|
-
return configPath2;
|
|
97
99
|
};
|
|
98
100
|
const configPath = await getProjectConfigPath(_dir);
|
|
99
101
|
if (!configPath) {
|
|
100
102
|
return { projectConfig: null, projectDir: null };
|
|
101
103
|
}
|
|
102
104
|
try {
|
|
103
|
-
const config = fs.readFileSync(configPath);
|
|
105
|
+
const config = fs.readFileSync(configPath, "utf8");
|
|
104
106
|
const projectConfig = JSON.parse(config);
|
|
105
107
|
return {
|
|
106
108
|
projectDir: path.dirname(configPath),
|
|
@@ -189,12 +191,15 @@ function getIsLegacyApp(appConfig, appPath) {
|
|
|
189
191
|
});
|
|
190
192
|
return !hasAnyReactExtensions;
|
|
191
193
|
}
|
|
192
|
-
async function determineSrcAndDest() {
|
|
194
|
+
async function determineSrcAndDest(webRoot2, isUsingLocalWorkspace = false) {
|
|
193
195
|
let absoluteSrc;
|
|
194
196
|
let dest;
|
|
195
|
-
const { projectDir, projectConfig } = await getProjectConfig(
|
|
197
|
+
const { projectDir, projectConfig } = await getProjectConfig(
|
|
198
|
+
webRoot2,
|
|
199
|
+
isUsingLocalWorkspace
|
|
200
|
+
);
|
|
196
201
|
if (projectDir && projectConfig) {
|
|
197
|
-
let themeJsonPath = getThemeJSONPath(
|
|
202
|
+
let themeJsonPath = getThemeJSONPath(webRoot2);
|
|
198
203
|
if (!themeJsonPath) {
|
|
199
204
|
const projectComponents = await findProjectComponents(projectDir);
|
|
200
205
|
const themeComponents = projectComponents.filter(
|
|
@@ -658,7 +663,7 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
658
663
|
const storybook2 = args.findIndex((arg) => arg === "--storybook") > 0;
|
|
659
664
|
const fieldGenEnabledOption2 = args.includes("--generateFieldsTypes");
|
|
660
665
|
const resetSession2 = args.includes("--resetSession");
|
|
661
|
-
const
|
|
666
|
+
const showUI2 = args.includes("--showUI");
|
|
662
667
|
return {
|
|
663
668
|
hubspotCliConfigPathOption: hubspotCliConfigPathOption2,
|
|
664
669
|
hubspotCliAccountNameOption: hubspotCliAccountNameOption2,
|
|
@@ -666,17 +671,17 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
666
671
|
storybook: storybook2,
|
|
667
672
|
fieldGenEnabledOption: fieldGenEnabledOption2,
|
|
668
673
|
webRoot: webRoot2,
|
|
669
|
-
showUI,
|
|
674
|
+
showUI: showUI2,
|
|
670
675
|
resetSession: resetSession2
|
|
671
676
|
};
|
|
672
677
|
}
|
|
673
|
-
async function buildThemePreviewOptions(webRoot2) {
|
|
678
|
+
async function buildThemePreviewOptions(webRoot2, isUsingLocalWorkspace = false) {
|
|
674
679
|
const themeJsonPath = join(webRoot2, "theme.json");
|
|
675
680
|
if (!existsSync(themeJsonPath)) {
|
|
676
681
|
return void 0;
|
|
677
682
|
}
|
|
678
683
|
const filePaths = await getUploadableFileList(webRoot2, false);
|
|
679
|
-
const { dest } = await determineSrcAndDest();
|
|
684
|
+
const { dest } = await determineSrcAndDest(webRoot2, isUsingLocalWorkspace);
|
|
680
685
|
const startProgressBar = (numFiles) => {
|
|
681
686
|
const initialUploadProgressBar = new cliProgress.SingleBar(
|
|
682
687
|
{
|
|
@@ -741,17 +746,17 @@ async function buildThemePreviewOptions(webRoot2) {
|
|
|
741
746
|
}
|
|
742
747
|
|
|
743
748
|
// src/createDevServer.ts
|
|
744
|
-
import
|
|
749
|
+
import path15 from "path";
|
|
745
750
|
import url2 from "url";
|
|
746
751
|
import express3 from "express";
|
|
747
752
|
import http3 from "http";
|
|
748
753
|
import bodyParser from "body-parser";
|
|
749
754
|
import { spawn } from "child_process";
|
|
750
|
-
import { normalizePath as
|
|
755
|
+
import { normalizePath as normalizePath9 } from "vite";
|
|
751
756
|
import { Transform } from "stream";
|
|
752
757
|
|
|
753
758
|
// src/routes/createDevServerRoutes.ts
|
|
754
|
-
import { Router } from "express";
|
|
759
|
+
import { Router, urlencoded } from "express";
|
|
755
760
|
import { createProxyMiddleware } from "http-proxy-middleware";
|
|
756
761
|
|
|
757
762
|
// src/routes/partial.ts
|
|
@@ -1372,8 +1377,8 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
1372
1377
|
);
|
|
1373
1378
|
return Object.fromEntries(relativeEntries);
|
|
1374
1379
|
}
|
|
1375
|
-
function toRelativePath(config,
|
|
1376
|
-
return
|
|
1380
|
+
function toRelativePath(config, path16) {
|
|
1381
|
+
return path16.replace(`${config.root}/`, "");
|
|
1377
1382
|
}
|
|
1378
1383
|
function shouldSkipModule(config, moduleInfo, code) {
|
|
1379
1384
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
@@ -1411,11 +1416,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1411
1416
|
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
1412
1417
|
let dndAreaComponentLocalImportName = DND_AREA_COMPONENT_NAME;
|
|
1413
1418
|
traverse(sourceAst, {
|
|
1414
|
-
ImportDeclaration(
|
|
1415
|
-
if (t.isStringLiteral(
|
|
1419
|
+
ImportDeclaration(path16) {
|
|
1420
|
+
if (t.isStringLiteral(path16.node.source, {
|
|
1416
1421
|
value: "@hubspot/cms-components"
|
|
1417
1422
|
})) {
|
|
1418
|
-
for (const specifier of
|
|
1423
|
+
for (const specifier of path16.node.specifiers) {
|
|
1419
1424
|
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
1420
1425
|
name: CMS_MODULE_COMPONENT_NAME
|
|
1421
1426
|
})) {
|
|
@@ -1429,14 +1434,14 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1429
1434
|
}
|
|
1430
1435
|
}
|
|
1431
1436
|
},
|
|
1432
|
-
JSXOpeningElement(
|
|
1433
|
-
if (t.isJSXIdentifier(
|
|
1437
|
+
JSXOpeningElement(path16) {
|
|
1438
|
+
if (t.isJSXIdentifier(path16.node.name, {
|
|
1434
1439
|
name: moduleComponentLocalImportName
|
|
1435
1440
|
})) {
|
|
1436
1441
|
let cmsModuleName;
|
|
1437
1442
|
let cmsModulePath;
|
|
1438
1443
|
let cmsModuleLabel;
|
|
1439
|
-
for (const prop of
|
|
1444
|
+
for (const prop of path16.node.attributes) {
|
|
1440
1445
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1441
1446
|
cmsModuleName = prop.value.value;
|
|
1442
1447
|
continue;
|
|
@@ -1471,11 +1476,11 @@ function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
|
1471
1476
|
}
|
|
1472
1477
|
contentDescriptors.modules[cmsModuleProps.name] = cmsModuleProps;
|
|
1473
1478
|
}
|
|
1474
|
-
if (t.isJSXIdentifier(
|
|
1479
|
+
if (t.isJSXIdentifier(path16.node.name, {
|
|
1475
1480
|
name: dndAreaComponentLocalImportName
|
|
1476
1481
|
})) {
|
|
1477
1482
|
let dndAreaName;
|
|
1478
|
-
for (const prop of
|
|
1483
|
+
for (const prop of path16.node.attributes) {
|
|
1479
1484
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
1480
1485
|
dndAreaName = prop.value.value;
|
|
1481
1486
|
continue;
|
|
@@ -2059,7 +2064,7 @@ function trackUsage(action) {
|
|
|
2059
2064
|
eventName: EVENT_NAME,
|
|
2060
2065
|
action,
|
|
2061
2066
|
nodeVersion: getNodeVersionData(),
|
|
2062
|
-
version: "0.18.
|
|
2067
|
+
version: "0.18.13",
|
|
2063
2068
|
os: getPlatform()
|
|
2064
2069
|
};
|
|
2065
2070
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -2132,12 +2137,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2132
2137
|
);
|
|
2133
2138
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
2134
2139
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
2135
|
-
const
|
|
2140
|
+
const path16 = body.substring(
|
|
2136
2141
|
startOffset + localJsRenderStartString.length,
|
|
2137
2142
|
pathEndOffset
|
|
2138
2143
|
);
|
|
2139
2144
|
offsetSoFar = pathEndOffset + 1;
|
|
2140
|
-
if (startOffset >= 0 &&
|
|
2145
|
+
if (startOffset >= 0 && path16) {
|
|
2141
2146
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
2142
2147
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
2143
2148
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -2162,7 +2167,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
2162
2167
|
result.push({
|
|
2163
2168
|
startOffset,
|
|
2164
2169
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
2165
|
-
path:
|
|
2170
|
+
path: path16,
|
|
2166
2171
|
json
|
|
2167
2172
|
});
|
|
2168
2173
|
}
|
|
@@ -2207,7 +2212,6 @@ import { http as hsCliHttp6 } from "@hubspot/local-dev-lib/http";
|
|
|
2207
2212
|
|
|
2208
2213
|
// src/lib/renderModule.ts
|
|
2209
2214
|
import { join as joinPosix2 } from "path/posix";
|
|
2210
|
-
import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
|
|
2211
2215
|
import * as cmsComponents2 from "@hubspot/cms-components";
|
|
2212
2216
|
import { http as hsCliHttp3 } from "@hubspot/local-dev-lib/http";
|
|
2213
2217
|
|
|
@@ -2237,6 +2241,16 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
|
|
|
2237
2241
|
return dataQueryResult;
|
|
2238
2242
|
}
|
|
2239
2243
|
|
|
2244
|
+
// src/lib/getFieldValuesForModule.ts
|
|
2245
|
+
import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
|
|
2246
|
+
function getFieldValuesForModule(fieldsJSON, fieldOverrides = {}) {
|
|
2247
|
+
const props = {};
|
|
2248
|
+
traverseFieldsJSON(fieldsJSON, fieldOverrides, (fieldPathArray, value) => {
|
|
2249
|
+
setIn(props, fieldPathArray, value);
|
|
2250
|
+
});
|
|
2251
|
+
return props;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2240
2254
|
// src/lib/renderModule.ts
|
|
2241
2255
|
var VALIDATE_FIELDS_ENDPOINT = "/designmanager/v1/modules/validate-fields";
|
|
2242
2256
|
var VALIDATE_META_ENDPOINT = "/designmanager/v1/modules/validate-meta";
|
|
@@ -2453,13 +2467,6 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
2453
2467
|
componentModule.unstable_modifyHtml
|
|
2454
2468
|
).then(applyFieldsValidationToRenderContext);
|
|
2455
2469
|
}
|
|
2456
|
-
function getFieldValuesForModule(fieldsJSON, fieldOverrides = {}) {
|
|
2457
|
-
const props = {};
|
|
2458
|
-
traverseFieldsJSON(fieldsJSON, fieldOverrides, (fieldPathArray, value) => {
|
|
2459
|
-
setIn(props, fieldPathArray, value);
|
|
2460
|
-
});
|
|
2461
|
-
return props;
|
|
2462
|
-
}
|
|
2463
2470
|
var renderModule_default = renderModule;
|
|
2464
2471
|
|
|
2465
2472
|
// src/proxyPage/utils.ts
|
|
@@ -2539,9 +2546,9 @@ var customColors = [
|
|
|
2539
2546
|
];
|
|
2540
2547
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
2541
2548
|
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;`;
|
|
2542
|
-
var renderLocalError_default = (
|
|
2549
|
+
var renderLocalError_default = (path16, error) => {
|
|
2543
2550
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
2544
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
2551
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path16}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
2545
2552
|
};
|
|
2546
2553
|
|
|
2547
2554
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -3362,7 +3369,7 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
|
|
|
3362
3369
|
const cssNeeded = Array.from(dom.window.document.querySelectorAll("style")).map((element) => element.outerHTML).join("");
|
|
3363
3370
|
return { html: modulePreviewContent, cssNeeded };
|
|
3364
3371
|
}
|
|
3365
|
-
async function renderLocalProjectModulePreview(moduleName, authedPortalId, authedEnv, authedHublet, webRoot2, viteServer, jsRenderingGates, projectName, projectComponentPath, fullOriginalUrl, cookieValue) {
|
|
3372
|
+
async function renderLocalProjectModulePreview(moduleName, authedPortalId, authedEnv, authedHublet, webRoot2, viteServer, jsRenderingGates, projectName, projectComponentPath, fullOriginalUrl, cookieValue, fieldOverrides = {}) {
|
|
3366
3373
|
const modulePath = normalizePath3(
|
|
3367
3374
|
path7.resolve(webRoot2, "components/modules/", moduleName)
|
|
3368
3375
|
);
|
|
@@ -3405,6 +3412,10 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3405
3412
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
3406
3413
|
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
3407
3414
|
const localFieldsJson = renderFieldsToJson(fields, modulePath);
|
|
3415
|
+
const localFieldValues = getFieldValuesForModule(
|
|
3416
|
+
localFieldsJson,
|
|
3417
|
+
fieldOverrides
|
|
3418
|
+
);
|
|
3408
3419
|
const localModule = {
|
|
3409
3420
|
isJsModule: true,
|
|
3410
3421
|
schemaVersion: 2,
|
|
@@ -3445,6 +3456,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3445
3456
|
`
|
|
3446
3457
|
);
|
|
3447
3458
|
}
|
|
3459
|
+
localRenderPlaceholders[0].json.props.fieldValues = localFieldValues;
|
|
3448
3460
|
return await renderComponentForPlaceholder(
|
|
3449
3461
|
0,
|
|
3450
3462
|
localRenderPlaceholders[0],
|
|
@@ -3802,6 +3814,74 @@ ${e.stack}`);
|
|
|
3802
3814
|
};
|
|
3803
3815
|
var module_default = moduleRouteHandler;
|
|
3804
3816
|
|
|
3817
|
+
// src/routes/moduleFieldsJson.ts
|
|
3818
|
+
import path10 from "path";
|
|
3819
|
+
import { normalizePath as normalizePath6 } from "vite";
|
|
3820
|
+
|
|
3821
|
+
// src/lib/renderModuleFieldsJson.ts
|
|
3822
|
+
import { join as joinPosix4 } from "path/posix";
|
|
3823
|
+
var lookForModuleInFolder3 = async (modulePath, viteServer) => {
|
|
3824
|
+
let componentModule;
|
|
3825
|
+
const insideFolderPath = joinPosix4(modulePath, "index");
|
|
3826
|
+
try {
|
|
3827
|
+
componentModule = await viteServer.ssrLoadModule(insideFolderPath);
|
|
3828
|
+
} catch (e) {
|
|
3829
|
+
if (!e.message.includes("Failed to load url")) {
|
|
3830
|
+
throw e;
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
return [componentModule, insideFolderPath];
|
|
3834
|
+
};
|
|
3835
|
+
async function renderModuleFieldsJson(viteServer, requestedModulePath) {
|
|
3836
|
+
let componentModule;
|
|
3837
|
+
try {
|
|
3838
|
+
if (!hasComponentExtension(requestedModulePath)) {
|
|
3839
|
+
[componentModule] = await lookForModuleInFolder3(
|
|
3840
|
+
requestedModulePath,
|
|
3841
|
+
viteServer
|
|
3842
|
+
);
|
|
3843
|
+
}
|
|
3844
|
+
if (!componentModule) {
|
|
3845
|
+
componentModule = await viteServer.ssrLoadModule(requestedModulePath);
|
|
3846
|
+
}
|
|
3847
|
+
} catch (error) {
|
|
3848
|
+
throw new Error(
|
|
3849
|
+
`Failed to load module ${requestedModulePath}: ${error.message}`
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
if (!componentModule) {
|
|
3853
|
+
throw new Error(`Couldn't find module: ${requestedModulePath}`);
|
|
3854
|
+
}
|
|
3855
|
+
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
3856
|
+
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
3857
|
+
const fieldsJson = renderFieldsToJson(
|
|
3858
|
+
componentModule.fields,
|
|
3859
|
+
requestedModulePath
|
|
3860
|
+
);
|
|
3861
|
+
return fieldsJson;
|
|
3862
|
+
}
|
|
3863
|
+
var renderModuleFieldsJson_default = renderModuleFieldsJson;
|
|
3864
|
+
|
|
3865
|
+
// src/routes/moduleFieldsJson.ts
|
|
3866
|
+
var moduleFieldsJsonRouteHandler = async (request2, response) => {
|
|
3867
|
+
try {
|
|
3868
|
+
sendTrackingRequest("fields-json-route");
|
|
3869
|
+
const { webRoot: webRoot2, viteServer } = request2.app.locals;
|
|
3870
|
+
const { moduleName } = request2.params;
|
|
3871
|
+
const modulePath = normalizePath6(
|
|
3872
|
+
path10.resolve(webRoot2, "components/modules/", moduleName)
|
|
3873
|
+
);
|
|
3874
|
+
const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
|
|
3875
|
+
return response.status(200).set({ "Content-Type": "application/json" }).json(fieldsJson);
|
|
3876
|
+
} catch (error) {
|
|
3877
|
+
console.error("Error processing module fields.json:", error);
|
|
3878
|
+
return response.status(500).json({
|
|
3879
|
+
error: "Failed to process module fields"
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
3882
|
+
};
|
|
3883
|
+
var moduleFieldsJson_default = moduleFieldsJsonRouteHandler;
|
|
3884
|
+
|
|
3805
3885
|
// src/proxyPage/fetchContentMetadata.ts
|
|
3806
3886
|
import http from "http";
|
|
3807
3887
|
import https from "https";
|
|
@@ -4015,16 +4095,20 @@ async function fetchPreviewTemplates(accountId, previewToken) {
|
|
|
4015
4095
|
url: `${DESIGN_MANAGER_API_PATH}/templates/local-preview?previewToken=${previewToken}`
|
|
4016
4096
|
})).data;
|
|
4017
4097
|
}
|
|
4018
|
-
async function fetchModuleByPath(accountId,
|
|
4098
|
+
async function fetchModuleByPath(accountId, path16) {
|
|
4019
4099
|
return (await hsCliHttp8.get(accountId, {
|
|
4020
|
-
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${
|
|
4100
|
+
url: `${DESIGN_MANAGER_API_PATH}/modules/by-path/${path16}?portalId=${accountId}`
|
|
4021
4101
|
})).data;
|
|
4022
4102
|
}
|
|
4023
|
-
async function fetchTemplateByPath(accountId,
|
|
4103
|
+
async function fetchTemplateByPath(accountId, path16) {
|
|
4024
4104
|
return (await hsCliHttp8.get(accountId, {
|
|
4025
|
-
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${
|
|
4105
|
+
url: `${DESIGN_MANAGER_API_PATH}/templates/by-path/${path16}?portalId=${accountId}`
|
|
4026
4106
|
})).data;
|
|
4027
4107
|
}
|
|
4108
|
+
async function fetchModulePageDependencies(accountId, path16) {
|
|
4109
|
+
const url3 = `${DESIGN_MANAGER_API_PATH}/modules/list-pages?modulePath=${path16}`;
|
|
4110
|
+
return (await hsCliHttp8.get(accountId, { url: url3 })).data;
|
|
4111
|
+
}
|
|
4028
4112
|
|
|
4029
4113
|
// src/components/HubLTemplatesList.tsx
|
|
4030
4114
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
@@ -4264,8 +4348,8 @@ function proxyServerlessRequest(req, res, next) {
|
|
|
4264
4348
|
}
|
|
4265
4349
|
|
|
4266
4350
|
// src/routes/modulePreviewRouteHandler.ts
|
|
4267
|
-
import
|
|
4268
|
-
import { normalizePath as
|
|
4351
|
+
import path11 from "path";
|
|
4352
|
+
import { normalizePath as normalizePath7 } from "vite";
|
|
4269
4353
|
async function modulePreviewRouteHandler(request2, response) {
|
|
4270
4354
|
sendTrackingRequest("view-module-preview-route");
|
|
4271
4355
|
const {
|
|
@@ -4279,9 +4363,46 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
4279
4363
|
projectComponentPath
|
|
4280
4364
|
} = request2.app.locals;
|
|
4281
4365
|
const moduleName = request2.params.moduleName;
|
|
4282
|
-
const modulePath =
|
|
4283
|
-
|
|
4366
|
+
const modulePath = normalizePath7(
|
|
4367
|
+
path11.resolve(webRoot2, "components/modules/", moduleName)
|
|
4284
4368
|
);
|
|
4369
|
+
const PREVIEWER_APP_PARAM = "hsPreviewerApp";
|
|
4370
|
+
let fieldOverrides = {};
|
|
4371
|
+
if (request2.method === "POST" && request2.body) {
|
|
4372
|
+
if (request2.query[PREVIEWER_APP_PARAM] === "module" && request2.body.module_data) {
|
|
4373
|
+
fieldOverrides = request2.body.module_data;
|
|
4374
|
+
} else {
|
|
4375
|
+
fieldOverrides = request2.body;
|
|
4376
|
+
}
|
|
4377
|
+
try {
|
|
4378
|
+
if (typeof fieldOverrides === "string") {
|
|
4379
|
+
const parsedFieldOverrides = JSON.parse(fieldOverrides);
|
|
4380
|
+
if (parsedFieldOverrides && typeof parsedFieldOverrides === "object" && !Array.isArray(parsedFieldOverrides)) {
|
|
4381
|
+
fieldOverrides = parsedFieldOverrides;
|
|
4382
|
+
} else {
|
|
4383
|
+
throw new Error("Parsed field overrides must be an object");
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4386
|
+
} catch (e) {
|
|
4387
|
+
console.error(
|
|
4388
|
+
`Error parsing field for module "${moduleName}": ${e.message}`,
|
|
4389
|
+
"\nReceived value:",
|
|
4390
|
+
fieldOverrides
|
|
4391
|
+
);
|
|
4392
|
+
}
|
|
4393
|
+
} else if (request2.query.fields) {
|
|
4394
|
+
try {
|
|
4395
|
+
if (typeof request2.query.fields === "string") {
|
|
4396
|
+
fieldOverrides = JSON.parse(
|
|
4397
|
+
decodeURIComponent(request2.query.fields.replace(/\+/g, "%20"))
|
|
4398
|
+
);
|
|
4399
|
+
}
|
|
4400
|
+
} catch (e) {
|
|
4401
|
+
console.error(
|
|
4402
|
+
`Error parsing field param for module ${moduleName}: ${request2.query.fields}`
|
|
4403
|
+
);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4285
4406
|
try {
|
|
4286
4407
|
const {
|
|
4287
4408
|
html: renderedHtml,
|
|
@@ -4299,7 +4420,8 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
4299
4420
|
projectName,
|
|
4300
4421
|
projectComponentPath,
|
|
4301
4422
|
fullOriginalUrlFromRequest(request2),
|
|
4302
|
-
request2.get("COOKIE")
|
|
4423
|
+
request2.get("COOKIE"),
|
|
4424
|
+
fieldOverrides
|
|
4303
4425
|
);
|
|
4304
4426
|
const baseTemplatePath = packagePath(
|
|
4305
4427
|
import.meta.url,
|
|
@@ -4495,6 +4617,7 @@ var createDevServerRoutes = async (viteServer, storybookPort) => {
|
|
|
4495
4617
|
);
|
|
4496
4618
|
}
|
|
4497
4619
|
devServerApp.use(viteServer.middlewares);
|
|
4620
|
+
devServerApp.use(urlencoded());
|
|
4498
4621
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
4499
4622
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
4500
4623
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -4503,7 +4626,12 @@ var createDevServerRoutes = async (viteServer, storybookPort) => {
|
|
|
4503
4626
|
devServerApp.get("/preview/module/:moduleName", modulePreviewRouteHandler_default);
|
|
4504
4627
|
devServerApp.get("/modules/", linksToAllModulesRouteHandler_default);
|
|
4505
4628
|
devServerApp.get("/module/:moduleName", module_default);
|
|
4629
|
+
devServerApp.get(
|
|
4630
|
+
"/preview/module/:moduleName/fields.json",
|
|
4631
|
+
moduleFieldsJson_default
|
|
4632
|
+
);
|
|
4506
4633
|
devServerApp.get("/module/:moduleName/*", module_default);
|
|
4634
|
+
devServerApp.post("/preview/module/:moduleName", modulePreviewRouteHandler_default);
|
|
4507
4635
|
devServerApp.get("/hublmodule/:modulePath(*)", hublModuleRouteHandler);
|
|
4508
4636
|
devServerApp.get("/template/:templatePath(*)", templateRouteHandler);
|
|
4509
4637
|
devServerApp.all("/hs/serverless/*", proxyServerlessRequest);
|
|
@@ -4780,33 +4908,67 @@ import { createServer as createViteServer2 } from "vite";
|
|
|
4780
4908
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
4781
4909
|
|
|
4782
4910
|
// src/lib/getDevServerUIData.ts
|
|
4911
|
+
import path12 from "path";
|
|
4912
|
+
import { normalizePath as normalizePath8 } from "vite";
|
|
4913
|
+
function mapModulesData(modules, themeWebRoot, viteServer) {
|
|
4914
|
+
return Promise.all(
|
|
4915
|
+
modules.moduleNames.map(async (name, index) => {
|
|
4916
|
+
const modulePath = normalizePath8(
|
|
4917
|
+
path12.resolve(themeWebRoot, "components/modules/", name)
|
|
4918
|
+
);
|
|
4919
|
+
const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
|
|
4920
|
+
return {
|
|
4921
|
+
name,
|
|
4922
|
+
subPath: modules.moduleSubpaths[index],
|
|
4923
|
+
nameWithExtension: modules.moduleNamesWithExtension[index],
|
|
4924
|
+
fieldsJson
|
|
4925
|
+
};
|
|
4926
|
+
})
|
|
4927
|
+
);
|
|
4928
|
+
}
|
|
4929
|
+
function mapPartialsData(modules) {
|
|
4930
|
+
return modules.partialNames.map((name, index) => ({
|
|
4931
|
+
name,
|
|
4932
|
+
subPath: modules.partialSubpaths[index]
|
|
4933
|
+
}));
|
|
4934
|
+
}
|
|
4783
4935
|
async function getDevServerUIData(reqLocals) {
|
|
4784
4936
|
const {
|
|
4785
4937
|
themeWebRoot,
|
|
4786
4938
|
authedPortalId,
|
|
4787
4939
|
projectName,
|
|
4788
4940
|
localPreviewToken,
|
|
4789
|
-
webRootProjectComponentFolder
|
|
4941
|
+
webRootProjectComponentFolder,
|
|
4942
|
+
viteServer
|
|
4790
4943
|
} = reqLocals;
|
|
4791
|
-
const
|
|
4792
|
-
const
|
|
4793
|
-
const
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
const hubLTemplateData = await fetchPreviewTemplates(
|
|
4798
|
-
authedPortalId,
|
|
4799
|
-
localPreviewToken
|
|
4944
|
+
const modulesData = findAllModulesInRoot(themeWebRoot);
|
|
4945
|
+
const partialsData = findAllPartialsInRoot(themeWebRoot);
|
|
4946
|
+
const mappedModulesData = await mapModulesData(
|
|
4947
|
+
modulesData,
|
|
4948
|
+
themeWebRoot,
|
|
4949
|
+
viteServer
|
|
4800
4950
|
);
|
|
4951
|
+
let hubLModuleData = { objects: [] };
|
|
4952
|
+
let hubLTemplateData = { objects: [] };
|
|
4953
|
+
if (authedPortalId) {
|
|
4954
|
+
hubLModuleData = await fetchHubLModules(authedPortalId, localPreviewToken);
|
|
4955
|
+
hubLTemplateData = await fetchPreviewTemplates(
|
|
4956
|
+
authedPortalId,
|
|
4957
|
+
localPreviewToken
|
|
4958
|
+
);
|
|
4959
|
+
}
|
|
4960
|
+
const hubLTemplates = (hubLTemplateData == null ? void 0 : hubLTemplateData.objects.filter(
|
|
4961
|
+
(template) => isCodedFile(template.filename)
|
|
4962
|
+
)) || [];
|
|
4801
4963
|
return {
|
|
4802
4964
|
authedPortalId,
|
|
4803
4965
|
projectName,
|
|
4804
|
-
|
|
4805
|
-
|
|
4966
|
+
modulesData: mappedModulesData,
|
|
4967
|
+
partialsData: mapPartialsData(partialsData),
|
|
4806
4968
|
hubLModules: (hubLModuleData == null ? void 0 : hubLModuleData.objects) || [],
|
|
4807
|
-
hubLTemplates
|
|
4808
|
-
|
|
4809
|
-
|
|
4969
|
+
hubLTemplates,
|
|
4970
|
+
themeWebRoot,
|
|
4971
|
+
webRootProjectComponentFolder
|
|
4810
4972
|
};
|
|
4811
4973
|
}
|
|
4812
4974
|
var getDevServerUIData_default = getDevServerUIData;
|
|
@@ -4819,7 +4981,11 @@ async function createAppServer(webRoot2, reqLocals, port) {
|
|
|
4819
4981
|
server: {
|
|
4820
4982
|
middlewareMode: true,
|
|
4821
4983
|
host: "hslocal.net",
|
|
4822
|
-
origin
|
|
4984
|
+
origin,
|
|
4985
|
+
hmr: {
|
|
4986
|
+
port: port + 1,
|
|
4987
|
+
host: "hslocal.net"
|
|
4988
|
+
}
|
|
4823
4989
|
},
|
|
4824
4990
|
appType: "custom",
|
|
4825
4991
|
root: webRoot2,
|
|
@@ -4857,14 +5023,32 @@ async function createAppServer(webRoot2, reqLocals, port) {
|
|
|
4857
5023
|
};
|
|
4858
5024
|
const viteServer = await createViteServer2(viteConfig);
|
|
4859
5025
|
app.use(viteServer.middlewares);
|
|
5026
|
+
app.get("/api/module-pages", async (req, res, next) => {
|
|
5027
|
+
const { path: path16, portalId } = req.query;
|
|
5028
|
+
if (!path16 || !portalId) {
|
|
5029
|
+
return res.status(400).json({ error: "Missing required parameters" });
|
|
5030
|
+
}
|
|
5031
|
+
try {
|
|
5032
|
+
const data = await fetchModulePageDependencies(
|
|
5033
|
+
Number(portalId),
|
|
5034
|
+
path16
|
|
5035
|
+
);
|
|
5036
|
+
res.json(data);
|
|
5037
|
+
} catch (err) {
|
|
5038
|
+
next(err);
|
|
5039
|
+
}
|
|
5040
|
+
});
|
|
4860
5041
|
app.use("*", async (req, res) => {
|
|
4861
5042
|
try {
|
|
4862
|
-
const initialProps = await getDevServerUIData_default(
|
|
5043
|
+
const initialProps = await getDevServerUIData_default({
|
|
5044
|
+
...reqLocals,
|
|
5045
|
+
viteServer
|
|
5046
|
+
});
|
|
4863
5047
|
const url3 = req.originalUrl.replace("/", "");
|
|
4864
|
-
let template = await fs4.readFile(
|
|
5048
|
+
let template = await fs4.readFile(`${webRoot2}/index.html`, "utf-8");
|
|
4865
5049
|
template = await viteServer.transformIndexHtml(url3, template);
|
|
4866
5050
|
const { render } = await viteServer.ssrLoadModule(
|
|
4867
|
-
|
|
5051
|
+
`${webRoot2}/serverEntry.tsx`
|
|
4868
5052
|
);
|
|
4869
5053
|
const rendered = await render(initialProps);
|
|
4870
5054
|
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
@@ -4880,6 +5064,10 @@ async function createAppServer(webRoot2, reqLocals, port) {
|
|
|
4880
5064
|
res.status(500).end(e.stack);
|
|
4881
5065
|
}
|
|
4882
5066
|
});
|
|
5067
|
+
app.use((err, req, res, next) => {
|
|
5068
|
+
console.error("API Error:", err);
|
|
5069
|
+
res.status(500).json({ error: "Internal server error" });
|
|
5070
|
+
});
|
|
4883
5071
|
app.listen(port, () => {
|
|
4884
5072
|
console.log(`Server started at http://localhost:${port}`);
|
|
4885
5073
|
});
|
|
@@ -5046,7 +5234,7 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5046
5234
|
}
|
|
5047
5235
|
|
|
5048
5236
|
// src/lib/validateHSPlatform.ts
|
|
5049
|
-
import
|
|
5237
|
+
import path13 from "path";
|
|
5050
5238
|
import fs5 from "fs";
|
|
5051
5239
|
import select from "@inquirer/select";
|
|
5052
5240
|
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
@@ -5058,12 +5246,12 @@ function findHSProjectJson(startPath) {
|
|
|
5058
5246
|
let currentDir = startPath;
|
|
5059
5247
|
let dirLevel = 0;
|
|
5060
5248
|
const maxDirLevel = 4;
|
|
5061
|
-
while (
|
|
5062
|
-
const filePath =
|
|
5249
|
+
while (path13.dirname(currentDir) !== currentDir && dirLevel < maxDirLevel) {
|
|
5250
|
+
const filePath = path13.join(currentDir, HSPROJECT_JSON);
|
|
5063
5251
|
if (checkFileExists(filePath)) {
|
|
5064
5252
|
return filePath;
|
|
5065
5253
|
}
|
|
5066
|
-
currentDir =
|
|
5254
|
+
currentDir = path13.dirname(currentDir);
|
|
5067
5255
|
dirLevel++;
|
|
5068
5256
|
}
|
|
5069
5257
|
console.log(
|
|
@@ -5369,7 +5557,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5369
5557
|
|
|
5370
5558
|
// src/lib/watchFieldsUpdates.ts
|
|
5371
5559
|
import fs6 from "fs";
|
|
5372
|
-
import
|
|
5560
|
+
import path14 from "path";
|
|
5373
5561
|
import readline from "readline";
|
|
5374
5562
|
var lastSerializedFieldsCache = {};
|
|
5375
5563
|
var formatAsTypeName = (str) => {
|
|
@@ -5381,9 +5569,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
5381
5569
|
const getEntryPathFromId = (id) => {
|
|
5382
5570
|
return id.startsWith(projectRoot) ? id.replace(`${projectRoot}/`, "") : "";
|
|
5383
5571
|
};
|
|
5384
|
-
const currentModuleId =
|
|
5572
|
+
const currentModuleId = path14.normalize(filePath);
|
|
5385
5573
|
const moduleEntryPath = getEntryPathFromId(currentModuleId);
|
|
5386
|
-
const subFolderTokens = moduleEntryPath.split(
|
|
5574
|
+
const subFolderTokens = moduleEntryPath.split(path14.sep);
|
|
5387
5575
|
return {
|
|
5388
5576
|
inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
|
|
5389
5577
|
isRootModuleFile: subFolderTokens.length === 3
|
|
@@ -5410,10 +5598,10 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5410
5598
|
return void 0;
|
|
5411
5599
|
if (isRootModuleFile)
|
|
5412
5600
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5413
|
-
const dir =
|
|
5601
|
+
const dir = path14.dirname(filePath);
|
|
5414
5602
|
const files = fs6.readdirSync(dir);
|
|
5415
5603
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5416
|
-
return indexFileName ? { indexFilePath:
|
|
5604
|
+
return indexFileName ? { indexFilePath: path14.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5417
5605
|
};
|
|
5418
5606
|
var getIndexFileFields = async (indexFilePath, indexFileName, viteServer) => {
|
|
5419
5607
|
let indexFile;
|
|
@@ -5437,7 +5625,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5437
5625
|
if (!indexInfo)
|
|
5438
5626
|
return;
|
|
5439
5627
|
const { indexFilePath, isRootModuleFile } = indexInfo;
|
|
5440
|
-
const indexFileName =
|
|
5628
|
+
const indexFileName = path14.parse(indexFilePath).name;
|
|
5441
5629
|
const isTypeFile = filePath.endsWith(".types.ts");
|
|
5442
5630
|
if (isTypeFile)
|
|
5443
5631
|
return;
|
|
@@ -5448,7 +5636,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5448
5636
|
);
|
|
5449
5637
|
if (fields) {
|
|
5450
5638
|
const typeFileName = isRootModuleFile ? `${indexFileName}.fields.types.ts` : "fields.type.ts";
|
|
5451
|
-
const typeFilePath =
|
|
5639
|
+
const typeFilePath = path14.join(path14.dirname(filePath), typeFileName);
|
|
5452
5640
|
const lastSerializedFields = lastSerializedFieldsCache[typeFilePath];
|
|
5453
5641
|
const serializedFields = JSON.stringify(fields);
|
|
5454
5642
|
if (lastSerializedFields === serializedFields)
|
|
@@ -5456,7 +5644,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5456
5644
|
const hasAutoGenComment = await fileContainsAutoGenComment(typeFilePath);
|
|
5457
5645
|
if (!hasAutoGenComment)
|
|
5458
5646
|
return;
|
|
5459
|
-
const moduleFolderName =
|
|
5647
|
+
const moduleFolderName = path14.basename(path14.dirname(filePath));
|
|
5460
5648
|
const outputTypeName = formatAsTypeName(moduleFolderName);
|
|
5461
5649
|
const didSucceed = writeFieldsType(fields, typeFilePath, outputTypeName);
|
|
5462
5650
|
if (didSucceed) {
|
|
@@ -5472,7 +5660,7 @@ var maybeUpdateFields = async (filePath, viteServer, projectRoot) => {
|
|
|
5472
5660
|
var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
5473
5661
|
const { moduleSubpaths } = findAllModulesInRoot(projectRoot);
|
|
5474
5662
|
moduleSubpaths.forEach((modulePath) => {
|
|
5475
|
-
const resolvedPath =
|
|
5663
|
+
const resolvedPath = path14.resolve(projectRoot, modulePath);
|
|
5476
5664
|
maybeUpdateFields(resolvedPath, viteServer, projectRoot);
|
|
5477
5665
|
});
|
|
5478
5666
|
const watchCallback = (filePath) => maybeUpdateFields(filePath, viteServer, projectRoot);
|
|
@@ -5496,7 +5684,7 @@ var BASE_PATH = "/";
|
|
|
5496
5684
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
5497
5685
|
var SHADOW_PORT = 1442;
|
|
5498
5686
|
var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
|
|
5499
|
-
async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2,
|
|
5687
|
+
async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2, showUI2) {
|
|
5500
5688
|
let authedPortalId = null;
|
|
5501
5689
|
let authedEnv = null;
|
|
5502
5690
|
let jsRenderingGates = [];
|
|
@@ -5610,7 +5798,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5610
5798
|
} catch (e) {
|
|
5611
5799
|
authedHublet = "na1";
|
|
5612
5800
|
}
|
|
5613
|
-
const absoluteWebRoot =
|
|
5801
|
+
const absoluteWebRoot = normalizePath9(path15.resolve(process.cwd(), webRoot2));
|
|
5614
5802
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
5615
5803
|
const projectConfigPath = findHSProjectJson(absoluteWebRoot);
|
|
5616
5804
|
if (authedPortalId) {
|
|
@@ -5701,9 +5889,9 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5701
5889
|
HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectComponentPath} (at ${protocol}://hslocal.net:${PORT}${extraServerInfo})
|
|
5702
5890
|
`
|
|
5703
5891
|
);
|
|
5704
|
-
if (
|
|
5705
|
-
const appWebRoot =
|
|
5706
|
-
|
|
5892
|
+
if (showUI2) {
|
|
5893
|
+
const appWebRoot = path15.join(
|
|
5894
|
+
path15.dirname(url2.fileURLToPath(import.meta.url)),
|
|
5707
5895
|
"../app"
|
|
5708
5896
|
);
|
|
5709
5897
|
const reqLocals = {
|
|
@@ -5719,8 +5907,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5719
5907
|
httpServers.push(appServer);
|
|
5720
5908
|
}
|
|
5721
5909
|
if (storybook2) {
|
|
5722
|
-
const packageRoot =
|
|
5723
|
-
const configPath =
|
|
5910
|
+
const packageRoot = path15.dirname(url2.fileURLToPath(import.meta.url));
|
|
5911
|
+
const configPath = path15.resolve(packageRoot, "./storybook-main");
|
|
5724
5912
|
sendTrackingRequest("start-storybook");
|
|
5725
5913
|
const storybookProcess = spawn(
|
|
5726
5914
|
"sb",
|
|
@@ -5740,7 +5928,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
5740
5928
|
portalId: authedPortalId.toString(),
|
|
5741
5929
|
hsEnv: authedEnv,
|
|
5742
5930
|
hublet: authedHublet,
|
|
5743
|
-
WEB_ROOT:
|
|
5931
|
+
WEB_ROOT: path15.join(webRoot2, "components")
|
|
5744
5932
|
}
|
|
5745
5933
|
}
|
|
5746
5934
|
);
|
|
@@ -5788,7 +5976,8 @@ var {
|
|
|
5788
5976
|
sslEnabledOption,
|
|
5789
5977
|
storybook,
|
|
5790
5978
|
fieldGenEnabledOption,
|
|
5791
|
-
resetSession
|
|
5979
|
+
resetSession,
|
|
5980
|
+
showUI
|
|
5792
5981
|
} = getDevServerCommandLineOptions(process.argv);
|
|
5793
5982
|
if (!webRoot) {
|
|
5794
5983
|
throw new Error(`No web root path argument specified`);
|
|
@@ -5808,5 +5997,6 @@ createDevServer_default(
|
|
|
5808
5997
|
hubspotCliAccountNameOption,
|
|
5809
5998
|
sslEnabledOption,
|
|
5810
5999
|
fieldGenEnabledOption,
|
|
5811
|
-
themePreviewOptions
|
|
6000
|
+
themePreviewOptions,
|
|
6001
|
+
showUI
|
|
5812
6002
|
);
|