Skip to content

Conversation

@DysektAI
Copy link
Member

@DysektAI DysektAI commented Nov 7, 2025

Summary

New developer tooling to improve local development workflows with zero production impact.

Part of splitting PR #111 into focused, reviewable pieces.

Changes

New Scripts:

  • scripts/emulator-wrapper.js - Wrapper for Firebase emulator management with better lifecycle handling
  • scripts/update-maps-from-tarkovdev.js - Automated map metadata sync from Tarkov.dev API
  • scripts/SCRIPTS.md - Documentation updates for script usage

Impact

Benefits

  1. Emulator Wrapper: Simplifies Firebase emulator startup/shutdown
  2. Map Sync Script: Automates keeping map data in sync with Tarkov.dev
  3. Documentation: Clear guidance on script usage

Testing

These scripts are for local development only and don't affect production:

  • Emulator wrapper can be tested with node scripts/emulator-wrapper.js
  • Map sync can be tested with node scripts/update-maps-from-tarkovdev.js

New developer tooling to improve workflows:

**New Scripts:**
- emulator-wrapper.js - Wrapper for Firebase emulator management
- update-maps-from-tarkovdev.js - Automated map metadata sync from Tarkov.dev
- SCRIPTS.md documentation updates

These scripts improve developer experience and automation
without affecting production application code.

Part of PR #111 split strategy - subset #4 (scripts/tooling).
Related: #111, #133
Copilot AI review requested due to automatic review settings November 7, 2025 04:25
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Documentation update simplifies scripts/SCRIPTS.md lint section description. Two new utility scripts added: emulator-wrapper.js wraps Firebase emulators with signal handling and debug log cleanup; update-maps-from-tarkovdev.js fetches maps from tarkov.dev with retry logic, converts schema, and preserves existing rotation/bounds data.

Changes

Cohort / File(s) Summary
Documentation
scripts/SCRIPTS.md
Updated lint section to remove references to lint-all.mjs and markdownlint, simplifying description to focus on ESLint and generic code quality. Minor formatting adjustments to line wraps and punctuation.
Firebase Emulator Wrapper
scripts/emulator-wrapper.js
New script that wraps firebase emulators:start with signal handlers (SIGINT, SIGTERM) to trigger cleanup routine. Deletes debug log files (firebase-debug.log, firebase-debug.*.log, database-debug.log, firestore-debug.log, pubsub-debug.log) using glob patterns before exiting. Includes logging for startup, shutdown, and errors.
Maps Data Synchronization
scripts/update-maps-from-tarkovdev.js
New script that fetches maps from tarkov.dev with exponential backoff retry logic, converts raw data to internal schema via convertToOurFormat, preserves coordinateRotation and bounds from existing maps.json, handles special cases for Factory and Labs, and writes prettified output. Includes robust error handling and logging.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EmulatorWrapper as emulator-wrapper.js
    participant Firebase as Firebase Emulator
    participant OS as OS Signals
    
    User->>EmulatorWrapper: Run script
    EmulatorWrapper->>EmulatorWrapper: Setup signal handlers (SIGINT, SIGTERM)
    EmulatorWrapper->>Firebase: Spawn emulators:start
    Firebase->>Firebase: Running...
    OS->>EmulatorWrapper: Signal received
    EmulatorWrapper->>EmulatorWrapper: Cleanup: Delete debug logs
    EmulatorWrapper->>Firebase: Exit
    EmulatorWrapper->>User: Exit with status
Loading
sequenceDiagram
    participant Script as update-maps-from-tarkovdev.js
    participant FileSystem as File System
    participant TarkovDev as tarkov.dev API
    
    Script->>FileSystem: Read existing maps.json
    Script->>TarkovDev: Fetch maps (with retry & backoff)
    alt Fetch Success
        TarkovDev-->>Script: Raw maps data
        Script->>Script: Convert to internal schema
        Script->>Script: Preserve rotation & bounds
        Script->>Script: Handle Factory/Labs special cases
        Script->>FileSystem: Write converted maps.json
        Script->>Script: Log results
    else Fetch Failure
        TarkovDev-->>Script: Error
        Script->>Script: Retry with backoff (up to limit)
        Script->>Script: Log error & exit
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • scripts/update-maps-from-tarkovdev.js requires close attention to: retry/backoff logic correctness, schema conversion and data preservation rules (especially Factory/Labs special cases), and preservation of existing rotation/bounds values
  • scripts/emulator-wrapper.js requires verification of: signal handler setup completeness, glob pattern correctness for debug log deletion, and proper error propagation
  • scripts/SCRIPTS.md is straightforward documentation and requires minimal review

Suggested labels

type:documentation, type:enhancement

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding new development scripts and tooling, which aligns with the three new files introduced (emulator-wrapper.js, update-maps-from-tarkovdev.js, and SCRIPTS.md).
Description check ✅ Passed The description is comprehensive and directly related to the changeset, providing clear context about the new scripts, their purposes, impact assessment, and testing guidance for the development tooling additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

@DysektAI

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces two new utility scripts for development workflow automation and updates the scripts documentation to reflect recent changes.

  • New script to sync/update map data from tarkov.dev API as fallback data
  • New wrapper script to automatically clean up Firebase emulator debug logs
  • Updated documentation to accurately describe the lint script behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
scripts/update-maps-from-tarkovdev.js Implements a robust map synchronization script that fetches map data from tarkov.dev with retry logic and transforms it to the application's format while preserving critical coordinate system configurations
scripts/emulator-wrapper.js Provides automatic cleanup of Firebase debug logs when emulators shut down, with proper signal handling for graceful termination
scripts/SCRIPTS.md Updates documentation to accurately reflect that the lint script only runs ESLint, removing outdated references to additional checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +11
* Run: npm run maps:sync
* Or: node scripts/update-maps-from-tarkovdev.js
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation references 'npm run maps:sync' but this script is not defined in package.json. Either add the script to package.json or update the documentation to only reference 'node scripts/update-maps-from-tarkovdev.js'.

Suggested change
* Run: npm run maps:sync
* Or: node scripts/update-maps-from-tarkovdev.js
* Run: node scripts/update-maps-from-tarkovdev.js

Copilot uses AI. Check for mistakes.
Comment on lines 76 to 78
/**
* Fetch tarkov.dev maps.json with robust retry logic
*/
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc comment on lines 76-78 describes 'Fetch tarkov.dev maps.json with robust retry logic' but is placed above the NAME_MAPPING constant, not a fetch function. This comment should either be moved to line 96 above fetchTarkovDevMaps() or updated to describe NAME_MAPPING.

Suggested change
/**
* Fetch tarkov.dev maps.json with robust retry logic
*/

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +96
/**
* Fetch tarkov.dev maps.json with robust retry logic
*/
async function fetchTarkovDevMaps() {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate JSDoc comment. The same comment 'Fetch tarkov.dev maps.json with robust retry logic' appears on both line 76-78 and line 93-95. Remove the one at line 76-78.

Copilot uses AI. Check for mistakes.
Comment on lines 48 to 54
await cleanup();
process.exit(0);
});

process.on('SIGTERM', async () => {
console.log('\n📴 Received SIGTERM, shutting down...');
await cleanup();
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signal handlers use async functions but process.exit(0) is called immediately after await cleanup(). If the emulatorProcess is still running when a signal is received, it won't be terminated. Consider calling emulatorProcess.kill() before process.exit() to ensure proper cleanup of the child process.

Suggested change
await cleanup();
process.exit(0);
});
process.on('SIGTERM', async () => {
console.log('\n📴 Received SIGTERM, shutting down...');
await cleanup();
await cleanup();
if (emulatorProcess && emulatorProcess.kill) {
emulatorProcess.kill();
}
process.exit(0);
});
process.on('SIGTERM', async () => {
console.log('\n📴 Received SIGTERM, shutting down...');
await cleanup();
if (emulatorProcess && emulatorProcess.kill) {
emulatorProcess.kill();
}

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

**Automatic Cleanup:** All emulator scripts now use an intelligent wrapper that
automatically cleans up Firebase debug logs when emulators shut down
(including SIGINT/SIGTERM signals).

P1 Badge Emulator wrapper never wired into npm scripts

The documentation now claims “All emulator scripts now use an intelligent wrapper” but none of the npm scripts were updated to execute scripts/emulator-wrapper.jspackage.json still calls firebase emulators:start directly. As a result the new cleanup logic never runs and the debug logs remain, while developers are led to believe the wrapper is active. Either update the npm scripts to invoke the wrapper or adjust the docs to avoid the false promise.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +10 to +13
import { spawn } from 'child_process';
import { rm } from 'fs/promises';
import { glob } from 'glob';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Declare glob dependency for emulator cleanup script

The new emulator wrapper imports glob but the repository does not list glob anywhere in its dependencies. On a clean install (npm install --omit=dev or after dependency pruning) running node scripts/emulator-wrapper.js will fail immediately with Cannot find package 'glob'… instead of starting the emulators, so the wrapper cannot be used reliably. Please add glob to devDependencies (or swap to an existing utility) before relying on this script.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai bot added type:documentation Type label for PR's ONLY use "Types" instead for Issues. type:enhancement labels Nov 7, 2025
coderabbitai[bot]

This comment was marked as resolved.

**P1 Critical - Add Missing Dependency:**
- Add 'glob' to devDependencies (required by emulator-wrapper.js)
- Add 'maps:sync' npm script for convenience

**Emulator Wrapper Fixes:**
- Fix signal handlers to kill child process before exit
- Fix exit code propagation for signal terminations
- Prevent masking failures when process killed by signal

**Documentation Fixes:**
- Remove duplicate JSDoc comment for fetchTarkovDevMaps()
- Move NAME_MAPPING JSDoc to correct location
- Remove orphaned comment fragment

Addresses all feedback from Copilot AI, CodeRabbit AI, and chatgpt-codex-connector.
Copilot AI review requested due to automatic review settings November 7, 2025 05:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (typeof code === 'number') {
process.exit(code);
}
// Signal or unknown termination – propagate as failure
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use an em dash (—) instead of en dash (–) for better punctuation consistency, or use two hyphens (--) which is more common in code comments.

Suggested change
// Signal or unknown termination propagate as failure
// Signal or unknown termination -- propagate as failure

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +160
if (ourKey === 'factory') {
floors.push('Basement', 'Ground_Floor', 'Second_Floor', 'Third_Floor');
} else {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Factory floor names are hardcoded here. If the floor structure changes in the source data from tarkov.dev, this hardcoded list could become stale. Consider adding a comment explaining why Factory requires special handling and under what conditions this hardcoded list should be updated.

Suggested change
if (ourKey === 'factory') {
floors.push('Basement', 'Ground_Floor', 'Second_Floor', 'Third_Floor');
} else {
// NOTE: The Factory floor names are hardcoded here because the source data from tarkov.dev
// may be inconsistent or not provide the desired order. If the floor structure, names, or order
// for Factory change in tarkov.dev, this list MUST be updated to match. See CodeQL rule for details.
if (ourKey === 'factory') {
floors.push('Basement', 'Ground_Floor', 'Second_Floor', 'Third_Floor');

Copilot uses AI. Check for mistakes.
Comment on lines +4 to 6
> **Purpose**: Documents all npm scripts and development workflows for the
> TarkovTracker monorepo
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The line break in the middle of the Purpose description appears unnecessary and reduces readability. Consider keeping it on a single line like it was originally, unless there's a specific markdown formatting requirement.

Suggested change
> **Purpose**: Documents all npm scripts and development workflows for the
> TarkovTracker monorepo
> **Purpose**: Documents all npm scripts and development workflows for the TarkovTracker monorepo

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +9
Scripts are
organized to avoid confusion and provide clear entry points from the root.
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The line break between 'Scripts are' and 'organized' appears arbitrary and reduces readability. Consider keeping this sentence on a single line like it was originally.

Suggested change
Scripts are
organized to avoid confusion and provide clear entry points from the root.
Scripts are organized to avoid confusion and provide clear entry points from the root.

Copilot uses AI. Check for mistakes.
@DysektAI DysektAI removed type:documentation Type label for PR's ONLY use "Types" instead for Issues. type:enhancement labels Nov 30, 2025
@DysektAI DysektAI marked this pull request as draft November 30, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants