@hubspot/cms-dev-server 0.18.15 → 0.18.18
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/generateJsonFromJsx.js +15 -22
- package/dist/index.js +78 -78
- package/dist/internalSsr.js +22 -6
- package/dist/run.js +78 -78
- package/dist/storybook/index.js +1 -1
- package/dist/storybook-main/main.js +26 -10
- package/package.json +3 -3
- package/types/api/designmanager.d.ts +4 -0
- package/types/lib/getDevServerUIData.d.ts +14 -6
- package/types/plugins/devSecretsPlugin.d.ts +1 -1
- package/types/proxyPage/fetchPreviewInfo.d.ts +1 -0
- package/types/routes/meta.d.ts +2 -0
- package/types/shadowDevServer/createShadowDevServerRoutes.d.ts +1 -2
- package/types/shadowDevServer/startShadowDevServer.d.ts +1 -2
- package/dist/generateJsonFromJsx.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/internalSsr.js.map +0 -7
- package/dist/island-runtime.js.map +0 -7
- package/dist/run.js.map +0 -7
- package/dist/storybook/index.js.map +0 -7
- package/dist/storybook-main/main.js.map +0 -7
- package/dist/storybook-main/preview.js.map +0 -7
- package/types/island-runtime.d.ts +0 -2
|
@@ -9,7 +9,7 @@ import { normalizePath as normalizePath2 } from "vite";
|
|
|
9
9
|
import { createServer as createViteServer } from "vite";
|
|
10
10
|
import { default as react } from "@vitejs/plugin-react";
|
|
11
11
|
|
|
12
|
-
// ../cms-js-internal/dist/types-
|
|
12
|
+
// ../cms-js-internal/dist/types-CsJ4tzsl.js
|
|
13
13
|
import path from "path";
|
|
14
14
|
var viteRoot;
|
|
15
15
|
var viteCommand;
|
|
@@ -126,7 +126,7 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
126
126
|
},
|
|
127
127
|
transform(code, id) {
|
|
128
128
|
const moduleInfo = this.getModuleInfo(id);
|
|
129
|
-
if (
|
|
129
|
+
if (!shouldAnalyzeModule(config, moduleInfo, code))
|
|
130
130
|
return null;
|
|
131
131
|
const contentDescriptors = analyzeSourceCodeUsages(
|
|
132
132
|
this,
|
|
@@ -141,7 +141,6 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
return null;
|
|
145
144
|
},
|
|
146
145
|
buildEnd(error) {
|
|
147
146
|
if (error)
|
|
@@ -213,9 +212,14 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
213
212
|
function toRelativePath(config, path4) {
|
|
214
213
|
return path4.replace(`${config.root}/`, "");
|
|
215
214
|
}
|
|
216
|
-
function
|
|
215
|
+
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
216
|
+
const [fileId, __] = moduleInfo.id.split("?");
|
|
217
217
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
218
|
-
return
|
|
218
|
+
return (
|
|
219
|
+
// analyze customer code only
|
|
220
|
+
!isExternal && moduleInfo.id.startsWith(config.root) && // jsx files that contain "Module" / "DndArea"
|
|
221
|
+
(fileId.endsWith(".tsx") || fileId.endsWith(".jsx")) && (code.includes(CMS_MODULE_COMPONENT_NAME) || code.includes(DND_AREA_COMPONENT_NAME))
|
|
222
|
+
);
|
|
219
223
|
}
|
|
220
224
|
function getEntryPoints(ctx, config) {
|
|
221
225
|
return Array.from(ctx.getModuleIds()).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => ctx.getModuleInfo(moduleId)).filter((moduleInfo) => moduleInfo.isEntry);
|
|
@@ -442,26 +446,15 @@ import { default as mkcert } from "vite-plugin-mkcert";
|
|
|
442
446
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
443
447
|
|
|
444
448
|
// src/plugins/devSecretsPlugin.ts
|
|
445
|
-
function devSecretsPlugin(secretNames) {
|
|
449
|
+
function devSecretsPlugin(secretNames = []) {
|
|
446
450
|
return {
|
|
447
451
|
name: "dev-secrets",
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
"@hubspot/cms-components"
|
|
453
|
-
);
|
|
454
|
-
if (cmsComponents2.setSecretsFromEnv) {
|
|
455
|
-
console.log(
|
|
456
|
-
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
457
|
-
);
|
|
458
|
-
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
459
|
-
} else if (secretNames.length > 0) {
|
|
460
|
-
console.warn(
|
|
461
|
-
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
462
|
-
);
|
|
452
|
+
config: () => {
|
|
453
|
+
return {
|
|
454
|
+
define: {
|
|
455
|
+
"import.meta.env.secretNames": secretNames
|
|
463
456
|
}
|
|
464
|
-
}
|
|
457
|
+
};
|
|
465
458
|
}
|
|
466
459
|
};
|
|
467
460
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createServer as createViteServer } from "vite";
|
|
3
3
|
import { default as react } from "@vitejs/plugin-react";
|
|
4
4
|
|
|
5
|
-
// ../cms-js-internal/dist/types-
|
|
5
|
+
// ../cms-js-internal/dist/types-CsJ4tzsl.js
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { createHash } from "crypto";
|
|
8
8
|
import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
@@ -224,11 +224,15 @@ function findAllModulesInRoot(webRoot) {
|
|
|
224
224
|
);
|
|
225
225
|
const moduleSubpaths = Object.keys(allModuleComponents);
|
|
226
226
|
const moduleExtensions = Object.values(allModuleComponents).map((path22) => {
|
|
227
|
-
|
|
227
|
+
if (!path22)
|
|
228
|
+
return "";
|
|
229
|
+
const extension = path22.split(".").pop() || "";
|
|
228
230
|
return extension;
|
|
229
231
|
});
|
|
230
232
|
const moduleNamesWithExtension = Object.values(allModuleComponents).map(
|
|
231
233
|
(path22) => {
|
|
234
|
+
if (!path22)
|
|
235
|
+
return "";
|
|
232
236
|
const file = path22.replace("components/modules/", "");
|
|
233
237
|
return file.includes("/index.") ? file.split("/index.")[0] : file;
|
|
234
238
|
}
|
|
@@ -357,6 +361,14 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
357
361
|
if (isUngatedForClientOnlySupplementalFieldSerialization && output.clientOnly) {
|
|
358
362
|
output.supplementalFieldValues = supplementalFieldValues;
|
|
359
363
|
}
|
|
364
|
+
if (output.supplementalFieldValues) {
|
|
365
|
+
output.supplementalFieldValues = Object.keys(
|
|
366
|
+
output.supplementalFieldValues
|
|
367
|
+
).sort().reduce((acc, key) => {
|
|
368
|
+
acc[key] = output.supplementalFieldValues[key];
|
|
369
|
+
return acc;
|
|
370
|
+
}, {});
|
|
371
|
+
}
|
|
360
372
|
return output;
|
|
361
373
|
}
|
|
362
374
|
);
|
|
@@ -509,7 +521,7 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
509
521
|
},
|
|
510
522
|
transform(code, id) {
|
|
511
523
|
const moduleInfo = this.getModuleInfo(id);
|
|
512
|
-
if (
|
|
524
|
+
if (!shouldAnalyzeModule(config, moduleInfo, code))
|
|
513
525
|
return null;
|
|
514
526
|
const contentDescriptors = analyzeSourceCodeUsages(
|
|
515
527
|
this,
|
|
@@ -524,7 +536,6 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
524
536
|
}
|
|
525
537
|
};
|
|
526
538
|
}
|
|
527
|
-
return null;
|
|
528
539
|
},
|
|
529
540
|
buildEnd(error) {
|
|
530
541
|
if (error)
|
|
@@ -596,9 +607,14 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
596
607
|
function toRelativePath(config, path15) {
|
|
597
608
|
return path15.replace(`${config.root}/`, "");
|
|
598
609
|
}
|
|
599
|
-
function
|
|
610
|
+
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
611
|
+
const [fileId, __] = moduleInfo.id.split("?");
|
|
600
612
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
601
|
-
return
|
|
613
|
+
return (
|
|
614
|
+
// analyze customer code only
|
|
615
|
+
!isExternal && moduleInfo.id.startsWith(config.root) && // jsx files that contain "Module" / "DndArea"
|
|
616
|
+
(fileId.endsWith(".tsx") || fileId.endsWith(".jsx")) && (code.includes(CMS_MODULE_COMPONENT_NAME) || code.includes(DND_AREA_COMPONENT_NAME))
|
|
617
|
+
);
|
|
602
618
|
}
|
|
603
619
|
function getEntryPoints(ctx, config) {
|
|
604
620
|
return Array.from(ctx.getModuleIds()).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => ctx.getModuleInfo(moduleId)).filter((moduleInfo) => moduleInfo.isEntry);
|
|
@@ -925,26 +941,15 @@ import { default as mkcert } from "vite-plugin-mkcert";
|
|
|
925
941
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
926
942
|
|
|
927
943
|
// src/plugins/devSecretsPlugin.ts
|
|
928
|
-
function devSecretsPlugin(secretNames) {
|
|
944
|
+
function devSecretsPlugin(secretNames = []) {
|
|
929
945
|
return {
|
|
930
946
|
name: "dev-secrets",
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
"@hubspot/cms-components"
|
|
936
|
-
);
|
|
937
|
-
if (cmsComponents3.setSecretsFromEnv) {
|
|
938
|
-
console.log(
|
|
939
|
-
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
940
|
-
);
|
|
941
|
-
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
942
|
-
} else if (secretNames.length > 0) {
|
|
943
|
-
console.warn(
|
|
944
|
-
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
945
|
-
);
|
|
947
|
+
config: () => {
|
|
948
|
+
return {
|
|
949
|
+
define: {
|
|
950
|
+
"import.meta.env.secretNames": secretNames
|
|
946
951
|
}
|
|
947
|
-
}
|
|
952
|
+
};
|
|
948
953
|
}
|
|
949
954
|
};
|
|
950
955
|
}
|
|
@@ -1464,7 +1469,7 @@ function trackUsage(action) {
|
|
|
1464
1469
|
eventName: EVENT_NAME,
|
|
1465
1470
|
action,
|
|
1466
1471
|
nodeVersion: getNodeVersionData(),
|
|
1467
|
-
version: "0.18.
|
|
1472
|
+
version: "0.18.18",
|
|
1468
1473
|
os: getPlatform()
|
|
1469
1474
|
};
|
|
1470
1475
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1967,7 +1972,8 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
|
1967
1972
|
})).data;
|
|
1968
1973
|
return {
|
|
1969
1974
|
previewDomain: content.previewDomain ?? content.resolvedDomain,
|
|
1970
|
-
previewKey: content.previewKey
|
|
1975
|
+
previewKey: content.previewKey,
|
|
1976
|
+
templatePath: content.templatePath
|
|
1971
1977
|
};
|
|
1972
1978
|
} catch (error) {
|
|
1973
1979
|
if (error.statusCode === 403 && error.error.message.match(
|
|
@@ -4067,32 +4073,27 @@ import express from "express";
|
|
|
4067
4073
|
|
|
4068
4074
|
// src/shadowDevServer/createShadowDevServerRoutes.ts
|
|
4069
4075
|
import { Router as Router2 } from "express";
|
|
4070
|
-
import { getAccountId as getAccountId3
|
|
4076
|
+
import { getAccountId as getAccountId3 } from "@hubspot/local-dev-lib/config";
|
|
4071
4077
|
import cors from "cors";
|
|
4072
|
-
|
|
4073
|
-
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
4078
|
+
function getShadowDevServerCheckHandler(devServerPort, themePath) {
|
|
4074
4079
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
4075
4080
|
const { query } = request2;
|
|
4076
4081
|
if (query) {
|
|
4077
4082
|
const {
|
|
4078
4083
|
hostName,
|
|
4079
4084
|
pathName,
|
|
4080
|
-
protocol,
|
|
4081
4085
|
contentId,
|
|
4082
4086
|
portalId: portalIdString
|
|
4083
4087
|
} = query;
|
|
4084
|
-
const pageUrl = `${protocol}//${hostName}${pathName}`;
|
|
4085
4088
|
const portalId = parseInt(portalIdString, 10);
|
|
4086
|
-
let proxyEnv;
|
|
4087
4089
|
let accountId;
|
|
4088
|
-
let
|
|
4090
|
+
let isTemplateFromDevTheme = false;
|
|
4089
4091
|
let localProxyUrl;
|
|
4090
4092
|
try {
|
|
4091
4093
|
accountId = getAccountId3(portalId);
|
|
4092
4094
|
if (accountId === null) {
|
|
4093
4095
|
throw new Error();
|
|
4094
4096
|
}
|
|
4095
|
-
proxyEnv = getEnv3(accountId);
|
|
4096
4097
|
} catch (e) {
|
|
4097
4098
|
response.status(500).end(
|
|
4098
4099
|
`Unable to find account for hubid = ${portalId}. Please check your hubspot.config.yaml`
|
|
@@ -4100,37 +4101,19 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
4100
4101
|
return;
|
|
4101
4102
|
}
|
|
4102
4103
|
try {
|
|
4103
|
-
const
|
|
4104
|
+
const { templatePath } = await fetchPreviewInfo_default(
|
|
4104
4105
|
accountId,
|
|
4105
4106
|
portalId,
|
|
4106
4107
|
contentId
|
|
4107
4108
|
);
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
portalId,
|
|
4111
|
-
"na1",
|
|
4112
|
-
// bad lazy TF (but does it really matter for this check)
|
|
4113
|
-
proxyEnv,
|
|
4114
|
-
false,
|
|
4115
|
-
gates
|
|
4116
|
-
);
|
|
4117
|
-
const pageHtml = await makeProxyPreviewRequest(
|
|
4118
|
-
accountId,
|
|
4119
|
-
pageUrl,
|
|
4120
|
-
previewKey,
|
|
4121
|
-
contentId,
|
|
4122
|
-
projectName,
|
|
4123
|
-
environmentConfig,
|
|
4124
|
-
gates
|
|
4125
|
-
);
|
|
4126
|
-
const localRenderPlaceholders = findLocalRenderPlaceholders(
|
|
4127
|
-
pageHtml.data
|
|
4128
|
-
);
|
|
4129
|
-
if (localRenderPlaceholders.length) {
|
|
4130
|
-
hasJSBuildingBlocks = true;
|
|
4109
|
+
if (templatePath.startsWith(themePath)) {
|
|
4110
|
+
isTemplateFromDevTheme = true;
|
|
4131
4111
|
localProxyUrl = `http://${hostName}.hslocal.net:${devServerPort}${pathName}`;
|
|
4132
4112
|
}
|
|
4133
|
-
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4113
|
+
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4114
|
+
isTemplateFromDevTheme,
|
|
4115
|
+
localProxyUrl
|
|
4116
|
+
});
|
|
4134
4117
|
} catch (error) {
|
|
4135
4118
|
response.status(500).end(
|
|
4136
4119
|
`Failed proxy render of page id = ${contentId} hub id = ${portalId}
|
|
@@ -4146,19 +4129,19 @@ ${error.stack}`
|
|
|
4146
4129
|
}
|
|
4147
4130
|
};
|
|
4148
4131
|
}
|
|
4149
|
-
async function createShadowDevServerRoutes(devServerPort,
|
|
4132
|
+
async function createShadowDevServerRoutes(devServerPort, themePath) {
|
|
4150
4133
|
const shadowDevServerRoutes = Router2();
|
|
4151
4134
|
shadowDevServerRoutes.get(
|
|
4152
4135
|
"/check-if-local-dev-server",
|
|
4153
4136
|
cors(),
|
|
4154
|
-
getShadowDevServerCheckHandler(devServerPort,
|
|
4137
|
+
getShadowDevServerCheckHandler(devServerPort, themePath)
|
|
4155
4138
|
);
|
|
4156
4139
|
return shadowDevServerRoutes;
|
|
4157
4140
|
}
|
|
4158
4141
|
|
|
4159
4142
|
// src/shadowDevServer/startShadowDevServer.ts
|
|
4160
4143
|
var testNetServer = net.createServer();
|
|
4161
|
-
async function startShadowDevServer(devServerPort, shadowPort,
|
|
4144
|
+
async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
4162
4145
|
const portIsTaken = await new Promise((res, rej) => {
|
|
4163
4146
|
console.log(`Starting proxy link server on port ${shadowPort}`);
|
|
4164
4147
|
testNetServer.once("error", (err) => {
|
|
@@ -4186,11 +4169,7 @@ async function startShadowDevServer(devServerPort, shadowPort, projectName, jsRe
|
|
|
4186
4169
|
shadowDevServer.listen(shadowPort);
|
|
4187
4170
|
shadowDevServer.use(
|
|
4188
4171
|
"/",
|
|
4189
|
-
await createShadowDevServerRoutes(
|
|
4190
|
-
devServerPort,
|
|
4191
|
-
projectName,
|
|
4192
|
-
jsRenderingGates
|
|
4193
|
-
)
|
|
4172
|
+
await createShadowDevServerRoutes(devServerPort, themePath)
|
|
4194
4173
|
);
|
|
4195
4174
|
}
|
|
4196
4175
|
|
|
@@ -4203,7 +4182,7 @@ import { default as react2 } from "@vitejs/plugin-react";
|
|
|
4203
4182
|
// src/lib/getDevServerUIData.ts
|
|
4204
4183
|
import path11 from "path";
|
|
4205
4184
|
import { normalizePath as normalizePath8 } from "vite";
|
|
4206
|
-
function
|
|
4185
|
+
function mapReactModules(modules, themeWebRoot, viteServer) {
|
|
4207
4186
|
return Promise.all(
|
|
4208
4187
|
modules.moduleNames.map(async (name, index) => {
|
|
4209
4188
|
const modulePath = normalizePath8(
|
|
@@ -4212,6 +4191,7 @@ function mapModulesData(modules, themeWebRoot, viteServer) {
|
|
|
4212
4191
|
const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
|
|
4213
4192
|
return {
|
|
4214
4193
|
name,
|
|
4194
|
+
type: "react" /* REACT */,
|
|
4215
4195
|
subPath: modules.moduleSubpaths[index],
|
|
4216
4196
|
nameWithExtension: modules.moduleNamesWithExtension[index],
|
|
4217
4197
|
extension: modules.moduleExtensions[index],
|
|
@@ -4220,10 +4200,25 @@ function mapModulesData(modules, themeWebRoot, viteServer) {
|
|
|
4220
4200
|
})
|
|
4221
4201
|
);
|
|
4222
4202
|
}
|
|
4223
|
-
function
|
|
4224
|
-
return modules.
|
|
4203
|
+
function normalizeHubLModules(modules) {
|
|
4204
|
+
return modules.map((module) => ({
|
|
4205
|
+
name: module.name,
|
|
4206
|
+
type: "hubl" /* HUBL */,
|
|
4207
|
+
subPath: `@projects/${module.path.split("/@projects/")[1] || module.path}`,
|
|
4208
|
+
nameWithExtension: module.filename,
|
|
4209
|
+
fieldsJson: module.fields
|
|
4210
|
+
}));
|
|
4211
|
+
}
|
|
4212
|
+
function normalizePartialsData(partialData) {
|
|
4213
|
+
return partialData.partialNames.map((name, index) => ({
|
|
4225
4214
|
name,
|
|
4226
|
-
subPath:
|
|
4215
|
+
subPath: partialData.partialSubpaths[index]
|
|
4216
|
+
}));
|
|
4217
|
+
}
|
|
4218
|
+
function normalizeTemplatesData(templates) {
|
|
4219
|
+
return templates.map((template) => ({
|
|
4220
|
+
name: template.displayName || template.label,
|
|
4221
|
+
subPath: `@projects/${template.path.split("/@projects/")[1] || template.path}`
|
|
4227
4222
|
}));
|
|
4228
4223
|
}
|
|
4229
4224
|
async function getDevServerUIData(reqLocals) {
|
|
@@ -4238,7 +4233,7 @@ async function getDevServerUIData(reqLocals) {
|
|
|
4238
4233
|
} = reqLocals;
|
|
4239
4234
|
const modulesData = findAllModulesInRoot(themeWebRoot);
|
|
4240
4235
|
const partialsData = findAllPartialsInRoot(themeWebRoot);
|
|
4241
|
-
const
|
|
4236
|
+
const reactModules = await mapReactModules(
|
|
4242
4237
|
modulesData,
|
|
4243
4238
|
themeWebRoot,
|
|
4244
4239
|
viteServer
|
|
@@ -4255,14 +4250,15 @@ async function getDevServerUIData(reqLocals) {
|
|
|
4255
4250
|
const hubLTemplates = (hubLTemplateData == null ? void 0 : hubLTemplateData.objects.filter(
|
|
4256
4251
|
(template) => isCodedFile(template.filename)
|
|
4257
4252
|
)) || [];
|
|
4253
|
+
const mappedHubLModules = normalizeHubLModules((hubLModuleData == null ? void 0 : hubLModuleData.objects) || []);
|
|
4258
4254
|
return {
|
|
4259
4255
|
authedPortalId,
|
|
4260
4256
|
authedEnv,
|
|
4261
4257
|
projectName,
|
|
4262
|
-
modulesData:
|
|
4263
|
-
partialsData:
|
|
4264
|
-
hubLModules:
|
|
4265
|
-
hubLTemplates,
|
|
4258
|
+
modulesData: reactModules,
|
|
4259
|
+
partialsData: normalizePartialsData(partialsData),
|
|
4260
|
+
hubLModules: mappedHubLModules || [],
|
|
4261
|
+
hubLTemplates: normalizeTemplatesData(hubLTemplates),
|
|
4266
4262
|
themeWebRoot,
|
|
4267
4263
|
webRootProjectComponentFolder
|
|
4268
4264
|
};
|
|
@@ -4474,7 +4470,7 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
|
|
|
4474
4470
|
|
|
4475
4471
|
// src/createDevServer.ts
|
|
4476
4472
|
import {
|
|
4477
|
-
getEnv as
|
|
4473
|
+
getEnv as getEnv3,
|
|
4478
4474
|
getAccountId as getAccountId4,
|
|
4479
4475
|
getAccountConfig as getAccountConfig2,
|
|
4480
4476
|
loadConfig,
|
|
@@ -5039,7 +5035,7 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
|
|
|
5039
5035
|
secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
|
|
5040
5036
|
if (validateConfig()) {
|
|
5041
5037
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption);
|
|
5042
|
-
const env =
|
|
5038
|
+
const env = getEnv3(hubspotCliAccountNameOption);
|
|
5043
5039
|
if (!env) {
|
|
5044
5040
|
throw new Error(
|
|
5045
5041
|
`No environment found for account ${hubspotCliAccountNameOption} from hubspot.config.yaml`
|
|
@@ -5204,7 +5200,11 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5204
5200
|
httpServers.push(httpServer);
|
|
5205
5201
|
}
|
|
5206
5202
|
if (!process.env.IN_CODESANDBOX && !process.env.CODESANDBOX_HOST) {
|
|
5207
|
-
startShadowDevServer(
|
|
5203
|
+
startShadowDevServer(
|
|
5204
|
+
PORT,
|
|
5205
|
+
SHADOW_PORT,
|
|
5206
|
+
themePreviewOptions ? themePreviewOptions.dest : ""
|
|
5207
|
+
);
|
|
5208
5208
|
}
|
|
5209
5209
|
let extraServerInfo = "";
|
|
5210
5210
|
const protocol = sslEnabledOption ? "https" : "http";
|
package/dist/internalSsr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../cms-js-internal/dist/types-
|
|
1
|
+
// ../cms-js-internal/dist/types-CsJ4tzsl.js
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { createHash } from "crypto";
|
|
4
4
|
import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
@@ -384,11 +384,15 @@ function findAllModulesInRoot(webRoot) {
|
|
|
384
384
|
);
|
|
385
385
|
const moduleSubpaths = Object.keys(allModuleComponents);
|
|
386
386
|
const moduleExtensions = Object.values(allModuleComponents).map((path2) => {
|
|
387
|
-
|
|
387
|
+
if (!path2)
|
|
388
|
+
return "";
|
|
389
|
+
const extension = path2.split(".").pop() || "";
|
|
388
390
|
return extension;
|
|
389
391
|
});
|
|
390
392
|
const moduleNamesWithExtension = Object.values(allModuleComponents).map(
|
|
391
393
|
(path2) => {
|
|
394
|
+
if (!path2)
|
|
395
|
+
return "";
|
|
392
396
|
const file = path2.replace("components/modules/", "");
|
|
393
397
|
return file.includes("/index.") ? file.split("/index.")[0] : file;
|
|
394
398
|
}
|
|
@@ -521,6 +525,14 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
521
525
|
if (isUngatedForClientOnlySupplementalFieldSerialization && output.clientOnly) {
|
|
522
526
|
output.supplementalFieldValues = supplementalFieldValues;
|
|
523
527
|
}
|
|
528
|
+
if (output.supplementalFieldValues) {
|
|
529
|
+
output.supplementalFieldValues = Object.keys(
|
|
530
|
+
output.supplementalFieldValues
|
|
531
|
+
).sort().reduce((acc, key) => {
|
|
532
|
+
acc[key] = output.supplementalFieldValues[key];
|
|
533
|
+
return acc;
|
|
534
|
+
}, {});
|
|
535
|
+
}
|
|
524
536
|
return output;
|
|
525
537
|
}
|
|
526
538
|
);
|
|
@@ -673,7 +685,7 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
673
685
|
},
|
|
674
686
|
transform(code, id) {
|
|
675
687
|
const moduleInfo = this.getModuleInfo(id);
|
|
676
|
-
if (
|
|
688
|
+
if (!shouldAnalyzeModule(config, moduleInfo, code))
|
|
677
689
|
return null;
|
|
678
690
|
const contentDescriptors = analyzeSourceCodeUsages(
|
|
679
691
|
this,
|
|
@@ -688,7 +700,6 @@ function findCmsModules(buildContentDescriptors = {}) {
|
|
|
688
700
|
}
|
|
689
701
|
};
|
|
690
702
|
}
|
|
691
|
-
return null;
|
|
692
703
|
},
|
|
693
704
|
buildEnd(error) {
|
|
694
705
|
if (error)
|
|
@@ -760,9 +771,14 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
|
|
|
760
771
|
function toRelativePath(config, path2) {
|
|
761
772
|
return path2.replace(`${config.root}/`, "");
|
|
762
773
|
}
|
|
763
|
-
function
|
|
774
|
+
function shouldAnalyzeModule(config, moduleInfo, code) {
|
|
775
|
+
const [fileId, __] = moduleInfo.id.split("?");
|
|
764
776
|
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
765
|
-
return
|
|
777
|
+
return (
|
|
778
|
+
// analyze customer code only
|
|
779
|
+
!isExternal && moduleInfo.id.startsWith(config.root) && // jsx files that contain "Module" / "DndArea"
|
|
780
|
+
(fileId.endsWith(".tsx") || fileId.endsWith(".jsx")) && (code.includes(CMS_MODULE_COMPONENT_NAME) || code.includes(DND_AREA_COMPONENT_NAME))
|
|
781
|
+
);
|
|
766
782
|
}
|
|
767
783
|
function getEntryPoints(ctx, config) {
|
|
768
784
|
return Array.from(ctx.getModuleIds()).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => ctx.getModuleInfo(moduleId)).filter((moduleInfo) => moduleInfo.isEntry);
|