Skip to content

Commit

Permalink
up: update kite deps update script logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 12, 2022
1 parent 348fdef commit bfee887
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 44 deletions.
31 changes: 31 additions & 0 deletions app/Console/SubCmd/ToolCmd/LnCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);

namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;

/**
* class LnCommand
*
* @author inhere
*/
class LnCommand extends Command
{
protected static string $name = 'ln';
protected static string $desc = 'quick create ln link';

protected function configure(): void
{
$this->flags->addArgByRule('name', 'show the tool detail info by name');
// $this->flags->addOpt('show', 's', 'show the tool info', 'bool');
// $this->flags->addOpt('list', 'l', 'list all can be installed tools', 'bool');
}

protected function execute(Input $input, Output $output)
{

$output->info('TODO');
}
}
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/config.cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
return [
// enable interactive
'no-interactive' => false,
'app' => [
// enable interactive
'no-interactive' => false,
],

// --------- component object config -----------

Expand Down
1 change: 1 addition & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

return [
'app' => [
'rootPath' => BASE_PATH,
],
'logger' => [
'name' => 'Kite',
Expand Down
49 changes: 41 additions & 8 deletions script/update-kite-deps.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash

set -e

# run: kite run --proxy update-kite-deps.sh
# run: sh script/update-kite-deps.sh

set -e
tmpKiteDir=~/Workspace/my-github/inhere/kite
usrKiteDir=~/.kite

Expand All @@ -16,18 +15,52 @@ git pull
composer update --no-progress
set +x

echo "update composer.lock"
echo "✅ Update composer.lock"
cp $tmpKiteDir/composer.lock $usrKiteDir

echo "update packages:"
echo "Update depends packages:"
for path in "$tmpKiteDir"/vendor/*; do
dir=$(basename "$path")

# update kite dev packages
if [[ $dir == "inhere" || $dir == "phppkg" || $dir == "toolkit" ]]; then
echo "- Skip the vendor/$dir"
for subpath in "$path"/* ; do
pkg=$(basename "$subpath")
dstDir=$usrKiteDir/vendor/"$dir/$pkg"
if [ -d "$dstDir"/.git ]; then
echo "- 🙈 SKIP exist dev package $dir/$pkg"
else
echo "- ✅ Add new dev package: $dir/$pkg"
cp -r "$tmpKiteDir/vendor/$dir/$pkg" "$usrKiteDir/vendor/$dir"/
fi
done
continue
fi

echo "- Update the vendor/$dir"
rm -rf $usrKiteDir/vendor/"$dir"
cp -r $tmpKiteDir/vendor/"$dir" $usrKiteDir/vendor/
# composer autoload files
if [ "$dir" == "autoload.php" ]; then
echo "- ✅ Update the vendor/$dir"
cp $tmpKiteDir/vendor/"$dir" $usrKiteDir/vendor/
continue
fi
if [[ "$dir" == "bin" || "$dir" == "composer" ]]; then
echo "- ✅ Update the vendor/$dir"
rm -rf $usrKiteDir/vendor/"$dir"
cp -r $tmpKiteDir/vendor/"$dir" $usrKiteDir/vendor/
continue
fi

# update third packages
for subpath in "$path"/* ; do
pkg=$(basename "$subpath")
echo "- ✅ Update package: $dir/$pkg"
rm -rf $usrKiteDir/vendor/"$dir/$pkg"
cp -r $tmpKiteDir/vendor/"$dir/$pkg" $usrKiteDir/vendor/"$dir"/
done
done

echo "🟢 Completed"

function foo() {
return
}
25 changes: 0 additions & 25 deletions script/update-kite-dev.sh

This file was deleted.

54 changes: 54 additions & 0 deletions script/upinit-kite-dev-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# run: kite run --proxy upinit-kite-dev-deps.sh
# run: bash script/upinit-kite-dev-deps.sh
set -e

# proxy_on
kiteDir=~/.kite
ghHost=https://github.com
cd $kiteDir

# create array
groups=(inhere phppkg toolkit)

echo "Update kite dev depends packages."
for dir in "${groups[@]}"; do
echo "- ✅ Update the vendor/$dir"

ghGrp=$dir
if [ "$dir" == "toolkit" ]; then
ghGrp="php-$dir"
fi

pDir=$kiteDir/vendor/$dir
for path in "$pDir"/*; do
pkg=$(basename "$path")

ghPkg=$pkg
if [[ "$pkg" == "console" ]]; then
ghPkg="php-$pkg"
elif [ "$pkg" == "sroute" ]; then
ghPkg="php-srouter"
fi

echo " - package: $dir/$pkg"
if [ -d "$path"/.git ]; then
echo " founded the .git dir, do update"
echo " into $path"
cd "$path"
echo " update by git pull"
git pull
else
echo " not found .git dir, do clone"
echo " goto $pDir"
cd "$pDir"
echo " remove old package dir"
rm -rf "$path"
echo " git clone $ghHost/$ghGrp/$ghPkg $pkg"
git clone "$ghHost/$ghGrp/$ghPkg" "$pkg"
fi
done
done

echo "🟢 Completed"

0 comments on commit bfee887

Please sign in to comment.