Skip to content

Commit fe84b75

Browse files
committed
chore: wip
1 parent f50bd21 commit fe84b75

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

storage/framework/core/buddy/bin/cli.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
// 1. need to check if in stacks project scope by checking whether the file `buddy` exists or a storage/framework/core/buddy exists
2-
// 2. if it does, then we proxy the command to the buddy cli via `./buddy <command> <args>`
3-
// 3. if it doesn't, we go up the directory tree and check again until we reach the root
4-
// 4. if we reach the root and still don't find the buddy cli, we throw an error asking the user if they want to set up a new stacks project
5-
// 5. if the user says yes, we create a new stacks project and proxy the command via `bunx stacks new <project-name>`
6-
// 6. if the user says no, we throw an error and exit
7-
81
import process from 'node:process'
9-
import { execSync } from 'node:child_process'
102
import { existsSync } from 'node:fs'
3+
import { $ } from 'bun'
114
import { cac } from 'cac'
125

136
const cli = cac()
@@ -19,13 +12,13 @@ cli
1912
const buddyCli = 'buddy'
2013

2114
if (existsSync(buddyCli))
22-
execSync(`${buddyCli} ${process.argv.slice(2).join(' ')}`, { stdio: 'inherit' })
15+
$`${buddyCli} ${process.argv.slice(2).join(' ')}`
2316

2417
let currentDir = process.cwd()
2518
let found = false
2619

2720
while (currentDir !== '/') {
28-
if (existsSync(`${currentDir}/storage/framework/core/buddy`)) {
21+
if (existsSync(`${currentDir}/storage/framework/core/buddy`)) { // if the buddy directory exists, we know we are in a stacks project
2922
found = true
3023
break
3124
}
@@ -38,7 +31,7 @@ cli
3831
process.exit(1)
3932
}
4033

41-
execSync(`bunx stacks new ${process.argv.slice(2).join(' ')}`, { stdio: 'inherit' })
34+
$`bunx stacks new ${process.argv.slice(2).join(' ')}`
4235
})
4336

4437
cli.parse()

storage/framework/core/buddy/build.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts ./src/cli.ts --outdir dist --format esm --target bun --external @stacksjs/actions --external @stacksjs/enums --external @stacksjs/config --external @stacksjs/dns --external @stacksjs/error-handling --external @stacksjs/cli --external @stacksjs/cloud --external @stacksjs/logging --external @stacksjs/utils --external @stacksjs/validation --external @stacksjs/path --external @stacksjs/storage --external @stacksjs/types --external @aws-sdk/client-route-53 --splitting --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts ./src/cli.ts --outdir dist --format esm --external @stacksjs/actions --external @stacksjs/enums --external @stacksjs/config --external @stacksjs/dns --external @stacksjs/error-handling --external @stacksjs/cli --external @stacksjs/cloud --external @stacksjs/logging --external @stacksjs/utils --external @stacksjs/validation --external @stacksjs/path --external @stacksjs/storage --external @stacksjs/types --external @aws-sdk/client-route-53 --splitting --target bun', {
44
cwd: import.meta.dir,
55
})
66

77
if (result.isErr())
88
log.error(result.error)
9+
10+
const binaryResult = await runCommand('bun build ./bin/cli.ts --compile --outfile buddy', {
11+
cwd: import.meta.dir,
12+
})
13+
14+
if (binaryResult.isErr())
15+
log.error(binaryResult.error)

0 commit comments

Comments
 (0)