@bagelink/workspace 1.10.7 → 1.10.11
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 +214 -9
- package/bin/bgl.ts +88 -2
- package/dist/bin/bgl.cjs +854 -14
- package/dist/bin/bgl.mjs +845 -6
- package/dist/composable.cjs +22 -0
- package/dist/composable.d.cts +52 -0
- package/dist/composable.d.mts +52 -0
- package/dist/composable.d.ts +52 -0
- package/dist/composable.mjs +19 -0
- package/dist/index.cjs +3 -160
- package/dist/index.d.cts +4 -160
- package/dist/index.d.mts +4 -160
- package/dist/index.d.ts +4 -160
- package/dist/index.mjs +2 -139
- package/dist/shared/workspace.Bc_dpzhA.mjs +500 -0
- package/dist/shared/workspace.BzlV5kcN.d.cts +50 -0
- package/dist/shared/workspace.BzlV5kcN.d.mts +50 -0
- package/dist/shared/workspace.BzlV5kcN.d.ts +50 -0
- package/dist/shared/workspace.DRlDHdPw.cjs +512 -0
- package/dist/vite.cjs +135 -0
- package/dist/vite.d.cts +98 -0
- package/dist/vite.d.mts +98 -0
- package/dist/vite.d.ts +98 -0
- package/dist/vite.mjs +125 -0
- package/env.d.ts +30 -0
- package/package.json +24 -3
- package/src/build.ts +45 -0
- package/src/composable.ts +70 -0
- package/src/dev.ts +171 -0
- package/src/index.ts +4 -78
- package/src/init.ts +72 -14
- package/src/lint.ts +90 -2
- package/src/netlify.ts +54 -3
- package/src/proxy.ts +23 -3
- package/src/sdk.ts +80 -44
- package/src/types.ts +10 -4
- package/src/vite.ts +166 -0
- package/src/workspace.ts +121 -16
- package/templates/dev-runner.ts +61 -0
- package/templates/tsconfig.app.json +23 -0
- package/dist/shared/workspace.BPEOymAx.cjs +0 -926
- package/dist/shared/workspace.DfYoqH33.mjs +0 -906
package/dist/index.d.mts
CHANGED
|
@@ -1,167 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
/**
|
|
45
|
-
* Load and resolve bgl.config.ts with cascading support
|
|
46
|
-
* Looks for config files from current directory up to workspace root
|
|
47
|
-
* If no config is found, prompts to create one interactively
|
|
48
|
-
*/
|
|
49
|
-
declare function resolveConfig(mode?: WorkspaceEnvironment, options?: WorkspaceOptions): Promise<WorkspaceConfig>;
|
|
50
|
-
/**
|
|
51
|
-
* Merge two configs, with the second one taking precedence
|
|
52
|
-
*/
|
|
53
|
-
declare function mergeConfigs(base: WorkspaceConfig, override: Partial<WorkspaceConfig>): WorkspaceConfig;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Generate bgl.config.ts file interactively
|
|
57
|
-
*/
|
|
58
|
-
declare function generateWorkspaceConfig(root?: string, configFile?: string): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Generate bgl.config.ts non-interactively
|
|
61
|
-
*/
|
|
62
|
-
declare function generateWorkspaceConfigSync(projectId: string, root?: string, configFile?: string, customHost?: string): void;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Generate netlify.toml redirect configuration
|
|
66
|
-
*/
|
|
67
|
-
declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
|
|
68
|
-
/**
|
|
69
|
-
* Generate complete netlify.toml file
|
|
70
|
-
*/
|
|
71
|
-
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string): string;
|
|
72
|
-
/**
|
|
73
|
-
* Write netlify.toml file to disk
|
|
74
|
-
*/
|
|
75
|
-
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
76
|
-
/**
|
|
77
|
-
* Set environment variables for build process
|
|
78
|
-
*/
|
|
79
|
-
declare function setBuildEnvVars(config: WorkspaceConfig): void;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Create Vite proxy configuration from WorkspaceConfig
|
|
83
|
-
*/
|
|
84
|
-
declare function createViteProxy(config: WorkspaceConfig): ProxyConfig;
|
|
85
|
-
/**
|
|
86
|
-
* Create custom proxy configuration
|
|
87
|
-
*/
|
|
88
|
-
declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
89
|
-
changeOrigin?: boolean;
|
|
90
|
-
rewrite?: boolean;
|
|
91
|
-
secure?: boolean;
|
|
92
|
-
}): ProxyConfig;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Set up linting in a project
|
|
96
|
-
*/
|
|
97
|
-
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Generate SDK from OpenAPI spec
|
|
101
|
-
*/
|
|
102
|
-
declare function generateSDK(root?: string): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Generate SDK for all projects in workspace
|
|
105
|
-
*/
|
|
106
|
-
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Initialize a new workspace with flat structure
|
|
110
|
-
*/
|
|
111
|
-
declare function initWorkspace(root?: string): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Add a new project to the workspace
|
|
114
|
-
*/
|
|
115
|
-
declare function addProject(name: string, root?: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* List all projects in workspace
|
|
118
|
-
*/
|
|
119
|
-
declare function listProjects(root?: string): string[];
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Detect if current directory is a workspace root
|
|
123
|
-
*/
|
|
124
|
-
declare function isWorkspace(root?: string): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Get workspace info
|
|
127
|
-
*/
|
|
128
|
-
declare function getWorkspaceInfo(root?: string): {
|
|
129
|
-
isWorkspace: boolean;
|
|
130
|
-
projects: string[];
|
|
131
|
-
hasShared: boolean;
|
|
132
|
-
};
|
|
1
|
+
import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.BzlV5kcN.mjs';
|
|
2
|
+
export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.BzlV5kcN.mjs';
|
|
3
|
+
export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.mjs';
|
|
133
4
|
|
|
134
5
|
/**
|
|
135
6
|
* Define workspace configuration
|
|
136
7
|
* Simple helper to get config from a config map
|
|
137
8
|
*/
|
|
138
9
|
declare function defineWorkspace(configs: Record<WorkspaceEnvironment, WorkspaceConfig>): (mode?: WorkspaceEnvironment) => WorkspaceConfig;
|
|
139
|
-
/**
|
|
140
|
-
* Create a workspace instance for managing project configuration
|
|
141
|
-
* Supports both single project and monorepo setups
|
|
142
|
-
*/
|
|
143
|
-
declare function createWorkspace(options?: WorkspaceOptions): {
|
|
144
|
-
/**
|
|
145
|
-
* Get resolved config for the specified environment
|
|
146
|
-
*/
|
|
147
|
-
getConfig(mode?: WorkspaceEnvironment): Promise<WorkspaceConfig>;
|
|
148
|
-
/**
|
|
149
|
-
* Create Vite proxy configuration
|
|
150
|
-
*/
|
|
151
|
-
createProxy(config: WorkspaceConfig): ProxyConfig;
|
|
152
|
-
/**
|
|
153
|
-
* Generate Netlify configuration file
|
|
154
|
-
*/
|
|
155
|
-
generateNetlify(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
156
|
-
/**
|
|
157
|
-
* Set build environment variables
|
|
158
|
-
*/
|
|
159
|
-
setBuildEnv(config: WorkspaceConfig): void;
|
|
160
|
-
/**
|
|
161
|
-
* Clear cached configuration
|
|
162
|
-
*/
|
|
163
|
-
clearCache(): void;
|
|
164
|
-
};
|
|
165
10
|
|
|
166
|
-
export {
|
|
167
|
-
export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
|
|
11
|
+
export { WorkspaceConfig, WorkspaceEnvironment, defineWorkspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,167 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
/**
|
|
45
|
-
* Load and resolve bgl.config.ts with cascading support
|
|
46
|
-
* Looks for config files from current directory up to workspace root
|
|
47
|
-
* If no config is found, prompts to create one interactively
|
|
48
|
-
*/
|
|
49
|
-
declare function resolveConfig(mode?: WorkspaceEnvironment, options?: WorkspaceOptions): Promise<WorkspaceConfig>;
|
|
50
|
-
/**
|
|
51
|
-
* Merge two configs, with the second one taking precedence
|
|
52
|
-
*/
|
|
53
|
-
declare function mergeConfigs(base: WorkspaceConfig, override: Partial<WorkspaceConfig>): WorkspaceConfig;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Generate bgl.config.ts file interactively
|
|
57
|
-
*/
|
|
58
|
-
declare function generateWorkspaceConfig(root?: string, configFile?: string): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Generate bgl.config.ts non-interactively
|
|
61
|
-
*/
|
|
62
|
-
declare function generateWorkspaceConfigSync(projectId: string, root?: string, configFile?: string, customHost?: string): void;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Generate netlify.toml redirect configuration
|
|
66
|
-
*/
|
|
67
|
-
declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
|
|
68
|
-
/**
|
|
69
|
-
* Generate complete netlify.toml file
|
|
70
|
-
*/
|
|
71
|
-
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string): string;
|
|
72
|
-
/**
|
|
73
|
-
* Write netlify.toml file to disk
|
|
74
|
-
*/
|
|
75
|
-
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
76
|
-
/**
|
|
77
|
-
* Set environment variables for build process
|
|
78
|
-
*/
|
|
79
|
-
declare function setBuildEnvVars(config: WorkspaceConfig): void;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Create Vite proxy configuration from WorkspaceConfig
|
|
83
|
-
*/
|
|
84
|
-
declare function createViteProxy(config: WorkspaceConfig): ProxyConfig;
|
|
85
|
-
/**
|
|
86
|
-
* Create custom proxy configuration
|
|
87
|
-
*/
|
|
88
|
-
declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
89
|
-
changeOrigin?: boolean;
|
|
90
|
-
rewrite?: boolean;
|
|
91
|
-
secure?: boolean;
|
|
92
|
-
}): ProxyConfig;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Set up linting in a project
|
|
96
|
-
*/
|
|
97
|
-
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Generate SDK from OpenAPI spec
|
|
101
|
-
*/
|
|
102
|
-
declare function generateSDK(root?: string): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Generate SDK for all projects in workspace
|
|
105
|
-
*/
|
|
106
|
-
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Initialize a new workspace with flat structure
|
|
110
|
-
*/
|
|
111
|
-
declare function initWorkspace(root?: string): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Add a new project to the workspace
|
|
114
|
-
*/
|
|
115
|
-
declare function addProject(name: string, root?: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* List all projects in workspace
|
|
118
|
-
*/
|
|
119
|
-
declare function listProjects(root?: string): string[];
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Detect if current directory is a workspace root
|
|
123
|
-
*/
|
|
124
|
-
declare function isWorkspace(root?: string): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Get workspace info
|
|
127
|
-
*/
|
|
128
|
-
declare function getWorkspaceInfo(root?: string): {
|
|
129
|
-
isWorkspace: boolean;
|
|
130
|
-
projects: string[];
|
|
131
|
-
hasShared: boolean;
|
|
132
|
-
};
|
|
1
|
+
import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.BzlV5kcN.js';
|
|
2
|
+
export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.BzlV5kcN.js';
|
|
3
|
+
export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.js';
|
|
133
4
|
|
|
134
5
|
/**
|
|
135
6
|
* Define workspace configuration
|
|
136
7
|
* Simple helper to get config from a config map
|
|
137
8
|
*/
|
|
138
9
|
declare function defineWorkspace(configs: Record<WorkspaceEnvironment, WorkspaceConfig>): (mode?: WorkspaceEnvironment) => WorkspaceConfig;
|
|
139
|
-
/**
|
|
140
|
-
* Create a workspace instance for managing project configuration
|
|
141
|
-
* Supports both single project and monorepo setups
|
|
142
|
-
*/
|
|
143
|
-
declare function createWorkspace(options?: WorkspaceOptions): {
|
|
144
|
-
/**
|
|
145
|
-
* Get resolved config for the specified environment
|
|
146
|
-
*/
|
|
147
|
-
getConfig(mode?: WorkspaceEnvironment): Promise<WorkspaceConfig>;
|
|
148
|
-
/**
|
|
149
|
-
* Create Vite proxy configuration
|
|
150
|
-
*/
|
|
151
|
-
createProxy(config: WorkspaceConfig): ProxyConfig;
|
|
152
|
-
/**
|
|
153
|
-
* Generate Netlify configuration file
|
|
154
|
-
*/
|
|
155
|
-
generateNetlify(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
156
|
-
/**
|
|
157
|
-
* Set build environment variables
|
|
158
|
-
*/
|
|
159
|
-
setBuildEnv(config: WorkspaceConfig): void;
|
|
160
|
-
/**
|
|
161
|
-
* Clear cached configuration
|
|
162
|
-
*/
|
|
163
|
-
clearCache(): void;
|
|
164
|
-
};
|
|
165
10
|
|
|
166
|
-
export {
|
|
167
|
-
export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
|
|
11
|
+
export { WorkspaceConfig, WorkspaceEnvironment, defineWorkspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,146 +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.DfYoqH33.mjs';
|
|
5
|
-
export { h as addProject, a as generateNetlifyConfig, b as generateNetlifyRedirect, e as generateSDK, f as generateSDKForWorkspace, c as generateWorkspaceConfigSync, j as getWorkspaceInfo, i as initWorkspace, k as isWorkspace, l as listProjects, d as setupLint } from './shared/workspace.DfYoqH33.mjs';
|
|
6
|
-
import 'prompts';
|
|
7
|
-
|
|
8
|
-
async function resolveConfig(mode = "development", options = {}) {
|
|
9
|
-
const root = options.root ?? process.cwd();
|
|
10
|
-
const configFile = options.configFile ?? "bgl.config.ts";
|
|
11
|
-
const localConfigPath = resolve(root, configFile);
|
|
12
|
-
const localConfig = await loadConfig(localConfigPath, mode);
|
|
13
|
-
if (localConfig) {
|
|
14
|
-
return localConfig;
|
|
15
|
-
}
|
|
16
|
-
let currentDir = root;
|
|
17
|
-
const rootDir = resolve("/");
|
|
18
|
-
while (currentDir !== rootDir) {
|
|
19
|
-
const parentDir = resolve(currentDir, "..");
|
|
20
|
-
const parentConfigPath = join(parentDir, configFile);
|
|
21
|
-
if (existsSync(parentConfigPath)) {
|
|
22
|
-
const config = await loadConfig(parentConfigPath, mode);
|
|
23
|
-
if (config) {
|
|
24
|
-
return config;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
currentDir = parentDir;
|
|
28
|
-
}
|
|
29
|
-
if (options.interactive !== false) {
|
|
30
|
-
await generateWorkspaceConfig(root, configFile);
|
|
31
|
-
const newConfig = await loadConfig(localConfigPath, mode);
|
|
32
|
-
if (newConfig) {
|
|
33
|
-
return newConfig;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
throw new Error(`No bgl.config.ts found in ${root} or parent directories`);
|
|
37
|
-
}
|
|
38
|
-
async function loadConfig(configPath, mode) {
|
|
39
|
-
if (!existsSync(configPath)) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const module = await import(`file://${configPath}`);
|
|
44
|
-
const configMap = module.default ?? module.configs ?? module.config;
|
|
45
|
-
if (typeof configMap === "function") {
|
|
46
|
-
return configMap(mode);
|
|
47
|
-
}
|
|
48
|
-
if (typeof configMap === "object" && configMap !== null) {
|
|
49
|
-
const modeConfig = configMap[mode];
|
|
50
|
-
if (mode in configMap && modeConfig !== void 0 && modeConfig !== null) {
|
|
51
|
-
return modeConfig;
|
|
52
|
-
}
|
|
53
|
-
return configMap;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.warn(`Failed to load config from ${configPath}:`, error);
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function mergeConfigs(base, override) {
|
|
62
|
-
return {
|
|
63
|
-
...base,
|
|
64
|
-
...override
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function createViteProxy(config) {
|
|
69
|
-
const proxy = {};
|
|
70
|
-
if (config.proxy && config.host) {
|
|
71
|
-
proxy[config.proxy] = {
|
|
72
|
-
target: config.host,
|
|
73
|
-
changeOrigin: true,
|
|
74
|
-
rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
|
|
75
|
-
secure: true
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
if (config.host) {
|
|
79
|
-
proxy["/files"] = {
|
|
80
|
-
target: config.host,
|
|
81
|
-
changeOrigin: true,
|
|
82
|
-
secure: true
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return proxy;
|
|
86
|
-
}
|
|
87
|
-
function createCustomProxy(paths, target, options = {}) {
|
|
88
|
-
const proxy = {};
|
|
89
|
-
for (const path of paths) {
|
|
90
|
-
proxy[path] = {
|
|
91
|
-
target,
|
|
92
|
-
changeOrigin: options.changeOrigin ?? true,
|
|
93
|
-
secure: options.secure ?? true,
|
|
94
|
-
...options.rewrite === true && {
|
|
95
|
-
rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return proxy;
|
|
100
|
-
}
|
|
1
|
+
export { getApiUrl, useWorkspace } from './composable.mjs';
|
|
101
2
|
|
|
102
3
|
function defineWorkspace(configs) {
|
|
103
4
|
return (mode = "development") => {
|
|
104
5
|
return configs[mode] || configs.development;
|
|
105
6
|
};
|
|
106
7
|
}
|
|
107
|
-
function createWorkspace(options = {}) {
|
|
108
|
-
let cachedConfig = null;
|
|
109
|
-
return {
|
|
110
|
-
/**
|
|
111
|
-
* Get resolved config for the specified environment
|
|
112
|
-
*/
|
|
113
|
-
async getConfig(mode = "development") {
|
|
114
|
-
if (!cachedConfig) {
|
|
115
|
-
cachedConfig = await resolveConfig(mode, options);
|
|
116
|
-
}
|
|
117
|
-
return cachedConfig;
|
|
118
|
-
},
|
|
119
|
-
/**
|
|
120
|
-
* Create Vite proxy configuration
|
|
121
|
-
*/
|
|
122
|
-
createProxy(config) {
|
|
123
|
-
return createViteProxy(config);
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* Generate Netlify configuration file
|
|
127
|
-
*/
|
|
128
|
-
generateNetlify(config, outPath = "./netlify.toml", additionalConfig) {
|
|
129
|
-
writeNetlifyConfig(config, outPath, additionalConfig);
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* Set build environment variables
|
|
133
|
-
*/
|
|
134
|
-
setBuildEnv(config) {
|
|
135
|
-
setBuildEnvVars(config);
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Clear cached configuration
|
|
139
|
-
*/
|
|
140
|
-
clearCache() {
|
|
141
|
-
cachedConfig = null;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
8
|
|
|
146
|
-
export {
|
|
9
|
+
export { defineWorkspace };
|