@stim-cli/metro 1.8.0 → 1.9.0

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.
package/README.md CHANGED
@@ -17,7 +17,8 @@ const { sharedCacheStores } = require('@stim-cli/metro');
17
17
  config.cacheStores = sharedCacheStores('my-app');
18
18
  ```
19
19
 
20
- Set `STIM_METRO_CACHE` to override the shared cache location.
20
+ Set `STIM_METRO_CACHE` to an absolute path to override the shared cache location.
21
+ A relative value is ignored with a warning.
21
22
 
22
23
  ## Optional second tier
23
24
 
@@ -49,6 +50,9 @@ const { ndjsonReporter } = require('@stim-cli/metro');
49
50
  config.reporter = ndjsonReporter({ dir: '/absolute/log/directory' });
50
51
  ```
51
52
 
53
+ It writes `metro.ndjson` and `client.ndjson`. When a file reaches about 8 MiB it is
54
+ renamed to `<name>.1`, replacing the previous one, and a new file starts.
55
+
52
56
  The reporter must be attached to the config passed directly to
53
57
  `Metro.runServer`. React Native and Expo CLIs can replace a reporter declared in
54
58
  `metro.config.js`.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { cacheProviderConfigFromEnv, cacheProviderEnvIsSet, createTieredMetroStore, loadCacheProvider } from "@stim-cli/cache";
5
- import { METRO_NAMED_CACHE_LAYOUT, metroCacheRoot, registerCache, tagSharedStore, workspaceLogDir } from "@stim-cli/core";
5
+ import { LOG_ROTATE_BYTES, METRO_NAMED_CACHE_LAYOUT, metroCacheRoot, registerCache, rotateLog, tagSharedStore, workspaceLogDir } from "@stim-cli/core";
6
6
  //#region index.ts
7
7
  const requireFromHere = createRequire(import.meta.url);
8
8
  function cacheRoot(name) {
@@ -137,13 +137,24 @@ function ndjsonReporter({ dir } = {}) {
137
137
  let drops = 0;
138
138
  const builds = /* @__PURE__ */ new Map();
139
139
  let failedBuild = null;
140
+ const uncheckedBytes = /* @__PURE__ */ new Map();
140
141
  function write(file, record) {
141
142
  try {
142
143
  if (!ensured) {
143
144
  fs.mkdirSync(logDir, { recursive: true });
144
145
  ensured = true;
145
146
  }
146
- fs.appendFileSync(path.join(logDir, file), JSON.stringify(record) + "\n");
147
+ const target = path.join(logDir, file);
148
+ const line = JSON.stringify(record) + "\n";
149
+ const unchecked = uncheckedBytes.get(file);
150
+ if (unchecked === void 0 || unchecked >= LOG_ROTATE_BYTES / 8) {
151
+ uncheckedBytes.set(file, 0);
152
+ try {
153
+ rotateLog(target, LOG_ROTATE_BYTES);
154
+ } catch {}
155
+ }
156
+ fs.appendFileSync(target, line);
157
+ uncheckedBytes.set(file, (uncheckedBytes.get(file) ?? 0) + Buffer.byteLength(line));
147
158
  } catch {
148
159
  drops += 1;
149
160
  ensured = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stim-cli/metro",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Metro integration for Stim: shared transforms across worktrees and structured logs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@stim-cli/cache": "^1.8.0",
28
- "@stim-cli/core": "^1.8.0"
27
+ "@stim-cli/cache": "^1.9.0",
28
+ "@stim-cli/core": "^1.9.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "metro-cache": "*"
@@ -34,7 +34,6 @@
34
34
  "node": ">=22.12.0"
35
35
  },
36
36
  "scripts": {
37
- "test": "node --test test/*.test.js",
38
37
  "build": "tsdown"
39
38
  }
40
39
  }