@woodsportal/hubspot-kit 1.0.26 → 1.0.29
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/CHANGELOG.md +19 -0
- package/README.md +242 -35
- package/dist/{chunk-U4KFGTEW.js → chunk-S2YJDWZU.js} +5 -5
- package/dist/chunk-S2YJDWZU.js.map +1 -0
- package/dist/cli.js +192 -256
- package/dist/cli.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/vite/index.js +1 -1
- package/examples/greenfield/module-hybrid-cdn/src/features/starter/content/woodscli-guide-content.ts +4 -4
- package/examples/greenfield/module-monolith/src/features/starter/content/woodscli-guide-content.ts +4 -4
- package/examples/smoke/run-matrix.mjs +1 -1
- package/package.json +1 -1
- package/scripts/detect-layout.mjs +71 -4
- package/scripts/run-hubspot-module-postbuild.mjs +26 -3
- package/templates/module-hybrid-cdn/src/features/starter/content/woodscli-guide-content.ts +4 -4
- package/templates/module-monolith/src/features/starter/content/woodscli-guide-content.ts +4 -4
- package/dist/chunk-U4KFGTEW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.29 — 2026-06-07
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
- **Removed `wp adopt`** — use `wp init` for new projects; add `woodscli.json` manually for legacy `<name>.module/` upload-only repos (see MODULES.md)
|
|
7
|
+
|
|
8
|
+
## 1.0.28 — 2026-06-07
|
|
9
|
+
|
|
10
|
+
### CLI
|
|
11
|
+
- **`wp adopt` dev scaffold** for preexisting `<name>.module/` repos — interactive track (monolith / hybrid CDN / upload-only) and optional template copy (`package.json`, `src/`, `public/`)
|
|
12
|
+
- CI flags: `--track monolith|hybrid-cdn`, `--scaffold-dev`, `--router hash|browser|none`
|
|
13
|
+
- Upload-only adopt: `module.outDir` stays at `.module/`; `wp doctor` skips dev checks with guidance
|
|
14
|
+
- Postbuild resolves `fields.json` / `module.html` from `dev.fieldsJson` when `public/` is absent
|
|
15
|
+
|
|
16
|
+
## 1.0.27 — 2026-06-07
|
|
17
|
+
|
|
18
|
+
### Docs
|
|
19
|
+
- Expanded README: full command reference, workflows, project layout, documentation index
|
|
20
|
+
- Aligned `GETTING-STARTED.md` and `HUBSPOT-CLI-SETUP.md` (`defaultPortal` = portal name)
|
|
21
|
+
|
|
3
22
|
## 1.0.26 — 2026-06-07
|
|
4
23
|
|
|
5
24
|
### CLI
|
package/README.md
CHANGED
|
@@ -1,64 +1,271 @@
|
|
|
1
1
|
# WoodsCLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> `npm i @woodsportal/hubspot-kit` · `wp dev`
|
|
3
|
+
**HubSpot CMS dev kit by WoodsPortal** — local preview, module field editing, Vite build pipelines, and HubSpot upload/watch for **custom modules** and **themes**.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npm i -D @woodsportal/hubspot-kit@^1.0.29
|
|
7
|
+
npx wp --version
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The `wp` CLI wraps [`@hubspot/cli`](https://developers.hubspot.com/docs/cms/developer-reference/local-development-cli) for CMS operations and adds WoodsPortal-specific tooling: hybrid CDN or monolith module builds, the **module-config overlay** (**Ctrl+Shift+Z** / **Cmd+Shift+Z**), and a `.wphs/` local workspace.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What you get
|
|
15
|
+
|
|
16
|
+
| Capability | Command / artifact |
|
|
17
|
+
|------------|-------------------|
|
|
18
|
+
| Scaffold module or theme | `wp init` |
|
|
19
|
+
| Local SPA + field editor | `wp dev` (`wp local`) |
|
|
20
|
+
| HubSpot file sync | `wp watch`, `wp upload` |
|
|
21
|
+
| Full ship pipeline | `wp deploy` (build → CDN publish → upload) |
|
|
22
|
+
| Project health check | `wp doctor` |
|
|
23
|
+
| Portal switching | `wp portal use` |
|
|
24
|
+
| CI / regression gates | `wp examples smoke`, `wp regression smoke`, `wp audit *` |
|
|
25
|
+
|
|
26
|
+
**Reference implementation:** [woodsportal-client-frontend](https://github.com/Digital-Woods/digitalwoods.io-woodsportal-client-frontend) — advanced hybrid CDN module with a full app adapter.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Prerequisites
|
|
31
|
+
|
|
32
|
+
| Requirement | Notes |
|
|
33
|
+
|-------------|--------|
|
|
34
|
+
| **Node.js 20+** | Enforced by `wp doctor` |
|
|
35
|
+
| **HubSpot CLI** | `npm i -g @hubspot/cli` — required for upload/watch/deploy |
|
|
36
|
+
| **HubSpot CMS portal** | Design Manager access; PAT or OAuth via `wp auth` |
|
|
37
|
+
| **Project config** | `woodscli.json` at repo root (created by `wp init`) |
|
|
38
|
+
|
|
39
|
+
Local preview (`wp dev`) runs **without** HubSpot credentials. Upload, watch, and deploy need a valid project `hubspot.config.yml`.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
**New project** (scaffold includes the kit):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx wp init -t module-hybrid-cdn -n my-portal-module
|
|
49
|
+
cd my-portal-module && npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Existing consumer** (add dev dependency):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm i -D @woodsportal/hubspot-kit@^1.0.29
|
|
56
|
+
# or: yarn add -D @woodsportal/hubspot-kit@^1.0.26
|
|
57
|
+
```
|
|
7
58
|
|
|
8
|
-
|
|
59
|
+
Use scripts that call `wp` directly, or rely on `node_modules/.bin/wp` after install.
|
|
9
60
|
|
|
10
|
-
|
|
11
|
-
|-------|---------------|-------------|
|
|
12
|
-
| **Module (hybrid CDN)** | `module-hybrid-cdn` | `wp init -t module-hybrid-cdn` → `wp dev` → `wp deploy` |
|
|
13
|
-
| **Module (monolith)** | `module-monolith` | `wp init -t module-monolith` → `wp dev` → `wp build --hubspot-only` |
|
|
14
|
-
| **Theme** | `theme-starter` | `wp init -t theme-starter` → `wp dev` → `wp upload` |
|
|
61
|
+
---
|
|
15
62
|
|
|
16
|
-
|
|
63
|
+
## Project types
|
|
17
64
|
|
|
18
|
-
|
|
65
|
+
| Track | `projectType` | Build output | Typical ship flow |
|
|
66
|
+
|-------|---------------|--------------|-------------------|
|
|
67
|
+
| **Module (hybrid CDN)** | `module-hybrid-cdn` | `dist/cdn/*` + `module.outDir` | `wp deploy` |
|
|
68
|
+
| **Module (monolith)** | `module-monolith` | Single bundle in `module.outDir` | `wp build` → `wp upload` |
|
|
69
|
+
| **Theme** | `theme-starter` | Theme folder under `theme.srcDir` | `wp upload` |
|
|
70
|
+
|
|
71
|
+
Init templates live under `templates/` in this package. Hybrid CDN splits vendor/app chunks for jsDelivr; monolith sets `cdn.mode: none` and skips CDN publish on deploy.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Quick start (greenfield)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npx wp init -t module-hybrid-cdn -n my-portal-module
|
|
79
|
+
cd my-portal-module && npm install
|
|
80
|
+
|
|
81
|
+
wp setup # hubspot.config.yml, .env.*, CDN files, vite shims (never overwrites)
|
|
82
|
+
wp doctor # Node, config, .wphs/, HubSpot CLI
|
|
83
|
+
wp auth # HubSpot login — updates hubspot.config.yml
|
|
84
|
+
wp portal use # interactive default portal (or: wp portal use <name>)
|
|
85
|
+
|
|
86
|
+
wp dev # http://localhost:3000 — alias: wp local
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Module overlay:** open the dev server, press **Ctrl+Shift+Z** (Windows/Linux) or **Cmd+Shift+Z** (macOS) to edit Content/Styles fields against `fields.json`.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Existing repository
|
|
19
94
|
|
|
20
95
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
wp setup # copy hubspot.config.yml, .env.*, CDN templates
|
|
96
|
+
wp setup # hubspot.config.yml, .env.*, vite shims (after woodscli.json exists)
|
|
97
|
+
wp migrate --yes # if you still have legacy .dev/ or woodsportal.hs.json
|
|
24
98
|
wp doctor
|
|
25
|
-
wp dev # alias: wp local
|
|
26
99
|
```
|
|
27
100
|
|
|
28
|
-
|
|
101
|
+
For legacy **`<name>.module/`** artifact folders (plain JS, no `src/`), add `woodscli.json` manually (see [docs/MODULES.md](./docs/MODULES.md)) then `wp setup` and `wp upload`.
|
|
102
|
+
|
|
103
|
+
Legacy filename `woodsportal.hs.json` is **not** read — migrate to `woodscli.json` with `wp migrate --yes`.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Day-to-day workflows
|
|
108
|
+
|
|
109
|
+
### Local development
|
|
29
110
|
|
|
30
111
|
```bash
|
|
31
|
-
wp
|
|
32
|
-
wp
|
|
112
|
+
wp dev # Vite HMR + module-config overlay
|
|
113
|
+
wp dev -p 3001 # custom port
|
|
33
114
|
```
|
|
34
115
|
|
|
35
|
-
|
|
116
|
+
### Watch HubSpot folder (CMS sync)
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
wp watch # hs cms watch on module.outDir (builds if output missing)
|
|
120
|
+
wp watch --rebuild # rebuild on src/ + public/ changes, then watch
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`wp watch` does not use progress spinners so **Ctrl+C** and HubSpot TTY output stay reliable.
|
|
124
|
+
|
|
125
|
+
### Build and ship
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
wp build # default --tier dev
|
|
129
|
+
wp build --cdn-only # hybrid CDN chunks only
|
|
130
|
+
wp build --hubspot-only # module bundle only (monolith-friendly)
|
|
131
|
+
|
|
132
|
+
wp publish --tier dev # push CDN mirror (hybrid only)
|
|
133
|
+
wp upload --tier dev # hs cms upload
|
|
134
|
+
wp deploy --tier dev # build + publish + upload (skips CDN when cdn.mode: none)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Tiers: `dev` | `stg` | `prod`. Production upload requires confirmation (`--yes` or `WP_HS_CONFIRM_PROD=1`). See [docs/BUILD-MODES.md](./docs/BUILD-MODES.md).
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## HubSpot authentication
|
|
142
|
+
|
|
143
|
+
1. `wp setup` copies `hubspot.config.yml.example` → `hubspot.config.yml` (gitignored).
|
|
144
|
+
2. `wp auth` runs `hs auth` (browser / PAT flow).
|
|
145
|
+
3. `wp portal list` shows configured portals; `wp portal use <name>` sets `defaultPortal`.
|
|
146
|
+
|
|
147
|
+
Run auth and portal commands from the **project root** so HubSpot CLI reads `./hubspot.config.yml`.
|
|
148
|
+
|
|
149
|
+
Full guide: [docs/HUBSPOT-CLI-SETUP.md](./docs/HUBSPOT-CLI-SETUP.md)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Command reference
|
|
154
|
+
|
|
155
|
+
Global flags (all commands): `--project <path>`, `--ci`, `--json`, `--verbose`, `--quiet`, `--dry-run`, `-y/--yes`.
|
|
156
|
+
|
|
157
|
+
### Project lifecycle
|
|
36
158
|
|
|
37
159
|
| Command | Description |
|
|
38
160
|
|---------|-------------|
|
|
39
|
-
| `wp
|
|
40
|
-
| `wp
|
|
41
|
-
| `wp
|
|
42
|
-
| `wp
|
|
43
|
-
| `wp
|
|
44
|
-
| `wp migrate` | `.dev/` → `.wphs/` |
|
|
45
|
-
| `wp examples smoke` | Run examples matrix (CI) |
|
|
46
|
-
| `wp audit secrets` | Scan for hardcoded credentials |
|
|
161
|
+
| `wp init [-t template] [-n name] [--router hash\|browser\|none]` | Scaffold `module-hybrid-cdn`, `module-monolith`, or `theme-starter` |
|
|
162
|
+
| `wp migrate` | Move legacy `.dev/` / `woodsportal.hs.json` → `.wphs/` + `woodscli.json` |
|
|
163
|
+
| `wp setup [--tier dev\|stg\|prod]` | Copy missing config, env, CDN, and vite shim files |
|
|
164
|
+
| `wp doctor` | Prerequisite checks (interactive progress on TTY) |
|
|
165
|
+
| `wp config validate` | Validate `woodscli.json` (zod) |
|
|
47
166
|
|
|
48
|
-
|
|
167
|
+
### HubSpot account
|
|
49
168
|
|
|
50
|
-
|
|
169
|
+
| Command | Description |
|
|
170
|
+
|---------|-------------|
|
|
171
|
+
| `wp auth` | `hs auth` — add or refresh portal credentials |
|
|
172
|
+
| `wp portal list` / `wp portal ls` | List `portals[]` and current `defaultPortal` |
|
|
173
|
+
| `wp portal use [name]` | `hs accounts use` — name or portalId; interactive if name omitted |
|
|
51
174
|
|
|
52
|
-
|
|
175
|
+
### Develop and sync
|
|
53
176
|
|
|
54
|
-
|
|
177
|
+
| Command | Description |
|
|
178
|
+
|---------|-------------|
|
|
179
|
+
| `wp dev` / `wp local` | Local Vite dev server + module-config UI |
|
|
180
|
+
| `wp watch [--rebuild] [--tier dev\|stg\|prod]` | `hs cms watch` on built module/theme output |
|
|
181
|
+
| `wp fields sync [--direction pull\|push]` | Sync `fields.json` with local cache |
|
|
55
182
|
|
|
56
|
-
|
|
183
|
+
### Build and deploy
|
|
57
184
|
|
|
58
|
-
|
|
185
|
+
| Command | Description |
|
|
186
|
+
|---------|-------------|
|
|
187
|
+
| `wp build [--tier] [--cdn-only] [--hubspot-only] [--cdn-esm]` | CDN + module (or theme no-op) |
|
|
188
|
+
| `wp publish [--tier] [--dry-run]` | Verify CDN endpoint and push jsDelivr mirror |
|
|
189
|
+
| `wp upload [--tier]` | `hs cms upload` using paths from `woodscli.json` |
|
|
190
|
+
| `wp deploy [--tier] [--skip-publish]` | Full pipeline: build → publish → upload |
|
|
191
|
+
|
|
192
|
+
### Quality and CI
|
|
193
|
+
|
|
194
|
+
| Command | Description |
|
|
195
|
+
|---------|-------------|
|
|
196
|
+
| `wp regression smoke [--skip-doctor]` | Config validate + consumer boundary checks |
|
|
197
|
+
| `wp examples list` | List scenarios from `examples/manifest.json` |
|
|
198
|
+
| `wp examples smoke [--scenario id] [--tier static\|live]` | Examples matrix (used in kit CI) |
|
|
199
|
+
| `wp audit ship-bundle` | Fail if dev-only strings appear in `dist/` |
|
|
200
|
+
| `wp audit parity [--baseline dir]` | Compare `dist/` to baseline snapshot |
|
|
201
|
+
| `wp audit baseline [--baseline dir]` | Capture parity baseline under `.wphs/` |
|
|
202
|
+
| `wp audit secrets` | Scan for hardcoded PATs / credentials |
|
|
203
|
+
|
|
204
|
+
Detailed flags and exit codes: [docs/CLI-REFERENCE.md](./docs/CLI-REFERENCE.md)
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Project layout
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
my-project/
|
|
212
|
+
├── woodscli.json # WoodsCLI project config (required)
|
|
213
|
+
├── hubspot.config.yml # HubSpot CLI portals (gitignored; from wp setup)
|
|
214
|
+
├── wphs.adapter.ts # Consumer adapter hook (modules)
|
|
215
|
+
├── vite.config.dev.mjs # Re-exports kit dev preset
|
|
216
|
+
├── vite.config.hubspot.mjs # or vite.config.monolith.mjs
|
|
217
|
+
├── .wphs/ # Local workspace (module-config, cache, audit)
|
|
218
|
+
├── src/ # App source
|
|
219
|
+
├── public/ # fields.json, module.html (modules)
|
|
220
|
+
└── dist/ # Build output (cdn + module.outDir)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| File / dir | Purpose |
|
|
224
|
+
|------------|---------|
|
|
225
|
+
| `woodscli.json` | `projectType`, module/theme paths, CDN mode, env tiers |
|
|
226
|
+
| `.wphs/` | Module-config overlay state, fixtures, audit baseline |
|
|
227
|
+
| `wphs.adapter.ts` | Bridge to your app (routing, API, HubSpot context) |
|
|
228
|
+
| `hubspot.config.yml` | Portal names, PATs, `defaultPortal` |
|
|
229
|
+
|
|
230
|
+
Config field reference: [docs/CONFIG-REFERENCE.md](./docs/CONFIG-REFERENCE.md)
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Documentation
|
|
235
|
+
|
|
236
|
+
| Doc | Topic |
|
|
237
|
+
|-----|--------|
|
|
238
|
+
| [GETTING-STARTED.md](./docs/GETTING-STARTED.md) | First-run walkthrough |
|
|
239
|
+
| [CLI-REFERENCE.md](./docs/CLI-REFERENCE.md) | All commands, flags, exit codes |
|
|
240
|
+
| [HUBSPOT-CLI-SETUP.md](./docs/HUBSPOT-CLI-SETUP.md) | PAT, auth, portals |
|
|
241
|
+
| [MODULES.md](./docs/MODULES.md) | Module build paths and overlay |
|
|
242
|
+
| [THEMES.md](./docs/THEMES.md) | Theme starter workflow |
|
|
243
|
+
| [BUILD-MODES.md](./docs/BUILD-MODES.md) | CDN vs monolith, tiers, prod guards |
|
|
244
|
+
| [ADAPTER.md](./docs/ADAPTER.md) | `wphs.adapter.ts` contract |
|
|
245
|
+
| [EXAMPLES.md](./docs/EXAMPLES.md) | Examples smoke matrix |
|
|
246
|
+
| [TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md) | Common failures |
|
|
247
|
+
| [RUNBOOK.md](./docs/RUNBOOK.md) | Ops and release notes |
|
|
248
|
+
| [CONTRIBUTING.md](./CONTRIBUTING.md) | PR and verify workflow |
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Develop the kit
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
git clone https://github.com/Digital-Woods/digitalwoods.io-woodsportal-hubspot-kit.git
|
|
256
|
+
cd digitalwoods.io-woodsportal-hubspot-kit
|
|
257
|
+
npm ci
|
|
258
|
+
npm run verify # typecheck + test + examples smoke + build
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Link locally in a consumer:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npm i -D @woodsportal/hubspot-kit@file:../digitalwoods.io-woodsportal-hubspot-kit
|
|
265
|
+
```
|
|
59
266
|
|
|
60
|
-
|
|
267
|
+
---
|
|
61
268
|
|
|
62
269
|
## License
|
|
63
270
|
|
|
64
|
-
MIT — Digital Woods
|
|
271
|
+
MIT — [Digital Woods](https://github.com/Digital-Woods)
|
|
@@ -95,14 +95,14 @@ function getKitRoot() {
|
|
|
95
95
|
return kitRoot;
|
|
96
96
|
}
|
|
97
97
|
function findProjectRoot2(from = process.cwd()) {
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
98
|
+
const resolved = findProjectRoot(from);
|
|
99
|
+
if (!resolved) {
|
|
100
100
|
throw new WpHsError("Could not find woodscli.json in this directory or any parent.", {
|
|
101
101
|
exitCode: ExitCode.USER_ERROR,
|
|
102
|
-
remediation: "Run wp init,
|
|
102
|
+
remediation: "Run wp init, or pass --project <path>. Legacy config: wp migrate --yes."
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
return
|
|
105
|
+
return resolved;
|
|
106
106
|
}
|
|
107
107
|
function kitPath(...segments) {
|
|
108
108
|
return resolve2(kitRoot, ...segments);
|
|
@@ -133,4 +133,4 @@ export {
|
|
|
133
133
|
getViteConfigPath,
|
|
134
134
|
createViteConfig
|
|
135
135
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-S2YJDWZU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/paths.ts","../src/lib/config-files.ts","../src/lib/errors.ts","../src/vite/paths.ts","../src/vite/create-vite-config.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { findProjectRoot as findConfigProjectRoot } from './config-files.js'\nimport { WpHsError, ExitCode } from './errors.js'\n\nconst KIT_PACKAGE_NAME = '@woodsportal/hubspot-kit'\n\nfunction resolveKitRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n while (true) {\n const pkgPath = resolve(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { name?: string }\n if (pkg.name === KIT_PACKAGE_NAME) {\n return dir\n }\n } catch {\n // keep walking\n }\n }\n const parent = dirname(dir)\n if (parent === dir) {\n break\n }\n dir = parent\n }\n\n throw new WpHsError('Could not resolve @woodsportal/hubspot-kit package root.', {\n exitCode: ExitCode.INTERNAL,\n })\n}\n\nconst kitRoot = resolveKitRoot()\n\nexport function getKitRoot(): string {\n return kitRoot\n}\n\nexport function findProjectRoot(from = process.cwd()): string {\n const resolved = findConfigProjectRoot(from)\n\n if (!resolved) {\n throw new WpHsError('Could not find woodscli.json in this directory or any parent.', {\n exitCode: ExitCode.USER_ERROR,\n remediation: 'Run wp init, or pass --project <path>. Legacy config: wp migrate --yes.',\n })\n }\n return resolved\n}\n\nexport function kitPath(...segments: string[]): string {\n return resolve(kitRoot, ...segments)\n}\n\nexport { resolveProjectConfig, WOODSCLI_CONFIG_FILE, LEGACY_WOODSPORTAL_HS_FILE } from './config-files.js'\n","import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\n/** Canonical WoodsCLI project config — the only supported filename. */\nexport const WOODSCLI_CONFIG_FILE = 'woodscli.json'\n\n/** Removed in v1.0.2+ — detected only for migrate/doctor messaging. */\nexport const LEGACY_WOODSPORTAL_HS_FILE = 'woodsportal.hs.json'\n\nexport type ResolvedProjectConfig = {\n path: string\n fileName: typeof WOODSCLI_CONFIG_FILE\n}\n\nfunction envConfigPath(projectRoot: string): string | null {\n const fromEnv = process.env.WOODSCLI_CONFIG?.trim() || process.env.WP_HS_CONFIG?.trim() || null\n if (!fromEnv) return null\n return resolve(projectRoot, fromEnv)\n}\n\nexport function legacyConfigPath(projectRoot: string): string {\n return resolve(projectRoot, LEGACY_WOODSPORTAL_HS_FILE)\n}\n\nexport function woodscliConfigPath(projectRoot: string): string {\n return resolve(projectRoot, WOODSCLI_CONFIG_FILE)\n}\n\n/** @returns null | 'legacy-only' | 'duplicate' */\nexport function legacyConfigConflict(projectRoot: string): 'legacy-only' | 'duplicate' | null {\n const hasWoodscli = existsSync(woodscliConfigPath(projectRoot))\n const hasLegacy = existsSync(legacyConfigPath(projectRoot))\n if (hasLegacy && hasWoodscli) return 'duplicate'\n if (hasLegacy && !hasWoodscli) return 'legacy-only'\n return null\n}\n\n/**\n * Resolve the active project config file (`woodscli.json` only).\n */\nexport function resolveProjectConfig(projectRoot: string): ResolvedProjectConfig | null {\n const envPath = envConfigPath(projectRoot)\n if (envPath) {\n if (!existsSync(envPath)) return null\n return { path: envPath, fileName: WOODSCLI_CONFIG_FILE }\n }\n\n const path = woodscliConfigPath(projectRoot)\n if (existsSync(path)) {\n return { path, fileName: WOODSCLI_CONFIG_FILE }\n }\n\n return null\n}\n\nexport function findProjectRoot(from = process.cwd()): string | null {\n if (process.env.WP_HS_PROJECT_ROOT?.trim()) {\n return resolve(process.env.WP_HS_PROJECT_ROOT.trim())\n }\n\n let dir = resolve(from)\n while (true) {\n if (resolveProjectConfig(dir)) {\n return dir\n }\n const parent = resolve(dir, '..')\n if (parent === dir) {\n return null\n }\n dir = parent\n }\n}\n","export const ExitCode = {\n SUCCESS: 0,\n USER_ERROR: 1,\n PREREQUISITE: 2,\n BUILD_FAILED: 3,\n PUBLISH_FAILED: 4,\n AUDIT_FAILED: 5,\n INTERNAL: 10,\n} as const\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode]\n\nexport class WpHsError extends Error {\n readonly exitCode: ExitCodeValue\n readonly remediation?: string\n\n constructor(\n message: string,\n options: { exitCode?: ExitCodeValue; remediation?: string; cause?: unknown } = {},\n ) {\n super(message, { cause: options.cause })\n this.name = 'WpHsError'\n this.exitCode = options.exitCode ?? ExitCode.USER_ERROR\n this.remediation = options.remediation\n }\n}\n\nexport function isWpHsError(error: unknown): error is WpHsError {\n return error instanceof WpHsError\n}\n","import { kitPath } from '../lib/paths.js'\n\nexport type VitePreset = 'dev' | 'hubspot' | 'cdn-vendor' | 'cdn-app' | 'cdn-esm'\n\nexport function getViteConfigPath(preset: VitePreset): string {\n return kitPath('vite', `vite.config.${preset}.mjs`)\n}\n","import { getViteConfigPath, type VitePreset } from './paths.js'\n\nexport type CreateViteConfigOptions = {\n /** Vite preset shipped with @woodsportal/hubspot-kit */\n preset: VitePreset\n /** Consumer project root (sets WP_HS_PROJECT_ROOT for kit scripts) */\n projectRoot?: string\n}\n\n/**\n * Returns the absolute path to a kit Vite config preset.\n * Consumer repos typically re-export: `export { default } from '@woodsportal/hubspot-kit/vite/vite.config.hubspot.mjs'`\n * or use this helper in a thin wrapper config.\n */\nexport function createViteConfig(\n presetOrOptions: VitePreset | CreateViteConfigOptions,\n): string {\n const options: CreateViteConfigOptions =\n typeof presetOrOptions === 'string' ? { preset: presetOrOptions } : presetOrOptions\n\n if (options.projectRoot?.trim()) {\n process.env.WP_HS_PROJECT_ROOT = options.projectRoot.trim()\n }\n\n return getViteConfigPath(options.preset)\n}\n"],"mappings":";AAAA,SAAS,cAAAA,aAAY,oBAAoB;AACzC,SAAS,SAAS,WAAAC,gBAAe;AACjC,SAAS,qBAAqB;;;ACF9B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AAGjB,IAAM,uBAAuB;AAUpC,SAAS,cAAc,aAAoC;AACzD,QAAM,UAAU,QAAQ,IAAI,iBAAiB,KAAK,KAAK,QAAQ,IAAI,cAAc,KAAK,KAAK;AAC3F,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,aAAa,OAAO;AACrC;AAMO,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,QAAQ,aAAa,oBAAoB;AAClD;AAcO,SAAS,qBAAqB,aAAmD;AACtF,QAAM,UAAU,cAAc,WAAW;AACzC,MAAI,SAAS;AACX,QAAI,CAAC,WAAW,OAAO,EAAG,QAAO;AACjC,WAAO,EAAE,MAAM,SAAS,UAAU,qBAAqB;AAAA,EACzD;AAEA,QAAM,OAAO,mBAAmB,WAAW;AAC3C,MAAI,WAAW,IAAI,GAAG;AACpB,WAAO,EAAE,MAAM,UAAU,qBAAqB;AAAA,EAChD;AAEA,SAAO;AACT;AAEO,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