@woodsportal/hubspot-kit 1.0.35 → 1.0.37
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 +12 -0
- package/dist/cli.js +142 -180
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
- package/scripts/resolve-consumer-dep.mjs +76 -11
- package/scripts/resolve-consumer-dep.test.mjs +22 -0
- package/scripts/run-dev.mjs +12 -90
- package/scripts/test-fixtures/consumer-dep/node_modules/@tanstack/router-plugin/dist/esm/vite.js +3 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/@tanstack/router-plugin/package.json +16 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/react/jsx-dev-runtime.js +1 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/react/jsx-runtime.js +1 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/react/package.json +8 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/vite/dist/node/index.js +1 -0
- package/scripts/test-fixtures/consumer-dep/node_modules/vite/package.json +10 -0
- package/scripts/test-fixtures/consumer-dep-fixture-root.mjs +8 -0
- package/scripts/vite/consumer-react-aliases.js +28 -0
- package/scripts/vite/consumer-react-aliases.test.mjs +12 -0
- package/scripts/vite/create-dev-server-config.mjs +114 -0
- package/scripts/vite/resolve-from-project-root.js +16 -8
- package/vite/vite.config.dev.mjs +2 -106
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
// src/cli/program.ts
|
|
14
14
|
import { readFileSync as readFileSync16 } from "fs";
|
|
15
|
-
import { resolve as
|
|
15
|
+
import { resolve as resolve23 } from "path";
|
|
16
16
|
import { Command } from "commander";
|
|
17
17
|
|
|
18
18
|
// src/lib/config.ts
|
|
@@ -321,11 +321,11 @@ function isVerboseStepLog(ctx) {
|
|
|
321
321
|
return ctx.global.verbose === true && !ctx.global.quiet && !ctx.global.json;
|
|
322
322
|
}
|
|
323
323
|
async function yieldForSpinnerPaint() {
|
|
324
|
-
await new Promise((
|
|
325
|
-
setImmediate(
|
|
324
|
+
await new Promise((resolve24) => {
|
|
325
|
+
setImmediate(resolve24);
|
|
326
326
|
});
|
|
327
|
-
await new Promise((
|
|
328
|
-
setTimeout(
|
|
327
|
+
await new Promise((resolve24) => {
|
|
328
|
+
setTimeout(resolve24, 48);
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
async function runCliTasks(ctx, tasks, options = {}) {
|
|
@@ -801,15 +801,7 @@ function isUploadOnlyPreexistingProject(projectRoot, moduleArtifactDirs) {
|
|
|
801
801
|
import { existsSync as existsSync6 } from "fs";
|
|
802
802
|
import { platform } from "os";
|
|
803
803
|
import { resolve as resolve7 } from "path";
|
|
804
|
-
var CONSUMER_DEV_CONFIG = "vite.config.dev.mjs";
|
|
805
804
|
var VITE_JS_SEGMENTS = ["node_modules", "vite", "bin", "vite.js"];
|
|
806
|
-
function resolveDevViteConfigPath(projectRoot) {
|
|
807
|
-
const consumerConfig = resolve7(projectRoot, CONSUMER_DEV_CONFIG);
|
|
808
|
-
if (existsSync6(consumerConfig)) {
|
|
809
|
-
return consumerConfig;
|
|
810
|
-
}
|
|
811
|
-
return kitPath("vite", "vite.config.dev.mjs");
|
|
812
|
-
}
|
|
813
805
|
function isProjectViteInstalled(projectRoot) {
|
|
814
806
|
return existsSync6(resolve7(projectRoot, ...VITE_JS_SEGMENTS));
|
|
815
807
|
}
|
|
@@ -831,9 +823,6 @@ function resolveProjectViteSpawn(projectRoot) {
|
|
|
831
823
|
}
|
|
832
824
|
return null;
|
|
833
825
|
}
|
|
834
|
-
function formatProjectViteSpawn(spawn2) {
|
|
835
|
-
return [spawn2.command, ...spawn2.prefixArgs].join(" ");
|
|
836
|
-
}
|
|
837
826
|
|
|
838
827
|
// src/lib/node-loader-interop.ts
|
|
839
828
|
var NODE_LTS_RECOMMENDED = "24";
|
|
@@ -1915,9 +1904,6 @@ async function runBuild(ctx, options) {
|
|
|
1915
1904
|
}
|
|
1916
1905
|
|
|
1917
1906
|
// src/cli/commands/dev.ts
|
|
1918
|
-
import { existsSync as existsSync8 } from "fs";
|
|
1919
|
-
import { resolve as resolve11 } from "path";
|
|
1920
|
-
import { spawn } from "child_process";
|
|
1921
1907
|
async function runDev(ctx, options) {
|
|
1922
1908
|
const port = options.port ?? 3e3;
|
|
1923
1909
|
const nodeWarning = nodeLoaderInteropWarning();
|
|
@@ -1926,64 +1912,40 @@ async function runDev(ctx, options) {
|
|
|
1926
1912
|
}
|
|
1927
1913
|
const env = {
|
|
1928
1914
|
...process.env,
|
|
1929
|
-
WP_HS_PROJECT_ROOT: ctx.projectRoot
|
|
1915
|
+
WP_HS_PROJECT_ROOT: ctx.projectRoot,
|
|
1916
|
+
WP_HS_DEV_PORT: String(port)
|
|
1930
1917
|
};
|
|
1931
|
-
const configPath = resolveDevViteConfigPath(ctx.projectRoot);
|
|
1932
|
-
const viteSpawn = resolveProjectViteSpawn(ctx.projectRoot);
|
|
1933
1918
|
if (ctx.global.dryRun) {
|
|
1934
|
-
|
|
1935
|
-
ctx.logger.info(`[dry-run] ${dryRunTarget} --config ${configPath} --port ${port}`);
|
|
1919
|
+
ctx.logger.info(`[dry-run] node ${kitPath("scripts", "run-dev.mjs")} (port ${port})`);
|
|
1936
1920
|
return ExitCode.SUCCESS;
|
|
1937
1921
|
}
|
|
1938
|
-
if (!
|
|
1922
|
+
if (!resolveProjectViteSpawn(ctx.projectRoot)) {
|
|
1939
1923
|
throw new WpHsError("vite is not installed in this project.", {
|
|
1940
1924
|
exitCode: ExitCode.PREREQUISITE,
|
|
1941
1925
|
remediation: "Run yarn install or npm install. If this is an older wp init project, add vite and peers to devDependencies (run wp init again or see @woodsportal/hubspot-kit templates)."
|
|
1942
1926
|
});
|
|
1943
1927
|
}
|
|
1944
|
-
const consumerConfig = resolve11(ctx.projectRoot, "vite.config.dev.mjs");
|
|
1945
|
-
if (!existsSync8(consumerConfig)) {
|
|
1946
|
-
throw new WpHsError("vite.config.dev.mjs is missing in the project root.", {
|
|
1947
|
-
exitCode: ExitCode.USER_ERROR,
|
|
1948
|
-
remediation: "Add vite.config.dev.mjs (see @woodsportal/hubspot-kit templates/module-hybrid-cdn)."
|
|
1949
|
-
});
|
|
1950
|
-
}
|
|
1951
1928
|
printWoodsCliDevBanner({
|
|
1952
1929
|
config: ctx.config,
|
|
1953
1930
|
port,
|
|
1954
1931
|
global: ctx.global
|
|
1955
1932
|
});
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
"--port",
|
|
1964
|
-
String(port),
|
|
1965
|
-
"--mode",
|
|
1966
|
-
"dev"
|
|
1967
|
-
],
|
|
1968
|
-
{
|
|
1969
|
-
cwd: ctx.projectRoot,
|
|
1970
|
-
env,
|
|
1971
|
-
stdio: "inherit"
|
|
1972
|
-
}
|
|
1973
|
-
);
|
|
1974
|
-
setImmediate(() => ensureHubSpotCliSetup(ctx, "local"));
|
|
1975
|
-
child.on("exit", (code) => {
|
|
1976
|
-
resolvePromise(code ?? ExitCode.USER_ERROR);
|
|
1977
|
-
});
|
|
1933
|
+
setImmediate(() => ensureHubSpotCliSetup(ctx, "local"));
|
|
1934
|
+
return runNodeScriptLongRunning(kitPath("scripts", "run-dev.mjs"), [], {
|
|
1935
|
+
cwd: ctx.projectRoot,
|
|
1936
|
+
env,
|
|
1937
|
+
logger: ctx.logger,
|
|
1938
|
+
dryRun: false,
|
|
1939
|
+
projectRoot: ctx.projectRoot
|
|
1978
1940
|
});
|
|
1979
1941
|
}
|
|
1980
1942
|
|
|
1981
1943
|
// src/cli/commands/deploy.ts
|
|
1982
|
-
import { resolve as
|
|
1944
|
+
import { resolve as resolve13 } from "path";
|
|
1983
1945
|
|
|
1984
1946
|
// src/lib/project-env-files.ts
|
|
1985
|
-
import { existsSync as
|
|
1986
|
-
import { resolve as
|
|
1947
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
|
|
1948
|
+
import { resolve as resolve11 } from "path";
|
|
1987
1949
|
var ENV_LOCAL_FILE = ".env.local";
|
|
1988
1950
|
var ENV_GITIGNORE_LINES = [".env", ".env.*", "!.env*.example", ENV_LOCAL_FILE];
|
|
1989
1951
|
function parseEnvFile(content) {
|
|
@@ -2003,8 +1965,8 @@ function parseEnvFile(content) {
|
|
|
2003
1965
|
return result;
|
|
2004
1966
|
}
|
|
2005
1967
|
function readEnvLocal(projectRoot) {
|
|
2006
|
-
const path =
|
|
2007
|
-
if (!
|
|
1968
|
+
const path = resolve11(projectRoot, ENV_LOCAL_FILE);
|
|
1969
|
+
if (!existsSync8(path)) return {};
|
|
2008
1970
|
return parseEnvFile(readFileSync7(path, "utf8"));
|
|
2009
1971
|
}
|
|
2010
1972
|
function formatEnvLocal(entries) {
|
|
@@ -2024,8 +1986,8 @@ function formatEnvLocal(entries) {
|
|
|
2024
1986
|
`;
|
|
2025
1987
|
}
|
|
2026
1988
|
function writeEnvLocal(projectRoot, entries) {
|
|
2027
|
-
const path =
|
|
2028
|
-
const existing =
|
|
1989
|
+
const path = resolve11(projectRoot, ENV_LOCAL_FILE);
|
|
1990
|
+
const existing = existsSync8(path) ? parseEnvFile(readFileSync7(path, "utf8")) : {};
|
|
2029
1991
|
writeFileSync2(path, formatEnvLocal({ ...existing, ...entries }));
|
|
2030
1992
|
}
|
|
2031
1993
|
function mergeProjectEnv(projectRoot, base = process.env) {
|
|
@@ -2039,8 +2001,8 @@ function mergeProjectEnv(projectRoot, base = process.env) {
|
|
|
2039
2001
|
return merged;
|
|
2040
2002
|
}
|
|
2041
2003
|
function ensureEnvFilesGitignore(projectRoot) {
|
|
2042
|
-
const gitignorePath =
|
|
2043
|
-
const existing =
|
|
2004
|
+
const gitignorePath = resolve11(projectRoot, ".gitignore");
|
|
2005
|
+
const existing = existsSync8(gitignorePath) ? readFileSync7(gitignorePath, "utf8") : "";
|
|
2044
2006
|
const toAppend = ENV_GITIGNORE_LINES.filter((line) => !existing.includes(line)).join("\n");
|
|
2045
2007
|
if (!toAppend) return;
|
|
2046
2008
|
writeFileSync2(gitignorePath, `${existing.trimEnd()}
|
|
@@ -2051,14 +2013,14 @@ ${toAppend}
|
|
|
2051
2013
|
}
|
|
2052
2014
|
|
|
2053
2015
|
// src/cli/commands/upload.ts
|
|
2054
|
-
import { resolve as
|
|
2016
|
+
import { resolve as resolve12 } from "path";
|
|
2055
2017
|
async function uploadModuleOrTheme(ctx) {
|
|
2056
2018
|
if (isThemeProject(ctx.config)) {
|
|
2057
2019
|
const theme = ctx.config.theme;
|
|
2058
2020
|
if (!theme) {
|
|
2059
2021
|
throw new WpHsError("theme block missing in woodscli.json", { exitCode: ExitCode.USER_ERROR });
|
|
2060
2022
|
}
|
|
2061
|
-
const srcDir =
|
|
2023
|
+
const srcDir = resolve12(ctx.projectRoot, theme.srcDir);
|
|
2062
2024
|
await runCommandAsync("hs", ["cms", "upload", srcDir, theme.uploadPath], {
|
|
2063
2025
|
cwd: ctx.projectRoot,
|
|
2064
2026
|
projectRoot: ctx.projectRoot,
|
|
@@ -2068,7 +2030,7 @@ async function uploadModuleOrTheme(ctx) {
|
|
|
2068
2030
|
});
|
|
2069
2031
|
return `Uploaded theme ${srcDir} \u2192 ${theme.uploadPath}`;
|
|
2070
2032
|
}
|
|
2071
|
-
const outDir =
|
|
2033
|
+
const outDir = resolve12(ctx.projectRoot, ctx.config.module.outDir);
|
|
2072
2034
|
const uploadPath = ctx.config.module.uploadPath;
|
|
2073
2035
|
await runCommandAsync("hs", ["cms", "upload", outDir, uploadPath], {
|
|
2074
2036
|
cwd: ctx.projectRoot,
|
|
@@ -2236,7 +2198,7 @@ async function runDeploy(ctx, options) {
|
|
|
2236
2198
|
if (!ctx.global.json) {
|
|
2237
2199
|
printCommandDone(
|
|
2238
2200
|
ctx,
|
|
2239
|
-
`Deploy complete (${
|
|
2201
|
+
`Deploy complete (${resolve13(ctx.projectRoot, ctx.config.module.outDir)} \u2192 ${ctx.config.module.uploadPath})`
|
|
2240
2202
|
);
|
|
2241
2203
|
}
|
|
2242
2204
|
return ExitCode.SUCCESS;
|
|
@@ -2309,8 +2271,8 @@ async function runPublish(ctx, options) {
|
|
|
2309
2271
|
|
|
2310
2272
|
// src/cli/commands/audit.ts
|
|
2311
2273
|
import { createHash } from "crypto";
|
|
2312
|
-
import { cpSync, existsSync as
|
|
2313
|
-
import { resolve as
|
|
2274
|
+
import { cpSync, existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync8, readdirSync, rmSync, statSync } from "fs";
|
|
2275
|
+
import { resolve as resolve14, join as join2 } from "path";
|
|
2314
2276
|
var FORBIDDEN_SHIP_TOKENS = [
|
|
2315
2277
|
"ModuleConfigOverlay",
|
|
2316
2278
|
"module-config-store",
|
|
@@ -2322,7 +2284,7 @@ function hashFile(path) {
|
|
|
2322
2284
|
return createHash("sha256").update(readFileSync8(path)).digest("hex");
|
|
2323
2285
|
}
|
|
2324
2286
|
function walkFiles(dir) {
|
|
2325
|
-
if (!
|
|
2287
|
+
if (!existsSync9(dir)) return [];
|
|
2326
2288
|
const entries = readdirSync(dir);
|
|
2327
2289
|
const files = [];
|
|
2328
2290
|
for (const entry of entries) {
|
|
@@ -2338,8 +2300,8 @@ function walkFiles(dir) {
|
|
|
2338
2300
|
async function runAuditShipBundle(ctx) {
|
|
2339
2301
|
const root = ctx.projectRoot;
|
|
2340
2302
|
const targets = [
|
|
2341
|
-
|
|
2342
|
-
|
|
2303
|
+
resolve14(root, "dist/cdn"),
|
|
2304
|
+
resolve14(root, ctx.config.module.outDir)
|
|
2343
2305
|
];
|
|
2344
2306
|
const violations = [];
|
|
2345
2307
|
for (const dir of targets) {
|
|
@@ -2372,21 +2334,21 @@ async function runAuditBaselineCapture(ctx, options) {
|
|
|
2372
2334
|
const root = ctx.projectRoot;
|
|
2373
2335
|
const baseline = options.baselineDir ?? defaultBaselineDir(root, ctx.config);
|
|
2374
2336
|
const sources = [
|
|
2375
|
-
{ label: "cdn", path:
|
|
2376
|
-
{ label: "hubspot", path:
|
|
2337
|
+
{ label: "cdn", path: resolve14(root, "dist/cdn") },
|
|
2338
|
+
{ label: "hubspot", path: resolve14(root, ctx.config.module.outDir) }
|
|
2377
2339
|
];
|
|
2378
2340
|
if (ctx.global.dryRun) {
|
|
2379
2341
|
ctx.logger.info(`[dry-run] Would capture baseline to ${baseline}`);
|
|
2380
2342
|
return ExitCode.SUCCESS;
|
|
2381
2343
|
}
|
|
2382
2344
|
for (const { label, path } of sources) {
|
|
2383
|
-
if (!
|
|
2345
|
+
if (!existsSync9(path)) {
|
|
2384
2346
|
throw new WpHsError(`Cannot capture baseline \u2014 missing ${path}`, {
|
|
2385
2347
|
exitCode: ExitCode.USER_ERROR,
|
|
2386
2348
|
remediation: "Run wp build before wp audit baseline --capture."
|
|
2387
2349
|
});
|
|
2388
2350
|
}
|
|
2389
|
-
const target =
|
|
2351
|
+
const target = resolve14(baseline, label);
|
|
2390
2352
|
rmSync(target, { recursive: true, force: true });
|
|
2391
2353
|
mkdirSync2(baseline, { recursive: true });
|
|
2392
2354
|
cpSync(path, target, { recursive: true });
|
|
@@ -2402,13 +2364,13 @@ async function runAuditParity(ctx, options) {
|
|
|
2402
2364
|
const root = ctx.projectRoot;
|
|
2403
2365
|
const baseline = options.baselineDir ?? defaultBaselineDir(root, ctx.config);
|
|
2404
2366
|
const currentDirs = [
|
|
2405
|
-
{ label: "cdn", path:
|
|
2406
|
-
{ label: "hubspot", path:
|
|
2367
|
+
{ label: "cdn", path: resolve14(root, "dist/cdn") },
|
|
2368
|
+
{ label: "hubspot", path: resolve14(root, ctx.config.module.outDir) }
|
|
2407
2369
|
];
|
|
2408
2370
|
const mismatches = [];
|
|
2409
2371
|
for (const { label, path } of currentDirs) {
|
|
2410
|
-
const baselinePath =
|
|
2411
|
-
if (!
|
|
2372
|
+
const baselinePath = resolve14(baseline, label);
|
|
2373
|
+
if (!existsSync9(baselinePath)) {
|
|
2412
2374
|
ctx.logger.warn(`No baseline at ${baselinePath} \u2014 skipping ${label} parity`);
|
|
2413
2375
|
continue;
|
|
2414
2376
|
}
|
|
@@ -2423,8 +2385,8 @@ async function runAuditParity(ctx, options) {
|
|
|
2423
2385
|
}
|
|
2424
2386
|
for (const file of baselineFiles) {
|
|
2425
2387
|
const rel = file.replace(baselinePath, "");
|
|
2426
|
-
const current =
|
|
2427
|
-
if (!
|
|
2388
|
+
const current = resolve14(path, rel.slice(1));
|
|
2389
|
+
if (!existsSync9(current)) continue;
|
|
2428
2390
|
const bh = hashFile(file);
|
|
2429
2391
|
const ch = hashFile(current);
|
|
2430
2392
|
if (bh !== ch) {
|
|
@@ -2451,7 +2413,7 @@ var SECRET_PATTERNS = [
|
|
|
2451
2413
|
];
|
|
2452
2414
|
async function runAuditSecrets(ctx) {
|
|
2453
2415
|
const root = ctx.projectRoot;
|
|
2454
|
-
const scanRoots = ["src", "public", ".wphs/config"].map((d) =>
|
|
2416
|
+
const scanRoots = ["src", "public", ".wphs/config"].map((d) => resolve14(root, d));
|
|
2455
2417
|
const findings = [];
|
|
2456
2418
|
for (const dir of scanRoots) {
|
|
2457
2419
|
for (const file of walkFiles(dir)) {
|
|
@@ -2483,13 +2445,13 @@ async function runAuditSecrets(ctx) {
|
|
|
2483
2445
|
}
|
|
2484
2446
|
|
|
2485
2447
|
// src/cli/commands/init.ts
|
|
2486
|
-
import { cpSync as cpSync2, existsSync as
|
|
2487
|
-
import { basename as basename2, resolve as
|
|
2448
|
+
import { cpSync as cpSync2, existsSync as existsSync13, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
|
|
2449
|
+
import { basename as basename2, resolve as resolve18 } from "path";
|
|
2488
2450
|
import * as p4 from "@clack/prompts";
|
|
2489
2451
|
|
|
2490
2452
|
// src/lib/init-router-scaffold.ts
|
|
2491
|
-
import { existsSync as
|
|
2492
|
-
import { resolve as
|
|
2453
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync9, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2454
|
+
import { resolve as resolve15 } from "path";
|
|
2493
2455
|
var ROUTER_FILES = [
|
|
2494
2456
|
"src/routes",
|
|
2495
2457
|
"src/routeTree.gen.ts",
|
|
@@ -2503,10 +2465,10 @@ function isModuleTemplate(template) {
|
|
|
2503
2465
|
return template === "module-hybrid-cdn" || template === "module-monolith";
|
|
2504
2466
|
}
|
|
2505
2467
|
function writeRouterConfig(targetDir, mode) {
|
|
2506
|
-
const configDir =
|
|
2468
|
+
const configDir = resolve15(targetDir, "src/config");
|
|
2507
2469
|
mkdirSync3(configDir, { recursive: true });
|
|
2508
2470
|
writeFileSync3(
|
|
2509
|
-
|
|
2471
|
+
resolve15(configDir, "router.ts"),
|
|
2510
2472
|
`/** Router history \u2014 set by \`wp init\`. Hash matches woodsportal-client-frontend (HubSpot CMS embeds). */
|
|
2511
2473
|
export type RouterHistoryMode = 'hash' | 'browser'
|
|
2512
2474
|
|
|
@@ -2516,7 +2478,7 @@ export const ROUTER_HISTORY: RouterHistoryMode = '${mode}'
|
|
|
2516
2478
|
}
|
|
2517
2479
|
function writeMountDevPreviewRouter(targetDir) {
|
|
2518
2480
|
writeFileSync3(
|
|
2519
|
-
|
|
2481
|
+
resolve15(targetDir, "src/portal/mount-dev-preview.tsx"),
|
|
2520
2482
|
`import { mountGreenfieldDev } from '../../.wphs/.kit-bootstrap-greenfield.tsx'
|
|
2521
2483
|
|
|
2522
2484
|
import { App } from '@/app'
|
|
@@ -2530,7 +2492,7 @@ export async function mountDevPreview() {
|
|
|
2530
2492
|
}
|
|
2531
2493
|
function writeMountDevPreviewSinglePage(targetDir) {
|
|
2532
2494
|
writeFileSync3(
|
|
2533
|
-
|
|
2495
|
+
resolve15(targetDir, "src/portal/mount-dev-preview.tsx"),
|
|
2534
2496
|
`import { mountGreenfieldDev } from '../../.wphs/.kit-bootstrap-greenfield.tsx'
|
|
2535
2497
|
|
|
2536
2498
|
import { StarterSinglePage } from '@/features/starter'
|
|
@@ -2544,7 +2506,7 @@ export async function mountDevPreview() {
|
|
|
2544
2506
|
}
|
|
2545
2507
|
function writeMountPortalRouter(targetDir) {
|
|
2546
2508
|
writeFileSync3(
|
|
2547
|
-
|
|
2509
|
+
resolve15(targetDir, "src/portal/mount-portal.tsx"),
|
|
2548
2510
|
`import ReactDOM from 'react-dom/client'
|
|
2549
2511
|
|
|
2550
2512
|
import { App } from '@/app'
|
|
@@ -2562,7 +2524,7 @@ export async function mountPortal() {
|
|
|
2562
2524
|
}
|
|
2563
2525
|
function writeMountPortalSinglePage(targetDir) {
|
|
2564
2526
|
writeFileSync3(
|
|
2565
|
-
|
|
2527
|
+
resolve15(targetDir, "src/portal/mount-portal.tsx"),
|
|
2566
2528
|
`import ReactDOM from 'react-dom/client'
|
|
2567
2529
|
|
|
2568
2530
|
import { StarterSinglePage } from '@/features/starter'
|
|
@@ -2579,8 +2541,8 @@ export async function mountPortal() {
|
|
|
2579
2541
|
);
|
|
2580
2542
|
}
|
|
2581
2543
|
function writeStarterSinglePage(targetDir) {
|
|
2582
|
-
const file =
|
|
2583
|
-
if (
|
|
2544
|
+
const file = resolve15(targetDir, "src/features/starter/components/starter-single-page.tsx");
|
|
2545
|
+
if (existsSync10(file)) {
|
|
2584
2546
|
return;
|
|
2585
2547
|
}
|
|
2586
2548
|
writeFileSync3(
|
|
@@ -2606,15 +2568,15 @@ export function StarterSinglePage() {
|
|
|
2606
2568
|
);
|
|
2607
2569
|
}
|
|
2608
2570
|
function removePath(targetDir, relativePath) {
|
|
2609
|
-
const full =
|
|
2610
|
-
if (!
|
|
2571
|
+
const full = resolve15(targetDir, relativePath);
|
|
2572
|
+
if (!existsSync10(full)) {
|
|
2611
2573
|
return;
|
|
2612
2574
|
}
|
|
2613
2575
|
rmSync2(full, { recursive: true, force: true });
|
|
2614
2576
|
}
|
|
2615
2577
|
function stripTanStackFromPackage(targetDir) {
|
|
2616
|
-
const pkgPath =
|
|
2617
|
-
if (!
|
|
2578
|
+
const pkgPath = resolve15(targetDir, "package.json");
|
|
2579
|
+
if (!existsSync10(pkgPath)) {
|
|
2618
2580
|
return;
|
|
2619
2581
|
}
|
|
2620
2582
|
const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
|
|
@@ -2644,8 +2606,8 @@ function applyRouterScaffold(targetDir, mode, template) {
|
|
|
2644
2606
|
writeRouterConfig(targetDir, mode);
|
|
2645
2607
|
writeMountDevPreviewRouter(targetDir);
|
|
2646
2608
|
writeMountPortalRouter(targetDir);
|
|
2647
|
-
const featuresIndex =
|
|
2648
|
-
if (
|
|
2609
|
+
const featuresIndex = resolve15(targetDir, "src/features/starter/index.ts");
|
|
2610
|
+
if (existsSync10(featuresIndex)) {
|
|
2649
2611
|
let content = readFileSync9(featuresIndex, "utf8");
|
|
2650
2612
|
if (!content.includes("StarterSinglePage")) {
|
|
2651
2613
|
content = content.replace(
|
|
@@ -2658,15 +2620,15 @@ function applyRouterScaffold(targetDir, mode, template) {
|
|
|
2658
2620
|
}
|
|
2659
2621
|
|
|
2660
2622
|
// src/lib/cdn-github-setup.ts
|
|
2661
|
-
import { existsSync as
|
|
2662
|
-
import { resolve as
|
|
2623
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync4 } from "fs";
|
|
2624
|
+
import { resolve as resolve16 } from "path";
|
|
2663
2625
|
import * as p3 from "@clack/prompts";
|
|
2664
2626
|
var PORTAL_CDN_PUBLISH_TOKEN_ENV = "PORTAL_CDN_PUBLISH_TOKEN";
|
|
2665
2627
|
var PORTAL_CDN_JSON = "portal.cdn.json";
|
|
2666
2628
|
var PLACEHOLDER_GITHUB = /your-org|your-portal-cdn-mirror/i;
|
|
2667
2629
|
function defaultPortalCdnJson() {
|
|
2668
2630
|
const examplePath = kitPath("templates", "shared", "portal.cdn.json.example");
|
|
2669
|
-
if (
|
|
2631
|
+
if (existsSync11(examplePath)) {
|
|
2670
2632
|
return JSON.parse(readFileSync10(examplePath, "utf8"));
|
|
2671
2633
|
}
|
|
2672
2634
|
return {
|
|
@@ -2678,8 +2640,8 @@ function defaultPortalCdnJson() {
|
|
|
2678
2640
|
};
|
|
2679
2641
|
}
|
|
2680
2642
|
function readPortalCdnJson(projectRoot) {
|
|
2681
|
-
const path =
|
|
2682
|
-
if (!
|
|
2643
|
+
const path = resolve16(projectRoot, PORTAL_CDN_JSON);
|
|
2644
|
+
if (!existsSync11(path)) return null;
|
|
2683
2645
|
try {
|
|
2684
2646
|
return JSON.parse(readFileSync10(path, "utf8"));
|
|
2685
2647
|
} catch {
|
|
@@ -2728,7 +2690,7 @@ function needsCdnGitHubSetup(projectRoot) {
|
|
|
2728
2690
|
function applyCdnGitHubSetup(projectRoot, input) {
|
|
2729
2691
|
const existing = readPortalCdnJson(projectRoot) ?? defaultPortalCdnJson();
|
|
2730
2692
|
const updated = portalCdnJsonFromGithub(input.github, existing);
|
|
2731
|
-
writeFileSync4(
|
|
2693
|
+
writeFileSync4(resolve16(projectRoot, PORTAL_CDN_JSON), `${JSON.stringify(updated, null, 2)}
|
|
2732
2694
|
`);
|
|
2733
2695
|
if (input.token?.trim()) {
|
|
2734
2696
|
writeEnvLocal(projectRoot, { [PORTAL_CDN_PUBLISH_TOKEN_ENV]: input.token.trim() });
|
|
@@ -2777,8 +2739,8 @@ function formatCdnSetupNote(_projectRoot) {
|
|
|
2777
2739
|
}
|
|
2778
2740
|
|
|
2779
2741
|
// src/lib/project-setup.ts
|
|
2780
|
-
import { copyFileSync, existsSync as
|
|
2781
|
-
import { basename, resolve as
|
|
2742
|
+
import { copyFileSync, existsSync as existsSync12, writeFileSync as writeFileSync5 } from "fs";
|
|
2743
|
+
import { basename, resolve as resolve17 } from "path";
|
|
2782
2744
|
function envFileForTier(tier) {
|
|
2783
2745
|
return tier === "dev" ? ".env.dev" : tier === "stg" ? ".env.stg" : ".env.prod";
|
|
2784
2746
|
}
|
|
@@ -2788,13 +2750,13 @@ function tiersToSetup(config, tier) {
|
|
|
2788
2750
|
}
|
|
2789
2751
|
function firstExisting(paths) {
|
|
2790
2752
|
for (const path of paths) {
|
|
2791
|
-
if (
|
|
2753
|
+
if (existsSync12(path)) return path;
|
|
2792
2754
|
}
|
|
2793
2755
|
return null;
|
|
2794
2756
|
}
|
|
2795
2757
|
function copyMissingFile(projectRoot, targetName, sourceCandidates, dryRun) {
|
|
2796
|
-
const target =
|
|
2797
|
-
if (
|
|
2758
|
+
const target = resolve17(projectRoot, targetName);
|
|
2759
|
+
if (existsSync12(target)) {
|
|
2798
2760
|
return { action: "skipped", path: targetName, detail: "already present" };
|
|
2799
2761
|
}
|
|
2800
2762
|
const source = firstExisting(sourceCandidates);
|
|
@@ -2816,8 +2778,8 @@ function copyMissingFile(projectRoot, targetName, sourceCandidates, dryRun) {
|
|
|
2816
2778
|
};
|
|
2817
2779
|
}
|
|
2818
2780
|
function writeMissingFile(projectRoot, targetName, content, dryRun) {
|
|
2819
|
-
const target =
|
|
2820
|
-
if (
|
|
2781
|
+
const target = resolve17(projectRoot, targetName);
|
|
2782
|
+
if (existsSync12(target)) {
|
|
2821
2783
|
return { action: "skipped", path: targetName, detail: "already present" };
|
|
2822
2784
|
}
|
|
2823
2785
|
if (!dryRun) {
|
|
@@ -2847,8 +2809,8 @@ function applyProjectSetup(ctx, options = {}) {
|
|
|
2847
2809
|
const templateDir = kitTemplateDir(config);
|
|
2848
2810
|
results.push(
|
|
2849
2811
|
copyMissingFile(projectRoot, HUBSPOT_CONFIG_FILE, [
|
|
2850
|
-
|
|
2851
|
-
|
|
2812
|
+
resolve17(projectRoot, HUBSPOT_CONFIG_EXAMPLE),
|
|
2813
|
+
resolve17(templateDir, HUBSPOT_CONFIG_EXAMPLE),
|
|
2852
2814
|
kitPath("templates", HUBSPOT_CONFIG_EXAMPLE)
|
|
2853
2815
|
], dryRun)
|
|
2854
2816
|
);
|
|
@@ -2857,8 +2819,8 @@ function applyProjectSetup(ctx, options = {}) {
|
|
|
2857
2819
|
const envExample = `${envFile}.example`;
|
|
2858
2820
|
results.push(
|
|
2859
2821
|
copyMissingFile(projectRoot, envFile, [
|
|
2860
|
-
|
|
2861
|
-
|
|
2822
|
+
resolve17(projectRoot, envExample),
|
|
2823
|
+
resolve17(sharedDir, envExample)
|
|
2862
2824
|
], dryRun)
|
|
2863
2825
|
);
|
|
2864
2826
|
}
|
|
@@ -2866,8 +2828,8 @@ function applyProjectSetup(ctx, options = {}) {
|
|
|
2866
2828
|
const mirror = config.cdn.mirror;
|
|
2867
2829
|
results.push(
|
|
2868
2830
|
copyMissingFile(projectRoot, mirror, [
|
|
2869
|
-
|
|
2870
|
-
|
|
2831
|
+
resolve17(projectRoot, `${mirror}.example`),
|
|
2832
|
+
resolve17(sharedDir, "portal.cdn.json.example")
|
|
2871
2833
|
], dryRun)
|
|
2872
2834
|
);
|
|
2873
2835
|
const buildIdFile = config.cdn.buildIdFile;
|
|
@@ -2882,15 +2844,15 @@ function applyProjectSetup(ctx, options = {}) {
|
|
|
2882
2844
|
}
|
|
2883
2845
|
for (const file of templateViteFiles(config)) {
|
|
2884
2846
|
results.push(
|
|
2885
|
-
copyMissingFile(projectRoot, file, [
|
|
2847
|
+
copyMissingFile(projectRoot, file, [resolve17(templateDir, file)], dryRun)
|
|
2886
2848
|
);
|
|
2887
2849
|
}
|
|
2888
2850
|
if (isModuleProject(config) && !isThemeProject(config)) {
|
|
2889
2851
|
const adapter = config.dev.adapter;
|
|
2890
|
-
const adapterPath =
|
|
2891
|
-
if (!
|
|
2892
|
-
const templateAdapter =
|
|
2893
|
-
if (
|
|
2852
|
+
const adapterPath = resolve17(projectRoot, adapter);
|
|
2853
|
+
if (!existsSync12(adapterPath)) {
|
|
2854
|
+
const templateAdapter = resolve17(templateDir, "wphs.adapter.ts");
|
|
2855
|
+
if (existsSync12(templateAdapter)) {
|
|
2894
2856
|
results.push(copyMissingFile(projectRoot, adapter, [templateAdapter], dryRun));
|
|
2895
2857
|
} else {
|
|
2896
2858
|
results.push({
|
|
@@ -2907,26 +2869,26 @@ function applyProjectSetup(ctx, options = {}) {
|
|
|
2907
2869
|
}
|
|
2908
2870
|
function copySharedSetupExamples(targetDir) {
|
|
2909
2871
|
const sharedDir = kitPath("templates", "shared");
|
|
2910
|
-
if (!
|
|
2872
|
+
if (!existsSync12(sharedDir)) return;
|
|
2911
2873
|
for (const name of [
|
|
2912
2874
|
".env.dev.example",
|
|
2913
2875
|
".env.stg.example",
|
|
2914
2876
|
".env.prod.example",
|
|
2915
2877
|
"portal.cdn.json.example"
|
|
2916
2878
|
]) {
|
|
2917
|
-
const src =
|
|
2918
|
-
const dest =
|
|
2919
|
-
if (
|
|
2879
|
+
const src = resolve17(sharedDir, name);
|
|
2880
|
+
const dest = resolve17(targetDir, name);
|
|
2881
|
+
if (existsSync12(src) && !existsSync12(dest)) {
|
|
2920
2882
|
copyFileSync(src, dest);
|
|
2921
2883
|
}
|
|
2922
2884
|
}
|
|
2923
2885
|
const hubspotExample = firstExisting([
|
|
2924
|
-
|
|
2886
|
+
resolve17(sharedDir, HUBSPOT_CONFIG_EXAMPLE),
|
|
2925
2887
|
kitPath("templates", HUBSPOT_CONFIG_EXAMPLE)
|
|
2926
2888
|
]);
|
|
2927
2889
|
if (!hubspotExample) return;
|
|
2928
|
-
const destHubspot =
|
|
2929
|
-
if (!
|
|
2890
|
+
const destHubspot = resolve17(targetDir, HUBSPOT_CONFIG_EXAMPLE);
|
|
2891
|
+
if (!existsSync12(destHubspot) && !existsSync12(resolve17(targetDir, HUBSPOT_CONFIG_FILE))) {
|
|
2930
2892
|
copyFileSync(hubspotExample, destHubspot);
|
|
2931
2893
|
}
|
|
2932
2894
|
}
|
|
@@ -3024,7 +2986,7 @@ function buildConfigForProject(template, projectName, router) {
|
|
|
3024
2986
|
return config;
|
|
3025
2987
|
}
|
|
3026
2988
|
function assertTargetDirIsScaffoldable(targetDir) {
|
|
3027
|
-
if (!
|
|
2989
|
+
if (!existsSync13(targetDir)) return;
|
|
3028
2990
|
const entries = readdirSync2(targetDir).filter((entry) => entry !== ".DS_Store");
|
|
3029
2991
|
if (entries.length > 0) {
|
|
3030
2992
|
throw new WpHsError(`Target directory is not empty: ${targetDir}`, {
|
|
@@ -3035,7 +2997,7 @@ function assertTargetDirIsScaffoldable(targetDir) {
|
|
|
3035
2997
|
}
|
|
3036
2998
|
function resolveInitTargetDir(options, interactiveName) {
|
|
3037
2999
|
if (options.directory) {
|
|
3038
|
-
return
|
|
3000
|
+
return resolve18(options.directory);
|
|
3039
3001
|
}
|
|
3040
3002
|
const parentDir = process.cwd();
|
|
3041
3003
|
const slug = options.name ?? interactiveName;
|
|
@@ -3049,7 +3011,7 @@ function resolveInitTargetDir(options, interactiveName) {
|
|
|
3049
3011
|
if (error) {
|
|
3050
3012
|
throw new WpHsError(error, { exitCode: ExitCode.USER_ERROR });
|
|
3051
3013
|
}
|
|
3052
|
-
return
|
|
3014
|
+
return resolve18(parentDir, slug);
|
|
3053
3015
|
}
|
|
3054
3016
|
async function runInit(ctx, options) {
|
|
3055
3017
|
const nonInteractive = ctx.global.ci || ctx.global.yes || ctx.global.json;
|
|
@@ -3122,7 +3084,7 @@ async function runInit(ctx, options) {
|
|
|
3122
3084
|
const slug = projectName ?? basename2(targetDir);
|
|
3123
3085
|
assertTargetDirIsScaffoldable(targetDir);
|
|
3124
3086
|
const templateDir = kitPath("templates", template);
|
|
3125
|
-
if (!
|
|
3087
|
+
if (!existsSync13(templateDir)) {
|
|
3126
3088
|
throw new WpHsError(`Template not found: ${template}`, { exitCode: ExitCode.USER_ERROR });
|
|
3127
3089
|
}
|
|
3128
3090
|
if (ctx.global.dryRun) {
|
|
@@ -3133,10 +3095,10 @@ async function runInit(ctx, options) {
|
|
|
3133
3095
|
cpSync2(templateDir, targetDir, { recursive: true });
|
|
3134
3096
|
copySharedSetupExamples(targetDir);
|
|
3135
3097
|
const config = buildConfigForProject(template, slug, router);
|
|
3136
|
-
writeFileSync6(
|
|
3098
|
+
writeFileSync6(resolve18(targetDir, WOODSCLI_CONFIG_FILE), `${JSON.stringify(config, null, 2)}
|
|
3137
3099
|
`);
|
|
3138
|
-
const pkgPath =
|
|
3139
|
-
if (
|
|
3100
|
+
const pkgPath = resolve18(targetDir, "package.json");
|
|
3101
|
+
if (existsSync13(pkgPath)) {
|
|
3140
3102
|
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
3141
3103
|
pkg.name = slug;
|
|
3142
3104
|
pkg.scripts = { ...pkg.scripts, ...TEMPLATE_SCRIPTS[template] };
|
|
@@ -3155,7 +3117,7 @@ async function runInit(ctx, options) {
|
|
|
3155
3117
|
logger: ctx.logger,
|
|
3156
3118
|
dryRun: false
|
|
3157
3119
|
});
|
|
3158
|
-
const gitignorePath =
|
|
3120
|
+
const gitignorePath = resolve18(targetDir, ".gitignore");
|
|
3159
3121
|
const gitignoreExtras = [
|
|
3160
3122
|
"hubspot.config.yml",
|
|
3161
3123
|
".wphs/config/module-config.local.json",
|
|
@@ -3168,7 +3130,7 @@ async function runInit(ctx, options) {
|
|
|
3168
3130
|
".wphs/.kit-bootstrap.tsx",
|
|
3169
3131
|
".wphs/.kit-bootstrap-greenfield.tsx"
|
|
3170
3132
|
];
|
|
3171
|
-
const existing =
|
|
3133
|
+
const existing = existsSync13(gitignorePath) ? readFileSync11(gitignorePath, "utf8") : "";
|
|
3172
3134
|
const toAppend = gitignoreExtras.filter((line) => !existing.includes(line)).join("\n");
|
|
3173
3135
|
if (toAppend) {
|
|
3174
3136
|
writeFileSync6(gitignorePath, `${existing.trimEnd()}
|
|
@@ -3209,14 +3171,14 @@ ${toAppend}
|
|
|
3209
3171
|
}
|
|
3210
3172
|
|
|
3211
3173
|
// src/cli/commands/migrate.ts
|
|
3212
|
-
import { cpSync as cpSync3, existsSync as
|
|
3213
|
-
import { join as join3, resolve as
|
|
3174
|
+
import { cpSync as cpSync3, existsSync as existsSync14, mkdirSync as mkdirSync5, readFileSync as readFileSync12, readdirSync as readdirSync3, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
|
|
3175
|
+
import { join as join3, resolve as resolve19 } from "path";
|
|
3214
3176
|
var LEGACY_DIRS = [".dev", ".woodsportal"];
|
|
3215
3177
|
var LEGACY_BASELINE = ".wp-hs-baseline";
|
|
3216
3178
|
var LEGACY_BUILD_ID_FILE = ".portal-build-id";
|
|
3217
3179
|
var MODULE_BUILD_ID_FILE = ".module-build-id";
|
|
3218
3180
|
function readFirstNonCommentLine(filePath) {
|
|
3219
|
-
if (!
|
|
3181
|
+
if (!existsSync14(filePath)) return void 0;
|
|
3220
3182
|
const line = readFileSync12(filePath, "utf8").split("\n").map((l) => l.trim()).find((l) => l.length > 0 && !l.startsWith("#"));
|
|
3221
3183
|
return line || void 0;
|
|
3222
3184
|
}
|
|
@@ -3231,34 +3193,34 @@ function stripToBaseline(raw) {
|
|
|
3231
3193
|
}
|
|
3232
3194
|
async function runMigrate(ctx, _options = {}) {
|
|
3233
3195
|
const root = ctx.projectRoot;
|
|
3234
|
-
const wphsRoot =
|
|
3196
|
+
const wphsRoot = resolve19(root, WPHS_WORKSPACE_DIR);
|
|
3235
3197
|
const actions = [];
|
|
3236
3198
|
for (const legacy of LEGACY_DIRS) {
|
|
3237
|
-
const legacyPath =
|
|
3238
|
-
if (!
|
|
3199
|
+
const legacyPath = resolve19(root, legacy);
|
|
3200
|
+
if (!existsSync14(legacyPath)) continue;
|
|
3239
3201
|
actions.push(`Move ${legacy}/ \u2192 .wphs/`);
|
|
3240
3202
|
if (ctx.global.dryRun) continue;
|
|
3241
3203
|
mkdirSync5(join3(wphsRoot, "config"), { recursive: true });
|
|
3242
3204
|
mkdirSync5(join3(wphsRoot, "assets", "branding"), { recursive: true });
|
|
3243
3205
|
const localConfig = join3(legacyPath, "module-config.local.json");
|
|
3244
3206
|
const exampleConfig = join3(legacyPath, "module-config.example.json");
|
|
3245
|
-
if (
|
|
3207
|
+
if (existsSync14(localConfig)) {
|
|
3246
3208
|
cpSync3(localConfig, join3(wphsRoot, "config", "module-config.local.json"));
|
|
3247
3209
|
}
|
|
3248
|
-
if (
|
|
3210
|
+
if (existsSync14(exampleConfig)) {
|
|
3249
3211
|
cpSync3(exampleConfig, join3(wphsRoot, "config", "module-config.example.json"));
|
|
3250
3212
|
}
|
|
3251
3213
|
const branding = join3(legacyPath, "branding-assets");
|
|
3252
|
-
if (
|
|
3214
|
+
if (existsSync14(branding)) {
|
|
3253
3215
|
for (const file of readdirSync3(branding)) {
|
|
3254
3216
|
cpSync3(join3(branding, file), join3(wphsRoot, "assets", "branding", file));
|
|
3255
3217
|
}
|
|
3256
3218
|
}
|
|
3257
3219
|
rmSync3(legacyPath, { recursive: true, force: true });
|
|
3258
3220
|
}
|
|
3259
|
-
const legacyBaseline =
|
|
3221
|
+
const legacyBaseline = resolve19(root, LEGACY_BASELINE);
|
|
3260
3222
|
const targetBaseline = join3(wphsRoot, "audit", "baseline");
|
|
3261
|
-
if (
|
|
3223
|
+
if (existsSync14(legacyBaseline)) {
|
|
3262
3224
|
actions.push(`Move ${LEGACY_BASELINE}/ \u2192 .wphs/audit/baseline/`);
|
|
3263
3225
|
if (!ctx.global.dryRun) {
|
|
3264
3226
|
mkdirSync5(targetBaseline, { recursive: true });
|
|
@@ -3266,22 +3228,22 @@ async function runMigrate(ctx, _options = {}) {
|
|
|
3266
3228
|
rmSync3(legacyBaseline, { recursive: true, force: true });
|
|
3267
3229
|
}
|
|
3268
3230
|
}
|
|
3269
|
-
const legacyConfigPath2 =
|
|
3270
|
-
const woodscliPath =
|
|
3271
|
-
if (
|
|
3231
|
+
const legacyConfigPath2 = resolve19(root, LEGACY_WOODSPORTAL_HS_FILE);
|
|
3232
|
+
const woodscliPath = resolve19(root, WOODSCLI_CONFIG_FILE);
|
|
3233
|
+
if (existsSync14(legacyConfigPath2) && !existsSync14(woodscliPath)) {
|
|
3272
3234
|
actions.push(`Rename ${LEGACY_WOODSPORTAL_HS_FILE} \u2192 ${WOODSCLI_CONFIG_FILE}`);
|
|
3273
3235
|
if (!ctx.global.dryRun) {
|
|
3274
3236
|
renameSync(legacyConfigPath2, woodscliPath);
|
|
3275
3237
|
}
|
|
3276
|
-
} else if (
|
|
3238
|
+
} else if (existsSync14(legacyConfigPath2) && existsSync14(woodscliPath)) {
|
|
3277
3239
|
actions.push(`Remove duplicate ${LEGACY_WOODSPORTAL_HS_FILE}`);
|
|
3278
3240
|
if (!ctx.global.dryRun) {
|
|
3279
3241
|
rmSync3(legacyConfigPath2, { force: true });
|
|
3280
3242
|
}
|
|
3281
3243
|
}
|
|
3282
|
-
const legacyBuildIdPath =
|
|
3283
|
-
const moduleBuildIdPath =
|
|
3284
|
-
if (
|
|
3244
|
+
const legacyBuildIdPath = resolve19(root, LEGACY_BUILD_ID_FILE);
|
|
3245
|
+
const moduleBuildIdPath = resolve19(root, MODULE_BUILD_ID_FILE);
|
|
3246
|
+
if (existsSync14(legacyBuildIdPath) && !existsSync14(moduleBuildIdPath)) {
|
|
3285
3247
|
const baseline = stripToBaseline(readFirstNonCommentLine(legacyBuildIdPath)) ?? "v0.0.1-dev";
|
|
3286
3248
|
actions.push(`Migrate ${LEGACY_BUILD_ID_FILE} \u2192 ${MODULE_BUILD_ID_FILE} (baseline ${baseline})`);
|
|
3287
3249
|
if (!ctx.global.dryRun) {
|
|
@@ -3294,7 +3256,7 @@ ${baseline}
|
|
|
3294
3256
|
rmSync3(legacyBuildIdPath, { force: true });
|
|
3295
3257
|
}
|
|
3296
3258
|
}
|
|
3297
|
-
if (
|
|
3259
|
+
if (existsSync14(woodscliPath)) {
|
|
3298
3260
|
const raw = JSON.parse(readFileSync12(woodscliPath, "utf8"));
|
|
3299
3261
|
let configChanged = false;
|
|
3300
3262
|
if (raw?.dev?.moduleConfigDir && raw.dev.moduleConfigDir !== WPHS_WORKSPACE_DIR) {
|
|
@@ -3376,15 +3338,15 @@ async function runExamplesSmoke(ctx, options = {}) {
|
|
|
3376
3338
|
}
|
|
3377
3339
|
|
|
3378
3340
|
// src/cli/commands/fields.ts
|
|
3379
|
-
import { cpSync as cpSync4, existsSync as
|
|
3380
|
-
import { resolve as
|
|
3341
|
+
import { cpSync as cpSync4, existsSync as existsSync15, readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
|
|
3342
|
+
import { resolve as resolve20 } from "path";
|
|
3381
3343
|
async function runFieldsSync(ctx, options = {}) {
|
|
3382
3344
|
const direction = options.direction ?? "pull";
|
|
3383
|
-
const fieldsPath =
|
|
3384
|
-
const cacheDir =
|
|
3385
|
-
const cachePath =
|
|
3345
|
+
const fieldsPath = resolve20(ctx.projectRoot, ctx.config.dev.fieldsJson);
|
|
3346
|
+
const cacheDir = resolve20(ctx.projectRoot, ctx.config.dev.moduleConfigDir, "cache", "fields-sync");
|
|
3347
|
+
const cachePath = resolve20(cacheDir, "fields.json");
|
|
3386
3348
|
if (direction === "pull") {
|
|
3387
|
-
if (!
|
|
3349
|
+
if (!existsSync15(fieldsPath)) {
|
|
3388
3350
|
throw new WpHsError(`Missing ${ctx.config.dev.fieldsJson}`, {
|
|
3389
3351
|
exitCode: ExitCode.USER_ERROR,
|
|
3390
3352
|
remediation: "Add fields.json or run wp init."
|
|
@@ -3400,7 +3362,7 @@ async function runFieldsSync(ctx, options = {}) {
|
|
|
3400
3362
|
ctx.logger.success(`Cached fields \u2192 ${cachePath}`);
|
|
3401
3363
|
return ExitCode.SUCCESS;
|
|
3402
3364
|
}
|
|
3403
|
-
if (!
|
|
3365
|
+
if (!existsSync15(cachePath)) {
|
|
3404
3366
|
throw new WpHsError("No cached fields \u2014 run wp fields sync pull first.", {
|
|
3405
3367
|
exitCode: ExitCode.USER_ERROR
|
|
3406
3368
|
});
|
|
@@ -3415,8 +3377,8 @@ async function runFieldsSync(ctx, options = {}) {
|
|
|
3415
3377
|
}
|
|
3416
3378
|
|
|
3417
3379
|
// src/cli/commands/regression.ts
|
|
3418
|
-
import { existsSync as
|
|
3419
|
-
import { resolve as
|
|
3380
|
+
import { existsSync as existsSync16 } from "fs";
|
|
3381
|
+
import { resolve as resolve21 } from "path";
|
|
3420
3382
|
var LEGACY_SHIM_SCRIPTS = [
|
|
3421
3383
|
"build-cdn.mjs",
|
|
3422
3384
|
"run-vite-build.mjs",
|
|
@@ -3439,21 +3401,21 @@ async function runRegressionSmoke(ctx, options = {}) {
|
|
|
3439
3401
|
if (!validateOk) failures.push("wp config validate failed");
|
|
3440
3402
|
if (options.checkLegacyShims !== false) {
|
|
3441
3403
|
for (const script of LEGACY_SHIM_SCRIPTS) {
|
|
3442
|
-
const shim =
|
|
3404
|
+
const shim = resolve21(ctx.projectRoot, "scripts", script);
|
|
3443
3405
|
const kitScript = kitPath("scripts", script);
|
|
3444
|
-
const shimOk =
|
|
3406
|
+
const shimOk = existsSync16(shim) && existsSync16(kitScript);
|
|
3445
3407
|
checks.push({ name: `shim:${script}`, ok: shimOk });
|
|
3446
3408
|
if (!shimOk) failures.push(`Missing legacy shim or kit script: ${script}`);
|
|
3447
3409
|
}
|
|
3448
3410
|
}
|
|
3449
3411
|
for (const rel of FORBIDDEN_CONSUMER_PATHS) {
|
|
3450
|
-
const forbidden =
|
|
3451
|
-
const absent = !
|
|
3412
|
+
const forbidden = resolve21(ctx.projectRoot, rel);
|
|
3413
|
+
const absent = !existsSync16(forbidden);
|
|
3452
3414
|
checks.push({ name: `no-${rel}`, ok: absent });
|
|
3453
3415
|
if (!absent) failures.push(`Forbidden dev path still present: ${rel}`);
|
|
3454
3416
|
}
|
|
3455
|
-
const woodscliConfig =
|
|
3456
|
-
const configOk =
|
|
3417
|
+
const woodscliConfig = resolve21(ctx.projectRoot, WOODSCLI_CONFIG_FILE);
|
|
3418
|
+
const configOk = existsSync16(woodscliConfig);
|
|
3457
3419
|
checks.push({ name: WOODSCLI_CONFIG_FILE, ok: configOk });
|
|
3458
3420
|
if (!configOk) failures.push(`${WOODSCLI_CONFIG_FILE} missing`);
|
|
3459
3421
|
if (ctx.global.json) {
|
|
@@ -3566,8 +3528,8 @@ async function runSetup(ctx, options = {}) {
|
|
|
3566
3528
|
import * as p5 from "@clack/prompts";
|
|
3567
3529
|
|
|
3568
3530
|
// src/lib/hubspot-portals.ts
|
|
3569
|
-
import { existsSync as
|
|
3570
|
-
import { resolve as
|
|
3531
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15 } from "fs";
|
|
3532
|
+
import { resolve as resolve22 } from "path";
|
|
3571
3533
|
function stripYamlScalar(value) {
|
|
3572
3534
|
const trimmed = value.trim();
|
|
3573
3535
|
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
@@ -3605,8 +3567,8 @@ function parseHubSpotConfigPortals(raw) {
|
|
|
3605
3567
|
return { defaultPortal, portals };
|
|
3606
3568
|
}
|
|
3607
3569
|
function readHubSpotPortals(projectRoot) {
|
|
3608
|
-
const configPath =
|
|
3609
|
-
if (!
|
|
3570
|
+
const configPath = resolve22(projectRoot, HUBSPOT_CONFIG_FILE);
|
|
3571
|
+
if (!existsSync17(configPath)) {
|
|
3610
3572
|
throw new WpHsError(`${HUBSPOT_CONFIG_FILE} not found in project root.`, {
|
|
3611
3573
|
exitCode: ExitCode.USER_ERROR,
|
|
3612
3574
|
remediation: "Run wp setup, then add your portal + PAT."
|
|
@@ -3742,7 +3704,7 @@ async function runWatch(ctx, options) {
|
|
|
3742
3704
|
// src/cli/program.ts
|
|
3743
3705
|
function readVersion() {
|
|
3744
3706
|
try {
|
|
3745
|
-
const pkg = JSON.parse(readFileSync16(
|
|
3707
|
+
const pkg = JSON.parse(readFileSync16(resolve23(getKitRoot(), "package.json"), "utf8"));
|
|
3746
3708
|
return pkg.version ?? "0.0.0";
|
|
3747
3709
|
} catch {
|
|
3748
3710
|
return "0.0.0";
|