-
Notifications
You must be signed in to change notification settings - Fork 116
[BREAKING CHANGE] [Feature] Core #129
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
Conversation
…res/fixes in other PRs. Added feature of autoupdate dotly
…overflow.com/a/17841619 Removed duplicate functions
…ta branch for testing and developing.
…otly, fixed all the way init-scripts were loaded because they fail. Fixed some issues.
* Added new functions to get the current script_name or script_path where the functions were run * Added function to conver mayus to lower
`mas` has added support for Apple Silicon: mas-cli/mas#310
…led (#107) Co-authored-by: David Asensio Cañas <david.asensio@lifullconnect.com>
In case of having multiple Cargo dependencies installed such as:
```sh
{▸} ~ cargo install --list
docpars v0.2.0:
docpars
git-delta v0.6.0:
delta
```
The previous command was passing out multiple lines:
```sh
{▸} ~ cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' '
docpars
git-delta
```
Because of these lines were being received by the very same `cargo install` command, it was failing:
```sh
{▸} ~ cargo install "$(cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')"
Updating crates.io index
error: could not find `docpars
git-delta` in registry `https://github.com/rust-lang/crates.io-index` with version `*`
```
Now, it executes the `cargo install` multiple times, but at least do not produce crashes 😅
```sh
{▸} ~ cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' | xargs -n1 cargo install
Updating crates.io index
Ignored package `docpars v0.2.0` is already installed, use --force to override
Updating crates.io index
Ignored package `git-delta v0.6.0` is already installed, use --force to override
```
Having pip3 installed does not imply having defined any dependencies for python. This change avoids crashing while running the `up` command. We were crashing because of the combination of `set -euo pipefail` with an empty input for the `grep -v '^\-e'` 🤟
Added script 'dot symlinks update'
* Fix errors with symlinks update script when files are symbolic links * Fix non alphanumeric names of files
…ates can apply its own symlinks without adding files in symlinks subfolder
…so use it without copying files to the init-scripts folder Added a CHANGELOG
* When you have problems of file permissions of autocompletions or any zsh file you can solve those errors by executing this subcommand.
Merged official dotly master branch in this branch.
|
…ould broke many scripts
- Fixed error getting `brew --prefix` because PATH is not defined yet when we need to get it. - Fixed error in shell/bash/init.sh because xargs did not have the argument -0 (NUL error)
xargs: WARNING: a NUL character occurred in the input. It cannot be passed through in the argument list. Did you mean to use the --null option?
Description
This adds a lot of libs for more incoming features when this PR will be approved. These libs were added here here because were recurrently used in the other features. This also change the way dotly is loaded because some times the features need a change in bashrc or zshrc, so now bash and zsh have a loader for dotly.
Core Libraries
Core libraries modified
git.shgit::get_local_HEAD_hashget local HEAD of the given branch or current HEAD.git::get_remote_branch_HEAD_hashthe commit hash of the remote branch HEAD.git::local_current_branch_commit_exists_remotereturn boolean if the given git remote branch HEAD is the same as the local branch HEAD.git::remote_branch_by_hashgive you the remote branch name by the commit hash.git::current_branchmodified to show the current branch.git::current_commit_hashget the current commit hash.git::get_commit_tagget tag if given commit is tagged in the local repository.git::get_all_local_tagsgit::get_current_latest_tagget local last tag (ordered by name).git::get_all_remote_tagsgit::get_all_remote_tags_version_onlyget remote tags but peform a format to branch name.git::check_local_tag_existscheck if given tag exists in local repository.git::check_remote_tag_existscheck if given tag exists in a git remote.git::get_submodule_propertyget.gitmodulesproperty for given module.git::check_local_repo_is_updatedcheck if local repository is behind remote origin repository by using git statusgit::simple_check_local_repo_is_updatedthe same as previous in more simple waygit::dotly_repository_execfunction to execute any function inside the DOTLY_PATH. Useful to performgit checkoutor any git command that require to be executed in the git repository.git::check_file_exists_in_previous_commitreturn true if file was added in latest commitgit::check_file_is_modified_after_commitcheck if a file was modified or added after the given commitgit::get_commit_timestampget the commit timestampgit::get_file_last_commit_timestampget the timestamp of last modified or added file if exists in any commitoutput.shoutput::questionget the input in a new line on macOSoutput::question_defaultwhich provides a default value if user no input a value in prompt.output::yesnoprovides a Yes/No question. It has fixed de double negation.platform.shplatform::semver_is_minor_patch_updatewhich compares if has a minor or patch change in semver versioning. This was added for dotly autoupdate feature.platform::semver_compareto compare semver versioning.dot.shdot::get_script_pathto get current script path in dotly scripts. Scripts can be installed in other context in a incoming feature so would be great use this when you need a external library for a script that it is in$DOTFILES_PATH/scriptsfolder. This not thinked for scripts that are in DOTLY_PATH because they must be "inmutable".dot::get_full_script_pathwith provides full path for calling this function script.dot::get_script_src_pathto load src internal script libraries (libraries in the same context as your dotly script). Seedot self version.Libraries added
templating.shWith this library you can create files or strings that have variables inside in the way of
XXX_VARIABLE_NAME_XXX, you can pipe string or pass it as argument or file (at the end) by using:You can also modify a bash variable in a file using:
async.shProvides async functionality as the same way of promises. This is a modified version of the async function of this library:
I did not add the source to the
README.mdI don't make that decision.array.shI use this with the script
dot self initto get the non disabled scripts or enabled or both. With this you can get the union, difference or disjunction of array values.files.shFunctions:
files::check_if_path_is_olderthat say true if a file or folder is older than the given time. True if is older, false if it is newer.files::backup_if_file_existsperform a backup of the given value and prints the path to the backup file.Modifications to
_main.shI consider
array.sh,files.shandasync.shcore libraries. The other libraries must be added manually if you want to use them in your scripts.Scripts modified
dot self updateModified to keep the same branch when updating dotly because was necessary for testing autoupdate and without this autoupdate does not have sense.
dot symlinks applyThis modification it is not very important. Just added
--versionfor the script. It was no moved to the DOCBLOC because makes no sense for me put it there and parse it when someone type--versioncalling the script.dot dotfiles createModified to use the new core
templating.shlibrary.Scripts added
dot self init(THIS WAS CHANGED VIEW LAST MESSAGE IN THIS PR)With this new script you can enable or disable script when open a new terminal or session. With this you will be able to enable or disable autoupdate.
dot self autoupdateExecutes async autoupdate. This is done here to avoid include all scripts when start the terminal which would make available all core functions that should be only available in the scripts.
dot self migrationExecutes script migrations. These scripts should have the version number as name and must be executable. The idea is to make simpler the dotly update when there are breaking changes or files/directory that are new in
dotfiles_templatedirectory.dot symlinks updateThis was added to execute update scripts when you update dotly and need to make changes to your current DOTFILES_PATH.
This update yaml files in a docbot format have to be in
$DOTLY_PATH/symlinks. There is one added to update old DOTFILES to this version but,.bashrcand.zshrcwere not added to update them, because maybe the user want to backup them and update them manually. Feel free to add any script here if you want :)About Autoupdate
Autoupdate need branch (tags) in the repository. It will use local tags to check if there is any update if value of
DOTLY_UPDATE_VERSIONtakesstableorminor. It will look for update in aHEADref of remote repository and local repository. This is done this way because DOTLY is always updated in master and master is the production branch.Modes (
DOTLY_AUTO_UPDATE_MODE)Autoupdate modes are:
silent, autoupdate with no warning about a update.auto, update silently and just show you a message when DOTLY was updated to restart your terminal.info, show you a message that there is available a new DOTLY version and also add a inbox at the very beginning of your DOTLY Theme prompt.prompt, just show the prompt inbox in DOTLY theme if there is any update.Version (
DOTLY_UPDATE_VERSION)latestupdate to latest commit inmasterbranch.stableupdate to latest tagged commit, because it is considered a stable commit.minorno update to major versions, considering that DOTLY will use a semver versioning.IMPORTANT The semver comparison function I put in the libraries is not compatible with tags like
beta,rc,alpha. Only consider number.Variables
DOTLY_AUTO_UPDATE_MODEby default takesautoDOTLY_AUTO_UPDATE_VERSIONby default takesstableDOTLY_UPDATE_PERIOD_IN_DAYSthe number of days that DOTLY should be older before start checking if there is any update.Enable/disable autoupdater
To enable autoupdater:
dot self init enable autoupdateTo disable autoupdater:
DEVELOPERS I strong recommend disable the option if your are developing something for dotly.
Autoupdater files
Autoupdater advise the user by creating empty files in
DOTFILES_PATHthese files are.dotly_force_current_version,.dotly_update_available,.dotly_update_available_is_majorand.dotly_updated.These files are recommend to add them in
.gitignore.File
.dotly_force_current_versionis a special file that forces dotly to no update automatically, this is useful if you are developing something for dotly core.New variables
GITHUB_TOKENis not necessary but recommend to get a Github token and add it to your dotfiles, if it is not present you can have errors about number of GitHub API limit reach which won't give any result to any API Call. If this is not defined you will see a message if you enable DOTLY Autoupdater or use any script that makes usage of this library.GITHUB_CACHE_PETITIONS_PERIOD_IN_DAYS, the number in days to keep the GitHub Cache of all API Calls. This makes this library faster.DOTLY_NO_INIT_SCRIPTSdisabledot self initusage and initial preload of scripts. (THIS WAS CHANGED, SEE LAST MESSAGE; CURRENT NAME OF THIS VARIABLE IS ANOTHER ONE).Fixes
findinstead ofls)dot self updateautomatically was switching to master branch even if you have installed from another branch. This was a rejected fix but was necessary for testing autoupdate.Documentation
No documentation was added.
Test
Testing by usage. You can tested from my fork, this branch was applied to master if you want to test.
Other
Feel free to modify this scripts, accept or reject them but I won't work anymore on this branch because I want it as it is in my own fork. Sorry.
Anyway if you have any doubt you can ask.
Task
git.shin this post.files.shfunction to perform backup if file exists.dot self migrationscript in this post.dot self updatedot self versionto select a DOTLY specific version and no update it.dot self migrationto execute migration scripts after any dotly update.