riverbankcms 0.7.0 → 0.8.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.
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env node
2
- import { n as assertCompatibleSdkPeer } from "./sdk-peer-BjTmH5Mt.mjs";
3
- import { dirname, resolve } from "path";
4
- import { createJiti } from "jiti";
5
- import { existsSync } from "fs";
6
- import { fileURLToPath } from "url";
7
-
8
- //#region src/load-config.ts
9
- /**
10
- * Config file loader for riverbank.config.ts
11
- *
12
- * Uses jiti to load TypeScript config files at runtime without
13
- * requiring a build step.
14
- */
15
- const DEFAULT_CONFIG_FILENAME = "riverbank.config.ts";
16
- const currentDir = dirname(fileURLToPath(import.meta.url));
17
- /**
18
- * Load builder config from a TypeScript file.
19
- *
20
- * @param configPath - Path to config file, or directory containing riverbank.config.ts
21
- * @returns The loaded config object
22
- * @throws Error if config file not found or invalid
23
- */
24
- async function loadConfigFile(configPath) {
25
- const resolvedPath = resolveConfigPath(configPath);
26
- if (!existsSync(resolvedPath)) {
27
- throw new Error(`Config file not found: ${resolvedPath}\n` + `Create a riverbank.config.ts file or specify a path with --config`);
28
- }
29
- assertCompatibleSdkPeer(resolvedPath);
30
- process.stderr.write(`Loading config from ${resolvedPath}...\n`);
31
- const alias = {};
32
- const sourceConfigPath = resolve(currentDir, "..", "config", "index.ts");
33
- const sourceIndexPath = resolve(currentDir, "..", "index.ts");
34
- if (existsSync(sourceConfigPath)) {
35
- alias["@riverbankcms/sdk/config"] = sourceConfigPath;
36
- }
37
- if (existsSync(sourceIndexPath)) {
38
- alias["@riverbankcms/sdk"] = sourceIndexPath;
39
- }
40
- const blocksDir = resolve(currentDir, "../../../blocks/src");
41
- if (existsSync(blocksDir)) {
42
- alias["@riverbankcms/blocks"] = blocksDir;
43
- }
44
- const mediaCorePath = resolve(currentDir, "../../../media-core/src/index.ts");
45
- if (existsSync(mediaCorePath)) {
46
- alias["@riverbankcms/media-core"] = mediaCorePath;
47
- }
48
- const jiti = createJiti(import.meta.url, {
49
- fsCache: false,
50
- moduleCache: false,
51
- alias: Object.keys(alias).length > 0 ? alias : undefined,
52
- jsx: Object.keys(alias).length > 0
53
- });
54
- try {
55
- const configModule = await jiti.import(resolvedPath);
56
- const config = configModule.default ?? configModule.config ?? configModule;
57
- if (!config || typeof config !== "object") {
58
- throw new Error("Config file must export a configuration object");
59
- }
60
- return config;
61
- } catch (error) {
62
- if (error instanceof Error) {
63
- throw new Error(`Failed to load config: ${error.message}`);
64
- }
65
- throw error;
66
- }
67
- }
68
- /**
69
- * Resolve config path from user input.
70
- *
71
- * If no path provided, looks for riverbank.config.ts in cwd.
72
- * If path is a directory, looks for riverbank.config.ts in that directory.
73
- * If path is a file, uses it directly.
74
- */
75
- function resolveConfigPath(configPath) {
76
- if (!configPath) {
77
- return resolve(process.cwd(), DEFAULT_CONFIG_FILENAME);
78
- }
79
- const resolved = resolve(configPath);
80
- if (existsSync(resolved) && !resolved.endsWith(".ts") && !resolved.endsWith(".js")) {
81
- return resolve(resolved, DEFAULT_CONFIG_FILENAME);
82
- }
83
- return resolved;
84
- }
85
-
86
- //#endregion
87
- export { loadConfigFile as t };