LoginSignup
16
7

More than 5 years have passed since last update.

cmdshelfによるスクリプト運用のご提案

Last updated at Posted at 2017-06-22
1 / 19

追記

  • 2017/10/28追記: swiftpmコマンドはなくなりました
  • 2018/9/3追記: cmdshelfはRustに移行しました。同時にblobコマンドは無くなりました。homebrewからインストールできます!

これまでのスクリプト運用の課題🐢

アプリのリポジトリにコミットしてしまっていて運用がつらい
- 他のプロジェクトと共有するのが面倒
- 例えばmasterにしかなくてhotfixでそのscriptが使えないという状況があり得る

どこかのOSSだったり、内製したものだったり、自分専用のものだったり、置き場所が点在している


AbemaTV iOSチームの場合

ios/tvos 共通で使い回したいスクリプトたち

  • acknowledgement_generator.swift
  • init_design.sh
  • carthage/update carthage/checkout

現状それぞれにコミットされていたりいなかったりするのを統一したい


構想🤔

  • scriptの管理場所や所有者なんて使う時にはただのノイズ
  • 必要な時に必要なスクリプトを迅速に使いたい
  • $PATHの設定とか正直面倒

そんなあなたに cmdshelf 📚


cmdshelf 📚

  • ~/.cmdshelf.yml でスクリプトの置き場所を管理
  • cmdshelf run hoge.sh でhoge.shがどこにあるか気にすることなく実行できる
  • 自分好みの .cmdshelf.yml を持ち歩ける
  • Written in Swift

.cmdshelf.yml

cmdshelf-yml.png


.cmdshelf.yml

cmdshelf-yml1.png


.cmdshelf.yml

cmdshelf-yml2.png


.cmdshelf.yml

cmdshelf-yml3.png


remoteの追加

$ cmdshelf remote add abema-ios-script https://github.com/abema/inherited-scripts-ios.git
$ cmdshelf list
remote:
  abema-ios-script:
    carthage/checkout
    carthage/update
    design/init_design.sh
    specific/abema-swift-api-session/validate-unit-test.sh
    tools/acknowledgement_generator.swift
    tools/outdated-localizables.sh
$ cmdshelf run "carthage/update APIKit"

最新のmasterがcheckoutされる
基本的にコンソールで実行可能なものならなんでもok


blobの追加

$ cmdshelf blob add random https://gist.githubusercontent.com/toshi0383/32728879049e95...
$ cmdshelf list
blob:
  random: https://gist.githubusercontent.com/toshi0383/32728879049e95db41ab801b1f05500...
$ cmdshelf run random

blobはローカルパスかhttp(s)のURLいずれかを登録可能
基本的にコンソールで実行可能なものならなんでもok


リポジトリの更新

$ cmdshelf update

remoteとswiftpmを更新


インストール


今後の展望

  • Makefile (CI) サポート

CIにcmdshelfをインストールするのに要する時間が許容範囲かどうか検証が必要
まずはzipダウンロードで入れられるように設定したいとは思っている (どうやんのかな

=> 解決済!


まとめ

  • cmdshelfでラクにスクリプトを共有
  • もう$PATHの設定に煩わされる必要なし👍

オープンソースです

イシューやプルリクなどコントリビュートお待ちしております。
https://github.com/toshi0383/cmdshelf


End

この資料は2017/06/21にチーム内で共有したものほぼそのままになります。
この時から色々と改善を実施したので詳細はリポジトリのCHANGELOGをご覧ください。
https://github.com/toshi0383/cmdshelf

16
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
7