Development Guide - hiro-nyon/cesium-heatbox GitHub Wiki
- Node.js 18.0.0 or higher
- npm 8.0.0 or higher
- Git
Target Audience: Development beginners and those new to JavaScript/Node.js library development
Purpose: Understand the development and release procedures for the cesium-heatbox project
- Development Environment Setup
- Git Basics
- About npm (Node Package Manager)
- Version Management and Tagging
- Development Workflow
- Testing and Building
- Release Process
- Troubleshooting
Required Software:
-
Node.js (Required)
node --version # v18.0.0 or higher required npm --version # v8.0.0 or higher required
-
Git (Required)
git --version
-
Visual Studio Code (Recommended)
- Recommended extensions: JavaScript snippets, ESLint, Prettier, GitLens
Project Setup:
cd /path/to/cesium-heatbox
npm install
npm run devGit is a version control system for tracking code changes and enabling collaboration. Key concepts include repositories, commits, branches, tags, and remote/local repositories.
Basic Commands:
# Check status
git status
git diff
# Record changes
git add .
git commit -m "commit message"
# Sync with remote
git pull origin main
git push origin main
# Branch operations
git branch
git checkout -b feature/new-feature
git merge feature/new-featureCommit Message Format:
<type>(<scope>): <subject>
Examples:
feat(core): add data source selection functionality
fix(renderer): resolve voxel color interpolation issue
docs: update API documentation
npm manages JavaScript packages and runs development scripts. Key concepts include package.json, dependencies, devDependencies, and scripts.
Common Commands:
# Package management
npm install package-name
npm install --save-dev package-name
npm uninstall package-name
# Script execution
npm run dev
npm run build
npm test
npm run lint
# Version management
npm version patch # 0.1.0 → 0.1.1
npm version minor # 0.1.1 → 0.2.0
npm version major # 0.2.0 → 1.0.0Daily Development Cycle:
- Morning:
git pull origin main,npm install,npm run dev - Development: Edit code,
npm test,npm run lint,npm run build - Completion:
git add .,git commit -m "message",git push origin main
Feature Development Flow:
- Specification review
- Design
- Implementation
- Testing
- Documentation
- Code review
- Commit
Testing Types:
- Unit tests: Individual function testing
- Integration tests: Component interaction testing
Test Commands:
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportBuild Commands:
npm run build # Production build
npm run build:dev # Development build
npm run build:watch # Watch modePreparation:
npm test
npm run lint
npm run buildVersion Updates:
# Alpha release
npm version 0.1.0-alpha.1 --no-git-tag-version
git add .
git commit -m "chore: bump version to 0.1.0-alpha.1"
git tag v0.1.0-alpha.1
git push origin main --tags
# Stable release
npm version 0.1.0 --no-git-tag-version
git tag v0.1.0
git push origin main --tagsNPM Publishing:
npm publish --tag alpha # Alpha release
npm publish # Stable releaseCommon Issues:
- npm install errors: Clear cache, delete node_modules, reinstall
- Test failures: Check detailed error messages, verify import paths
- Build errors: Check file paths, import statements, webpack config
- Git push errors: Pull latest changes, resolve conflicts
For detailed solutions, see the Japanese section below.
対象: 開発初心者・JavaScript/Node.jsライブラリ開発が初めての方
目的: cesium-heatboxプロジェクトの開発・リリース手順を理解する
# バージョン確認
node --version # v18.0.0以上が必要
npm --version # v8.0.0以上が必要インストール方法:
- Node.js公式サイトから最新のLTS版をダウンロード
- インストーラーを実行して指示に従う
# バージョン確認
git --versionインストール方法:
- Git公式サイトからダウンロード
- またはHomebrew:
brew install git
- VS Code公式サイトからダウンロード
- 推奨拡張機能:
- JavaScript (ES6) code snippets
- ESLint
- Prettier
- GitLens
# プロジェクトディレクトリに移動
cd /path/to/cesium-heatbox
# 依存関係のインストール
npm install
# 開発サーバーの起動テスト
npm run dev- バージョン管理システム: コードの変更履歴を記録・管理
- 協業ツール: 複数人でのコード共有・統合
- バックアップ: コードの安全な保管
# 現在の状態を確認
git status
# 変更されたファイルを確認
git diff
# コミット履歴を確認
git log --oneline# 変更をステージングエリアに追加
git add . # 全ファイル
git add src/Heatbox.js # 特定ファイル
# コミット(変更を記録)
git commit -m "機能追加: データソース選択機能を実装"
# より詳細なコミットメッセージ
git commit -m "feat: add data source selection functionality
- Add createFromDataSource method
- Add data source switching capability
- Update API documentation
- Add unit tests for new features"# リモートから最新版を取得
git pull origin main
# ローカルの変更をリモートに送信
git push origin main
# タグをプッシュ
git push origin --tags<type>(<scope>): <subject>
<body>
<footer>
feat(core): add data source selection functionality
Add methods for selecting specific data sources:
- createFromDataSource()
- switchDataSource()
- getAvailableDataSources()
This enables users to create heatmaps from specific
data sources instead of all entities in the viewer.
Closes #123
-
feat: 新機能 -
fix: バグ修正 -
docs: ドキュメント更新 -
style: フォーマット変更 -
refactor: リファクタリング -
test: テスト追加・修正 -
chore: 雑務(依存関係更新など)
- パッケージ管理システム: JavaScriptライブラリの管理
- スクリプト実行: 開発・ビルドコマンドの実行
- 公開プラットフォーム: 作成したライブラリを世界に公開
{
"name": "cesium-heatbox", // パッケージ名
"version": "0.1.0", // バージョン
"description": "3D heatmap library", // 説明
"main": "dist/cesium-heatbox.js", // メインファイル
"scripts": { // 実行可能コマンド
"dev": "webpack serve --mode development",
"build": "webpack --mode production",
"test": "jest"
},
"dependencies": {}, // 本番環境で必要なパッケージ
"devDependencies": { // 開発時のみ必要なパッケージ
"webpack": "^5.97.0",
"jest": "^30.0.0"
}
}dependencies:
- 本番環境で必要なパッケージ
- ライブラリを使用するユーザーにもインストールされる
- 例: lodash, moment
devDependencies:
- 開発時のみ必要なパッケージ
- ビルドツール、テストフレームワークなど
- 例: webpack, jest, eslint
peerDependencies:
- 使用者が別途インストールする必要があるパッケージ
- 例: cesium(このプロジェクトの場合)
# パッケージをインストール
npm install package-name
# 開発用パッケージをインストール
npm install --save-dev package-name
# グローバルにインストール
npm install -g package-name
# パッケージを削除
npm uninstall package-name
# 依存関係を確認
npm list
npm outdated # 古いパッケージを確認# package.jsonのscriptsを実行
npm run dev # 開発サーバー起動
npm run build # ビルド実行
npm test # テスト実行
npm run lint # コード品質チェック- MAJOR: 破壊的変更(既存の使い方が変わる)
- MINOR: 新機能追加(後方互換性あり)
- PATCH: バグ修正
-
1.0.0→1.0.1: バグ修正 -
1.0.1→1.1.0: 新機能追加 -
1.1.0→2.0.0: 破壊的変更
-
0.1.0-alpha.1: 開発初期版 -
0.1.0-beta.1: 機能完成版 -
0.1.0-rc.1: リリース候補版
# package.jsonのバージョンを更新
npm version patch # 0.1.0 → 0.1.1
npm version minor # 0.1.1 → 0.2.0
npm version major # 0.2.0 → 1.0.0
# プレリリース版
npm version prerelease --preid=alpha # 0.1.0-alpha.1
npm version prerelease --preid=beta # 0.1.0-beta.1
npm version prerelease --preid=rc # 0.1.0-rc.1# タグを作成
git tag v0.1.0-alpha.1
git tag -a v0.1.0 -m "Initial release"
# タグを確認
git tag -l
# タグをプッシュ
git push origin v0.1.0-alpha.1
git push origin --tags # 全タグ
# タグを削除
git tag -d v0.1.0-alpha.1 # ローカル
git push origin :v0.1.0-alpha.1 # リモート# 最新版を取得
git pull origin main
# 依存関係を更新(必要に応じて)
npm install
# 開発サーバーを起動
npm run dev# 新しいブランチを作成(オプション)
git checkout -b feature/data-source-selection
# コードを編集
# ... 開発作業 ...
# テストを実行
npm test
# リンティングを実行
npm run lint
# ビルドを確認
npm run build# 変更をコミット
git add .
git commit -m "feat: add data source selection functionality"
# リモートにプッシュ
git push origin main
# または
git push origin feature/data-source-selection- 仕様確認: specification.mdで要件を確認
- 設計: 必要なファイル・クラス・メソッドを設計
- 実装: コードを記述
- テスト: 単体テスト・統合テストを作成・実行
- ドキュメント: API.mdやREADME.mdを更新
- レビュー: コードの品質確認
- コミット: 変更を記録
# メインブランチで直接作業
git checkout main
git pull origin main
# 開発作業
git add .
git commit -m "message"
git push origin main# 機能開発用ブランチ作成
git checkout -b feature/new-feature
# 開発作業
git add .
git commit -m "message"
git push origin feature/new-feature
# 完了後、メインブランチに統合
git checkout main
git merge feature/new-feature
git push origin main
git branch -d feature/new-feature- 品質保証: バグの早期発見
- 回帰防止: 既存機能の破壊を防止
- 仕様明確化: コードの使い方を明示
- リファクタリング: 安全な改善
単体テスト(Unit Test):
// test/core/VoxelGrid.test.js
describe('VoxelGrid', () => {
test('正しいボクセル数を計算する', () => {
const bounds = { minLon: 0, maxLon: 100, minLat: 0, maxLat: 100 };
const grid = new VoxelGrid(bounds, 20);
expect(grid.numVoxelsX).toBe(5);
expect(grid.numVoxelsY).toBe(5);
});
});統合テスト(Integration Test):
// test/integration/Heatbox.integration.test.js
describe('Heatbox Integration', () => {
test('エンティティからヒートマップを作成', async () => {
const entities = generateTestEntities(viewer, bounds, 100);
const heatbox = new Heatbox(viewer);
const stats = await heatbox.createFromEntities(entities);
expect(stats.totalEntities).toBe(100);
});
});# 全テストを実行
npm test
# ウォッチモード(ファイル変更時に自動実行)
npm run test:watch
# カバレッジ(どの部分がテストされているか)
npm run test:coverage
# 特定のテストファイルのみ実行
npm test -- VoxelGrid.test.js- トランスパイル: 新しいJavaScriptを古いブラウザで動くように変換
- バンドル: 複数のファイルを1つにまとめる
- 最適化: コードサイズを削減、実行速度を向上
- 形式変換: ES Modules → UMD、CommonJS
# 開発版ビルド
npm run build:dev
# 本番版ビルド(最適化あり)
npm run build
# 特定形式のみビルド
npm run build:esm # ES Modules
npm run build:umd # UMD(ブラウザ直接読み込み用)
npm run build:types # TypeScript型定義
# 継続的ビルド(ファイル変更時に自動実行)
npm run build:watch# dist/フォルダの内容確認
ls -la dist/
# ファイルサイズ確認
du -h dist/*
# 生成されたファイル
# - cesium-heatbox.js (開発版)
# - cesium-heatbox.min.js (本番版・最適化済み)
# - cesium-heatbox.umd.js (UMD版)
# - cesium-heatbox.d.ts (TypeScript型定義)# 全テストが通ることを確認
npm test
# リンティングエラーがないことを確認
npm run lint
# ビルドが成功することを確認
npm run build
# 型チェックが通ることを確認
npm run type-check# 以下のファイルを更新
# - CHANGELOG.md: 変更内容を記録
# - README.md: 使用方法を更新
# - docs/API.md: API仕様を更新
# - package.json: バージョン情報を更新# バージョンを0.1.0-alpha.1に更新
npm version 0.1.0-alpha.1 --no-git-tag-version
# 手動でタグを作成
git add .
git commit -m "chore: bump version to 0.1.0-alpha.1"
git tag v0.1.0-alpha.1
# GitHubにプッシュ
git push origin main
git push origin v0.1.0-alpha.1# バージョンを0.1.0-beta.1に更新
npm version 0.1.0-beta.1 --no-git-tag-version
# タグを作成してプッシュ
git add .
git commit -m "chore: bump version to 0.1.0-beta.1"
git tag v0.1.0-beta.1
git push origin main
git push origin v0.1.0-beta.1# バージョンを0.1.0に更新
npm version 0.1.0 --no-git-tag-version
# タグを作成してプッシュ
git add .
git commit -m "chore: release v0.1.0"
git tag v0.1.0
git push origin main
git push origin v0.1.0# パッケージ内容を確認
npm pack --dry-run
# 公開されるファイルを確認
npm publish --dry-run# Alpha版として公開
npm publish --tag alpha
# Beta版として公開
npm publish --tag beta
# 正式版として公開
npm publish# パッケージ情報を確認
npm info cesium-heatbox
# インストールテスト
npm install cesium-heatbox@alpha
npm install cesium-heatbox@beta
npm install cesium-heatbox# Changelog
## [0.1.0-alpha.1] - 2025-07-09
### Added
- 基本的なヒートマップ機能
- エンティティ処理とボクセル変換
- HSV色補間による可視化
- バッチ描画システム
- 基本的なテストスイート
### Changed
- なし
### Deprecated
- なし
### Removed
- なし
### Fixed
- なし
### Security
- なし現象:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /path/to/package.json解決方法:
# 正しいディレクトリにいるか確認
pwd
ls -la package.json
# node_modulesとpackage-lock.jsonを削除して再インストール
rm -rf node_modules package-lock.json
npm install現象:
FAIL test/Heatbox.test.js
● Test suite failed to run解決方法:
# 詳細なエラーメッセージを確認
npm test -- --verbose
# 特定のテストファイルのみ実行
npm test -- Heatbox.test.js
# テストファイルのコードを確認
# - importパスが正しいか
# - モックが適切に設定されているか
# - 非同期処理が正しく待機されているか現象:
ERROR in ./src/index.js
Module not found: Error: Can't resolve './Heatbox'解決方法:
# ファイルパスを確認
ls -la src/
# import文を確認
grep -r "import.*Heatbox" src/
# webpack設定を確認
cat webpack.config.js現象:
error: failed to push some refs to 'origin'解決方法:
# リモートの最新版を取得
git pull origin main
# コンフリクトがある場合は解決
git status
# コンフリクトファイルを編集
git add .
git commit -m "resolve conflicts"
# 再度プッシュ
git push origin main現象:
fatal: tag 'v0.1.0' already exists解決方法:
# 既存のタグを削除
git tag -d v0.1.0
# リモートのタグも削除
git push origin :v0.1.0
# 新しいタグを作成
git tag v0.1.0
git push origin v0.1.0# 1. 依存関係をクリア
rm -rf node_modules package-lock.json
# 2. ビルド成果物をクリア
rm -rf dist coverage
# 3. 依存関係を再インストール
npm install
# 4. 動作確認
npm test
npm run build
npm run dev- GitHub Issues: プロジェクト固有の問題
- Stack Overflow: 一般的な開発問題
- Discord/Slack: リアルタイムな質問
このガイドでは、cesium-heatboxプロジェクトの開発に必要な基本的な知識と手順を説明しました。
- 環境構築: Node.js、Git、エディタを正しく設定
- バージョン管理: セマンティックバージョニングとタグ付け
- 開発サイクル: テスト → ビルド → コミット → プッシュ
- リリース: Alpha → Beta → 正式版の段階的リリース
- トラブル対応: 問題発生時の基本的な対処法
- specification.mdでプロジェクトの全体像を理解
- 実際にコードを編集して動作確認
- テストを追加して品質向上
- 新機能の実装にチャレンジ
- コミュニティとの交流
開発は試行錯誤の連続です。エラーが発生しても慌てず、このガイドを参考に一つずつ解決していきましょう。
更新情報
- 作成日: 2025年7月9日
- 対象バージョン: cesium-heatbox v0.1.0-alpha.1
- 次回更新: 新機能追加時