@bagelink/workspace 1.7.35 → 1.7.39

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/dist/index.d.mts CHANGED
@@ -1,47 +1,7 @@
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
- }
1
+ import { W as WorkspaceConfig, a as WorkspaceEnvironment, b as WorkspaceOptions, P as ProxyConfig } from './shared/workspace.CSNgk3PR.mjs';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.mjs';
3
+ export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.mjs';
4
+ import 'vite';
45
5
 
46
6
  /**
47
7
  * Load and resolve bgl.config.ts with cascading support
@@ -94,54 +54,6 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
94
54
  secure?: boolean;
95
55
  }): ProxyConfig;
96
56
 
97
- /**
98
- * Runtime workspace configuration
99
- * Provides access to workspace config injected at build time
100
- */
101
- interface RuntimeWorkspaceConfig {
102
- /** API proxy path (e.g., '/api') */
103
- proxy: string;
104
- /** API host URL (e.g., 'https://project.bagel.to') */
105
- host: string;
106
- /** OpenAPI specification URL (if configured) */
107
- openapiUrl?: string;
108
- /** Current environment mode */
109
- mode: 'localhost' | 'development' | 'production';
110
- }
111
- /**
112
- * Get workspace configuration at runtime
113
- * Config is injected as environment variables during build
114
- *
115
- * @example
116
- * ```ts
117
- * import { useWorkspace } from '@bagelink/workspace'
118
- *
119
- * const { proxy, host } = useWorkspace()
120
- * const auth = initAuth({ baseURL: proxy })
121
- * ```
122
- *
123
- * @example In Vue component
124
- * ```vue
125
- * <script setup>
126
- * import { useWorkspace } from '@bagelink/workspace'
127
- *
128
- * const { proxy, host, mode } = useWorkspace()
129
- * </script>
130
- * ```
131
- */
132
- declare function useWorkspace(): RuntimeWorkspaceConfig;
133
- /**
134
- * Get the full API URL by combining host and proxy
135
- *
136
- * @example
137
- * ```ts
138
- * import { getApiUrl } from '@bagelink/workspace'
139
- *
140
- * const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
141
- * ```
142
- */
143
- declare function getApiUrl(): string;
144
-
145
57
  /**
146
58
  * Detect if current directory is a workspace root
147
59
  */
@@ -171,72 +83,6 @@ declare function generateSDK(root?: string): Promise<void>;
171
83
  */
172
84
  declare function generateSDKForWorkspace(root?: string): Promise<void>;
173
85
 
174
- interface BagelinkPluginOptions {
175
- /**
176
- * Path to shared package relative to project
177
- * @default '../shared'
178
- */
179
- sharedPath?: string;
180
- /**
181
- * Whether to include @shared alias
182
- * @default true
183
- */
184
- includeSharedAlias?: boolean;
185
- /**
186
- * Additional path aliases beyond @ and @shared
187
- */
188
- additionalAliases?: Record<string, string>;
189
- /**
190
- * Whether to auto-configure proxy
191
- * @default true
192
- */
193
- configureProxy?: boolean;
194
- }
195
- /**
196
- * Vite plugin for Bagelink workspace integration
197
- * Automatically configures proxy and path aliases based on bgl.config.ts
198
- *
199
- * @example
200
- * ```ts
201
- * import { defineConfig } from 'vite'
202
- * import vue from '@vitejs/plugin-vue'
203
- * import { bagelink } from '@bagelink/workspace/vite'
204
- * import workspace from './bgl.config'
205
- *
206
- * export default defineConfig({
207
- * plugins: [
208
- * vue(),
209
- * bagelink({ workspace })
210
- * ]
211
- * })
212
- * ```
213
- *
214
- * @example With custom options
215
- * ```ts
216
- * import { defineConfig } from 'vite'
217
- * import vue from '@vitejs/plugin-vue'
218
- * import { bagelink } from '@bagelink/workspace/vite'
219
- * import workspace from './bgl.config'
220
- *
221
- * export default defineConfig({
222
- * plugins: [
223
- * vue(),
224
- * bagelink({
225
- * workspace,
226
- * sharedPath: '../packages/shared',
227
- * additionalAliases: {
228
- * '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
229
- * }
230
- * })
231
- * ]
232
- * })
233
- * ```
234
- */
235
- declare function bagelink(options: {
236
- workspace: (mode: WorkspaceEnvironment) => WorkspaceConfig;
237
- config?: BagelinkPluginOptions;
238
- }): Plugin;
239
-
240
86
  /**
241
87
  * Initialize a new workspace with flat structure
242
88
  */
@@ -282,5 +128,4 @@ declare function createWorkspace(options?: WorkspaceOptions): {
282
128
  clearCache(): void;
283
129
  };
284
130
 
285
- export { addProject, bagelink, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getApiUrl, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, useWorkspace, writeNetlifyConfig };
286
- export type { BagelinkPluginOptions, ProxyConfig, RuntimeWorkspaceConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
131
+ export { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions, addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, writeNetlifyConfig };
package/dist/index.d.ts CHANGED
@@ -1,47 +1,7 @@
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
- }
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
+ export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.js';
4
+ import 'vite';
45
5
 
46
6
  /**
47
7
  * Load and resolve bgl.config.ts with cascading support
@@ -94,54 +54,6 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
94
54
  secure?: boolean;
95
55
  }): ProxyConfig;
96
56
 
97
- /**
98
- * Runtime workspace configuration
99
- * Provides access to workspace config injected at build time
100
- */
101
- interface RuntimeWorkspaceConfig {
102
- /** API proxy path (e.g., '/api') */
103
- proxy: string;
104
- /** API host URL (e.g., 'https://project.bagel.to') */
105
- host: string;
106
- /** OpenAPI specification URL (if configured) */
107
- openapiUrl?: string;
108
- /** Current environment mode */
109
- mode: 'localhost' | 'development' | 'production';
110
- }
111
- /**
112
- * Get workspace configuration at runtime
113
- * Config is injected as environment variables during build
114
- *
115
- * @example
116
- * ```ts
117
- * import { useWorkspace } from '@bagelink/workspace'
118
- *
119
- * const { proxy, host } = useWorkspace()
120
- * const auth = initAuth({ baseURL: proxy })
121
- * ```
122
- *
123
- * @example In Vue component
124
- * ```vue
125
- * <script setup>
126
- * import { useWorkspace } from '@bagelink/workspace'
127
- *
128
- * const { proxy, host, mode } = useWorkspace()
129
- * </script>
130
- * ```
131
- */
132
- declare function useWorkspace(): RuntimeWorkspaceConfig;
133
- /**
134
- * Get the full API URL by combining host and proxy
135
- *
136
- * @example
137
- * ```ts
138
- * import { getApiUrl } from '@bagelink/workspace'
139
- *
140
- * const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
141
- * ```
142
- */
143
- declare function getApiUrl(): string;
144
-
145
57
  /**
146
58
  * Detect if current directory is a workspace root
147
59
  */
@@ -171,72 +83,6 @@ declare function generateSDK(root?: string): Promise<void>;
171
83
  */
172
84
  declare function generateSDKForWorkspace(root?: string): Promise<void>;
173
85
 
174
- interface BagelinkPluginOptions {
175
- /**
176
- * Path to shared package relative to project
177
- * @default '../shared'
178
- */
179
- sharedPath?: string;
180
- /**
181
- * Whether to include @shared alias
182
- * @default true
183
- */
184
- includeSharedAlias?: boolean;
185
- /**
186
- * Additional path aliases beyond @ and @shared
187
- */
188
- additionalAliases?: Record<string, string>;
189
- /**
190
- * Whether to auto-configure proxy
191
- * @default true
192
- */
193
- configureProxy?: boolean;
194
- }
195
- /**
196
- * Vite plugin for Bagelink workspace integration
197
- * Automatically configures proxy and path aliases based on bgl.config.ts
198
- *
199
- * @example
200
- * ```ts
201
- * import { defineConfig } from 'vite'
202
- * import vue from '@vitejs/plugin-vue'
203
- * import { bagelink } from '@bagelink/workspace/vite'
204
- * import workspace from './bgl.config'
205
- *
206
- * export default defineConfig({
207
- * plugins: [
208
- * vue(),
209
- * bagelink({ workspace })
210
- * ]
211
- * })
212
- * ```
213
- *
214
- * @example With custom options
215
- * ```ts
216
- * import { defineConfig } from 'vite'
217
- * import vue from '@vitejs/plugin-vue'
218
- * import { bagelink } from '@bagelink/workspace/vite'
219
- * import workspace from './bgl.config'
220
- *
221
- * export default defineConfig({
222
- * plugins: [
223
- * vue(),
224
- * bagelink({
225
- * workspace,
226
- * sharedPath: '../packages/shared',
227
- * additionalAliases: {
228
- * '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
229
- * }
230
- * })
231
- * ]
232
- * })
233
- * ```
234
- */
235
- declare function bagelink(options: {
236
- workspace: (mode: WorkspaceEnvironment) => WorkspaceConfig;
237
- config?: BagelinkPluginOptions;
238
- }): Plugin;
239
-
240
86
  /**
241
87
  * Initialize a new workspace with flat structure
242
88
  */
@@ -282,5 +128,4 @@ declare function createWorkspace(options?: WorkspaceOptions): {
282
128
  clearCache(): void;
283
129
  };
284
130
 
285
- export { addProject, bagelink, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getApiUrl, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, useWorkspace, writeNetlifyConfig };
286
- export type { BagelinkPluginOptions, ProxyConfig, RuntimeWorkspaceConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
131
+ export { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions, addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, writeNetlifyConfig };
package/dist/index.mjs CHANGED
@@ -3,9 +3,12 @@ import { resolve, join } from 'node:path';
3
3
  import process from 'node:process';
4
4
  import { g as generateWorkspaceConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.PLrsjsJ2.mjs';
5
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 { fileURLToPath } from 'node:url';
6
+ import { c as createViteProxy } from './shared/workspace.D0MF8ERh.mjs';
7
+ export { b as bagelink, a as createCustomProxy } from './shared/workspace.D0MF8ERh.mjs';
8
+ export { getApiUrl, useWorkspace } from './composable.mjs';
7
9
  import 'prompts';
8
10
  import 'node:child_process';
11
+ import 'node:url';
9
12
 
10
13
  async function resolveConfig(mode = "development", options = {}) {
11
14
  const root = options.root ?? process.cwd();
@@ -67,98 +70,6 @@ function mergeConfigs(base, override) {
67
70
  };
68
71
  }
69
72
 
70
- function createViteProxy(config) {
71
- const proxy = {};
72
- if (config.proxy && config.host) {
73
- proxy[config.proxy] = {
74
- target: config.host,
75
- changeOrigin: true,
76
- rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
77
- secure: true
78
- };
79
- }
80
- if (config.host) {
81
- proxy["/files"] = {
82
- target: config.host,
83
- changeOrigin: true,
84
- secure: true
85
- };
86
- }
87
- return proxy;
88
- }
89
- function createCustomProxy(paths, target, options = {}) {
90
- const proxy = {};
91
- for (const path of paths) {
92
- proxy[path] = {
93
- target,
94
- changeOrigin: options.changeOrigin ?? true,
95
- secure: options.secure ?? true,
96
- ...options.rewrite === true && {
97
- rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
98
- }
99
- };
100
- }
101
- return proxy;
102
- }
103
-
104
- function useWorkspace() {
105
- const proxy = import.meta.env.VITE_BGL_PROXY || "/api";
106
- const host = import.meta.env.VITE_BGL_HOST || "";
107
- const openapiUrl = import.meta.env.VITE_BGL_OPENAPI_URL;
108
- const mode = import.meta.env.MODE || "development";
109
- return {
110
- proxy,
111
- host,
112
- openapiUrl,
113
- mode
114
- };
115
- }
116
- function getApiUrl() {
117
- const { host, proxy } = useWorkspace();
118
- return `${host}${proxy}`;
119
- }
120
-
121
- function bagelink(options) {
122
- const { workspace, config = {} } = options;
123
- let workspaceConfig;
124
- return {
125
- name: "vite-plugin-bagelink",
126
- enforce: "pre",
127
- configResolved(resolved) {
128
- workspaceConfig = workspace(resolved.mode);
129
- },
130
- config(userConfig, { mode }) {
131
- workspaceConfig = workspace(mode);
132
- const alias = {};
133
- if (config.includeSharedAlias !== false) {
134
- const sharedPath = config.sharedPath ?? "../shared";
135
- alias["@shared"] = fileURLToPath(new URL(sharedPath, `file://${process.cwd()}/`));
136
- }
137
- alias["@"] = fileURLToPath(new URL("./src", `file://${process.cwd()}/`));
138
- if (config.additionalAliases) {
139
- Object.assign(alias, config.additionalAliases);
140
- }
141
- const server = config.configureProxy !== false ? {
142
- proxy: createViteProxy(workspaceConfig)
143
- } : void 0;
144
- const define = {
145
- "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
146
- "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
147
- ...workspaceConfig.openapi_url && {
148
- "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
149
- }
150
- };
151
- return {
152
- resolve: {
153
- alias
154
- },
155
- define,
156
- ...server && { server }
157
- };
158
- }
159
- };
160
- }
161
-
162
73
  function defineWorkspace(configs) {
163
74
  return (mode = "development") => {
164
75
  return configs[mode] || configs.development;
@@ -203,4 +114,4 @@ function createWorkspace(options = {}) {
203
114
  };
204
115
  }
205
116
 
206
- export { bagelink, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateWorkspaceConfig, getApiUrl, mergeConfigs, resolveConfig, setBuildEnvVars, useWorkspace, writeNetlifyConfig };
117
+ export { createViteProxy, createWorkspace, defineWorkspace, generateWorkspaceConfig, mergeConfigs, resolveConfig, setBuildEnvVars, 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 };