@hubspot/cms-dev-server 0.18.28 → 1.0.0
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-BDlX5eip.js +154 -0
- package/dist/app/assets/index-C0KdU9bk.css +1 -0
- package/dist/app/index.html +2 -2
- package/dist/app/server/serverEntry.js +189 -119
- package/dist/index.js +160 -98
- package/dist/run.js +270 -212
- package/package.json +3 -3
- package/types/api/designmanager.d.ts +1 -0
- package/types/api/project.d.ts +5 -0
- 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/lib/getDevServerUIData.d.ts +11 -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/dist/app/assets/index-BivIDhYl.css +0 -1
- package/dist/app/assets/index-C5FZod7r.js +0 -154
- package/types/lib/renderModuleJson.d.ts +0 -4
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.0",
|
|
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,
|
|
@@ -4011,11 +4011,44 @@ function buildTemplateIndex() {
|
|
|
4011
4011
|
}
|
|
4012
4012
|
|
|
4013
4013
|
// src/routes/createDevServerRoutes.ts
|
|
4014
|
-
import
|
|
4014
|
+
import fs4 from "node:fs/promises";
|
|
4015
4015
|
|
|
4016
4016
|
// src/lib/getDevServerUIData.ts
|
|
4017
4017
|
import path11 from "path";
|
|
4018
4018
|
import { normalizePath as normalizePath8 } from "vite";
|
|
4019
|
+
|
|
4020
|
+
// src/api/project.ts
|
|
4021
|
+
import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
|
|
4022
|
+
var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
|
|
4023
|
+
async function fetchProjectByName(accountId, projectName) {
|
|
4024
|
+
return (await hsCliHttp11.get(accountId, {
|
|
4025
|
+
url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
|
|
4026
|
+
})).data;
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
// src/lib/getDevServerUIData.ts
|
|
4030
|
+
import fs3 from "node:fs";
|
|
4031
|
+
var templateTypeMap = {
|
|
4032
|
+
// Standard templates
|
|
4033
|
+
4: "Landing Page",
|
|
4034
|
+
2: "Email",
|
|
4035
|
+
42: "Blog Listing",
|
|
4036
|
+
41: "Blog Post",
|
|
4037
|
+
6: "Blog (Deprecated)",
|
|
4038
|
+
// Global partials
|
|
4039
|
+
38: "Global Partial",
|
|
4040
|
+
18: "Global Group",
|
|
4041
|
+
// System templates
|
|
4042
|
+
11: "Error Page",
|
|
4043
|
+
19: "Password Prompt",
|
|
4044
|
+
29: "Membership Login",
|
|
4045
|
+
30: "Membership Register",
|
|
4046
|
+
31: "Membership Reset",
|
|
4047
|
+
32: "Membership Reset Request",
|
|
4048
|
+
12: "Subscription Preferences",
|
|
4049
|
+
14: "Backup Unsubscribe",
|
|
4050
|
+
27: "Search Results"
|
|
4051
|
+
};
|
|
4019
4052
|
function mapReactModules(modules, themeWebRoot, viteServer) {
|
|
4020
4053
|
return Promise.all(
|
|
4021
4054
|
modules.moduleNames.map(async (name, index) => {
|
|
@@ -4050,11 +4083,28 @@ function normalizePartialsData(partialData) {
|
|
|
4050
4083
|
}));
|
|
4051
4084
|
}
|
|
4052
4085
|
function normalizeTemplatesData(templates) {
|
|
4053
|
-
return templates.map((template) => ({
|
|
4086
|
+
return templates.filter((template) => template.templateType in templateTypeMap).map((template) => ({
|
|
4054
4087
|
name: template.displayName || template.label,
|
|
4055
|
-
subPath:
|
|
4088
|
+
subPath: extractSubPath(template.path),
|
|
4089
|
+
templateTypeLabel: templateTypeMap[template.templateType]
|
|
4056
4090
|
}));
|
|
4057
4091
|
}
|
|
4092
|
+
function extractSubPath(componentPath) {
|
|
4093
|
+
var _a;
|
|
4094
|
+
const projectPrefix = "@projects/";
|
|
4095
|
+
if (!componentPath) {
|
|
4096
|
+
return projectPrefix;
|
|
4097
|
+
}
|
|
4098
|
+
const projectPath = (_a = componentPath.split(projectPrefix)) == null ? void 0 : _a[1];
|
|
4099
|
+
return `${projectPrefix}${projectPath || componentPath}`;
|
|
4100
|
+
}
|
|
4101
|
+
function detectPackageManager(projectRoot) {
|
|
4102
|
+
if (fs3.existsSync(path11.join(projectRoot, "yarn.lock")))
|
|
4103
|
+
return "yarn";
|
|
4104
|
+
if (fs3.existsSync(path11.join(projectRoot, "pnpm-lock.yaml")))
|
|
4105
|
+
return "pnpm";
|
|
4106
|
+
return "npm";
|
|
4107
|
+
}
|
|
4058
4108
|
async function getDevServerUIData(reqLocals, viteServer) {
|
|
4059
4109
|
const {
|
|
4060
4110
|
themeWebRoot,
|
|
@@ -4062,8 +4112,19 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4062
4112
|
authedPortalId,
|
|
4063
4113
|
projectName,
|
|
4064
4114
|
localPreviewToken,
|
|
4065
|
-
webRootProjectComponentFolder
|
|
4115
|
+
webRootProjectComponentFolder,
|
|
4116
|
+
sslEnabled
|
|
4066
4117
|
} = reqLocals;
|
|
4118
|
+
const packageJson = getPackageJson(themeWebRoot);
|
|
4119
|
+
const packageManager = detectPackageManager(themeWebRoot);
|
|
4120
|
+
const runCommand = packageManager === "yarn" ? "yarn" : `${packageManager} run`;
|
|
4121
|
+
const cliCommands = Object.entries((packageJson == null ? void 0 : packageJson.scripts) || {}).map(
|
|
4122
|
+
([scriptName, description]) => ({
|
|
4123
|
+
scriptName,
|
|
4124
|
+
description,
|
|
4125
|
+
runCommand: `${runCommand} ${scriptName}`
|
|
4126
|
+
})
|
|
4127
|
+
);
|
|
4067
4128
|
const modulesData = findAllModulesInRoot(themeWebRoot);
|
|
4068
4129
|
const partialsData = findAllPartialsInRoot(themeWebRoot);
|
|
4069
4130
|
const reactModules = await mapReactModules(
|
|
@@ -4073,15 +4134,16 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4073
4134
|
);
|
|
4074
4135
|
let hubLModuleData = { objects: [] };
|
|
4075
4136
|
let hubLTemplateData = { objects: [] };
|
|
4137
|
+
let projectData = null;
|
|
4076
4138
|
if (authedPortalId) {
|
|
4077
|
-
[hubLModuleData, hubLTemplateData] = await Promise.all([
|
|
4139
|
+
[hubLModuleData, hubLTemplateData, projectData] = await Promise.all([
|
|
4078
4140
|
fetchHubLModules(authedPortalId, localPreviewToken),
|
|
4079
|
-
fetchPreviewTemplates(authedPortalId, localPreviewToken)
|
|
4141
|
+
fetchPreviewTemplates(authedPortalId, localPreviewToken),
|
|
4142
|
+
fetchProjectByName(authedPortalId, projectName).catch(() => {
|
|
4143
|
+
return null;
|
|
4144
|
+
})
|
|
4080
4145
|
]);
|
|
4081
4146
|
}
|
|
4082
|
-
const hubLTemplates = (hubLTemplateData == null ? void 0 : hubLTemplateData.objects.filter(
|
|
4083
|
-
(template) => isCodedFile(template.filename)
|
|
4084
|
-
)) || [];
|
|
4085
4147
|
const mappedHubLModules = normalizeHubLModules((hubLModuleData == null ? void 0 : hubLModuleData.objects) || []);
|
|
4086
4148
|
return {
|
|
4087
4149
|
authedPortalId,
|
|
@@ -4090,9 +4152,12 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4090
4152
|
modulesData: reactModules,
|
|
4091
4153
|
partialsData: normalizePartialsData(partialsData),
|
|
4092
4154
|
hubLModules: mappedHubLModules || [],
|
|
4093
|
-
hubLTemplates: normalizeTemplatesData(
|
|
4155
|
+
hubLTemplates: normalizeTemplatesData((hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []),
|
|
4094
4156
|
themeWebRoot,
|
|
4095
|
-
webRootProjectComponentFolder
|
|
4157
|
+
webRootProjectComponentFolder,
|
|
4158
|
+
cliCommands,
|
|
4159
|
+
sslEnabled,
|
|
4160
|
+
projectData
|
|
4096
4161
|
};
|
|
4097
4162
|
}
|
|
4098
4163
|
var getDevServerUIData_default = getDevServerUIData;
|
|
@@ -4116,6 +4181,7 @@ async function handleGetModulePages(req, res, next) {
|
|
|
4116
4181
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4117
4182
|
}
|
|
4118
4183
|
try {
|
|
4184
|
+
sendTrackingRequest("handle-module-dependencies");
|
|
4119
4185
|
const data = await fetchModulePageDependencies(
|
|
4120
4186
|
Number(portalId),
|
|
4121
4187
|
path16
|
|
@@ -4131,6 +4197,7 @@ function handleOpenFile(req, res, next) {
|
|
|
4131
4197
|
return res.status(400).json({ error: "Missing required parameters" });
|
|
4132
4198
|
}
|
|
4133
4199
|
try {
|
|
4200
|
+
sendTrackingRequest("handle-open-file");
|
|
4134
4201
|
const command = getOpenCommand();
|
|
4135
4202
|
spawn(command, [path16], { detached: true }).unref();
|
|
4136
4203
|
res.sendStatus(200);
|
|
@@ -4175,50 +4242,46 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4175
4242
|
);
|
|
4176
4243
|
}
|
|
4177
4244
|
devServerApp.use(urlencoded());
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
devServerApp.use("/assets", expressStatic(distAssetsPath));
|
|
4183
|
-
} else {
|
|
4184
|
-
devServerApp.use(appServer.middlewares);
|
|
4185
|
-
}
|
|
4186
|
-
devServerApp.use(viteServer.middlewares);
|
|
4187
|
-
devServerApp.use("/api", createAppServerRoutes_default());
|
|
4188
|
-
devServerApp.get("/", async (req, res) => {
|
|
4189
|
-
try {
|
|
4190
|
-
const initialProps = await getDevServerUIData_default(reqLocals, viteServer);
|
|
4191
|
-
const url3 = req.originalUrl.replace("/", "");
|
|
4192
|
-
const templatePath = path12.join(appWebRoot, "index.html");
|
|
4193
|
-
const serverEntryPath = isProd ? path12.join(appWebRoot, "server/serverEntry.js") : path12.join(appWebRoot, "serverEntry.tsx");
|
|
4194
|
-
let render;
|
|
4195
|
-
let template = await fs3.readFile(path12.join(templatePath), "utf-8");
|
|
4196
|
-
if (isProd) {
|
|
4197
|
-
const { render: ssrRender } = await import(serverEntryPath);
|
|
4198
|
-
render = ssrRender;
|
|
4199
|
-
} else {
|
|
4200
|
-
template = await appServer.transformIndexHtml(url3, template);
|
|
4201
|
-
render = (await appServer.ssrLoadModule(serverEntryPath)).render;
|
|
4202
|
-
}
|
|
4203
|
-
const rendered = await render(initialProps);
|
|
4204
|
-
const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
|
|
4205
|
-
`<!--app-script-->`,
|
|
4206
|
-
`<script>window.__hsInitialProps = ${JSON.stringify(
|
|
4207
|
-
initialProps
|
|
4208
|
-
)};</script>` ?? ""
|
|
4209
|
-
);
|
|
4210
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
4211
|
-
} catch (e) {
|
|
4212
|
-
appServer == null ? void 0 : appServer.ssrFixStacktrace(e);
|
|
4213
|
-
console.log(e.stack);
|
|
4214
|
-
res.status(500).end(e.stack);
|
|
4215
|
-
}
|
|
4216
|
-
});
|
|
4217
|
-
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));
|
|
4218
4249
|
} else {
|
|
4219
|
-
devServerApp.use(
|
|
4220
|
-
devServerApp.get("/", homeRouteHandler_default);
|
|
4250
|
+
devServerApp.use(appServer.middlewares);
|
|
4221
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);
|
|
4222
4285
|
devServerApp.get("/proxy", proxyPathPageRouteHandler);
|
|
4223
4286
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
4224
4287
|
devServerApp.get("/partial/:partial", partial_default);
|
|
@@ -4360,6 +4423,7 @@ import {
|
|
|
4360
4423
|
createServer as createViteServer2
|
|
4361
4424
|
} from "vite";
|
|
4362
4425
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
4426
|
+
import { default as mkcert2 } from "vite-plugin-mkcert";
|
|
4363
4427
|
async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
4364
4428
|
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
4365
4429
|
const viteConfig = {
|
|
@@ -4368,7 +4432,8 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
4368
4432
|
host: "hslocal.net",
|
|
4369
4433
|
origin,
|
|
4370
4434
|
hmr: {
|
|
4371
|
-
protocol: sslEnabled ? "wss" :
|
|
4435
|
+
protocol: sslEnabled ? "wss" : "ws",
|
|
4436
|
+
port: port + 1
|
|
4372
4437
|
}
|
|
4373
4438
|
},
|
|
4374
4439
|
appType: "custom",
|
|
@@ -4397,7 +4462,8 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
4397
4462
|
}
|
|
4398
4463
|
}),
|
|
4399
4464
|
clientIslandEntryPlugin(),
|
|
4400
|
-
resolveIslandPlugin()
|
|
4465
|
+
resolveIslandPlugin(),
|
|
4466
|
+
sslEnabled ? mkcert2() : null
|
|
4401
4467
|
],
|
|
4402
4468
|
css: {
|
|
4403
4469
|
postcss: appWebRoot
|
|
@@ -4487,7 +4553,7 @@ import {
|
|
|
4487
4553
|
import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
|
|
4488
4554
|
|
|
4489
4555
|
// src/proxyPage/fetchDomains.ts
|
|
4490
|
-
import { http as
|
|
4556
|
+
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
4491
4557
|
|
|
4492
4558
|
// src/lib/errors.ts
|
|
4493
4559
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -4545,7 +4611,7 @@ function handleSecretsError(error) {
|
|
|
4545
4611
|
// src/proxyPage/fetchDomains.ts
|
|
4546
4612
|
async function fetchDomains(portalId) {
|
|
4547
4613
|
try {
|
|
4548
|
-
const result = (await
|
|
4614
|
+
const result = (await hsCliHttp12.get(portalId, {
|
|
4549
4615
|
url: `/cms/v3/domains`,
|
|
4550
4616
|
params: { portalId },
|
|
4551
4617
|
responseType: "json"
|
|
@@ -4569,12 +4635,12 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
4569
4635
|
|
|
4570
4636
|
// src/lib/validateHSPlatform.ts
|
|
4571
4637
|
import path13 from "path";
|
|
4572
|
-
import
|
|
4638
|
+
import fs5 from "fs";
|
|
4573
4639
|
import select from "@inquirer/select";
|
|
4574
|
-
import { http as
|
|
4640
|
+
import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
|
|
4575
4641
|
var HSPROJECT_JSON = "hsproject.json";
|
|
4576
4642
|
function checkFileExists(filePath) {
|
|
4577
|
-
return
|
|
4643
|
+
return fs5.existsSync(filePath) && fs5.statSync(filePath).isFile();
|
|
4578
4644
|
}
|
|
4579
4645
|
function findHSProjectJson(startPath) {
|
|
4580
4646
|
let currentDir = startPath;
|
|
@@ -4600,12 +4666,12 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
4600
4666
|
);
|
|
4601
4667
|
return false;
|
|
4602
4668
|
}
|
|
4603
|
-
const hsProjectJSONContents =
|
|
4669
|
+
const hsProjectJSONContents = fs5.readFileSync(projectConfigPath, "utf8");
|
|
4604
4670
|
const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
|
|
4605
4671
|
const { platformVersion } = hsProjectJSONData;
|
|
4606
4672
|
let platformVersionResult;
|
|
4607
4673
|
try {
|
|
4608
|
-
platformVersionResult = (await
|
|
4674
|
+
platformVersionResult = (await hsCliHttp13.get(portalId, {
|
|
4609
4675
|
url: `developer/projects/v1/platformVersion`,
|
|
4610
4676
|
responseType: "json"
|
|
4611
4677
|
})).data;
|
|
@@ -4628,7 +4694,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
4628
4694
|
});
|
|
4629
4695
|
hsProjectJSONData.platformVersion = answer;
|
|
4630
4696
|
try {
|
|
4631
|
-
|
|
4697
|
+
fs5.writeFileSync(
|
|
4632
4698
|
projectConfigPath,
|
|
4633
4699
|
JSON.stringify(hsProjectJSONData, void 0, 2),
|
|
4634
4700
|
"utf8"
|
|
@@ -4645,7 +4711,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
4645
4711
|
}
|
|
4646
4712
|
|
|
4647
4713
|
// src/createDevServer.ts
|
|
4648
|
-
import { http as
|
|
4714
|
+
import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
|
|
4649
4715
|
|
|
4650
4716
|
// ../cms-js-internal/dist/buildFieldsTypes.js
|
|
4651
4717
|
import { writeFileSync } from "fs";
|
|
@@ -4890,7 +4956,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
4890
4956
|
}
|
|
4891
4957
|
|
|
4892
4958
|
// src/lib/watchFieldsUpdates.ts
|
|
4893
|
-
import
|
|
4959
|
+
import fs6 from "fs";
|
|
4894
4960
|
import path14 from "path";
|
|
4895
4961
|
import readline from "readline";
|
|
4896
4962
|
var lastSerializedFieldsCache = {};
|
|
@@ -4912,9 +4978,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
4912
4978
|
};
|
|
4913
4979
|
};
|
|
4914
4980
|
var fileContainsAutoGenComment = async (filePath) => {
|
|
4915
|
-
if (!
|
|
4981
|
+
if (!fs6.existsSync(filePath))
|
|
4916
4982
|
return true;
|
|
4917
|
-
const stream2 =
|
|
4983
|
+
const stream2 = fs6.createReadStream(filePath);
|
|
4918
4984
|
const reader = readline.createInterface({ input: stream2 });
|
|
4919
4985
|
const firstLine = await new Promise(
|
|
4920
4986
|
(resolve2) => reader.once("line", (line) => resolve2(line.trim()))
|
|
@@ -4933,7 +4999,7 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
4933
4999
|
if (isRootModuleFile)
|
|
4934
5000
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
4935
5001
|
const dir = path14.dirname(filePath);
|
|
4936
|
-
const files =
|
|
5002
|
+
const files = fs6.readdirSync(dir);
|
|
4937
5003
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
4938
5004
|
return indexFileName ? { indexFilePath: path14.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
4939
5005
|
};
|
|
@@ -5018,7 +5084,7 @@ var BASE_PATH = "/";
|
|
|
5018
5084
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
5019
5085
|
var SHADOW_PORT = 1442;
|
|
5020
5086
|
var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
|
|
5021
|
-
async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabledOption, fieldGenEnabledOption, themePreviewOptions
|
|
5087
|
+
async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabledOption, fieldGenEnabledOption, themePreviewOptions) {
|
|
5022
5088
|
let authedPortalId = null;
|
|
5023
5089
|
let authedEnv = null;
|
|
5024
5090
|
let jsRenderingGates = [];
|
|
@@ -5125,7 +5191,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5125
5191
|
}
|
|
5126
5192
|
let authedHublet;
|
|
5127
5193
|
try {
|
|
5128
|
-
const accountInformation = (await
|
|
5194
|
+
const accountInformation = (await hsCliHttp14.get(authedPortalId, {
|
|
5129
5195
|
url: "/account-info/v3/details"
|
|
5130
5196
|
})).data;
|
|
5131
5197
|
authedHublet = accountInformation.dataHostingLocation;
|
|
@@ -5184,32 +5250,28 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5184
5250
|
expressServer.locals.domainsToProxy = domainsToProxy;
|
|
5185
5251
|
expressServer.locals.localPreviewToken = _localPreviewToken;
|
|
5186
5252
|
expressServer.use(bodyParser.json());
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
reqLocals,
|
|
5210
|
-
appWebRoot
|
|
5211
|
-
};
|
|
5212
|
-
}
|
|
5253
|
+
const __dirname2 = path15.dirname(url2.fileURLToPath(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
|
+
};
|
|
5213
5275
|
expressServer.use(
|
|
5214
5276
|
BASE_PATH,
|
|
5215
5277
|
await createDevServerRoutes_default(
|