@bagelink/workspace 1.7.33 → 1.7.37
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 +137 -4
- package/bin/bgl.ts +12 -2
- package/dist/bin/bgl.cjs +9 -4
- package/dist/bin/bgl.mjs +9 -4
- package/dist/index.cjs +23 -35
- package/dist/index.d.cts +56 -46
- package/dist/index.d.mts +56 -46
- package/dist/index.d.ts +56 -46
- package/dist/index.mjs +20 -34
- package/dist/shared/workspace.CSNgk3PR.d.cts +113 -0
- package/dist/shared/workspace.CSNgk3PR.d.mts +113 -0
- package/dist/shared/workspace.CSNgk3PR.d.ts +113 -0
- package/dist/shared/{workspace.OuHxYc4s.cjs → workspace.CamNrnD_.cjs} +85 -28
- package/dist/shared/workspace.D0MF8ERh.mjs +79 -0
- package/dist/shared/workspace.DfLGMczD.cjs +87 -0
- package/dist/shared/{workspace.CcKgYZPx.mjs → workspace.PLrsjsJ2.mjs} +85 -28
- package/dist/vite.cjs +9 -0
- package/dist/vite.d.cts +2 -0
- package/dist/vite.d.mts +2 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.mjs +3 -0
- package/env.d.ts +29 -0
- package/package.json +9 -2
- package/src/composable.ts +65 -0
- package/src/index.ts +4 -0
- package/src/init.ts +18 -12
- package/src/netlify.ts +54 -3
- package/src/vite.ts +135 -0
- package/src/workspace.ts +23 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,6 @@
|
|
|
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
|
-
}
|
|
1
|
+
import { W as WorkspaceConfig, a as WorkspaceEnvironment, b as WorkspaceOptions, P as ProxyConfig } from './shared/workspace.CSNgk3PR.js';
|
|
2
|
+
export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.js';
|
|
3
|
+
import 'vite';
|
|
43
4
|
|
|
44
5
|
/**
|
|
45
6
|
* Load and resolve bgl.config.ts with cascading support
|
|
@@ -63,16 +24,17 @@ declare function generateWorkspaceConfigSync(projectId: string, root?: string, c
|
|
|
63
24
|
|
|
64
25
|
/**
|
|
65
26
|
* Generate netlify.toml redirect configuration
|
|
27
|
+
* Uses environment variables for flexibility across environments
|
|
66
28
|
*/
|
|
67
29
|
declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
|
|
68
30
|
/**
|
|
69
31
|
* Generate complete netlify.toml file
|
|
70
32
|
*/
|
|
71
|
-
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string): string;
|
|
33
|
+
declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string, useTemplate?: boolean): string;
|
|
72
34
|
/**
|
|
73
35
|
* Write netlify.toml file to disk
|
|
74
36
|
*/
|
|
75
|
-
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
|
|
37
|
+
declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string, useTemplate?: boolean): void;
|
|
76
38
|
/**
|
|
77
39
|
* Set environment variables for build process
|
|
78
40
|
*/
|
|
@@ -91,6 +53,54 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
|
91
53
|
secure?: boolean;
|
|
92
54
|
}): ProxyConfig;
|
|
93
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
|
+
|
|
94
104
|
/**
|
|
95
105
|
* Detect if current directory is a workspace root
|
|
96
106
|
*/
|
|
@@ -165,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
|
|
|
165
175
|
clearCache(): void;
|
|
166
176
|
};
|
|
167
177
|
|
|
168
|
-
export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, writeNetlifyConfig };
|
|
169
|
-
export type {
|
|
178
|
+
export { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions, addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getApiUrl, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, useWorkspace, writeNetlifyConfig };
|
|
179
|
+
export type { RuntimeWorkspaceConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { resolve, join } from 'node:path';
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import { g as generateWorkspaceConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.
|
|
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.
|
|
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';
|
|
6
8
|
import 'prompts';
|
|
7
9
|
import 'node:child_process';
|
|
10
|
+
import 'node:url';
|
|
8
11
|
|
|
9
12
|
async function resolveConfig(mode = "development", options = {}) {
|
|
10
13
|
const root = options.root ?? process.cwd();
|
|
@@ -66,38 +69,21 @@ function mergeConfigs(base, override) {
|
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
function
|
|
70
|
-
const proxy =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
proxy["/files"] = {
|
|
81
|
-
target: config.host,
|
|
82
|
-
changeOrigin: true,
|
|
83
|
-
secure: true
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return proxy;
|
|
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
|
+
};
|
|
87
83
|
}
|
|
88
|
-
function
|
|
89
|
-
const proxy =
|
|
90
|
-
|
|
91
|
-
proxy[path] = {
|
|
92
|
-
target,
|
|
93
|
-
changeOrigin: options.changeOrigin ?? true,
|
|
94
|
-
secure: options.secure ?? true,
|
|
95
|
-
...options.rewrite === true && {
|
|
96
|
-
rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
return proxy;
|
|
84
|
+
function getApiUrl() {
|
|
85
|
+
const { host, proxy } = useWorkspace();
|
|
86
|
+
return `${host}${proxy}`;
|
|
101
87
|
}
|
|
102
88
|
|
|
103
89
|
function defineWorkspace(configs) {
|
|
@@ -144,4 +130,4 @@ function createWorkspace(options = {}) {
|
|
|
144
130
|
};
|
|
145
131
|
}
|
|
146
132
|
|
|
147
|
-
export {
|
|
133
|
+
export { createViteProxy, createWorkspace, defineWorkspace, generateWorkspaceConfig, getApiUrl, mergeConfigs, resolveConfig, setBuildEnvVars, useWorkspace, writeNetlifyConfig };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
4
|
+
interface WorkspaceConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The host URL of the backend API server
|
|
7
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
8
|
+
*/
|
|
9
|
+
host: string;
|
|
10
|
+
/**
|
|
11
|
+
* The proxy path to use for API requests
|
|
12
|
+
* @default '/api'
|
|
13
|
+
*/
|
|
14
|
+
proxy: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
17
|
+
*/
|
|
18
|
+
openapi_url?: string;
|
|
19
|
+
}
|
|
20
|
+
interface WorkspaceOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Root directory of the workspace
|
|
23
|
+
* @default process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
root?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the config file relative to root
|
|
28
|
+
* @default 'bgl.config.ts'
|
|
29
|
+
*/
|
|
30
|
+
configFile?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enable interactive config generation if no config is found
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
interactive?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface ProxyConfig {
|
|
38
|
+
[path: string]: {
|
|
39
|
+
target: string;
|
|
40
|
+
changeOrigin: boolean;
|
|
41
|
+
rewrite?: (path: string) => string;
|
|
42
|
+
secure: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface BagelinkPluginOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Path to shared package relative to project
|
|
49
|
+
* @default '../shared'
|
|
50
|
+
*/
|
|
51
|
+
sharedPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to include @shared alias
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
includeSharedAlias?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Additional path aliases beyond @ and @shared
|
|
59
|
+
*/
|
|
60
|
+
additionalAliases?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to auto-configure proxy
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
configureProxy?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Vite plugin for Bagelink workspace integration
|
|
69
|
+
* Automatically configures proxy and path aliases based on bgl.config.ts
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { defineConfig } from 'vite'
|
|
74
|
+
* import vue from '@vitejs/plugin-vue'
|
|
75
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
76
|
+
* import workspace from './bgl.config'
|
|
77
|
+
*
|
|
78
|
+
* export default defineConfig({
|
|
79
|
+
* plugins: [
|
|
80
|
+
* vue(),
|
|
81
|
+
* bagelink({ workspace })
|
|
82
|
+
* ]
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example With custom options
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { defineConfig } from 'vite'
|
|
89
|
+
* import vue from '@vitejs/plugin-vue'
|
|
90
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
91
|
+
* import workspace from './bgl.config'
|
|
92
|
+
*
|
|
93
|
+
* export default defineConfig({
|
|
94
|
+
* plugins: [
|
|
95
|
+
* vue(),
|
|
96
|
+
* bagelink({
|
|
97
|
+
* workspace,
|
|
98
|
+
* sharedPath: '../packages/shared',
|
|
99
|
+
* additionalAliases: {
|
|
100
|
+
* '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
|
|
101
|
+
* }
|
|
102
|
+
* })
|
|
103
|
+
* ]
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function bagelink(options: {
|
|
108
|
+
workspace: (mode: WorkspaceEnvironment) => WorkspaceConfig;
|
|
109
|
+
config?: BagelinkPluginOptions;
|
|
110
|
+
}): Plugin;
|
|
111
|
+
|
|
112
|
+
export { bagelink as c };
|
|
113
|
+
export type { BagelinkPluginOptions as B, ProxyConfig as P, WorkspaceConfig as W, WorkspaceEnvironment as a, WorkspaceOptions as b };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
4
|
+
interface WorkspaceConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The host URL of the backend API server
|
|
7
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
8
|
+
*/
|
|
9
|
+
host: string;
|
|
10
|
+
/**
|
|
11
|
+
* The proxy path to use for API requests
|
|
12
|
+
* @default '/api'
|
|
13
|
+
*/
|
|
14
|
+
proxy: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
17
|
+
*/
|
|
18
|
+
openapi_url?: string;
|
|
19
|
+
}
|
|
20
|
+
interface WorkspaceOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Root directory of the workspace
|
|
23
|
+
* @default process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
root?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the config file relative to root
|
|
28
|
+
* @default 'bgl.config.ts'
|
|
29
|
+
*/
|
|
30
|
+
configFile?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enable interactive config generation if no config is found
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
interactive?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface ProxyConfig {
|
|
38
|
+
[path: string]: {
|
|
39
|
+
target: string;
|
|
40
|
+
changeOrigin: boolean;
|
|
41
|
+
rewrite?: (path: string) => string;
|
|
42
|
+
secure: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface BagelinkPluginOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Path to shared package relative to project
|
|
49
|
+
* @default '../shared'
|
|
50
|
+
*/
|
|
51
|
+
sharedPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to include @shared alias
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
includeSharedAlias?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Additional path aliases beyond @ and @shared
|
|
59
|
+
*/
|
|
60
|
+
additionalAliases?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to auto-configure proxy
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
configureProxy?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Vite plugin for Bagelink workspace integration
|
|
69
|
+
* Automatically configures proxy and path aliases based on bgl.config.ts
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { defineConfig } from 'vite'
|
|
74
|
+
* import vue from '@vitejs/plugin-vue'
|
|
75
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
76
|
+
* import workspace from './bgl.config'
|
|
77
|
+
*
|
|
78
|
+
* export default defineConfig({
|
|
79
|
+
* plugins: [
|
|
80
|
+
* vue(),
|
|
81
|
+
* bagelink({ workspace })
|
|
82
|
+
* ]
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example With custom options
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { defineConfig } from 'vite'
|
|
89
|
+
* import vue from '@vitejs/plugin-vue'
|
|
90
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
91
|
+
* import workspace from './bgl.config'
|
|
92
|
+
*
|
|
93
|
+
* export default defineConfig({
|
|
94
|
+
* plugins: [
|
|
95
|
+
* vue(),
|
|
96
|
+
* bagelink({
|
|
97
|
+
* workspace,
|
|
98
|
+
* sharedPath: '../packages/shared',
|
|
99
|
+
* additionalAliases: {
|
|
100
|
+
* '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
|
|
101
|
+
* }
|
|
102
|
+
* })
|
|
103
|
+
* ]
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function bagelink(options: {
|
|
108
|
+
workspace: (mode: WorkspaceEnvironment) => WorkspaceConfig;
|
|
109
|
+
config?: BagelinkPluginOptions;
|
|
110
|
+
}): Plugin;
|
|
111
|
+
|
|
112
|
+
export { bagelink as c };
|
|
113
|
+
export type { BagelinkPluginOptions as B, ProxyConfig as P, WorkspaceConfig as W, WorkspaceEnvironment as a, WorkspaceOptions as b };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
|
|
4
|
+
interface WorkspaceConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The host URL of the backend API server
|
|
7
|
+
* @example 'http://localhost:8000' | 'https://project.bagel.to'
|
|
8
|
+
*/
|
|
9
|
+
host: string;
|
|
10
|
+
/**
|
|
11
|
+
* The proxy path to use for API requests
|
|
12
|
+
* @default '/api'
|
|
13
|
+
*/
|
|
14
|
+
proxy: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional OpenAPI specification URL for SDK generation
|
|
17
|
+
*/
|
|
18
|
+
openapi_url?: string;
|
|
19
|
+
}
|
|
20
|
+
interface WorkspaceOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Root directory of the workspace
|
|
23
|
+
* @default process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
root?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the config file relative to root
|
|
28
|
+
* @default 'bgl.config.ts'
|
|
29
|
+
*/
|
|
30
|
+
configFile?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enable interactive config generation if no config is found
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
interactive?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface ProxyConfig {
|
|
38
|
+
[path: string]: {
|
|
39
|
+
target: string;
|
|
40
|
+
changeOrigin: boolean;
|
|
41
|
+
rewrite?: (path: string) => string;
|
|
42
|
+
secure: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface BagelinkPluginOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Path to shared package relative to project
|
|
49
|
+
* @default '../shared'
|
|
50
|
+
*/
|
|
51
|
+
sharedPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to include @shared alias
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
includeSharedAlias?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Additional path aliases beyond @ and @shared
|
|
59
|
+
*/
|
|
60
|
+
additionalAliases?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to auto-configure proxy
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
configureProxy?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Vite plugin for Bagelink workspace integration
|
|
69
|
+
* Automatically configures proxy and path aliases based on bgl.config.ts
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { defineConfig } from 'vite'
|
|
74
|
+
* import vue from '@vitejs/plugin-vue'
|
|
75
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
76
|
+
* import workspace from './bgl.config'
|
|
77
|
+
*
|
|
78
|
+
* export default defineConfig({
|
|
79
|
+
* plugins: [
|
|
80
|
+
* vue(),
|
|
81
|
+
* bagelink({ workspace })
|
|
82
|
+
* ]
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example With custom options
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { defineConfig } from 'vite'
|
|
89
|
+
* import vue from '@vitejs/plugin-vue'
|
|
90
|
+
* import { bagelink } from '@bagelink/workspace/vite'
|
|
91
|
+
* import workspace from './bgl.config'
|
|
92
|
+
*
|
|
93
|
+
* export default defineConfig({
|
|
94
|
+
* plugins: [
|
|
95
|
+
* vue(),
|
|
96
|
+
* bagelink({
|
|
97
|
+
* workspace,
|
|
98
|
+
* sharedPath: '../packages/shared',
|
|
99
|
+
* additionalAliases: {
|
|
100
|
+
* '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
|
|
101
|
+
* }
|
|
102
|
+
* })
|
|
103
|
+
* ]
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function bagelink(options: {
|
|
108
|
+
workspace: (mode: WorkspaceEnvironment) => WorkspaceConfig;
|
|
109
|
+
config?: BagelinkPluginOptions;
|
|
110
|
+
}): Plugin;
|
|
111
|
+
|
|
112
|
+
export { bagelink as c };
|
|
113
|
+
export type { BagelinkPluginOptions as B, ProxyConfig as P, WorkspaceConfig as W, WorkspaceEnvironment as a, WorkspaceOptions as b };
|