diff --git a/.github/workflows/link.yml b/.github/workflows/link.yml new file mode 100644 index 00000000..5c3beeac --- /dev/null +++ b/.github/workflows/link.yml @@ -0,0 +1,57 @@ +name: Link + +on: + push: + branches: + - master + paths: + - '**.yml' + - lisp/** + - cmds/** + - src/** + - test/** + pull_request: + branches: + - master + paths-ignore: + - '**.md' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + emacs-version: + - 26.3 + - 27.2 + - 28.2 + - snapshot + + steps: + - uses: jcs090218/setup-emacs@master + with: + version: ${{ matrix.emacs-version }} + + - uses: actions/checkout@v3 + + - name: Prepare Eask (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: | + chmod -R 777 ./ + .github/scripts/setup-eask + + - name: Prepare Eask (Windows) + if: matrix.os == 'windows-latest' + run: .github/scripts/setup-eask.ps1 + + - name: Testing... + run: | + make command-link + diff --git a/CHANGELOG.md b/CHANGELOG.md index 05220d15..f17467de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * Add command to clean pkg-file (#99) * Add option `-o`/`--output` to output log for Eask checker (#100) * Fix line-endings for unix system (#106) +* Add `link` command (#107) ## 0.7.x > Released Sep 08, 2022 diff --git a/Makefile b/Makefile index 11837e18..0b47452d 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,9 @@ command-outdated-upgrade: command-search: ./test/commands/search/run.sh +command-link: + ./test/commands/link/run.sh + test-ert: ./test/commands/test/ert/run.sh diff --git a/cmds/core/link.js b/cmds/core/link.js new file mode 100644 index 00000000..3b4f924e --- /dev/null +++ b/cmds/core/link.js @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2023 Jen-Chieh Shen + * + * 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, 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 GNU Emacs; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +"use strict"; + +exports.command = ['link ']; +exports.desc = 'Manage links'; +exports.builder = function (yargs) { + return yargs + .usage(`${exports.desc} + +Usage: eask link [options..]`) + .commandDir('../link/') + .demandCommand(); +}; + +exports.handler = async (argv) => { }; diff --git a/cmds/link/add.js b/cmds/link/add.js new file mode 100644 index 00000000..7da5915b --- /dev/null +++ b/cmds/link/add.js @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2023 Jen-Chieh Shen + * + * 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, 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 GNU Emacs; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +"use strict"; + +exports.command = ['add ']; +exports.desc = 'Link a local package'; +exports.builder = { + name: { + description: 'name of the link', + requiresArg: true, + type: 'string', + }, + path: { + description: 'location (target package) where you want to link', + requiresArg: true, + type: 'string', + }, +}; + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'link/add', argv.name, argv.path); +}; diff --git a/cmds/link/delete.js b/cmds/link/delete.js new file mode 100644 index 00000000..5c1feccf --- /dev/null +++ b/cmds/link/delete.js @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2023 Jen-Chieh Shen + * + * 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, 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 GNU Emacs; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +"use strict"; + +exports.command = ['delete [names..]']; +exports.desc = 'Delete local linked packages'; +exports.builder = { + names: { + description: 'name of the link, accept array', + requiresArg: false, + type: 'array', + }, +}; + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'link/delete', argv.names); +}; diff --git a/cmds/link/list.js b/cmds/link/list.js new file mode 100644 index 00000000..fca845d8 --- /dev/null +++ b/cmds/link/list.js @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2023 Jen-Chieh Shen + * + * 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, 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 GNU Emacs; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +"use strict"; + +exports.command = ['list']; +exports.desc = 'List all project links'; + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'link/list'); +}; diff --git a/docs/content/en/Getting Started/Basic Usage.md b/docs/content/en/Getting Started/Basic Usage.md index 826b74cf..a97fbbbe 100644 --- a/docs/content/en/Getting Started/Basic Usage.md +++ b/docs/content/en/Getting Started/Basic Usage.md @@ -27,22 +27,23 @@ Eask is a command-line tool that helps you build, lint, and test Emacs Lisp pack Usage: eask [options..] Commands: - archives List out all package archives [aliases: sources] + archives List out all package archives [aliases: sources] autoloads Generate autoloads file clean Delete various files produced during building compile [names..] Byte compile all Emacs Lisp files in the package - concat [names..] Concatenate elisp files [aliases: concatenate] + concat [names..] Concatenate elisp files [aliases: concatenate] create Create a new elisp project emacs [args..] Execute emacs with the appropriate environment eval [form] Evaluate lisp form with a proper PATH - path Print the PATH (exec-path) from workspace [aliases: exec-path] + path Print the PATH (exec-path) from workspace [aliases: exec-path] exec [args..] Execute command with correct environment PATH set up files Print the list of all package files info Display information about the current package init Create new Eask file in current directory - install-deps Automatically install package dependencies [aliases: install-dependencies, prepare] + install-deps Automatically install package dependencies [aliases: install-dependencies, prepare] install [names..] Install packages keywords List available keywords that can be used in the header section + link Manage links lint Run linter list List packages load-path Print the load-path from workspace @@ -54,39 +55,39 @@ Commands: recipe Suggest a recipe format refresh Download package archives reinstall [names..] Reinstall packages - run [names..] Run the script named [names..] [aliases: run-script] + run [names..] Run the script named [names..] [aliases: run-script] search [queries..] Search packages test Run test - uninstall [names..] Uninstall packages [aliases: delete] + 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] + upgrade-eask Upgrade Eask itself [aliases: upgrade-self] Proxy Options: - --proxy update proxy for HTTP and HTTPS to host [string] - --http-proxy update proxy for HTTP to host [string] - --https-proxy update proxy for HTTPS to host [string] - --no-proxy set no-proxy to host [string] + --proxy update proxy for HTTP and HTTPS to host [string] + --http-proxy update proxy for HTTP to host [string] + --https-proxy update proxy for HTTPS to host [string] + --no-proxy set no-proxy to host [string] Options: - --version show version number [boolean] - --help show usage instructions [boolean] - -g, --global change default workspace to ~/.emacs.d/ [boolean] - -a, --all enable all flag [boolean] - -q, --quick start cleanly without loading the configuration files [boolean] - -f, --force enable force flag [boolean] - --development, --dev turn on development mode [boolean] - --debug turn on debug mode [boolean] - --strict report error instead of warnings [boolean] - --allow-error continue the executioon even there is error reported [boolean] - --insecure allow insecure connection [boolean] - --timestamps log with timestamps [boolean] - --log-level log with level [boolean] - --log-file, --lf generate log files [boolean] - --elapsed-time, --et show elapsed time between each operation [boolean] - --no-color disable color output [boolean] - -v, --verbose set verbosity from 0 to 4 [number] + --version show version number [boolean] + --help show usage instructions [boolean] + -g, --global change default workspace to ~/.emacs.d/ [boolean] + -a, --all enable all flag [boolean] + -q, --quick start cleanly without loading the configuration files [boolean] + -f, --force enable force flag [boolean] + --development, --dev turn on development mode [boolean] + --debug turn on debug mode [boolean] + --strict report error instead of warnings [boolean] + --allow-error continue the executioon even there is error reported [boolean] + --insecure allow insecure connection [boolean] + --timestamps log with timestamps [boolean] + --log-level log with level [boolean] + --log-file, --lf generate log files [boolean] + --elapsed-time, --et show elapsed time between each operation [boolean] + --no-color disable color output [boolean] + -v, --verbose set verbosity from 0 to 4 [number] For more information, find the manual at https://emacs-eask.github.io/ ``` diff --git a/docs/content/en/Getting Started/Commands and options.md b/docs/content/en/Getting Started/Commands and options.md index 2ecccd7b..231f080b 100644 --- a/docs/content/en/Getting Started/Commands and options.md +++ b/docs/content/en/Getting Started/Commands and options.md @@ -11,6 +11,24 @@ The general syntax of the **eask** program is: $ eask [GLOBAL-OPTIONS] [COMMAND] [COMMAND-OPTIONS] [COMMAND-ARGUMENTS] ``` +# 🚩 Creating + +## 🔍 eask create package + +Create a new elisp project with the default `Eask`-file and CI/CD support. + +{{< hint info >}} +💡 The template project is located in https://github.com/emacs-eask/template-elisp +{{< /hint >}} + +## 🔍 eask create elpa + +Create a new ELPA using [github-elpa](https://github.com/10sr/github-elpa). + +{{< hint info >}} +💡 The template project is located in https://github.com/emacs-eask/template-elpa +{{< /hint >}} + # 🚩 Core ## 🔍 eask init @@ -301,23 +319,31 @@ Download package archives. $ eask [GLOBAL-OPTIONS] refresh ``` -# 🚩 Creating +# 🚩 Linking -## 🔍 eask create package +## 🔍 eask link add -Create a new elisp project with the default `Eask`-file and CI/CD support. +Link a local package. -{{< hint info >}} -💡 The template project is located in https://github.com/emacs-eask/template-elisp -{{< /hint >}} +```sh +$ eask [GLOBAL-OPTIONS] link add +``` -## 🔍 eask create elpa +## 🔍 eask link delete [name..] -Create a new ELPA using [github-elpa](https://github.com/10sr/github-elpa). +Delete local linked packages. -{{< hint info >}} -💡 The template project is located in https://github.com/emacs-eask/template-elpa -{{< /hint >}} +```sh +$ eask [GLOBAL-OPTIONS] link delete [names..] +``` + +## 🔍 eask link list + +List all project links. + +```sh +$ eask [GLOBAL-OPTIONS] link list +``` # 🚩 Cleaning diff --git a/lisp/_prepare.el b/lisp/_prepare.el index e6c05e26..fe894cc2 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -149,6 +149,10 @@ the `eask-start' execution.") (mapc (lambda (elm) (setq result (max result (length (eask-2str elm))))) sequence) result)) +(defun eask-f-filename (path) + "Return the name of PATH." + (file-name-nondirectory (directory-file-name path))) + (defun eask-s-replace (old new s) "Replace OLD with NEW in S each time it occurs." (if (fboundp #'string-replace) @@ -763,6 +767,23 @@ This uses function `locate-dominating-file' to look up directory tree." (defvar eask-depends-on nil) (defvar eask-depends-on-dev nil) +(defmacro eask--save-eask-file-state (&rest body) + "Execute BODY without touching the Eask-file global variables." + (declare (indent 0) (debug t)) + `(let (package-archives + package-archive-priorities + eask-package + eask-package-desc + eask-website-url + eask-keywords + eask-package-file + eask-files + eask-scripts + eask-depends-on-emacs + eask-depends-on + eask-depends-on-dev) + ,@body)) + (defun eask-package--get (key) "Return package info by KEY." (plist-get eask-package key)) diff --git a/lisp/checker/check-eask.el b/lisp/checker/check-eask.el index 5319a3ae..8f0a24ae 100644 --- a/lisp/checker/check-eask.el +++ b/lisp/checker/check-eask.el @@ -87,23 +87,6 @@ (t #'eask--write-plain-text)) level msg)))) -(defmacro eask--save-eask-file-state (&rest body) - "Execute BODY without touching the Eask-file global variables." - (declare (indent 0) (debug t)) - `(let (package-archives - package-archive-priorities - eask-package - eask-package-desc - eask-website-url - eask-keywords - eask-package-file - eask-files - eask-scripts - eask-depends-on-emacs - eask-depends-on - eask-depends-on-dev) - ,@body)) - (defun eask--check-file (files) "Lint list of Eask FILES." (let (checked-files content) diff --git a/lisp/help/link/delete b/lisp/help/link/delete new file mode 100644 index 00000000..f9944a9b --- /dev/null +++ b/lisp/help/link/delete @@ -0,0 +1,4 @@ + +💡 You need to specify package(s) you want to unlink + + $ eask link delete PKG-1 PKG-2 diff --git a/lisp/link/add.el b/lisp/link/add.el new file mode 100644 index 00000000..c09a2e3a --- /dev/null +++ b/lisp/link/add.el @@ -0,0 +1,79 @@ +;;; link/add.el --- Link a local package -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to link a local package +;; +;; $ eask link add [name] [path] +;; +;; +;; Initialization options: +;; +;; [name] name of the link +;; [path] location (target package) where you want to link +;; + +;;; Code: + +(load (expand-file-name + "../_prepare.el" + (file-name-directory (nth 1 (member "-scriptload" command-line-args)))) + nil t) + +(eask-load "link/list") + +(defvar eask--link-package-name) +(defvar eask--link-package-version) + +(defun eask--create-link (name source) + "Add link with NAME to PATH." + (let* ((dir-name (format "%s-%s" eask--link-package-name eask--link-package-version)) + (link-path (expand-file-name dir-name package-user-dir))) + (when (file-exists-p link-path) + (ignore-errors (delete-file link-path)) + (ignore-errors (delete-directory link-path t))) + (make-symbolic-link source link-path) + (eask-msg "") + (eask-info "✓ Created link from %s to %s" source (eask-f-filename link-path)))) + +(eask-start + (let* ((names (eask-args)) + (name (nth 0 names)) + (path (nth 1 names)) + (source (expand-file-name path))) + (cond + ;; Wrong arguments number. + ((<= 3 (length names)) + (eask-info "✗ This command only accepts maximum of 2 arguments: %s" + (mapconcat #'identity names " "))) + ;; Source path not found! + ((not (directory-name-p source)) + (eask-info "✗ Can't create link %s to non-existing path: %s" name source)) + ;; Load Eask-file and pkg-file + ((let ((pkg-el (package--description-file source)) + (pkg-eask (car (eask--all-files source))) + (pkg-desc)) + (cond ((file-exists-p pkg-el) + (with-temp-buffer + (insert-file-contents pkg-el) + (setq pkg-desc (ignore-errors + (if pkg-el + (package--read-pkg-desc 'dir) + (package-buffer-info)))))) + ((file-exists-p pkg-eask) + (eask--save-eask-file-state + (eask--setup-env + (eask--alias-env + (if (ignore-errors (load pkg-eask 'noerror t)) + (setq eask--link-package-name (eask-package-name) + eask--link-package-version (eask-package-version)) + (eask-info "✗ Error loading Eask-file: %s" pkg-eask)))))) + (t + (eask-info "✗ Link source %s doesn't have an Eask or %s-pkg.el file" + source name))) + pkg-desc)) + ;; Create the link + (t + (eask--create-link name source))))) + +;;; link/add.el ends here diff --git a/lisp/link/delete.el b/lisp/link/delete.el new file mode 100644 index 00000000..d6512eb8 --- /dev/null +++ b/lisp/link/delete.el @@ -0,0 +1,55 @@ +;;; link/delete.el --- Delete local linked packages -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to delete local linked packages +;; +;; $ eask link delete [names..] +;; +;; +;; Initialization options: +;; +;; [names..] name of the link, accept array +;; + +;;; Code: + +(load (expand-file-name + "../_prepare.el" + (file-name-directory (nth 1 (member "-scriptload" command-line-args)))) + nil t) + +(eask-load "link/list") + +(defun eask--delete-link (name) + "Delete a link by its' NAME." + (let* ((links (eask--links)) + (source (assoc name links)) + (link (expand-file-name name package-user-dir))) + (if (and source (file-symlink-p link)) + (progn + (ignore-errors (delete-file link)) + (ignore-errors (delete-directory link t)) + (eask-info "✓ Unlinked package %s" link) + t) + (eask-info "✗ Package %s not linked" name) + nil))) + +(eask-start + (let ((names (eask-args)) + (links (eask--links)) + (deleted 0)) + (cond ((zerop (length names)) + (eask-info "✗ No package to unlink, please specify with the package name") + (eask-help "link/delete")) + (t + (dolist (name names) + (when (eask--delete-link name) + (cl-incf deleted))) + (eask-msg "") + (eask-info "(Total of %s package%s unlinked, %s skipped)" + deleted + (eask--sinr deleted "" "s") + (- (length names) deleted)))))) + +;;; link/delete.el ends here diff --git a/lisp/link/list.el b/lisp/link/list.el new file mode 100644 index 00000000..17450ed6 --- /dev/null +++ b/lisp/link/list.el @@ -0,0 +1,43 @@ +;;; link/list.el --- List all project links -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to list all project links +;; +;; $ eask link list +;; + +;;; Code: + +(load (expand-file-name + "../_prepare.el" + (file-name-directory (nth 1 (member "-scriptload" command-line-args)))) + nil t) + +(defun eask--links () + "Return a list of all links." + (mapcar + (lambda (file) + (cons (eask-f-filename file) (file-truename file))) + (cl-remove-if-not #'file-symlink-p (directory-files package-user-dir t)))) + +(defun eask--print-link (link offset) + "Print information regarding the LINK. + +The argument OFFSET is used to align the result." + (message (concat " %-" (eask-2str offset) "s %s") (car link) (cdr link))) + +(eask-start + (if-let* ((links (eask--links)) + (offset (eask-seq-str-max (mapcar #'car links)))) + (progn + (eask-info "Linked packages:") + (eask-msg "") + (dolist (link links) (eask--print-link link offset)) + (eask-msg "") + (eask-info "(Total of %s linked package%s)" + (length links) + (eask--sinr links "" "s"))) + (eask-info "(No linked packages)"))) + +;;; link/add.el ends here diff --git a/package-lock.json b/package-lock.json index e1a4c412..fbf0750f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@emacs-eask/cli", - "version": "0.7.7", + "version": "0.7.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@emacs-eask/cli", - "version": "0.7.7", + "version": "0.7.8", "license": "GPL-3.0", "dependencies": { "yargs": "^17.0.0" diff --git a/test/commands/emacs/run.sh b/test/commands/emacs/run.sh index 78499e2d..c63ede0f 100644 --- a/test/commands/emacs/run.sh +++ b/test/commands/emacs/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/exec/run.sh b/test/commands/exec/run.sh index 52f6ea2a..14b51df2 100644 --- a/test/commands/exec/run.sh +++ b/test/commands/exec/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/global/run.sh b/test/commands/global/run.sh index 48aab94d..71ba6326 100644 --- a/test/commands/global/run.sh +++ b/test/commands/global/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 @@ -28,7 +28,7 @@ set -e echo "Copy test configuration" -./test/mini.emacs.d/scripts/copy_config.sh +./test/fixtures/mini.emacs.d/scripts/copy_config.sh echo "Testing global commands..." eask archives -g diff --git a/test/commands/install/run.sh b/test/commands/install/run.sh index 584ccf13..3a7f0e44 100644 --- a/test/commands/install/run.sh +++ b/test/commands/install/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 @@ -27,7 +27,7 @@ set -e echo "Test commands related to install, and uninstall" # Naviate to the test package -cd "./test/mini.emacs.pkg/" +cd "./test/fixtures/mini.emacs.pkg.1/" echo "Install dependencies" eask install-deps diff --git a/test/commands/link/run.sh b/test/commands/link/run.sh new file mode 100644 index 00000000..99b76e0d --- /dev/null +++ b/test/commands/link/run.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright (C) 2023 Jen-Chieh Shen + +# 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, 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 GNU Emacs; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +## Commentary: +# +# Here we test all local (workspace) commands by simulating a Emacs +# pacakge development environment! +# +# Notice, below we clone a random packae (repo) that uses Eask as the +# dependencies management tool. +# + +set -e + +eask link add "mini.emacs.pkg.1" "./test/fixtures/mini.emacs.pkg.1/" +eask link list +eask link delete mini.emacs.pkg.1-0.0.1 diff --git a/test/commands/local/run.sh b/test/commands/local/run.sh index bf13f750..5bba3616 100644 --- a/test/commands/local/run.sh +++ b/test/commands/local/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 @@ -29,7 +29,7 @@ set -e # Naviate to the test package -cd "./test/mini.emacs.pkg/" +cd "./test/fixtures/mini.emacs.pkg.1/" echo "Testing local commands..." eask info diff --git a/test/commands/outdated_upgrade/run.sh b/test/commands/outdated_upgrade/run.sh index 8bb726d8..7d8826b2 100644 --- a/test/commands/outdated_upgrade/run.sh +++ b/test/commands/outdated_upgrade/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/search/run.sh b/test/commands/search/run.sh index 28ccb045..7915b926 100644 --- a/test/commands/search/run.sh +++ b/test/commands/search/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/test/buttercup/run.sh b/test/commands/test/buttercup/run.sh index bf528c58..8bbce869 100644 --- a/test/commands/test/buttercup/run.sh +++ b/test/commands/test/buttercup/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/test/ert-runner/run.sh b/test/commands/test/ert-runner/run.sh index b69e894e..90203405 100644 --- a/test/commands/test/ert-runner/run.sh +++ b/test/commands/test/ert-runner/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/commands/test/ert/run.sh b/test/commands/test/ert/run.sh index 76bec5e2..9308d084 100644 --- a/test/commands/test/ert/run.sh +++ b/test/commands/test/ert/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (C) 2022 Jen-Chieh Shen +# Copyright (C) 2022-2023 Jen-Chieh Shen # 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 diff --git a/test/mini.emacs.d/.gitignore b/test/fixtures/mini.emacs.d/.gitignore similarity index 100% rename from test/mini.emacs.d/.gitignore rename to test/fixtures/mini.emacs.d/.gitignore diff --git a/test/mini.emacs.d/Eask b/test/fixtures/mini.emacs.d/Eask similarity index 100% rename from test/mini.emacs.d/Eask rename to test/fixtures/mini.emacs.d/Eask diff --git a/test/mini.emacs.d/RADME.md b/test/fixtures/mini.emacs.d/RADME.md similarity index 100% rename from test/mini.emacs.d/RADME.md rename to test/fixtures/mini.emacs.d/RADME.md diff --git a/test/mini.emacs.d/init.el b/test/fixtures/mini.emacs.d/init.el similarity index 100% rename from test/mini.emacs.d/init.el rename to test/fixtures/mini.emacs.d/init.el diff --git a/test/mini.emacs.d/scripts/copy_config.ps1 b/test/fixtures/mini.emacs.d/scripts/copy_config.ps1 similarity index 91% rename from test/mini.emacs.d/scripts/copy_config.ps1 rename to test/fixtures/mini.emacs.d/scripts/copy_config.ps1 index 3321a956..1fb33d7b 100644 --- a/test/mini.emacs.d/scripts/copy_config.ps1 +++ b/test/fixtures/mini.emacs.d/scripts/copy_config.ps1 @@ -22,4 +22,4 @@ echo "Copy test configuration" mkdir "$env:USERPROFILE/AppData/Roaming/.emacs.d" -robocopy /e "./test/mini.emacs.d/" "$env:USERPROFILE/AppData/Roaming/.emacs.d" +robocopy /e "./test/fixtures/mini.emacs.d/" "$env:USERPROFILE/AppData/Roaming/.emacs.d" diff --git a/test/mini.emacs.d/scripts/copy_config.sh b/test/fixtures/mini.emacs.d/scripts/copy_config.sh similarity index 94% rename from test/mini.emacs.d/scripts/copy_config.sh rename to test/fixtures/mini.emacs.d/scripts/copy_config.sh index 2d1c8352..e86b1fe0 100644 --- a/test/mini.emacs.d/scripts/copy_config.sh +++ b/test/fixtures/mini.emacs.d/scripts/copy_config.sh @@ -23,4 +23,4 @@ # echo "Copy test configuration" -cp -R ./test/mini.emacs.d/ ~/.emacs.d +cp -R ./test/fixtures/mini.emacs.d/ ~/.emacs.d diff --git a/test/mini.emacs.pkg/Eask b/test/fixtures/mini.emacs.pkg.1/Eask similarity index 84% rename from test/mini.emacs.pkg/Eask rename to test/fixtures/mini.emacs.pkg.1/Eask index 07d75588..ad6acf40 100644 --- a/test/mini.emacs.pkg/Eask +++ b/test/fixtures/mini.emacs.pkg.1/Eask @@ -1,11 +1,11 @@ -(package "mini.emacs.pkg" +(package "mini.emacs.pkg.1" "0.0.1" "Minimal test package") -(website-url "https://github.com/emacs-eask/mini.emacs.pkg") +(website-url "https://github.com/emacs-eask/mini.emacs.pkg.1") (keywords "test") -(package-file "mini.emacs.pkg.el") +(package-file "mini.emacs.pkg.1.el") (files "files/*.el") diff --git a/test/mini.emacs.pkg/RADME.md b/test/fixtures/mini.emacs.pkg.1/RADME.md similarity index 100% rename from test/mini.emacs.pkg/RADME.md rename to test/fixtures/mini.emacs.pkg.1/RADME.md diff --git a/test/mini.emacs.pkg/files/mini.emacs.pkg-1.el b/test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-1.el similarity index 79% rename from test/mini.emacs.pkg/files/mini.emacs.pkg-1.el rename to test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-1.el index 6a035726..f0a9690b 100644 --- a/test/mini.emacs.pkg/files/mini.emacs.pkg-1.el +++ b/test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-1.el @@ -1,4 +1,4 @@ -;;; mini.emacs.pkg-1.el --- Extern file 1 -*- lexical-binding: t; -*- +;;; mini.emacs.pkg.1-1.el --- Extern file 1 -*- lexical-binding: t; -*- ;; This file is NOT part of GNU Emacs. @@ -17,16 +17,16 @@ ;;; Commentary: ;; -;; extern/mini.emacs.pkg-1.el +;; files/mini.emacs.pkg.1-1.el ;; ;;; Code: -(defun mini.emacs.pkg-1 () +(defun mini.emacs.pkg.1-1 () "Test function 1." (interactive) ) -(provide 'mini.emacs.pkg-1) -;;; mini.emacs.pkg-1.el ends here +(provide 'mini.emacs.pkg.1-1) +;;; mini.emacs.pkg.1-1.el ends here diff --git a/test/mini.emacs.pkg/files/mini.emacs.pkg-2.el b/test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-2.el similarity index 79% rename from test/mini.emacs.pkg/files/mini.emacs.pkg-2.el rename to test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-2.el index 701cc4ff..6c62bb33 100644 --- a/test/mini.emacs.pkg/files/mini.emacs.pkg-2.el +++ b/test/fixtures/mini.emacs.pkg.1/files/mini.emacs.pkg.1-2.el @@ -1,4 +1,4 @@ -;;; mini.emacs.pkg-2.el --- Extern file 2 -*- lexical-binding: t; -*- +;;; mini.emacs.pkg.1-2.el --- Extern file 2 -*- lexical-binding: t; -*- ;; This file is NOT part of GNU Emacs. @@ -17,15 +17,15 @@ ;;; Commentary: ;; -;; extern/mini.emacs.pkg-2.el +;; files/mini.emacs.pkg.1-2.el ;; ;;; Code: -(defun mini.emacs.pkg-2 () +(defun mini.emacs.pkg.1-2 () "Test function 2." (interactive) ) -(provide 'mini.emacs.pkg-2) -;;; mini.emacs.pkg-2.el ends here +(provide 'mini.emacs.pkg.1-2) +;;; mini.emacs.pkg.1-2.el ends here diff --git a/test/mini.emacs.pkg/mini.emacs.pkg.el b/test/fixtures/mini.emacs.pkg.1/mini.emacs.pkg.1.el similarity index 81% rename from test/mini.emacs.pkg/mini.emacs.pkg.el rename to test/fixtures/mini.emacs.pkg.1/mini.emacs.pkg.1.el index ab3d82d9..b8cf3629 100644 --- a/test/mini.emacs.pkg/mini.emacs.pkg.el +++ b/test/fixtures/mini.emacs.pkg.1/mini.emacs.pkg.1.el @@ -1,10 +1,10 @@ -;;; mini.emacs.pkg.el --- Minimal test package -*- lexical-binding: t; -*- +;;; mini.emacs.pkg.1.el --- Minimal test package -*- lexical-binding: t; -*- -;; Copyright (C) 2022 Shen, Jen-Chieh +;; Copyright (C) 2022-2023 Shen, Jen-Chieh ;; Created date 2022-03-29 01:52:58 ;; Author: Shen, Jen-Chieh -;; URL: https://github.com/emacs-eask/mini.emacs.pkg +;; URL: https://github.com/emacs-eask/mini.emacs.pkg.1 ;; Version: 0.0.1 ;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1")) ;; Keywords: test @@ -35,5 +35,5 @@ (require 's) (require 'fringe-helper) -(provide 'mini.emacs.pkg) -;;; mini.emacs.pkg.el ends here +(provide 'mini.emacs.pkg.1) +;;; mini.emacs.pkg.1.el ends here diff --git a/test/fixtures/mini.emacs.pkg.2/Eask b/test/fixtures/mini.emacs.pkg.2/Eask new file mode 100644 index 00000000..6edd8cb3 --- /dev/null +++ b/test/fixtures/mini.emacs.pkg.2/Eask @@ -0,0 +1,30 @@ +(package "mini.emacs.pkg.2" + "0.0.1" + "Minimal test package") + +(website-url "https://github.com/emacs-eask/mini.emacs.pkg.2") +(keywords "test") + +(package-file "mini.emacs.pkg.2.el") + +(files "files/*.el") + +(script "test" "echo \"Have a nice day!~ ;)\"") +(script "info" "eask info") + +(source "gnu") +(source "melpa") +(source "jcs-elpa") + +(depends-on "emacs" "26.1") +(depends-on "f") +(depends-on "s") +(depends-on "fringe-helper") +(depends-on "watch-cursor" + :repo "jcs-elpa/watch-cursor" :fetcher 'github) +(depends-on "organize-imports-java" + :repo "jcs-elpa/organize-imports-java" + :fetcher 'github + :files '(:defaults "sdk" "default")) + +(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 diff --git a/test/fixtures/mini.emacs.pkg.2/RADME.md b/test/fixtures/mini.emacs.pkg.2/RADME.md new file mode 100644 index 00000000..441cfd06 --- /dev/null +++ b/test/fixtures/mini.emacs.pkg.2/RADME.md @@ -0,0 +1 @@ +Minimal Emacs package to simulate development environment; only for testing purposes! diff --git a/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-1.el b/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-1.el new file mode 100644 index 00000000..b2e8c561 --- /dev/null +++ b/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-1.el @@ -0,0 +1,32 @@ +;;; mini.emacs.pkg.2-1.el --- Extern file 1 -*- lexical-binding: t; -*- + +;; This file is NOT part of GNU Emacs. + +;; 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: +;; +;; files/mini.emacs.pkg.2-1.el +;; + +;;; Code: + + +(defun mini.emacs.pkg.2-1 () + "Test function 1." + (interactive) + ) + +(provide 'mini.emacs.pkg.2-1) +;;; mini.emacs.pkg.2-1.el ends here diff --git a/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-2.el b/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-2.el new file mode 100644 index 00000000..d19294b7 --- /dev/null +++ b/test/fixtures/mini.emacs.pkg.2/files/mini.emacs.pkg.2-2.el @@ -0,0 +1,31 @@ +;;; mini.emacs.pkg.2-2.el --- Extern file 2 -*- lexical-binding: t; -*- + +;; This file is NOT part of GNU Emacs. + +;; 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: +;; +;; files/mini.emacs.pkg.2-2.el +;; + +;;; Code: + +(defun mini.emacs.pkg.2-2 () + "Test function 2." + (interactive) + ) + +(provide 'mini.emacs.pkg.2-2) +;;; mini.emacs.pkg.2-2.el ends here diff --git a/test/fixtures/mini.emacs.pkg.2/mini.emacs.pkg.2.el b/test/fixtures/mini.emacs.pkg.2/mini.emacs.pkg.2.el new file mode 100644 index 00000000..d25fe47d --- /dev/null +++ b/test/fixtures/mini.emacs.pkg.2/mini.emacs.pkg.2.el @@ -0,0 +1,39 @@ +;;; mini.emacs.pkg.2.el --- Minimal test package -*- lexical-binding: t; -*- + +;; Copyright (C) 2022-2023 Shen, Jen-Chieh +;; Created date 2022-03-29 01:52:58 + +;; Author: Shen, Jen-Chieh +;; URL: https://github.com/emacs-eask/mini.emacs.pkg.2 +;; Version: 0.0.1 +;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1")) +;; Keywords: test + +;; This file is NOT part of GNU Emacs. + +;; 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: +;; +;; Minimal Emacs package to simulate development environment; only for testing +;; purposes! +;; + +;;; Code: + +(require 's) +(require 'fringe-helper) + +(provide 'mini.emacs.pkg.2) +;;; mini.emacs.pkg.2.el ends here