@hubspot/cms-dev-server 0.10.5 → 0.11.1
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 +30 -3
- package/dist/internalSsr.js +12 -12
- package/dist/run.js +101 -33
- package/dist/storybook-main/main.js +12 -12
- package/package.json +5 -5
- package/types/createViteDevServer.d.ts +1 -1
- package/types/plugins/devSecretsPlugin.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -80,7 +80,31 @@ function clientIslandEntryPlugin() {
|
|
|
80
80
|
import mkcert from "vite-plugin-mkcert";
|
|
81
81
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
82
82
|
import { default as Inspect } from "vite-plugin-inspect";
|
|
83
|
-
|
|
83
|
+
|
|
84
|
+
// src/plugins/devSecretsPlugin.ts
|
|
85
|
+
function devSecretsPlugin(secretNames) {
|
|
86
|
+
return {
|
|
87
|
+
name: "dev-secrets",
|
|
88
|
+
configureServer: {
|
|
89
|
+
order: "post",
|
|
90
|
+
async handler(server) {
|
|
91
|
+
const cmsComponents = await server.ssrLoadModule(
|
|
92
|
+
"@hubspot/cms-components"
|
|
93
|
+
);
|
|
94
|
+
if (cmsComponents.setSecretsFromEnv) {
|
|
95
|
+
cmsComponents.setSecretsFromEnv(secretNames);
|
|
96
|
+
} else if (secretNames.length > 0) {
|
|
97
|
+
console.warn(
|
|
98
|
+
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/createViteDevServer.ts
|
|
107
|
+
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], __jsRenderingGates, secretNames) {
|
|
84
108
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
85
109
|
`${proxyDomain}.localhost`,
|
|
86
110
|
`${proxyDomain}.hslocal.net`
|
|
@@ -129,11 +153,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
129
153
|
clientIslandEntryPlugin(),
|
|
130
154
|
resolveIslandPlugin(),
|
|
131
155
|
viteCommonjs(),
|
|
132
|
-
Inspect()
|
|
156
|
+
Inspect(),
|
|
157
|
+
devSecretsPlugin(secretNames)
|
|
133
158
|
],
|
|
134
159
|
css: {
|
|
135
160
|
postcss: webRoot
|
|
136
|
-
}
|
|
161
|
+
},
|
|
162
|
+
envDir: webRoot,
|
|
163
|
+
envPrefix: "HS_"
|
|
137
164
|
};
|
|
138
165
|
return createViteServer(viteConfig);
|
|
139
166
|
}
|
package/dist/internalSsr.js
CHANGED
|
@@ -118,9 +118,9 @@ var serializeIslandDataToJSON = (tweakedIslandsArray, indent = 0) => {
|
|
|
118
118
|
${indentString}`)}`;
|
|
119
119
|
};
|
|
120
120
|
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
121
|
-
const indentString = new Array(indent).fill(" ").join("");
|
|
122
121
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
123
122
|
if (sharedStateIDs.length > 0) {
|
|
123
|
+
const indentString = " ".repeat(indent);
|
|
124
124
|
const stateByID = {};
|
|
125
125
|
sharedStateIDs.forEach(
|
|
126
126
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
@@ -128,12 +128,12 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
|
|
|
128
128
|
const stringifiedState = JSON.stringify(stateByID, null, 2);
|
|
129
129
|
return `
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
var newState = ${stringifiedState};
|
|
132
|
+
if(window.__hsSSInit) {
|
|
133
|
+
window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
|
|
134
|
+
} else {
|
|
135
|
+
window.__hsSSInit = newState;
|
|
136
|
+
}`.replace(/\n/gm, `
|
|
137
137
|
${indentString}`);
|
|
138
138
|
}
|
|
139
139
|
return "";
|
|
@@ -187,7 +187,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
187
187
|
perServerRequestData,
|
|
188
188
|
viteDevServer
|
|
189
189
|
);
|
|
190
|
-
return
|
|
190
|
+
return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
|
|
191
191
|
islands,
|
|
192
192
|
indent
|
|
193
193
|
)}${writeSharedStateToJsGlobal(
|
|
@@ -491,10 +491,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
491
491
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
492
492
|
}
|
|
493
493
|
return `
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
494
|
+
<script type="text/javascript">
|
|
495
|
+
${globals.join("\n ")}
|
|
496
|
+
</script>
|
|
497
|
+
`;
|
|
498
498
|
}
|
|
499
499
|
function namespaceModulePropsShape(props) {
|
|
500
500
|
const {
|
package/dist/run.js
CHANGED
|
@@ -77,7 +77,7 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// src/createDevServer.ts
|
|
80
|
-
import
|
|
80
|
+
import path7 from "path";
|
|
81
81
|
import url2 from "url";
|
|
82
82
|
import express2 from "express";
|
|
83
83
|
import http3 from "http";
|
|
@@ -184,9 +184,9 @@ var serializeIslandDataToJSON = (tweakedIslandsArray, indent = 0) => {
|
|
|
184
184
|
${indentString}`)}`;
|
|
185
185
|
};
|
|
186
186
|
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
187
|
-
const indentString = new Array(indent).fill(" ").join("");
|
|
188
187
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
189
188
|
if (sharedStateIDs.length > 0) {
|
|
189
|
+
const indentString = " ".repeat(indent);
|
|
190
190
|
const stateByID = {};
|
|
191
191
|
sharedStateIDs.forEach(
|
|
192
192
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
@@ -194,12 +194,12 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
|
|
|
194
194
|
const stringifiedState = JSON.stringify(stateByID, null, 2);
|
|
195
195
|
return `
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
var newState = ${stringifiedState};
|
|
198
|
+
if(window.__hsSSInit) {
|
|
199
|
+
window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
|
|
200
|
+
} else {
|
|
201
|
+
window.__hsSSInit = newState;
|
|
202
|
+
}`.replace(/\n/gm, `
|
|
203
203
|
${indentString}`);
|
|
204
204
|
}
|
|
205
205
|
return "";
|
|
@@ -253,7 +253,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
253
253
|
perServerRequestData,
|
|
254
254
|
viteDevServer
|
|
255
255
|
);
|
|
256
|
-
return
|
|
256
|
+
return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
|
|
257
257
|
islands,
|
|
258
258
|
indent
|
|
259
259
|
)}${writeSharedStateToJsGlobal(
|
|
@@ -517,10 +517,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
517
517
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
518
518
|
}
|
|
519
519
|
return `
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
520
|
+
<script type="text/javascript">
|
|
521
|
+
${globals.join("\n ")}
|
|
522
|
+
</script>
|
|
523
|
+
`;
|
|
524
524
|
}
|
|
525
525
|
function namespaceModulePropsShape(props) {
|
|
526
526
|
const {
|
|
@@ -739,7 +739,8 @@ var renderPartial_default = renderPartial;
|
|
|
739
739
|
import { promises as fsPromises } from "fs";
|
|
740
740
|
var { readFile } = fsPromises;
|
|
741
741
|
var generateIslandSetupScriptBlock = () => {
|
|
742
|
-
return
|
|
742
|
+
return `
|
|
743
|
+
<script type="module">
|
|
743
744
|
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
744
745
|
initConfigSingletonFromJSON(window.__hsEnvConfig);
|
|
745
746
|
</script>
|
|
@@ -749,7 +750,7 @@ var generateIslandSetupScriptBlock = () => {
|
|
|
749
750
|
"island-runtime"
|
|
750
751
|
)}';
|
|
751
752
|
setupIslandHydration();
|
|
752
|
-
|
|
753
|
+
</script>
|
|
753
754
|
`;
|
|
754
755
|
};
|
|
755
756
|
var createdPlainHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock) => {
|
|
@@ -793,13 +794,13 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
|
|
|
793
794
|
htmlTemplate = htmlTemplate.replace(
|
|
794
795
|
"<!--islandsglobal-->",
|
|
795
796
|
`<script>
|
|
796
|
-
|
|
797
|
+
${createIslandsGlobalJsForClientInDev(
|
|
797
798
|
renderContext.islands,
|
|
798
799
|
renderContext.perServerRequestData,
|
|
799
800
|
viteServer,
|
|
800
|
-
|
|
801
|
+
6
|
|
801
802
|
)}
|
|
802
|
-
|
|
803
|
+
</script>
|
|
803
804
|
`
|
|
804
805
|
);
|
|
805
806
|
} else {
|
|
@@ -868,7 +869,7 @@ function trackUsage(action) {
|
|
|
868
869
|
eventName: EVENT_NAME,
|
|
869
870
|
action,
|
|
870
871
|
nodeVersion: getNodeVersionData(),
|
|
871
|
-
version: "0.
|
|
872
|
+
version: "0.11.1",
|
|
872
873
|
os: getPlatform()
|
|
873
874
|
};
|
|
874
875
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1433,12 +1434,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1433
1434
|
);
|
|
1434
1435
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1435
1436
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1436
|
-
const
|
|
1437
|
+
const path8 = body.substring(
|
|
1437
1438
|
startOffset + localJsRenderStartString.length,
|
|
1438
1439
|
pathEndOffset
|
|
1439
1440
|
);
|
|
1440
1441
|
offsetSoFar = pathEndOffset + 1;
|
|
1441
|
-
if (startOffset >= 0 &&
|
|
1442
|
+
if (startOffset >= 0 && path8) {
|
|
1442
1443
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1443
1444
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1444
1445
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1449,7 +1450,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1449
1450
|
result.push({
|
|
1450
1451
|
startOffset,
|
|
1451
1452
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1452
|
-
path:
|
|
1453
|
+
path: path8,
|
|
1453
1454
|
json
|
|
1454
1455
|
});
|
|
1455
1456
|
offsetSoFar = endOffset + localJsRenderEndString.length;
|
|
@@ -1557,9 +1558,9 @@ var customColors = [
|
|
|
1557
1558
|
];
|
|
1558
1559
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1559
1560
|
var darkErrorStyles = `background-color: #222; color: #ccc; padding: 0.5em; font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;`;
|
|
1560
|
-
var renderLocalError_default = (
|
|
1561
|
+
var renderLocalError_default = (path8, error) => {
|
|
1561
1562
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1562
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1563
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path8}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1563
1564
|
};
|
|
1564
1565
|
|
|
1565
1566
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2286,7 +2287,31 @@ import { default as react } from "@vitejs/plugin-react";
|
|
|
2286
2287
|
import mkcert from "vite-plugin-mkcert";
|
|
2287
2288
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
2288
2289
|
import { default as Inspect } from "vite-plugin-inspect";
|
|
2289
|
-
|
|
2290
|
+
|
|
2291
|
+
// src/plugins/devSecretsPlugin.ts
|
|
2292
|
+
function devSecretsPlugin(secretNames) {
|
|
2293
|
+
return {
|
|
2294
|
+
name: "dev-secrets",
|
|
2295
|
+
configureServer: {
|
|
2296
|
+
order: "post",
|
|
2297
|
+
async handler(server) {
|
|
2298
|
+
const cmsComponents2 = await server.ssrLoadModule(
|
|
2299
|
+
"@hubspot/cms-components"
|
|
2300
|
+
);
|
|
2301
|
+
if (cmsComponents2.setSecretsFromEnv) {
|
|
2302
|
+
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
2303
|
+
} else if (secretNames.length > 0) {
|
|
2304
|
+
console.warn(
|
|
2305
|
+
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// src/createViteDevServer.ts
|
|
2314
|
+
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], __jsRenderingGates, secretNames) {
|
|
2290
2315
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
2291
2316
|
`${proxyDomain}.localhost`,
|
|
2292
2317
|
`${proxyDomain}.hslocal.net`
|
|
@@ -2335,11 +2360,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
2335
2360
|
clientIslandEntryPlugin(),
|
|
2336
2361
|
resolveIslandPlugin(),
|
|
2337
2362
|
viteCommonjs(),
|
|
2338
|
-
Inspect()
|
|
2363
|
+
Inspect(),
|
|
2364
|
+
devSecretsPlugin(secretNames)
|
|
2339
2365
|
],
|
|
2340
2366
|
css: {
|
|
2341
2367
|
postcss: webRoot2
|
|
2342
|
-
}
|
|
2368
|
+
},
|
|
2369
|
+
envDir: webRoot2,
|
|
2370
|
+
envPrefix: "HS_"
|
|
2343
2371
|
};
|
|
2344
2372
|
return createViteServer(viteConfig);
|
|
2345
2373
|
}
|
|
@@ -2422,6 +2450,7 @@ import {
|
|
|
2422
2450
|
loadConfig,
|
|
2423
2451
|
validateConfig
|
|
2424
2452
|
} from "@hubspot/cli-lib/lib/config.js";
|
|
2453
|
+
import { fetchSecrets } from "@hubspot/cli-lib/api/secrets.js";
|
|
2425
2454
|
|
|
2426
2455
|
// src/proxyPage/fetchDomains.ts
|
|
2427
2456
|
import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
|
|
@@ -2475,6 +2504,14 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
2475
2504
|
return domainNames;
|
|
2476
2505
|
}
|
|
2477
2506
|
|
|
2507
|
+
// src/lib/getCMSAssetConfig.ts
|
|
2508
|
+
import fs2 from "fs";
|
|
2509
|
+
import path6 from "path";
|
|
2510
|
+
function getCMSAssetConfig(webRoot2) {
|
|
2511
|
+
const cmsAssetsPath = path6.join(webRoot2, "cms-assets.json");
|
|
2512
|
+
return JSON.parse(fs2.readFileSync(cmsAssetsPath).toString());
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2478
2515
|
// src/createDevServer.ts
|
|
2479
2516
|
var BASE_PATH = "/";
|
|
2480
2517
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
@@ -2485,6 +2522,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2485
2522
|
let authedEnv = null;
|
|
2486
2523
|
let jsRenderingGates = [];
|
|
2487
2524
|
let personalAccessKey = null;
|
|
2525
|
+
let secretNames = [];
|
|
2488
2526
|
if (hubspotCliConfigPathOption2 && hubspotCliAccountNameOption2) {
|
|
2489
2527
|
console.log(
|
|
2490
2528
|
`Loading HS auth (account = ${hubspotCliAccountNameOption2}) configuration at: ${hubspotCliConfigPathOption2}`
|
|
@@ -2499,6 +2537,15 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2499
2537
|
);
|
|
2500
2538
|
}
|
|
2501
2539
|
loadConfig(hubspotCliConfigPathOption2 || null, { useEnv: false });
|
|
2540
|
+
let cmsAssetConfig;
|
|
2541
|
+
try {
|
|
2542
|
+
cmsAssetConfig = getCMSAssetConfig(webRoot2);
|
|
2543
|
+
} catch (e) {
|
|
2544
|
+
console.error(
|
|
2545
|
+
`Error finding or parsing cms-assets.json when initializing in ${webRoot2}`
|
|
2546
|
+
);
|
|
2547
|
+
process.exit(1);
|
|
2548
|
+
}
|
|
2502
2549
|
if (validateConfig()) {
|
|
2503
2550
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
|
|
2504
2551
|
authedEnv = getEnv2(hubspotCliAccountNameOption2);
|
|
@@ -2522,6 +2569,26 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2522
2569
|
);
|
|
2523
2570
|
}
|
|
2524
2571
|
}
|
|
2572
|
+
try {
|
|
2573
|
+
const secretsResponse = await fetchSecrets(authedPortalId);
|
|
2574
|
+
if (cmsAssetConfig.secretNames && secretsResponse) {
|
|
2575
|
+
secretNames = secretsResponse.results.filter(
|
|
2576
|
+
(secretName) => cmsAssetConfig.secretNames.includes(secretName)
|
|
2577
|
+
);
|
|
2578
|
+
if (secretNames.length < cmsAssetConfig.secretNames.length) {
|
|
2579
|
+
const missingSecrets = cmsAssetConfig.secretNames.filter(
|
|
2580
|
+
(secretName) => secretsResponse.results.includes(secretName) === false
|
|
2581
|
+
);
|
|
2582
|
+
console.error(
|
|
2583
|
+
`Secrets ${missingSecrets.join(
|
|
2584
|
+
", "
|
|
2585
|
+
)} could not be found as initialized for this account, be sure to use \`hs secrets add\``
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
} catch (e) {
|
|
2590
|
+
console.log(e);
|
|
2591
|
+
}
|
|
2525
2592
|
} else {
|
|
2526
2593
|
console.warn(
|
|
2527
2594
|
`Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
|
|
@@ -2549,20 +2616,21 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2549
2616
|
}
|
|
2550
2617
|
}
|
|
2551
2618
|
const authedHublet = "na1";
|
|
2552
|
-
const absoluteWebRoot = normalizePath5(
|
|
2619
|
+
const absoluteWebRoot = normalizePath5(path7.resolve(process.cwd(), webRoot2));
|
|
2553
2620
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
2554
2621
|
const viteServer = await createViteDevServer_default(
|
|
2555
2622
|
absoluteWebRoot,
|
|
2556
2623
|
PORT,
|
|
2557
2624
|
sslEnabledOption2,
|
|
2558
2625
|
domainsToProxy,
|
|
2559
|
-
jsRenderingGates
|
|
2626
|
+
jsRenderingGates,
|
|
2627
|
+
secretNames
|
|
2560
2628
|
);
|
|
2561
2629
|
const viteHTTPSConfig = viteServer.config.server.https;
|
|
2562
2630
|
const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
|
|
2563
2631
|
const httpsCert = viteHTTPSConfig ? viteHTTPSConfig.cert : null;
|
|
2564
2632
|
const projectName = getProjectNameFromHSConfig(
|
|
2565
|
-
|
|
2633
|
+
path7.join(webRoot2, "../hsproject.json")
|
|
2566
2634
|
);
|
|
2567
2635
|
const httpServers = [];
|
|
2568
2636
|
const expressServer = express2();
|
|
@@ -2619,8 +2687,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2619
2687
|
`
|
|
2620
2688
|
);
|
|
2621
2689
|
if (storybook2) {
|
|
2622
|
-
const packageRoot =
|
|
2623
|
-
const configPath =
|
|
2690
|
+
const packageRoot = path7.dirname(url2.fileURLToPath(import.meta.url));
|
|
2691
|
+
const configPath = path7.resolve(packageRoot, "./storybook-main");
|
|
2624
2692
|
sendTrackingRequest("start-storybook");
|
|
2625
2693
|
const storybookProcess = spawn(
|
|
2626
2694
|
"sb",
|
|
@@ -2640,7 +2708,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2640
2708
|
portalId: authedPortalId.toString(),
|
|
2641
2709
|
hsEnv: authedEnv,
|
|
2642
2710
|
hublet: authedHublet,
|
|
2643
|
-
WEB_ROOT:
|
|
2711
|
+
WEB_ROOT: path7.join(webRoot2, "components")
|
|
2644
2712
|
}
|
|
2645
2713
|
}
|
|
2646
2714
|
);
|
|
@@ -285,10 +285,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
285
285
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
286
286
|
}
|
|
287
287
|
return `
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
<script type="text/javascript">
|
|
289
|
+
${globals.join("\n ")}
|
|
290
|
+
</script>
|
|
291
|
+
`;
|
|
292
292
|
}
|
|
293
293
|
function namespaceModulePropsShape(props) {
|
|
294
294
|
const {
|
|
@@ -459,9 +459,9 @@ var init_dist = __esm({
|
|
|
459
459
|
${indentString}`)}`;
|
|
460
460
|
};
|
|
461
461
|
writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
462
|
-
const indentString = new Array(indent).fill(" ").join("");
|
|
463
462
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
464
463
|
if (sharedStateIDs.length > 0) {
|
|
464
|
+
const indentString = " ".repeat(indent);
|
|
465
465
|
const stateByID = {};
|
|
466
466
|
sharedStateIDs.forEach(
|
|
467
467
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
@@ -469,12 +469,12 @@ ${indentString}`)}`;
|
|
|
469
469
|
const stringifiedState = JSON.stringify(stateByID, null, 2);
|
|
470
470
|
return `
|
|
471
471
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
472
|
+
var newState = ${stringifiedState};
|
|
473
|
+
if(window.__hsSSInit) {
|
|
474
|
+
window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
|
|
475
|
+
} else {
|
|
476
|
+
window.__hsSSInit = newState;
|
|
477
|
+
}`.replace(/\n/gm, `
|
|
478
478
|
${indentString}`);
|
|
479
479
|
}
|
|
480
480
|
return "";
|
|
@@ -485,7 +485,7 @@ ${indentString}`);
|
|
|
485
485
|
perServerRequestData,
|
|
486
486
|
viteDevServer
|
|
487
487
|
);
|
|
488
|
-
return
|
|
488
|
+
return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
|
|
489
489
|
islands,
|
|
490
490
|
indent
|
|
491
491
|
)}${writeSharedStateToJsGlobal(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"runBuild": "node dist/run.js",
|
|
21
21
|
"start": "ts-node-esm --transpileOnly runWhenDeveloping.ts",
|
|
22
22
|
"start-inspect": "node --loader ts-node/esm --inspect runWhenDeveloping.ts",
|
|
23
|
-
"test": "NODE_ENV=test vitest run",
|
|
24
|
-
"test:watch": "NODE_ENV=test vitest watch"
|
|
23
|
+
"test": "PORT=30042 NODE_ENV=test vitest run",
|
|
24
|
+
"test:watch": "PORT=30042 NODE_ENV=test vitest watch"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@hubspot/cli-lib": "^3.0.12",
|
|
28
|
-
"@hubspot/cms-components": "^0.
|
|
28
|
+
"@hubspot/cms-components": "^0.11.1",
|
|
29
29
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
30
30
|
"@storybook/addon-actions": "7.0.7",
|
|
31
31
|
"@storybook/addon-essentials": "7.0.7",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "9f30f60b3fba97d314fcc84b1fa171637755f961"
|
|
105
105
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[], __jsRenderingGates: string[]): Promise<import("vite").ViteDevServer>;
|
|
1
|
+
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[], __jsRenderingGates: string[], secretNames: string[]): Promise<import("vite").ViteDevServer>;
|
|
2
2
|
export default createViteDevServer;
|