@hubspot/cms-dev-server 0.16.0 → 0.16.2
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/index.js +3 -0
- package/dist/internalSsr.js +6 -1
- package/dist/run.js +34 -51
- package/dist/storybook-main/main.js +6 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -123,6 +123,9 @@ function devSecretsPlugin(secretNames) {
|
|
|
123
123
|
"@hubspot/cms-components"
|
|
124
124
|
);
|
|
125
125
|
if (cmsComponents2.setSecretsFromEnv) {
|
|
126
|
+
console.log(
|
|
127
|
+
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
128
|
+
);
|
|
126
129
|
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
127
130
|
} else if (secretNames.length > 0) {
|
|
128
131
|
console.warn(
|
package/dist/internalSsr.js
CHANGED
|
@@ -271,7 +271,12 @@ var HEALTHCHECKS_ENABLED_DEFAULT = true;
|
|
|
271
271
|
var HEALTHCHECKS_STRICT_DEFAULT = false;
|
|
272
272
|
function getCMSAssetConfig(webRoot) {
|
|
273
273
|
const cmsAssetsPath = path.join(webRoot, "cms-assets.json");
|
|
274
|
-
|
|
274
|
+
const cmsThemePath = path.join(webRoot, "theme.json");
|
|
275
|
+
const configPathToUse = fs.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;
|
|
276
|
+
const parsedConfig = JSON.parse(
|
|
277
|
+
fs.readFileSync(configPathToUse).toString()
|
|
278
|
+
);
|
|
279
|
+
return parsedConfig;
|
|
275
280
|
}
|
|
276
281
|
function getCMSAssetConfigIfExists(webRoot) {
|
|
277
282
|
try {
|
package/dist/run.js
CHANGED
|
@@ -291,7 +291,12 @@ function getEntryPointHashWithIndexSuffix(entryPoint, index) {
|
|
|
291
291
|
}
|
|
292
292
|
function getCMSAssetConfig(webRoot2) {
|
|
293
293
|
const cmsAssetsPath = path2.join(webRoot2, "cms-assets.json");
|
|
294
|
-
|
|
294
|
+
const cmsThemePath = path2.join(webRoot2, "theme.json");
|
|
295
|
+
const configPathToUse = fs.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;
|
|
296
|
+
const parsedConfig = JSON.parse(
|
|
297
|
+
fs.readFileSync(configPathToUse).toString()
|
|
298
|
+
);
|
|
299
|
+
return parsedConfig;
|
|
295
300
|
}
|
|
296
301
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
297
302
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
@@ -1050,7 +1055,7 @@ function trackUsage(action) {
|
|
|
1050
1055
|
eventName: EVENT_NAME,
|
|
1051
1056
|
action,
|
|
1052
1057
|
nodeVersion: getNodeVersionData(),
|
|
1053
|
-
version: "0.16.
|
|
1058
|
+
version: "0.16.2",
|
|
1054
1059
|
os: getPlatform()
|
|
1055
1060
|
};
|
|
1056
1061
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1560,29 +1565,7 @@ var module_default = moduleRouteHandler;
|
|
|
1560
1565
|
// src/proxyPage/fetchContentMetadata.ts
|
|
1561
1566
|
import http from "http";
|
|
1562
1567
|
import https from "https";
|
|
1563
|
-
import localDevHttpImport4 from "@hubspot/local-dev-lib/http";
|
|
1564
1568
|
import { getAccountId } from "@hubspot/local-dev-lib/config";
|
|
1565
|
-
var { default: hsCliHttp4 } = localDevHttpImport4;
|
|
1566
|
-
async function requestContentPreview(url3, portalId) {
|
|
1567
|
-
const urlObject = new URL(url3);
|
|
1568
|
-
const proxiedQueryParams = {};
|
|
1569
|
-
for (const queryKey of urlObject.searchParams.keys()) {
|
|
1570
|
-
const values = urlObject.searchParams.getAll(queryKey);
|
|
1571
|
-
if (values.length > 1) {
|
|
1572
|
-
proxiedQueryParams[queryKey] = values;
|
|
1573
|
-
} else {
|
|
1574
|
-
proxiedQueryParams[queryKey] = values[0];
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
const accountId = getAccountId(portalId);
|
|
1578
|
-
const response = await hsCliHttp4.get(accountId, {
|
|
1579
|
-
baseURL: urlObject.origin,
|
|
1580
|
-
url: urlObject.pathname,
|
|
1581
|
-
params: proxiedQueryParams,
|
|
1582
|
-
responseType: "text"
|
|
1583
|
-
});
|
|
1584
|
-
return response;
|
|
1585
|
-
}
|
|
1586
1569
|
async function requestPage(url3, redirects = 0, originalUrl) {
|
|
1587
1570
|
if (redirects > 5) {
|
|
1588
1571
|
throw new Error(
|
|
@@ -1620,12 +1603,7 @@ async function requestPage(url3, redirects = 0, originalUrl) {
|
|
|
1620
1603
|
});
|
|
1621
1604
|
}
|
|
1622
1605
|
async function fetchContentMetadata(url3, portalId) {
|
|
1623
|
-
|
|
1624
|
-
if (url3.includes("hs_preview")) {
|
|
1625
|
-
res = await requestContentPreview(url3, portalId);
|
|
1626
|
-
} else {
|
|
1627
|
-
res = await requestPage(url3);
|
|
1628
|
-
}
|
|
1606
|
+
const res = await requestPage(url3);
|
|
1629
1607
|
const portalIdHeader = res.headers["x-hs-hub-id"];
|
|
1630
1608
|
const contentId = res.headers["x-hs-content-id"];
|
|
1631
1609
|
if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
|
|
@@ -1662,7 +1640,7 @@ async function fetchContentMetadata(url3, portalId) {
|
|
|
1662
1640
|
import path5 from "path";
|
|
1663
1641
|
import { normalizePath as normalizePath4 } from "vite";
|
|
1664
1642
|
import { getAccountId as getAccountId2, getEnv } from "@hubspot/local-dev-lib/config";
|
|
1665
|
-
import
|
|
1643
|
+
import localDevHttpImport5 from "@hubspot/local-dev-lib/http";
|
|
1666
1644
|
|
|
1667
1645
|
// src/lib/proxyHelpers.ts
|
|
1668
1646
|
import fs2 from "fs";
|
|
@@ -1844,8 +1822,8 @@ var renderLocalError_default = (path10, error) => {
|
|
|
1844
1822
|
};
|
|
1845
1823
|
|
|
1846
1824
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
1847
|
-
import
|
|
1848
|
-
var { default:
|
|
1825
|
+
import localDevHttpImport4 from "@hubspot/local-dev-lib/http";
|
|
1826
|
+
var { default: hsCliHttp4 } = localDevHttpImport4;
|
|
1849
1827
|
var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
1850
1828
|
if (!contentId) {
|
|
1851
1829
|
throw new Error(
|
|
@@ -1853,7 +1831,7 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
|
1853
1831
|
);
|
|
1854
1832
|
}
|
|
1855
1833
|
try {
|
|
1856
|
-
const content = await
|
|
1834
|
+
const content = await hsCliHttp4.get(accountId, {
|
|
1857
1835
|
url: `/content/api/v4/contents/${contentId}`,
|
|
1858
1836
|
params: { portalId },
|
|
1859
1837
|
responseType: "json"
|
|
@@ -1892,7 +1870,7 @@ import {
|
|
|
1892
1870
|
isDebugUrlString as isDebugUrlString3,
|
|
1893
1871
|
mergeServerRequestData_internal
|
|
1894
1872
|
} from "@hubspot/cms-components";
|
|
1895
|
-
var { default:
|
|
1873
|
+
var { default: hsCliHttp5 } = localDevHttpImport5;
|
|
1896
1874
|
var getEntryPointBasePathFromProxyRequest = (request2) => {
|
|
1897
1875
|
if (!request2) {
|
|
1898
1876
|
return "";
|
|
@@ -1953,15 +1931,13 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1953
1931
|
contentId
|
|
1954
1932
|
}).toString()}`
|
|
1955
1933
|
);
|
|
1956
|
-
const result =
|
|
1934
|
+
const result = hsCliHttp5.get(accountId, {
|
|
1957
1935
|
baseURL,
|
|
1958
1936
|
url: pathname,
|
|
1959
1937
|
params: proxiedQueryParams,
|
|
1960
1938
|
responseType: "text",
|
|
1961
|
-
// Maybe we can remove the user agent?
|
|
1962
1939
|
headers: {
|
|
1963
|
-
COOKIE: cookieHeader
|
|
1964
|
-
"User-Agent": "HubSpot CMS Dev Server"
|
|
1940
|
+
COOKIE: cookieHeader
|
|
1965
1941
|
}
|
|
1966
1942
|
});
|
|
1967
1943
|
return result.catch((error) => {
|
|
@@ -2557,8 +2533,8 @@ function proxyServerlessRequest(req, res, next) {
|
|
|
2557
2533
|
import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
|
|
2558
2534
|
import path6 from "path";
|
|
2559
2535
|
import { normalizePath as normalizePath5 } from "vite";
|
|
2560
|
-
import
|
|
2561
|
-
var { default:
|
|
2536
|
+
import localDevHttpImport6 from "@hubspot/local-dev-lib/http";
|
|
2537
|
+
var { default: hsCliHttp6 } = localDevHttpImport6;
|
|
2562
2538
|
async function modulePreviewRouteHandler(request2, response) {
|
|
2563
2539
|
sendTrackingRequest("view-module-preview-route");
|
|
2564
2540
|
const {
|
|
@@ -2634,7 +2610,7 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2634
2610
|
});
|
|
2635
2611
|
const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
|
|
2636
2612
|
process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot${authedEnv === "qa" ? "qa" : ""}`;
|
|
2637
|
-
const templatePreviewPromise =
|
|
2613
|
+
const templatePreviewPromise = hsCliHttp6.post(authedPortalId, {
|
|
2638
2614
|
url: `/api/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
|
|
2639
2615
|
headers: {
|
|
2640
2616
|
["content-type"]: "application/x-www-form-urlencoded",
|
|
@@ -2907,6 +2883,9 @@ function devSecretsPlugin(secretNames) {
|
|
|
2907
2883
|
"@hubspot/cms-components"
|
|
2908
2884
|
);
|
|
2909
2885
|
if (cmsComponents3.setSecretsFromEnv) {
|
|
2886
|
+
console.log(
|
|
2887
|
+
`Attempting to load HS_* secrets from .env: ${secretNames}`
|
|
2888
|
+
);
|
|
2910
2889
|
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
2911
2890
|
} else if (secretNames.length > 0) {
|
|
2912
2891
|
console.warn(
|
|
@@ -3061,7 +3040,7 @@ import {
|
|
|
3061
3040
|
import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
|
|
3062
3041
|
|
|
3063
3042
|
// src/proxyPage/fetchDomains.ts
|
|
3064
|
-
import
|
|
3043
|
+
import localDevHttpImport7 from "@hubspot/local-dev-lib/http";
|
|
3065
3044
|
|
|
3066
3045
|
// src/lib/errors.ts
|
|
3067
3046
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -3117,10 +3096,10 @@ function handleSecretsError(error) {
|
|
|
3117
3096
|
}
|
|
3118
3097
|
|
|
3119
3098
|
// src/proxyPage/fetchDomains.ts
|
|
3120
|
-
var { default:
|
|
3099
|
+
var { default: hsCliHttp7 } = localDevHttpImport7;
|
|
3121
3100
|
async function fetchDomains(portalId) {
|
|
3122
3101
|
try {
|
|
3123
|
-
const result = await
|
|
3102
|
+
const result = await hsCliHttp7.get(portalId, {
|
|
3124
3103
|
url: `/cms/v3/domains`,
|
|
3125
3104
|
params: { portalId },
|
|
3126
3105
|
responseType: "json"
|
|
@@ -3146,8 +3125,8 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
3146
3125
|
import path7 from "path";
|
|
3147
3126
|
import fs3 from "fs";
|
|
3148
3127
|
import select from "@inquirer/select";
|
|
3149
|
-
import
|
|
3150
|
-
var { default:
|
|
3128
|
+
import localDevHttpImport8 from "@hubspot/local-dev-lib/http";
|
|
3129
|
+
var { default: hsCliHttp8 } = localDevHttpImport8;
|
|
3151
3130
|
var HSPROJECT_JSON = "hsproject.json";
|
|
3152
3131
|
function checkFileExists(filePath) {
|
|
3153
3132
|
return fs3.existsSync(filePath) && fs3.statSync(filePath).isFile();
|
|
@@ -3181,7 +3160,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
3181
3160
|
const { platformVersion } = hsProjectJSONData;
|
|
3182
3161
|
let platformVersionResult;
|
|
3183
3162
|
try {
|
|
3184
|
-
platformVersionResult = await
|
|
3163
|
+
platformVersionResult = await hsCliHttp8.get(portalId, {
|
|
3185
3164
|
url: `developer/projects/v1/platformVersion`,
|
|
3186
3165
|
responseType: "json"
|
|
3187
3166
|
});
|
|
@@ -3221,7 +3200,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
|
|
|
3221
3200
|
}
|
|
3222
3201
|
|
|
3223
3202
|
// src/createDevServer.ts
|
|
3224
|
-
import
|
|
3203
|
+
import localDevHttpImport9 from "@hubspot/local-dev-lib/http";
|
|
3225
3204
|
|
|
3226
3205
|
// ../cms-js-internal/dist/buildFieldsTypes.js
|
|
3227
3206
|
import { writeFileSync } from "fs";
|
|
@@ -3578,12 +3557,13 @@ var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
|
|
|
3578
3557
|
};
|
|
3579
3558
|
|
|
3580
3559
|
// src/createDevServer.ts
|
|
3581
|
-
var { default:
|
|
3560
|
+
var { default: hsCliHttp9 } = localDevHttpImport9;
|
|
3582
3561
|
var BASE_PATH = "/";
|
|
3583
3562
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
3584
3563
|
var SHADOW_PORT = 1442;
|
|
3585
3564
|
var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
|
|
3586
3565
|
async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2) {
|
|
3566
|
+
var _a;
|
|
3587
3567
|
let authedPortalId = null;
|
|
3588
3568
|
let authedEnv = null;
|
|
3589
3569
|
let jsRenderingGates = [];
|
|
@@ -3668,6 +3648,9 @@ If needed you can refer to another config file with --config.
|
|
|
3668
3648
|
|
|
3669
3649
|
Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded do to missing account data.`
|
|
3670
3650
|
);
|
|
3651
|
+
if (((_a = cmsAssetConfig.secretNames) == null ? void 0 : _a.length) > 0) {
|
|
3652
|
+
secretNames = cmsAssetConfig.secretNames;
|
|
3653
|
+
}
|
|
3671
3654
|
}
|
|
3672
3655
|
setTrackingInfo(authedPortalId, authedEnv);
|
|
3673
3656
|
sendTrackingRequest("start-dev-server");
|
|
@@ -3692,7 +3675,7 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
3692
3675
|
}
|
|
3693
3676
|
let authedHublet;
|
|
3694
3677
|
try {
|
|
3695
|
-
const accountInformation = await
|
|
3678
|
+
const accountInformation = await hsCliHttp9.get(authedPortalId, {
|
|
3696
3679
|
url: "/account-info/v3/details"
|
|
3697
3680
|
});
|
|
3698
3681
|
authedHublet = accountInformation.dataHostingLocation;
|
|
@@ -166,7 +166,12 @@ function includesHublDataReference(templateSource) {
|
|
|
166
166
|
}
|
|
167
167
|
function getCMSAssetConfig(webRoot2) {
|
|
168
168
|
const cmsAssetsPath = path.join(webRoot2, "cms-assets.json");
|
|
169
|
-
|
|
169
|
+
const cmsThemePath = path.join(webRoot2, "theme.json");
|
|
170
|
+
const configPathToUse = fs.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;
|
|
171
|
+
const parsedConfig = JSON.parse(
|
|
172
|
+
fs.readFileSync(configPathToUse).toString()
|
|
173
|
+
);
|
|
174
|
+
return parsedConfig;
|
|
170
175
|
}
|
|
171
176
|
function getCMSAssetConfigIfExists(webRoot2) {
|
|
172
177
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"publint": "publint --level warning --prod"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@hubspot/cms-components": "^0.16.
|
|
28
|
+
"@hubspot/cms-components": "^0.16.2",
|
|
29
29
|
"@hubspot/local-dev-lib": "^1.9.0",
|
|
30
30
|
"@inquirer/select": "^2.0.0",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "0e84a7bc87fb3f237a930d522801c4ed5da2771f"
|
|
112
112
|
}
|