@hubspot/cms-dev-server 0.18.17 → 0.18.19
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 +6 -17
- package/dist/index.js +36 -68
- package/dist/run.js +36 -68
- package/package.json +3 -3
- 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/types/lib/renderModuleJson.d.ts +0 -4
|
@@ -446,26 +446,15 @@ import { default as mkcert } from "vite-plugin-mkcert";
|
|
|
446
446
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
447
447
|
|
|
448
448
|
// src/plugins/devSecretsPlugin.ts
|
|
449
|
-
function devSecretsPlugin(secretNames) {
|
|
449
|
+
function devSecretsPlugin(secretNames = []) {
|
|
450
450
|
return {
|
|
451
451
|
name: "dev-secrets",
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
"@hubspot/cms-components"
|
|
457
|
-
);
|
|
458
|
-
if (cmsComponents2.setSecretsFromEnv) {
|
|
459
|
-
console.log(
|
|
460
|
-
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
461
|
-
);
|
|
462
|
-
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
463
|
-
} else if (secretNames.length > 0) {
|
|
464
|
-
console.warn(
|
|
465
|
-
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
466
|
-
);
|
|
452
|
+
config: () => {
|
|
453
|
+
return {
|
|
454
|
+
define: {
|
|
455
|
+
"import.meta.env.secretNames": secretNames
|
|
467
456
|
}
|
|
468
|
-
}
|
|
457
|
+
};
|
|
469
458
|
}
|
|
470
459
|
};
|
|
471
460
|
}
|
package/dist/index.js
CHANGED
|
@@ -933,26 +933,15 @@ import { default as mkcert } from "vite-plugin-mkcert";
|
|
|
933
933
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
934
934
|
|
|
935
935
|
// src/plugins/devSecretsPlugin.ts
|
|
936
|
-
function devSecretsPlugin(secretNames) {
|
|
936
|
+
function devSecretsPlugin(secretNames = []) {
|
|
937
937
|
return {
|
|
938
938
|
name: "dev-secrets",
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
"@hubspot/cms-components"
|
|
944
|
-
);
|
|
945
|
-
if (cmsComponents3.setSecretsFromEnv) {
|
|
946
|
-
console.log(
|
|
947
|
-
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
948
|
-
);
|
|
949
|
-
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
950
|
-
} else if (secretNames.length > 0) {
|
|
951
|
-
console.warn(
|
|
952
|
-
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
953
|
-
);
|
|
939
|
+
config: () => {
|
|
940
|
+
return {
|
|
941
|
+
define: {
|
|
942
|
+
"import.meta.env.secretNames": secretNames
|
|
954
943
|
}
|
|
955
|
-
}
|
|
944
|
+
};
|
|
956
945
|
}
|
|
957
946
|
};
|
|
958
947
|
}
|
|
@@ -1472,7 +1461,7 @@ function trackUsage(action) {
|
|
|
1472
1461
|
eventName: EVENT_NAME,
|
|
1473
1462
|
action,
|
|
1474
1463
|
nodeVersion: getNodeVersionData(),
|
|
1475
|
-
version: "0.18.
|
|
1464
|
+
version: "0.18.19",
|
|
1476
1465
|
os: getPlatform()
|
|
1477
1466
|
};
|
|
1478
1467
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1975,7 +1964,8 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
|
1975
1964
|
})).data;
|
|
1976
1965
|
return {
|
|
1977
1966
|
previewDomain: content.previewDomain ?? content.resolvedDomain,
|
|
1978
|
-
previewKey: content.previewKey
|
|
1967
|
+
previewKey: content.previewKey,
|
|
1968
|
+
templatePath: content.templatePath
|
|
1979
1969
|
};
|
|
1980
1970
|
} catch (error) {
|
|
1981
1971
|
if (error.statusCode === 403 && error.error.message.match(
|
|
@@ -3925,9 +3915,7 @@ var buildModuleIndex = () => buildHTMLResponse(`
|
|
|
3925
3915
|
|
|
3926
3916
|
// src/routes/hublTemplateRouteHandler.ts
|
|
3927
3917
|
import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
|
|
3928
|
-
import {
|
|
3929
|
-
buildStaticEnvConfig as buildStaticEnvConfig5
|
|
3930
|
-
} from "@hubspot/cms-components";
|
|
3918
|
+
import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
|
|
3931
3919
|
import { getEnv as getEnv2 } from "@hubspot/local-dev-lib/config";
|
|
3932
3920
|
var templateRouteHandler = async (request2, response) => {
|
|
3933
3921
|
sendTrackingRequest("view-template-route");
|
|
@@ -3957,7 +3945,9 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
3957
3945
|
try {
|
|
3958
3946
|
templateInfo = await fetchTemplateByPath(authedPortalId, calculatedPath);
|
|
3959
3947
|
} catch (err) {
|
|
3960
|
-
console.error(
|
|
3948
|
+
console.error(
|
|
3949
|
+
`Failed to fetch template data for ${calculatedPath}: ${err}`
|
|
3950
|
+
);
|
|
3961
3951
|
}
|
|
3962
3952
|
if (!templateInfo || !("previewKey" in templateInfo)) {
|
|
3963
3953
|
response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
|
|
@@ -3974,6 +3964,7 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
3974
3964
|
...request2.query
|
|
3975
3965
|
};
|
|
3976
3966
|
const previewUrl = new URL(getPreviewUrl(request2, params));
|
|
3967
|
+
const fullOriginalUrl = `${request2.protocol}://${request2.get("host")}${request2.originalUrl}`;
|
|
3977
3968
|
try {
|
|
3978
3969
|
const result = (await hsCliHttp10.get(authedPortalId, {
|
|
3979
3970
|
baseURL: previewUrl.origin,
|
|
@@ -3985,7 +3976,7 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
3985
3976
|
response,
|
|
3986
3977
|
pageHtml,
|
|
3987
3978
|
webRoot,
|
|
3988
|
-
|
|
3979
|
+
fullOriginalUrl,
|
|
3989
3980
|
environmentConfig,
|
|
3990
3981
|
viteServer,
|
|
3991
3982
|
projectName,
|
|
@@ -4075,32 +4066,27 @@ import express from "express";
|
|
|
4075
4066
|
|
|
4076
4067
|
// src/shadowDevServer/createShadowDevServerRoutes.ts
|
|
4077
4068
|
import { Router as Router2 } from "express";
|
|
4078
|
-
import { getAccountId as getAccountId3
|
|
4069
|
+
import { getAccountId as getAccountId3 } from "@hubspot/local-dev-lib/config";
|
|
4079
4070
|
import cors from "cors";
|
|
4080
|
-
|
|
4081
|
-
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
4071
|
+
function getShadowDevServerCheckHandler(devServerPort, themePath) {
|
|
4082
4072
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
4083
4073
|
const { query } = request2;
|
|
4084
4074
|
if (query) {
|
|
4085
4075
|
const {
|
|
4086
4076
|
hostName,
|
|
4087
4077
|
pathName,
|
|
4088
|
-
protocol,
|
|
4089
4078
|
contentId,
|
|
4090
4079
|
portalId: portalIdString
|
|
4091
4080
|
} = query;
|
|
4092
|
-
const pageUrl = `${protocol}//${hostName}${pathName}`;
|
|
4093
4081
|
const portalId = parseInt(portalIdString, 10);
|
|
4094
|
-
let proxyEnv;
|
|
4095
4082
|
let accountId;
|
|
4096
|
-
let
|
|
4083
|
+
let isTemplateFromDevTheme = false;
|
|
4097
4084
|
let localProxyUrl;
|
|
4098
4085
|
try {
|
|
4099
4086
|
accountId = getAccountId3(portalId);
|
|
4100
4087
|
if (accountId === null) {
|
|
4101
4088
|
throw new Error();
|
|
4102
4089
|
}
|
|
4103
|
-
proxyEnv = getEnv3(accountId);
|
|
4104
4090
|
} catch (e) {
|
|
4105
4091
|
response.status(500).end(
|
|
4106
4092
|
`Unable to find account for hubid = ${portalId}. Please check your hubspot.config.yaml`
|
|
@@ -4108,37 +4094,19 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
4108
4094
|
return;
|
|
4109
4095
|
}
|
|
4110
4096
|
try {
|
|
4111
|
-
const
|
|
4097
|
+
const { templatePath } = await fetchPreviewInfo_default(
|
|
4112
4098
|
accountId,
|
|
4113
4099
|
portalId,
|
|
4114
4100
|
contentId
|
|
4115
4101
|
);
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
portalId,
|
|
4119
|
-
"na1",
|
|
4120
|
-
// bad lazy TF (but does it really matter for this check)
|
|
4121
|
-
proxyEnv,
|
|
4122
|
-
false,
|
|
4123
|
-
gates
|
|
4124
|
-
);
|
|
4125
|
-
const pageHtml = await makeProxyPreviewRequest(
|
|
4126
|
-
accountId,
|
|
4127
|
-
pageUrl,
|
|
4128
|
-
previewKey,
|
|
4129
|
-
contentId,
|
|
4130
|
-
projectName,
|
|
4131
|
-
environmentConfig,
|
|
4132
|
-
gates
|
|
4133
|
-
);
|
|
4134
|
-
const localRenderPlaceholders = findLocalRenderPlaceholders(
|
|
4135
|
-
pageHtml.data
|
|
4136
|
-
);
|
|
4137
|
-
if (localRenderPlaceholders.length) {
|
|
4138
|
-
hasJSBuildingBlocks = true;
|
|
4102
|
+
if (templatePath.startsWith(themePath)) {
|
|
4103
|
+
isTemplateFromDevTheme = true;
|
|
4139
4104
|
localProxyUrl = `http://${hostName}.hslocal.net:${devServerPort}${pathName}`;
|
|
4140
4105
|
}
|
|
4141
|
-
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4106
|
+
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4107
|
+
isTemplateFromDevTheme,
|
|
4108
|
+
localProxyUrl
|
|
4109
|
+
});
|
|
4142
4110
|
} catch (error) {
|
|
4143
4111
|
response.status(500).end(
|
|
4144
4112
|
`Failed proxy render of page id = ${contentId} hub id = ${portalId}
|
|
@@ -4154,19 +4122,19 @@ ${error.stack}`
|
|
|
4154
4122
|
}
|
|
4155
4123
|
};
|
|
4156
4124
|
}
|
|
4157
|
-
async function createShadowDevServerRoutes(devServerPort,
|
|
4125
|
+
async function createShadowDevServerRoutes(devServerPort, themePath) {
|
|
4158
4126
|
const shadowDevServerRoutes = Router2();
|
|
4159
4127
|
shadowDevServerRoutes.get(
|
|
4160
4128
|
"/check-if-local-dev-server",
|
|
4161
4129
|
cors(),
|
|
4162
|
-
getShadowDevServerCheckHandler(devServerPort,
|
|
4130
|
+
getShadowDevServerCheckHandler(devServerPort, themePath)
|
|
4163
4131
|
);
|
|
4164
4132
|
return shadowDevServerRoutes;
|
|
4165
4133
|
}
|
|
4166
4134
|
|
|
4167
4135
|
// src/shadowDevServer/startShadowDevServer.ts
|
|
4168
4136
|
var testNetServer = net.createServer();
|
|
4169
|
-
async function startShadowDevServer(devServerPort, shadowPort,
|
|
4137
|
+
async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
4170
4138
|
const portIsTaken = await new Promise((res, rej) => {
|
|
4171
4139
|
console.log(`Starting proxy link server on port ${shadowPort}`);
|
|
4172
4140
|
testNetServer.once("error", (err) => {
|
|
@@ -4194,11 +4162,7 @@ async function startShadowDevServer(devServerPort, shadowPort, projectName, jsRe
|
|
|
4194
4162
|
shadowDevServer.listen(shadowPort);
|
|
4195
4163
|
shadowDevServer.use(
|
|
4196
4164
|
"/",
|
|
4197
|
-
await createShadowDevServerRoutes(
|
|
4198
|
-
devServerPort,
|
|
4199
|
-
projectName,
|
|
4200
|
-
jsRenderingGates
|
|
4201
|
-
)
|
|
4165
|
+
await createShadowDevServerRoutes(devServerPort, themePath)
|
|
4202
4166
|
);
|
|
4203
4167
|
}
|
|
4204
4168
|
|
|
@@ -4499,7 +4463,7 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
|
|
|
4499
4463
|
|
|
4500
4464
|
// src/createDevServer.ts
|
|
4501
4465
|
import {
|
|
4502
|
-
getEnv as
|
|
4466
|
+
getEnv as getEnv3,
|
|
4503
4467
|
getAccountId as getAccountId4,
|
|
4504
4468
|
getAccountConfig as getAccountConfig2,
|
|
4505
4469
|
loadConfig,
|
|
@@ -5064,7 +5028,7 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
|
|
|
5064
5028
|
secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
|
|
5065
5029
|
if (validateConfig()) {
|
|
5066
5030
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption);
|
|
5067
|
-
const env =
|
|
5031
|
+
const env = getEnv3(hubspotCliAccountNameOption);
|
|
5068
5032
|
if (!env) {
|
|
5069
5033
|
throw new Error(
|
|
5070
5034
|
`No environment found for account ${hubspotCliAccountNameOption} from hubspot.config.yaml`
|
|
@@ -5229,7 +5193,11 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5229
5193
|
httpServers.push(httpServer);
|
|
5230
5194
|
}
|
|
5231
5195
|
if (!process.env.IN_CODESANDBOX && !process.env.CODESANDBOX_HOST) {
|
|
5232
|
-
startShadowDevServer(
|
|
5196
|
+
startShadowDevServer(
|
|
5197
|
+
PORT,
|
|
5198
|
+
SHADOW_PORT,
|
|
5199
|
+
themePreviewOptions ? themePreviewOptions.dest : ""
|
|
5200
|
+
);
|
|
5233
5201
|
}
|
|
5234
5202
|
let extraServerInfo = "";
|
|
5235
5203
|
const protocol = sslEnabledOption ? "https" : "http";
|
package/dist/run.js
CHANGED
|
@@ -2081,7 +2081,7 @@ function trackUsage(action) {
|
|
|
2081
2081
|
eventName: EVENT_NAME,
|
|
2082
2082
|
action,
|
|
2083
2083
|
nodeVersion: getNodeVersionData(),
|
|
2084
|
-
version: "0.18.
|
|
2084
|
+
version: "0.18.19",
|
|
2085
2085
|
os: getPlatform()
|
|
2086
2086
|
};
|
|
2087
2087
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -2584,7 +2584,8 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
|
2584
2584
|
})).data;
|
|
2585
2585
|
return {
|
|
2586
2586
|
previewDomain: content.previewDomain ?? content.resolvedDomain,
|
|
2587
|
-
previewKey: content.previewKey
|
|
2587
|
+
previewKey: content.previewKey,
|
|
2588
|
+
templatePath: content.templatePath
|
|
2588
2589
|
};
|
|
2589
2590
|
} catch (error) {
|
|
2590
2591
|
if (error.statusCode === 403 && error.error.message.match(
|
|
@@ -4534,9 +4535,7 @@ var buildModuleIndex = () => buildHTMLResponse(`
|
|
|
4534
4535
|
|
|
4535
4536
|
// src/routes/hublTemplateRouteHandler.ts
|
|
4536
4537
|
import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
|
|
4537
|
-
import {
|
|
4538
|
-
buildStaticEnvConfig as buildStaticEnvConfig5
|
|
4539
|
-
} from "@hubspot/cms-components";
|
|
4538
|
+
import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
|
|
4540
4539
|
import { getEnv as getEnv2 } from "@hubspot/local-dev-lib/config";
|
|
4541
4540
|
var templateRouteHandler = async (request2, response) => {
|
|
4542
4541
|
sendTrackingRequest("view-template-route");
|
|
@@ -4566,7 +4565,9 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
4566
4565
|
try {
|
|
4567
4566
|
templateInfo = await fetchTemplateByPath(authedPortalId, calculatedPath);
|
|
4568
4567
|
} catch (err) {
|
|
4569
|
-
console.error(
|
|
4568
|
+
console.error(
|
|
4569
|
+
`Failed to fetch template data for ${calculatedPath}: ${err}`
|
|
4570
|
+
);
|
|
4570
4571
|
}
|
|
4571
4572
|
if (!templateInfo || !("previewKey" in templateInfo)) {
|
|
4572
4573
|
response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
|
|
@@ -4583,6 +4584,7 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
4583
4584
|
...request2.query
|
|
4584
4585
|
};
|
|
4585
4586
|
const previewUrl = new URL(getPreviewUrl(request2, params));
|
|
4587
|
+
const fullOriginalUrl = `${request2.protocol}://${request2.get("host")}${request2.originalUrl}`;
|
|
4586
4588
|
try {
|
|
4587
4589
|
const result = (await hsCliHttp10.get(authedPortalId, {
|
|
4588
4590
|
baseURL: previewUrl.origin,
|
|
@@ -4594,7 +4596,7 @@ var templateRouteHandler = async (request2, response) => {
|
|
|
4594
4596
|
response,
|
|
4595
4597
|
pageHtml,
|
|
4596
4598
|
webRoot2,
|
|
4597
|
-
|
|
4599
|
+
fullOriginalUrl,
|
|
4598
4600
|
environmentConfig,
|
|
4599
4601
|
viteServer,
|
|
4600
4602
|
projectName,
|
|
@@ -4684,32 +4686,27 @@ import express from "express";
|
|
|
4684
4686
|
|
|
4685
4687
|
// src/shadowDevServer/createShadowDevServerRoutes.ts
|
|
4686
4688
|
import { Router as Router2 } from "express";
|
|
4687
|
-
import { getAccountId as getAccountId3
|
|
4689
|
+
import { getAccountId as getAccountId3 } from "@hubspot/local-dev-lib/config";
|
|
4688
4690
|
import cors from "cors";
|
|
4689
|
-
|
|
4690
|
-
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
4691
|
+
function getShadowDevServerCheckHandler(devServerPort, themePath) {
|
|
4691
4692
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
4692
4693
|
const { query } = request2;
|
|
4693
4694
|
if (query) {
|
|
4694
4695
|
const {
|
|
4695
4696
|
hostName,
|
|
4696
4697
|
pathName,
|
|
4697
|
-
protocol,
|
|
4698
4698
|
contentId,
|
|
4699
4699
|
portalId: portalIdString
|
|
4700
4700
|
} = query;
|
|
4701
|
-
const pageUrl = `${protocol}//${hostName}${pathName}`;
|
|
4702
4701
|
const portalId = parseInt(portalIdString, 10);
|
|
4703
|
-
let proxyEnv;
|
|
4704
4702
|
let accountId;
|
|
4705
|
-
let
|
|
4703
|
+
let isTemplateFromDevTheme = false;
|
|
4706
4704
|
let localProxyUrl;
|
|
4707
4705
|
try {
|
|
4708
4706
|
accountId = getAccountId3(portalId);
|
|
4709
4707
|
if (accountId === null) {
|
|
4710
4708
|
throw new Error();
|
|
4711
4709
|
}
|
|
4712
|
-
proxyEnv = getEnv3(accountId);
|
|
4713
4710
|
} catch (e) {
|
|
4714
4711
|
response.status(500).end(
|
|
4715
4712
|
`Unable to find account for hubid = ${portalId}. Please check your hubspot.config.yaml`
|
|
@@ -4717,37 +4714,19 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
4717
4714
|
return;
|
|
4718
4715
|
}
|
|
4719
4716
|
try {
|
|
4720
|
-
const
|
|
4717
|
+
const { templatePath } = await fetchPreviewInfo_default(
|
|
4721
4718
|
accountId,
|
|
4722
4719
|
portalId,
|
|
4723
4720
|
contentId
|
|
4724
4721
|
);
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
portalId,
|
|
4728
|
-
"na1",
|
|
4729
|
-
// bad lazy TF (but does it really matter for this check)
|
|
4730
|
-
proxyEnv,
|
|
4731
|
-
false,
|
|
4732
|
-
gates
|
|
4733
|
-
);
|
|
4734
|
-
const pageHtml = await makeProxyPreviewRequest(
|
|
4735
|
-
accountId,
|
|
4736
|
-
pageUrl,
|
|
4737
|
-
previewKey,
|
|
4738
|
-
contentId,
|
|
4739
|
-
projectName,
|
|
4740
|
-
environmentConfig,
|
|
4741
|
-
gates
|
|
4742
|
-
);
|
|
4743
|
-
const localRenderPlaceholders = findLocalRenderPlaceholders(
|
|
4744
|
-
pageHtml.data
|
|
4745
|
-
);
|
|
4746
|
-
if (localRenderPlaceholders.length) {
|
|
4747
|
-
hasJSBuildingBlocks = true;
|
|
4722
|
+
if (templatePath.startsWith(themePath)) {
|
|
4723
|
+
isTemplateFromDevTheme = true;
|
|
4748
4724
|
localProxyUrl = `http://${hostName}.hslocal.net:${devServerPort}${pathName}`;
|
|
4749
4725
|
}
|
|
4750
|
-
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4726
|
+
response.status(200).set({ "Content-Type": "application/json" }).json({
|
|
4727
|
+
isTemplateFromDevTheme,
|
|
4728
|
+
localProxyUrl
|
|
4729
|
+
});
|
|
4751
4730
|
} catch (error) {
|
|
4752
4731
|
response.status(500).end(
|
|
4753
4732
|
`Failed proxy render of page id = ${contentId} hub id = ${portalId}
|
|
@@ -4763,19 +4742,19 @@ ${error.stack}`
|
|
|
4763
4742
|
}
|
|
4764
4743
|
};
|
|
4765
4744
|
}
|
|
4766
|
-
async function createShadowDevServerRoutes(devServerPort,
|
|
4745
|
+
async function createShadowDevServerRoutes(devServerPort, themePath) {
|
|
4767
4746
|
const shadowDevServerRoutes = Router2();
|
|
4768
4747
|
shadowDevServerRoutes.get(
|
|
4769
4748
|
"/check-if-local-dev-server",
|
|
4770
4749
|
cors(),
|
|
4771
|
-
getShadowDevServerCheckHandler(devServerPort,
|
|
4750
|
+
getShadowDevServerCheckHandler(devServerPort, themePath)
|
|
4772
4751
|
);
|
|
4773
4752
|
return shadowDevServerRoutes;
|
|
4774
4753
|
}
|
|
4775
4754
|
|
|
4776
4755
|
// src/shadowDevServer/startShadowDevServer.ts
|
|
4777
4756
|
var testNetServer = net.createServer();
|
|
4778
|
-
async function startShadowDevServer(devServerPort, shadowPort,
|
|
4757
|
+
async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
4779
4758
|
const portIsTaken = await new Promise((res, rej) => {
|
|
4780
4759
|
console.log(`Starting proxy link server on port ${shadowPort}`);
|
|
4781
4760
|
testNetServer.once("error", (err) => {
|
|
@@ -4803,11 +4782,7 @@ async function startShadowDevServer(devServerPort, shadowPort, projectName, jsRe
|
|
|
4803
4782
|
shadowDevServer.listen(shadowPort);
|
|
4804
4783
|
shadowDevServer.use(
|
|
4805
4784
|
"/",
|
|
4806
|
-
await createShadowDevServerRoutes(
|
|
4807
|
-
devServerPort,
|
|
4808
|
-
projectName,
|
|
4809
|
-
jsRenderingGates
|
|
4810
|
-
)
|
|
4785
|
+
await createShadowDevServerRoutes(devServerPort, themePath)
|
|
4811
4786
|
);
|
|
4812
4787
|
}
|
|
4813
4788
|
|
|
@@ -4818,26 +4793,15 @@ import { default as mkcert } from "vite-plugin-mkcert";
|
|
|
4818
4793
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
4819
4794
|
|
|
4820
4795
|
// src/plugins/devSecretsPlugin.ts
|
|
4821
|
-
function devSecretsPlugin(secretNames) {
|
|
4796
|
+
function devSecretsPlugin(secretNames = []) {
|
|
4822
4797
|
return {
|
|
4823
4798
|
name: "dev-secrets",
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
"@hubspot/cms-components"
|
|
4829
|
-
);
|
|
4830
|
-
if (cmsComponents3.setSecretsFromEnv) {
|
|
4831
|
-
console.log(
|
|
4832
|
-
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
4833
|
-
);
|
|
4834
|
-
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
4835
|
-
} else if (secretNames.length > 0) {
|
|
4836
|
-
console.warn(
|
|
4837
|
-
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
4838
|
-
);
|
|
4799
|
+
config: () => {
|
|
4800
|
+
return {
|
|
4801
|
+
define: {
|
|
4802
|
+
"import.meta.env.secretNames": secretNames
|
|
4839
4803
|
}
|
|
4840
|
-
}
|
|
4804
|
+
};
|
|
4841
4805
|
}
|
|
4842
4806
|
};
|
|
4843
4807
|
}
|
|
@@ -5227,7 +5191,7 @@ async function getJsRenderingGates(portalId, env2, personalAccessKey) {
|
|
|
5227
5191
|
|
|
5228
5192
|
// src/createDevServer.ts
|
|
5229
5193
|
import {
|
|
5230
|
-
getEnv as
|
|
5194
|
+
getEnv as getEnv3,
|
|
5231
5195
|
getAccountId as getAccountId4,
|
|
5232
5196
|
getAccountConfig as getAccountConfig3,
|
|
5233
5197
|
loadConfig,
|
|
@@ -5792,7 +5756,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
5792
5756
|
secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
|
|
5793
5757
|
if (validateConfig()) {
|
|
5794
5758
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
|
|
5795
|
-
const env2 =
|
|
5759
|
+
const env2 = getEnv3(hubspotCliAccountNameOption2);
|
|
5796
5760
|
if (!env2) {
|
|
5797
5761
|
throw new Error(
|
|
5798
5762
|
`No environment found for account ${hubspotCliAccountNameOption2} from hubspot.config.yaml`
|
|
@@ -5957,7 +5921,11 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5957
5921
|
httpServers.push(httpServer);
|
|
5958
5922
|
}
|
|
5959
5923
|
if (!process.env.IN_CODESANDBOX && !process.env.CODESANDBOX_HOST) {
|
|
5960
|
-
startShadowDevServer(
|
|
5924
|
+
startShadowDevServer(
|
|
5925
|
+
PORT,
|
|
5926
|
+
SHADOW_PORT,
|
|
5927
|
+
themePreviewOptions2 ? themePreviewOptions2.dest : ""
|
|
5928
|
+
);
|
|
5961
5929
|
}
|
|
5962
5930
|
let extraServerInfo = "";
|
|
5963
5931
|
const protocol = sslEnabledOption2 ? "https" : "http";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.19",
|
|
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": "^0.18.
|
|
32
|
+
"@hubspot/cms-components": "^0.18.19",
|
|
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",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"publishConfig": {
|
|
131
131
|
"access": "public"
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "24c5d8c526c341f9142ce5fdc3dfa7389310b28b"
|
|
134
134
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
export default function devSecretsPlugin(secretNames
|
|
2
|
+
export default function devSecretsPlugin(secretNames?: Array<string>): Plugin;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default function createShadowDevServerRoutes(devServerPort: number, projectName: string, gates: Gate[]): Promise<import("express-serve-static-core").Router>;
|
|
1
|
+
export default function createShadowDevServerRoutes(devServerPort: number, themePath: string): Promise<import("express-serve-static-core").Router>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default function startShadowDevServer(devServerPort: number, shadowPort: number, projectName: string, jsRenderingGates: Gate[]): Promise<void>;
|
|
1
|
+
export default function startShadowDevServer(devServerPort: number, shadowPort: number, themePath: string): Promise<void>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ViteDevServer } from 'vite';
|
|
2
|
-
export declare const lookForModuleInFolder: (modulePath: string, viteServer: ViteDevServer) => Promise<[any, string]>;
|
|
3
|
-
declare function renderModuleJson(viteServer: ViteDevServer, requestedModulePath: string): Promise<any>;
|
|
4
|
-
export default renderModuleJson;
|