diff --git a/README.md b/README.md
index 98083bf..392708c 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,26 @@
# npm.el
-[![MELPA](https://melpa.org/packages/npm-badge.svg)](https://melpa.org/#/npm)
-[![MELPA Stable](https://stable.melpa.org/packages/npm-badge.svg)](https://stable.melpa.org/#/npm)
-[![Actions Status](https://github.com/shaneikennedy/npm.el/workflows/check/badge.svg)](https://github.com/shaneikennedy/npm.el/actions)
+[![Actions Status](https://github.com/shaneikennedy/bun.el/workflows/check/badge.svg)](https://github.com/shaneikennedy/bun.el/actions)
-This is an npm client for emacs.
+This is a bun.sh client for emacs.
-## Important
-There is another package [npm-mode](https://github.com/mojochao/npm-mode) that serves a similar purpose to this package. npm-mode offers a way to execute npm commands quickly using key-bindings whereas this package makes use of [transient.el](https://github.com/magit/transient) to offer a more graphical user experience for interacting with npm that I find to be advantageous for exploration and in general when you aren't totally familiar with npm or your current node project. Since both packages serve a similar purpose, they both define a mode called `npm-mode` and as such there would likely be conflicts if both packages were installed. **Choose the package that best fits your desired NPM workflow**.
+This package makes use of [transient.el](https://github.com/magit/transient) to offer an interactive experience with bun that I find to be advantageous for exploration and in general when you aren't totally familiar with bun or your current javascript/typescript project.
## Install
-This package is available on MELPA
+This package is not yet available on MELPA
### Using `use-package`
+`git clone git@github.com:shaneikennedy/bun.el.git /path/to/bun.el`
+
``` emacs-lisp
-(use-package npm
- :ensure t)
+(use-package bun
+ :ensure t
+ :load-path "~/dev/shane/bun.el/")
```
## Usage
-`M-x npm`
-
-|![Startup screen for npm](assets/npm-startup.png "NPM startup") | ![Run screen for npm](assets/npm-run.png "NPM run") |
-:----------------------------------------------------------------------:|:-------------:
-![Install screen for npm](assets/npm-install.png "NPM install") | ![Update screen for npm](assets/npm-update.png "NPM update")
-
-
-### Common workflows
-
-If you use this package to run your dev server, then the default configuration in this package will kill the process every time you need to install/update a package or run a different script (aka not ideal). To keep your dev server (or any long running process) running while you run your other npm workflows with this package, you can set `npm-common-buffer-name-function` to `npm-common-create-unique-buffer-name` which will generate a unique buffer name for each of your workflows. You can set this directly with `setq` or through the cusomtimzation menu for `npm`.
-
+`M-x bun`
-As of right now this package only supports the `npm run, test, install, update, and publish` commands but I hope to add more functionality soon. If you have a command you would really like to see added here please open an issue!
-NPM test uses the [emacs-jest](https://github.com/Emiller88/emacs-jest/tree/4c6ddd3304e199211f0fbdc8a5b83ccbfe1f7fcc) package by default. If you want to run your project's custom test script, for now, use npm-run and choose "test".
+As of right now this package only supports the `bun run, test, install, and update` commands but I hope to add more functionality soon. If you have a command you would really like to see added here please open an issue!
diff --git a/bun-common.el b/bun-common.el
new file mode 100644
index 0000000..a9bfa8c
--- /dev/null
+++ b/bun-common.el
@@ -0,0 +1,87 @@
+;;; bun-common.el --- Run your bun workflows -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Shane Kennedy
+
+;; Author: Shane Kennedy
+;; Homepage: https://github.com/shaneikennedy/bun.el
+;; Keywords: tools
+;; Version: 0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+;; The common functions needed by many or all bun commands.
+
+;;; Code:
+(require 'compile)
+(require 'json)
+(require 'subr-x)
+(require 'transient)
+
+(defgroup bun ()
+ "Group for bun."
+ :group 'tools
+ :prefix "bun-")
+
+(defconst bun-common--config-file "package.json")
+
+(defcustom bun-common-buffer-name-function "*bun*"
+ "Buffer name for `bun' command, or function which return buffer name.
+The function takes three arguments, ROOT, BUN-COMMAND, ARGS.
+ROOT is project root directory. BUN-COMMAND is bun command string.
+ARGS is list of arguments passed to bun command.
+
+You can use `bun-common-create-unique-buffer-name' to use unique buffer name
+among all sesstions."
+ :group 'bun
+ :type '(choice
+ (string :tag "Use same buffer through all sessions")
+ (const :tag "Use unique buffer name among all sessions" bun-common-create-unique-buffer-name)
+ function))
+
+(defun bun-common-create-unique-buffer-name (root bun-command _args)
+ "Create buffer name unique to ROOT and BUN-COMMAND."
+ (concat "*" bun-command " in " root "*"))
+
+(defun bun-common--generate-buffer-name-function (root bun-command args)
+ "Generate function which return buffer name to pass `compilation-start'.
+ROOT is project root directory. BUN-COMMAND is bun command string.
+ARGS is list of arguments passed to bun command.
+
+This function uses `bun-common-buffer-name-function'."
+ (lambda (_)
+ (if (stringp bun-common-buffer-name-function)
+ bun-common-buffer-name-function
+ (funcall bun-common-buffer-name-function
+ root bun-command args))))
+
+;; Common
+(defun bun-common--get-prorect-dir ()
+ "Function to determine the file path of the project root directory."
+ (message (locate-dominating-file (or (buffer-file-name) default-directory)
+ bun-common--config-file)))
+
+(defun bun-common--compile (bun-command &optional args)
+ "Generic compile command for BUN-COMMAND with ARGS functionality."
+ (compilation-start (string-join (list bun-command args) " ")
+ 'bun-mode
+ (bun-common--generate-buffer-name-function
+ (bun-common--get-project-dir) bun-command args)))
+
+(defun bun-common--arguments nil
+ "Arguments function for transient."
+ (transient-args 'bun-menu))
+
+(provide 'bun-common)
+;;; bun-common.el ends here
diff --git a/npm-init.el b/bun-init.el
similarity index 60%
rename from npm-init.el
rename to bun-init.el
index 0cb3ae2..9665c5d 100644
--- a/npm-init.el
+++ b/bun-init.el
@@ -1,9 +1,9 @@
-;;; npm-init.el --- Run your npm workflows -*- lexical-binding: t; -*-
+;;; bun-init.el --- Run your bun workflows -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Shane Kennedy
;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
+;; Homepage: https://github.com/shaneikennedy/bun.el
;; Keywords: tools
;; Version: 0
@@ -24,25 +24,25 @@
;; Functions for initializing a node project.
;;; Code:
-(require 'npm-common)
+(require 'bun-common)
-(defconst npm-init--prefix-command "npm init")
-(defconst npm-init--temp-buffer ".npminit")
+(defconst bun-init--prefix-command "bun init")
+(defconst bun-init--temp-buffer ".buninit")
;;;###autoload
-(defun npm-init ()
- "Initialize a project folder as a npm project."
- (interactive)
- (save-excursion
- (let* ((project-root-folder (read-directory-name "Project root :"))
- (command npm-init--prefix-command))
- (generate-new-buffer (concat project-root-folder npm-init--temp-buffer))
- (set-buffer (concat project-root-folder npm-init--temp-buffer))
+(defun bun-init ()
+ "Initialize a project folder as a bun project."
+ (interactive)
+ (save-excursion
+ (let* ((project-root-folder (read-directory-name "Project root :"))
+ (command bun-init--prefix-command))
+ (generate-new-buffer (concat project-root-folder bun-init--temp-buffer))
+ (set-buffer (concat project-root-folder bun-init--temp-buffer))
(let ((current-prefix-arg '(4)))
(setq compilation-read-command nil)
(setq compile-command command)
(call-interactively #'compile))
- (kill-buffer project-root-folder))))
+ (kill-buffer project-root-folder))))
-(provide 'npm-init)
-;;; npm-init.el ends here
+(provide 'bun-init)
+;;; bun-init.el ends here
diff --git a/bun-install.el b/bun-install.el
new file mode 100644
index 0000000..5336865
--- /dev/null
+++ b/bun-install.el
@@ -0,0 +1,77 @@
+;;; bun-install.el --- Run your bun workflows -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Shane Kennedy
+
+;; Author: Shane Kennedy
+;; Homepage: https://github.com/shaneikennedy/bun.el
+;; Keywords: tools
+;; Version: 0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+;; Functions for installing bun packages.
+
+;;; Code:
+(require 'bun-common)
+
+(transient-define-prefix bun-install-menu ()
+ "Open bun install transient menu pop up."
+ ["Arguments"
+ ("-f" "Force fetching even if copy exists on disk" "--force")
+ ("-g" "Save as global dependency" "--global")
+ ("-p" "Save as production dependency" "--save-prod")
+ ("-d" "Save as development dependency" "--save-dev")
+ ("-o" "Save as optional dependency" "--save-optional")
+ ("-e" "Save exact version" "--save-exact")
+ ("-n" "Do not save to package.json" "--no-save")]
+ [["Command"
+ ("i" "Install new package" bun-install)
+ ("I" "Install current packages (in package.json)" bun-install-current)]]
+ (interactive)
+ (transient-setup 'bun-install-menu))
+
+
+(defconst bun-install--prefix-command "bun install")
+
+(defun bun-install--get-install-command (package-name)
+ "Construct the shell command for a given PACKAGE-NAME."
+ (concat bun-install--prefix-command " " package-name))
+
+(defun bun-install--choose-package ()
+ "Let user choose which package to install."
+ (interactive)
+ (completing-read "Type the name of the package you want to install: " ()))
+
+(defun bun-install-menu-arguments nil
+ "Arguments function for transient."
+ (transient-args 'bun-install-menu))
+
+(defun bun-install-current (&optional args)
+ "Invoke the compile mode with the install prefix-command and ARGS if provided but no packages."
+ (interactive)
+ (let ((arguments (string-join args " "))
+ (bun-command (bun-install--get-install-command "")))
+ (bun-common--compile bun-command arguments)))
+
+;;;###autoload
+(defun bun-install (&optional args)
+ "Invoke the compile mode with the install prefix-command and ARGS if provided."
+ (interactive (list (bun-install-menu-arguments)))
+ (let* ((arguments (string-join args " "))
+ (bun-command (bun-install--get-install-command (bun-install--choose-package))))
+ (bun-common--compile bun-command arguments)))
+
+(provide 'bun-install)
+;;; bun-install.el ends here
diff --git a/npm-run.el b/bun-run.el
similarity index 55%
rename from npm-run.el
rename to bun-run.el
index d59229b..616e120 100644
--- a/npm-run.el
+++ b/bun-run.el
@@ -1,9 +1,9 @@
-;;; npm-run.el --- Run your npm workflows -*- lexical-binding: t; -*-
+;;; bun-run.el --- Run your bun workflows -*- lexical-binding: t; -*-
-;; Copyright (C) 2020 Shane Kennedy
+;; Copyright (C) 2024 Shane Kennedy
;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
+;; Homepage: https://github.com/shaneikennedy/bun.el
;; Keywords: tools
;; Version: 0
@@ -21,32 +21,32 @@
;; along with this program. If not, see .
;;; Commentary:
-;; Functions for using npm run.
+;; Functions for using bun run.
;;; Code:
-(require 'npm-common)
+(require 'bun-common)
-(defconst npm-run--prefix-command "npm run")
+(defconst bun-run--prefix-command "bun run")
-(defun npm-run--get-run-command (script-name)
+(defun bun-run--get-run-command (script-name)
"Construct the shell command for a given SCRIPT-NAME."
- (concat npm-run--prefix-command " " script-name))
+ (concat bun-run--prefix-command " " script-name))
-(defun npm-run--get-scripts (project-dir)
- "Function to parse package.json in the PROJECT-DIR to find npm scripts."
- (mapcar 'car (cdr (assoc 'scripts (json-read-file (concat project-dir npm-common--config-file))))))
+(defun bun-run--get-scripts (project-dir)
+ "Function to parse package.json in the PROJECT-DIR to find bun scripts."
+ (mapcar 'car (cdr (assoc 'scripts (json-read-file (concat project-dir bun-common--config-file))))))
-(defun npm-run--choose-script ()
+(defun bun-run--choose-script ()
"Let user choose which script to run."
(interactive)
- (completing-read "Select script from list: " (npm-run--get-scripts (npm-common--get-project-dir)) nil t))
+ (completing-read "Select script from list: " (bun-run--get-scripts (bun-common--get-project-dir)) nil t))
;;;###autoload
-(defun npm-run (&optional _args)
+(defun bun-run (&optional _args)
"Invoke the compile mode with the run prefix-command and ARGS if provided."
- (interactive (list (npm-common--arguments)))
- (npm-common--compile (npm-run--get-run-command (npm-run--choose-script))))
+ (interactive (list (bun-common--arguments)))
+ (bun-common--compile (bun-run--get-run-command (bun-run--choose-script))))
-(provide 'npm-run)
-;;; npm-run.el ends here
+(provide 'bun-run)
+;;; bun-run.el ends here
diff --git a/bun-test.el b/bun-test.el
new file mode 100644
index 0000000..c0cece5
--- /dev/null
+++ b/bun-test.el
@@ -0,0 +1,52 @@
+;;; bun-test.el --- Run your bun workflows -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Shane Kennedy
+
+;; Author: Shane Kennedy
+;; Homepage: https://github.com/shaneikennedy/bun.el
+;; Keywords: tools
+;; Version: 0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+;; Functions for testing bun packages.
+
+;;; Code:
+(require 'bun-common)
+
+(transient-define-prefix bun-test-menu ()
+ "Open bun test transient menu pop up."
+ []
+ [["Command"
+ ("t" "Test current project" bun-test)]]
+ (interactive)
+ (transient-setup 'bun-test-menu))
+
+
+(defconst bun-test--prefix-command "bun test")
+
+(defun bun-test-menu-arguments nil
+ "Arguments function for transient."
+ (transient-args 'bun-test-menu))
+
+;;;###autoload
+(defun bun-test (&optional args)
+ "Invoke the compile mode with the test prefix-command and ARGS if provided."
+ (interactive (list (bun-test-menu-arguments)))
+ (let* ((arguments (string-join args " ")))
+ (bun-common--compile bun-test--prefix-command arguments)))
+
+(provide 'bun-test)
+;;; bun-test.el ends here
diff --git a/bun-update.el b/bun-update.el
new file mode 100644
index 0000000..f2a9f2c
--- /dev/null
+++ b/bun-update.el
@@ -0,0 +1,67 @@
+;;; bun-update.el --- Run your bun workflows -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Shane Kennedy
+
+;; Author: Shane Kennedy
+;; Homepage: https://github.com/shaneikennedy/bun.el
+;; Keywords: tools
+;; Version: 0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+;;; Functions for running bun update.
+
+;;; Code:
+(require 'bun-common)
+
+(defconst bun-update--prefix-command "bun update")
+
+(defun bun-update--get-update-command (package-name)
+ "Construct the shell command for a given PACKAGE-NAME."
+ (concat bun-update--prefix-command " " package-name))
+
+(defun bun-update--get-packages (project-dir)
+ "Function to parse package.json in the PROJECT-DIR to find bun packages."
+ (append
+ (bun-update--get-dev-dependency-packages project-dir)
+ (bun-update--get-optional-dependency-packages project-dir)
+ (bun-update--get-dependency-packages project-dir)))
+
+(defun bun-update--get-dev-dependency-packages(project-dir)
+ "Function to parse package.json in the PROJECT-DIR to find bun devDependencies."
+ (mapcar 'car (cdr (assoc 'devDependencies (json-read-file (concat project-dir bun-common--config-file))))))
+
+(defun bun-update--get-optional-dependency-packages(project-dir)
+ "Function to parse package.json in the PROJECT-DIR to find bun optionalDependencies."
+ (mapcar 'car (cdr (assoc 'optionalDependencies (json-read-file (concat project-dir bun-common--config-file))))))
+
+(defun bun-update--get-dependency-packages(project-dir)
+ "Function to parse package.json in the PROJECT-DIR to find bun dependencies."
+ (mapcar 'car (cdr (assoc 'dependencies (json-read-file (concat project-dir bun-common--config-file))))))
+
+(defun bun-update--choose-package ()
+ "Let user choose which package to update."
+ (interactive)
+ (completing-read "Select package from list: " (bun-update--get-packages (bun-common--get-project-dir)) nil t))
+
+;;;###autoload
+(defun bun-update (&optional _args)
+ "Invoke the compile mode with the update prefix-command and ARGS if provided."
+ (interactive (list (bun-common--arguments)))
+ (bun-common--compile (bun-update--get-update-command (bun-update--choose-package))))
+
+
+(provide 'bun-update)
+;;; bun-update.el ends here
diff --git a/bun.el b/bun.el
new file mode 100644
index 0000000..669f5c5
--- /dev/null
+++ b/bun.el
@@ -0,0 +1,67 @@
+;;; bun.el --- Run your bun workflows -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Shane Kennedy
+
+;; Author: Shane Kennedy
+;; Homepage: https://github.com/shaneikennedy/bun.el
+;; Package-Requires: ((emacs "26.1") (transient "0.1.0"))
+;; Keywords: tools
+;; Version: 0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+;; This package offers a transient interface to the bun cli.
+
+;;; Code:
+(require 'bun-common)
+(require 'bun-run)
+(require 'bun-install)
+(require 'bun-update)
+(require 'bun-init)
+(require 'bun-test)
+
+(defconst bun-mode-map compilation-mode-map)
+
+(define-derived-mode bun-mode compilation-mode "bun"
+ "Major mode for the bun compilation buffer."
+ (use-local-map bun-mode-map)
+ (setq major-mode 'bun-mode)
+ (setq mode-name "bun")
+ (setq-local truncate-lines t))
+
+;;;###autoload
+(defun bun ()
+ "Entrypoint function to the package.
+This will first check to make sure there is a package.json file and then open the menu."
+ (interactive)
+ (if (bun-common--get-project-dir)
+ (call-interactively #'bun-menu)
+ (if (y-or-n-p "You are not in an bun project, would you like to initialize one? ")
+ (call-interactively #'bun-init))))
+
+;; Entrypoint menu
+(transient-define-prefix bun-menu ()
+ "Open bun transient menu pop up."
+ [["Command"
+ ("u" "Update" bun-update)
+ ("i" "Install" bun-install-menu)
+ ("t" "Test" bun-test)
+ ("r" "Run" bun-run)]]
+ (interactive)
+ (transient-setup 'bun-menu))
+
+
+(provide 'bun)
+;;; bun.el ends here
diff --git a/npm-common.el b/npm-common.el
deleted file mode 100644
index 65d66c8..0000000
--- a/npm-common.el
+++ /dev/null
@@ -1,87 +0,0 @@
-;;; npm-common.el --- Run your npm workflows -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2020 Shane Kennedy
-
-;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
-;; Keywords: tools
-;; Version: 0
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
-
-;;; Commentary:
-;; The common functions needed by many or all npm commands.
-
-;;; Code:
-(require 'compile)
-(require 'json)
-(require 'subr-x)
-(require 'transient)
-
-(defgroup npm ()
- "Group for npm."
- :group 'tools
- :prefix "npm-")
-
-(defconst npm-common--config-file "package.json")
-
-(defcustom npm-common-buffer-name-function "*npm*"
- "Buffer name for `npm' command, or function which return buffer name.
-The function takes three arguments, ROOT, NPM-COMMAND, ARGS.
-ROOT is project root directory. NPM-COMMAND is npm command string.
-ARGS is list of arguments passed to npm command.
-
-You can use `npm-common-create-unique-buffer-name' to use unique buffer name
-among all sesstions."
- :group 'npm
- :type '(choice
- (string :tag "Use same buffer through all sessions")
- (const :tag "Use unique buffer name among all sessions" npm-common-create-unique-buffer-name)
- function))
-
-(defun npm-common-create-unique-buffer-name (root npm-command _args)
- "Create buffer name unique to ROOT and NPM-COMMAND."
- (concat "*" npm-command " in " root "*"))
-
-(defun npm-common--generate-buffer-name-function (root npm-command args)
- "Generate function which return buffer name to pass `compilation-start'.
-ROOT is project root directory. NPM-COMMAND is npm command string.
-ARGS is list of arguments passed to npm command.
-
-This function uses `npm-common-buffer-name-function'."
- (lambda (_)
- (if (stringp npm-common-buffer-name-function)
- npm-common-buffer-name-function
- (funcall npm-common-buffer-name-function
- root npm-command args))))
-
-;; Common
-(defun npm-common--get-project-dir ()
- "Function that determines the file path of the project root directory."
- (locate-dominating-file (or (buffer-file-name) default-directory)
- npm-common--config-file))
-
-(defun npm-common--compile (npm-command &optional args)
- "Generic compile command for NPM-COMMAND with ARGS functionality."
- (compilation-start (string-join (list npm-command args) " ")
- 'npm-mode
- (npm-common--generate-buffer-name-function
- (npm-common--get-project-dir) npm-command args)))
-
-(defun npm-common--arguments nil
- "Arguments function for transient."
- (transient-args 'npm-menu))
-
-(provide 'npm-common)
-;;; npm-common.el ends here
diff --git a/npm-install.el b/npm-install.el
deleted file mode 100644
index 74f682c..0000000
--- a/npm-install.el
+++ /dev/null
@@ -1,77 +0,0 @@
-;;; npm-install.el --- Run your npm workflows -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2020 Shane Kennedy
-
-;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
-;; Keywords: tools
-;; Version: 0
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
-
-;;; Commentary:
-;; Functions for installing npm pakcages.
-
-;;; Code:
-(require 'npm-common)
-
-(transient-define-prefix npm-install-menu ()
- "Open npm install transient menu pop up."
- ["Arguments"
- ("-f" "Force fetching even if copy exists on disk" "--force")
- ("-g" "Save as global dependency" "--global")
- ("-p" "Save as production dependency" "--save-prod")
- ("-d" "Save as development dependency" "--save-dev")
- ("-o" "Save as optional dependency" "--save-optional")
- ("-e" "Save exact version" "--save-exact")
- ("-n" "Do not save to package.json" "--no-save")]
- [["Command"
- ("i" "Install new package" npm-install)
- ("I" "Install current packages (in package.json)" npm-install-current)]]
- (interactive)
- (transient-setup 'npm-install-menu))
-
-
-(defconst npm-install--prefix-command "npm install")
-
-(defun npm-install--get-install-command (package-name)
- "Construct the shell command for a given PACKAGE-NAME."
- (concat npm-install--prefix-command " " package-name))
-
-(defun npm-install--choose-package ()
- "Let user choose which package to install."
- (interactive)
- (completing-read "Type the name of the package you want to install: " ()))
-
-(defun npm-install-menu-arguments nil
- "Arguments function for transient."
- (transient-args 'npm-install-menu))
-
-(defun npm-install-current (&optional args)
- "Invoke the compile mode with the install prefix-command and ARGS if provided but no packages."
- (interactive)
- (let ((arguments (string-join args " "))
- (npm-command (npm-install--get-install-command "")))
- (npm-common--compile npm-command arguments)))
-
-;;;###autoload
-(defun npm-install (&optional args)
- "Invoke the compile mode with the install prefix-command and ARGS if provided."
- (interactive (list (npm-install-menu-arguments)))
- (let* ((arguments (string-join args " "))
- (npm-command (npm-install--get-install-command (npm-install--choose-package))))
- (npm-common--compile npm-command arguments)))
-
-(provide 'npm-install)
-;;; npm-install.el ends here
diff --git a/npm-publish.el b/npm-publish.el
deleted file mode 100644
index 230fb56..0000000
--- a/npm-publish.el
+++ /dev/null
@@ -1,70 +0,0 @@
-;;; npm-publish.el --- Run your npm workflows -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2020 Shane Kennedy
-
-;; Author: Shane Kennedy, Manas Jayanth
-;; Homepage: https://github.com/shaneikennedy/npm.el
-;; Keywords: tools
-;; Version: 0
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
-
-;;; Commentary:
-;; Functions for publishing project an NPM registry
-
-;;; Code:
-(require 'npm-common)
-
-(transient-define-prefix npm-publish-menu ()
- "Open npm publish transient menu pop up."
- ["Arguments"
- ("-r" "set npm registry where the package must be published" "--registry=")
- ("-d" "dry run" "--dry-run")
- ("-o" "otp" "--otp=")
- ("-w" "set workspace" "--workspace=")
- ("-s" "set workspaces" "--workspaces")
- ("-i" "include workspace root in the publish" "--include-workspace-root")
- ("-a" "set package access for other users on the registry" "--access=")
- ("-t" "set npm dist tag. See https://docs.npmjs.com/cli/v8/commands/npm-dist-tag" "--tag=")
- ]
- [["Command"
- ("p" "Publish" npm-publish)]]
- (interactive)
- (transient-setup 'npm-publish-menu))
-
-(defconst npm-publish--prefix-command "npm publish")
-
-(defun npm-publish--get-publish-command (tarball-name)
- "Construct the shell command for a given TARBALL-NAME."
- (concat npm-publish--prefix-command " " tarball-name))
-
-(defun npm-publish--choose-tarball ()
- "Let user choose which package to publish."
- (interactive)
- (read-file-name "Type the path of the tarball you want to publish: " ()))
-
-(defun npm-publish-menu-arguments nil
- "Arguments function for transient."
- (transient-args 'npm-publish-menu))
-
-;;;###autoload
-(defun npm-publish (&optional args)
- "Invoke the compile mode with ARGS to publish an NPM package to a registry."
- (interactive (list (npm-publish-menu-arguments)))
- (let* ((arguments (string-join args " "))
- (npm-command (npm-publish--get-publish-command (npm-publish--choose-tarball))))
- (npm-common--compile npm-command arguments)))
-
-(provide 'npm-publish)
-;;; npm-publish.el ends here
diff --git a/npm-update.el b/npm-update.el
deleted file mode 100644
index 4fdcb41..0000000
--- a/npm-update.el
+++ /dev/null
@@ -1,67 +0,0 @@
-;;; npm-update.el --- Run your npm workflows -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2020 Shane Kennedy
-
-;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
-;; Keywords: tools
-;; Version: 0
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
-
-;;; Commentary:
-;;; Functions for running npm update.
-
-;;; Code:
-(require 'npm-common)
-
-(defconst npm-update--prefix-command "npm update")
-
-(defun npm-update--get-update-command (package-name)
- "Construct the shell command for a given PACKAGE-NAME."
- (concat npm-update--prefix-command " " package-name))
-
-(defun npm-update--get-packages (project-dir)
- "Function to parse package.json in the PROJECT-DIR to find npm packages."
- (append
- (npm-update--get-dev-dependency-packages project-dir)
- (npm-update--get-optional-dependency-packages project-dir)
- (npm-update--get-dependency-packages project-dir)))
-
-(defun npm-update--get-dev-dependency-packages(project-dir)
- "Function to parse package.json in the PROJECT-DIR to find npm devDependencies."
- (mapcar 'car (cdr (assoc 'devDependencies (json-read-file (concat project-dir npm-common--config-file))))))
-
-(defun npm-update--get-optional-dependency-packages(project-dir)
- "Function to parse package.json in the PROJECT-DIR to find npm optionalDependencies."
- (mapcar 'car (cdr (assoc 'optionalDependencies (json-read-file (concat project-dir npm-common--config-file))))))
-
-(defun npm-update--get-dependency-packages(project-dir)
- "Function to parse package.json in the PROJECT-DIR to find npm dependencies."
- (mapcar 'car (cdr (assoc 'dependencies (json-read-file (concat project-dir npm-common--config-file))))))
-
-(defun npm-update--choose-package ()
- "Let user choose which package to update."
- (interactive)
- (completing-read "Select package from list: " (npm-update--get-packages (npm-common--get-project-dir)) nil t))
-
-;;;###autoload
-(defun npm-update (&optional _args)
- "Invoke the compile mode with the update prefix-command and ARGS if provided."
- (interactive (list (npm-common--arguments)))
- (npm-common--compile (npm-update--get-update-command (npm-update--choose-package))))
-
-
-(provide 'npm-update)
-;;; npm-update.el ends here
diff --git a/npm.el b/npm.el
deleted file mode 100644
index 7ad2375..0000000
--- a/npm.el
+++ /dev/null
@@ -1,70 +0,0 @@
-;;; npm.el --- Run your npm workflows -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2020 Shane Kennedy
-
-;; Author: Shane Kennedy
-;; Homepage: https://github.com/shaneikennedy/npm.el
-;; Package-Requires: ((emacs "25.1") (transient "0.1.0") (jest "20220807.2243"))
-;; Keywords: tools
-;; Version: 0
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
-
-;;; Commentary:
-;; This package offers a transient interface to the npm cli.
-
-;;; Code:
-(require 'jest)
-
-(require 'npm-common)
-(require 'npm-run)
-(require 'npm-install)
-(require 'npm-update)
-(require 'npm-init)
-(require 'npm-publish)
-
-(defconst npm-mode-map compilation-mode-map)
-
-(define-derived-mode npm-mode compilation-mode "NPM"
- "Major mode for the NPM compilation buffer."
- (use-local-map npm-mode-map)
- (setq major-mode 'npm-mode)
- (setq mode-name "NPM")
- (setq-local truncate-lines t))
-
-;;;###autoload
-(defun npm ()
- "Entrypoint function to the package.
-This will first check to make sure there is a package.json file and then open the menu."
- (interactive)
- (if (npm-common--get-project-dir)
- (call-interactively #'npm-menu)
- (if (y-or-n-p "You are not in an NPM project, would you like to initialize one? ")
- (call-interactively #'npm-init))))
-
-;; Entrypoint menu
-(transient-define-prefix npm-menu ()
- "Open npm transient menu pop up."
- [["Command"
- ("u" "Update" npm-update)
- ("i" "Install" npm-install-menu)
- ("r" "Run" npm-run)
- ("t" "Test" jest-popup)
- ("p" "Publish" npm-publish-menu)]]
- (interactive)
- (transient-setup 'npm-menu))
-
-
-(provide 'npm)
-;;; npm.el ends here