有了組織,你就可以從 Hex.pm 發布和取得私有套件,而且你可以完全控制哪些使用者有權存取這些套件。要管理你所加入的任何組織,請前往 儀表板。前往 註冊表單 來建立一個組織。
組織的套件會在組織的存放庫下建立名稱空間。只有組織成員有權存取存放庫的套件,要透過 Mix 取得權限,你需要使用 mix hex.organization
任務授權組織。執行以下指令來進行
$ mix hex.organization auth acme
要執行此指令,你需要在你的機器上驗證使用者身分,執行 $ mix hex.user register
進行註冊,或 $ mix hex.user auth
使用現有使用者驗證身分。
若要將封包直接刊登至您的組織,請在命令 $ mix hex.publish --organization acme
中加入 --organization
旗標。您也可以設定封包以歸屬於特定組織,只要在封包設定中加入 organization: "acme"
選項即可
defp package() do
[
organization: "acme",
...
]
end
私人封包只能依賴其自身儲存庫中的封包,以及所有公開封包所在的全球 "hexpm"
儲存庫。您可以使用依賴項宣告中的 :organization
選項指定應從特定組織的儲存庫中擷取封包,若未包含此選項,則假設封包屬於全球儲存庫。例如
defp deps() do
[
# This package will be fetched from the global repository
{:ecto, "~> 2.0"},
# This package will be fetched from the acme organization's repository
{:secret, "~> 1.0", organization: "acme"},
]
end
您可以使用 mix hex.organization key
任務手動產生儲存庫驗證金鑰。此金鑰可用於在您的 CI 伺服器上擷取封包,而無需使用使用者名稱和密碼進行手動驗證。
在您的本地電腦上執行下列命令
$ mix hex.organization key acme generate
Passphrase: ...
126d49fb3014bd26457471ebae97c625
您也可以在您組織的 儀表板 上產生組織金鑰。
複製回傳的雜湊,並在您的建置伺服器上使用它來進行驗證
$ mix hex.organization auth acme --key 126d49fb3014bd26457471ebae97c625