Skip to content

Commit 2932b7e

Browse files
committed
🚧 working on new install script
1 parent 91e0672 commit 2932b7e

44 files changed

Lines changed: 1839 additions & 1482 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/self-test-installation.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ name: Self test install / extend
44
on:
55
# Triggers the workflow on push or pull request events but only for the "main" branch
66
push:
7-
branches: [ "main" ]
7+
branches: ["main"]
88
paths:
9-
- 'tests.d/self-install/**'
10-
- 'commands.d/self-install.sh'
11-
- 'commands.d/self-extend.sh'
9+
- "tests.d/self-install/**"
10+
- "commands.d/self-install.sh"
11+
- "commands.d/self-extend.sh"
1212
pull_request:
1313
paths:
14-
- 'tests.d/self-install/**'
15-
- 'commands.d/self-install.sh'
16-
- 'commands.d/self-extend.sh'
14+
- "tests.d/self-install/**"
15+
- "commands.d/self-install.sh"
16+
- "commands.d/self-extend.sh"
1717

1818
# Allows you to run this workflow manually from the Actions tab
1919
workflow_dispatch:
@@ -50,4 +50,4 @@ jobs:
5050
-e RUNNING_IN_DOCKER=true \
5151
-e BRANCH_NAME=${BRANCH_NAME} \
5252
noyacode/minideb-bash5.0 \
53-
./tests.d/self-install/test self test -C
53+
./tests.d/self-install/test self test -c

.github/workflows/self-test.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ name: Self test
44
on:
55
# Triggers the workflow on push or pull request events but only for the "main" branch
66
push:
7-
branches: [ "main" ]
7+
branches: ["main"]
88
paths-ignore:
9-
- 'docs/**'
9+
- "docs/**"
1010
pull_request:
1111
paths-ignore:
12-
- 'docs/**'
12+
- "docs/**"
1313

1414
# Allows you to run this workflow manually from the Actions tab
1515
workflow_dispatch:
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
bash --version
4141
chmod +x valet
42-
./valet self test -C
42+
./valet self test -c
4343
4444
# Runs tests with bash 5
4545
- name: Run valet self test on bash5
@@ -49,4 +49,4 @@ jobs:
4949
-v $PWD:/app \
5050
-w /app \
5151
noyacode/minideb-bash5.0 \
52-
bash --version; VALET_CONFIG_ENABLE_COLORS=true VALET_CONFIG_DISABLE_PROGRESS=true ./valet self test -C
52+
bash --version; VALET_CONFIG_ENABLE_COLORS=true VALET_CONFIG_DISABLE_PROGRESS=true ./valet self test -c

commands.d/bash-bootstrap.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ description: |-
139139
140140
## 6. Incoming features
141141
142-
# TODO: FEATURES TO IMPLEMENT:
143-
#
144-
# - add builtin "z" to jump to frequently used directories
145-
# - auto source .env and .envrc files in the current directory
146-
# - Provide a good and fast default prompt if atuin is not installed
142+
TODO: FEATURES TO IMPLEMENT:
143+
144+
- add builtin "z" to jump to frequently used directories
145+
- auto source .env and .envrc files in the current directory
146+
- Provide a good and fast default prompt if atuin is not installed
147147
148148
options:
149149
- name: --bash-scripts-directory <directory>

commands.d/self-add-command.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ examples:
3333
COMMAND_YAML
3434
function selfAddCommand() {
3535
local commandName
36-
command::parseArguments "$@"; eval "${REPLY}"
36+
command::parseArguments "$@"
37+
eval "${REPLY}"
3738
command::checkParsedResults
3839

3940
local templateFlavor="default"
@@ -47,7 +48,7 @@ function selfAddCommand() {
4748
# check if we are working for an extension
4849
core::getExtensionsDirectory
4950
if [[ ${PWD} != "${REPLY}"* && ! -d "commands.d" ]]; then
50-
log::warning "The current directory is not under the valet user directory ⌜${REPLY}⌝."
51+
log::warning "The current directory is not under the valet extensions directory ⌜${REPLY}⌝."
5152
if ! interactive::confirm "It does not look like the current directory ⌜${PWD}⌝ is a valet extension, do you want to proceed anyway?"; then
5253
log::info "Aborting the creation of the command."
5354
log::info "You should first create an extension with ⌜valet self extend⌝ and then cd into the created directory."

commands.d/self-add-library.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ examples:
3333
COMMAND_YAML
3434
function selfAddLibrary() {
3535
local libraryName
36-
command::parseArguments "$@"; eval "${REPLY}"
36+
command::parseArguments "$@"
37+
eval "${REPLY}"
3738
command::checkParsedResults
3839

3940
local templateFlavor="default"
@@ -47,7 +48,7 @@ function selfAddLibrary() {
4748
# check if we are working for an extension
4849
core::getExtensionsDirectory
4950
if [[ ${PWD} != "${REPLY}"* && ! -d "libraries.d" ]]; then
50-
log::warning "The current directory is not under the valet user directory ⌜${REPLY}⌝."
51+
log::warning "The current directory is not under the valet extensions directory ⌜${REPLY}⌝."
5152
if ! interactive::confirm "It does not look like the current directory ⌜${PWD}⌝ is a valet extension, do you want to proceed anyway?"; then
5253
log::info "Aborting the creation of the library."
5354
log::info "You should first create an extension with ⌜valet self extend⌝ and then cd into the created directory."

commands.d/self-build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
command: self build
1414
function: selfBuild
1515
author: github.com/jcaillon
16-
shortDescription: Index all the commands and libraries present in the valet user directory and installation directory.
16+
shortDescription: Index all the commands and libraries present in the valet extensions directory and installation directory.
1717
description: |-
18-
Index all the command and libraries present in the valet user directory and installation directory.
18+
Index all the command and libraries present in the valet extensions directory and installation directory.
1919
2020
This command can be used to re-build the menu / help / options / arguments in case you have modified, added or removed a Valet command definition.
2121
@@ -25,7 +25,7 @@ description: |-
2525
2626
- Makes a list of all the eligible files in which we could find command definitions.
2727
- For each file in this list, extract the command definitions.
28-
- Build your commands file (in your valet user directory) from these definitions.
28+
- Build your commands file (in your valet extensions directory) from these definitions.
2929
- Makes a list of all `libraries.d` directories found in the user directory.
3030
3131
You can call this script directly in case calling ⌜valet self build⌝ is broken:
@@ -326,7 +326,7 @@ function extractCommandDefinitionsToVariables() {
326326
declareOtherCommandVariables
327327

328328
if ((duplicatedCommands > 0)); then
329-
core::fail "There are ${duplicatedCommands} duplicated commands, please remove them. Do you have a duplicated folder in your valet user directory?"
329+
core::fail "There are ${duplicatedCommands} duplicated commands, please remove them. Do you have a duplicated folder in your valet extensions directory?"
330330
fi
331331
}
332332

commands.d/self-document.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,20 @@ options:
3434
- name: -o, --output <directory path>
3535
description: |-
3636
The directory in which the documentation will be generated.
37-
Defaults to the valet user directory.
37+
Defaults to the valet extensions directory.
3838
- name: -C, --core-only
3939
description: |-
4040
Generate the documentation for the core functions only.
41-
Will not generate for libraries present in the valet user directory.
41+
Will not generate for libraries present in the valet extensions directory.
4242
examples:
4343
- name: self document
4444
description: |-
4545
Generate the documentation for all the library functions of Valet and output to the default directory.
4646
COMMAND_YAML
4747
function selfDocument() {
4848
local output coreOnly
49-
command::parseArguments "$@"; eval "${REPLY}"
49+
command::parseArguments "$@"
50+
eval "${REPLY}"
5051
command::checkParsedResults
5152

5253
# default output to the user directory
@@ -153,7 +154,7 @@ function selfDocument::getAllFunctionsDocumentation() {
153154
local line
154155
while IFS=$'\n' read -rd $'\n' line || [[ -n ${line:-} ]]; do
155156
if [[ ${reading} == "false" ]]; then
156-
if [[ ${line} == "# ##"* && ${line} != *"(private)"* && ${line} != *"(deprecated)"* ]]; then
157+
if [[ ${line} == "# ##"* && ${line} != *"(private)"* && ${line} != *"(deprecated)"* ]]; then
157158
reading=true
158159
else
159160
continue
@@ -216,7 +217,7 @@ function selfDocument::convertFunctionDocumentationToMarkdown() {
216217
documentation="${documentation:${#line}+1}"
217218

218219
if [[ "${line}" =~ ^("- \$"([^ :]+))[^_]+_[^_]+_:$ ]]; then
219-
if (( parameterCount > 0 )); then
220+
if ((parameterCount > 0)); then
220221
REPLY+=$'\n'
221222
else
222223
REPLY+="Inputs:"$'\n'$'\n'
@@ -433,4 +434,4 @@ function selfDocument_writeAllCommandsToMarkdown() {
433434
# add footer
434435
content+="> ${pageFooter}"
435436
fs::writeToFile "${outputFile}" content
436-
}
437+
}

commands.d/self-extend.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ description: |-
3636
3737
This command will either:
3838
39-
- Create and setup a new extension directory under the valet user directory,
39+
- Create and setup a new extension directory under the valet extensions directory,
4040
- setup an existing directory as a valet extension,
41-
- or download the given extension (repository) and install it in the Valet user directory.
41+
- or download the given extension (repository) and install it in the valet extensions directory.
4242
4343
For downloaded extensions, all GIT repositories are supported.
4444
For the specific cases of GitHub and GitLab repositories, this command will:
@@ -156,8 +156,8 @@ function selfExtend() {
156156

157157
# rebuild the command cache
158158
log::info "Rebuilding the command cache."
159-
command::deleteUserCommands
160-
command::reloadUserCommands
159+
command::deleteCommandsIndex
160+
command::reloadCommandsIndex
161161

162162
# rebuild the documentation
163163
log::info "Rebuilding the documentation."

commands.d/self-install.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ description: |-
4444
in a bin directory already present in your PATH, or by adding the Valet
4545
directory to your PATH on shell startup.
4646
47-
- 4. Copy the showcase (command examples) in the valet user directory ~/.valet.d.
47+
- 4. Copy the showcase (command examples) in the valet extensions directory ~/.valet.d.
4848
4949
- 6. Run self setup command (in case of a new installation) or re-export the config.
5050
5151
- 7. Try to update (fetch merge --ff-only) the git repositories and all
52-
installed extensions in your valet user directory.
52+
installed extensions in your valet extensions directory.
5353
5454
options:
5555
- name: -u, --unattended
@@ -84,19 +84,19 @@ options:
8484
default: false
8585
- name: --no-showcase
8686
description: |-
87-
Set to true to to not copy the showcase (command examples) to the valet user directory (~/.valet.d).
87+
Set to true to to not copy the showcase (command examples) to the valet extensions directory (~/.valet.d).
8888
8989
If you do not set this option, newer versions of the showcase will override the existing ones.
9090
9191
In case of an update, if the showcase.d directory does not exist, the showcase will not be copied.
9292
default: false
9393
- name: -U, --skip-extensions
9494
description: |-
95-
Set to true to not attempt to update the installed extensions under the valet user directory (~/.valet.d).
95+
Set to true to not attempt to update the installed extensions under the valet extensions directory (~/.valet.d).
9696
default: false
9797
- name: -e, --only-extensions
9898
description: |-
99-
Set to true to only update the installed extensions under the valet user directory (~/.valet.d).
99+
Set to true to only update the installed extensions under the valet extensions directory (~/.valet.d).
100100
default: false
101101
- name: --skip-extensions-setup
102102
description: |-
@@ -332,14 +332,14 @@ function selfUpdate() {
332332
fi
333333

334334
# remove the user commands to rebuild them
335-
command::deleteUserCommands
335+
command::deleteCommandsIndex
336336
if [[ ${firstInstallation} == "true" ]]; then
337337
# shellcheck source=../libraries.d/main
338338
source "${GLOBAL_INSTALLATION_DIRECTORY}/libraries.d/main"
339339
log::debug "Sourcing the core functions from valet."
340340
selfUpdate_sourceDependencies
341341
else
342-
command::reloadUserCommands
342+
command::reloadCommandsIndex
343343
fi
344344

345345
if [[ ${createShim} == "true" ]]; then
@@ -744,7 +744,7 @@ if [[ ${GLOBAL_MAIN_INCLUDED:-} != "true" ]]; then
744744
*) REPLY="unknown" ;;
745745
esac
746746
}
747-
function core::getExtensionsDirectory() { REPLY="${VALET_CONFIG_USER_VALET_DIRECTORY:-${HOME}/.valet.d}"; }
747+
function core::getExtensionsDirectory() { REPLY="${VALET_CONFIG_EXTENSIONS_DIRECTORY:-${HOME}/.valet.d}"; }
748748
function core::getUserDataDirectory() { REPLY="${VALET_CONFIG_USER_DATA_DIRECTORY:-${XDG_DATA_HOME:-${HOME}/.local/share}/valet}"; }
749749
function interactive::confirm() {
750750
local \
@@ -776,7 +776,7 @@ if [[ ${GLOBAL_MAIN_INCLUDED:-} != "true" ]]; then
776776
function fs::readFile() { REPLY="$(<"${1}")"; }
777777
function progress::start() { :; }
778778
function progress::stop() { :; }
779-
function command::deleteUserCommands() {
779+
function command::deleteCommandsIndex() {
780780
core::getUserDataDirectory
781781
rm -f "${REPLY}/commands" 1>/dev/null || :
782782
}

commands.d/self-release.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ options:
5555
Do not perform the release, just show what would be done.
5656
COMMAND_YAML
5757
function selfRelease() {
58-
command::parseArguments "$@"; eval "${REPLY}"
58+
command::parseArguments "$@"
59+
eval "${REPLY}"
5960
command::checkParsedResults
6061

6162
if [[ ${dryRun:-} == "true" ]]; then
@@ -245,7 +246,6 @@ function selfRelease::createRelease() {
245246
-d "${releasePayload}" \
246247
--- failOnError=true acceptableCodes='201,422'
247248

248-
249249
createdReleaseJson="${REPLY}"
250250

251251
log::success "The new version has been released on GitHub."
@@ -349,9 +349,6 @@ function selfRelease::updateDocumentation() {
349349
exe::invoke cp -f "${GLOBAL_INSTALLATION_DIRECTORY}/extras/lib-valet.md" "${GLOBAL_INSTALLATION_DIRECTORY}/docs/static/lib-valet.md"
350350
exe::invoke cp -f "${GLOBAL_INSTALLATION_DIRECTORY}/extras/valet-commands.md" "${GLOBAL_INSTALLATION_DIRECTORY}/docs/static/valet-commands.md"
351351

352-
# copy the vscode recommended extensions
353-
exe::invoke cp "${GLOBAL_INSTALLATION_DIRECTORY}/.vscode/extensions.json" "${GLOBAL_INSTALLATION_DIRECTORY}/extras/extensions.json"
354-
355352
# export stats
356353
# shellcheck disable=SC2034
357354
local statsContent="nbFunctions: ${#SORTED_FUNCTION_NAMES[@]}"$'\n'

0 commit comments

Comments
 (0)