@bagelink/workspace 1.8.37 → 1.8.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 CHANGED
@@ -57,10 +57,15 @@ Create `bgl.config.ts`:
57
57
  import { defineWorkspace } from '@bagelink/workspace'
58
58
  import type { WorkspaceConfig, WorkspaceEnvironment } from '@bagelink/workspace'
59
59
 
60
+ /**
61
+ * Define your workspace environments
62
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
63
+ * Use --mode flag to switch: bgl dev --mode <env_name>
64
+ */
60
65
  const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
61
66
  localhost: {
62
67
  host: 'http://localhost:8000',
63
- proxy: '/api',
68
+ proxy: '/api', // Optional: remove to skip proxy setup
64
69
  openapi_url: 'http://localhost:8000/openapi.json',
65
70
  },
66
71
  development: {
@@ -72,6 +77,11 @@ const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
72
77
  host: 'https://project.bagel.to',
73
78
  proxy: '/api',
74
79
  },
80
+ // Add your own custom environments
81
+ staging: {
82
+ host: 'https://staging.project.bagel.to',
83
+ proxy: '/api',
84
+ },
75
85
  }
76
86
 
77
87
  export default defineWorkspace(configs)
@@ -165,8 +175,8 @@ export default defineConfig(({ mode }) => {
165
175
  import { useWorkspace, getApiUrl } from '@bagelink/workspace'
166
176
 
167
177
  // In your app setup
168
- const { proxy, host, mode } = useWorkspace()
169
- const auth = createAuth({ baseURL: proxy })
178
+ const { baseURL, proxy, host, mode } = useWorkspace()
179
+ const auth = createAuth({ baseURL }) // Uses proxy if available, otherwise host
170
180
 
171
181
  // Or get full API URL
172
182
  const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
@@ -179,8 +189,8 @@ const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
179
189
  import { useWorkspace } from '@bagelink/workspace'
180
190
  import { createAuth } from '@bagelink/auth'
181
191
 
182
- const { proxy, host, mode } = useWorkspace()
183
- const auth = createAuth({ baseURL: proxy })
192
+ const { baseURL, proxy, host, mode } = useWorkspace()
193
+ const auth = createAuth({ baseURL }) // Uses proxy if available, otherwise host
184
194
 
185
195
  console.log('API Host:', host)
186
196
  console.log('Environment:', mode)
@@ -203,12 +213,58 @@ const openapi = import.meta.env.VITE_BGL_OPENAPI_URL // optional
203
213
  "scripts": {
204
214
  "dev": "vite",
205
215
  "dev:local": "vite --mode localhost",
206
- "build": "vite build"
216
+ "dev:staging": "vite --mode staging",
217
+ "build": "vite build",
218
+ "build:staging": "vite build --mode staging"
207
219
  }
208
220
  }
209
221
  ```
210
222
 
211
- ### 5. Generate Netlify Config
223
+ ### 5. Custom Environments
224
+
225
+ You can define as many custom environments as you need. The environment name is completely flexible:
226
+
227
+ ```typescript
228
+ const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
229
+ localhost: {
230
+ host: 'http://localhost:8000',
231
+ proxy: '/api',
232
+ },
233
+ development: {
234
+ host: 'https://dev.project.bagel.to',
235
+ proxy: '/api',
236
+ },
237
+ staging: {
238
+ host: 'https://staging.project.bagel.to',
239
+ proxy: '/api',
240
+ },
241
+ preview: {
242
+ host: 'https://preview.project.bagel.to',
243
+ // No proxy - will use host directly
244
+ },
245
+ production: {
246
+ host: 'https://project.bagel.to',
247
+ proxy: '/api',
248
+ },
249
+ }
250
+ ```
251
+
252
+ Use the `--mode` flag to switch environments:
253
+
254
+ ```bash
255
+ # Development
256
+ bgl dev --mode development
257
+
258
+ # Staging
259
+ bgl dev --mode staging
260
+
261
+ # Production build
262
+ bgl build --mode production
263
+ ```
264
+
265
+ **Note:** The `proxy` field is optional. If omitted, no proxy will be configured for that environment, and `baseURL` from `useWorkspace()` will return the `host` value instead.
266
+
267
+ ### 6. Generate Netlify Config
212
268
 
213
269
  ```typescript
214
270
  import { writeNetlifyConfig } from '@bagelink/workspace'
@@ -516,16 +572,17 @@ Get workspace configuration at runtime. Config is injected as environment variab
516
572
  ```typescript
517
573
  import { useWorkspace } from '@bagelink/workspace'
518
574
 
519
- const { proxy, host, openapiUrl, mode } = useWorkspace()
575
+ const { baseURL, proxy, host, openapiUrl, mode } = useWorkspace()
520
576
  ```
521
577
 
522
578
  **Returns:**
523
579
  ```typescript
524
580
  interface RuntimeWorkspaceConfig {
525
- proxy: string // '/api'
581
+ baseURL: string // proxy if available, otherwise host
582
+ proxy?: string // '/api' (optional)
526
583
  host: string // 'https://project.bagel.to'
527
584
  openapiUrl?: string // optional
528
- mode: 'localhost' | 'development' | 'production'
585
+ mode: string // current environment (e.g., 'localhost', 'development', 'staging')
529
586
  }
530
587
  ```
531
588
 
package/bin/bgl.ts CHANGED
@@ -137,14 +137,19 @@ Usage:
137
137
  bgl add <name> Add a new project to workspace
138
138
  bgl list List all projects in workspace
139
139
  bgl dev [filter] [...args] Run dev servers with clean output (default: './!shared*')
140
- Additional args are passed to vite (e.g., --mode localhost)
140
+ Examples:
141
+ bgl dev --mode localhost
142
+ bgl dev --mode staging
143
+ bgl dev admin --mode production
141
144
  bgl build [project] [...args] Build project by directory (default: all projects)
145
+ Example: bgl build --mode production
142
146
  bgl lint init Set up linting (auto-detects workspace)
143
147
  bgl sdk generate Generate SDK (auto-detects workspace)
144
148
 
145
149
  Options:
146
150
  --workspace, -w Force workspace mode
147
151
  --project, -p Force single project mode
152
+ --mode <env> Set environment (matches bgl.config.ts keys)
148
153
  --help, -h Show this help message
149
154
 
150
155
  Note: Commands auto-detect workspace mode based on directory structure
package/dist/bin/bgl.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
  const node_path = require('node:path');
5
5
  const process = require('node:process');
6
6
  const node_child_process = require('node:child_process');
7
- const netlify = require('../shared/workspace.CuE882NE.cjs');
7
+ const netlify = require('../shared/workspace.Didrexg0.cjs');
8
8
  const node_fs = require('node:fs');
9
9
  const prompts = require('prompts');
10
10
 
@@ -216,10 +216,15 @@ async function generateWorkspaceConfig(root = process__default.cwd(), configFile
216
216
  const configContent = `import { defineWorkspace } from '@bagelink/workspace'
217
217
  import type { WorkspaceConfig, WorkspaceEnvironment } from '@bagelink/workspace'
218
218
 
219
+ /**
220
+ * Define your workspace environments
221
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
222
+ * Use --mode flag to switch: bgl dev --mode <env_name>
223
+ */
219
224
  const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
220
225
  localhost: {
221
226
  host: 'http://localhost:8000',
222
- proxy: '/api',
227
+ proxy: '/api', // Optional: remove to skip proxy setup
223
228
  openapi_url: 'http://localhost:8000/openapi.json',
224
229
  },
225
230
  development: {
@@ -890,14 +895,19 @@ Usage:
890
895
  bgl add <name> Add a new project to workspace
891
896
  bgl list List all projects in workspace
892
897
  bgl dev [filter] [...args] Run dev servers with clean output (default: './!shared*')
893
- Additional args are passed to vite (e.g., --mode localhost)
898
+ Examples:
899
+ bgl dev --mode localhost
900
+ bgl dev --mode staging
901
+ bgl dev admin --mode production
894
902
  bgl build [project] [...args] Build project by directory (default: all projects)
903
+ Example: bgl build --mode production
895
904
  bgl lint init Set up linting (auto-detects workspace)
896
905
  bgl sdk generate Generate SDK (auto-detects workspace)
897
906
 
898
907
  Options:
899
908
  --workspace, -w Force workspace mode
900
909
  --project, -p Force single project mode
910
+ --mode <env> Set environment (matches bgl.config.ts keys)
901
911
  --help, -h Show this help message
902
912
 
903
913
  Note: Commands auto-detect workspace mode based on directory structure
package/dist/bin/bgl.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { resolve } from 'node:path';
3
3
  import process from 'node:process';
4
4
  import { spawn } from 'node:child_process';
5
- import { l as listProjects, w as writeNetlifyConfig, i as initWorkspace, a as addProject } from '../shared/workspace.ThBu2HJO.mjs';
5
+ import { l as listProjects, w as writeNetlifyConfig, i as initWorkspace, a as addProject } from '../shared/workspace.CzoC6XYF.mjs';
6
6
  import { existsSync, readFileSync, readdirSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs';
7
7
  import prompts from 'prompts';
8
8
 
@@ -209,10 +209,15 @@ async function generateWorkspaceConfig(root = process.cwd(), configFile = "bgl.c
209
209
  const configContent = `import { defineWorkspace } from '@bagelink/workspace'
210
210
  import type { WorkspaceConfig, WorkspaceEnvironment } from '@bagelink/workspace'
211
211
 
212
+ /**
213
+ * Define your workspace environments
214
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
215
+ * Use --mode flag to switch: bgl dev --mode <env_name>
216
+ */
212
217
  const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
213
218
  localhost: {
214
219
  host: 'http://localhost:8000',
215
- proxy: '/api',
220
+ proxy: '/api', // Optional: remove to skip proxy setup
216
221
  openapi_url: 'http://localhost:8000/openapi.json',
217
222
  },
218
223
  development: {
@@ -883,14 +888,19 @@ Usage:
883
888
  bgl add <name> Add a new project to workspace
884
889
  bgl list List all projects in workspace
885
890
  bgl dev [filter] [...args] Run dev servers with clean output (default: './!shared*')
886
- Additional args are passed to vite (e.g., --mode localhost)
891
+ Examples:
892
+ bgl dev --mode localhost
893
+ bgl dev --mode staging
894
+ bgl dev admin --mode production
887
895
  bgl build [project] [...args] Build project by directory (default: all projects)
896
+ Example: bgl build --mode production
888
897
  bgl lint init Set up linting (auto-detects workspace)
889
898
  bgl sdk generate Generate SDK (auto-detects workspace)
890
899
 
891
900
  Options:
892
901
  --workspace, -w Force workspace mode
893
902
  --project, -p Force single project mode
903
+ --mode <env> Set environment (matches bgl.config.ts keys)
894
904
  --help, -h Show this help message
895
905
 
896
906
  Note: Commands auto-detect workspace mode based on directory structure
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  function useWorkspace() {
4
- const proxy = undefined.VITE_BGL_PROXY || "/api";
4
+ const proxy = undefined.VITE_BGL_PROXY || void 0;
5
5
  const host = undefined.VITE_BGL_HOST || "";
6
6
  const openapiUrl = undefined.VITE_BGL_OPENAPI_URL;
7
7
  const mode = undefined.MODE || "development";
8
8
  return {
9
9
  proxy,
10
10
  host,
11
+ baseURL: proxy ?? host,
11
12
  openapiUrl,
12
13
  mode
13
14
  };
@@ -4,13 +4,15 @@
4
4
  */
5
5
  interface RuntimeWorkspaceConfig {
6
6
  /** API proxy path (e.g., '/api') */
7
- proxy: string;
7
+ proxy?: string;
8
8
  /** API host URL (e.g., 'https://project.bagel.to') */
9
9
  host: string;
10
+ /** Base URL for API requests (proxy if available, otherwise host) */
11
+ baseURL: string;
10
12
  /** OpenAPI specification URL (if configured) */
11
13
  openapiUrl?: string;
12
14
  /** Current environment mode */
13
- mode: 'localhost' | 'development' | 'production';
15
+ mode: string;
14
16
  }
15
17
  /**
16
18
  * Get workspace configuration at runtime
@@ -4,13 +4,15 @@
4
4
  */
5
5
  interface RuntimeWorkspaceConfig {
6
6
  /** API proxy path (e.g., '/api') */
7
- proxy: string;
7
+ proxy?: string;
8
8
  /** API host URL (e.g., 'https://project.bagel.to') */
9
9
  host: string;
10
+ /** Base URL for API requests (proxy if available, otherwise host) */
11
+ baseURL: string;
10
12
  /** OpenAPI specification URL (if configured) */
11
13
  openapiUrl?: string;
12
14
  /** Current environment mode */
13
- mode: 'localhost' | 'development' | 'production';
15
+ mode: string;
14
16
  }
15
17
  /**
16
18
  * Get workspace configuration at runtime
@@ -4,13 +4,15 @@
4
4
  */
5
5
  interface RuntimeWorkspaceConfig {
6
6
  /** API proxy path (e.g., '/api') */
7
- proxy: string;
7
+ proxy?: string;
8
8
  /** API host URL (e.g., 'https://project.bagel.to') */
9
9
  host: string;
10
+ /** Base URL for API requests (proxy if available, otherwise host) */
11
+ baseURL: string;
10
12
  /** OpenAPI specification URL (if configured) */
11
13
  openapiUrl?: string;
12
14
  /** Current environment mode */
13
- mode: 'localhost' | 'development' | 'production';
15
+ mode: string;
14
16
  }
15
17
  /**
16
18
  * Get workspace configuration at runtime
@@ -1,11 +1,12 @@
1
1
  function useWorkspace() {
2
- const proxy = import.meta.env.VITE_BGL_PROXY || "/api";
2
+ const proxy = import.meta.env.VITE_BGL_PROXY || void 0;
3
3
  const host = import.meta.env.VITE_BGL_HOST || "";
4
4
  const openapiUrl = import.meta.env.VITE_BGL_OPENAPI_URL;
5
5
  const mode = import.meta.env.MODE || "development";
6
6
  return {
7
7
  proxy,
8
8
  host,
9
+ baseURL: proxy ?? host,
9
10
  openapiUrl,
10
11
  mode
11
12
  };
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.CefUteAh.cjs';
2
- export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.CefUteAh.cjs';
1
+ import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.BzlV5kcN.cjs';
2
+ export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.BzlV5kcN.cjs';
3
3
  export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.cjs';
4
4
 
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.CefUteAh.mjs';
2
- export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.CefUteAh.mjs';
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
3
  export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.mjs';
4
4
 
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WorkspaceEnvironment, a as WorkspaceConfig } from './shared/workspace.CefUteAh.js';
2
- export { P as ProxyConfig, b as WorkspaceOptions } from './shared/workspace.CefUteAh.js';
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
3
  export { RuntimeWorkspaceConfig, getApiUrl, useWorkspace } from './composable.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
1
+ type WorkspaceEnvironment = string;
2
2
  interface WorkspaceConfig {
3
3
  /**
4
4
  * The host URL of the backend API server
@@ -6,10 +6,11 @@ interface WorkspaceConfig {
6
6
  */
7
7
  host: string;
8
8
  /**
9
- * The proxy path to use for API requests
10
- * @default '/api'
9
+ * Optional proxy path to use for API requests
10
+ * If not set, no proxy will be configured for this environment
11
+ * @example '/api'
11
12
  */
12
- proxy: string;
13
+ proxy?: string;
13
14
  /**
14
15
  * Optional OpenAPI specification URL for SDK generation
15
16
  */
@@ -1,4 +1,4 @@
1
- type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
1
+ type WorkspaceEnvironment = string;
2
2
  interface WorkspaceConfig {
3
3
  /**
4
4
  * The host URL of the backend API server
@@ -6,10 +6,11 @@ interface WorkspaceConfig {
6
6
  */
7
7
  host: string;
8
8
  /**
9
- * The proxy path to use for API requests
10
- * @default '/api'
9
+ * Optional proxy path to use for API requests
10
+ * If not set, no proxy will be configured for this environment
11
+ * @example '/api'
11
12
  */
12
- proxy: string;
13
+ proxy?: string;
13
14
  /**
14
15
  * Optional OpenAPI specification URL for SDK generation
15
16
  */
@@ -1,4 +1,4 @@
1
- type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
1
+ type WorkspaceEnvironment = string;
2
2
  interface WorkspaceConfig {
3
3
  /**
4
4
  * The host URL of the backend API server
@@ -6,10 +6,11 @@ interface WorkspaceConfig {
6
6
  */
7
7
  host: string;
8
8
  /**
9
- * The proxy path to use for API requests
10
- * @default '/api'
9
+ * Optional proxy path to use for API requests
10
+ * If not set, no proxy will be configured for this environment
11
+ * @example '/api'
11
12
  */
12
- proxy: string;
13
+ proxy?: string;
13
14
  /**
14
15
  * Optional OpenAPI specification URL for SDK generation
15
16
  */
@@ -97,10 +97,15 @@ function createWorkspaceRoot(root, name, projectId) {
97
97
  );
98
98
  const bglConfig = `import { defineWorkspace } from '@bagelink/workspace'
99
99
 
100
+ /**
101
+ * Define your workspace environments
102
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
103
+ * Use --mode flag to switch: bgl dev --mode <env_name>
104
+ */
100
105
  export default defineWorkspace({
101
106
  localhost: {
102
107
  host: 'http://localhost:8000',
103
- proxy: '/api',
108
+ proxy: '/api', // Optional: remove to skip proxy setup
104
109
  openapi_url: 'http://localhost:8000/openapi.json',
105
110
  },
106
111
  development: {
@@ -104,10 +104,15 @@ function createWorkspaceRoot(root, name, projectId) {
104
104
  );
105
105
  const bglConfig = `import { defineWorkspace } from '@bagelink/workspace'
106
106
 
107
+ /**
108
+ * Define your workspace environments
109
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
110
+ * Use --mode flag to switch: bgl dev --mode <env_name>
111
+ */
107
112
  export default defineWorkspace({
108
113
  localhost: {
109
114
  host: 'http://localhost:8000',
110
- proxy: '/api',
115
+ proxy: '/api', // Optional: remove to skip proxy setup
111
116
  openapi_url: 'http://localhost:8000/openapi.json',
112
117
  },
113
118
  development: {
package/dist/vite.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const node_path = require('node:path');
4
4
  const process = require('node:process');
5
5
  const node_url = require('node:url');
6
- const netlify = require('./shared/workspace.CuE882NE.cjs');
6
+ const netlify = require('./shared/workspace.Didrexg0.cjs');
7
7
  require('node:fs');
8
8
  require('prompts');
9
9
 
@@ -104,7 +104,9 @@ function bagelink(options) {
104
104
  }
105
105
  };
106
106
  const define = {
107
- "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
107
+ ...workspaceConfig.proxy && {
108
+ "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy)
109
+ },
108
110
  "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
109
111
  ...workspaceConfig.openapi_url && {
110
112
  "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
package/dist/vite.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.CefUteAh.cjs';
2
+ import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.BzlV5kcN.cjs';
3
3
 
4
4
  /**
5
5
  * Generate complete netlify.toml file
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.CefUteAh.mjs';
2
+ import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.BzlV5kcN.mjs';
3
3
 
4
4
  /**
5
5
  * Generate complete netlify.toml file
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.CefUteAh.js';
2
+ import { a as WorkspaceConfig, P as ProxyConfig, W as WorkspaceEnvironment } from './shared/workspace.BzlV5kcN.js';
3
3
 
4
4
  /**
5
5
  * Generate complete netlify.toml file
package/dist/vite.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { basename } from 'node:path';
2
2
  import process from 'node:process';
3
3
  import { fileURLToPath } from 'node:url';
4
- import { l as listProjects } from './shared/workspace.ThBu2HJO.mjs';
5
- export { g as generateNetlifyConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.ThBu2HJO.mjs';
4
+ import { l as listProjects } from './shared/workspace.CzoC6XYF.mjs';
5
+ export { g as generateNetlifyConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.CzoC6XYF.mjs';
6
6
  import 'node:fs';
7
7
  import 'prompts';
8
8
 
@@ -99,7 +99,9 @@ function bagelink(options) {
99
99
  }
100
100
  };
101
101
  const define = {
102
- "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
102
+ ...workspaceConfig.proxy && {
103
+ "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy)
104
+ },
103
105
  "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
104
106
  ...workspaceConfig.openapi_url && {
105
107
  "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
package/env.d.ts CHANGED
@@ -7,9 +7,10 @@
7
7
  interface ImportMetaEnv {
8
8
  /**
9
9
  * API proxy path (e.g., '/api')
10
- * Injected from bgl.config.ts
10
+ * Injected from bgl.config.ts if configured
11
+ * Optional - if not set, use VITE_BGL_HOST directly
11
12
  */
12
- readonly VITE_BGL_PROXY: string
13
+ readonly VITE_BGL_PROXY?: string
13
14
 
14
15
  /**
15
16
  * API host URL (e.g., 'https://project.bagel.to')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/workspace",
3
3
  "type": "module",
4
- "version": "1.8.37",
4
+ "version": "1.8.41",
5
5
  "description": "Monorepo workspace tooling for Bagel projects with proxy and config management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
package/src/composable.ts CHANGED
@@ -1,16 +1,20 @@
1
+ /// <reference types="vite/client" />
2
+
1
3
  /**
2
4
  * Runtime workspace configuration
3
5
  * Provides access to workspace config injected at build time
4
6
  */
5
7
  export interface RuntimeWorkspaceConfig {
6
8
  /** API proxy path (e.g., '/api') */
7
- proxy: string
9
+ proxy?: string
8
10
  /** API host URL (e.g., 'https://project.bagel.to') */
9
11
  host: string
12
+ /** Base URL for API requests (proxy if available, otherwise host) */
13
+ baseURL: string
10
14
  /** OpenAPI specification URL (if configured) */
11
15
  openapiUrl?: string
12
16
  /** Current environment mode */
13
- mode: 'localhost' | 'development' | 'production'
17
+ mode: string
14
18
  }
15
19
 
16
20
  /**
@@ -36,14 +40,15 @@ export interface RuntimeWorkspaceConfig {
36
40
  */
37
41
  export function useWorkspace(): RuntimeWorkspaceConfig {
38
42
  // Access env variables injected by the Vite plugin
39
- const proxy = import.meta.env.VITE_BGL_PROXY || '/api'
43
+ const proxy = import.meta.env.VITE_BGL_PROXY || undefined
40
44
  const host = import.meta.env.VITE_BGL_HOST || ''
41
45
  const openapiUrl = import.meta.env.VITE_BGL_OPENAPI_URL
42
- const mode = (import.meta.env.MODE as RuntimeWorkspaceConfig['mode']) || 'development'
46
+ const mode = (import.meta.env.MODE as string) || 'development'
43
47
 
44
48
  return {
45
49
  proxy,
46
50
  host,
51
+ baseURL: proxy ?? host,
47
52
  openapiUrl,
48
53
  mode,
49
54
  }
package/src/init.ts CHANGED
@@ -49,10 +49,15 @@ export async function generateWorkspaceConfig(
49
49
  const configContent = `import { defineWorkspace } from '@bagelink/workspace'
50
50
  import type { WorkspaceConfig, WorkspaceEnvironment } from '@bagelink/workspace'
51
51
 
52
+ /**
53
+ * Define your workspace environments
54
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
55
+ * Use --mode flag to switch: bgl dev --mode <env_name>
56
+ */
52
57
  const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
53
58
  localhost: {
54
59
  host: 'http://localhost:8000',
55
- proxy: '/api',
60
+ proxy: '/api', // Optional: remove to skip proxy setup
56
61
  openapi_url: 'http://localhost:8000/openapi.json',
57
62
  },
58
63
  development: {
@@ -142,10 +147,15 @@ export function generateWorkspaceConfigSync(
142
147
  const configContent = `import { defineWorkspace } from '@bagelink/workspace'
143
148
  import type { WorkspaceConfig, WorkspaceEnvironment } from '@bagelink/workspace'
144
149
 
150
+ /**
151
+ * Define your workspace environments
152
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
153
+ * Use --mode flag to switch: bgl dev --mode <env_name>
154
+ */
145
155
  const configs: Record<WorkspaceEnvironment, WorkspaceConfig> = {
146
156
  localhost: {
147
157
  host: 'http://localhost:8000',
148
- proxy: '/api',
158
+ proxy: '/api', // Optional: remove to skip proxy setup
149
159
  openapi_url: 'http://localhost:8000/openapi.json',
150
160
  },
151
161
  development: {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type WorkspaceEnvironment = 'localhost' | 'development' | 'production'
1
+ export type WorkspaceEnvironment = string
2
2
 
3
3
  export interface WorkspaceConfig {
4
4
  /**
@@ -8,10 +8,11 @@ export interface WorkspaceConfig {
8
8
  host: string
9
9
 
10
10
  /**
11
- * The proxy path to use for API requests
12
- * @default '/api'
11
+ * Optional proxy path to use for API requests
12
+ * If not set, no proxy will be configured for this environment
13
+ * @example '/api'
13
14
  */
14
- proxy: string
15
+ proxy?: string
15
16
 
16
17
  /**
17
18
  * Optional OpenAPI specification URL for SDK generation
package/src/vite.ts CHANGED
@@ -142,7 +142,9 @@ export function bagelink(options: {
142
142
 
143
143
  // Inject workspace config as environment variables
144
144
  const define = {
145
- 'import.meta.env.VITE_BGL_PROXY': JSON.stringify(workspaceConfig.proxy),
145
+ ...(workspaceConfig.proxy && {
146
+ 'import.meta.env.VITE_BGL_PROXY': JSON.stringify(workspaceConfig.proxy),
147
+ }),
146
148
  'import.meta.env.VITE_BGL_HOST': JSON.stringify(workspaceConfig.host),
147
149
  ...(workspaceConfig.openapi_url && {
148
150
  'import.meta.env.VITE_BGL_OPENAPI_URL': JSON.stringify(workspaceConfig.openapi_url),
package/src/workspace.ts CHANGED
@@ -121,10 +121,15 @@ function createWorkspaceRoot(root: string, name: string, projectId: string): voi
121
121
  // bgl.config.ts (shared)
122
122
  const bglConfig = `import { defineWorkspace } from '@bagelink/workspace'
123
123
 
124
+ /**
125
+ * Define your workspace environments
126
+ * You can add as many custom environments as needed (e.g., 'staging', 'preview')
127
+ * Use --mode flag to switch: bgl dev --mode <env_name>
128
+ */
124
129
  export default defineWorkspace({
125
130
  localhost: {
126
131
  host: 'http://localhost:8000',
127
- proxy: '/api',
132
+ proxy: '/api', // Optional: remove to skip proxy setup
128
133
  openapi_url: 'http://localhost:8000/openapi.json',
129
134
  },
130
135
  development: {