320 lines
9.1 KiB
Python
320 lines
9.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
AI Moji Packager
|
|
生成されたフォント・CSSファイルをnpmパッケージとして配布準備
|
|
"""
|
|
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
from typing import Dict
|
|
from datetime import datetime
|
|
|
|
class AIMojiPackager:
|
|
def __init__(self, output_dir: str = "../../dist"):
|
|
self.output_dir = Path(output_dir)
|
|
self.metadata_file = self.output_dir / "metadata.json"
|
|
|
|
def load_metadata(self) -> Dict:
|
|
"""メタデータファイルを読み込み"""
|
|
if not self.metadata_file.exists():
|
|
raise FileNotFoundError(f"メタデータファイルが見つかりません: {self.metadata_file}")
|
|
|
|
with open(self.metadata_file, 'r', encoding='utf-8') as f:
|
|
return json.load(f)
|
|
|
|
def generate_package_json(self, metadata: Dict) -> str:
|
|
"""package.json生成"""
|
|
package_data = {
|
|
"name": "aimoji",
|
|
"version": metadata["version"],
|
|
"description": "AI Moji文字システム - アイコンフォントパッケージ",
|
|
"main": "css/aimoji.css",
|
|
"style": "css/aimoji.css",
|
|
"sass": "scss/_variables.scss",
|
|
"keywords": [
|
|
"icons",
|
|
"font",
|
|
"css",
|
|
"ai-moji",
|
|
"webfont",
|
|
"katakamuna",
|
|
"japanese"
|
|
],
|
|
"homepage": "https://github.com/syui/ai",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/syui/ai.git"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/syui/ai/issues"
|
|
},
|
|
"author": "syui",
|
|
"license": "MIT",
|
|
"files": [
|
|
"fonts/*",
|
|
"css/*",
|
|
"scss/*",
|
|
"README.md",
|
|
"metadata.json"
|
|
],
|
|
"engines": {
|
|
"node": ">=12"
|
|
},
|
|
"scripts": {
|
|
"build": "echo 'AI Moji Icons are pre-built'",
|
|
"test": "echo 'No tests specified'"
|
|
},
|
|
"devDependencies": {},
|
|
"dependencies": {}
|
|
}
|
|
|
|
package_file = self.output_dir / "package.json"
|
|
with open(package_file, 'w', encoding='utf-8') as f:
|
|
json.dump(package_data, f, indent=2, ensure_ascii=False)
|
|
|
|
return str(package_file)
|
|
|
|
def generate_readme(self, metadata: Dict) -> str:
|
|
"""README.md生成"""
|
|
readme_content = f"""# AI Moji Icons
|
|
|
|
AI Moji文字システムのアイコンフォントパッケージです。
|
|
アルファベット、カタカムナ、数字の組み合わせによる独自の文字システムをWebフォントとして提供します。
|
|
|
|
## インストール
|
|
|
|
```bash
|
|
npm install aimoji
|
|
```
|
|
|
|
## 使用方法
|
|
|
|
### CSS
|
|
|
|
```html
|
|
<link rel="stylesheet" href="node_modules/aimoji/css/aimoji.css">
|
|
```
|
|
|
|
### HTML
|
|
|
|
```html
|
|
<i class="aimoji aimoji-ai"></i>
|
|
<i class="aimoji aimoji-game"></i>
|
|
<i class="aimoji aimoji-card"></i>
|
|
```
|
|
|
|
### SCSS
|
|
|
|
```scss
|
|
@import "node_modules/aimoji/scss/variables";
|
|
@import "node_modules/aimoji/scss/mixins";
|
|
|
|
.my-icon {{
|
|
@include aimoji-icon($aimoji-ai);
|
|
@include aimoji-size(24px);
|
|
}}
|
|
```
|
|
|
|
## アイコン一覧
|
|
|
|
総アイコン数: **{metadata["total_icons"]}**
|
|
|
|
| アイコン名 | CSS クラス | Unicode |
|
|
|-----------|-----------|---------|
|
|
"""
|
|
|
|
# アイコン一覧テーブル生成
|
|
for icon in metadata["icons"]:
|
|
readme_content += f"| {icon['name']} | `.{icon['css_class']}` | `{icon['unicode']}` |\n"
|
|
|
|
readme_content += f"""
|
|
|
|
## SCSS Mixins
|
|
|
|
### 基本的な使用方法
|
|
|
|
```scss
|
|
// アイコンの基本スタイル
|
|
.icon {{
|
|
@include aimoji-base();
|
|
}}
|
|
|
|
// 特定のアイコンを表示
|
|
.ai-icon {{
|
|
@include aimoji-icon($aimoji-ai);
|
|
}}
|
|
|
|
// サイズ指定
|
|
.large-icon {{
|
|
@include aimoji-size(32px);
|
|
}}
|
|
```
|
|
|
|
### アニメーション
|
|
|
|
```scss
|
|
// 回転アニメーション
|
|
.spinning-icon {{
|
|
@include aimoji-spin();
|
|
}}
|
|
|
|
// パルスアニメーション
|
|
.pulsing-icon {{
|
|
@include aimoji-pulse();
|
|
}}
|
|
|
|
// 手動回転
|
|
.rotated-icon {{
|
|
@include aimoji-rotate(45);
|
|
}}
|
|
|
|
// 反転
|
|
.flipped-icon {{
|
|
@include aimoji-flip-horizontal();
|
|
}}
|
|
```
|
|
|
|
## ビルド情報
|
|
|
|
- **バージョン**: {metadata["version"]}
|
|
- **フォントファミリー**: {metadata["font_family"]}
|
|
- **Unicode範囲**: {metadata["build_info"]["unicode_range"]}
|
|
- **生成日時**: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
|
|
- **ジェネレーター**: {metadata["build_info"]["generator"]}
|
|
|
|
## ライセンス
|
|
|
|
MIT License
|
|
|
|
## 開発者
|
|
|
|
- **作者**: syui
|
|
- **リポジトリ**: https://github.com/syui/ai
|
|
- **プロジェクト**: AI Moji文字システム
|
|
|
|
## 哲学
|
|
|
|
AI Mojiは「存在子理論」に基づく文字システムです。
|
|
現実の個人の唯一性をデジタル世界で担保し、現実とゲームの循環的影響を実現します。
|
|
|
|
詳細は[エコシステム統合設計書](https://github.com/syui/ai/blob/main/CLAUDE.md)をご覧ください。
|
|
"""
|
|
|
|
readme_file = self.output_dir / "README.md"
|
|
with open(readme_file, 'w', encoding='utf-8') as f:
|
|
f.write(readme_content)
|
|
|
|
return str(readme_file)
|
|
|
|
def generate_license(self) -> str:
|
|
"""LICENSE生成"""
|
|
license_content = f"""MIT License
|
|
|
|
Copyright (c) {datetime.now().year} syui
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
"""
|
|
|
|
license_file = self.output_dir / "LICENSE"
|
|
with open(license_file, 'w', encoding='utf-8') as f:
|
|
f.write(license_content)
|
|
|
|
return str(license_file)
|
|
|
|
def validate_package(self) -> bool:
|
|
"""パッケージの完全性チェック"""
|
|
required_files = [
|
|
"package.json",
|
|
"README.md",
|
|
"LICENSE",
|
|
"metadata.json",
|
|
"css/aimoji.css",
|
|
"css/aimoji.min.css",
|
|
"scss/_variables.scss",
|
|
"scss/_mixins.scss",
|
|
"fonts"
|
|
]
|
|
|
|
missing_files = []
|
|
for file_path in required_files:
|
|
full_path = self.output_dir / file_path
|
|
if not full_path.exists():
|
|
missing_files.append(file_path)
|
|
|
|
if missing_files:
|
|
print(f"⚠️ 以下のファイルが不足しています: {', '.join(missing_files)}")
|
|
return False
|
|
|
|
print("✅ パッケージの完全性チェック: 問題なし")
|
|
return True
|
|
|
|
def package_all(self) -> Dict:
|
|
"""全パッケージファイル生成"""
|
|
print("📦 パッケージング開始...")
|
|
|
|
# メタデータ読み込み
|
|
metadata = self.load_metadata()
|
|
|
|
# package.json生成
|
|
package_file = self.generate_package_json(metadata)
|
|
print(f"✅ package.json生成完了: {package_file}")
|
|
|
|
# README.md生成
|
|
readme_file = self.generate_readme(metadata)
|
|
print(f"✅ README.md生成完了: {readme_file}")
|
|
|
|
# LICENSE生成
|
|
license_file = self.generate_license()
|
|
print(f"✅ LICENSE生成完了: {license_file}")
|
|
|
|
# パッケージ検証
|
|
is_valid = self.validate_package()
|
|
|
|
return {
|
|
"package_file": package_file,
|
|
"readme_file": readme_file,
|
|
"license_file": license_file,
|
|
"is_valid": is_valid,
|
|
"output_dir": str(self.output_dir)
|
|
}
|
|
|
|
def main():
|
|
"""メイン実行関数"""
|
|
try:
|
|
packager = AIMojiPackager()
|
|
result = packager.package_all()
|
|
|
|
print("\n📦 パッケージング完了!")
|
|
print(f"📁 出力ディレクトリ: {result['output_dir']}")
|
|
|
|
if result["is_valid"]:
|
|
print("🚀 npmパッケージとして公開準備完了!")
|
|
print(" npm publish コマンドで公開できます")
|
|
else:
|
|
print("⚠️ パッケージに問題があります")
|
|
|
|
except Exception as e:
|
|
print(f"❌ エラーが発生しました: {e}")
|
|
return 1
|
|
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
exit(main()) |