@woodsportal/hubspot-kit 1.0.39-dev.1 → 1.0.40

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 CHANGED
@@ -899,19 +899,70 @@ function checkConfig(ctx) {
899
899
  ];
900
900
  }
901
901
  }
902
+ function envFileForTier(tier) {
903
+ if (tier === "dev") return ".env.dev";
904
+ if (tier === "stg") return ".env.stg";
905
+ return ".env.prod";
906
+ }
907
+ function readEnvFileValue(projectRoot, file, key) {
908
+ const path = resolve8(projectRoot, file);
909
+ if (!existsSync7(path)) return void 0;
910
+ try {
911
+ const content = readFileSync5(path, "utf8");
912
+ const match = content.match(new RegExp(`^${key}=(.*)$`, "m"));
913
+ return match?.[1]?.trim();
914
+ } catch {
915
+ return void 0;
916
+ }
917
+ }
902
918
  function checkEnvFiles(ctx) {
903
- return ctx.config.env.tiers.map((tier) => {
904
- const file = tier === "dev" ? ".env.dev" : tier === "stg" ? ".env.stg" : ".env.prod";
905
- const path = resolve8(ctx.projectRoot, file);
906
- const ok = existsSync7(path);
907
- return {
919
+ const checks = [];
920
+ const localPath = resolve8(ctx.projectRoot, ".env.local");
921
+ const localOk = existsSync7(localPath);
922
+ checks.push({
923
+ name: "env-local",
924
+ ok: localOk,
925
+ message: localOk ? ".env.local present" : ".env.local missing (required for yarn local / wp local)",
926
+ remediation: localOk ? void 0 : "wp setup or copy .env.local.example \u2192 .env.local",
927
+ severity: "warn"
928
+ });
929
+ const legacyLocalDev = resolve8(ctx.projectRoot, ".env.dev");
930
+ if (!localOk && existsSync7(legacyLocalDev)) {
931
+ const nodeEnv = readEnvFileValue(ctx.projectRoot, ".env.dev", "VITE_NODE_ENV");
932
+ const hasDevMode = readEnvFileValue(ctx.projectRoot, ".env.dev", "VITE_DEV_MODE") != null;
933
+ const looksLikeLocal = hasDevMode || nodeEnv === "local" || nodeEnv == null || nodeEnv === "development";
934
+ if (looksLikeLocal) {
935
+ checks.push({
936
+ name: "env-local-migration",
937
+ ok: false,
938
+ message: ".env.dev looks like old localhost config \u2014 rename to .env.local and add VITE_NODE_ENV=local",
939
+ remediation: "mv .env.dev .env.local (then create .env.dev from .env.dev.example for deploy:dev)",
940
+ severity: "warn"
941
+ });
942
+ }
943
+ }
944
+ for (const tier of ctx.config.env.tiers) {
945
+ const file = envFileForTier(tier);
946
+ const ok = existsSync7(resolve8(ctx.projectRoot, file));
947
+ if (tier === "stg") {
948
+ checks.push({
949
+ name: "env-stg",
950
+ ok: true,
951
+ message: ok ? ".env.stg present" : ".env.stg missing (optional \u2014 reserved for future staging)",
952
+ remediation: ok ? void 0 : "Create from .env.stg.example when a staging API exists",
953
+ severity: "warn"
954
+ });
955
+ continue;
956
+ }
957
+ checks.push({
908
958
  name: `env-${tier}`,
909
959
  ok,
910
960
  message: ok ? `${file} present` : `${file} missing`,
911
961
  remediation: ok ? void 0 : "wp setup (copies from .example templates)",
912
962
  severity: "warn"
913
- };
914
- });
963
+ });
964
+ }
965
+ return checks;
915
966
  }
916
967
  function checkLegacyBuildIdFile(ctx) {
917
968
  if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return null;
@@ -1748,8 +1799,10 @@ function parseBuildTier(value) {
1748
1799
  }
1749
1800
 
1750
1801
  // src/cli/commands/build.ts
1751
- function tierToStgFlag(tier) {
1752
- return tier === "dev" || tier === "stg" ? ["--stg"] : [];
1802
+ function tierToViteModeFlag(tier) {
1803
+ if (tier === "dev") return ["--dev"];
1804
+ if (tier === "stg") return ["--stg"];
1805
+ return ["--prod"];
1753
1806
  }
1754
1807
  function buildTasks(ctx, options, run) {
1755
1808
  const tier = options.tier ?? DEFAULT_BUILD_TIER;
@@ -1765,7 +1818,7 @@ function buildTasks(ctx, options, run) {
1765
1818
  task: async () => {
1766
1819
  await run("run-vite-build.mjs", [
1767
1820
  resolve10(ctx.projectRoot, "vite.config.monolith.mjs"),
1768
- ...tierToStgFlag(tier)
1821
+ ...tierToViteModeFlag(tier)
1769
1822
  ]);
1770
1823
  await run("run-hubspot-module-postbuild.mjs");
1771
1824
  }
@@ -1779,10 +1832,10 @@ function buildTasks(ctx, options, run) {
1779
1832
  if (options.cdnEsm) {
1780
1833
  await run("run-vite-build.mjs", [
1781
1834
  resolve10(ctx.projectRoot, "vite.config.cdn-esm.mjs"),
1782
- ...tierToStgFlag(tier)
1835
+ ...tierToViteModeFlag(tier)
1783
1836
  ]);
1784
1837
  } else {
1785
- await run("build-cdn.mjs", tierToStgFlag(tier));
1838
+ await run("build-cdn.mjs", tierToViteModeFlag(tier));
1786
1839
  }
1787
1840
  await run("generate-cdn-manifest.mjs");
1788
1841
  }
@@ -1794,7 +1847,7 @@ function buildTasks(ctx, options, run) {
1794
1847
  task: async () => {
1795
1848
  await run("run-vite-build.mjs", [
1796
1849
  resolve10(ctx.projectRoot, "vite.config.hubspot.mjs"),
1797
- ...tierToStgFlag(tier)
1850
+ ...tierToViteModeFlag(tier)
1798
1851
  ]);
1799
1852
  await run("run-hubspot-module-postbuild.mjs");
1800
1853
  }
@@ -2128,7 +2181,7 @@ async function runDeploy(ctx, options) {
2128
2181
  dryRun: ctx.global.dryRun,
2129
2182
  streamOutput: ctx.global.verbose
2130
2183
  };
2131
- const verifyFlag = tier === "prod" ? ["--prod"] : ["--stg"];
2184
+ const verifyFlag = tier === "prod" ? ["--prod"] : tier === "stg" ? ["--stg"] : ["--dev"];
2132
2185
  const tasks = [
2133
2186
  {
2134
2187
  title: "Checking HubSpot CLI",
@@ -2227,7 +2280,7 @@ async function runPublish(ctx, options) {
2227
2280
  dryRun: ctx.global.dryRun || options.dryRun,
2228
2281
  streamOutput: ctx.global.verbose
2229
2282
  };
2230
- const verifyFlag = tier === "prod" ? ["--prod"] : ["--stg"];
2283
+ const verifyFlag = tier === "prod" ? ["--prod"] : tier === "stg" ? ["--stg"] : ["--dev"];
2231
2284
  const publishArgs = options.dryRun ? ["--dry-run"] : [];
2232
2285
  try {
2233
2286
  await runCliTasks(
@@ -2741,7 +2794,7 @@ function formatCdnSetupNote(_projectRoot) {
2741
2794
  // src/lib/project-setup.ts
2742
2795
  import { copyFileSync, existsSync as existsSync12, writeFileSync as writeFileSync5 } from "fs";
2743
2796
  import { basename, resolve as resolve17 } from "path";
2744
- function envFileForTier(tier) {
2797
+ function envFileForTier2(tier) {
2745
2798
  return tier === "dev" ? ".env.dev" : tier === "stg" ? ".env.stg" : ".env.prod";
2746
2799
  }
2747
2800
  function tiersToSetup(config, tier) {
@@ -2814,8 +2867,14 @@ function applyProjectSetup(ctx, options = {}) {
2814
2867
  kitPath("templates", HUBSPOT_CONFIG_EXAMPLE)
2815
2868
  ], dryRun)
2816
2869
  );
2870
+ results.push(
2871
+ copyMissingFile(projectRoot, ".env.local", [
2872
+ resolve17(projectRoot, ".env.local.example"),
2873
+ resolve17(sharedDir, ".env.local.example")
2874
+ ], dryRun)
2875
+ );
2817
2876
  for (const tier of tiersToSetup(config, options.tier)) {
2818
- const envFile = envFileForTier(tier);
2877
+ const envFile = envFileForTier2(tier);
2819
2878
  const envExample = `${envFile}.example`;
2820
2879
  results.push(
2821
2880
  copyMissingFile(projectRoot, envFile, [
@@ -2871,6 +2930,7 @@ function copySharedSetupExamples(targetDir) {
2871
2930
  const sharedDir = kitPath("templates", "shared");
2872
2931
  if (!existsSync12(sharedDir)) return;
2873
2932
  for (const name of [
2933
+ ".env.local.example",
2874
2934
  ".env.dev.example",
2875
2935
  ".env.stg.example",
2876
2936
  ".env.prod.example",