Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rename command check-eask to analyze #230

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:

- name: Testing...
run: |
make command-check-eask
make command-analyze
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* fix(build.yml): Release with `.tar.gz` instead of `.zip` on Unix-like system (#214 and #216)
* feat: Add `loc` command (#227)
* fix: Allow initialize in other scopes (#229)
* feat: Rename command `check-eask` to `analyze` (#230)

## 0.9.x
> Released Nov 17, 2023
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ command-config:
command-local:
./test/commands/local/run.sh

command-check-eask:
command-analyze:
./test/checker/dsl/run.sh
./test/checker/metadata/run.sh

Expand Down
4 changes: 2 additions & 2 deletions cmds/checker/check-eask.js → cmds/core/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"use strict";

exports.command = ['check-eask [files..]'];
exports.command = ['analyze [files..]'];
exports.desc = 'Run Eask checker';
exports.builder = yargs => yargs
.positional(
Expand All @@ -40,7 +40,7 @@ exports.builder = yargs => yargs
});

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'checker/check-eask'
await UTIL.e_call(argv, 'core/analyze'
, argv.files
, UTIL.def_flag(argv.json, '--json')
, UTIL.def_flag(argv.output, '--output', argv.output));
Expand Down
4 changes: 2 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Eask is a command-line tool that helps you build, lint, and test Emacs Lisp pack
Usage: eask <command> [options..]

Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
Expand All @@ -55,7 +56,7 @@ Commands:
load [files..] Load elisp files
outdated Show all outdated dependencies
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
refresh Download package archives
reinstall [names..] Reinstall packages
Expand All @@ -65,7 +66,6 @@ Commands:
test <type> Run test
uninstall [names..] Uninstall packages [aliases: delete]
upgrade [names..] Upgrade packages
check-eask [files..] Run eask checker
locate Print out Eask installed location
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]

Expand Down
4 changes: 2 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Eask is a command-line tool that helps you build, lint, and test Emacs Lisp pack
Usage: eask <command> [options..]

Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
Expand All @@ -52,7 +53,7 @@ Commands:
load [files..] Load elisp files
outdated Show all outdated dependencies
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
refresh Download package archives
reinstall [names..] Reinstall packages
Expand All @@ -62,7 +63,6 @@ Commands:
test <type> Run test
uninstall [names..] Uninstall packages [aliases: delete]
upgrade [names..] Upgrade packages
check-eask [files..] Run eask checker
locate Print out Eask installed location
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]

Expand Down
14 changes: 7 additions & 7 deletions docs/content/Getting-Started/Commands-and-options/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -867,28 +867,28 @@ $ eask [GLOBAL-OPTIONS] locate

Commands to check your Eask-file.

## 🔍 eask check-eask
## 🔍 eask analyze

Lint an `Eask`-file.

```sh
$ eask [GLOBAL-OPTIONS] check-eask [FILES..]
$ eask [GLOBAL-OPTIONS] analyze [FILES..]
```

Example:

```bash
# lint all Eask-files in the current directory and subdirectories
eask check-eask
eask analyze
# lint specific files
eask check-eask Eask Eask.27
eask analyze Eask Eask.27
# lint all Eask-files in specified directory and subdirectories
eask check-eask src/
eask analyze src/
# print result as JSON
eask check-eask --json
eask analyze --json
```

For more detail, run `eask check-eask --help`.
For more detail, run `eask analyze --help`.

# 🚩 Global Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,28 +854,28 @@ $ eask [GLOBAL-OPTIONS] locate

檢查您的 Eask 文件的命令。

## 🔍 eask check-eask
## 🔍 eask analyze

檢查 `Eask` 文件。

```sh
$ eask [GLOBAL-OPTIONS] check-eask [FILES..]
$ eask [GLOBAL-OPTIONS] analyze [FILES..]
```

例子:

```bash
# lint all Eask-files in the current directory and subdirectories
eask check-eask
eask analyze
# lint specific files
eask check-eask Eask Eask.27
eask analyze Eask Eask.27
# lint all Eask-files in specified directory and subdirectories
eask check-eask src/
eask analyze src/
# print result as JSON
eask check-eask --json
eask analyze --json
```

有關更多詳細信息,請運行 `eask check-eask --help`。
有關更多詳細信息,請運行 `eask analyze --help`。

# 🚩 全域選項

Expand Down
1 change: 0 additions & 1 deletion eask
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ yargs
.scriptName('')
.epilogue(epilogue)
.commandDir('cmds/core/')
.commandDir('cmds/checker/')
.commandDir('cmds/util/')
.command({
command: '*',
Expand Down
2 changes: 1 addition & 1 deletion lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ workspace has no valid Eask-file; it will load global workspace instead."

(defun eask-checker-p ()
"Return t if running Eask as the checker."
(member (eask-command) '("check-eask")))
(member (eask-command) '("analyze")))

(defun eask-script (script)
"Return full SCRIPT filename."
Expand Down
62 changes: 31 additions & 31 deletions lisp/checker/check-eask.el → lisp/core/analyze.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
;;; checker/check-eask.el --- Run eask checker -*- lexical-binding: t; -*-
;;; core/analyze.el --- Run eask checker -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Commmand use to run Eask checker
;;
;; $ eask check-eask [FILES..]
;; $ eask analyze [FILES..]
;;
;;
;; Positionals:
Expand All @@ -24,24 +24,24 @@
nil t))

;; Plain Text
(defvar eask-checker--log nil)
(defvar eask-analyze--log nil)
;; JSON format
(defvar eask-checker--warnings nil)
(defvar eask-checker--errors nil)
(defvar eask-analyze--warnings nil)
(defvar eask-analyze--errors nil)

(defun eask-checker--pretty-json (json)
(defun eask-analyze--pretty-json (json)
"Return pretty JSON."
(with-temp-buffer (insert json) (json-pretty-print-buffer) (buffer-string)))

(defun eask-checker--load-buffer ()
(defun eask-analyze--load-buffer ()
"Return the current file loading session."
(car (cl-remove-if-not
(lambda (elm) (string-prefix-p " *load*-" (buffer-name elm))) (buffer-list))))

(defun eask-checker--write-json-format (level msg)
(defun eask-analyze--write-json-format (level msg)
"Prepare log for JSON format.

For arguments LEVEL and MSG, please see function `eask-checker--write-log' for more
For arguments LEVEL and MSG, please see function `eask-analyze--write-log' for more
information."
(let* ((bounds (bounds-of-thing-at-point 'sexp))
(filename (or load-file-name eask-file))
Expand All @@ -63,13 +63,13 @@ information."
(filename . ,filename)
(message . ,msg))
(cl-case level
(`error eask-checker--errors)
(`warn eask-checker--warnings)))))
(`error eask-analyze--errors)
(`warn eask-analyze--warnings)))))

(defun eask-checker--write-plain-text (level msg)
(defun eask-analyze--write-plain-text (level msg)
"Prepare log for plain text format.

For arguments LEVEL and MSG, please see function `eask-checker--write-log' for more
For arguments LEVEL and MSG, please see function `eask-analyze--write-log' for more
information."
(let* ((level-string (cl-case level
(`error "Error")
Expand All @@ -80,20 +80,20 @@ information."
(if load-file-name (current-column) 0)
level-string
msg)))
(push (ansi-color-filter-apply log) eask-checker--log)))
(push (ansi-color-filter-apply log) eask-analyze--log)))

(defun eask-checker--write-log (level msg)
(defun eask-analyze--write-log (level msg)
"Write the log.

Argument LEVEL and MSG are data from the debug log signal."
(unless (string= " *temp*" (buffer-name)) ; avoid error from `package-file' directive
(with-current-buffer (or (eask-checker--load-buffer) (buffer-name))
(with-current-buffer (or (eask-analyze--load-buffer) (buffer-name))
(funcall
(cond ((eask-json-p) #'eask-checker--write-json-format)
(t #'eask-checker--write-plain-text))
(cond ((eask-json-p) #'eask-analyze--write-json-format)
(t #'eask-analyze--write-plain-text))
level msg))))

(defun eask-checker--check-file (files)
(defun eask-analyze--file (files)
"Lint list of Eask FILES."
(let (checked-files content)
;; Linting
Expand All @@ -105,19 +105,19 @@ Argument LEVEL and MSG are data from the debug log signal."
;; Print result
(eask-msg "")
(cond ((and (eask-json-p) ; JSON format
(or eask-checker--warnings eask-checker--errors))
(or eask-analyze--warnings eask-analyze--errors))
(setq content
(eask-checker--pretty-json (json-encode
`((warnings . ,eask-checker--warnings)
(errors . ,eask-checker--errors)))))
(eask-analyze--pretty-json (json-encode
`((warnings . ,eask-analyze--warnings)
(errors . ,eask-analyze--errors)))))
(eask-msg content))
(eask-checker--log ; Plain text
(eask-analyze--log ; Plain text
(setq content
(with-temp-buffer
(dolist (msg (reverse eask-checker--log))
(dolist (msg (reverse eask-analyze--log))
(insert msg "\n"))
(buffer-string)))
(mapc #'eask-msg (reverse eask-checker--log)))
(mapc #'eask-msg (reverse eask-analyze--log)))
(t
(eask-info "(Checked %s file%s)"
(length checked-files)
Expand All @@ -131,8 +131,8 @@ Argument LEVEL and MSG are data from the debug log signal."
;;; Program Entry

;; Preparation
(add-hook 'eask-on-error-hook #'eask-checker--write-log)
(add-hook 'eask-on-warning-hook #'eask-checker--write-log)
(add-hook 'eask-on-error-hook #'eask-analyze--write-log)
(add-hook 'eask-on-warning-hook #'eask-analyze--write-log)

(let* ((default-directory (cond ((eask-global-p) eask-homedir)
((eask-config-p) user-emacs-directory)
Expand All @@ -144,14 +144,14 @@ Argument LEVEL and MSG are data from the debug log signal."
(cond
;; Files found, do the action!
(files
(eask-checker--check-file files))
(eask-analyze--file files))
;; Pattern defined, but no file found!
(patterns
(eask-info "(No files match wildcard: %s)"
(mapconcat #'identity patterns " ")))
;; Default, print help!
(t
(eask-info "(No Eask-files have been checked)")
(eask-help "checker/check-eask"))))
(eask-help "checker/analyze"))))

;;; checker/check-eask.el ends here
;;; core/analyze.el ends here
2 changes: 1 addition & 1 deletion lisp/help/checker/check-eask → lisp/help/core/analyze
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

💡 You need to specify file(s) you want to Eask checker to check

$ eask check-eask FILE-1 FILE-2
$ eask analyze FILE-1 FILE-2
14 changes: 7 additions & 7 deletions test/checker/dsl/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

## Commentary:
#
# Test command/checker `check-eask`
# Test command/analyze `analyze`
#

set -e

# Naviate to the test package
cd $(dirname "$0")

echo "Testing check-eask command... (Plain text)"
eask check-eask
eask check-eask Eask
echo "Testing analyze command... (Plain text)"
eask analyze
eask analyze Eask

echo "Testing check-eask command... (JSON format)"
eask check-eask --json
eask check-eask Eask --json
echo "Testing analyze command... (JSON format)"
eask analyze --json
eask analyze Eask --json
14 changes: 7 additions & 7 deletions test/checker/metadata/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

## Commentary:
#
# Test command/checker `check-eask`
# Test command/checker `analyze`
#

set -e

# Naviate to the test package
cd $(dirname "$0")

echo "Testing check-eask command... (Plain text)"
eask check-eask
eask check-eask Eask
echo "Testing analyze command... (Plain text)"
eask analyze
eask analyze Eask

echo "Testing check-eask command... (JSON format)"
eask check-eask --json
eask check-eask Eask --json
echo "Testing analyze command... (JSON format)"
eask analyze --json
eask analyze Eask --json
Loading