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

[Feature] Create scripts from terminal #8

Merged
merged 14 commits into from
Jun 24, 2021

Conversation

gtrabanco
Copy link
Owner

Description

This provides scripts to create core or user scripts easier.

Motivation

Create the scripts faster with just by executing a script.

Added core libraries

templating.sh

This from PR #129.

dot.sh

This from PR #129

output.sh

This from PR #129

Added scripts

dot dotly create

Create a custom script in your DOTFILES_PATH or in DOTLY_PATH. See dot dotly create --help

Dotly script creator


Usage:
  create [-h | --help]
  create [-v | --version]
  create [-c | --core] [-s | --sample] [--author <author>] [--email <email] <context> <script_name> [<script_description>...]

Options:
  -h --help          Show this help
  -v --version       Show the program version
  -s --sample        Create a script using more complete example with some comments.
                     useful if it is your first script. Anyway you can see more help
                     in the docopt website: http://docopt.org
  -c --core          Create the context and script in "/Users/gtrabanco/.dotfiles/modules/dotly/scripts" instead of
                     your "/Users/gtrabanco/.dotfiles/scripts" folder
  --author <author>  Provide who is the author, if none the default git author will
                     be used
  --email <email>    Provide author email, if none the default git author email will
                     be used

Author:
  Gabriel Trabanco <gtrabanco@users.noreply.github.com>

dot dotly install-remote

Install scripts from remote url. It must be a raw url to download it. See dot dotly install-remote --help

Install remote context or script in your /Users/gtrabanco/.dotfiles from url. It
must be the url to the raw file.
If you fill the last param <script_name>, the remote file name will be
omited and renamed in your /Users/gtrabanco/.dotfiles/scripts/<context> folder

Usage:
  install-remote [ -h | --help ]
  install-remote [ -v | --version ]
  install-remote <context> <script_raw_url> [<script_name>]

Options:
  -h --help     Show this help
  -v --version  Show the program version


Author:
  Gabriel Trabanco Llano <gtrabanco@users.noreply.github.com>

If PR #129 is approved then next files must be discarded:

  • scripts/core/dot.sh
  • scripts/core/output.sh
  • scripts/core/templating.sh

Because probably are more updated in the PR #129

@gtrabanco gtrabanco merged commit 556d3bd into feature/core Jun 24, 2021
@gtrabanco gtrabanco deleted the feature/template_scripts branch June 24, 2021 22:11
gtrabanco added a commit that referenced this pull request Jun 24, 2021
* Paths are now loaded before everything

* Core update, adding some functions that will be used with other features/fixes in other PRs. Added feature of autoupdate dotly

* Improved output::join with a stackoverflow function in: https://stackoverflow.com/a/17841619
Removed duplicate functions

* Added closed and unapproved PR #61 because it is needed when I use beta branch for testing and developing.

* Added a way to modify DOTFILES_PATH structure when add a feature to dotly, fixed all the way init-scripts were loaded because they fail. Fixed some issues.

* Added some core functions:
* Added new functions to get the current script_name or script_path where the functions were run
* Added function to conver mayus to lower

* Fix git pretty-log when commit is a branch (#100)

* 🍎 Install `mas` even on Apple Silicon (arm64) (#102)

`mas` has added support for Apple Silicon: mas-cli/mas#310

* Trigger `dot` command using `ctr+f`

* Use Volta instead of NPM to dump global packages in case it is installed (#107)

Co-authored-by: David Asensio Cañas <david.asensio@lifullconnect.com>

* [📦 rust] Fix crash while updating cargo dependencies (#113)

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
```

* [🐍 python] Avoid crash in case of not having python dependencies (#111)

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 async library
Added script 'dot symlinks update'

* Enable/disable autoload scripts can be symlinks

* Fixed error #93 with bash autocompletions

* Autoupdate

* Added folder for use with script 'dot symlinks update'
* Fix errors with symlinks update script when files are symbolic links
* Fix non alphanumeric names of files

* Added warning when no GITHUB_TOKEN is set

* Repetitive stuff should be in a loop

* Added support in update symlinks for symlinks, so now scripts and updates can apply its own symlinks without adding files in symlinks subfolder

* Support for symlinks and files as init scripts, so now scripts can also use it without copying files to the init-scripts folder
Added a CHANGELOG

* Added a new subcommand for script 'dot shell zsh': 'fix_permissions'
* When you have problems of file permissions of autocompletions or any zsh file
  you can solve those errors by executing this subcommand.

* Added a way to deactivate init scripts

* Use {▪} icon for prompt error status (#128)

Merged official dotly master branch in this branch.

* Removed unneded variable

* Fixed unbound variables

* Solved end / in url makes api call fail

* Not necessary lib

* Removed not needed variable

* Not needed file

* Renamed utils to src as PR #140

* Fixed to avoid unbound variable

* Changes in autoupdate
- Now github API is not needed for autoupdate
- Update minor right way but need tagged commits
- Update stable only to tagged versions
- Update to latest commit in master as always did

* Added 'dot self version' to choose your running DOTLY version

* Added more options to 'dot self version'

* Solved issues with libraries

* Feat/Fix migration and how libraries are loaded
- Moved functions from platform to dot
- Now added a function to load sandboxed libraries in context
- Migrate all scripts of this feature to use function to load sandboxed libraries
- Added migration script
- Renamed dotbot migration file
- Added option to no warn user about dotbot migration changes

* Added a way to try to guess if migration script is necessary

* Added migration script

* Fixed templating

* Fixed .zshrc file

* Updated init-dotly for zsh

* Updated init-dotly for bash

* Fix migration scripts
Final formating for dot self update

* Added gitignore to migration script, added dotbot migration yaml

* Added zsh test back

* Fixed to add automatically $HOME var when tamplating if path is inside your home

* Fixed zsh theme for autoupdate. Fix Format in .gitignore

* Fixed copy paste error for zsh DOTLY loading

* Fixed function name. It must be called autoupdate instead of update

* Modified to use the new way of load sandboxed libraries

* Added second optional param to dot::get_script_src_path
 - Now end .sh is optional but recommended
 - Now firstly it will try to load from Dotly core (for optional core libs)
 - Secondly it will try to load from directory 'src' in given path as second argument or current script path
 - Finally it will try to load from given path or inside the current script path

* Modified how libraries are loaded second step and later. Final work is:
1. Try to load from dotly core for not added in _main libraries (optionals)
2. Try to load from current script context 'src' subfolder
3. Try to load from a given context as second argument 'src' folder
4. If the second argument is not a context and library is not ther it will manage the second argument as a directory where the lib in the first argument should be.

* Check for variables or default value

* Deleted platform function from output.sh

* Removed not need of restore start working directory

* Fixed unbound variable

* Fixed dot::get_script_src_path lib loading

- Changed load priority. If second parameter is given it should be in the first place.
- Fixed loading libraries when not .sh was provided.
- Added `SCRIPT_LOADED_LIBS` variable to avoid duplicate loading of libs.

* Added default theme codely

* Fixed error when LOADED_LIBS does not have any library yet

* Fix(core): Dotfiles, core and variables
- Changed the way how dotly is loaded
- Removed dotfiles_template/shell/init.sh
- Changed JAVA_HOME
- Conditional add to PATH of `JAVA_HOME`, `GEM_HOME` and `GOHOME`
- Fixed core library `array.sh` were not loaded.
- Fixed in the `_main.sh` the alphabetical order were not preserved for `output.sh`
- Fixed functions that were required for dotly were in the user `functions.sh` instead in the core loading file. Now these functions are in `shell/init-dotly.sh` and `shell/zsh/init.sh`.
- Fixed not default theme were provided in bash.
- `dot::get_script_src_path` should be the recommended way to load a lib in any script. Maybe these functions should be directly available in `dot` command.
- Minor change in migration script to export current `PATH` directories

* Provided default values to all variables in output. Changed $1 for $* to accept all params in text functions

* Added brew autocompletions for bash and zsh
Changed the way bash autocompletions are loaded
Some fixes in reverse-search internal variables
Added shellcheck ignores when needed in dotly loader
Added handle errors when loading files
Init scripts now with find which enable it to use non alphabetical path names
Moved to init-dotly.sh aliases.sh and functions.sh

* Added double quotes in _main for DOTLY_PATH because it can contain non alphabetical chars

* Improved output::join with a stackoverflow function in: https://stackoverflow.com/a/17841619
Removed duplicate functions

* Added closed and unapproved PR #61 because it is needed when I use beta branch for testing and developing.

* Added a way to modify DOTFILES_PATH structure when add a feature to dotly, fixed all the way init-scripts were loaded because they fail. Fixed some issues.

* Added some core functions:
* Added new functions to get the current script_name or script_path where the functions were run
* Added function to conver mayus to lower

* Added async library
Added script 'dot symlinks update'

* Some changes in templating::replace_var

* Fixed dot::get_script_src_path wrong call to SCRIPT_LOADED_LIBS. Also changed the way the variable is initialized

* Changed how check if a value exists in an array

* Fixed that init script were not initilizing

* Moved init dis/enable scripts
Some fixes in library
Some changes in dotly-init.sh

* Fixed dot self migration

* Changed the usage of output::clarification to output::write

* Deleted output::clarification

* Fixed error message when enabled init-script does not exists

* output::question output::question_default output::yesno Change them could broke many scripts

* Fixed enable when select multiple script to enable

* Fixed path error for zsh brew autocompletions

* Fix update when no update yaml file is given and no choose in fzf selection

* Changed the name of dot::get_script_src_path to dot::load_library.

* Fixed NUL character ocurred in the input

* Fixed copy&paste error

* Update comment

* Fixed how path is loaded in dotly initializer. Fixed BASH shell loading zsh in macOS

* Fix: PATHS and BASH
- 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)

* Added GPG_TTY in init-dotly because it fails if I add it later

* Added open command

* Fixed no solved merge conflict

* Fix xargs issue without -0 option
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?

* The libs were not be added to SCRIPT_LOADED_LIBS

* Output compatibility with dotly. Modified dot command to lazy command

* [Feature] Create scripts from terminal (#8)

* Added dotly core scripts to create scripts

* Added output library from PR 129

* Update function dot::get_script_src_path

* Fixed error when LOADED_LIBS does not have any library yet

* Restored templating, dot and output from master to avoid merging problems

* Added shellcheck to template, added check of DOTLY_PATH in scripts

* Fixed minor issue in docopt script definition

* Changed the name of dot::get_script_src_path to dot::load_library.

* Added option to create script in $DOTFILES_PATH/bin

* Fixed variable name

* Fixed no chmod were applied before

* Fixed no new line were added before load dotly core

* Renamed to sloth

* Added output.sh library from feature/core because we do not want to modify it

Co-authored-by: Gabriel Trabanco Llano <gtrabanco@users.noreply.github.com>

Co-authored-by: Gabriel Trabanco Llano <gtrabanco@users.noreply.github.com>
Co-authored-by: Henry Palacios <henrydpalacios@gmail.com>
Co-authored-by: Javier Ferrer <javier.mailserio@gmail.com>
Co-authored-by: Rafa Gómez <rgomezcasas@gmail.com>
Co-authored-by: David Asensio Cañas <david.asensio@icloud.com>
Co-authored-by: David Asensio Cañas <david.asensio@lifullconnect.com>
Co-authored-by: Daniel Santamaría <santaka87@gmail.com>
@gtrabanco gtrabanco self-assigned this Jun 30, 2021
@gtrabanco gtrabanco added enhancement New feature or request minor Minor change in semantic versioning labels Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor Minor change in semantic versioning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant