@bagelink/workspace 1.7.35 → 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/dist/index.cjs CHANGED
@@ -4,9 +4,10 @@ const node_fs = require('node:fs');
4
4
  const node_path = require('node:path');
5
5
  const process = require('node:process');
6
6
  const workspace = require('./shared/workspace.CamNrnD_.cjs');
7
- const node_url = require('node:url');
7
+ const vite = require('./shared/workspace.DfLGMczD.cjs');
8
8
  require('prompts');
9
9
  require('node:child_process');
10
+ require('node:url');
10
11
 
11
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
13
 
@@ -72,40 +73,6 @@ function mergeConfigs(base, override) {
72
73
  };
73
74
  }
74
75
 
75
- function createViteProxy(config) {
76
- const proxy = {};
77
- if (config.proxy && config.host) {
78
- proxy[config.proxy] = {
79
- target: config.host,
80
- changeOrigin: true,
81
- rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
82
- secure: true
83
- };
84
- }
85
- if (config.host) {
86
- proxy["/files"] = {
87
- target: config.host,
88
- changeOrigin: true,
89
- secure: true
90
- };
91
- }
92
- return proxy;
93
- }
94
- function createCustomProxy(paths, target, options = {}) {
95
- const proxy = {};
96
- for (const path of paths) {
97
- proxy[path] = {
98
- target,
99
- changeOrigin: options.changeOrigin ?? true,
100
- secure: options.secure ?? true,
101
- ...options.rewrite === true && {
102
- rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
103
- }
104
- };
105
- }
106
- return proxy;
107
- }
108
-
109
76
  function useWorkspace() {
110
77
  const proxy = undefined.VITE_BGL_PROXY || "/api";
111
78
  const host = undefined.VITE_BGL_HOST || "";
@@ -123,47 +90,6 @@ function getApiUrl() {
123
90
  return `${host}${proxy}`;
124
91
  }
125
92
 
126
- function bagelink(options) {
127
- const { workspace, config = {} } = options;
128
- let workspaceConfig;
129
- return {
130
- name: "vite-plugin-bagelink",
131
- enforce: "pre",
132
- configResolved(resolved) {
133
- workspaceConfig = workspace(resolved.mode);
134
- },
135
- config(userConfig, { mode }) {
136
- workspaceConfig = workspace(mode);
137
- const alias = {};
138
- if (config.includeSharedAlias !== false) {
139
- const sharedPath = config.sharedPath ?? "../shared";
140
- alias["@shared"] = node_url.fileURLToPath(new URL(sharedPath, `file://${process__default.cwd()}/`));
141
- }
142
- alias["@"] = node_url.fileURLToPath(new URL("./src", `file://${process__default.cwd()}/`));
143
- if (config.additionalAliases) {
144
- Object.assign(alias, config.additionalAliases);
145
- }
146
- const server = config.configureProxy !== false ? {
147
- proxy: createViteProxy(workspaceConfig)
148
- } : void 0;
149
- const define = {
150
- "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
151
- "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
152
- ...workspaceConfig.openapi_url && {
153
- "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
154
- }
155
- };
156
- return {
157
- resolve: {
158
- alias
159
- },
160
- define,
161
- ...server && { server }
162
- };
163
- }
164
- };
165
- }
166
-
167
93
  function defineWorkspace(configs) {
168
94
  return (mode = "development") => {
169
95
  return configs[mode] || configs.development;
@@ -185,7 +111,7 @@ function createWorkspace(options = {}) {
185
111
  * Create Vite proxy configuration
186
112
  */
187
113
  createProxy(config) {
188
- return createViteProxy(config);
114
+ return vite.createViteProxy(config);
189
115
  },
190
116
  /**
191
117
  * Generate Netlify configuration file
@@ -223,9 +149,9 @@ exports.runDev = workspace.runDev;
223
149
  exports.setBuildEnvVars = workspace.setBuildEnvVars;
224
150
  exports.setupLint = workspace.setupLint;
225
151
  exports.writeNetlifyConfig = workspace.writeNetlifyConfig;
226
- exports.bagelink = bagelink;
227
- exports.createCustomProxy = createCustomProxy;
228
- exports.createViteProxy = createViteProxy;
152
+ exports.bagelink = vite.bagelink;
153
+ exports.createCustomProxy = vite.createCustomProxy;
154
+ exports.createViteProxy = vite.createViteProxy;
229
155
  exports.createWorkspace = createWorkspace;
230
156
  exports.defineWorkspace = defineWorkspace;
231
157
  exports.getApiUrl = getApiUrl;
package/dist/index.d.cts CHANGED
@@ -1,47 +1,6 @@
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.cjs';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.cjs';
3
+ import 'vite';
45
4
 
46
5
  /**
47
6
  * Load and resolve bgl.config.ts with cascading support
@@ -171,72 +130,6 @@ declare function generateSDK(root?: string): Promise<void>;
171
130
  */
172
131
  declare function generateSDKForWorkspace(root?: string): Promise<void>;
173
132
 
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
133
  /**
241
134
  * Initialize a new workspace with flat structure
242
135
  */
@@ -282,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
282
175
  clearCache(): void;
283
176
  };
284
177
 
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 };
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.d.mts CHANGED
@@ -1,47 +1,6 @@
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
+ import 'vite';
45
4
 
46
5
  /**
47
6
  * Load and resolve bgl.config.ts with cascading support
@@ -171,72 +130,6 @@ declare function generateSDK(root?: string): Promise<void>;
171
130
  */
172
131
  declare function generateSDKForWorkspace(root?: string): Promise<void>;
173
132
 
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
133
  /**
241
134
  * Initialize a new workspace with flat structure
242
135
  */
@@ -282,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
282
175
  clearCache(): void;
283
176
  };
284
177
 
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 };
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.d.ts CHANGED
@@ -1,47 +1,6 @@
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
+ import 'vite';
45
4
 
46
5
  /**
47
6
  * Load and resolve bgl.config.ts with cascading support
@@ -171,72 +130,6 @@ declare function generateSDK(root?: string): Promise<void>;
171
130
  */
172
131
  declare function generateSDKForWorkspace(root?: string): Promise<void>;
173
132
 
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
133
  /**
241
134
  * Initialize a new workspace with flat structure
242
135
  */
@@ -282,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
282
175
  clearCache(): void;
283
176
  };
284
177
 
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 };
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
@@ -3,9 +3,11 @@ 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';
7
8
  import 'prompts';
8
9
  import 'node:child_process';
10
+ import 'node:url';
9
11
 
10
12
  async function resolveConfig(mode = "development", options = {}) {
11
13
  const root = options.root ?? process.cwd();
@@ -67,40 +69,6 @@ function mergeConfigs(base, override) {
67
69
  };
68
70
  }
69
71
 
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
72
  function useWorkspace() {
105
73
  const proxy = import.meta.env.VITE_BGL_PROXY || "/api";
106
74
  const host = import.meta.env.VITE_BGL_HOST || "";
@@ -118,47 +86,6 @@ function getApiUrl() {
118
86
  return `${host}${proxy}`;
119
87
  }
120
88
 
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
89
  function defineWorkspace(configs) {
163
90
  return (mode = "development") => {
164
91
  return configs[mode] || configs.development;
@@ -203,4 +130,4 @@ function createWorkspace(options = {}) {
203
130
  };
204
131
  }
205
132
 
206
- export { bagelink, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateWorkspaceConfig, getApiUrl, mergeConfigs, resolveConfig, setBuildEnvVars, useWorkspace, writeNetlifyConfig };
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 };
@@ -0,0 +1,79 @@
1
+ import process from 'node:process';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ function createViteProxy(config) {
5
+ const proxy = {};
6
+ if (config.proxy && config.host) {
7
+ proxy[config.proxy] = {
8
+ target: config.host,
9
+ changeOrigin: true,
10
+ rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
11
+ secure: true
12
+ };
13
+ }
14
+ if (config.host) {
15
+ proxy["/files"] = {
16
+ target: config.host,
17
+ changeOrigin: true,
18
+ secure: true
19
+ };
20
+ }
21
+ return proxy;
22
+ }
23
+ function createCustomProxy(paths, target, options = {}) {
24
+ const proxy = {};
25
+ for (const path of paths) {
26
+ proxy[path] = {
27
+ target,
28
+ changeOrigin: options.changeOrigin ?? true,
29
+ secure: options.secure ?? true,
30
+ ...options.rewrite === true && {
31
+ rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
32
+ }
33
+ };
34
+ }
35
+ return proxy;
36
+ }
37
+
38
+ function bagelink(options) {
39
+ const { workspace, config = {} } = options;
40
+ let workspaceConfig;
41
+ return {
42
+ name: "vite-plugin-bagelink",
43
+ enforce: "pre",
44
+ configResolved(resolved) {
45
+ workspaceConfig = workspace(resolved.mode);
46
+ },
47
+ config(userConfig, { mode }) {
48
+ workspaceConfig = workspace(mode);
49
+ const alias = {};
50
+ if (config.includeSharedAlias !== false) {
51
+ const sharedPath = config.sharedPath ?? "../shared";
52
+ alias["@shared"] = fileURLToPath(new URL(sharedPath, `file://${process.cwd()}/`));
53
+ }
54
+ alias["@"] = fileURLToPath(new URL("./src", `file://${process.cwd()}/`));
55
+ if (config.additionalAliases) {
56
+ Object.assign(alias, config.additionalAliases);
57
+ }
58
+ const server = config.configureProxy !== false ? {
59
+ proxy: createViteProxy(workspaceConfig)
60
+ } : void 0;
61
+ const define = {
62
+ "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
63
+ "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
64
+ ...workspaceConfig.openapi_url && {
65
+ "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
66
+ }
67
+ };
68
+ return {
69
+ resolve: {
70
+ alias
71
+ },
72
+ define,
73
+ ...server && { server }
74
+ };
75
+ }
76
+ };
77
+ }
78
+
79
+ export { createCustomProxy as a, bagelink as b, createViteProxy as c };
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ const process = require('node:process');
4
+ const node_url = require('node:url');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
7
+
8
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
9
+
10
+ function createViteProxy(config) {
11
+ const proxy = {};
12
+ if (config.proxy && config.host) {
13
+ proxy[config.proxy] = {
14
+ target: config.host,
15
+ changeOrigin: true,
16
+ rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
17
+ secure: true
18
+ };
19
+ }
20
+ if (config.host) {
21
+ proxy["/files"] = {
22
+ target: config.host,
23
+ changeOrigin: true,
24
+ secure: true
25
+ };
26
+ }
27
+ return proxy;
28
+ }
29
+ function createCustomProxy(paths, target, options = {}) {
30
+ const proxy = {};
31
+ for (const path of paths) {
32
+ proxy[path] = {
33
+ target,
34
+ changeOrigin: options.changeOrigin ?? true,
35
+ secure: options.secure ?? true,
36
+ ...options.rewrite === true && {
37
+ rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
38
+ }
39
+ };
40
+ }
41
+ return proxy;
42
+ }
43
+
44
+ function bagelink(options) {
45
+ const { workspace, config = {} } = options;
46
+ let workspaceConfig;
47
+ return {
48
+ name: "vite-plugin-bagelink",
49
+ enforce: "pre",
50
+ configResolved(resolved) {
51
+ workspaceConfig = workspace(resolved.mode);
52
+ },
53
+ config(userConfig, { mode }) {
54
+ workspaceConfig = workspace(mode);
55
+ const alias = {};
56
+ if (config.includeSharedAlias !== false) {
57
+ const sharedPath = config.sharedPath ?? "../shared";
58
+ alias["@shared"] = node_url.fileURLToPath(new URL(sharedPath, `file://${process__default.cwd()}/`));
59
+ }
60
+ alias["@"] = node_url.fileURLToPath(new URL("./src", `file://${process__default.cwd()}/`));
61
+ if (config.additionalAliases) {
62
+ Object.assign(alias, config.additionalAliases);
63
+ }
64
+ const server = config.configureProxy !== false ? {
65
+ proxy: createViteProxy(workspaceConfig)
66
+ } : void 0;
67
+ const define = {
68
+ "import.meta.env.VITE_BGL_PROXY": JSON.stringify(workspaceConfig.proxy),
69
+ "import.meta.env.VITE_BGL_HOST": JSON.stringify(workspaceConfig.host),
70
+ ...workspaceConfig.openapi_url && {
71
+ "import.meta.env.VITE_BGL_OPENAPI_URL": JSON.stringify(workspaceConfig.openapi_url)
72
+ }
73
+ };
74
+ return {
75
+ resolve: {
76
+ alias
77
+ },
78
+ define,
79
+ ...server && { server }
80
+ };
81
+ }
82
+ };
83
+ }
84
+
85
+ exports.bagelink = bagelink;
86
+ exports.createCustomProxy = createCustomProxy;
87
+ exports.createViteProxy = createViteProxy;
package/dist/vite.cjs ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ require('node:process');
4
+ require('node:url');
5
+ const vite = require('./shared/workspace.DfLGMczD.cjs');
6
+
7
+
8
+
9
+ exports.bagelink = vite.bagelink;
@@ -0,0 +1,2 @@
1
+ import 'vite';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.cjs';
@@ -0,0 +1,2 @@
1
+ import 'vite';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.mjs';
package/dist/vite.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import 'vite';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.js';
package/dist/vite.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import 'node:process';
2
+ import 'node:url';
3
+ export { b as bagelink } from './shared/workspace.D0MF8ERh.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/workspace",
3
3
  "type": "module",
4
- "version": "1.7.35",
4
+ "version": "1.7.37",
5
5
  "description": "Monorepo workspace tooling for Bagel projects with proxy and config management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -36,7 +36,8 @@
36
36
  "types": "./dist/vite.d.ts",
37
37
  "require": "./dist/vite.cjs",
38
38
  "import": "./dist/vite.mjs"
39
- }
39
+ },
40
+ "./env": "./env.d.ts"
40
41
  },
41
42
  "main": "./dist/index.mjs",
42
43
  "module": "./dist/index.mjs",