モジュールの公開
モジュールの公開
Section titled “モジュールの公開”再利用可能なコードを Wippy Hub で共有します。
- hub.wippy.ai でアカウントを作成する
- 組織を作成するか、既存の組織に参加する
- 組織内でモジュール名を登録する
モジュール構造
Section titled “モジュール構造”mymodule/├── wippy.yaml # モジュールマニフェスト├── src/│ ├── _index.yaml # エントリ定義│ └── *.lua # ソースファイル└── README.md # ドキュメント(任意)wippy.yaml
Section titled “wippy.yaml”モジュールマニフェスト:
organization: acmemodule: http-utilsdescription: HTTP utilities and helperslicense: MITrepository: https://github.com/acme/http-utilshomepage: https://acme.devkeywords: - http - utilities| フィールド | 必須 | 説明 |
|---|---|---|
organization | はい | Hub 上の組織名 |
module | はい | モジュール名 |
description | いいえ | 短い説明 |
license | いいえ | SPDX 識別子(MIT、Apache-2.0) |
repository | いいえ | ソースリポジトリ URL |
homepage | いいえ | プロジェクトホームページ |
keywords | いいえ | 検索キーワード |
エントリ定義
Section titled “エントリ定義”エントリは _index.yaml で定義します:
version: "1.0"namespace: acme.http
entries: - name: definition kind: ns.definition meta: title: HTTP Utilities description: Helpers for HTTP operations
- name: client kind: library.lua source: file://client.lua modules: - http_client - json他のモジュールへの依存関係を宣言します:
entries: - name: __dependency.wippy.test kind: ns.dependency meta: description: Testing framework component: wippy/test version: ">=0.3.0"バージョン制約:
| 制約 | 意味 |
|---|---|
* | 任意のバージョン |
1.0.0 | 厳密なバージョン |
>=1.0.0 | 最小バージョン |
^1.0.0 | 互換性あり(同じメジャーバージョン) |
利用者が指定する必要のある設定を定義します:
entries: - name: api_endpoint kind: ns.requirement meta: description: API endpoint URL targets: - entry: acme.http:client path: ".meta.endpoint" default: "https://api.example.com"ターゲットは値が注入される場所を指定します:
entry- 設定対象のエントリ IDpath- 値を注入する JSONPath
利用者はオーバーライドで設定します。-o フラグは namespace:entry:field=value のトリプルを受け取ります:
wippy run -o acme.http:client:meta.endpoint=https://custom.api.com他のエントリを参照します:
- name: handler kind: function.lua source: file://handler.lua modules: - json imports: client: acme.http:client # 同じ名前空間 utils: acme.utils:helpers # 異なる名前空間 base_registry: :registry # 組み込みLua 内:
local client = require("client")local utils = require("utils")コントラクト
Section titled “コントラクト”公開インターフェースを定義します:
- name: http_contract kind: contract.definition meta: name: HTTP Client Contract methods: - name: get description: Perform GET request - name: post description: Perform POST request
- name: http_contract_binding kind: contract.binding contracts: - contract: acme.http:http_contract methods: get: acme.http:get_handler post: acme.http:post_handler公開ワークフロー
Section titled “公開ワークフロー”wippy auth loginwippy initwippy updatewippy lintwippy publish --dry-runwippy publish --version 1.0.0リリースノート付き:
wippy publish --version 1.0.0 --release-notes "Initial release"| フラグ | 説明 |
|---|---|
--label <name> | イミュータブルなバージョンの代わりに、可変ラベル(例:latest、beta)として公開する |
--protected | 公開バージョンを保護対象としてマークする(削除や上書きが不可になる) |
--registry <url> | この公開時のみレジストリ URL を上書きする |
--config <dir> | wippy.yaml を含むディレクトリ(デフォルト:カレントディレクトリ) |
--create | モジュールがまだ存在しない場合はハブに登録してから公開する |
--module-visibility <v> | --create 用の可視性:private(デフォルト)または public |
--module-type <t> | --create 用のタイプ:application(デフォルト)、library、agent、または plugin |
--module-display-name <n> | --create 用の表示名 |
静的ファイルの埋め込み
Section titled “静的ファイルの埋め込み”fs.directory エントリ(静的アセット、テンプレート、公開ファイル)を含むモジュールは、それらを公開パッケージに含めるために --embed を使用する必要があります。これがない場合、fs.directory エントリは除外されます。
wippy publish --version 1.0.0 --embed app:public_fileswippy publish --version 1.0.0 --embed app:assets,app:templates--embed フラグは、エントリ ID または fs.directory エントリに一致する名前を受け取ります。同じフラグは wippy pack でも利用できます。
モジュールを初めて公開すると、自動的にハブに登録され(デフォルトでは private)、公開が一度リトライされます。事前に登録してプロパティを設定するには --create を渡します。
wippy publish --create --version 0.1.0 \ --module-visibility public \ --module-type library \ --module-display-name "HTTP Utils"--create は冪等です — すでに登録済みのモジュールでは create ステップは何もしません。アカウントが組織内でモジュールを作成できない場合、ハブは公開する代わりに権限エラーを返します。
ローカルハブへの公開
Section titled “ローカルハブへの公開”--registry をローカルで動作しているハブに向けると、公開とインストールをパブリックレジストリなしで行えます。プレーン HTTP はローカルホストに対してのみ許可されます — localhost、127.0.0.1、およびコンテナエイリアスの host.docker.internal(Docker Desktop / OrbStack)と host.containers.internal(Podman)。それ以外のホストは HTTPS を使用する必要があります。
wippy auth login --registry http://localhost:8080 --token wpy_xxxwippy publish --registry http://localhost:8080 --create --version 0.1.0レジストリとトークンは、環境変数 WIPPY_REGISTRY および WIPPY_TOKEN から取得することもできます。未設定の場合、レジストリはデフォルトで https://hub.wippy.ai になります。
組織のプライベートモジュールクォータが使い切られている場合、公開は cannot publish: Private-module quota exhausted (5 of 5)... のようなメッセージで失敗します。モジュールを public にするか、組織管理者にクォータの引き上げを依頼してください。アップロードとダウンロードは、一時的なネットワークエラー時に自動でリトライされます。
公開モジュールの利用
Section titled “公開モジュールの利用”依存関係の追加
Section titled “依存関係の追加”wippy add acme/http-utilswippy add acme/http-utils@1.0.0wippy installランタイム時に値をオーバーライドします:
wippy run -o acme.http:client:meta.endpoint=https://my.api.comまたは .wippy.yaml 内:
override: acme.http:client:meta.endpoint: "https://my.api.com"コードでのインポート
Section titled “コードでのインポート”# your src/_index.yamlentries: - name: __dependency.acme.http kind: ns.dependency component: acme/http-utils version: ">=1.0.0"
- name: my_handler kind: function.lua source: file://handler.lua imports: http: acme.http:clientwippy.yaml:
organization: acmemodule: cachedescription: In-memory caching with TTLlicense: MITkeywords: - cache - memorysrc/_index.yaml:
version: "1.0"namespace: acme.cache
entries: - name: definition kind: ns.definition meta: title: Cache Module
- name: max_size kind: ns.requirement meta: description: Maximum cache entries targets: - entry: acme.cache:cache path: ".meta.max_size" default: "1000"
- name: cache kind: library.lua meta: max_size: 1000 source: file://cache.lua modules: - timesrc/cache.lua:
local time = require("time")
local cache = {}local store = {}local max_size = 1000
function cache.set(key, value, ttl) if #store >= max_size then cache.evict_oldest() end store[key] = { value = value, expires = ttl and (time.now():unix() + ttl) or nil }end
function cache.get(key) local entry = store[key] if not entry then return nil end if entry.expires and time.now():unix() > entry.expires then store[key] = nil return nil end return entry.valueend
return cache公開:
wippy init && wippy update && wippy lintwippy publish --version 1.0.0