Nyashのコード共有エコシステムを支える、シンプルで直感的なパッケージマネージャー「nypm (Nyash Package Manager)」の設計。
# 依存関係をインストール
nyash install
# 特定パッケージをインストール
nyash install awesome-math
nyash install awesome-math@1.2.0
# 開発依存として追加
nyash install --dev test-framework
# グローバルインストール
nyash install -g nyash-formatter
# パッケージを公開
nyash publish
# ドライラン(実際には公開しない)
nyash publish --dry-run
# アクセス制御付き公開
nyash publish --access public
# パッケージ初期化
nyash init
# 依存関係の更新
nyash update
nyash update awesome-math
# パッケージの削除
nyash uninstall awesome-math
# 依存関係ツリーの表示
nyash list
nyash list --depth=0
# パッケージ検索
nyash search math
# パッケージ情報表示
nyash info awesome-math
my-awesome-package/
├── nyash.toml # パッケージマニフェスト
├── src/
│ ├── index.ny # メインエントリーポイント
│ └── lib/
│ └── utils.ny
├── tests/
│ └── test_main.ny
├── docs/
│ └── README.md
├── examples/
│ └── basic_usage.ny
└── .nyashignore # 公開時の除外ファイル
[package]
name = "awesome-math"
version = "1.0.0"
description = "高度な数学計算ライブラリ"
author = "Nyash Developer <dev@example.com>"
license = "MIT"
repository = "https://github.com/user/awesome-math"
keywords = ["math", "calculation", "algebra"]
# メインエントリーポイント
main = "src/index.ny"
# 最小Nyashバージョン
nyash = ">=1.0.0"
[dependencies]
# 実行時依存
basic-utils = "^2.0.0"
string-helpers = "~1.5.0"
[dev-dependencies]
# 開発時のみ必要
test-framework = "^3.0.0"
mock-library = "^1.2.0"
[scripts]
# カスタムスクリプト
test = "nyash test tests/"
build = "nyash compile src/"
lint = "nyash-lint src/"
# 正確なバージョン
"1.2.3"
# 互換性のあるバージョン(推奨)
"^1.2.3" # >=1.2.3 <2.0.0
# 近似バージョン
"~1.2.3" # >=1.2.3 <1.3.0
# 範囲指定
">=1.0.0 <2.0.0"
# ワイルドカード
"1.2.*" # >=1.2.0 <1.3.0
project/
├── nyash.toml
├── src/
│ └── main.ny
└── nyash_modules/ # 依存パッケージ格納場所
├── awesome-math/
│ ├── nyash.toml
│ └── src/
├── string-helpers/
│ ├── nyash.toml
│ └── src/
└── .cache/ # ダウンロードキャッシュ
nyash_modules/
をチェックGET /packages/{name} # パッケージ情報取得
GET /packages/{name}/versions # バージョン一覧
GET /packages/{name}/{version} # 特定バージョン情報
POST /packages # パッケージ公開
GET /search?q={query} # パッケージ検索
{
"name": "awesome-math",
"version": "1.0.0",
"description": "高度な数学計算ライブラリ",
"author": {
"name": "Nyash Developer",
"email": "dev@example.com"
},
"repository": "https://github.com/user/awesome-math",
"downloads": {
"last_day": 150,
"last_week": 1200,
"last_month": 5000
},
"versions": ["1.0.0", "0.9.0", "0.8.0"],
"dependencies": {
"basic-utils": "^2.0.0"
},
"tarball": "https://registry.nyash.dev/awesome-math-1.0.0.tgz"
}
# nyash.toml
[package.signature]
algorithm = "ed25519"
public_key = "..."
nyash_modules/
└── awesome-math/
├── nyash.toml
└── .nyash-integrity # SHA256ハッシュ
# ルートnyash.toml
[workspace]
members = [
"packages/core",
"packages/utils",
"packages/cli"
]
# .nyashrc
[registries]
default = "https://registry.nyash.dev"
company = "https://npm.company.com"
[scopes]
"@company" = "company"
# キャッシュからインストール
nyash install --offline
# キャッシュの事前ダウンロード
nyash cache add awesome-math@1.0.0
~/.nyash/cache/
├── packages/
│ └── awesome-math-1.0.0.tgz
├── metadata/
│ └── awesome-math.json
└── index.db # SQLiteインデックス
Everything is Box - パッケージマネージャーもBoxを運ぶ