@bagelink/workspace 1.7.3 → 1.7.8
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 +236 -8
- package/bin/bgl.ts +102 -4
- package/dist/bin/bgl.cjs +80 -5
- package/dist/bin/bgl.mjs +80 -5
- package/dist/index.cjs +18 -42
- package/dist/index.d.cts +41 -1
- package/dist/index.d.mts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.mjs +4 -36
- package/dist/shared/workspace.BMTTo3s8.cjs +993 -0
- package/dist/shared/workspace.COhZ__uF.mjs +973 -0
- package/package.json +15 -4
- package/src/detect.ts +90 -0
- package/src/index.ts +5 -0
- package/src/init.ts +36 -9
- package/src/lint.ts +235 -0
- package/src/sdk.ts +175 -0
- package/src/workspace.ts +505 -0
- package/templates/dev-runner.ts +61 -0
- package/dist/shared/workspace.BaaKkm9b.mjs +0 -182
- package/dist/shared/workspace.CkP5t0--.cjs +0 -190
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const node_fs = require('node:fs');
|
|
4
4
|
const node_path = require('node:path');
|
|
5
5
|
const process = require('node:process');
|
|
6
|
-
const
|
|
6
|
+
const detect = require('./shared/workspace.BMTTo3s8.cjs');
|
|
7
7
|
require('prompts');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -32,7 +32,7 @@ async function resolveConfig(mode = "development", options = {}) {
|
|
|
32
32
|
currentDir = parentDir;
|
|
33
33
|
}
|
|
34
34
|
if (options.interactive !== false) {
|
|
35
|
-
await
|
|
35
|
+
await detect.generateWorkspaceConfig(root, configFile);
|
|
36
36
|
const newConfig = await loadConfig(localConfigPath, mode);
|
|
37
37
|
if (newConfig) {
|
|
38
38
|
return newConfig;
|
|
@@ -70,38 +70,6 @@ function mergeConfigs(base, override) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function generateNetlifyRedirect(config) {
|
|
74
|
-
const redirect = `[[redirects]]
|
|
75
|
-
from = "${config.proxy}/*"
|
|
76
|
-
to = "${config.host}/:splat"
|
|
77
|
-
status = 200
|
|
78
|
-
force = true
|
|
79
|
-
headers = {X-From = "Netlify"}
|
|
80
|
-
`;
|
|
81
|
-
return redirect;
|
|
82
|
-
}
|
|
83
|
-
function generateNetlifyConfig(config, additionalConfig) {
|
|
84
|
-
const redirect = generateNetlifyRedirect(config);
|
|
85
|
-
if (additionalConfig !== void 0 && additionalConfig !== "") {
|
|
86
|
-
return `${redirect}
|
|
87
|
-
${additionalConfig}`;
|
|
88
|
-
}
|
|
89
|
-
return redirect;
|
|
90
|
-
}
|
|
91
|
-
function writeNetlifyConfig(config, outPath = "./netlify.toml", additionalConfig) {
|
|
92
|
-
const content = generateNetlifyConfig(config, additionalConfig);
|
|
93
|
-
const resolvedPath = node_path.resolve(outPath);
|
|
94
|
-
node_fs.writeFileSync(resolvedPath, content, "utf-8");
|
|
95
|
-
console.log(`\u2713 Generated netlify.toml at ${resolvedPath}`);
|
|
96
|
-
}
|
|
97
|
-
function setBuildEnvVars(config) {
|
|
98
|
-
process__default.env.BGL_PROXY_PATH = config.proxy;
|
|
99
|
-
process__default.env.BGL_API_HOST = config.host;
|
|
100
|
-
if (config.openapi_url !== void 0 && config.openapi_url !== "") {
|
|
101
|
-
process__default.env.BGL_OPENAPI_URL = config.openapi_url;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
73
|
function createViteProxy(config) {
|
|
106
74
|
const proxy = {};
|
|
107
75
|
if (config.proxy && config.host) {
|
|
@@ -163,13 +131,13 @@ function createWorkspace(options = {}) {
|
|
|
163
131
|
* Generate Netlify configuration file
|
|
164
132
|
*/
|
|
165
133
|
generateNetlify(config, outPath = "./netlify.toml", additionalConfig) {
|
|
166
|
-
writeNetlifyConfig(config, outPath, additionalConfig);
|
|
134
|
+
detect.writeNetlifyConfig(config, outPath, additionalConfig);
|
|
167
135
|
},
|
|
168
136
|
/**
|
|
169
137
|
* Set build environment variables
|
|
170
138
|
*/
|
|
171
139
|
setBuildEnv(config) {
|
|
172
|
-
setBuildEnvVars(config);
|
|
140
|
+
detect.setBuildEnvVars(config);
|
|
173
141
|
},
|
|
174
142
|
/**
|
|
175
143
|
* Clear cached configuration
|
|
@@ -180,15 +148,23 @@ function createWorkspace(options = {}) {
|
|
|
180
148
|
};
|
|
181
149
|
}
|
|
182
150
|
|
|
183
|
-
exports.
|
|
184
|
-
exports.
|
|
151
|
+
exports.addProject = detect.addProject;
|
|
152
|
+
exports.generateNetlifyConfig = detect.generateNetlifyConfig;
|
|
153
|
+
exports.generateNetlifyRedirect = detect.generateNetlifyRedirect;
|
|
154
|
+
exports.generateSDK = detect.generateSDK;
|
|
155
|
+
exports.generateSDKForWorkspace = detect.generateSDKForWorkspace;
|
|
156
|
+
exports.generateWorkspaceConfig = detect.generateWorkspaceConfig;
|
|
157
|
+
exports.generateWorkspaceConfigSync = detect.generateWorkspaceConfigSync;
|
|
158
|
+
exports.getWorkspaceInfo = detect.getWorkspaceInfo;
|
|
159
|
+
exports.initWorkspace = detect.initWorkspace;
|
|
160
|
+
exports.isWorkspace = detect.isWorkspace;
|
|
161
|
+
exports.listProjects = detect.listProjects;
|
|
162
|
+
exports.setBuildEnvVars = detect.setBuildEnvVars;
|
|
163
|
+
exports.setupLint = detect.setupLint;
|
|
164
|
+
exports.writeNetlifyConfig = detect.writeNetlifyConfig;
|
|
185
165
|
exports.createCustomProxy = createCustomProxy;
|
|
186
166
|
exports.createViteProxy = createViteProxy;
|
|
187
167
|
exports.createWorkspace = createWorkspace;
|
|
188
168
|
exports.defineWorkspace = defineWorkspace;
|
|
189
|
-
exports.generateNetlifyConfig = generateNetlifyConfig;
|
|
190
|
-
exports.generateNetlifyRedirect = generateNetlifyRedirect;
|
|
191
169
|
exports.mergeConfigs = mergeConfigs;
|
|
192
170
|
exports.resolveConfig = resolveConfig;
|
|
193
|
-
exports.setBuildEnvVars = setBuildEnvVars;
|
|
194
|
-
exports.writeNetlifyConfig = writeNetlifyConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -91,6 +91,46 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
|
91
91
|
secure?: boolean;
|
|
92
92
|
}): ProxyConfig;
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Set up linting in a project
|
|
96
|
+
*/
|
|
97
|
+
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Generate SDK from OpenAPI spec
|
|
101
|
+
*/
|
|
102
|
+
declare function generateSDK(root?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Generate SDK for all projects in workspace
|
|
105
|
+
*/
|
|
106
|
+
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize a new workspace with flat structure
|
|
110
|
+
*/
|
|
111
|
+
declare function initWorkspace(root?: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Add a new project to the workspace
|
|
114
|
+
*/
|
|
115
|
+
declare function addProject(name: string, root?: string): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* List all projects in workspace
|
|
118
|
+
*/
|
|
119
|
+
declare function listProjects(root?: string): string[];
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Detect if current directory is a workspace root
|
|
123
|
+
*/
|
|
124
|
+
declare function isWorkspace(root?: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Get workspace info
|
|
127
|
+
*/
|
|
128
|
+
declare function getWorkspaceInfo(root?: string): {
|
|
129
|
+
isWorkspace: boolean;
|
|
130
|
+
projects: string[];
|
|
131
|
+
hasShared: boolean;
|
|
132
|
+
};
|
|
133
|
+
|
|
94
134
|
/**
|
|
95
135
|
* Define workspace configuration
|
|
96
136
|
* Simple helper to get config from a config map
|
|
@@ -123,5 +163,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
|
|
|
123
163
|
clearCache(): void;
|
|
124
164
|
};
|
|
125
165
|
|
|
126
|
-
export { createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, mergeConfigs, resolveConfig, setBuildEnvVars, writeNetlifyConfig };
|
|
166
|
+
export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
|
|
127
167
|
export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
|
package/dist/index.d.mts
CHANGED
|
@@ -91,6 +91,46 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
|
91
91
|
secure?: boolean;
|
|
92
92
|
}): ProxyConfig;
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Set up linting in a project
|
|
96
|
+
*/
|
|
97
|
+
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Generate SDK from OpenAPI spec
|
|
101
|
+
*/
|
|
102
|
+
declare function generateSDK(root?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Generate SDK for all projects in workspace
|
|
105
|
+
*/
|
|
106
|
+
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize a new workspace with flat structure
|
|
110
|
+
*/
|
|
111
|
+
declare function initWorkspace(root?: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Add a new project to the workspace
|
|
114
|
+
*/
|
|
115
|
+
declare function addProject(name: string, root?: string): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* List all projects in workspace
|
|
118
|
+
*/
|
|
119
|
+
declare function listProjects(root?: string): string[];
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Detect if current directory is a workspace root
|
|
123
|
+
*/
|
|
124
|
+
declare function isWorkspace(root?: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Get workspace info
|
|
127
|
+
*/
|
|
128
|
+
declare function getWorkspaceInfo(root?: string): {
|
|
129
|
+
isWorkspace: boolean;
|
|
130
|
+
projects: string[];
|
|
131
|
+
hasShared: boolean;
|
|
132
|
+
};
|
|
133
|
+
|
|
94
134
|
/**
|
|
95
135
|
* Define workspace configuration
|
|
96
136
|
* Simple helper to get config from a config map
|
|
@@ -123,5 +163,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
|
|
|
123
163
|
clearCache(): void;
|
|
124
164
|
};
|
|
125
165
|
|
|
126
|
-
export { createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, mergeConfigs, resolveConfig, setBuildEnvVars, writeNetlifyConfig };
|
|
166
|
+
export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
|
|
127
167
|
export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,46 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
|
|
|
91
91
|
secure?: boolean;
|
|
92
92
|
}): ProxyConfig;
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Set up linting in a project
|
|
96
|
+
*/
|
|
97
|
+
declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Generate SDK from OpenAPI spec
|
|
101
|
+
*/
|
|
102
|
+
declare function generateSDK(root?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Generate SDK for all projects in workspace
|
|
105
|
+
*/
|
|
106
|
+
declare function generateSDKForWorkspace(root?: string): Promise<void>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize a new workspace with flat structure
|
|
110
|
+
*/
|
|
111
|
+
declare function initWorkspace(root?: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Add a new project to the workspace
|
|
114
|
+
*/
|
|
115
|
+
declare function addProject(name: string, root?: string): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* List all projects in workspace
|
|
118
|
+
*/
|
|
119
|
+
declare function listProjects(root?: string): string[];
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Detect if current directory is a workspace root
|
|
123
|
+
*/
|
|
124
|
+
declare function isWorkspace(root?: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Get workspace info
|
|
127
|
+
*/
|
|
128
|
+
declare function getWorkspaceInfo(root?: string): {
|
|
129
|
+
isWorkspace: boolean;
|
|
130
|
+
projects: string[];
|
|
131
|
+
hasShared: boolean;
|
|
132
|
+
};
|
|
133
|
+
|
|
94
134
|
/**
|
|
95
135
|
* Define workspace configuration
|
|
96
136
|
* Simple helper to get config from a config map
|
|
@@ -123,5 +163,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
|
|
|
123
163
|
clearCache(): void;
|
|
124
164
|
};
|
|
125
165
|
|
|
126
|
-
export { createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, mergeConfigs, resolveConfig, setBuildEnvVars, writeNetlifyConfig };
|
|
166
|
+
export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
|
|
127
167
|
export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
2
|
import { resolve, join } from 'node:path';
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import { g as generateWorkspaceConfig } from './shared/workspace.
|
|
5
|
-
export { a as generateWorkspaceConfigSync } from './shared/workspace.
|
|
4
|
+
import { g as generateWorkspaceConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.COhZ__uF.mjs';
|
|
5
|
+
export { h as addProject, a as generateNetlifyConfig, b as generateNetlifyRedirect, e as generateSDK, f as generateSDKForWorkspace, c as generateWorkspaceConfigSync, j as getWorkspaceInfo, i as initWorkspace, k as isWorkspace, l as listProjects, d as setupLint } from './shared/workspace.COhZ__uF.mjs';
|
|
6
6
|
import 'prompts';
|
|
7
7
|
|
|
8
8
|
async function resolveConfig(mode = "development", options = {}) {
|
|
@@ -65,38 +65,6 @@ function mergeConfigs(base, override) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function generateNetlifyRedirect(config) {
|
|
69
|
-
const redirect = `[[redirects]]
|
|
70
|
-
from = "${config.proxy}/*"
|
|
71
|
-
to = "${config.host}/:splat"
|
|
72
|
-
status = 200
|
|
73
|
-
force = true
|
|
74
|
-
headers = {X-From = "Netlify"}
|
|
75
|
-
`;
|
|
76
|
-
return redirect;
|
|
77
|
-
}
|
|
78
|
-
function generateNetlifyConfig(config, additionalConfig) {
|
|
79
|
-
const redirect = generateNetlifyRedirect(config);
|
|
80
|
-
if (additionalConfig !== void 0 && additionalConfig !== "") {
|
|
81
|
-
return `${redirect}
|
|
82
|
-
${additionalConfig}`;
|
|
83
|
-
}
|
|
84
|
-
return redirect;
|
|
85
|
-
}
|
|
86
|
-
function writeNetlifyConfig(config, outPath = "./netlify.toml", additionalConfig) {
|
|
87
|
-
const content = generateNetlifyConfig(config, additionalConfig);
|
|
88
|
-
const resolvedPath = resolve(outPath);
|
|
89
|
-
writeFileSync(resolvedPath, content, "utf-8");
|
|
90
|
-
console.log(`\u2713 Generated netlify.toml at ${resolvedPath}`);
|
|
91
|
-
}
|
|
92
|
-
function setBuildEnvVars(config) {
|
|
93
|
-
process.env.BGL_PROXY_PATH = config.proxy;
|
|
94
|
-
process.env.BGL_API_HOST = config.host;
|
|
95
|
-
if (config.openapi_url !== void 0 && config.openapi_url !== "") {
|
|
96
|
-
process.env.BGL_OPENAPI_URL = config.openapi_url;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
68
|
function createViteProxy(config) {
|
|
101
69
|
const proxy = {};
|
|
102
70
|
if (config.proxy && config.host) {
|
|
@@ -175,4 +143,4 @@ function createWorkspace(options = {}) {
|
|
|
175
143
|
};
|
|
176
144
|
}
|
|
177
145
|
|
|
178
|
-
export { createCustomProxy, createViteProxy, createWorkspace, defineWorkspace,
|
|
146
|
+
export { createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateWorkspaceConfig, mergeConfigs, resolveConfig, setBuildEnvVars, writeNetlifyConfig };
|