@woodsportal/hubspot-kit 1.0.39-dev.1 → 1.0.40-dev.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/cli.js +77 -17
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/scripts/portal-env-mode.mjs +8 -5
- package/scripts/portal-vite-env.mjs +2 -2
- package/scripts/run-dev.mjs +2 -2
- package/scripts/run-vite-build.mjs +2 -2
- package/scripts/verify-cdn-api-endpoint.mjs +10 -8
- package/scripts/vite/create-dev-server-config.mjs +2 -2
- package/scripts/watch-hubspot.mjs +1 -0
- package/templates/shared/.env.dev.example +2 -4
- package/templates/shared/.env.local.example +6 -0
- package/templates/shared/.env.stg.example +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woodsportal/hubspot-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40-dev.0",
|
|
4
4
|
"description": "WoodsCLI — HubSpot CMS dev kit by WoodsPortal. wp CLI, Vite presets, module-config overlay, and theme/module build pipelines.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Portal Vite modes — align with `.env.dev` | `.env.stg` | `.env.prod`.
|
|
2
|
+
* Portal Vite modes — align with `.env.local` | `.env.dev` | `.env.stg` | `.env.prod`.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
/** @typedef {'dev' | 'stg' | 'prod'} PortalViteMode */
|
|
5
|
+
/** @typedef {'local' | 'dev' | 'stg' | 'prod'} PortalViteMode */
|
|
6
6
|
|
|
7
7
|
/** @param {string[]} [argv] */
|
|
8
8
|
export function resolvePortalViteMode(argv = process.argv) {
|
|
9
|
+
if (argv.includes('--local')) return /** @type {PortalViteMode} */ ('local')
|
|
9
10
|
if (argv.includes('--stg') || argv.includes('--staging')) return /** @type {PortalViteMode} */ ('stg')
|
|
10
|
-
if (argv.includes('--dev')
|
|
11
|
+
if (argv.includes('--dev')) return /** @type {PortalViteMode} */ ('dev')
|
|
12
|
+
if (argv.includes('--development')) return /** @type {PortalViteMode} */ ('local')
|
|
13
|
+
if (argv.includes('--prod') || argv.includes('--production')) return /** @type {PortalViteMode} */ ('prod')
|
|
11
14
|
return /** @type {PortalViteMode} */ ('prod')
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
/** React / bundler NODE_ENV (not the same as portal tier). */
|
|
15
18
|
/** @param {PortalViteMode | string} mode */
|
|
16
19
|
export function nodeEnvForPortalMode(mode) {
|
|
17
|
-
return mode === '
|
|
20
|
+
return mode === 'local' ? 'development' : 'production'
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/** Tailwind class prefix applies on CDN / HubSpot builds, not local dev. */
|
|
21
24
|
/** @param {PortalViteMode | string} mode */
|
|
22
25
|
export function isPrefixBuildMode(mode) {
|
|
23
|
-
return mode === 'stg' || mode === 'prod' || mode === 'staging' || mode === 'production'
|
|
26
|
+
return mode === 'dev' || mode === 'stg' || mode === 'prod' || mode === 'staging' || mode === 'production'
|
|
24
27
|
}
|
|
@@ -6,7 +6,7 @@ import { envWithPortalBuildId } from './resolve-portal-build-id.mjs'
|
|
|
6
6
|
import { envWithPortalCdnConfig } from './load-portal-cdn-config.mjs'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @param {'
|
|
9
|
+
* @param {'local' | 'dev' | 'stg' | 'prod'} mode
|
|
10
10
|
* @param {string} root
|
|
11
11
|
* @param {NodeJS.ProcessEnv} [extra]
|
|
12
12
|
*/
|
|
@@ -29,7 +29,7 @@ export function envForPortalBuild(mode, root, extra = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @param {'
|
|
32
|
+
* @param {'local' | 'dev' | 'stg' | 'prod'} mode
|
|
33
33
|
*/
|
|
34
34
|
export function defaultDatadogFlag(mode) {
|
|
35
35
|
if (process.env.VITE_DATADOG_RUM_ENABLED != null) {
|
package/scripts/run-dev.mjs
CHANGED
|
@@ -16,14 +16,14 @@ process.env.WP_HS_PROJECT_ROOT = projectRoot
|
|
|
16
16
|
const userConfig = await createDevServerViteConfig({ projectRoot, kitRoot, port })
|
|
17
17
|
const resolved =
|
|
18
18
|
typeof userConfig === 'function'
|
|
19
|
-
? await userConfig({ mode: '
|
|
19
|
+
? await userConfig({ mode: 'local', command: 'serve' })
|
|
20
20
|
: await userConfig
|
|
21
21
|
|
|
22
22
|
const { createServer } = await importConsumerDep('vite')
|
|
23
23
|
const server = await createServer({
|
|
24
24
|
...resolved,
|
|
25
25
|
configFile: false,
|
|
26
|
-
mode: '
|
|
26
|
+
mode: 'local',
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
await server.listen()
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Run `vite build` with portal env — `.env.stg` / `.env.prod` take precedence over shell.
|
|
4
4
|
*
|
|
5
|
-
* Usage: node scripts/run-vite-build.mjs <vite-config.mjs> [--stg]
|
|
5
|
+
* Usage: node scripts/run-vite-build.mjs <vite-config.mjs> [--local | --dev | --stg | --prod]
|
|
6
6
|
*/
|
|
7
7
|
import { spawnSync } from 'node:child_process'
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ const configArg = process.argv[2]
|
|
|
21
21
|
const mode = resolvePortalViteMode()
|
|
22
22
|
|
|
23
23
|
if (!configArg) {
|
|
24
|
-
console.error('Usage: node scripts/run-vite-build.mjs <vite-config.mjs> [--stg]')
|
|
24
|
+
console.error('Usage: node scripts/run-vite-build.mjs <vite-config.mjs> [--local | --dev | --stg | --prod]')
|
|
25
25
|
process.exit(1)
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Fail if dist/cdn/app.*.js does not bake the API URL from .env.stg / .env.prod.
|
|
3
|
+
* Fail if dist/cdn/app.*.js does not bake the API URL from .env.dev / .env.stg / .env.prod.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
+
* node scripts/verify-cdn-api-endpoint.mjs --dev
|
|
6
7
|
* node scripts/verify-cdn-api-endpoint.mjs --stg
|
|
7
8
|
* node scripts/verify-cdn-api-endpoint.mjs --prod
|
|
8
9
|
*/
|
|
9
10
|
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
10
|
-
import {
|
|
11
|
-
import { fileURLToPath } from 'node:url'
|
|
12
|
-
import { findProjectRoot } from './project-root.mjs'
|
|
13
|
-
import { loadEnv } from 'vite'
|
|
11
|
+
import { resolve } from 'node:path'
|
|
14
12
|
|
|
13
|
+
import { findProjectRoot } from './project-root.mjs'
|
|
15
14
|
import { resolvePortalBuildId } from './resolve-portal-build-id.mjs'
|
|
16
15
|
import { resolvePortalViteMode } from './portal-env-mode.mjs'
|
|
17
16
|
|
|
18
17
|
const root = findProjectRoot()
|
|
19
18
|
|
|
19
|
+
const dev = process.argv.includes('--dev')
|
|
20
20
|
const stg = process.argv.includes('--stg') || process.argv.includes('--staging')
|
|
21
21
|
const prod = process.argv.includes('--prod') || process.argv.includes('--production')
|
|
22
|
+
const tierFlags = [dev, stg, prod].filter(Boolean)
|
|
22
23
|
|
|
23
|
-
if (
|
|
24
|
+
if (tierFlags.length !== 1) {
|
|
24
25
|
console.error(
|
|
25
|
-
'Usage: node scripts/verify-cdn-api-endpoint.mjs --stg | --prod',
|
|
26
|
+
'Usage: node scripts/verify-cdn-api-endpoint.mjs --dev | --stg | --prod',
|
|
26
27
|
)
|
|
27
28
|
process.exit(1)
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const mode = resolvePortalViteMode()
|
|
32
|
+
const { loadEnv } = await import('vite')
|
|
31
33
|
const fromFile = loadEnv(mode, root, '').VITE_PUBLIC_REST_API_ENDPOINT
|
|
32
34
|
const fromEnv =
|
|
33
35
|
process.env.VITE_PUBLIC_REST_API_ENDPOINT || process.env.WOODPORTAL_API_BASE_URL
|
|
@@ -51,7 +53,7 @@ const appFile = readdirSync(cdnDir).find((f) => f === `app.${buildId}.js`)
|
|
|
51
53
|
|
|
52
54
|
if (!appFile) {
|
|
53
55
|
console.error(
|
|
54
|
-
`[verify-cdn-api] app.${buildId}.js not found in dist/cdn — rebuild with matching .
|
|
56
|
+
`[verify-cdn-api] app.${buildId}.js not found in dist/cdn — rebuild with matching .module-build-id`,
|
|
55
57
|
)
|
|
56
58
|
process.exit(1)
|
|
57
59
|
}
|
|
@@ -60,7 +60,7 @@ export async function createDevServerViteConfig(options = {}) {
|
|
|
60
60
|
plugins: [
|
|
61
61
|
bootstrapShimResolver({ bootstrapShim, bootstrapGreenfieldShim, kitRoot }),
|
|
62
62
|
resolveFromProjectRoot(projectRoot, kitRoot),
|
|
63
|
-
...(command === 'serve' && mode === '
|
|
63
|
+
...(command === 'serve' && mode === 'local'
|
|
64
64
|
? [sdkLogBridge(), moduleConfigStore(projectRoot)]
|
|
65
65
|
: []),
|
|
66
66
|
...(hasTanStackRoutes ? [TanStackRouterVite({ autoCodeSplitting: false })] : []),
|
|
@@ -100,7 +100,7 @@ export async function createDevServerViteConfig(options = {}) {
|
|
|
100
100
|
'import.meta.env.VITE_WPHS_MODULE_NAME': JSON.stringify(
|
|
101
101
|
config?.module?.name ?? config?.theme?.name ?? 'module',
|
|
102
102
|
),
|
|
103
|
-
'process.env.NODE_ENV': JSON.stringify(mode === '
|
|
103
|
+
'process.env.NODE_ENV': JSON.stringify(mode === 'local' ? 'development' : 'production'),
|
|
104
104
|
'process.env': {},
|
|
105
105
|
process: JSON.stringify({ env: {} }),
|
|
106
106
|
},
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Deployed dev CDN build (deploy:dev, ci:release-module:dev) — copy to .env.dev
|
|
2
|
+
VITE_NODE_ENV=dev
|
|
3
3
|
VITE_PUBLIC_REST_API_ENDPOINT=https://api.dev.woodsportal.com
|
|
4
|
-
# VITE_DEV_PORTAL_ID=1
|
|
5
|
-
# VITE_DEV_HUB_ID=12345678
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reserved — future staging CDN (wp build --tier stg). Copy to .env.stg when a staging API exists.
|
|
2
2
|
VITE_NODE_ENV=stg
|
|
3
|
-
VITE_PUBLIC_REST_API_ENDPOINT=https://api.
|
|
3
|
+
# VITE_PUBLIC_REST_API_ENDPOINT=https://api.stg.woodsportal.com
|