placementt-core 1.400.1116 → 1.400.1117

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/watch-local.js +38 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "placementt-core",
4
4
  "author": "Placementt",
5
- "version": "1.400.1116",
5
+ "version": "1.400.1117",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
8
  "scripts": {
package/watch-local.js CHANGED
@@ -50,6 +50,43 @@ function toDevAlgoliaConfig(source) {
50
50
  return swapped;
51
51
  }
52
52
 
53
+ // Consumers linked via yalc during a dev watch session should talk to the
54
+ // local Functions emulator, not the deployed dev project - otherwise every
55
+ // backend change under test here needs re-deploying to be seen at all. The
56
+ // source never imports connectFunctionsEmulator (the call is normally left
57
+ // commented out for real builds), so this adds the import as well as
58
+ // uncommenting the call - both get undone by restore() like everything else.
59
+ function toDevFirebaseConfig(source) {
60
+ const withCredentials = source.replace(/\(credentialsProd\)/g, "(credentialsDev)");
61
+ if (withCredentials === source) {
62
+ console.error(`❌ No credentialsProd usage found in ${firebaseConfigPath} — this dev build would still point at production.`);
63
+ restore();
64
+ process.exit(1);
65
+ }
66
+
67
+ const withImport = withCredentials.replace(
68
+ "import {getFunctions} from \"firebase/functions\";",
69
+ "import {getFunctions, connectFunctionsEmulator} from \"firebase/functions\";",
70
+ );
71
+ if (withImport === withCredentials) {
72
+ console.error(`❌ Could not find the firebase/functions import in ${firebaseConfigPath} to add connectFunctionsEmulator to.`);
73
+ restore();
74
+ process.exit(1);
75
+ }
76
+
77
+ const withEmulator = withImport.replace(
78
+ "// connectFunctionsEmulator(functions, \"localhost\", 5001);",
79
+ "connectFunctionsEmulator(functions, \"localhost\", 5001);",
80
+ );
81
+ if (withEmulator === withImport) {
82
+ console.error(`❌ Could not find the commented-out connectFunctionsEmulator line in ${firebaseConfigPath}.`);
83
+ restore();
84
+ process.exit(1);
85
+ }
86
+
87
+ return withEmulator;
88
+ }
89
+
53
90
  let restored = false;
54
91
  function restore() {
55
92
  if (restored) return;
@@ -72,7 +109,7 @@ if (target === "dev") {
72
109
  console.log("🛠 Switching to DEV config for this watch session...");
73
110
  fs.writeFileSync(
74
111
  firebaseConfigPath,
75
- originalFirebaseConfig.replace(/\(credentialsProd\)/g, "(credentialsDev)"),
112
+ toDevFirebaseConfig(originalFirebaseConfig),
76
113
  );
77
114
  fs.writeFileSync(
78
115
  algoliaConfigPath,