@bagelink/workspace 1.9.0 → 1.10.0

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
@@ -311,6 +311,71 @@ bgl lint init --workspace
311
311
 
312
312
  Sets up linting at workspace root level for all projects.
313
313
 
314
+ ### SDK Generation
315
+
316
+ #### `bgl sdk generate`
317
+
318
+ Generate TypeScript SDK from OpenAPI specification:
319
+
320
+ ```bash
321
+ bgl sdk generate
322
+
323
+ ? OpenAPI spec URL: › http://localhost:8000/openapi.json
324
+ ? Output directory: › ./src/api
325
+ ? Split into organized files? › Yes
326
+
327
+ 📡 Fetching OpenAPI spec from: http://localhost:8000/openapi.json
328
+ 📁 Output directory: ./src/api
329
+
330
+ ✅ Generated types.d.ts
331
+ ✅ Generated api.ts
332
+ ✅ Generated index.ts
333
+ 🔀 Splitting into organized files...
334
+ ✅ Files organized into directories
335
+
336
+ ✅ SDK generated successfully!
337
+
338
+ Import it in your code:
339
+ import { api } from './api'
340
+ ```
341
+
342
+ **Features:**
343
+ - Auto-reads `openapi_url` from `bgl.config.ts`
344
+ - Generates TypeScript types from OpenAPI schema
345
+ - Creates type-safe API client
346
+ - Optional file organization (split by endpoints)
347
+ - Works with both local and remote OpenAPI specs
348
+
349
+ **For workspace:**
350
+ ```bash
351
+ bgl sdk generate --workspace
352
+
353
+ ? Select projects to generate SDK for:
354
+ ✔ admin
355
+ ✔ customer
356
+ ✔ mobile
357
+ ```
358
+
359
+ Generates SDK for multiple projects from their respective `openapi_url` configs.
360
+
361
+ **Generated structure:**
362
+ ```
363
+ src/api/
364
+ ├── index.ts # Main export
365
+ ├── types.d.ts # TypeScript types
366
+ └── api.ts # API client
367
+
368
+ # Or with --split:
369
+ src/api/
370
+ ├── endpoints/
371
+ │ ├── users.ts
372
+ │ ├── auth.ts
373
+ │ └── data.ts
374
+ ├── types/
375
+ │ └── index.ts
376
+ └── index.ts
377
+ ```
378
+
314
379
  ### `npx bgl --help`
315
380
 
316
381
  Show CLI help.
package/bin/bgl.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import process from 'node:process'
3
3
  import { generateWorkspaceConfig } from '../src/init.js'
4
- import { addProject, initWorkspace, listProjects } from '../src/workspace.js'
5
4
  import { setupLint } from '../src/lint.js'
5
+ import { generateSDK, generateSDKForWorkspace } from '../src/sdk.js'
6
+ import { addProject, initWorkspace, listProjects } from '../src/workspace.js'
6
7
 
7
8
  const [,, command, subcommand, ...args] = process.argv
8
9
 
@@ -32,7 +33,7 @@ async function main() {
32
33
  }
33
34
  else {
34
35
  console.log('\nProjects:')
35
- projects.forEach(p => console.log(` - ${p}`))
36
+ projects.forEach((p) => { console.log(` - ${p}`) })
36
37
  console.log('')
37
38
  }
38
39
  }
@@ -46,6 +47,26 @@ async function main() {
46
47
  Lint Commands:
47
48
  bgl lint init Set up linting in current project
48
49
  bgl lint init --workspace Set up linting for workspace root
50
+ `)
51
+ process.exit(1)
52
+ }
53
+ }
54
+ else if (command === 'sdk') {
55
+ if (subcommand === 'generate') {
56
+ const isWorkspace = args.includes('--workspace') || args.includes('-w')
57
+ if (isWorkspace) {
58
+ await generateSDKForWorkspace()
59
+ }
60
+ else {
61
+ const projectName = args.find(arg => !arg.startsWith('-'))
62
+ await generateSDK(process.cwd(), projectName)
63
+ }
64
+ }
65
+ else {
66
+ console.log(`
67
+ SDK Commands:
68
+ bgl sdk generate Generate SDK from OpenAPI spec
69
+ bgl sdk generate --workspace Generate SDK for all workspace projects
49
70
  `)
50
71
  process.exit(1)
51
72
  }
@@ -55,15 +76,17 @@ Lint Commands:
55
76
  Bagel Workspace CLI
56
77
 
57
78
  Usage:
58
- bgl init Generate bgl.config.ts for single project
59
- bgl init --workspace Create a new workspace with multiple projects
60
- bgl add <name> Add a new project to workspace
61
- bgl list List all projects in workspace
62
- bgl lint init Set up linting in current project
63
- bgl lint init --workspace Set up linting for workspace root
79
+ bgl init Generate bgl.config.ts for single project
80
+ bgl init --workspace Create a new workspace with multiple projects
81
+ bgl add <name> Add a new project to workspace
82
+ bgl list List all projects in workspace
83
+ bgl lint init Set up linting in current project
84
+ bgl lint init --workspace Set up linting for workspace root
85
+ bgl sdk generate Generate SDK from OpenAPI spec
86
+ bgl sdk generate --workspace Generate SDK for all workspace projects
64
87
 
65
88
  Options:
66
- --help, -h Show this help message
89
+ --help, -h Show this help message
67
90
  `)
68
91
  process.exit(command === '--help' || command === '-h' ? 0 : 1)
69
92
  }
package/dist/bin/bgl.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const process = require('node:process');
5
- const lint = require('../shared/workspace.CCUm_5GG.cjs');
5
+ const workspace = require('../shared/workspace.dQE-K3dI.cjs');
6
6
  require('node:fs');
7
7
  require('node:path');
8
8
  require('prompts');
@@ -16,9 +16,9 @@ async function main() {
16
16
  if (command === "init") {
17
17
  const isWorkspace = args.includes("--workspace") || args.includes("-w");
18
18
  if (isWorkspace) {
19
- await lint.initWorkspace();
19
+ await workspace.initWorkspace();
20
20
  } else {
21
- await lint.generateWorkspaceConfig();
21
+ await workspace.generateWorkspaceConfig();
22
22
  }
23
23
  } else if (command === "add") {
24
24
  const projectName = args[0];
@@ -27,25 +27,44 @@ async function main() {
27
27
  console.log("Usage: bgl add <project-name>");
28
28
  process__default.exit(1);
29
29
  }
30
- await lint.addProject(projectName);
30
+ await workspace.addProject(projectName);
31
31
  } else if (command === "list") {
32
- const projects = lint.listProjects();
32
+ const projects = workspace.listProjects();
33
33
  if (projects.length === 0) {
34
34
  console.log("No projects found");
35
35
  } else {
36
36
  console.log("\nProjects:");
37
- projects.forEach((p) => console.log(` - ${p}`));
37
+ projects.forEach((p) => {
38
+ console.log(` - ${p}`);
39
+ });
38
40
  console.log("");
39
41
  }
40
42
  } else if (command === "lint") {
41
43
  if (subcommand === "init") {
42
44
  const isWorkspace = args.includes("--workspace") || args.includes("-w");
43
- await lint.setupLint(process__default.cwd(), isWorkspace);
45
+ await workspace.setupLint(process__default.cwd(), isWorkspace);
44
46
  } else {
45
47
  console.log(`
46
48
  Lint Commands:
47
49
  bgl lint init Set up linting in current project
48
50
  bgl lint init --workspace Set up linting for workspace root
51
+ `);
52
+ process__default.exit(1);
53
+ }
54
+ } else if (command === "sdk") {
55
+ if (subcommand === "generate") {
56
+ const isWorkspace = args.includes("--workspace") || args.includes("-w");
57
+ if (isWorkspace) {
58
+ await workspace.generateSDKForWorkspace();
59
+ } else {
60
+ args.find((arg) => !arg.startsWith("-"));
61
+ await workspace.generateSDK(process__default.cwd());
62
+ }
63
+ } else {
64
+ console.log(`
65
+ SDK Commands:
66
+ bgl sdk generate Generate SDK from OpenAPI spec
67
+ bgl sdk generate --workspace Generate SDK for all workspace projects
49
68
  `);
50
69
  process__default.exit(1);
51
70
  }
@@ -54,15 +73,17 @@ Lint Commands:
54
73
  Bagel Workspace CLI
55
74
 
56
75
  Usage:
57
- bgl init Generate bgl.config.ts for single project
58
- bgl init --workspace Create a new workspace with multiple projects
59
- bgl add <name> Add a new project to workspace
60
- bgl list List all projects in workspace
61
- bgl lint init Set up linting in current project
62
- bgl lint init --workspace Set up linting for workspace root
76
+ bgl init Generate bgl.config.ts for single project
77
+ bgl init --workspace Create a new workspace with multiple projects
78
+ bgl add <name> Add a new project to workspace
79
+ bgl list List all projects in workspace
80
+ bgl lint init Set up linting in current project
81
+ bgl lint init --workspace Set up linting for workspace root
82
+ bgl sdk generate Generate SDK from OpenAPI spec
83
+ bgl sdk generate --workspace Generate SDK for all workspace projects
63
84
 
64
85
  Options:
65
- --help, -h Show this help message
86
+ --help, -h Show this help message
66
87
  `);
67
88
  process__default.exit(command === "--help" || command === "-h" ? 0 : 1);
68
89
  }
package/dist/bin/bgl.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import process from 'node:process';
3
- import { i as initWorkspace, g as generateWorkspaceConfig, d as addProject, l as listProjects, e as setupLint } from '../shared/workspace.cX7U2RUq.mjs';
3
+ import { i as initWorkspace, g as generateWorkspaceConfig, h as addProject, l as listProjects, d as setupLint, f as generateSDKForWorkspace, e as generateSDK } from '../shared/workspace.CTMBmbXa.mjs';
4
4
  import 'node:fs';
5
5
  import 'node:path';
6
6
  import 'prompts';
@@ -28,7 +28,9 @@ async function main() {
28
28
  console.log("No projects found");
29
29
  } else {
30
30
  console.log("\nProjects:");
31
- projects.forEach((p) => console.log(` - ${p}`));
31
+ projects.forEach((p) => {
32
+ console.log(` - ${p}`);
33
+ });
32
34
  console.log("");
33
35
  }
34
36
  } else if (command === "lint") {
@@ -40,6 +42,23 @@ async function main() {
40
42
  Lint Commands:
41
43
  bgl lint init Set up linting in current project
42
44
  bgl lint init --workspace Set up linting for workspace root
45
+ `);
46
+ process.exit(1);
47
+ }
48
+ } else if (command === "sdk") {
49
+ if (subcommand === "generate") {
50
+ const isWorkspace = args.includes("--workspace") || args.includes("-w");
51
+ if (isWorkspace) {
52
+ await generateSDKForWorkspace();
53
+ } else {
54
+ args.find((arg) => !arg.startsWith("-"));
55
+ await generateSDK(process.cwd());
56
+ }
57
+ } else {
58
+ console.log(`
59
+ SDK Commands:
60
+ bgl sdk generate Generate SDK from OpenAPI spec
61
+ bgl sdk generate --workspace Generate SDK for all workspace projects
43
62
  `);
44
63
  process.exit(1);
45
64
  }
@@ -48,15 +67,17 @@ Lint Commands:
48
67
  Bagel Workspace CLI
49
68
 
50
69
  Usage:
51
- bgl init Generate bgl.config.ts for single project
52
- bgl init --workspace Create a new workspace with multiple projects
53
- bgl add <name> Add a new project to workspace
54
- bgl list List all projects in workspace
55
- bgl lint init Set up linting in current project
56
- bgl lint init --workspace Set up linting for workspace root
70
+ bgl init Generate bgl.config.ts for single project
71
+ bgl init --workspace Create a new workspace with multiple projects
72
+ bgl add <name> Add a new project to workspace
73
+ bgl list List all projects in workspace
74
+ bgl lint init Set up linting in current project
75
+ bgl lint init --workspace Set up linting for workspace root
76
+ bgl sdk generate Generate SDK from OpenAPI spec
77
+ bgl sdk generate --workspace Generate SDK for all workspace projects
57
78
 
58
79
  Options:
59
- --help, -h Show this help message
80
+ --help, -h Show this help message
60
81
  `);
61
82
  process.exit(command === "--help" || command === "-h" ? 0 : 1);
62
83
  }
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 lint = require('./shared/workspace.CCUm_5GG.cjs');
6
+ const workspace = require('./shared/workspace.dQE-K3dI.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 lint.generateWorkspaceConfig(root, configFile);
35
+ await workspace.generateWorkspaceConfig(root, configFile);
36
36
  const newConfig = await loadConfig(localConfigPath, mode);
37
37
  if (newConfig) {
38
38
  return newConfig;
@@ -131,13 +131,13 @@ function createWorkspace(options = {}) {
131
131
  * Generate Netlify configuration file
132
132
  */
133
133
  generateNetlify(config, outPath = "./netlify.toml", additionalConfig) {
134
- lint.writeNetlifyConfig(config, outPath, additionalConfig);
134
+ workspace.writeNetlifyConfig(config, outPath, additionalConfig);
135
135
  },
136
136
  /**
137
137
  * Set build environment variables
138
138
  */
139
139
  setBuildEnv(config) {
140
- lint.setBuildEnvVars(config);
140
+ workspace.setBuildEnvVars(config);
141
141
  },
142
142
  /**
143
143
  * Clear cached configuration
@@ -148,16 +148,18 @@ function createWorkspace(options = {}) {
148
148
  };
149
149
  }
150
150
 
151
- exports.addProject = lint.addProject;
152
- exports.generateNetlifyConfig = lint.generateNetlifyConfig;
153
- exports.generateNetlifyRedirect = lint.generateNetlifyRedirect;
154
- exports.generateWorkspaceConfig = lint.generateWorkspaceConfig;
155
- exports.generateWorkspaceConfigSync = lint.generateWorkspaceConfigSync;
156
- exports.initWorkspace = lint.initWorkspace;
157
- exports.listProjects = lint.listProjects;
158
- exports.setBuildEnvVars = lint.setBuildEnvVars;
159
- exports.setupLint = lint.setupLint;
160
- exports.writeNetlifyConfig = lint.writeNetlifyConfig;
151
+ exports.addProject = workspace.addProject;
152
+ exports.generateNetlifyConfig = workspace.generateNetlifyConfig;
153
+ exports.generateNetlifyRedirect = workspace.generateNetlifyRedirect;
154
+ exports.generateSDK = workspace.generateSDK;
155
+ exports.generateSDKForWorkspace = workspace.generateSDKForWorkspace;
156
+ exports.generateWorkspaceConfig = workspace.generateWorkspaceConfig;
157
+ exports.generateWorkspaceConfigSync = workspace.generateWorkspaceConfigSync;
158
+ exports.initWorkspace = workspace.initWorkspace;
159
+ exports.listProjects = workspace.listProjects;
160
+ exports.setBuildEnvVars = workspace.setBuildEnvVars;
161
+ exports.setupLint = workspace.setupLint;
162
+ exports.writeNetlifyConfig = workspace.writeNetlifyConfig;
161
163
  exports.createCustomProxy = createCustomProxy;
162
164
  exports.createViteProxy = createViteProxy;
163
165
  exports.createWorkspace = createWorkspace;
package/dist/index.d.cts CHANGED
@@ -91,6 +91,20 @@ 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, projectName?: string): Promise<void>;
103
+ /**
104
+ * Generate SDK for all projects in workspace
105
+ */
106
+ declare function generateSDKForWorkspace(root?: string): Promise<void>;
107
+
94
108
  /**
95
109
  * Initialize a new workspace with flat structure
96
110
  */
@@ -104,11 +118,6 @@ declare function addProject(name: string, root?: string): Promise<void>;
104
118
  */
105
119
  declare function listProjects(root?: string): string[];
106
120
 
107
- /**
108
- * Set up linting in a project
109
- */
110
- declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
111
-
112
121
  /**
113
122
  * Define workspace configuration
114
123
  * Simple helper to get config from a config map
@@ -141,5 +150,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
141
150
  clearCache(): void;
142
151
  };
143
152
 
144
- export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
153
+ export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
145
154
  export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
package/dist/index.d.mts CHANGED
@@ -91,6 +91,20 @@ 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, projectName?: string): Promise<void>;
103
+ /**
104
+ * Generate SDK for all projects in workspace
105
+ */
106
+ declare function generateSDKForWorkspace(root?: string): Promise<void>;
107
+
94
108
  /**
95
109
  * Initialize a new workspace with flat structure
96
110
  */
@@ -104,11 +118,6 @@ declare function addProject(name: string, root?: string): Promise<void>;
104
118
  */
105
119
  declare function listProjects(root?: string): string[];
106
120
 
107
- /**
108
- * Set up linting in a project
109
- */
110
- declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
111
-
112
121
  /**
113
122
  * Define workspace configuration
114
123
  * Simple helper to get config from a config map
@@ -141,5 +150,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
141
150
  clearCache(): void;
142
151
  };
143
152
 
144
- export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
153
+ export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
145
154
  export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
package/dist/index.d.ts CHANGED
@@ -91,6 +91,20 @@ 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, projectName?: string): Promise<void>;
103
+ /**
104
+ * Generate SDK for all projects in workspace
105
+ */
106
+ declare function generateSDKForWorkspace(root?: string): Promise<void>;
107
+
94
108
  /**
95
109
  * Initialize a new workspace with flat structure
96
110
  */
@@ -104,11 +118,6 @@ declare function addProject(name: string, root?: string): Promise<void>;
104
118
  */
105
119
  declare function listProjects(root?: string): string[];
106
120
 
107
- /**
108
- * Set up linting in a project
109
- */
110
- declare function setupLint(root?: string, isWorkspace?: boolean): Promise<void>;
111
-
112
121
  /**
113
122
  * Define workspace configuration
114
123
  * Simple helper to get config from a config map
@@ -141,5 +150,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
141
150
  clearCache(): void;
142
151
  };
143
152
 
144
- export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
153
+ export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, initWorkspace, listProjects, mergeConfigs, resolveConfig, setBuildEnvVars, setupLint, writeNetlifyConfig };
145
154
  export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
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, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.cX7U2RUq.mjs';
5
- export { d as addProject, a as generateNetlifyConfig, b as generateNetlifyRedirect, c as generateWorkspaceConfigSync, i as initWorkspace, l as listProjects, e as setupLint } from './shared/workspace.cX7U2RUq.mjs';
4
+ import { g as generateWorkspaceConfig, s as setBuildEnvVars, w as writeNetlifyConfig } from './shared/workspace.CTMBmbXa.mjs';
5
+ export { h as addProject, a as generateNetlifyConfig, b as generateNetlifyRedirect, e as generateSDK, f as generateSDKForWorkspace, c as generateWorkspaceConfigSync, i as initWorkspace, l as listProjects, d as setupLint } from './shared/workspace.CTMBmbXa.mjs';
6
6
  import 'prompts';
7
7
 
8
8
  async function resolveConfig(mode = "development", options = {}) {