@bagelink/workspace 1.7.37 → 1.7.41
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/README.md +20 -5
- package/dist/bin/bgl.cjs +1012 -14
- package/dist/bin/bgl.mjs +1001 -4
- package/dist/composable.cjs +21 -0
- package/dist/composable.d.cts +50 -0
- package/dist/composable.d.mts +50 -0
- package/dist/composable.d.ts +50 -0
- package/dist/composable.mjs +18 -0
- package/dist/index.cjs +3 -150
- package/dist/index.d.cts +4 -172
- package/dist/index.d.mts +4 -172
- package/dist/index.d.ts +4 -172
- package/dist/index.mjs +2 -126
- package/dist/shared/workspace.D1xukL92.d.cts +44 -0
- package/dist/shared/workspace.D1xukL92.d.mts +44 -0
- package/dist/shared/workspace.D1xukL92.d.ts +44 -0
- package/dist/shared/workspace.Dx9_TIij.cjs +86 -0
- package/dist/shared/workspace.Twuo1PFw.mjs +78 -0
- package/dist/vite.cjs +88 -4
- package/dist/vite.d.cts +97 -2
- package/dist/vite.d.mts +97 -2
- package/dist/vite.d.ts +97 -2
- package/dist/vite.mjs +82 -3
- package/package.json +6 -1
- package/src/index.ts +9 -77
- package/src/vite.ts +4 -0
- package/dist/shared/workspace.CSNgk3PR.d.cts +0 -113
- package/dist/shared/workspace.CSNgk3PR.d.mts +0 -113
- package/dist/shared/workspace.CSNgk3PR.d.ts +0 -113
- package/dist/shared/workspace.CamNrnD_.cjs +0 -1155
- package/dist/shared/workspace.D0MF8ERh.mjs +0 -79
- package/dist/shared/workspace.DfLGMczD.cjs +0 -87
- package/dist/shared/workspace.PLrsjsJ2.mjs +0 -1134
package/dist/index.d.mts
CHANGED
|
@@ -1,179 +1,11 @@
|
|
|
1
|
-
import { W as
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Load and resolve bgl.config.ts with cascading support
|
|
7
|
-
* Looks for config files from current directory up to workspace root
|
|
8
|
-
* If no config is found, prompts to create one interactively
|
|
9
|
-
*/
|
|
10
|
-
declare function resolveConfig(mode?: WorkspaceEnvironment, options?: WorkspaceOptions): Promise<WorkspaceConfig>;
|
|
11
|
-
/**
|
|
12
|
-
* Merge two configs, with the second one taking precedence
|
|
13
|
-
*/
|
|
14
|
-
declare function mergeConfigs(base: WorkspaceConfig, override: Partial<WorkspaceConfig>): WorkspaceConfig;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate bgl.config.ts file interactively
|
|
18
|
-
*/
|
|
19
|
-
declare function generateWorkspaceConfig(root?: string, configFile?: string): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate bgl.config.ts non-interactively
|
|
22
|
-
*/
|
|
23
|
-
declare function generateWorkspaceConfigSync(projectId: string, root?: string, configFile?: string, customHost?: string): void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Generate netlify.toml redirect configuration
|
|
27
|
-
* Uses environment variables for flexibility across environments
|
|
28
|
-
*/
|
|
29
|
-
declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
|
|
30
|
-
/**
|
|
31
|
-
* Generate complete netlify.toml file
|
|
32
|
-
*/
|
|
33
|
-
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string, useTemplate?: boolean): string;
|
|
34
|
-
/**
|
|
35
|
-
* Write netlify.toml file to disk
|
|
36
|
-
*/
|
|
37
|
-
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string, useTemplate?: boolean): void;
|
|
38
|
-
/**
|
|
39
|
-
* Set environment variables for build process
|
|
40
|
-
*/
|
|
41
|
-
declare function setBuildEnvVars(config: WorkspaceConfig): void;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create Vite proxy configuration from WorkspaceConfig
|
|
45
|
-
*/
|
|
46
|
-
declare function createViteProxy(config: WorkspaceConfig): ProxyConfig;
|
|
47
|
-
/**
|
|
48
|
-
* Create custom proxy configuration
|
|
49
|
-
*/
|
|
50
|
-
declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
51
|
-
changeOrigin?: boolean;
|
|
52
|
-
rewrite?: boolean;
|
|
53
|
-
secure?: boolean;
|
|
54
|
-
}): ProxyConfig;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Runtime workspace configuration
|
|
58
|
-
* Provides access to workspace config injected at build time
|
|
59
|
-
*/
|
|
60
|
-
interface RuntimeWorkspaceConfig {
|
|
61
|
-
/** API proxy path (e.g., '/api') */
|
|
62
|
-
proxy: string;
|
|
63
|
-
/** API host URL (e.g., 'https://project.bagel.to') */
|
|
64
|
-
host: string;
|
|
65
|
-
/** OpenAPI specification URL (if configured) */
|
|
66
|
-
openapiUrl?: string;
|
|
67
|
-
/** Current environment mode */
|
|
68
|
-
mode: 'localhost' | 'development' | 'production';
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get workspace configuration at runtime
|
|
72
|
-
* Config is injected as environment variables during build
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* import { useWorkspace } from '@bagelink/workspace'
|
|
77
|
-
*
|
|
78
|
-
* const { proxy, host } = useWorkspace()
|
|
79
|
-
* const auth = initAuth({ baseURL: proxy })
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example In Vue component
|
|
83
|
-
* ```vue
|
|
84
|
-
* <script setup>
|
|
85
|
-
* import { useWorkspace } from '@bagelink/workspace'
|
|
86
|
-
*
|
|
87
|
-
* const { proxy, host, mode } = useWorkspace()
|
|
88
|
-
* </script>
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare function useWorkspace(): RuntimeWorkspaceConfig;
|
|
92
|
-
/**
|
|
93
|
-
* Get the full API URL by combining host and proxy
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* import { getApiUrl } from '@bagelink/workspace'
|
|
98
|
-
*
|
|
99
|
-
* const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
declare function getApiUrl(): string;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Detect if current directory is a workspace root
|
|
106
|
-
*/
|
|
107
|
-
declare function isWorkspace(root?: string): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Get workspace info
|
|
110
|
-
*/
|
|
111
|
-
declare function getWorkspaceInfo(root?: string): {
|
|
112
|
-
isWorkspace: boolean;
|
|
113
|
-
projects: string[];
|
|
114
|
-
hasShared: boolean;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
declare function runDev(filter?: string, additionalArgs?: string[]): Promise<number>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Set up linting in a project
|
|
121
|
-
*/
|
|
122
|
-
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Generate SDK from OpenAPI spec
|
|
126
|
-
*/
|
|
127
|
-
declare function generateSDK(root?: string): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Generate SDK for all projects in workspace
|
|
130
|
-
*/
|
|
131
|
-
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Initialize a new workspace with flat structure
|
|
135
|
-
*/
|
|
136
|
-
declare function initWorkspace(root?: string): Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Add a new project to the workspace
|
|
139
|
-
*/
|
|
140
|
-
declare function addProject(name: string, root?: string): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* List all projects in workspace
|
|
143
|
-
*/
|
|
144
|
-
declare function listProjects(root?: string): string[];
|
|
1
|
+
import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.D1xukL92.mjs';
|
|
2
|
+
export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.D1xukL92.mjs';
|
|
3
|
+
export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.mjs';
|
|
145
4
|
|
|
146
5
|
/**
|
|
147
6
|
* Define workspace configuration
|
|
148
7
|
* Simple helper to get config from a config map
|
|
149
8
|
*/
|
|
150
9
|
declare function defineWorkspace(configs: Record<WorkspaceEnvironment, WorkspaceConfig>): (mode?: WorkspaceEnvironment) => WorkspaceConfig;
|
|
151
|
-
/**
|
|
152
|
-
* Create a workspace instance for managing project configuration
|
|
153
|
-
* Supports both single project and monorepo setups
|
|
154
|
-
*/
|
|
155
|
-
declare function createWorkspace(options?: WorkspaceOptions): {
|
|
156
|
-
/**
|
|
157
|
-
* Get resolved config for the specified environment
|
|
158
|
-
*/
|
|
159
|
-
getConfig(mode?: WorkspaceEnvironment): Promise<WorkspaceConfig>;
|
|
160
|
-
/**
|
|
161
|
-
* Create Vite proxy configuration
|
|
162
|
-
*/
|
|
163
|
-
createProxy(config: WorkspaceConfig): ProxyConfig;
|
|
164
|
-
/**
|
|
165
|
-
* Generate Netlify configuration file
|
|
166
|
-
*/
|
|
167
|
-
generateNetlify(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
168
|
-
/**
|
|
169
|
-
* Set build environment variables
|
|
170
|
-
*/
|
|
171
|
-
setBuildEnv(config: WorkspaceConfig): void;
|
|
172
|
-
/**
|
|
173
|
-
* Clear cached configuration
|
|
174
|
-
*/
|
|
175
|
-
clearCache(): void;
|
|
176
|
-
};
|
|
177
10
|
|
|
178
|
-
export {
|
|
179
|
-
export type { RuntimeWorkspaceConfig };
|
|
11
|
+
export { WorkspaceConfig, WorkspaceEnvironment, defineWorkspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,179 +1,11 @@
|
|
|
1
|
-
import { W as
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Load and resolve bgl.config.ts with cascading support
|
|
7
|
-
* Looks for config files from current directory up to workspace root
|
|
8
|
-
* If no config is found, prompts to create one interactively
|
|
9
|
-
*/
|
|
10
|
-
declare function resolveConfig(mode?: WorkspaceEnvironment, options?: WorkspaceOptions): Promise<WorkspaceConfig>;
|
|
11
|
-
/**
|
|
12
|
-
* Merge two configs, with the second one taking precedence
|
|
13
|
-
*/
|
|
14
|
-
declare function mergeConfigs(base: WorkspaceConfig, override: Partial<WorkspaceConfig>): WorkspaceConfig;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate bgl.config.ts file interactively
|
|
18
|
-
*/
|
|
19
|
-
declare function generateWorkspaceConfig(root?: string, configFile?: string): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate bgl.config.ts non-interactively
|
|
22
|
-
*/
|
|
23
|
-
declare function generateWorkspaceConfigSync(projectId: string, root?: string, configFile?: string, customHost?: string): void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Generate netlify.toml redirect configuration
|
|
27
|
-
* Uses environment variables for flexibility across environments
|
|
28
|
-
*/
|
|
29
|
-
declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
|
|
30
|
-
/**
|
|
31
|
-
* Generate complete netlify.toml file
|
|
32
|
-
*/
|
|
33
|
-
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string, useTemplate?: boolean): string;
|
|
34
|
-
/**
|
|
35
|
-
* Write netlify.toml file to disk
|
|
36
|
-
*/
|
|
37
|
-
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string, useTemplate?: boolean): void;
|
|
38
|
-
/**
|
|
39
|
-
* Set environment variables for build process
|
|
40
|
-
*/
|
|
41
|
-
declare function setBuildEnvVars(config: WorkspaceConfig): void;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create Vite proxy configuration from WorkspaceConfig
|
|
45
|
-
*/
|
|
46
|
-
declare function createViteProxy(config: WorkspaceConfig): ProxyConfig;
|
|
47
|
-
/**
|
|
48
|
-
* Create custom proxy configuration
|
|
49
|
-
*/
|
|
50
|
-
declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
51
|
-
changeOrigin?: boolean;
|
|
52
|
-
rewrite?: boolean;
|
|
53
|
-
secure?: boolean;
|
|
54
|
-
}): ProxyConfig;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Runtime workspace configuration
|
|
58
|
-
* Provides access to workspace config injected at build time
|
|
59
|
-
*/
|
|
60
|
-
interface RuntimeWorkspaceConfig {
|
|
61
|
-
/** API proxy path (e.g., '/api') */
|
|
62
|
-
proxy: string;
|
|
63
|
-
/** API host URL (e.g., 'https://project.bagel.to') */
|
|
64
|
-
host: string;
|
|
65
|
-
/** OpenAPI specification URL (if configured) */
|
|
66
|
-
openapiUrl?: string;
|
|
67
|
-
/** Current environment mode */
|
|
68
|
-
mode: 'localhost' | 'development' | 'production';
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get workspace configuration at runtime
|
|
72
|
-
* Config is injected as environment variables during build
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* import { useWorkspace } from '@bagelink/workspace'
|
|
77
|
-
*
|
|
78
|
-
* const { proxy, host } = useWorkspace()
|
|
79
|
-
* const auth = initAuth({ baseURL: proxy })
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example In Vue component
|
|
83
|
-
* ```vue
|
|
84
|
-
* <script setup>
|
|
85
|
-
* import { useWorkspace } from '@bagelink/workspace'
|
|
86
|
-
*
|
|
87
|
-
* const { proxy, host, mode } = useWorkspace()
|
|
88
|
-
* </script>
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare function useWorkspace(): RuntimeWorkspaceConfig;
|
|
92
|
-
/**
|
|
93
|
-
* Get the full API URL by combining host and proxy
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* import { getApiUrl } from '@bagelink/workspace'
|
|
98
|
-
*
|
|
99
|
-
* const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
declare function getApiUrl(): string;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Detect if current directory is a workspace root
|
|
106
|
-
*/
|
|
107
|
-
declare function isWorkspace(root?: string): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Get workspace info
|
|
110
|
-
*/
|
|
111
|
-
declare function getWorkspaceInfo(root?: string): {
|
|
112
|
-
isWorkspace: boolean;
|
|
113
|
-
projects: string[];
|
|
114
|
-
hasShared: boolean;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
declare function runDev(filter?: string, additionalArgs?: string[]): Promise<number>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Set up linting in a project
|
|
121
|
-
*/
|
|
122
|
-
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Generate SDK from OpenAPI spec
|
|
126
|
-
*/
|
|
127
|
-
declare function generateSDK(root?: string): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Generate SDK for all projects in workspace
|
|
130
|
-
*/
|
|
131
|
-
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Initialize a new workspace with flat structure
|
|
135
|
-
*/
|
|
136
|
-
declare function initWorkspace(root?: string): Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Add a new project to the workspace
|
|
139
|
-
*/
|
|
140
|
-
declare function addProject(name: string, root?: string): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* List all projects in workspace
|
|
143
|
-
*/
|
|
144
|
-
declare function listProjects(root?: string): string[];
|
|
1
|
+
import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.D1xukL92.js';
|
|
2
|
+
export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.D1xukL92.js';
|
|
3
|
+
export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.js';
|
|
145
4
|
|
|
146
5
|
/**
|
|
147
6
|
* Define workspace configuration
|
|
148
7
|
* Simple helper to get config from a config map
|
|
149
8
|
*/
|
|
150
9
|
declare function defineWorkspace(configs: Record<WorkspaceEnvironment, WorkspaceConfig>): (mode?: WorkspaceEnvironment) => WorkspaceConfig;
|
|
151
|
-
/**
|
|
152
|
-
* Create a workspace instance for managing project configuration
|
|
153
|
-
* Supports both single project and monorepo setups
|
|
154
|
-
*/
|
|
155
|
-
declare function createWorkspace(options?: WorkspaceOptions): {
|
|
156
|
-
/**
|
|
157
|
-
* Get resolved config for the specified environment
|
|
158
|
-
*/
|
|
159
|
-
getConfig(mode?: WorkspaceEnvironment): Promise<WorkspaceConfig>;
|
|
160
|
-
/**
|
|
161
|
-
* Create Vite proxy configuration
|
|
162
|
-
*/
|
|
163
|
-
createProxy(config: WorkspaceConfig): ProxyConfig;
|
|
164
|
-
/**
|
|
165
|
-
* Generate Netlify configuration file
|
|
166
|
-
*/
|
|
167
|
-
generateNetlify(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
168
|
-
/**
|
|
169
|
-
* Set build environment variables
|
|
170
|
-
*/
|
|
171
|
-
setBuildEnv(config: WorkspaceConfig): void;
|
|
172
|
-
/**
|
|
173
|
-
* Clear cached configuration
|
|
174
|
-
*/
|
|
175
|
-
clearCache(): void;
|
|
176
|
-
};
|
|
177
10
|
|
|
178
|
-
export {
|
|
179
|
-
export type { RuntimeWorkspaceConfig };
|
|
11
|
+
export { WorkspaceConfig, WorkspaceEnvironment, defineWorkspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,133 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { resolve, join } from 'node:path';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { g as generateWorkspaceConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.PLrsjsJ2.mjs';
|
|
5
|
-
export { j as addProject, a as generateNetlifyConfig, b as generateNetlifyRedirect, f as generateSDK, h as generateSDKForWorkspace, c as generateWorkspaceConfigSync, d as getWorkspaceInfo, k as initWorkspace, i as isWorkspace, l as listProjects, r as runDev, e as setupLint } from './shared/workspace.PLrsjsJ2.mjs';
|
|
6
|
-
import { c as createViteProxy } from './shared/workspace.D0MF8ERh.mjs';
|
|
7
|
-
export { b as bagelink, a as createCustomProxy } from './shared/workspace.D0MF8ERh.mjs';
|
|
8
|
-
import 'prompts';
|
|
9
|
-
import 'node:child_process';
|
|
10
|
-
import 'node:url';
|
|
11
|
-
|
|
12
|
-
async function resolveConfig(mode = "development", options = {}) {
|
|
13
|
-
const root = options.root ?? process.cwd();
|
|
14
|
-
const configFile = options.configFile ?? "bgl.config.ts";
|
|
15
|
-
const localConfigPath = resolve(root, configFile);
|
|
16
|
-
const localConfig = await loadConfig(localConfigPath, mode);
|
|
17
|
-
if (localConfig) {
|
|
18
|
-
return localConfig;
|
|
19
|
-
}
|
|
20
|
-
let currentDir = root;
|
|
21
|
-
const rootDir = resolve("/");
|
|
22
|
-
while (currentDir !== rootDir) {
|
|
23
|
-
const parentDir = resolve(currentDir, "..");
|
|
24
|
-
const parentConfigPath = join(parentDir, configFile);
|
|
25
|
-
if (existsSync(parentConfigPath)) {
|
|
26
|
-
const config = await loadConfig(parentConfigPath, mode);
|
|
27
|
-
if (config) {
|
|
28
|
-
return config;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
currentDir = parentDir;
|
|
32
|
-
}
|
|
33
|
-
if (options.interactive !== false) {
|
|
34
|
-
await generateWorkspaceConfig(root, configFile);
|
|
35
|
-
const newConfig = await loadConfig(localConfigPath, mode);
|
|
36
|
-
if (newConfig) {
|
|
37
|
-
return newConfig;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`No bgl.config.ts found in ${root} or parent directories`);
|
|
41
|
-
}
|
|
42
|
-
async function loadConfig(configPath, mode) {
|
|
43
|
-
if (!existsSync(configPath)) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const module = await import(`file://${configPath}`);
|
|
48
|
-
const configMap = module.default ?? module.configs ?? module.config;
|
|
49
|
-
if (typeof configMap === "function") {
|
|
50
|
-
return configMap(mode);
|
|
51
|
-
}
|
|
52
|
-
if (typeof configMap === "object" && configMap !== null) {
|
|
53
|
-
const modeConfig = configMap[mode];
|
|
54
|
-
if (mode in configMap && modeConfig !== void 0 && modeConfig !== null) {
|
|
55
|
-
return modeConfig;
|
|
56
|
-
}
|
|
57
|
-
return configMap;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.warn(`Failed to load config from ${configPath}:`, error);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function mergeConfigs(base, override) {
|
|
66
|
-
return {
|
|
67
|
-
...base,
|
|
68
|
-
...override
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function useWorkspace() {
|
|
73
|
-
const proxy = import.meta.env.VITE_BGL_PROXY || "/api";
|
|
74
|
-
const host = import.meta.env.VITE_BGL_HOST || "";
|
|
75
|
-
const openapiUrl = import.meta.env.VITE_BGL_OPENAPI_URL;
|
|
76
|
-
const mode = import.meta.env.MODE || "development";
|
|
77
|
-
return {
|
|
78
|
-
proxy,
|
|
79
|
-
host,
|
|
80
|
-
openapiUrl,
|
|
81
|
-
mode
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function getApiUrl() {
|
|
85
|
-
const { host, proxy } = useWorkspace();
|
|
86
|
-
return `${host}${proxy}`;
|
|
87
|
-
}
|
|
1
|
+
export { getApiUrl, useWorkspace } from './composable.mjs';
|
|
88
2
|
|
|
89
3
|
function defineWorkspace(configs) {
|
|
90
4
|
return (mode = "development") => {
|
|
91
5
|
return configs[mode] || configs.development;
|
|
92
6
|
};
|
|
93
7
|
}
|
|
94
|
-
function createWorkspace(options = {}) {
|
|
95
|
-
let cachedConfig = null;
|
|
96
|
-
return {
|
|
97
|
-
/**
|
|
98
|
-
* Get resolved config for the specified environment
|
|
99
|
-
*/
|
|
100
|
-
async getConfig(mode = "development") {
|
|
101
|
-
if (!cachedConfig) {
|
|
102
|
-
cachedConfig = await resolveConfig(mode, options);
|
|
103
|
-
}
|
|
104
|
-
return cachedConfig;
|
|
105
|
-
},
|
|
106
|
-
/**
|
|
107
|
-
* Create Vite proxy configuration
|
|
108
|
-
*/
|
|
109
|
-
createProxy(config) {
|
|
110
|
-
return createViteProxy(config);
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Generate Netlify configuration file
|
|
114
|
-
*/
|
|
115
|
-
generateNetlify(config, outPath = "./netlify.toml", additionalConfig) {
|
|
116
|
-
writeNetlifyConfig(config, outPath, additionalConfig);
|
|
117
|
-
},
|
|
118
|
-
/**
|
|
119
|
-
* Set build environment variables
|
|
120
|
-
*/
|
|
121
|
-
setBuildEnv(config) {
|
|
122
|
-
setBuildEnvVars(config);
|
|
123
|
-
},
|
|
124
|
-
/**
|
|
125
|
-
* Clear cached configuration
|
|
126
|
-
*/
|
|
127
|
-
clearCache() {
|
|
128
|
-
cachedConfig = null;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
8
|
|
|
133
|
-
export {
|
|
9
|
+
export { defineWorkspace };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
2
|
+
interface WorkspaceConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The host URL of the backend API server
|
|
5
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
6
|
+
*/
|
|
7
|
+
host: string;
|
|
8
|
+
/**
|
|
9
|
+
* The proxy path to use for API requests
|
|
10
|
+
* @default '/api'
|
|
11
|
+
*/
|
|
12
|
+
proxy: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
15
|
+
*/
|
|
16
|
+
openapi_url?: string;
|
|
17
|
+
}
|
|
18
|
+
interface WorkspaceOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Root directory of the workspace
|
|
21
|
+
* @default process.cwd()
|
|
22
|
+
*/
|
|
23
|
+
root?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Path to the config file relative to root
|
|
26
|
+
* @default 'bgl.config.ts'
|
|
27
|
+
*/
|
|
28
|
+
configFile?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Enable interactive config generation if no config is found
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
interactive?: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface ProxyConfig {
|
|
36
|
+
[path: string]: {
|
|
37
|
+
target: string;
|
|
38
|
+
changeOrigin: boolean;
|
|
39
|
+
rewrite?: (path: string) => string;
|
|
40
|
+
secure: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type { ProxyConfig as P, WorkspaceEnvironment as W, WorkspaceConfig as a, WorkspaceOptions as b };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
2
|
+
interface WorkspaceConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The host URL of the backend API server
|
|
5
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
6
|
+
*/
|
|
7
|
+
host: string;
|
|
8
|
+
/**
|
|
9
|
+
* The proxy path to use for API requests
|
|
10
|
+
* @default '/api'
|
|
11
|
+
*/
|
|
12
|
+
proxy: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
15
|
+
*/
|
|
16
|
+
openapi_url?: string;
|
|
17
|
+
}
|
|
18
|
+
interface WorkspaceOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Root directory of the workspace
|
|
21
|
+
* @default process.cwd()
|
|
22
|
+
*/
|
|
23
|
+
root?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Path to the config file relative to root
|
|
26
|
+
* @default 'bgl.config.ts'
|
|
27
|
+
*/
|
|
28
|
+
configFile?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Enable interactive config generation if no config is found
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
interactive?: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface ProxyConfig {
|
|
36
|
+
[path: string]: {
|
|
37
|
+
target: string;
|
|
38
|
+
changeOrigin: boolean;
|
|
39
|
+
rewrite?: (path: string) => string;
|
|
40
|
+
secure: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type { ProxyConfig as P, WorkspaceEnvironment as W, WorkspaceConfig as a, WorkspaceOptions as b };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
2
|
+
interface WorkspaceConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The host URL of the backend API server
|
|
5
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
6
|
+
*/
|
|
7
|
+
host: string;
|
|
8
|
+
/**
|
|
9
|
+
* The proxy path to use for API requests
|
|
10
|
+
* @default '/api'
|
|
11
|
+
*/
|
|
12
|
+
proxy: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
15
|
+
*/
|
|
16
|
+
openapi_url?: string;
|
|
17
|
+
}
|
|
18
|
+
interface WorkspaceOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Root directory of the workspace
|
|
21
|
+
* @default process.cwd()
|
|
22
|
+
*/
|
|
23
|
+
root?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Path to the config file relative to root
|
|
26
|
+
* @default 'bgl.config.ts'
|
|
27
|
+
*/
|
|
28
|
+
configFile?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Enable interactive config generation if no config is found
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
interactive?: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface ProxyConfig {
|
|
36
|
+
[path: string]: {
|
|
37
|
+
target: string;
|
|
38
|
+
changeOrigin: boolean;
|
|
39
|
+
rewrite?: (path: string) => string;
|
|
40
|
+
secure: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type { ProxyConfig as P, WorkspaceEnvironment as W, WorkspaceConfig as a, WorkspaceOptions as b };
|