@bagelink/workspace 1.10.6 → 1.11.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/bin/bgl.ts CHANGED
@@ -10,7 +10,12 @@ const [,, command, subcommand, ...args] = process.argv
10
10
 
11
11
  async function main() {
12
12
  if (command === 'init') {
13
- const createWorkspace = args.includes('--workspace') || args.includes('-w')
13
+ // Check both subcommand and args for --workspace flag
14
+ const createWorkspace
15
+ = subcommand === '--workspace'
16
+ || subcommand === '-w'
17
+ || args.includes('--workspace')
18
+ || args.includes('-w')
14
19
  if (createWorkspace) {
15
20
  await initWorkspace()
16
21
  }
@@ -19,7 +24,7 @@ async function main() {
19
24
  }
20
25
  }
21
26
  else if (command === 'add') {
22
- const projectName = args[0]
27
+ const projectName = subcommand // 'bgl add admin' -> subcommand is 'admin'
23
28
  if (!projectName) {
24
29
  console.error('Error: Project name is required')
25
30
  console.log('Usage: bgl add <project-name>')
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 detect = require('../shared/workspace.DQ-r7Tja.cjs');
5
+ const detect = require('../shared/workspace.BMTTo3s8.cjs');
6
6
  require('node:fs');
7
7
  require('node:path');
8
8
  require('prompts');
@@ -14,14 +14,14 @@ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
14
14
  const [, , command, subcommand, ...args] = process__default.argv;
15
15
  async function main() {
16
16
  if (command === "init") {
17
- const createWorkspace = args.includes("--workspace") || args.includes("-w");
17
+ const createWorkspace = subcommand === "--workspace" || subcommand === "-w" || args.includes("--workspace") || args.includes("-w");
18
18
  if (createWorkspace) {
19
19
  await detect.initWorkspace();
20
20
  } else {
21
21
  await detect.generateWorkspaceConfig();
22
22
  }
23
23
  } else if (command === "add") {
24
- const projectName = args[0];
24
+ const projectName = subcommand;
25
25
  if (!projectName) {
26
26
  console.error("Error: Project name is required");
27
27
  console.log("Usage: bgl add <project-name>");
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, h as addProject, l as listProjects, k as isWorkspace, d as setupLint, f as generateSDKForWorkspace, e as generateSDK } from '../shared/workspace.Dq4_YhqE.mjs';
3
+ import { i as initWorkspace, g as generateWorkspaceConfig, h as addProject, l as listProjects, k as isWorkspace, d as setupLint, f as generateSDKForWorkspace, e as generateSDK } from '../shared/workspace.COhZ__uF.mjs';
4
4
  import 'node:fs';
5
5
  import 'node:path';
6
6
  import 'prompts';
@@ -8,14 +8,14 @@ import 'prompts';
8
8
  const [, , command, subcommand, ...args] = process.argv;
9
9
  async function main() {
10
10
  if (command === "init") {
11
- const createWorkspace = args.includes("--workspace") || args.includes("-w");
11
+ const createWorkspace = subcommand === "--workspace" || subcommand === "-w" || args.includes("--workspace") || args.includes("-w");
12
12
  if (createWorkspace) {
13
13
  await initWorkspace();
14
14
  } else {
15
15
  await generateWorkspaceConfig();
16
16
  }
17
17
  } else if (command === "add") {
18
- const projectName = args[0];
18
+ const projectName = subcommand;
19
19
  if (!projectName) {
20
20
  console.error("Error: Project name is required");
21
21
  console.log("Usage: bgl add <project-name>");
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 detect = require('./shared/workspace.DQ-r7Tja.cjs');
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; }
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.Dq4_YhqE.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.Dq4_YhqE.mjs';
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 = {}) {
@@ -566,10 +566,11 @@ async function initWorkspace(root = process__default.cwd()) {
566
566
  process__default.exit(1);
567
567
  }
568
568
  const { workspaceName, projectId, createFirstProject, firstProjectName } = response;
569
+ const workspaceDir = node_path.resolve(root, workspaceName);
569
570
  createWorkspaceRoot(root, workspaceName, projectId);
570
- createSharedPackage(root);
571
+ createSharedPackage(workspaceDir);
571
572
  if (createFirstProject && firstProjectName) {
572
- await addProject(firstProjectName, root);
573
+ await addProject(firstProjectName, workspaceDir);
573
574
  }
574
575
  console.log("\n\u2705 Workspace created successfully!");
575
576
  console.log("\nNext steps:");
@@ -594,7 +595,8 @@ function createWorkspaceRoot(root, name, projectId) {
594
595
  private: true,
595
596
  workspaces: ["*", "!node_modules"],
596
597
  scripts: {
597
- dev: "bun run --filter './[!shared]*' dev",
598
+ dev: "bun scripts/dev.ts",
599
+ "dev:verbose": "bun run --filter './[!shared]*' dev",
598
600
  build: "bun run --filter './[!shared]*' build",
599
601
  typecheck: "tsc --noEmit"
600
602
  },
@@ -666,6 +668,72 @@ dist
666
668
  .vite
667
669
  `;
668
670
  node_fs.writeFileSync(node_path.resolve(workspaceDir, ".gitignore"), gitignore);
671
+ const scriptsDir = node_path.resolve(workspaceDir, "scripts");
672
+ node_fs.mkdirSync(scriptsDir, { recursive: true });
673
+ const devRunnerContent = `#!/usr/bin/env bun
674
+ import { spawn } from 'bun'
675
+ import { readdir } from 'fs/promises'
676
+ import { resolve } from 'path'
677
+
678
+ const projectsRoot = process.cwd()
679
+ const projects = (await readdir(projectsRoot, { withFileTypes: true }))
680
+ .filter(
681
+ item =>
682
+ item.isDirectory()
683
+ && item.name !== 'node_modules'
684
+ && item.name !== 'shared'
685
+ && item.name !== 'scripts'
686
+ && item.name !== '.git'
687
+ && !item.name.startsWith('.'),
688
+ )
689
+ .map(item => item.name)
690
+
691
+ console.log(\`\\n\u{1F680} Starting \${projects.length} project\${projects.length > 1 ? 's' : ''}...\\n\`)
692
+
693
+ const urlPattern = /Local:\\s+(http:\\/\\/localhost:\\d+)/
694
+
695
+ projects.forEach((project) => {
696
+ const proc = spawn({
697
+ cmd: ['bun', 'run', 'dev'],
698
+ cwd: resolve(projectsRoot, project),
699
+ stdout: 'pipe',
700
+ stderr: 'pipe',
701
+ })
702
+
703
+ const decoder = new TextDecoder()
704
+
705
+ proc.stdout.pipeTo(
706
+ new WritableStream({
707
+ write(chunk) {
708
+ const text = decoder.decode(chunk)
709
+ const match = text.match(urlPattern)
710
+ if (match) {
711
+ console.log(\` \u2713 \${project.padEnd(15)} \u2192 \${match[1]}\`)
712
+ }
713
+ },
714
+ }),
715
+ )
716
+
717
+ proc.stderr.pipeTo(
718
+ new WritableStream({
719
+ write(chunk) {
720
+ const text = decoder.decode(chunk)
721
+ if (text.includes('error') || text.includes('Error')) {
722
+ console.error(\` \u2717 \${project}: \${text.trim()}\`)
723
+ }
724
+ },
725
+ }),
726
+ )
727
+ })
728
+
729
+ console.log('\\n\u{1F4A1} Press Ctrl+C to stop all servers\\n')
730
+
731
+ process.on('SIGINT', () => {
732
+ console.log('\\n\\n\u{1F44B} Stopping all servers...\\n')
733
+ process.exit()
734
+ })
735
+ `;
736
+ node_fs.writeFileSync(node_path.resolve(scriptsDir, "dev.ts"), devRunnerContent);
669
737
  console.log(`\u2705 Created workspace: ${name}`);
670
738
  }
671
739
  function createSharedPackage(root) {
@@ -559,10 +559,11 @@ async function initWorkspace(root = process.cwd()) {
559
559
  process.exit(1);
560
560
  }
561
561
  const { workspaceName, projectId, createFirstProject, firstProjectName } = response;
562
+ const workspaceDir = resolve(root, workspaceName);
562
563
  createWorkspaceRoot(root, workspaceName, projectId);
563
- createSharedPackage(root);
564
+ createSharedPackage(workspaceDir);
564
565
  if (createFirstProject && firstProjectName) {
565
- await addProject(firstProjectName, root);
566
+ await addProject(firstProjectName, workspaceDir);
566
567
  }
567
568
  console.log("\n\u2705 Workspace created successfully!");
568
569
  console.log("\nNext steps:");
@@ -587,7 +588,8 @@ function createWorkspaceRoot(root, name, projectId) {
587
588
  private: true,
588
589
  workspaces: ["*", "!node_modules"],
589
590
  scripts: {
590
- dev: "bun run --filter './[!shared]*' dev",
591
+ dev: "bun scripts/dev.ts",
592
+ "dev:verbose": "bun run --filter './[!shared]*' dev",
591
593
  build: "bun run --filter './[!shared]*' build",
592
594
  typecheck: "tsc --noEmit"
593
595
  },
@@ -659,6 +661,72 @@ dist
659
661
  .vite
660
662
  `;
661
663
  writeFileSync(resolve(workspaceDir, ".gitignore"), gitignore);
664
+ const scriptsDir = resolve(workspaceDir, "scripts");
665
+ mkdirSync(scriptsDir, { recursive: true });
666
+ const devRunnerContent = `#!/usr/bin/env bun
667
+ import { spawn } from 'bun'
668
+ import { readdir } from 'fs/promises'
669
+ import { resolve } from 'path'
670
+
671
+ const projectsRoot = process.cwd()
672
+ const projects = (await readdir(projectsRoot, { withFileTypes: true }))
673
+ .filter(
674
+ item =>
675
+ item.isDirectory()
676
+ && item.name !== 'node_modules'
677
+ && item.name !== 'shared'
678
+ && item.name !== 'scripts'
679
+ && item.name !== '.git'
680
+ && !item.name.startsWith('.'),
681
+ )
682
+ .map(item => item.name)
683
+
684
+ console.log(\`\\n\u{1F680} Starting \${projects.length} project\${projects.length > 1 ? 's' : ''}...\\n\`)
685
+
686
+ const urlPattern = /Local:\\s+(http:\\/\\/localhost:\\d+)/
687
+
688
+ projects.forEach((project) => {
689
+ const proc = spawn({
690
+ cmd: ['bun', 'run', 'dev'],
691
+ cwd: resolve(projectsRoot, project),
692
+ stdout: 'pipe',
693
+ stderr: 'pipe',
694
+ })
695
+
696
+ const decoder = new TextDecoder()
697
+
698
+ proc.stdout.pipeTo(
699
+ new WritableStream({
700
+ write(chunk) {
701
+ const text = decoder.decode(chunk)
702
+ const match = text.match(urlPattern)
703
+ if (match) {
704
+ console.log(\` \u2713 \${project.padEnd(15)} \u2192 \${match[1]}\`)
705
+ }
706
+ },
707
+ }),
708
+ )
709
+
710
+ proc.stderr.pipeTo(
711
+ new WritableStream({
712
+ write(chunk) {
713
+ const text = decoder.decode(chunk)
714
+ if (text.includes('error') || text.includes('Error')) {
715
+ console.error(\` \u2717 \${project}: \${text.trim()}\`)
716
+ }
717
+ },
718
+ }),
719
+ )
720
+ })
721
+
722
+ console.log('\\n\u{1F4A1} Press Ctrl+C to stop all servers\\n')
723
+
724
+ process.on('SIGINT', () => {
725
+ console.log('\\n\\n\u{1F44B} Stopping all servers...\\n')
726
+ process.exit()
727
+ })
728
+ `;
729
+ writeFileSync(resolve(scriptsDir, "dev.ts"), devRunnerContent);
662
730
  console.log(`\u2705 Created workspace: ${name}`);
663
731
  }
664
732
  function createSharedPackage(root) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/workspace",
3
3
  "type": "module",
4
- "version": "1.10.6",
4
+ "version": "1.11.0",
5
5
  "description": "Monorepo workspace tooling for Bagel projects with proxy and config management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
package/src/workspace.ts CHANGED
@@ -43,14 +43,16 @@ export async function initWorkspace(root: string = process.cwd()): Promise<void>
43
43
 
44
44
  const { workspaceName, projectId, createFirstProject, firstProjectName } = response
45
45
 
46
+ const workspaceDir = resolve(root, workspaceName)
47
+
46
48
  // Create workspace structure
47
49
  createWorkspaceRoot(root, workspaceName, projectId)
48
50
 
49
51
  // Create shared package
50
- createSharedPackage(root)
52
+ createSharedPackage(workspaceDir)
51
53
 
52
54
  if (createFirstProject && firstProjectName) {
53
- await addProject(firstProjectName, root)
55
+ await addProject(firstProjectName, workspaceDir)
54
56
  }
55
57
 
56
58
  console.log('\n✅ Workspace created successfully!')
@@ -85,7 +87,8 @@ function createWorkspaceRoot(root: string, name: string, projectId: string): voi
85
87
  private: true,
86
88
  workspaces: ['*', '!node_modules'],
87
89
  scripts: {
88
- dev: 'bun run --filter \'./[!shared]*\' dev',
90
+ dev: 'bun scripts/dev.ts',
91
+ 'dev:verbose': 'bun run --filter \'./[!shared]*\' dev',
89
92
  build: 'bun run --filter \'./[!shared]*\' build',
90
93
  typecheck: 'tsc --noEmit',
91
94
  },
@@ -166,6 +169,77 @@ dist
166
169
 
167
170
  writeFileSync(resolve(workspaceDir, '.gitignore'), gitignore)
168
171
 
172
+ // Create scripts directory
173
+ const scriptsDir = resolve(workspaceDir, 'scripts')
174
+ mkdirSync(scriptsDir, { recursive: true })
175
+
176
+ // Copy dev runner script
177
+ const devRunnerContent = `#!/usr/bin/env bun
178
+ import { spawn } from 'bun'
179
+ import { readdir } from 'fs/promises'
180
+ import { resolve } from 'path'
181
+
182
+ const projectsRoot = process.cwd()
183
+ const projects = (await readdir(projectsRoot, { withFileTypes: true }))
184
+ .filter(
185
+ item =>
186
+ item.isDirectory()
187
+ && item.name !== 'node_modules'
188
+ && item.name !== 'shared'
189
+ && item.name !== 'scripts'
190
+ && item.name !== '.git'
191
+ && !item.name.startsWith('.'),
192
+ )
193
+ .map(item => item.name)
194
+
195
+ console.log(\`\\n🚀 Starting \${projects.length} project\${projects.length > 1 ? 's' : ''}...\\n\`)
196
+
197
+ const urlPattern = /Local:\\s+(http:\\/\\/localhost:\\d+)/
198
+
199
+ projects.forEach((project) => {
200
+ const proc = spawn({
201
+ cmd: ['bun', 'run', 'dev'],
202
+ cwd: resolve(projectsRoot, project),
203
+ stdout: 'pipe',
204
+ stderr: 'pipe',
205
+ })
206
+
207
+ const decoder = new TextDecoder()
208
+
209
+ proc.stdout.pipeTo(
210
+ new WritableStream({
211
+ write(chunk) {
212
+ const text = decoder.decode(chunk)
213
+ const match = text.match(urlPattern)
214
+ if (match) {
215
+ console.log(\` ✓ \${project.padEnd(15)} → \${match[1]}\`)
216
+ }
217
+ },
218
+ }),
219
+ )
220
+
221
+ proc.stderr.pipeTo(
222
+ new WritableStream({
223
+ write(chunk) {
224
+ const text = decoder.decode(chunk)
225
+ if (text.includes('error') || text.includes('Error')) {
226
+ console.error(\` ✗ \${project}: \${text.trim()}\`)
227
+ }
228
+ },
229
+ }),
230
+ )
231
+ })
232
+
233
+ console.log('\\n💡 Press Ctrl+C to stop all servers\\n')
234
+
235
+ process.on('SIGINT', () => {
236
+ console.log('\\n\\n👋 Stopping all servers...\\n')
237
+ process.exit()
238
+ })
239
+ `
240
+
241
+ writeFileSync(resolve(scriptsDir, 'dev.ts'), devRunnerContent)
242
+
169
243
  console.log(`✅ Created workspace: ${name}`)
170
244
  }
171
245
 
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bun
2
+ import { spawn } from 'bun'
3
+ import { readdir } from 'fs/promises'
4
+ import { resolve } from 'path'
5
+
6
+ const projectsRoot = process.cwd()
7
+ const projects = (await readdir(projectsRoot, { withFileTypes: true }))
8
+ .filter(
9
+ item =>
10
+ item.isDirectory()
11
+ && item.name !== 'node_modules'
12
+ && item.name !== 'shared'
13
+ && item.name !== '.git'
14
+ && !item.name.startsWith('.'),
15
+ )
16
+ .map(item => item.name)
17
+
18
+ console.log(`\n🚀 Starting ${projects.length} project${projects.length > 1 ? 's' : ''}...\n`)
19
+
20
+ const urlPattern = /Local:\s+(http:\/\/localhost:\d+)/
21
+
22
+ projects.forEach((project) => {
23
+ const proc = spawn({
24
+ cmd: ['bun', 'run', 'dev'],
25
+ cwd: resolve(projectsRoot, project),
26
+ stdout: 'pipe',
27
+ stderr: 'pipe',
28
+ })
29
+
30
+ const decoder = new TextDecoder()
31
+
32
+ proc.stdout.pipeTo(
33
+ new WritableStream({
34
+ write(chunk) {
35
+ const text = decoder.decode(chunk)
36
+ const match = text.match(urlPattern)
37
+ if (match) {
38
+ console.log(` ✓ ${project.padEnd(15)} → ${match[1]}`)
39
+ }
40
+ },
41
+ }),
42
+ )
43
+
44
+ proc.stderr.pipeTo(
45
+ new WritableStream({
46
+ write(chunk) {
47
+ const text = decoder.decode(chunk)
48
+ if (text.includes('error') || text.includes('Error')) {
49
+ console.error(` ✗ ${project}: ${text.trim()}`)
50
+ }
51
+ },
52
+ }),
53
+ )
54
+ })
55
+
56
+ console.log('\n💡 Press Ctrl+C to stop all servers\n')
57
+
58
+ process.on('SIGINT', () => {
59
+ console.log('\n\n👋 Stopping all servers...\n')
60
+ process.exit()
61
+ })