@hubspot/cms-dev-server 0.18.29 → 1.0.4
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/assets/{index-BnyRQ2fe.js → index-BDlX5eip.js} +14 -14
- package/dist/app/index.html +1 -1
- package/dist/app/server/serverEntry.js +22 -48
- package/dist/index.js +65 -70
- package/dist/run.js +67 -76
- package/package.json +3 -3
- package/types/constants/errors.d.ts +5 -0
- package/types/createAppViteConfig.d.ts +2 -0
- package/types/createDevServer.d.ts +1 -1
- package/types/lib/cli.d.ts +22 -0
- package/types/lib/cliUtils.d.ts +14 -0
- package/types/lib/constants.d.ts +1 -0
- package/types/routes/api.d.ts +2 -0
- package/types/routes/appServerRoutes.d.ts +5 -0
- package/types/storybook-main/preview.d.ts +9 -0
- package/types/lib/renderModuleJson.d.ts +0 -4
package/dist/app/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>CMS React Dev Server Home</title>
|
|
7
7
|
<!--app-head-->
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BDlX5eip.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-C0KdU9bk.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -1574,7 +1574,8 @@ function unstable_usePodcastShows(resolvableIds) {
|
|
|
1574
1574
|
function unstable_usePodcastEpisodes(resolvableIds) {
|
|
1575
1575
|
var _a;
|
|
1576
1576
|
const renderContext = useRenderContext();
|
|
1577
|
-
const
|
|
1577
|
+
const normalizedType = resolvableIds.type.toUpperCase();
|
|
1578
|
+
const uniqueId = `${normalizedType}:${resolvableIds.value}`;
|
|
1578
1579
|
if (!((_a = renderContext.resolvedDataDependencies) == null ? void 0 : _a.podcastEpisodes)) {
|
|
1579
1580
|
return [];
|
|
1580
1581
|
}
|
|
@@ -2221,29 +2222,6 @@ function useAddModule(name, path, label) {
|
|
|
2221
2222
|
}
|
|
2222
2223
|
};
|
|
2223
2224
|
}
|
|
2224
|
-
function DndArea(props) {
|
|
2225
|
-
const { name } = props;
|
|
2226
|
-
useAddDndArea(name);
|
|
2227
|
-
return /* @__PURE__ */ jsx(
|
|
2228
|
-
"div",
|
|
2229
|
-
{
|
|
2230
|
-
dangerouslySetInnerHTML: {
|
|
2231
|
-
__html: `<!-- hs-dnd-area-placeholder-${name} -->`
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
);
|
|
2235
|
-
}
|
|
2236
|
-
function useAddDndArea(name) {
|
|
2237
|
-
const renderContext = useServerRenderContext();
|
|
2238
|
-
const dndAreaValue = { name };
|
|
2239
|
-
renderContext.contentDescriptors = {
|
|
2240
|
-
...renderContext.contentDescriptors,
|
|
2241
|
-
dndAreas: {
|
|
2242
|
-
...renderContext.contentDescriptors.dndAreas,
|
|
2243
|
-
[name]: dndAreaValue
|
|
2244
|
-
}
|
|
2245
|
-
};
|
|
2246
|
-
}
|
|
2247
2225
|
async function renderServerSidePropsWithAsyncLocalStoreContext$1(getServerSideProps, propsAndDeps, renderContext) {
|
|
2248
2226
|
var _a;
|
|
2249
2227
|
if (propsAndDeps.extraDeps.url && ((_a = propsAndDeps.extraDeps) == null ? void 0 : _a.url.toString()) !== renderContext.pageUrl) {
|
|
@@ -2261,7 +2239,6 @@ const cmsComponents = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defin
|
|
|
2261
2239
|
ALL_MODULE_DATA_FETCH_DEPENDENCY_TYPES,
|
|
2262
2240
|
ClientRenderContextProvider,
|
|
2263
2241
|
Cta,
|
|
2264
|
-
DndArea,
|
|
2265
2242
|
ExistingIslandContextProvider,
|
|
2266
2243
|
Form,
|
|
2267
2244
|
ISO639CodeEnum,
|
|
@@ -2597,7 +2574,7 @@ const Hero = ({
|
|
|
2597
2574
|
authedEnv
|
|
2598
2575
|
}) => {
|
|
2599
2576
|
const isAuthed = !!authedPortalId;
|
|
2600
|
-
const authTooltipText = isAuthed ? "You are connected to your HubSpot account" : `You are not connected to your HubSpot Account.
|
|
2577
|
+
const authTooltipText = isAuthed ? "You are connected to your HubSpot account" : `You are not connected to your HubSpot Account. Please run "hs init" to connect and view content in the dev server.`;
|
|
2601
2578
|
const combinedModules = [...modulesData, ...hubLModules];
|
|
2602
2579
|
const handleOpenInApp = () => {
|
|
2603
2580
|
try {
|
|
@@ -2650,7 +2627,7 @@ const Hero = ({
|
|
|
2650
2627
|
}
|
|
2651
2628
|
),
|
|
2652
2629
|
authedPortalId && /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
2653
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
2630
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
|
|
2654
2631
|
Button,
|
|
2655
2632
|
{
|
|
2656
2633
|
size: "sm",
|
|
@@ -2659,24 +2636,19 @@ const Hero = ({
|
|
|
2659
2636
|
disabled: !projectData,
|
|
2660
2637
|
children: [
|
|
2661
2638
|
/* @__PURE__ */ jsx(ExternalLink, {}),
|
|
2662
|
-
"
|
|
2639
|
+
" View in HubSpot"
|
|
2663
2640
|
]
|
|
2664
2641
|
}
|
|
2665
|
-
) }),
|
|
2666
|
-
/* @__PURE__ */ jsx(
|
|
2667
|
-
|
|
2668
|
-
{
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
2676
|
-
"with this version, you can revert it in Projects."
|
|
2677
|
-
] })
|
|
2678
|
-
}
|
|
2679
|
-
)
|
|
2642
|
+
) }) }),
|
|
2643
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
2644
|
+
"To view file in the HubSpot,",
|
|
2645
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
2646
|
+
'run "hs project upload".',
|
|
2647
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
2648
|
+
"If you encounter any issues",
|
|
2649
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
2650
|
+
"with this version, you can revert it in Projects."
|
|
2651
|
+
] }) })
|
|
2680
2652
|
] })
|
|
2681
2653
|
] })
|
|
2682
2654
|
] }),
|
|
@@ -3005,7 +2977,7 @@ const ComponentDependencySection = ({
|
|
|
3005
2977
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold leading-9 decoration-skip-ink", children: "Dependencies" }),
|
|
3006
2978
|
projectData && isLoading ? /* @__PURE__ */ jsx(Skeleton, { className: "h-[20px] flex-1" }) : projectData && moduleDependencies && /* @__PURE__ */ jsx("span", { className: "text-lg font-bold leading-8", children: `${moduleDependencies.length} ${moduleDependencies.length === 1 ? "page uses" : "pages use"} this ${componentType}` })
|
|
3007
2979
|
] }),
|
|
3008
|
-
!projectData ? /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500 italic", children:
|
|
2980
|
+
!projectData ? /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500 italic", children: 'Please run "hs project upload" to see what pages this module is used on.' }) : isLoading ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
3009
2981
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-[20px] w-full" }),
|
|
3010
2982
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-[20px] w-full" })
|
|
3011
2983
|
] }) : error ? /* @__PURE__ */ jsxs("div", { className: "text-red-500", children: [
|
|
@@ -3130,7 +3102,8 @@ const ActionButtons = ({
|
|
|
3130
3102
|
componentType,
|
|
3131
3103
|
onPreviewClick,
|
|
3132
3104
|
onViewLocalClick,
|
|
3133
|
-
sslEnabled
|
|
3105
|
+
sslEnabled,
|
|
3106
|
+
projectData
|
|
3134
3107
|
}) => {
|
|
3135
3108
|
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3136
3109
|
componentType === "module" && /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
@@ -3139,11 +3112,11 @@ const ActionButtons = ({
|
|
|
3139
3112
|
{
|
|
3140
3113
|
variant: "outline",
|
|
3141
3114
|
onClick: () => onPreviewClick(component),
|
|
3142
|
-
disabled: !sslEnabled,
|
|
3115
|
+
disabled: !sslEnabled || !projectData,
|
|
3143
3116
|
children: "View in app"
|
|
3144
3117
|
}
|
|
3145
3118
|
) }) }),
|
|
3146
|
-
!sslEnabled
|
|
3119
|
+
!sslEnabled ? /* @__PURE__ */ jsx(TooltipContent, { children: "Please run the dev server with the --ssl flag to view in HubSpot" }) : !projectData ? /* @__PURE__ */ jsx(TooltipContent, { children: 'Please run "hs project upload" to view in HubSpot' }) : null
|
|
3147
3120
|
] }),
|
|
3148
3121
|
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onViewLocalClick(component), children: "View local version" })
|
|
3149
3122
|
] });
|
|
@@ -3234,7 +3207,8 @@ function ComponentTable({
|
|
|
3234
3207
|
componentType,
|
|
3235
3208
|
onPreviewClick: handlePreviewClick,
|
|
3236
3209
|
onViewLocalClick: handleViewLocalClick,
|
|
3237
|
-
sslEnabled
|
|
3210
|
+
sslEnabled,
|
|
3211
|
+
projectData
|
|
3238
3212
|
}
|
|
3239
3213
|
) })
|
|
3240
3214
|
] }, index)) })
|
package/dist/index.js
CHANGED
|
@@ -1465,7 +1465,7 @@ function trackUsage(action) {
|
|
|
1465
1465
|
eventName: EVENT_NAME,
|
|
1466
1466
|
action,
|
|
1467
1467
|
nodeVersion: getNodeVersionData(),
|
|
1468
|
-
version: "0.
|
|
1468
|
+
version: "1.0.4",
|
|
1469
1469
|
os: getPlatform()
|
|
1470
1470
|
};
|
|
1471
1471
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -3545,7 +3545,7 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
3545
3545
|
next();
|
|
3546
3546
|
return;
|
|
3547
3547
|
}
|
|
3548
|
-
sendTrackingRequest("view-home-route");
|
|
3548
|
+
sendTrackingRequest("view-legacy-home-route");
|
|
3549
3549
|
const {
|
|
3550
3550
|
authedPortalId,
|
|
3551
3551
|
webRoot,
|
|
@@ -4181,6 +4181,7 @@ async function handleGetModulePages(req, res, next) {
|
|
|
4181
4181
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4182
4182
|
}
|
|
4183
4183
|
try {
|
|
4184
|
+
sendTrackingRequest("handle-module-dependencies");
|
|
4184
4185
|
const data = await fetchModulePageDependencies(
|
|
4185
4186
|
Number(portalId),
|
|
4186
4187
|
path16
|
|
@@ -4196,6 +4197,7 @@ function handleOpenFile(req, res, next) {
|
|
|
4196
4197
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4197
4198
|
}
|
|
4198
4199
|
try {
|
|
4200
|
+
sendTrackingRequest("handle-open-file");
|
|
4199
4201
|
const command = getOpenCommand();
|
|
4200
4202
|
spawn(command, [path16], { detached: true }).unref();
|
|
4201
4203
|
res.sendStatus(200);
|
|
@@ -4240,50 +4242,46 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4240
4242
|
);
|
|
4241
4243
|
}
|
|
4242
4244
|
devServerApp.use(urlencoded());
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4248
|
-
} else {
|
|
4249
|
-
devServerApp.use(appServer.middlewares);
|
|
4250
|
-
}
|
|
4251
|
-
devServerApp.use(viteServer.middlewares);
|
|
4252
|
-
devServerApp.use("/api", createAppServerRoutes_default());
|
|
4253
|
-
devServerApp.get("/", async (req, res) => {
|
|
4254
|
-
try {
|
|
4255
|
-
const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
|
|
4256
|
-
const url3 = req.originalUrl.replace("/", "");
|
|
4257
|
-
const templatePath = path12.join(appWebRoot, "index.html");
|
|
4258
|
-
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4259
|
-
let render;
|
|
4260
|
-
let template = await fs4.readFile(path12.join(templatePath), "utf-8");
|
|
4261
|
-
if (isProd) {
|
|
4262
|
-
const { render: ssrRender } = await import(serverEntryPath);
|
|
4263
|
-
render = ssrRender;
|
|
4264
|
-
} else {
|
|
4265
|
-
template = await appServer.transformIndexHtml(url3, template);
|
|
4266
|
-
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
4267
|
-
}
|
|
4268
|
-
const rendered = await render(initialProps);
|
|
4269
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4270
|
-
`<!--app-script-->`,
|
|
4271
|
-
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4272
|
-
initialProps
|
|
4273
|
-
)};</script>` ?? ""
|
|
4274
|
-
);
|
|
4275
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4276
|
-
} catch (e) {
|
|
4277
|
-
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
4278
|
-
console.log(e.stack);
|
|
4279
|
-
res.status(500).end(e.stack);
|
|
4280
|
-
}
|
|
4281
|
-
});
|
|
4282
|
-
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
4245
|
+
const appWebRoot = isProd ? path12.join(__dirname, "app") : appServerConfig == null ? void 0 : appServerConfig.appWebRoot;
|
|
4246
|
+
if (isProd) {
|
|
4247
|
+
const distAssetsPath = path12.join(appWebRoot, "assets");
|
|
4248
|
+
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4283
4249
|
} else {
|
|
4284
|
-
devServerApp.use(
|
|
4285
|
-
devServerApp.get("/", homeRouteHandler_default);
|
|
4250
|
+
devServerApp.use(appServer.middlewares);
|
|
4286
4251
|
}
|
|
4252
|
+
devServerApp.use(viteServer.middlewares);
|
|
4253
|
+
devServerApp.use("/api", createAppServerRoutes_default());
|
|
4254
|
+
devServerApp.get("/", async (req, res) => {
|
|
4255
|
+
try {
|
|
4256
|
+
sendTrackingRequest("view-index-route");
|
|
4257
|
+
const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
|
|
4258
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4259
|
+
const templatePath = path12.join(appWebRoot, "index.html");
|
|
4260
|
+
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4261
|
+
let render;
|
|
4262
|
+
let template = await fs4.readFile(path12.join(templatePath), "utf-8");
|
|
4263
|
+
if (isProd) {
|
|
4264
|
+
const { render: ssrRender } = await import(serverEntryPath);
|
|
4265
|
+
render = ssrRender;
|
|
4266
|
+
} else {
|
|
4267
|
+
template = await appServer.transformIndexHtml(url3, template);
|
|
4268
|
+
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
4269
|
+
}
|
|
4270
|
+
const rendered = await render(initialProps);
|
|
4271
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4272
|
+
`<!--app-script-->`,
|
|
4273
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4274
|
+
initialProps
|
|
4275
|
+
)};</script>` ?? ""
|
|
4276
|
+
);
|
|
4277
|
+
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4278
|
+
} catch (e) {
|
|
4279
|
+
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
4280
|
+
console.log(e.stack);
|
|
4281
|
+
res.status(500).end(e.stack);
|
|
4282
|
+
}
|
|
4283
|
+
});
|
|
4284
|
+
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
4287
4285
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
4288
4286
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
4289
4287
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -5086,7 +5084,7 @@ var BASE_PATH = "/";
|
|
|
5086
5084
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
5087
5085
|
var SHADOW_PORT = 1442;
|
|
5088
5086
|
var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
|
|
5089
|
-
async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabledOption, fieldGenEnabledOption, themePreviewOptions
|
|
5087
|
+
async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabledOption, fieldGenEnabledOption, themePreviewOptions) {
|
|
5090
5088
|
let authedPortalId = null;
|
|
5091
5089
|
let authedEnv = null;
|
|
5092
5090
|
let jsRenderingGates = [];
|
|
@@ -5252,31 +5250,28 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5252
5250
|
expressServer.locals.domainsToProxy = domainsToProxy;
|
|
5253
5251
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5254
5252
|
expressServer.use(bodyParser.json());
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
appWebRoot
|
|
5278
|
-
};
|
|
5279
|
-
}
|
|
5253
|
+
const __dirname2 = path15.dirname(url2.fileURLToPath(new URL(import.meta.url)));
|
|
5254
|
+
const appWebRoot = normalizePath9(path15.resolve(__dirname2, "../app"));
|
|
5255
|
+
const reqLocals = {
|
|
5256
|
+
themeWebRoot: absoluteWebRoot,
|
|
5257
|
+
authedPortalId,
|
|
5258
|
+
authedEnv,
|
|
5259
|
+
authedHublet,
|
|
5260
|
+
projectName,
|
|
5261
|
+
webRootProjectComponentFolder,
|
|
5262
|
+
localPreviewToken: _localPreviewToken,
|
|
5263
|
+
sslEnabled: sslEnabledOption
|
|
5264
|
+
};
|
|
5265
|
+
const appServer = await createAppServer_default(
|
|
5266
|
+
appWebRoot,
|
|
5267
|
+
PORT,
|
|
5268
|
+
sslEnabledOption
|
|
5269
|
+
);
|
|
5270
|
+
const appServerConfig = {
|
|
5271
|
+
appServer,
|
|
5272
|
+
reqLocals,
|
|
5273
|
+
appWebRoot
|
|
5274
|
+
};
|
|
5280
5275
|
expressServer.use(
|
|
5281
5276
|
BASE_PATH,
|
|
5282
5277
|
await createDevServerRoutes_default(
|
package/dist/run.js
CHANGED
|
@@ -675,7 +675,6 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
675
675
|
const storybook2 = args.findIndex((arg) => arg === "--storybook") > 0;
|
|
676
676
|
const fieldGenEnabledOption2 = args.includes("--generateFieldsTypes");
|
|
677
677
|
const resetSession2 = args.includes("--resetSession");
|
|
678
|
-
const showUI2 = args.includes("--showUI");
|
|
679
678
|
return {
|
|
680
679
|
hubspotCliConfigPathOption: hubspotCliConfigPathOption2,
|
|
681
680
|
hubspotCliAccountNameOption: hubspotCliAccountNameOption2,
|
|
@@ -683,7 +682,6 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
683
682
|
storybook: storybook2,
|
|
684
683
|
fieldGenEnabledOption: fieldGenEnabledOption2,
|
|
685
684
|
webRoot: webRoot2,
|
|
686
|
-
showUI: showUI2,
|
|
687
685
|
resetSession: resetSession2
|
|
688
686
|
};
|
|
689
687
|
}
|
|
@@ -2097,7 +2095,7 @@ function trackUsage(action) {
|
|
|
2097
2095
|
eventName: EVENT_NAME,
|
|
2098
2096
|
action,
|
|
2099
2097
|
nodeVersion: getNodeVersionData(),
|
|
2100
|
-
version: "0.
|
|
2098
|
+
version: "1.0.4",
|
|
2101
2099
|
os: getPlatform()
|
|
2102
2100
|
};
|
|
2103
2101
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -4177,7 +4175,7 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
4177
4175
|
next();
|
|
4178
4176
|
return;
|
|
4179
4177
|
}
|
|
4180
|
-
sendTrackingRequest("view-home-route");
|
|
4178
|
+
sendTrackingRequest("view-legacy-home-route");
|
|
4181
4179
|
const {
|
|
4182
4180
|
authedPortalId,
|
|
4183
4181
|
webRoot: webRoot2,
|
|
@@ -4921,6 +4919,7 @@ async function handleGetModulePages(req, res, next) {
|
|
|
4921
4919
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4922
4920
|
}
|
|
4923
4921
|
try {
|
|
4922
|
+
sendTrackingRequest("handle-module-dependencies");
|
|
4924
4923
|
const data = await fetchModulePageDependencies(
|
|
4925
4924
|
Number(portalId),
|
|
4926
4925
|
path17
|
|
@@ -4936,6 +4935,7 @@ function handleOpenFile(req, res, next) {
|
|
|
4936
4935
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4937
4936
|
}
|
|
4938
4937
|
try {
|
|
4938
|
+
sendTrackingRequest("handle-open-file");
|
|
4939
4939
|
const command = getOpenCommand();
|
|
4940
4940
|
spawn(command, [path17], { detached: true }).unref();
|
|
4941
4941
|
res.sendStatus(200);
|
|
@@ -4980,50 +4980,46 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4980
4980
|
);
|
|
4981
4981
|
}
|
|
4982
4982
|
devServerApp.use(urlencoded());
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4988
|
-
} else {
|
|
4989
|
-
devServerApp.use(appServer.middlewares);
|
|
4990
|
-
}
|
|
4991
|
-
devServerApp.use(viteServer.middlewares);
|
|
4992
|
-
devServerApp.use("/api", createAppServerRoutes_default());
|
|
4993
|
-
devServerApp.get("/", async (req, res) => {
|
|
4994
|
-
try {
|
|
4995
|
-
const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
|
|
4996
|
-
const url3 = req.originalUrl.replace("/", "");
|
|
4997
|
-
const templatePath = path13.join(appWebRoot, "index.html");
|
|
4998
|
-
const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
|
|
4999
|
-
let render;
|
|
5000
|
-
let template = await fs5.readFile(path13.join(templatePath), "utf-8");
|
|
5001
|
-
if (isProd) {
|
|
5002
|
-
const { render: ssrRender } = await import(serverEntryPath);
|
|
5003
|
-
render = ssrRender;
|
|
5004
|
-
} else {
|
|
5005
|
-
template = await appServer.transformIndexHtml(url3, template);
|
|
5006
|
-
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
5007
|
-
}
|
|
5008
|
-
const rendered = await render(initialProps);
|
|
5009
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
5010
|
-
`<!--app-script-->`,
|
|
5011
|
-
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
5012
|
-
initialProps
|
|
5013
|
-
)};</script>` ?? ""
|
|
5014
|
-
);
|
|
5015
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
5016
|
-
} catch (e) {
|
|
5017
|
-
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
5018
|
-
console.log(e.stack);
|
|
5019
|
-
res.status(500).end(e.stack);
|
|
5020
|
-
}
|
|
5021
|
-
});
|
|
5022
|
-
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
4983
|
+
const appWebRoot = isProd ? path13.join(__dirname, "app") : appServerConfig == null ? void 0 : appServerConfig.appWebRoot;
|
|
4984
|
+
if (isProd) {
|
|
4985
|
+
const distAssetsPath = path13.join(appWebRoot, "assets");
|
|
4986
|
+
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
5023
4987
|
} else {
|
|
5024
|
-
devServerApp.use(
|
|
5025
|
-
devServerApp.get("/", homeRouteHandler_default);
|
|
4988
|
+
devServerApp.use(appServer.middlewares);
|
|
5026
4989
|
}
|
|
4990
|
+
devServerApp.use(viteServer.middlewares);
|
|
4991
|
+
devServerApp.use("/api", createAppServerRoutes_default());
|
|
4992
|
+
devServerApp.get("/", async (req, res) => {
|
|
4993
|
+
try {
|
|
4994
|
+
sendTrackingRequest("view-index-route");
|
|
4995
|
+
const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
|
|
4996
|
+
const url3 = req.originalUrl.replace("/", "");
|
|
4997
|
+
const templatePath = path13.join(appWebRoot, "index.html");
|
|
4998
|
+
const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
|
|
4999
|
+
let render;
|
|
5000
|
+
let template = await fs5.readFile(path13.join(templatePath), "utf-8");
|
|
5001
|
+
if (isProd) {
|
|
5002
|
+
const { render: ssrRender } = await import(serverEntryPath);
|
|
5003
|
+
render = ssrRender;
|
|
5004
|
+
} else {
|
|
5005
|
+
template = await appServer.transformIndexHtml(url3, template);
|
|
5006
|
+
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
5007
|
+
}
|
|
5008
|
+
const rendered = await render(initialProps);
|
|
5009
|
+
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
5010
|
+
`<!--app-script-->`,
|
|
5011
|
+
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
5012
|
+
initialProps
|
|
5013
|
+
)};</script>` ?? ""
|
|
5014
|
+
);
|
|
5015
|
+
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
5016
|
+
} catch (e) {
|
|
5017
|
+
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
5018
|
+
console.log(e.stack);
|
|
5019
|
+
res.status(500).end(e.stack);
|
|
5020
|
+
}
|
|
5021
|
+
});
|
|
5022
|
+
devServerApp.get("/legacy", homeRouteHandler_default);
|
|
5027
5023
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
5028
5024
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
5029
5025
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -5826,7 +5822,7 @@ var BASE_PATH = "/";
|
|
|
5826
5822
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
5827
5823
|
var SHADOW_PORT = 1442;
|
|
5828
5824
|
var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
|
|
5829
|
-
async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2
|
|
5825
|
+
async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2) {
|
|
5830
5826
|
let authedPortalId = null;
|
|
5831
5827
|
let authedEnv = null;
|
|
5832
5828
|
let jsRenderingGates = [];
|
|
@@ -5992,31 +5988,28 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5992
5988
|
expressServer.locals.domainsToProxy = domainsToProxy;
|
|
5993
5989
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5994
5990
|
expressServer.use(bodyParser.json());
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
appWebRoot
|
|
6018
|
-
};
|
|
6019
|
-
}
|
|
5991
|
+
const __dirname2 = path16.dirname(url2.fileURLToPath(new URL(import.meta.url)));
|
|
5992
|
+
const appWebRoot = normalizePath9(path16.resolve(__dirname2, "../app"));
|
|
5993
|
+
const reqLocals = {
|
|
5994
|
+
themeWebRoot: absoluteWebRoot,
|
|
5995
|
+
authedPortalId,
|
|
5996
|
+
authedEnv,
|
|
5997
|
+
authedHublet,
|
|
5998
|
+
projectName,
|
|
5999
|
+
webRootProjectComponentFolder,
|
|
6000
|
+
localPreviewToken: _localPreviewToken,
|
|
6001
|
+
sslEnabled: sslEnabledOption2
|
|
6002
|
+
};
|
|
6003
|
+
const appServer = await createAppServer_default(
|
|
6004
|
+
appWebRoot,
|
|
6005
|
+
PORT,
|
|
6006
|
+
sslEnabledOption2
|
|
6007
|
+
);
|
|
6008
|
+
const appServerConfig = {
|
|
6009
|
+
appServer,
|
|
6010
|
+
reqLocals,
|
|
6011
|
+
appWebRoot
|
|
6012
|
+
};
|
|
6020
6013
|
expressServer.use(
|
|
6021
6014
|
BASE_PATH,
|
|
6022
6015
|
await createDevServerRoutes_default(
|
|
@@ -6134,8 +6127,7 @@ var {
|
|
|
6134
6127
|
sslEnabledOption,
|
|
6135
6128
|
storybook,
|
|
6136
6129
|
fieldGenEnabledOption,
|
|
6137
|
-
resetSession
|
|
6138
|
-
showUI
|
|
6130
|
+
resetSession
|
|
6139
6131
|
} = getDevServerCommandLineOptions(process.argv);
|
|
6140
6132
|
if (!webRoot) {
|
|
6141
6133
|
throw new Error(`No web root path argument specified`);
|
|
@@ -6155,6 +6147,5 @@ createDevServer_default(
|
|
|
6155
6147
|
hubspotCliAccountNameOption,
|
|
6156
6148
|
sslEnabledOption,
|
|
6157
6149
|
fieldGenEnabledOption,
|
|
6158
|
-
themePreviewOptions
|
|
6159
|
-
showUI
|
|
6150
|
+
themePreviewOptions
|
|
6160
6151
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.4",
|
|
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.
|
|
32
|
+
"@hubspot/cms-components": "^1.0.4",
|
|
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": "7139eb8f1b96f886e803a9178f00dea63f4483af"
|
|
135
135
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemePreviewOptions } from './lib/previewUtils.js';
|
|
2
|
-
declare function createDevServer(webRoot: string, storybook: boolean, hubspotCliConfigPathOption?: string, hubspotCliAccountNameOption?: string, sslEnabledOption?: boolean, fieldGenEnabledOption?: boolean, themePreviewOptions?: ThemePreviewOptions
|
|
2
|
+
declare function createDevServer(webRoot: string, storybook: boolean, hubspotCliConfigPathOption?: string, hubspotCliAccountNameOption?: string, sslEnabledOption?: boolean, fieldGenEnabledOption?: boolean, themePreviewOptions?: ThemePreviewOptions): Promise<{
|
|
3
3
|
close: () => Promise<[...PromiseSettledResult<unknown>[], PromiseSettledResult<unknown>]>;
|
|
4
4
|
}>;
|
|
5
5
|
export default createDevServer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export declare function getDevServerCommandLineOptions(argv: NodeJS.Process['argv']): {
|
|
3
|
+
hubspotCliConfigPathOption: string;
|
|
4
|
+
hubspotCliAccountNameOption: string;
|
|
5
|
+
sslEnabledOption: boolean;
|
|
6
|
+
storybook: boolean;
|
|
7
|
+
fieldGenEnabledOption: boolean;
|
|
8
|
+
webRoot: string;
|
|
9
|
+
resetSession: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function buildThemePreviewOptions(webRoot: string): Promise<{
|
|
12
|
+
filePaths: string[];
|
|
13
|
+
startProgressBar: (numFiles: any) => {
|
|
14
|
+
onAttemptCallback: () => void;
|
|
15
|
+
onSuccessCallback: () => void;
|
|
16
|
+
onFirstErrorCallback: () => void;
|
|
17
|
+
onRetryCallback: () => void;
|
|
18
|
+
onFinalErrorCallback: () => any;
|
|
19
|
+
onFinishCallback: (results: any) => void;
|
|
20
|
+
};
|
|
21
|
+
dest: any;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function determineSrcAndDest(): Promise<{
|
|
2
|
+
absoluteSrc: any;
|
|
3
|
+
dest: any;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function getUploadableFileList(src: any, convertFields: any): Promise<any[]>;
|
|
6
|
+
export declare function fieldsJsPrompt(filePath: any, projectDir: any, skipFiles?: any[]): Promise<any[]>;
|
|
7
|
+
export declare function logError(error: any, context?: {}): void;
|
|
8
|
+
export declare class ApiErrorContext {
|
|
9
|
+
accountId: any;
|
|
10
|
+
request: any;
|
|
11
|
+
payload: any;
|
|
12
|
+
projectName: any;
|
|
13
|
+
constructor(props?: any);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const templateTypeMap: Record<number, string>;
|
|
@@ -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): Promise<Response<any, Record<string, any>>>;
|
|
4
|
+
export declare function appServerRoutes(): import("express-serve-static-core").Router;
|
|
5
|
+
export default appServerRoutes;
|