@hubspot/cms-dev-server 0.10.5 → 0.11.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/fsevents-72LCIACT.node +0 -0
- package/dist/index.js +24 -3
- package/dist/run.js +77 -16
- package/package.json +3 -3
- package/types/createViteDevServer.d.ts +1 -1
- package/types/generateBpmAliases.d.ts +2 -0
- package/types/noNodeBuiltinsPlugin.d.ts +3 -0
- package/types/plugins/devSecretsPlugin.d.ts +2 -0
- package/types/resolveSharedDeps.d.ts +2 -0
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -80,7 +80,25 @@ 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
|
+
cmsComponents.setSecretsFromEnv(secretNames);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/createViteDevServer.ts
|
|
101
|
+
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], __jsRenderingGates, secretNames) {
|
|
84
102
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
85
103
|
`${proxyDomain}.localhost`,
|
|
86
104
|
`${proxyDomain}.hslocal.net`
|
|
@@ -129,11 +147,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
129
147
|
clientIslandEntryPlugin(),
|
|
130
148
|
resolveIslandPlugin(),
|
|
131
149
|
viteCommonjs(),
|
|
132
|
-
Inspect()
|
|
150
|
+
Inspect(),
|
|
151
|
+
devSecretsPlugin(secretNames)
|
|
133
152
|
],
|
|
134
153
|
css: {
|
|
135
154
|
postcss: webRoot
|
|
136
|
-
}
|
|
155
|
+
},
|
|
156
|
+
envDir: webRoot,
|
|
157
|
+
envPrefix: "HS_"
|
|
137
158
|
};
|
|
138
159
|
return createViteServer(viteConfig);
|
|
139
160
|
}
|
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";
|
|
@@ -868,7 +868,7 @@ function trackUsage(action) {
|
|
|
868
868
|
eventName: EVENT_NAME,
|
|
869
869
|
action,
|
|
870
870
|
nodeVersion: getNodeVersionData(),
|
|
871
|
-
version: "0.
|
|
871
|
+
version: "0.11.0",
|
|
872
872
|
os: getPlatform()
|
|
873
873
|
};
|
|
874
874
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1433,12 +1433,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1433
1433
|
);
|
|
1434
1434
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1435
1435
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1436
|
-
const
|
|
1436
|
+
const path8 = body.substring(
|
|
1437
1437
|
startOffset + localJsRenderStartString.length,
|
|
1438
1438
|
pathEndOffset
|
|
1439
1439
|
);
|
|
1440
1440
|
offsetSoFar = pathEndOffset + 1;
|
|
1441
|
-
if (startOffset >= 0 &&
|
|
1441
|
+
if (startOffset >= 0 && path8) {
|
|
1442
1442
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1443
1443
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1444
1444
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1449,7 +1449,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1449
1449
|
result.push({
|
|
1450
1450
|
startOffset,
|
|
1451
1451
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1452
|
-
path:
|
|
1452
|
+
path: path8,
|
|
1453
1453
|
json
|
|
1454
1454
|
});
|
|
1455
1455
|
offsetSoFar = endOffset + localJsRenderEndString.length;
|
|
@@ -1557,9 +1557,9 @@ var customColors = [
|
|
|
1557
1557
|
];
|
|
1558
1558
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1559
1559
|
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 = (
|
|
1560
|
+
var renderLocalError_default = (path8, error) => {
|
|
1561
1561
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1562
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1562
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path8}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1563
1563
|
};
|
|
1564
1564
|
|
|
1565
1565
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2286,7 +2286,25 @@ import { default as react } from "@vitejs/plugin-react";
|
|
|
2286
2286
|
import mkcert from "vite-plugin-mkcert";
|
|
2287
2287
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
2288
2288
|
import { default as Inspect } from "vite-plugin-inspect";
|
|
2289
|
-
|
|
2289
|
+
|
|
2290
|
+
// src/plugins/devSecretsPlugin.ts
|
|
2291
|
+
function devSecretsPlugin(secretNames) {
|
|
2292
|
+
return {
|
|
2293
|
+
name: "dev-secrets",
|
|
2294
|
+
configureServer: {
|
|
2295
|
+
order: "post",
|
|
2296
|
+
async handler(server) {
|
|
2297
|
+
const cmsComponents2 = await server.ssrLoadModule(
|
|
2298
|
+
"@hubspot/cms-components"
|
|
2299
|
+
);
|
|
2300
|
+
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// src/createViteDevServer.ts
|
|
2307
|
+
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], __jsRenderingGates, secretNames) {
|
|
2290
2308
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
2291
2309
|
`${proxyDomain}.localhost`,
|
|
2292
2310
|
`${proxyDomain}.hslocal.net`
|
|
@@ -2335,11 +2353,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
2335
2353
|
clientIslandEntryPlugin(),
|
|
2336
2354
|
resolveIslandPlugin(),
|
|
2337
2355
|
viteCommonjs(),
|
|
2338
|
-
Inspect()
|
|
2356
|
+
Inspect(),
|
|
2357
|
+
devSecretsPlugin(secretNames)
|
|
2339
2358
|
],
|
|
2340
2359
|
css: {
|
|
2341
2360
|
postcss: webRoot2
|
|
2342
|
-
}
|
|
2361
|
+
},
|
|
2362
|
+
envDir: webRoot2,
|
|
2363
|
+
envPrefix: "HS_"
|
|
2343
2364
|
};
|
|
2344
2365
|
return createViteServer(viteConfig);
|
|
2345
2366
|
}
|
|
@@ -2422,6 +2443,7 @@ import {
|
|
|
2422
2443
|
loadConfig,
|
|
2423
2444
|
validateConfig
|
|
2424
2445
|
} from "@hubspot/cli-lib/lib/config.js";
|
|
2446
|
+
import { fetchSecrets } from "@hubspot/cli-lib/api/secrets.js";
|
|
2425
2447
|
|
|
2426
2448
|
// src/proxyPage/fetchDomains.ts
|
|
2427
2449
|
import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
|
|
@@ -2475,6 +2497,14 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
2475
2497
|
return domainNames;
|
|
2476
2498
|
}
|
|
2477
2499
|
|
|
2500
|
+
// src/lib/getCMSAssetConfig.ts
|
|
2501
|
+
import fs2 from "fs";
|
|
2502
|
+
import path6 from "path";
|
|
2503
|
+
function getCMSAssetConfig(webRoot2) {
|
|
2504
|
+
const cmsAssetsPath = path6.join(webRoot2, "cms-assets.json");
|
|
2505
|
+
return JSON.parse(fs2.readFileSync(cmsAssetsPath).toString());
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2478
2508
|
// src/createDevServer.ts
|
|
2479
2509
|
var BASE_PATH = "/";
|
|
2480
2510
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
@@ -2485,6 +2515,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2485
2515
|
let authedEnv = null;
|
|
2486
2516
|
let jsRenderingGates = [];
|
|
2487
2517
|
let personalAccessKey = null;
|
|
2518
|
+
let secretNames = [];
|
|
2488
2519
|
if (hubspotCliConfigPathOption2 && hubspotCliAccountNameOption2) {
|
|
2489
2520
|
console.log(
|
|
2490
2521
|
`Loading HS auth (account = ${hubspotCliAccountNameOption2}) configuration at: ${hubspotCliConfigPathOption2}`
|
|
@@ -2499,6 +2530,15 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2499
2530
|
);
|
|
2500
2531
|
}
|
|
2501
2532
|
loadConfig(hubspotCliConfigPathOption2 || null, { useEnv: false });
|
|
2533
|
+
let cmsAssetConfig;
|
|
2534
|
+
try {
|
|
2535
|
+
cmsAssetConfig = getCMSAssetConfig(webRoot2);
|
|
2536
|
+
} catch (e) {
|
|
2537
|
+
console.error(
|
|
2538
|
+
`Error finding or parsing cms-assets.json when initializing in ${webRoot2}`
|
|
2539
|
+
);
|
|
2540
|
+
process.exit(1);
|
|
2541
|
+
}
|
|
2502
2542
|
if (validateConfig()) {
|
|
2503
2543
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
|
|
2504
2544
|
authedEnv = getEnv2(hubspotCliAccountNameOption2);
|
|
@@ -2522,6 +2562,26 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2522
2562
|
);
|
|
2523
2563
|
}
|
|
2524
2564
|
}
|
|
2565
|
+
try {
|
|
2566
|
+
const secretsResponse = await fetchSecrets(authedPortalId);
|
|
2567
|
+
if (cmsAssetConfig.secretNames && secretsResponse) {
|
|
2568
|
+
secretNames = secretsResponse.results.filter(
|
|
2569
|
+
(secretName) => cmsAssetConfig.secretNames.includes(secretName)
|
|
2570
|
+
);
|
|
2571
|
+
if (secretNames.length < cmsAssetConfig.secretNames.length) {
|
|
2572
|
+
const missingSecrets = cmsAssetConfig.secretNames.filter(
|
|
2573
|
+
(secretName) => secretsResponse.results.includes(secretName) === false
|
|
2574
|
+
);
|
|
2575
|
+
console.error(
|
|
2576
|
+
`Secrets ${missingSecrets.join(
|
|
2577
|
+
", "
|
|
2578
|
+
)} could not be found as initialized for this account, be sure to use \`hs secrets add\``
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
} catch (e) {
|
|
2583
|
+
console.log(e);
|
|
2584
|
+
}
|
|
2525
2585
|
} else {
|
|
2526
2586
|
console.warn(
|
|
2527
2587
|
`Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
|
|
@@ -2549,20 +2609,21 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2549
2609
|
}
|
|
2550
2610
|
}
|
|
2551
2611
|
const authedHublet = "na1";
|
|
2552
|
-
const absoluteWebRoot = normalizePath5(
|
|
2612
|
+
const absoluteWebRoot = normalizePath5(path7.resolve(process.cwd(), webRoot2));
|
|
2553
2613
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
2554
2614
|
const viteServer = await createViteDevServer_default(
|
|
2555
2615
|
absoluteWebRoot,
|
|
2556
2616
|
PORT,
|
|
2557
2617
|
sslEnabledOption2,
|
|
2558
2618
|
domainsToProxy,
|
|
2559
|
-
jsRenderingGates
|
|
2619
|
+
jsRenderingGates,
|
|
2620
|
+
secretNames
|
|
2560
2621
|
);
|
|
2561
2622
|
const viteHTTPSConfig = viteServer.config.server.https;
|
|
2562
2623
|
const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
|
|
2563
2624
|
const httpsCert = viteHTTPSConfig ? viteHTTPSConfig.cert : null;
|
|
2564
2625
|
const projectName = getProjectNameFromHSConfig(
|
|
2565
|
-
|
|
2626
|
+
path7.join(webRoot2, "../hsproject.json")
|
|
2566
2627
|
);
|
|
2567
2628
|
const httpServers = [];
|
|
2568
2629
|
const expressServer = express2();
|
|
@@ -2619,8 +2680,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2619
2680
|
`
|
|
2620
2681
|
);
|
|
2621
2682
|
if (storybook2) {
|
|
2622
|
-
const packageRoot =
|
|
2623
|
-
const configPath =
|
|
2683
|
+
const packageRoot = path7.dirname(url2.fileURLToPath(import.meta.url));
|
|
2684
|
+
const configPath = path7.resolve(packageRoot, "./storybook-main");
|
|
2624
2685
|
sendTrackingRequest("start-storybook");
|
|
2625
2686
|
const storybookProcess = spawn(
|
|
2626
2687
|
"sb",
|
|
@@ -2640,7 +2701,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2640
2701
|
portalId: authedPortalId.toString(),
|
|
2641
2702
|
hsEnv: authedEnv,
|
|
2642
2703
|
hublet: authedHublet,
|
|
2643
|
-
WEB_ROOT:
|
|
2704
|
+
WEB_ROOT: path7.join(webRoot2, "components")
|
|
2644
2705
|
}
|
|
2645
2706
|
}
|
|
2646
2707
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@hubspot/cli-lib": "^3.0.12",
|
|
28
|
-
"@hubspot/cms-components": "^0.
|
|
28
|
+
"@hubspot/cms-components": "^0.11.0",
|
|
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": "58a898a8a65a52b85a56d562289e5ee38becddfb"
|
|
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;
|