@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/README.md +4 -5
- package/dist/composable.cjs +21 -0
- package/dist/composable.d.cts +50 -0
- package/dist/composable.d.mts +50 -0
- package/dist/composable.d.ts +50 -0
- package/dist/composable.mjs +18 -0
- package/dist/index.cjs +9 -99
- package/dist/index.d.cts +5 -160
- package/dist/index.d.mts +5 -160
- package/dist/index.d.ts +5 -160
- package/dist/index.mjs +5 -94
- 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.D0MF8ERh.mjs +79 -0
- package/dist/shared/workspace.DfLGMczD.cjs +87 -0
- 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/package.json +8 -2
- package/src/index.ts +5 -0
|
@@ -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
package/dist/vite.d.cts
ADDED
package/dist/vite.d.mts
ADDED
package/dist/vite.d.ts
ADDED
package/dist/vite.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/workspace",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.39",
|
|
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,13 @@
|
|
|
36
36
|
"types": "./dist/vite.d.ts",
|
|
37
37
|
"require": "./dist/vite.cjs",
|
|
38
38
|
"import": "./dist/vite.mjs"
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"./composable": {
|
|
41
|
+
"types": "./dist/composable.d.ts",
|
|
42
|
+
"require": "./dist/composable.cjs",
|
|
43
|
+
"import": "./dist/composable.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./env": "./env.d.ts"
|
|
40
46
|
},
|
|
41
47
|
"main": "./dist/index.mjs",
|
|
42
48
|
"module": "./dist/index.mjs",
|
package/src/index.ts
CHANGED
|
@@ -34,13 +34,18 @@ export {
|
|
|
34
34
|
writeNetlifyConfig,
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// Runtime composables (browser-safe, no Node.js dependencies)
|
|
37
38
|
export { getApiUrl, useWorkspace } from './composable'
|
|
38
39
|
export type { RuntimeWorkspaceConfig } from './composable'
|
|
40
|
+
|
|
41
|
+
// Node.js / CLI-only exports
|
|
39
42
|
export { getWorkspaceInfo, isWorkspace } from './detect'
|
|
40
43
|
export { runDev } from './dev'
|
|
41
44
|
export { setupLint } from './lint'
|
|
42
45
|
export { generateSDK, generateSDKForWorkspace } from './sdk'
|
|
46
|
+
// Vite plugin (build-time only)
|
|
43
47
|
export { bagelink } from './vite'
|
|
48
|
+
|
|
44
49
|
export type { BagelinkPluginOptions } from './vite'
|
|
45
50
|
export { addProject, initWorkspace, listProjects } from './workspace'
|
|
46
51
|
|