-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add bump command * changelog * add test and docs * rm en translation * docs * fix doc trans * improve string sexp * rm msg
- Loading branch information
Showing
10 changed files
with
217 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (C) 2023 the Eask authors. | ||
* | ||
* 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
exports.command = ['bump [levels..]']; | ||
exports.desc = UTIL.hide_cmd('Bump version for your project'); | ||
exports.builder = yargs => yargs | ||
.positional( | ||
'[levels..]', { | ||
description: "version level to bump; accept `major', `minor' or `patch'", | ||
type: 'array', | ||
}); | ||
|
||
exports.handler = async (argv) => { | ||
await UTIL.e_call(argv, 'core/bump' | ||
, argv.levels); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
;;; core/bump.el --- Bump version for your project -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
;; | ||
;; Command use to bump version, | ||
;; | ||
;; $ eask bump | ||
;; | ||
;; | ||
;; Positionals: | ||
;; | ||
;; [levels..] version level to bump; accept `major', `minor' or `patch' | ||
;; | ||
|
||
;;; Code: | ||
|
||
(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args))))) | ||
(load (expand-file-name "_prepare.el" | ||
(locate-dominating-file dir "_prepare.el")) | ||
nil t)) | ||
|
||
(defun eask-bump-version--version (version index) | ||
"Bump VERSION with INDEX." | ||
(let ((lst (if (stringp version) (version-to-list version) version))) | ||
(setf (nth index lst) (cl-incf (nth index lst))) | ||
(mapconcat #'eask-2str lst version-separator))) | ||
|
||
(defun eask-bump-version--major-version (version) | ||
"Bump VERSION major level." | ||
(eask-bump-version--version version 0)) | ||
|
||
(defun eask-bump-version--minor-version (version) | ||
"Bump VERSION minor level." | ||
(eask-bump-version--version version 1)) | ||
|
||
(defun eask-bump-version--patch-level (version) | ||
"Bump VERSION patch level." | ||
(eask-bump-version--version version 2)) | ||
|
||
(eask-start | ||
(let ((package-file (or eask-package-file | ||
(eask-guess-entry-point))) | ||
(levels (eask-args)) | ||
(desc) | ||
(version) | ||
(tasks (if eask-file 2 1))) | ||
(unless eask-package-file | ||
(eask-info "💡 Detect package file `%s'..." package-file)) | ||
(cond | ||
((and (not (member "major" levels)) | ||
(not (member "minor" levels)) | ||
(not (member "patch" levels))) | ||
(eask-help "core/bump")) | ||
((not (file-exists-p package-file)) | ||
(eask-info "(No package file found)")) | ||
(t | ||
(with-current-buffer (find-file package-file) | ||
(setq desc (package-buffer-info))) | ||
(setq version (package-desc-version desc)) | ||
(when (member "major" levels) | ||
(setq version (eask-bump-version--major-version version))) | ||
(when (member "minor" levels) | ||
(setq version (eask-bump-version--minor-version version))) | ||
(when (member "patch" levels) | ||
(setq version (eask-bump-version--patch-level version))) | ||
(eask-msg "New version: %s" version) | ||
(let (success) | ||
(eask-with-progress | ||
(format " - [1/%s] Bump version for package-file (%s)... " | ||
tasks | ||
(eask-root-del package-file)) | ||
(with-current-buffer (find-file package-file) | ||
(goto-char (point-min)) | ||
(cond ((re-search-forward ";;[ \t]*Version:[ \t]*" nil t) | ||
(delete-region (point) (line-end-position)) | ||
(insert version) | ||
(setq success t) | ||
(save-buffer)) | ||
(t | ||
(eask-error | ||
"Failed to bump version to package file; invalid search string: %s" | ||
package-file)))) | ||
(if success "done ✓" "skipped ✗"))) | ||
(when eask-file | ||
(let (success) | ||
(eask-with-progress | ||
(format " - [1/%s] Bump version for Eask-file (%s)... " | ||
tasks | ||
(eask-root-del eask-file)) | ||
(with-current-buffer (find-file eask-file) | ||
(goto-char (point-min)) | ||
(cond ((re-search-forward "(package[ \t\r\n\"]*" nil t) | ||
(forward-char -1) | ||
(forward-thing 'sexp) | ||
(forward-thing 'sexp) | ||
(forward-sexp -1) | ||
(delete-region (1+ (point)) (save-excursion | ||
(forward-thing 'sexp) | ||
(1- (point)))) | ||
(forward-char 1) | ||
(insert version) | ||
(setq success t) | ||
(save-buffer)) | ||
(t | ||
(eask-error | ||
"Failed to bump version to Eask-file; invalid search string: %s" | ||
eask-file)))) | ||
(if success "done ✓" "skipped ✗")))))))) | ||
|
||
;;; core/bump.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
💡 You need to specify version level(s) in order to make this command work: | ||
|
||
$ eask bump major | ||
|
||
💡 The `bump` command accepts multiple values: | ||
|
||
$ eask bump major |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters