@rn-iso/metro 1.3.2 → 1.4.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
@@ -39,7 +39,7 @@ only the entries nothing has touched, not the whole cache.
39
39
  rn-iso is an optional peer. Without it the cache works exactly the same; it is
40
40
  just invisible to housekeeping.
41
41
 
42
- `RN_ISO_METRO_CACHE` overrides the location.
42
+ The location can be overridden by `RN_ISO_METRO_CACHE`, or machine-wide by `caches.metroCache` in `~/.rn-iso/config.json` (an absolute path; the env var wins). The CLI and this package resolve both identically, so they always share one store.
43
43
 
44
44
  ## The NDJSON log reporter
45
45
 
package/dist/index.js CHANGED
@@ -23,56 +23,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_fs = require("node:fs");
25
25
  node_fs = __toESM(node_fs);
26
- let node_os = require("node:os");
27
- node_os = __toESM(node_os);
28
26
  let node_path = require("node:path");
29
27
  node_path = __toESM(node_path);
28
+ let _rn_iso_core = require("@rn-iso/core");
30
29
  //#region index.ts
31
- function configDir() {
32
- return process.env.RN_ISO_HOME || node_path.default.join(node_os.default.homedir(), ".rn-iso");
33
- }
34
- function cacheNameSegment(name) {
35
- return String(name).replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^\.+/, "") || "app";
36
- }
37
30
  function cacheRoot(name) {
38
- if (process.env.RN_ISO_METRO_CACHE) return process.env.RN_ISO_METRO_CACHE;
39
- const root = node_path.default.join(configDir(), "metro-cache");
40
- return name === void 0 || name === null || name === "" ? root : node_path.default.join(root, cacheNameSegment(name));
41
- }
42
- function registerCache({ dir, name, prune, note, entriesDepth }) {
43
- try {
44
- const home = configDir();
45
- const file = node_path.default.join(home, "caches.json");
46
- let manifest = {
47
- version: 1,
48
- caches: []
49
- };
50
- try {
51
- const parsed = JSON.parse(node_fs.default.readFileSync(file, "utf-8"));
52
- if (Array.isArray(parsed?.caches)) manifest = {
53
- version: 1,
54
- caches: parsed.caches
55
- };
56
- } catch {}
57
- const others = manifest.caches.filter((c) => c.dir !== dir);
58
- const record = {
59
- dir,
60
- name,
61
- prune,
62
- note,
63
- registeredBy: process.cwd()
64
- };
65
- if (entriesDepth) record.entriesDepth = entriesDepth;
66
- others.push(record);
67
- node_fs.default.mkdirSync(home, { recursive: true });
68
- node_fs.default.writeFileSync(file, JSON.stringify({
69
- version: 1,
70
- caches: others
71
- }, null, 2));
72
- } catch {}
31
+ return (0, _rn_iso_core.metroCacheRoot)(name);
73
32
  }
74
33
  function registerOnce(dir) {
75
- registerCache({
34
+ (0, _rn_iso_core.registerCache)({
76
35
  dir,
77
36
  name: "Metro transform cache",
78
37
  prune: "entries",
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@rn-iso/metro",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Metro integration for rn-iso: one transform cache shared by every worktree, plus an NDJSON reporter for structured logs.",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/appandflow/rn-iso.git",
9
+ "directory": "packages/metro"
10
+ },
6
11
  "files": [
7
12
  "dist",
8
13
  "README.md",
@@ -21,6 +26,9 @@
21
26
  "test": "node --test test/*.test.js",
22
27
  "build": "tsdown"
23
28
  },
29
+ "dependencies": {
30
+ "@rn-iso/core": "^1.4.0"
31
+ },
24
32
  "peerDependencies": {
25
33
  "metro-cache": "*"
26
34
  },