-
Notifications
You must be signed in to change notification settings - Fork 0
/
asd.rb
50 lines (42 loc) · 1.48 KB
/
asd.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Asd < Formula
desc "Reads ALPS documents and produces a full state diagram and hyperlinked documentation."
homepage "https://alps-asd.github.io/"
url "https://github.com/alps-asd/app-state-diagram/releases/download/0.11.8/asd.phar"
sha256 "6a612835407edaa65dea0b0d983409c67cfcfb367bbb9fb81765e60c6375e824"
license "MIT"
depends_on "[email protected]"
depends_on "composer" => :build
depends_on "node"
def install
# PHARファイルをlibexecにインストール
libexec.install "asd.phar"
# PHARファイルを解凍
system "php -r \"(new Phar('#{libexec}/asd.phar'))->extractTo('#{libexec}');\""
# npm install の実行
system "npm", "install", "--prefix", "#{libexec}/asd-sync"
# 必要なファイルに実行権限を付与し、shebangを追加
bin_asd = "#{libexec}/bin/asd"
chmod 0755, bin_asd
File.open(bin_asd, 'r+') do |file|
content = file.read
file.seek(0)
file.write("#!/usr/bin/env php\n" + content)
end
# npmプロジェクト実行スクリプトの作成
(bin/"asdw").write <<~EOS
#!/bin/bash
cd "#{libexec}/asd-sync" && npm start -- --profile "$@"
EOS
(bin/"asdw").chmod 0755
# asd.phar 実行スクリプトの作成
(bin/"asd").write <<~EOS
#!/bin/bash
php "#{libexec}/asd.phar" "$@"
EOS
(bin/"asd").chmod 0755
end
test do
system "#{bin}/asdw"
system "#{bin}/asd"
end
end