diff --git a/src/common-utils/_install-bin.sh b/src/common-utils/_install-bin.sh new file mode 100755 index 0000000..a149988 --- /dev/null +++ b/src/common-utils/_install-bin.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +### Init directories +caller_filename=$(ps -o args= $PPID) +caller_filepath=$(readlink -f ${caller_filename##/bin/sh}) +export source=$(dirname $caller_filepath) +export feature=$(basename $source | sed 's/_.*$//') +export target=${1:-/usr/local/share}/$feature + +### Create links to utils in /usr/local/bin +find $target -type f -name "_*.sh" -exec echo {} \; -exec chmod +x {} \; | while read file +do + link=/usr/local/bin/$(basename $file | sed 's/^_//;s/.sh$//') + ln -sf $file $link +done diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index 07406f0..deb36fc 100755 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "name": "Common Utils", - "version": "1.1.5", + "version": "1.1.6", "description": "Common utils for tomgrv/devcontainer-features", "dependsOn": { "ghcr.io/devcontainers/features/common-utils": {} diff --git a/src/common-utils/install-bin.sh b/src/common-utils/install-bin.sh deleted file mode 100755 index 9753252..0000000 --- a/src/common-utils/install-bin.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e - -### Create links to utils in /usr/bin -find $target -type f -name "_*.sh" -exec echo {} \; -exec chmod +x {} \; | while read file -do - link=/usr/bin/$(basename $file | sed -e 's/^_//' -e 's/.sh$//') - rm -f $link || true - ln -s $file $link || true -done diff --git a/src/common-utils/install.sh b/src/common-utils/install.sh index 4071f86..5d1527a 100755 --- a/src/common-utils/install.sh +++ b/src/common-utils/install.sh @@ -22,3 +22,4 @@ done ### Install this feature $(dirname $0)/_install-feature.sh +$(dirname $0)/_install-bin.sh diff --git a/src/gitutils/install-stubs.sh b/src/gitutils/install-stubs.sh deleted file mode 100755 index 9d1adc7..0000000 --- a/src/gitutils/install-stubs.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -set -e - -### Merge all files from stub folder to root with git merge-file -echo "Merging stubs files..." -for file in $(find $source/stubs -type f); do - - ### Get middle part of the path - folder=$(dirname ${file#$source/stubs/}) - - ### Create folder if not exists - mkdir -p $folder - - ### Merge file - echo "Merge $folder/$(basename $file)" - git merge-file -p $file $folder/$(basename $file) ${folder#$source/}/$(basename $file) >$folder/$(basename $file) - - ### Apply rights - chmod $(stat -c "%a" $file) $folder/$(basename $file) -done - -### Find all file with a trailing slash outside dist folder, make sure they are added to .gitignore and remove the trailing slash -echo "Add files to .gitignore..." -for file in $(find . -type f -name "#*" -not -path "./stubs/*" -not -path "./node_modules/*" -not -path "./vendors/*"); do - - echo "Add $file to .gitignore" - - ### Remove trailing # and leading ./# - clean=${file#./#} - - ### Add to .gitignore if not already there - grep -qxF $clean .gitignore || echo "$clean" >>.gitignore - - ### Rename file - mv $file $clean -done diff --git a/src/gitutils/install.sh b/src/gitutils/install.sh index 9f524e9..3d8594b 100755 --- a/src/gitutils/install.sh +++ b/src/gitutils/install.sh @@ -3,3 +3,4 @@ set -e ### Install this feature install-feature +install-stubs diff --git a/src/gitversion/devcontainer-feature.json b/src/gitversion/devcontainer-feature.json index 385ba00..7da5b81 100755 --- a/src/gitversion/devcontainer-feature.json +++ b/src/gitversion/devcontainer-feature.json @@ -1,6 +1,6 @@ { "name": "GitVersion feature", - "version": "3.0.1", + "version": "3.0.2", "description": "Add gitversion to your devcontainer", "dependsOn": { "ghcr.io/devcontainers/features/dotnet": "", diff --git a/src/gitversion/install-stubs.sh b/src/gitversion/install-stubs.sh deleted file mode 100755 index da24087..0000000 --- a/src/gitversion/install-stubs.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -set -e - -### Merge all files from stub folder to root with git merge-file -echo "Merging stubs files" -for file in $(find $source/stubs -type f); do - - ### Get middle part of the path - folder=$(dirname ${file#$source/stubs/}) - - ### Create folder if not exists - mkdir -p $folder - - ### Merge file - echo "Merge $folder/$(basename $file)" - git merge-file -p $file $folder/$(basename $file) ${folder#$source/}/$(basename $file) >$folder/$(basename $file) - - ### Apply rights - chmod $(stat -c "%a" $file) $folder/$(basename $file) -done - -### Find all file with a trailing slash outside dist folder, make sure they are added to .gitignore and remove the trailing slash -echo "Add files to .gitignore" -for file in $(find . -type f -name "#*" ! -path "*/stubs/*" ! -path "./node_modules/*" ! -path "./vendors/*"); do - - echo "Add $file to .gitignore" - - ### Remove # occurences in file path - clean=${file#./#} - - ### Add to .gitignore if not already there - grep -qxF $clean .gitignore || echo "$clean" >>.gitignore - - ### Rename file - mv $file $clean -done diff --git a/src/gitversion/install.sh b/src/gitversion/install.sh index ddeec3a..72b9228 100755 --- a/src/gitversion/install.sh +++ b/src/gitversion/install.sh @@ -3,3 +3,4 @@ set -e ### Install feature install-feature +install-stubs diff --git a/src/larasets/_art.sh b/src/larasets/_art.sh new file mode 100755 index 0000000..a171308 --- /dev/null +++ b/src/larasets/_art.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +workspace=${containerWorkspaceFolder:-${CODESPACE_VSCODE_FOLDER:-.}} +[ -n "$LARAVEL_SAIL" ] && [ "$LARAVEL_SAIL" -eq 1 ] && sail artisan "$@" || php -d xdebug.mode=off $workspace/artisan "$@" diff --git a/src/larasets/_sail.sh b/src/larasets/_sail.sh new file mode 100755 index 0000000..9f9e685 --- /dev/null +++ b/src/larasets/_sail.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +workspace=${containerWorkspaceFolder:-${CODESPACE_VSCODE_FOLDER:-.}} +[ -f sail ] && echo sail || echo $workspace/vendor/bin/sail diff --git a/src/larasets/configure-aliases.sh b/src/larasets/configure-aliases.sh index 1661c83..8e3d5c2 100755 --- a/src/larasets/configure-aliases.sh +++ b/src/larasets/configure-aliases.sh @@ -12,11 +12,6 @@ fi $SUDO cat <~/.bash_aliases alias gitv='gitversion' -alias sail='sh $([ -f sail ] && echo sail || echo ${containerWorkspaceFolder:-.}/vendor/bin/sail)' - -art() { - test -n "\$LARAVEL_SAIL" && test "\$LARAVEL_SAIL" -eq 1 && sail artisan "\$@" || php -d xdebug.mode=off \${CODESPACE_VSCODE_FOLDER:-.}/artisan "\$@" -} && export -f art srv() { test -n "\$LARAVEL_SAIL" && test "\$LARAVEL_SAIL" -eq 1 && sail npx --yes pm2 "\$@" || npx --yes pm2 "\$@" diff --git a/src/larasets/devcontainer-feature.json b/src/larasets/devcontainer-feature.json index cc466a7..fac5fe4 100755 --- a/src/larasets/devcontainer-feature.json +++ b/src/larasets/devcontainer-feature.json @@ -1,13 +1,13 @@ { "name": "Laravel settings", - "version": "3.0.2", + "version": "3.0.4", "description": "A feature to add useful laravel settings to your shell.", "containerEnv": { "APP_DEBUG": "true", "APP_ENV": "local", "APP_PORT": "80", - "APP_URL": "https://${localEnv:CODESPACE_NAME}-${containerEnv:APP_PORT}.${localEnv:GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}", - "ASSET_URL": "${containerEnv:APP_URL}", + "APP_URL": "https://${localEnv:CODESPACE_NAME}-${localEnv:APP_PORT}.${localEnv:GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}", + "ASSET_URL": "${localEnv:APP_URL}", "LARAVEL_SAIL": "1", "DB_CONNECTION": "sqlite", "DB_DATABASE": "database/database.sqlite", @@ -84,5 +84,8 @@ "installsAfter": [ "ghcr.io/tomgrv/devcontainer-features/common-utils" ], + "legacyIds": [ + "larasets" + ], "postStartCommand": "configure-feature larasets" } diff --git a/src/larasets/install.sh b/src/larasets/install.sh index 9f524e9..10b11e1 100755 --- a/src/larasets/install.sh +++ b/src/larasets/install.sh @@ -3,3 +3,4 @@ set -e ### Install this feature install-feature +install-bin