bulltrackers-module 1.0.245 → 1.0.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,34 +10,44 @@ const { normalizeName, getExpectedDateStrings, DEFINITIVE_EARLIEST_DATES } = req
10
10
  const { checkRootDataAvailability } = require('../data/AvailabilityChecker');
11
11
  const { FieldValue } = require('@google-cloud/firestore');
12
12
  const pLimit = require('p-limit');
13
-
14
- // Attempt to load package.json to get version. Path depends on where this is invoked.
15
- let packageVersion = '1.0.301'; // Bumped version to reflect logic change
16
-
13
+ const path = require('path');
14
+ const packageJson = require(path.join(__dirname, '..', '..', 'package.json'));
15
+ const packageVersion = packageJson.version;
17
16
 
18
17
  /**
19
18
  * AUTO-RUN ENTRY POINT
20
19
  * Checks if a report for the current version exists. If not, runs it.
21
- * Designed to be called "Fire-and-Forget" at system init.
22
20
  */
23
21
  async function ensureBuildReport(config, dependencies, manifest) {
24
22
  const { db, logger } = dependencies;
25
- const buildId = `v${packageVersion}`;
26
- const reportRef = db.collection('computation_build_records').doc(buildId);
23
+ const now = new Date();
24
+
25
+ // BuildId still includes timestamp for uniqueness
26
+ const buildId = `v${packageVersion}_${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}_${String(now.getHours()).padStart(2,'0')}-${String(now.getMinutes()).padStart(2,'0')}-${String(now.getSeconds()).padStart(2,'0')}`;
27
+
28
+ // Reference to "latest" doc
29
+ const latestRef = db.collection('computation_build_records').doc('latest');
27
30
 
28
31
  try {
29
- const doc = await reportRef.get();
30
- if (doc.exists) {
31
- logger.log('INFO', `[BuildReporter] ✅ Pre-flight check for ${buildId} already exists. Skipping.`);
32
+ const latestDoc = await latestRef.get();
33
+ const priorVersion = latestDoc.exists ? latestDoc.data().packageVersion : null;
34
+
35
+ if (priorVersion === packageVersion) {
36
+ logger.log('INFO', `[BuildReporter] ✅ Version ${packageVersion} already has a report. Skipping.`);
32
37
  return;
33
38
  }
34
-
35
- logger.log('INFO', `[BuildReporter] 🚀 New Version Detected (${buildId}). Auto-running Pre-flight Report...`);
36
- // We do NOT await this in the main thread if called during init,
37
- // but here we are in an async function so we proceed.
38
- // Defaulting to 90 days for the auto-run to capture full historical impact
39
+
40
+ logger.log('INFO', `[BuildReporter] 🚀 New Version Detected (${packageVersion}). Auto-running Pre-flight Report...`);
41
+
39
42
  await generateBuildReport(config, dependencies, manifest, 90, buildId);
40
-
43
+
44
+ // Update "latest" pointer
45
+ await latestRef.set({
46
+ packageVersion,
47
+ buildId,
48
+ generatedAt: now.toISOString()
49
+ });
50
+
41
51
  } catch (e) {
42
52
  logger.log('ERROR', `[BuildReporter] Auto-run check failed: ${e.message}`);
43
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.245",
3
+ "version": "1.0.247",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [