@lukoweb/apitogo 0.1.51 → 0.1.53

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.
@@ -1,5 +1,5 @@
1
1
  import { normalizePath, type Plugin, type ResolvedConfig } from "vite";
2
- import { getCurrentConfig } from "../config/loader.js";
2
+ import { getCurrentConfig, loadZudokuConfig } from "../config/loader.js";
3
3
 
4
4
  const virtualModuleId = "virtual:zudoku-config";
5
5
  const resolvedVirtualModuleId = `\0${virtualModuleId}`;
@@ -17,7 +17,7 @@ const viteConfigPlugin = (): Plugin => {
17
17
  configResolved(resolvedConfig) {
18
18
  viteConfig = resolvedConfig;
19
19
  },
20
- load(id) {
20
+ async load(id) {
21
21
  if (id !== resolvedVirtualModuleId) return;
22
22
 
23
23
  const configPath = getCurrentConfig().__meta.configPath;
@@ -25,11 +25,28 @@ const viteConfigPlugin = (): Plugin => {
25
25
  return `export default {};`;
26
26
  }
27
27
 
28
+ const { config: loadedConfig } = await loadZudokuConfig(
29
+ {
30
+ mode: viteConfig.mode,
31
+ command: viteConfig.command,
32
+ },
33
+ viteConfig.root,
34
+ );
35
+ const clientMeta = {
36
+ rootDir: loadedConfig.__meta.rootDir,
37
+ pricingEnabled: loadedConfig.__meta.pricingEnabled,
38
+ authenticationEnabled: loadedConfig.__meta.authenticationEnabled,
39
+ previewPlans: loadedConfig.__meta.previewPlans,
40
+ };
41
+
28
42
  return `
29
43
  import rawConfig from "${normalizePath(configPath)}";
30
44
  import { runPluginTransformConfig } from "@lukoweb/apitogo/plugins";
31
45
 
32
- const config = await runPluginTransformConfig(rawConfig);
46
+ const config = await runPluginTransformConfig({
47
+ ...rawConfig,
48
+ __meta: ${JSON.stringify(clientMeta)},
49
+ });
33
50
  export default config;
34
51
  `;
35
52
  },
@@ -1,10 +1,16 @@
1
1
  import path from "node:path";
2
2
  import type { Plugin, ResolvedConfig } from "vite";
3
+ import {
4
+ loadApitogoConfig,
5
+ readPlanCatalogItems,
6
+ } from "../config/apitogo-config-loader.js";
3
7
  import {
4
8
  manifestPathsForEnv,
5
9
  manifestToPreviewCatalog,
10
+ plansToPreviewCatalog,
6
11
  readEffectiveManifest,
7
12
  resolveManifestEnv,
13
+ type ManifestPlanInput,
8
14
  } from "../config/local-manifest.js";
9
15
 
10
16
  export const APITOGO_LOCAL_MANIFEST_VIRTUAL_ID =
@@ -24,6 +30,15 @@ const viteLocalManifestPlugin = (): Plugin => {
24
30
  try {
25
31
  const manifest = await readEffectiveManifest(rootDir, env);
26
32
  catalog = manifestToPreviewCatalog(manifest);
33
+ if (!catalog.plans.length) {
34
+ const config = loadApitogoConfig(rootDir);
35
+ catalog = {
36
+ ...catalog,
37
+ ...plansToPreviewCatalog(
38
+ readPlanCatalogItems(config) as ManifestPlanInput[],
39
+ ),
40
+ };
41
+ }
27
42
  } catch {
28
43
  // Missing or invalid manifest — empty catalog for preview.
29
44
  }