Skip to content

Commit

Permalink
add bun commands (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsumura-h authored Sep 30, 2023
1 parent 1ae9921 commit e02d57d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/palladian/cli/functions/add_impl.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import std/osproc
import std/strutils
import std/strformat

proc add*(dev=false, args:seq[string]):int =
## = `bun add xx`. Add a dependency to package.json
let packages = args.join(" ")
let isDev = if dev: "-d" else: ""
echo execProcess(&"bun add {isDev} {packages}")
1 change: 1 addition & 0 deletions src/palladian/cli/functions/install_impl.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import std/osproc

proc install*() =
## = `bun install`. Install dependencies for a package.json
echo execProcess("bun install")
2 changes: 1 addition & 1 deletion src/palladian/cli/functions/new_impl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Successfully created a new palladian project "{packageName}"


proc new*(args:seq[string]):int =
## Create new project
## Create a new project
var
message:string
packageName:string
Expand Down
8 changes: 8 additions & 0 deletions src/palladian/cli/functions/remove_impl.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import std/osproc
import std/strutils
import std/strformat

proc remove*(args:seq[string]):int =
## = `bun remove xx`. Remove a dependency from package.json
let packages = args.join(" ")
echo execProcess(&"bun remove {packages}")
5 changes: 5 additions & 0 deletions src/palladian/cli/functions/update_impl.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import std/osproc

proc update*() =
## = `bun update`. Update outdated dependencies.
echo execProcess("bun update")
15 changes: 14 additions & 1 deletion src/palladian/cli/palladian_cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,18 @@ import ./functions/dev_impl
import ./functions/serve_impl
import ./functions/build_impl
import ./functions/install_impl
import ./functions/add_impl
import ./functions/remove_impl
import ./functions/update_impl

dispatchMulti([newImpl.new], [serve], [dev], [build], [install_impl.install])

dispatchMulti(
[newImpl.new],
[dev_impl.dev],
[serve_impl.serve],
[build_impl.build],
[install_impl.install],
[add_impl.add, help={"dev": "Add dependency to \"devDependencies\""}],
[remove_impl.remove],
[update_impl.update]
)

0 comments on commit e02d57d

Please sign in to comment.