@hubspot/cms-dev-server 0.18.27 → 0.18.29
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 +154 -0
- package/dist/app/assets/index-C0KdU9bk.css +1 -0
- package/dist/app/index.html +2 -2
- package/dist/app/server/serverEntry.js +191 -79
- package/dist/index.js +101 -34
- package/dist/run.js +209 -142
- package/package.json +3 -3
- package/types/api/designmanager.d.ts +1 -0
- package/types/api/project.d.ts +5 -0
- package/types/lib/getDevServerUIData.d.ts +11 -0
- package/dist/app/assets/index-D-Xvc93s.js +0 -154
- package/dist/app/assets/index-vAx-PiEw.css +0 -1
package/dist/run.js
CHANGED
|
@@ -2097,7 +2097,7 @@ function trackUsage(action) {
|
|
|
2097
2097
|
eventName: EVENT_NAME,
|
|
2098
2098
|
action,
|
|
2099
2099
|
nodeVersion: getNodeVersionData(),
|
|
2100
|
-
version: "0.18.
|
|
2100
|
+
version: "0.18.29",
|
|
2101
2101
|
os: getPlatform()
|
|
2102
2102
|
};
|
|
2103
2103
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -4643,11 +4643,152 @@ function buildTemplateIndex() {
|
|
|
4643
4643
|
}
|
|
4644
4644
|
|
|
4645
4645
|
// src/routes/createDevServerRoutes.ts
|
|
4646
|
-
import
|
|
4646
|
+
import fs5 from "node:fs/promises";
|
|
4647
4647
|
|
|
4648
4648
|
// src/lib/getDevServerUIData.ts
|
|
4649
4649
|
import path12 from "path";
|
|
4650
4650
|
import { normalizePath as normalizePath8 } from "vite";
|
|
4651
|
+
|
|
4652
|
+
// src/api/project.ts
|
|
4653
|
+
import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
|
|
4654
|
+
var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
|
|
4655
|
+
async function fetchProjectByName(accountId, projectName) {
|
|
4656
|
+
return (await hsCliHttp11.get(accountId, {
|
|
4657
|
+
url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
|
|
4658
|
+
})).data;
|
|
4659
|
+
}
|
|
4660
|
+
|
|
4661
|
+
// src/createViteDevServer.ts
|
|
4662
|
+
import { createServer as createViteServer } from "vite";
|
|
4663
|
+
import { default as react } from "@vitejs/plugin-react";
|
|
4664
|
+
import { default as mkcert } from "vite-plugin-mkcert";
|
|
4665
|
+
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
4666
|
+
|
|
4667
|
+
// src/plugins/devSecretsPlugin.ts
|
|
4668
|
+
function devSecretsPlugin(secretNames = []) {
|
|
4669
|
+
return {
|
|
4670
|
+
name: "dev-secrets",
|
|
4671
|
+
config: () => {
|
|
4672
|
+
return {
|
|
4673
|
+
define: {
|
|
4674
|
+
"import.meta.env.secretNames": secretNames
|
|
4675
|
+
}
|
|
4676
|
+
};
|
|
4677
|
+
}
|
|
4678
|
+
};
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
// src/createViteDevServer.ts
|
|
4682
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
4683
|
+
import { join as join4 } from "path";
|
|
4684
|
+
function getPackageJson(packagePath2) {
|
|
4685
|
+
return JSON.parse(readFileSync3(join4(packagePath2, "package.json")).toString());
|
|
4686
|
+
}
|
|
4687
|
+
function getDepsForPackage(packagePath2) {
|
|
4688
|
+
const packageJson = getPackageJson(packagePath2);
|
|
4689
|
+
return packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
4690
|
+
}
|
|
4691
|
+
function getDepsForPackageIfExists(packagePath2) {
|
|
4692
|
+
try {
|
|
4693
|
+
return getDepsForPackage(packagePath2);
|
|
4694
|
+
} catch (e) {
|
|
4695
|
+
console.log("No package.json at ", packagePath2);
|
|
4696
|
+
return [];
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames) {
|
|
4700
|
+
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
4701
|
+
`${proxyDomain}.localhost`,
|
|
4702
|
+
`${proxyDomain}.hslocal.net`
|
|
4703
|
+
]).flat();
|
|
4704
|
+
if (process.env.VITE_ORIGIN) {
|
|
4705
|
+
console.log(`
|
|
4706
|
+
Custom origin: ${process.env.VITE_ORIGIN}
|
|
4707
|
+
`);
|
|
4708
|
+
}
|
|
4709
|
+
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
4710
|
+
const consumerDeps = getDepsForPackageIfExists(webRoot2);
|
|
4711
|
+
const isProjectWithReact = consumerDeps.includes("@hubspot/cms-components");
|
|
4712
|
+
const ssrAndOptimizeDep = isProjectWithReact ? {
|
|
4713
|
+
ssr: {
|
|
4714
|
+
// TODO: might need more entries here to get things to resolve through
|
|
4715
|
+
// resolveWebRootDepsPlugin
|
|
4716
|
+
noExternal: "@hubspot/cms-components"
|
|
4717
|
+
},
|
|
4718
|
+
resolve: {
|
|
4719
|
+
conditions: ["server"],
|
|
4720
|
+
dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
|
|
4721
|
+
},
|
|
4722
|
+
optimizeDeps: {
|
|
4723
|
+
include: ["react", "react-dom", "react-dom/client"]
|
|
4724
|
+
}
|
|
4725
|
+
} : {};
|
|
4726
|
+
const reactAndIslandsPlugins = isProjectWithReact || process.env.VITEST ? [
|
|
4727
|
+
react({
|
|
4728
|
+
babel: {
|
|
4729
|
+
plugins: [
|
|
4730
|
+
"babel-plugin-styled-components",
|
|
4731
|
+
"styled-jsx/babel",
|
|
4732
|
+
"macros"
|
|
4733
|
+
]
|
|
4734
|
+
}
|
|
4735
|
+
}),
|
|
4736
|
+
clientIslandEntryPlugin(),
|
|
4737
|
+
resolveIslandPlugin(),
|
|
4738
|
+
jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
|
|
4739
|
+
devSecretsPlugin(secretNames),
|
|
4740
|
+
noncePlaceholderPlugin()
|
|
4741
|
+
] : [];
|
|
4742
|
+
const viteConfig = {
|
|
4743
|
+
appType: "custom",
|
|
4744
|
+
server: {
|
|
4745
|
+
middlewareMode: true,
|
|
4746
|
+
host: "hslocal.net",
|
|
4747
|
+
origin,
|
|
4748
|
+
hmr: {
|
|
4749
|
+
protocol: sslEnabled ? "wss" : void 0
|
|
4750
|
+
}
|
|
4751
|
+
},
|
|
4752
|
+
root: webRoot2,
|
|
4753
|
+
...ssrAndOptimizeDep,
|
|
4754
|
+
plugins: [
|
|
4755
|
+
jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
|
|
4756
|
+
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
4757
|
+
...reactAndIslandsPlugins
|
|
4758
|
+
],
|
|
4759
|
+
css: {
|
|
4760
|
+
postcss: webRoot2
|
|
4761
|
+
},
|
|
4762
|
+
envDir: webRoot2,
|
|
4763
|
+
envPrefix: "HS_"
|
|
4764
|
+
};
|
|
4765
|
+
return createViteServer(viteConfig);
|
|
4766
|
+
}
|
|
4767
|
+
var createViteDevServer_default = createViteDevServer;
|
|
4768
|
+
|
|
4769
|
+
// src/lib/getDevServerUIData.ts
|
|
4770
|
+
import fs4 from "node:fs";
|
|
4771
|
+
var templateTypeMap = {
|
|
4772
|
+
// Standard templates
|
|
4773
|
+
4: "Landing Page",
|
|
4774
|
+
2: "Email",
|
|
4775
|
+
42: "Blog Listing",
|
|
4776
|
+
41: "Blog Post",
|
|
4777
|
+
6: "Blog (Deprecated)",
|
|
4778
|
+
// Global partials
|
|
4779
|
+
38: "Global Partial",
|
|
4780
|
+
18: "Global Group",
|
|
4781
|
+
// System templates
|
|
4782
|
+
11: "Error Page",
|
|
4783
|
+
19: "Password Prompt",
|
|
4784
|
+
29: "Membership Login",
|
|
4785
|
+
30: "Membership Register",
|
|
4786
|
+
31: "Membership Reset",
|
|
4787
|
+
32: "Membership Reset Request",
|
|
4788
|
+
12: "Subscription Preferences",
|
|
4789
|
+
14: "Backup Unsubscribe",
|
|
4790
|
+
27: "Search Results"
|
|
4791
|
+
};
|
|
4651
4792
|
function mapReactModules(modules, themeWebRoot, viteServer) {
|
|
4652
4793
|
return Promise.all(
|
|
4653
4794
|
modules.moduleNames.map(async (name, index) => {
|
|
@@ -4682,11 +4823,28 @@ function normalizePartialsData(partialData) {
|
|
|
4682
4823
|
}));
|
|
4683
4824
|
}
|
|
4684
4825
|
function normalizeTemplatesData(templates) {
|
|
4685
|
-
return templates.map((template) => ({
|
|
4826
|
+
return templates.filter((template) => template.templateType in templateTypeMap).map((template) => ({
|
|
4686
4827
|
name: template.displayName || template.label,
|
|
4687
|
-
subPath:
|
|
4828
|
+
subPath: extractSubPath(template.path),
|
|
4829
|
+
templateTypeLabel: templateTypeMap[template.templateType]
|
|
4688
4830
|
}));
|
|
4689
4831
|
}
|
|
4832
|
+
function extractSubPath(componentPath) {
|
|
4833
|
+
var _a;
|
|
4834
|
+
const projectPrefix = "@projects/";
|
|
4835
|
+
if (!componentPath) {
|
|
4836
|
+
return projectPrefix;
|
|
4837
|
+
}
|
|
4838
|
+
const projectPath = (_a = componentPath.split(projectPrefix)) == null ? void 0 : _a[1];
|
|
4839
|
+
return `${projectPrefix}${projectPath || componentPath}`;
|
|
4840
|
+
}
|
|
4841
|
+
function detectPackageManager(projectRoot) {
|
|
4842
|
+
if (fs4.existsSync(path12.join(projectRoot, "yarn.lock")))
|
|
4843
|
+
return "yarn";
|
|
4844
|
+
if (fs4.existsSync(path12.join(projectRoot, "pnpm-lock.yaml")))
|
|
4845
|
+
return "pnpm";
|
|
4846
|
+
return "npm";
|
|
4847
|
+
}
|
|
4690
4848
|
async function getDevServerUIData(reqLocals, viteServer) {
|
|
4691
4849
|
const {
|
|
4692
4850
|
themeWebRoot,
|
|
@@ -4694,8 +4852,19 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4694
4852
|
authedPortalId,
|
|
4695
4853
|
projectName,
|
|
4696
4854
|
localPreviewToken,
|
|
4697
|
-
webRootProjectComponentFolder
|
|
4855
|
+
webRootProjectComponentFolder,
|
|
4856
|
+
sslEnabled
|
|
4698
4857
|
} = reqLocals;
|
|
4858
|
+
const packageJson = getPackageJson(themeWebRoot);
|
|
4859
|
+
const packageManager = detectPackageManager(themeWebRoot);
|
|
4860
|
+
const runCommand = packageManager === "yarn" ? "yarn" : `${packageManager} run`;
|
|
4861
|
+
const cliCommands = Object.entries((packageJson == null ? void 0 : packageJson.scripts) || {}).map(
|
|
4862
|
+
([scriptName, description]) => ({
|
|
4863
|
+
scriptName,
|
|
4864
|
+
description,
|
|
4865
|
+
runCommand: `${runCommand} ${scriptName}`
|
|
4866
|
+
})
|
|
4867
|
+
);
|
|
4699
4868
|
const modulesData = findAllModulesInRoot(themeWebRoot);
|
|
4700
4869
|
const partialsData = findAllPartialsInRoot(themeWebRoot);
|
|
4701
4870
|
const reactModules = await mapReactModules(
|
|
@@ -4705,15 +4874,16 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4705
4874
|
);
|
|
4706
4875
|
let hubLModuleData = { objects: [] };
|
|
4707
4876
|
let hubLTemplateData = { objects: [] };
|
|
4877
|
+
let projectData = null;
|
|
4708
4878
|
if (authedPortalId) {
|
|
4709
|
-
[hubLModuleData, hubLTemplateData] = await Promise.all([
|
|
4879
|
+
[hubLModuleData, hubLTemplateData, projectData] = await Promise.all([
|
|
4710
4880
|
fetchHubLModules(authedPortalId, localPreviewToken),
|
|
4711
|
-
fetchPreviewTemplates(authedPortalId, localPreviewToken)
|
|
4881
|
+
fetchPreviewTemplates(authedPortalId, localPreviewToken),
|
|
4882
|
+
fetchProjectByName(authedPortalId, projectName).catch(() => {
|
|
4883
|
+
return null;
|
|
4884
|
+
})
|
|
4712
4885
|
]);
|
|
4713
4886
|
}
|
|
4714
|
-
const hubLTemplates = (hubLTemplateData == null ? void 0 : hubLTemplateData.objects.filter(
|
|
4715
|
-
(template) => isCodedFile(template.filename)
|
|
4716
|
-
)) || [];
|
|
4717
4887
|
const mappedHubLModules = normalizeHubLModules((hubLModuleData == null ? void 0 : hubLModuleData.objects) || []);
|
|
4718
4888
|
return {
|
|
4719
4889
|
authedPortalId,
|
|
@@ -4722,9 +4892,12 @@ async function getDevServerUIData(reqLocals, viteServer) {
|
|
|
4722
4892
|
modulesData: reactModules,
|
|
4723
4893
|
partialsData: normalizePartialsData(partialsData),
|
|
4724
4894
|
hubLModules: mappedHubLModules || [],
|
|
4725
|
-
hubLTemplates: normalizeTemplatesData(
|
|
4895
|
+
hubLTemplates: normalizeTemplatesData((hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []),
|
|
4726
4896
|
themeWebRoot,
|
|
4727
|
-
webRootProjectComponentFolder
|
|
4897
|
+
webRootProjectComponentFolder,
|
|
4898
|
+
cliCommands,
|
|
4899
|
+
sslEnabled,
|
|
4900
|
+
projectData
|
|
4728
4901
|
};
|
|
4729
4902
|
}
|
|
4730
4903
|
var getDevServerUIData_default = getDevServerUIData;
|
|
@@ -4824,7 +4997,7 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
|
|
|
4824
4997
|
const templatePath = path13.join(appWebRoot, "index.html");
|
|
4825
4998
|
const serverEntryPath = isProd ? path13.join(appWebRoot, "server/serverEntry.js") : path13.join(appWebRoot, "serverEntry.tsx");
|
|
4826
4999
|
let render;
|
|
4827
|
-
let template = await
|
|
5000
|
+
let template = await fs5.readFile(path13.join(templatePath), "utf-8");
|
|
4828
5001
|
if (isProd) {
|
|
4829
5002
|
const { render: ssrRender } = await import(serverEntryPath);
|
|
4830
5003
|
render = ssrRender;
|
|
@@ -4987,119 +5160,12 @@ async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
|
4987
5160
|
);
|
|
4988
5161
|
}
|
|
4989
5162
|
|
|
4990
|
-
// src/createViteDevServer.ts
|
|
4991
|
-
import { createServer as createViteServer } from "vite";
|
|
4992
|
-
import { default as react } from "@vitejs/plugin-react";
|
|
4993
|
-
import { default as mkcert } from "vite-plugin-mkcert";
|
|
4994
|
-
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
4995
|
-
|
|
4996
|
-
// src/plugins/devSecretsPlugin.ts
|
|
4997
|
-
function devSecretsPlugin(secretNames = []) {
|
|
4998
|
-
return {
|
|
4999
|
-
name: "dev-secrets",
|
|
5000
|
-
config: () => {
|
|
5001
|
-
return {
|
|
5002
|
-
define: {
|
|
5003
|
-
"import.meta.env.secretNames": secretNames
|
|
5004
|
-
}
|
|
5005
|
-
};
|
|
5006
|
-
}
|
|
5007
|
-
};
|
|
5008
|
-
}
|
|
5009
|
-
|
|
5010
|
-
// src/createViteDevServer.ts
|
|
5011
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
5012
|
-
import { join as join4 } from "path";
|
|
5013
|
-
function getPackageJson(packagePath2) {
|
|
5014
|
-
return JSON.parse(readFileSync3(join4(packagePath2, "package.json")).toString());
|
|
5015
|
-
}
|
|
5016
|
-
function getDepsForPackage(packagePath2) {
|
|
5017
|
-
const packageJson = getPackageJson(packagePath2);
|
|
5018
|
-
return packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
5019
|
-
}
|
|
5020
|
-
function getDepsForPackageIfExists(packagePath2) {
|
|
5021
|
-
try {
|
|
5022
|
-
return getDepsForPackage(packagePath2);
|
|
5023
|
-
} catch (e) {
|
|
5024
|
-
console.log("No package.json at ", packagePath2);
|
|
5025
|
-
return [];
|
|
5026
|
-
}
|
|
5027
|
-
}
|
|
5028
|
-
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames) {
|
|
5029
|
-
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
5030
|
-
`${proxyDomain}.localhost`,
|
|
5031
|
-
`${proxyDomain}.hslocal.net`
|
|
5032
|
-
]).flat();
|
|
5033
|
-
if (process.env.VITE_ORIGIN) {
|
|
5034
|
-
console.log(`
|
|
5035
|
-
Custom origin: ${process.env.VITE_ORIGIN}
|
|
5036
|
-
`);
|
|
5037
|
-
}
|
|
5038
|
-
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
5039
|
-
const consumerDeps = getDepsForPackageIfExists(webRoot2);
|
|
5040
|
-
const isProjectWithReact = consumerDeps.includes("@hubspot/cms-components");
|
|
5041
|
-
const ssrAndOptimizeDep = isProjectWithReact ? {
|
|
5042
|
-
ssr: {
|
|
5043
|
-
// TODO: might need more entries here to get things to resolve through
|
|
5044
|
-
// resolveWebRootDepsPlugin
|
|
5045
|
-
noExternal: "@hubspot/cms-components"
|
|
5046
|
-
},
|
|
5047
|
-
resolve: {
|
|
5048
|
-
conditions: ["server"],
|
|
5049
|
-
dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
|
|
5050
|
-
},
|
|
5051
|
-
optimizeDeps: {
|
|
5052
|
-
include: ["react", "react-dom", "react-dom/client"]
|
|
5053
|
-
}
|
|
5054
|
-
} : {};
|
|
5055
|
-
const reactAndIslandsPlugins = isProjectWithReact || process.env.VITEST ? [
|
|
5056
|
-
react({
|
|
5057
|
-
babel: {
|
|
5058
|
-
plugins: [
|
|
5059
|
-
"babel-plugin-styled-components",
|
|
5060
|
-
"styled-jsx/babel",
|
|
5061
|
-
"macros"
|
|
5062
|
-
]
|
|
5063
|
-
}
|
|
5064
|
-
}),
|
|
5065
|
-
clientIslandEntryPlugin(),
|
|
5066
|
-
resolveIslandPlugin(),
|
|
5067
|
-
jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
|
|
5068
|
-
devSecretsPlugin(secretNames),
|
|
5069
|
-
noncePlaceholderPlugin()
|
|
5070
|
-
] : [];
|
|
5071
|
-
const viteConfig = {
|
|
5072
|
-
appType: "custom",
|
|
5073
|
-
server: {
|
|
5074
|
-
middlewareMode: true,
|
|
5075
|
-
host: "hslocal.net",
|
|
5076
|
-
origin,
|
|
5077
|
-
hmr: {
|
|
5078
|
-
protocol: sslEnabled ? "wss" : void 0
|
|
5079
|
-
}
|
|
5080
|
-
},
|
|
5081
|
-
root: webRoot2,
|
|
5082
|
-
...ssrAndOptimizeDep,
|
|
5083
|
-
plugins: [
|
|
5084
|
-
jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
|
|
5085
|
-
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
5086
|
-
...reactAndIslandsPlugins
|
|
5087
|
-
],
|
|
5088
|
-
css: {
|
|
5089
|
-
postcss: webRoot2
|
|
5090
|
-
},
|
|
5091
|
-
envDir: webRoot2,
|
|
5092
|
-
envPrefix: "HS_"
|
|
5093
|
-
};
|
|
5094
|
-
return createViteServer(viteConfig);
|
|
5095
|
-
}
|
|
5096
|
-
var createViteDevServer_default = createViteDevServer;
|
|
5097
|
-
|
|
5098
5163
|
// src/createAppServer.ts
|
|
5099
5164
|
import {
|
|
5100
5165
|
createServer as createViteServer2
|
|
5101
5166
|
} from "vite";
|
|
5102
5167
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
5168
|
+
import { default as mkcert2 } from "vite-plugin-mkcert";
|
|
5103
5169
|
async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
5104
5170
|
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
5105
5171
|
const viteConfig = {
|
|
@@ -5108,7 +5174,8 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
5108
5174
|
host: "hslocal.net",
|
|
5109
5175
|
origin,
|
|
5110
5176
|
hmr: {
|
|
5111
|
-
protocol: sslEnabled ? "wss" :
|
|
5177
|
+
protocol: sslEnabled ? "wss" : "ws",
|
|
5178
|
+
port: port + 1
|
|
5112
5179
|
}
|
|
5113
5180
|
},
|
|
5114
5181
|
appType: "custom",
|
|
@@ -5137,7 +5204,8 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
5137
5204
|
}
|
|
5138
5205
|
}),
|
|
5139
5206
|
clientIslandEntryPlugin(),
|
|
5140
|
-
resolveIslandPlugin()
|
|
5207
|
+
resolveIslandPlugin(),
|
|
5208
|
+
sslEnabled ? mkcert2() : null
|
|
5141
5209
|
],
|
|
5142
5210
|
css: {
|
|
5143
5211
|
postcss: appWebRoot
|
|
@@ -5227,7 +5295,7 @@ import {
|
|
|
5227
5295
|
import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
|
|
5228
5296
|
|
|
5229
5297
|
// src/proxyPage/fetchDomains.ts
|
|
5230
|
-
import { http as
|
|
5298
|
+
import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
|
|
5231
5299
|
|
|
5232
5300
|
// src/lib/errors.ts
|
|
5233
5301
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -5285,7 +5353,7 @@ function handleSecretsError(error) {
|
|
|
5285
5353
|
// src/proxyPage/fetchDomains.ts
|
|
5286
5354
|
async function fetchDomains(portalId) {
|
|
5287
5355
|
try {
|
|
5288
|
-
const result = (await
|
|
5356
|
+
const result = (await hsCliHttp12.get(portalId, {
|
|
5289
5357
|
url: `/cms/v3/domains`,
|
|
5290
5358
|
params: { portalId },
|
|
5291
5359
|
responseType: "json"
|
|
@@ -5309,12 +5377,12 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
5309
5377
|
|
|
5310
5378
|
// src/lib/validateHSPlatform.ts
|
|
5311
5379
|
import path14 from "path";
|
|
5312
|
-
import
|
|
5380
|
+
import fs6 from "fs";
|
|
5313
5381
|
import select from "@inquirer/select";
|
|
5314
|
-
import { http as
|
|
5382
|
+
import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
|
|
5315
5383
|
var HSPROJECT_JSON = "hsproject.json";
|
|
5316
5384
|
function checkFileExists(filePath) {
|
|
5317
|
-
return
|
|
5385
|
+
return fs6.existsSync(filePath) && fs6.statSync(filePath).isFile();
|
|
5318
5386
|
}
|
|
5319
5387
|
function findHSProjectJson(startPath) {
|
|
5320
5388
|
let currentDir = startPath;
|
|
@@ -5340,12 +5408,12 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5340
5408
|
);
|
|
5341
5409
|
return false;
|
|
5342
5410
|
}
|
|
5343
|
-
const hsProjectJSONContents =
|
|
5411
|
+
const hsProjectJSONContents = fs6.readFileSync(projectConfigPath, "utf8");
|
|
5344
5412
|
const hsProjectJSONData = JSON.parse(hsProjectJSONContents);
|
|
5345
5413
|
const { platformVersion } = hsProjectJSONData;
|
|
5346
5414
|
let platformVersionResult;
|
|
5347
5415
|
try {
|
|
5348
|
-
platformVersionResult = (await
|
|
5416
|
+
platformVersionResult = (await hsCliHttp13.get(portalId, {
|
|
5349
5417
|
url: `developer/projects/v1/platformVersion`,
|
|
5350
5418
|
responseType: "json"
|
|
5351
5419
|
})).data;
|
|
@@ -5368,7 +5436,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5368
5436
|
});
|
|
5369
5437
|
hsProjectJSONData.platformVersion = answer;
|
|
5370
5438
|
try {
|
|
5371
|
-
|
|
5439
|
+
fs6.writeFileSync(
|
|
5372
5440
|
projectConfigPath,
|
|
5373
5441
|
JSON.stringify(hsProjectJSONData, void 0, 2),
|
|
5374
5442
|
"utf8"
|
|
@@ -5385,7 +5453,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
5385
5453
|
}
|
|
5386
5454
|
|
|
5387
5455
|
// src/createDevServer.ts
|
|
5388
|
-
import { http as
|
|
5456
|
+
import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
|
|
5389
5457
|
|
|
5390
5458
|
// ../cms-js-internal/dist/buildFieldsTypes.js
|
|
5391
5459
|
import { writeFileSync } from "fs";
|
|
@@ -5630,7 +5698,7 @@ function writeFieldsType(fields, fileName, typeName) {
|
|
|
5630
5698
|
}
|
|
5631
5699
|
|
|
5632
5700
|
// src/lib/watchFieldsUpdates.ts
|
|
5633
|
-
import
|
|
5701
|
+
import fs7 from "fs";
|
|
5634
5702
|
import path15 from "path";
|
|
5635
5703
|
import readline from "readline";
|
|
5636
5704
|
var lastSerializedFieldsCache = {};
|
|
@@ -5652,9 +5720,9 @@ var isInModulesFolder = (filePath, projectRoot) => {
|
|
|
5652
5720
|
};
|
|
5653
5721
|
};
|
|
5654
5722
|
var fileContainsAutoGenComment = async (filePath) => {
|
|
5655
|
-
if (!
|
|
5723
|
+
if (!fs7.existsSync(filePath))
|
|
5656
5724
|
return true;
|
|
5657
|
-
const stream2 =
|
|
5725
|
+
const stream2 = fs7.createReadStream(filePath);
|
|
5658
5726
|
const reader = readline.createInterface({ input: stream2 });
|
|
5659
5727
|
const firstLine = await new Promise(
|
|
5660
5728
|
(resolve3) => reader.once("line", (line) => resolve3(line.trim()))
|
|
@@ -5673,7 +5741,7 @@ var getIndexFile = (filePath, projectRoot) => {
|
|
|
5673
5741
|
if (isRootModuleFile)
|
|
5674
5742
|
return { indexFilePath: filePath, isRootModuleFile };
|
|
5675
5743
|
const dir = path15.dirname(filePath);
|
|
5676
|
-
const files =
|
|
5744
|
+
const files = fs7.readdirSync(dir);
|
|
5677
5745
|
const indexFileName = files.find((file) => file.startsWith("index."));
|
|
5678
5746
|
return indexFileName ? { indexFilePath: path15.join(dir, indexFileName), isRootModuleFile } : void 0;
|
|
5679
5747
|
};
|
|
@@ -5865,7 +5933,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5865
5933
|
}
|
|
5866
5934
|
let authedHublet;
|
|
5867
5935
|
try {
|
|
5868
|
-
const accountInformation = (await
|
|
5936
|
+
const accountInformation = (await hsCliHttp14.get(authedPortalId, {
|
|
5869
5937
|
url: "/account-info/v3/details"
|
|
5870
5938
|
})).data;
|
|
5871
5939
|
authedHublet = accountInformation.dataHostingLocation;
|
|
@@ -5926,10 +5994,8 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5926
5994
|
expressServer.use(bodyParser.json());
|
|
5927
5995
|
let appServerConfig = null;
|
|
5928
5996
|
if (showUI2) {
|
|
5929
|
-
const
|
|
5930
|
-
|
|
5931
|
-
"../app"
|
|
5932
|
-
);
|
|
5997
|
+
const __dirname2 = path16.dirname(url2.fileURLToPath(import.meta.url));
|
|
5998
|
+
const appWebRoot = normalizePath9(path16.resolve(__dirname2, "../app"));
|
|
5933
5999
|
const reqLocals = {
|
|
5934
6000
|
themeWebRoot: absoluteWebRoot,
|
|
5935
6001
|
authedPortalId,
|
|
@@ -5937,7 +6003,8 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
5937
6003
|
authedHublet,
|
|
5938
6004
|
projectName,
|
|
5939
6005
|
webRootProjectComponentFolder,
|
|
5940
|
-
localPreviewToken: _localPreviewToken
|
|
6006
|
+
localPreviewToken: _localPreviewToken,
|
|
6007
|
+
sslEnabled: sslEnabledOption2
|
|
5941
6008
|
};
|
|
5942
6009
|
const appServer = await createAppServer_default(
|
|
5943
6010
|
appWebRoot,
|
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.29",
|
|
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.29",
|
|
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": "9d248141be427d81a7339f21077bb2a8db88975d"
|
|
135
135
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { ProjectData } from '../api/project.js';
|
|
2
3
|
export declare enum ModuleType {
|
|
3
4
|
REACT = "react",
|
|
4
5
|
HUBL = "hubl"
|
|
@@ -18,6 +19,7 @@ export interface PartialData {
|
|
|
18
19
|
export interface TemplateData {
|
|
19
20
|
name: string;
|
|
20
21
|
subPath: string;
|
|
22
|
+
templateTypeLabel: string;
|
|
21
23
|
}
|
|
22
24
|
export interface DevServerUIData {
|
|
23
25
|
authedPortalId: number;
|
|
@@ -27,6 +29,13 @@ export interface DevServerUIData {
|
|
|
27
29
|
partialsData: PartialData[];
|
|
28
30
|
hubLTemplates: TemplateData[];
|
|
29
31
|
themeWebRoot: string;
|
|
32
|
+
cliCommands: {
|
|
33
|
+
scriptName: string;
|
|
34
|
+
description: string;
|
|
35
|
+
runCommand: string;
|
|
36
|
+
}[];
|
|
37
|
+
sslEnabled: boolean;
|
|
38
|
+
projectData: ProjectData | null;
|
|
30
39
|
[key: string]: any;
|
|
31
40
|
}
|
|
32
41
|
export interface RequestLocals {
|
|
@@ -37,6 +46,8 @@ export interface RequestLocals {
|
|
|
37
46
|
projectName: string;
|
|
38
47
|
webRootProjectComponentFolder: string;
|
|
39
48
|
localPreviewToken: string;
|
|
49
|
+
sslEnabled: boolean;
|
|
40
50
|
}
|
|
51
|
+
export declare const templateTypeMap: Record<number, string>;
|
|
41
52
|
export declare function getDevServerUIData(reqLocals: RequestLocals, viteServer: ViteDevServer): Promise<DevServerUIData>;
|
|
42
53
|
export default getDevServerUIData;
|