File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
storage/framework/core/buddy Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 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
-
8
1
import process from 'node:process'
9
- import { execSync } from 'node:child_process'
10
2
import { existsSync } from 'node:fs'
3
+ import { $ } from 'bun'
11
4
import { cac } from 'cac'
12
5
13
6
const cli = cac ( )
19
12
const buddyCli = 'buddy'
20
13
21
14
if ( existsSync ( buddyCli ) )
22
- execSync ( `${ buddyCli } ${ process . argv . slice ( 2 ) . join ( ' ' ) } ` , { stdio : 'inherit' } )
15
+ $ `${ buddyCli } ${ process . argv . slice ( 2 ) . join ( ' ' ) } `
23
16
24
17
let currentDir = process . cwd ( )
25
18
let found = false
26
19
27
20
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
29
22
found = true
30
23
break
31
24
}
38
31
process . exit ( 1 )
39
32
}
40
33
41
- execSync ( `bunx stacks new ${ process . argv . slice ( 2 ) . join ( ' ' ) } ` , { stdio : 'inherit' } )
34
+ $ `bunx stacks new ${ process . argv . slice ( 2 ) . join ( ' ' ) } `
42
35
} )
43
36
44
37
cli . parse ( )
Original file line number Diff line number Diff line change 1
1
import { log , runCommand } from '@stacksjs/cli'
2
2
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' , {
4
4
cwd : import . meta. dir ,
5
5
} )
6
6
7
7
if ( result . isErr ( ) )
8
8
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 )
You can’t perform that action at this time.
0 commit comments