@hubspot/cms-dev-server 1.2.78 → 1.2.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generateJsonFromJsx.js +14 -8
- package/dist/index.js +16 -120
- package/dist/island-runtime.js +4 -0
- package/dist/run.js +22 -2122
- package/package.json +2 -2
- package/types/createViteDevServer.d.ts +2 -2
|
@@ -562,18 +562,25 @@ import { join } from "path";
|
|
|
562
562
|
function getPackageJson(packagePath2) {
|
|
563
563
|
return JSON.parse(readFileSync(join(packagePath2, "package.json")).toString());
|
|
564
564
|
}
|
|
565
|
-
function
|
|
566
|
-
const packageJson = getPackageJson(packagePath2);
|
|
567
|
-
return packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
568
|
-
}
|
|
569
|
-
function getDepsForPackageIfExists(packagePath2) {
|
|
565
|
+
function getAllDepsForPackageIfExists(packagePath2) {
|
|
570
566
|
try {
|
|
571
|
-
|
|
567
|
+
const packageJson = getPackageJson(packagePath2);
|
|
568
|
+
return [
|
|
569
|
+
.../* @__PURE__ */ new Set([
|
|
570
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
571
|
+
...Object.keys(packageJson.peerDependencies ?? {})
|
|
572
|
+
])
|
|
573
|
+
];
|
|
572
574
|
} catch (e) {
|
|
573
575
|
console.warn("No package.json at ", packagePath2);
|
|
574
576
|
return [];
|
|
575
577
|
}
|
|
576
578
|
}
|
|
579
|
+
function hasCmsComponentsDependency(packagePath2) {
|
|
580
|
+
return getAllDepsForPackageIfExists(packagePath2).includes(
|
|
581
|
+
"@hubspot/cms-components"
|
|
582
|
+
);
|
|
583
|
+
}
|
|
577
584
|
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames, logLevel) {
|
|
578
585
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
579
586
|
`${proxyDomain}.localhost`,
|
|
@@ -585,8 +592,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
585
592
|
`);
|
|
586
593
|
}
|
|
587
594
|
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
588
|
-
const
|
|
589
|
-
const isProjectWithReact = consumerDeps.includes("@hubspot/cms-components") || process.env.TRANSLATE_ASSET;
|
|
595
|
+
const isProjectWithReact = hasCmsComponentsDependency(webRoot) || process.env.TRANSLATE_ASSET;
|
|
590
596
|
const componentsShimPlugin = isProjectWithReact ? null : cmsComponentsShimPlugin();
|
|
591
597
|
const ssrAndOptimizeDep = isProjectWithReact ? {
|
|
592
598
|
ssr: {
|
package/dist/index.js
CHANGED
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
-
};
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// ../node_modules/@inquirer/select/dist/esm/index.mjs
|
|
12
|
-
var esm_exports = {};
|
|
13
|
-
__export(esm_exports, {
|
|
14
|
-
Separator: () => Separator,
|
|
15
|
-
default: () => esm_default
|
|
16
|
-
});
|
|
17
|
-
import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, useMemo, isEnterKey, isUpKey, isDownKey, isNumberKey, Separator, makeTheme } from "@inquirer/core";
|
|
18
|
-
import chalk from "chalk";
|
|
19
|
-
import figures from "figures";
|
|
20
|
-
import ansiEscapes from "ansi-escapes";
|
|
21
|
-
function isSelectable(item) {
|
|
22
|
-
return !Separator.isSeparator(item) && !item.disabled;
|
|
23
|
-
}
|
|
24
|
-
var selectTheme, esm_default;
|
|
25
|
-
var init_esm = __esm({
|
|
26
|
-
"../node_modules/@inquirer/select/dist/esm/index.mjs"() {
|
|
27
|
-
selectTheme = {
|
|
28
|
-
icon: { cursor: figures.pointer },
|
|
29
|
-
style: { disabled: (text) => chalk.dim(`- ${text}`) }
|
|
30
|
-
};
|
|
31
|
-
esm_default = createPrompt((config, done) => {
|
|
32
|
-
const { choices: items, loop = true, pageSize = 7 } = config;
|
|
33
|
-
const firstRender = useRef(true);
|
|
34
|
-
const theme = makeTheme(selectTheme, config.theme);
|
|
35
|
-
const prefix = usePrefix({ theme });
|
|
36
|
-
const [status, setStatus] = useState("pending");
|
|
37
|
-
const bounds = useMemo(() => {
|
|
38
|
-
const first = items.findIndex(isSelectable);
|
|
39
|
-
const last = items.length - 1 - [...items].reverse().findIndex(isSelectable);
|
|
40
|
-
if (first < 0)
|
|
41
|
-
throw new Error("[select prompt] No selectable choices. All choices are disabled.");
|
|
42
|
-
return { first, last };
|
|
43
|
-
}, [items]);
|
|
44
|
-
const defaultItemIndex = useMemo(() => {
|
|
45
|
-
if (!("default" in config))
|
|
46
|
-
return -1;
|
|
47
|
-
return items.findIndex((item) => isSelectable(item) && item.value === config.default);
|
|
48
|
-
}, [config.default, items]);
|
|
49
|
-
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
50
|
-
const selectedChoice = items[active];
|
|
51
|
-
useKeypress((key) => {
|
|
52
|
-
if (isEnterKey(key)) {
|
|
53
|
-
setStatus("done");
|
|
54
|
-
done(selectedChoice.value);
|
|
55
|
-
} else if (isUpKey(key) || isDownKey(key)) {
|
|
56
|
-
if (loop || isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
|
|
57
|
-
const offset = isUpKey(key) ? -1 : 1;
|
|
58
|
-
let next = active;
|
|
59
|
-
do {
|
|
60
|
-
next = (next + offset + items.length) % items.length;
|
|
61
|
-
} while (!isSelectable(items[next]));
|
|
62
|
-
setActive(next);
|
|
63
|
-
}
|
|
64
|
-
} else if (isNumberKey(key)) {
|
|
65
|
-
const position = Number(key.name) - 1;
|
|
66
|
-
const item = items[position];
|
|
67
|
-
if (item != null && isSelectable(item)) {
|
|
68
|
-
setActive(position);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
const message = theme.style.message(config.message);
|
|
73
|
-
let helpTip;
|
|
74
|
-
if (firstRender.current && items.length <= pageSize) {
|
|
75
|
-
firstRender.current = false;
|
|
76
|
-
helpTip = theme.style.help("(Use arrow keys)");
|
|
77
|
-
}
|
|
78
|
-
const page = usePagination({
|
|
79
|
-
items,
|
|
80
|
-
active,
|
|
81
|
-
renderItem({ item, isActive }) {
|
|
82
|
-
if (Separator.isSeparator(item)) {
|
|
83
|
-
return ` ${item.separator}`;
|
|
84
|
-
}
|
|
85
|
-
const line = item.name || item.value;
|
|
86
|
-
if (item.disabled) {
|
|
87
|
-
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
88
|
-
return theme.style.disabled(`${line} ${disabledLabel}`);
|
|
89
|
-
}
|
|
90
|
-
const color = isActive ? theme.style.highlight : (x) => x;
|
|
91
|
-
const cursor = isActive ? theme.icon.cursor : ` `;
|
|
92
|
-
return color(`${cursor} ${line}`);
|
|
93
|
-
},
|
|
94
|
-
pageSize,
|
|
95
|
-
loop,
|
|
96
|
-
theme
|
|
97
|
-
});
|
|
98
|
-
if (status === "done") {
|
|
99
|
-
const answer = selectedChoice.name || // TODO: Could we enforce that at the type level? Name should be defined for non-string values.
|
|
100
|
-
String(selectedChoice.value);
|
|
101
|
-
return `${prefix} ${message} ${theme.style.answer(answer)}`;
|
|
102
|
-
}
|
|
103
|
-
const choiceDescription = selectedChoice.description ? `
|
|
104
|
-
${selectedChoice.description}` : ``;
|
|
105
|
-
return `${[prefix, message, helpTip].filter(Boolean).join(" ")}
|
|
106
|
-
${page}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
1
|
// src/createViteDevServer.ts
|
|
112
2
|
import { createServer as createViteServer } from "vite";
|
|
113
3
|
import { createRequire } from "module";
|
|
@@ -1248,18 +1138,25 @@ import { join as join2 } from "path";
|
|
|
1248
1138
|
function getPackageJson(packagePath2) {
|
|
1249
1139
|
return JSON.parse(readFileSync2(join2(packagePath2, "package.json")).toString());
|
|
1250
1140
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const packageJson = getPackageJson(packagePath2);
|
|
1253
|
-
return packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
1254
|
-
}
|
|
1255
|
-
function getDepsForPackageIfExists(packagePath2) {
|
|
1141
|
+
function getAllDepsForPackageIfExists(packagePath2) {
|
|
1256
1142
|
try {
|
|
1257
|
-
|
|
1143
|
+
const packageJson = getPackageJson(packagePath2);
|
|
1144
|
+
return [
|
|
1145
|
+
.../* @__PURE__ */ new Set([
|
|
1146
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
1147
|
+
...Object.keys(packageJson.peerDependencies ?? {})
|
|
1148
|
+
])
|
|
1149
|
+
];
|
|
1258
1150
|
} catch (e) {
|
|
1259
1151
|
console.warn("No package.json at ", packagePath2);
|
|
1260
1152
|
return [];
|
|
1261
1153
|
}
|
|
1262
1154
|
}
|
|
1155
|
+
function hasCmsComponentsDependency(packagePath2) {
|
|
1156
|
+
return getAllDepsForPackageIfExists(packagePath2).includes(
|
|
1157
|
+
"@hubspot/cms-components"
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1263
1160
|
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames, logLevel) {
|
|
1264
1161
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
1265
1162
|
`${proxyDomain}.localhost`,
|
|
@@ -1271,8 +1168,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1271
1168
|
`);
|
|
1272
1169
|
}
|
|
1273
1170
|
const origin = process.env.VITE_ORIGIN ?? (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);
|
|
1274
|
-
const
|
|
1275
|
-
const isProjectWithReact = consumerDeps.includes("@hubspot/cms-components") || process.env.TRANSLATE_ASSET;
|
|
1171
|
+
const isProjectWithReact = hasCmsComponentsDependency(webRoot) || process.env.TRANSLATE_ASSET;
|
|
1276
1172
|
const componentsShimPlugin = isProjectWithReact ? null : cmsComponentsShimPlugin();
|
|
1277
1173
|
const ssrAndOptimizeDep = isProjectWithReact ? {
|
|
1278
1174
|
ssr: {
|
|
@@ -1767,7 +1663,7 @@ function trackUsage(action) {
|
|
|
1767
1663
|
eventName: EVENT_NAME,
|
|
1768
1664
|
action,
|
|
1769
1665
|
nodeVersion: getNodeVersionData(),
|
|
1770
|
-
version: "1.2.
|
|
1666
|
+
version: "1.2.80",
|
|
1771
1667
|
os: getPlatform()
|
|
1772
1668
|
};
|
|
1773
1669
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -5548,7 +5444,7 @@ async function validateHSPlatform(projectConfigPath, portalId, deferSelection) {
|
|
|
5548
5444
|
}
|
|
5549
5445
|
if (platformVersion === void 0 || !platformVersionResult.activePlatformVersions.includes(platformVersion)) {
|
|
5550
5446
|
const promptAndWrite = async () => {
|
|
5551
|
-
const { default: select } = await
|
|
5447
|
+
const { default: select } = await import("@inquirer/select");
|
|
5552
5448
|
const answer = await select({
|
|
5553
5449
|
message: 'Your local "hsproject.json" does not have a valid platform version, please select a valid platform version. You can read more about Platform Versioning here https://developers.hubspot.com/docs/platform/platform-versioning',
|
|
5554
5450
|
choices: platformVersionResult.activePlatformVersions.map(
|
package/dist/island-runtime.js
CHANGED
|
@@ -44,10 +44,14 @@ function isValidHostname(hostname) {
|
|
|
44
44
|
(label) => label.length >= 1 && label.length <= 63 && !label.startsWith("-") && !label.endsWith("-")
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
+
var LOCAL_DEV_HOSTNAMES = ["localhost", "127.0.0.1", "0.0.0.0", "[::1]"];
|
|
47
48
|
function getSecureOverrideUrl(path) {
|
|
48
49
|
const currentUrl = new URL(window.location.toString());
|
|
49
50
|
const overrideHost = currentUrl.searchParams.get("hsDebugOverridePublicHost");
|
|
50
51
|
try {
|
|
52
|
+
if (!LOCAL_DEV_HOSTNAMES.includes(currentUrl.hostname)) {
|
|
53
|
+
throw new Error("Override host is only allowed in local development");
|
|
54
|
+
}
|
|
51
55
|
if (!overrideHost) {
|
|
52
56
|
throw new Error("No override host provided");
|
|
53
57
|
}
|