fireemu 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # fireemu
2
+
3
+ A deterministic, test-only local runtime for Firebase SDK and Functions code, written in Rust.
4
+
5
+ `fireemu` is not a faster re-implementation of the Firebase Emulator Suite. Its core is a
6
+ deterministic state machine that detects missing Firestore indexes, production limit violations
7
+ and inefficient queries locally; isolates state, events, time and Function execution per project
8
+ so parallel tests stay deterministic; runs scheduled Functions against a virtual clock and offers
9
+ `await-idle` instead of `sleep`; reproduces retries, duplicate delivery, delays and conflicts as
10
+ seeded fault injection; and never claims compatibility it cannot show -- every feature is declared
11
+ in a Capability Manifest with an explicit precision.
12
+
13
+ The real `firebase-admin`, `firebase` (Node and browser) and `firebase/firestore/lite` SDKs run
14
+ against it unchanged.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ npm install -D fireemu
20
+ npx fireemu init
21
+ npx fireemu doctor
22
+ ```
23
+
24
+ ```sh
25
+ pnpm add -D fireemu # or: pnpm dlx fireemu doctor
26
+ yarn add -D fireemu
27
+ ```
28
+
29
+ Nothing is downloaded at install time and there is no install script. `fireemu` is a small Node
30
+ launcher; the daemon for your platform arrives as an optional dependency
31
+ (`@fireemu/darwin-arm64` and friends), so npm installs exactly one binary and skips the rest.
32
+ An install that resolved from a cache or a private registry is a complete, offline installation.
33
+
34
+ ## Initialize
35
+
36
+ `npx fireemu init` creates `fireemu.json` with the recommended `strict` profile. In a terminal, its wizard explains the extra validation supplied by `strict`, the pinned official behavior selected by `firebase`, and how a referenced Firebase project configuration stays live. In CI or with redirected input it uses the strict defaults without prompting; use `--interactive` to force the wizard or `--yes`/`--no-interactive` to suppress it.
37
+
38
+ If the project already has `firebase.json`, init records it as a live `firebaseJson` reference so rules, indexes, Functions codebases and emulator ports are loaded again on every start. `--profile firebase` and `--firebase-json <file>` choose alternatives explicitly. Existing `fireemu.json` files are preserved unless `--force` is supplied, and a symbolic link is never overwritten.
39
+
40
+ ```sh
41
+ npx fireemu init --yes
42
+ npx fireemu up --config fireemu.json
43
+ ```
44
+
45
+ ## Use
46
+
47
+ ```sh
48
+ npx fireemu up --config fireemu.json
49
+ ```
50
+
51
+ `exec` is the `firebase emulators:exec` equivalent: it serves the same, runs a command with the
52
+ emulator host variables once every listener is bound, stops everything when the command exits and
53
+ exits with its status.
54
+
55
+ ```sh
56
+ npx fireemu exec --firebase-json firebase.json --project my-app --only auth,firestore,storage -- vitest run
57
+ ```
58
+
59
+ The command receives `FIRESTORE_EMULATOR_HOST`, `FIREBASE_AUTH_EMULATOR_HOST`,
60
+ `FIREBASE_STORAGE_EMULATOR_HOST` / `STORAGE_EMULATOR_HOST`, `GOOGLE_CLOUD_PROJECT` /
61
+ `GCLOUD_PROJECT`, and `FIREEMU_CONTROL_TOKEN` / `FIREEMU_CONTROL_URL` for the control API.
62
+
63
+ An Emulator UI is compiled into the binary and served at `http://127.0.0.1:4000/ui`
64
+ (`--ui-port 0` turns it off).
65
+
66
+ ## Supported platforms
67
+
68
+ | Package | OS | Arch | Built for |
69
+ | --- | --- | --- | --- |
70
+ | `@fireemu/darwin-arm64` | macOS 13+ | Apple silicon | `aarch64-apple-darwin` |
71
+ | `@fireemu/darwin-x64` | macOS 13+ | Intel | `x86_64-apple-darwin` |
72
+ | `@fireemu/linux-x64` | Linux (any libc) | x86-64 | `x86_64-unknown-linux-musl`, static |
73
+ | `@fireemu/linux-arm64` | Linux (any libc) | arm64 | `aarch64-unknown-linux-musl`, static |
74
+ | `@fireemu/win32-x64` | Windows 10+ | x86-64 | `x86_64-pc-windows-msvc` |
75
+
76
+ The Linux builds are statically linked against musl, so they run on any distribution and inside
77
+ distroless and Alpine containers.
78
+
79
+ ## Prerequisites
80
+
81
+ - **Node 20 or newer** to run the launcher, and to run a Functions codebase. Nothing else needs
82
+ Node; Firestore, Auth, Storage and the UI are served by the binary itself.
83
+ - **No Java.** Unlike the Firebase Emulator Suite, `fireemu` runs no JVM emulator.
84
+ - For `--functions <dir>`: the codebase's own `node_modules`, with `firebase-functions` v6 or v7
85
+ and `firebase-admin`. `npx fireemu doctor` prints the range the bundled runner supports.
86
+
87
+ ## Check an installation
88
+
89
+ ```sh
90
+ npx fireemu doctor
91
+ ```
92
+
93
+ It reports the version and platform of the installed binary, whether the Emulator UI is compiled
94
+ in, where the Node runner was found and which `firebase-functions` majors it instruments, the Node
95
+ version, and that no JVM is required. Anything missing comes with a remediation line, and a broken
96
+ installation exits non-zero so a setup script can gate on it. The report carries versions and paths
97
+ only -- never tokens, keys, or the contents of a configuration file.
98
+
99
+ ## Upgrade, uninstall, offline
100
+
101
+ - **Upgrade**: `npm install -D fireemu@<version>`. The launcher pins its platform packages to its
102
+ own exact version, so `fireemu@1.2.3` can only resolve `@fireemu/linux-x64@1.2.3` -- an upgrade
103
+ moves the binary and the launcher together, never one without the other.
104
+ - **Uninstall**: `npm uninstall fireemu`. Nothing is installed outside `node_modules`: no cache
105
+ directory, no global binary, no downloaded component.
106
+ - **Offline**: `npm install --offline` works once the tarballs are in the npm cache, and so does
107
+ installing from a private registry that mirrors the `fireemu` and `@fireemu` packages. Warm a
108
+ cache with `npm install` on a machine of the same platform, or vendor the tarballs with
109
+ `npm pack`.
110
+ - **A vendored or self-built binary**: set `FIREEMU_BINARY_PATH` to it and the launcher runs that
111
+ instead of resolving a platform package.
112
+ - **If the binary is missing**: the launcher says which package it looked for and what is
113
+ published. The usual cause is an install that skipped optional dependencies
114
+ (`--omit=optional`, `--no-optional`, or a lockfile built on another platform).
115
+
116
+ ## Documentation and source
117
+
118
+ <https://github.com/t-k/fireemu>
119
+
120
+ ## License
121
+
122
+ Apache-2.0
@@ -0,0 +1,81 @@
1
+ THIRD-PARTY SOFTWARE NOTICES AND LICENSES
2
+
3
+ This file lists third-party material copied into or bundled with fireemu distributions.
4
+
5
+ Firebase CLI
6
+ ------------
7
+
8
+ Source: https://github.com/firebase/firebase-tools
9
+ Version: 15.28.2
10
+ Usage: Static templates for the Auth Emulator identity-provider login widget, derived from widget_ui.js and handlers.js.
11
+
12
+ The MIT License (MIT)
13
+
14
+ Copyright (c) 2015 Firebase
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in
24
+ all copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
+ THE SOFTWARE.
33
+
34
+ Google APIs protocol definitions
35
+ --------------------------------
36
+
37
+ Source: https://github.com/googleapis/googleapis
38
+ Revision: 1f38da6aa7661cf22e17247ad33d2d566a2c356e
39
+ Usage: Firestore and Pub/Sub protocol definitions.
40
+ License: Apache License 2.0. The applicable license text is distributed in the accompanying LICENSE file. Copyright and license headers are retained in the source files.
41
+
42
+ Embedded web UI dependencies
43
+ ----------------------------
44
+
45
+ The following components are distributed under the MIT License:
46
+
47
+ @solidjs/router 1.0.0
48
+ Copyright 2020-2022 Ryan Carniato
49
+
50
+ csstype 3.2.3
51
+ Copyright 2017-2018 Fredrik Nicol
52
+
53
+ neverthrow 8.2.0
54
+ Copyright 2019 Giorgio Delgado
55
+
56
+ seroval 1.5.6
57
+ Copyright 2025 Alexis Munsayac
58
+
59
+ seroval-plugins 1.5.6
60
+ Copyright 2025 Alexis Munsayac
61
+
62
+ solid-js 1.9.15
63
+ Copyright 2016-2025 Ryan Carniato
64
+
65
+ Permission is hereby granted, free of charge, to any person obtaining a copy
66
+ of this software and associated documentation files (the "Software"), to deal
67
+ in the Software without restriction, including without limitation the rights
68
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69
+ copies of the Software, and to permit persons to whom the Software is
70
+ furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in
73
+ all copies or substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
81
+ THE SOFTWARE.
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ // The `fireemu` launcher: find the binary for this platform and become it.
3
+ //
4
+ // `fireemu` itself carries no binary. Each platform's daemon ships in its own package
5
+ // (`@fireemu/darwin-arm64` and friends), declared here as an optional dependency with an `os`
6
+ // and `cpu` of its own, so npm installs exactly one of them and skips the rest. There is no
7
+ // postinstall step and nothing is downloaded at install time: an `npm install` that resolved
8
+ // from a cache or a private registry is a complete, offline-capable installation.
9
+ //
10
+ // The supported list this prints when nothing matched is read out of the installed
11
+ // `package.json` rather than hard-coded, so it always names the platforms that were actually
12
+ // published beside this launcher.
13
+
14
+ import { spawnSync } from "node:child_process";
15
+ import { chmodSync, accessSync, constants as fsConstants, readFileSync } from "node:fs";
16
+ import { createRequire } from "node:module";
17
+ import { constants as osConstants } from "node:os";
18
+ import { dirname, join } from "node:path";
19
+ import { fileURLToPath } from "node:url";
20
+
21
+ const require = createRequire(import.meta.url);
22
+ const here = dirname(fileURLToPath(import.meta.url));
23
+
24
+ /** This launcher's own manifest: the version, and the platforms published with it. */
25
+ function manifest() {
26
+ return JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8"));
27
+ }
28
+
29
+ /** `@fireemu/<os>-<arch>` for the platform this process runs on. */
30
+ function platformPackage() {
31
+ return `@fireemu/${process.platform}-${process.arch}`;
32
+ }
33
+
34
+ /** The daemon's file name inside a platform package. */
35
+ function binaryName() {
36
+ return process.platform === "win32" ? "fireemu.exe" : "fireemu";
37
+ }
38
+
39
+ /**
40
+ * The daemon to run.
41
+ *
42
+ * `FIREEMU_BINARY_PATH` wins so a vendored, air-gapped or locally built binary can be used
43
+ * without touching `node_modules`. Otherwise the platform package is resolved through Node's
44
+ * own algorithm, which finds it wherever the package manager put it -- a flat `node_modules`,
45
+ * a pnpm store, or a workspace root.
46
+ */
47
+ function resolveBinary() {
48
+ const override = process.env.FIREEMU_BINARY_PATH;
49
+ if (override) {
50
+ return { path: override, from: "FIREEMU_BINARY_PATH" };
51
+ }
52
+ const pkg = platformPackage();
53
+ try {
54
+ const root = dirname(require.resolve(`${pkg}/package.json`));
55
+ return { path: join(root, "bin", binaryName()), from: pkg };
56
+ } catch {
57
+ return undefined;
58
+ }
59
+ }
60
+
61
+ /** The error a user can act on: what this host is, and what was published. */
62
+ function noBinaryMessage() {
63
+ const supported = Object.keys(manifest().optionalDependencies ?? {})
64
+ .toSorted()
65
+ .map((name) => ` ${name}`)
66
+ .join("\n");
67
+ const pkg = platformPackage();
68
+ return [
69
+ `fireemu has no binary for ${process.platform}-${process.arch}.`,
70
+ "",
71
+ `It looked for the package ${pkg}, which is not installed. Supported platforms:`,
72
+ supported,
73
+ "",
74
+ "If your platform is on that list, the install skipped the optional dependency. This is",
75
+ "usually one of:",
76
+ " - an install run with --no-optional, --omit=optional or --ignore-optional;",
77
+ " - a lockfile created on another platform and installed with --frozen-lockfile;",
78
+ " - a private registry or offline cache that does not mirror the @fireemu scope.",
79
+ "",
80
+ `Reinstall with optional dependencies enabled, or install ${pkg} directly.`,
81
+ "If your platform is not on that list, fireemu does not publish a binary for it yet;",
82
+ "build one from source (https://github.com/t-k/fireemu) and point",
83
+ "FIREEMU_BINARY_PATH at it.",
84
+ ].join("\n");
85
+ }
86
+
87
+ /**
88
+ * Makes sure the binary is executable.
89
+ *
90
+ * npm preserves the executable bit through a tarball, but a registry proxy, a `pnpm` store on
91
+ * a filesystem that drops modes, or an archive round-tripped through a zip can lose it. Fixing
92
+ * it here keeps the package free of an install script; a read-only installation that is
93
+ * already executable is left alone.
94
+ */
95
+ function ensureExecutable(path) {
96
+ if (process.platform === "win32") return;
97
+ try {
98
+ accessSync(path, fsConstants.X_OK);
99
+ return;
100
+ } catch {
101
+ // Fall through and try to grant it.
102
+ }
103
+ try {
104
+ chmodSync(path, 0o755);
105
+ } catch {
106
+ // A read-only install: let the spawn below report the real failure.
107
+ }
108
+ }
109
+
110
+ function main() {
111
+ const binary = resolveBinary();
112
+ if (!binary) {
113
+ process.stderr.write(`${noBinaryMessage()}\n`);
114
+ process.exit(1);
115
+ }
116
+ ensureExecutable(binary.path);
117
+ // stdio is inherited, so the daemon reads the real terminal and Ctrl-C reaches it directly:
118
+ // the launcher is in the same process group and does not need to forward anything.
119
+ const result = spawnSync(binary.path, process.argv.slice(2), {
120
+ stdio: "inherit",
121
+ windowsHide: false,
122
+ });
123
+ if (result.error) {
124
+ const reason =
125
+ result.error.code === "ENOENT"
126
+ ? `${binary.path} does not exist (from ${binary.from})`
127
+ : `${binary.path}: ${result.error.message}`;
128
+ process.stderr.write(`fireemu could not start the daemon: ${reason}\n`);
129
+ process.exit(1);
130
+ }
131
+ if (result.signal) {
132
+ // Report the death the way a shell does, so `fireemu ... ; echo $?` matches running the
133
+ // daemon directly.
134
+ const number = osConstants.signals[result.signal] ?? 0;
135
+ process.exit(128 + number);
136
+ }
137
+ process.exit(result.status ?? 1);
138
+ }
139
+
140
+ main();
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "fireemu",
3
+ "version": "0.1.0",
4
+ "description": "A deterministic, test-only local runtime for Firebase SDK and Functions code",
5
+ "keywords": [
6
+ "emulator",
7
+ "firebase",
8
+ "firebase-functions",
9
+ "firestore",
10
+ "testing"
11
+ ],
12
+ "homepage": "https://github.com/t-k/fireemu#readme",
13
+ "bugs": "https://github.com/t-k/fireemu/issues",
14
+ "license": "Apache-2.0",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/t-k/fireemu.git"
18
+ },
19
+ "bin": {
20
+ "fireemu": "bin/fireemu.mjs"
21
+ },
22
+ "files": [
23
+ "bin/fireemu.mjs",
24
+ "README.md",
25
+ "LICENSE",
26
+ "THIRD_PARTY_LICENSES.txt"
27
+ ],
28
+ "type": "module",
29
+ "optionalDependencies": {
30
+ "@fireemu/darwin-arm64": "0.1.0",
31
+ "@fireemu/darwin-x64": "0.1.0",
32
+ "@fireemu/linux-x64": "0.1.0",
33
+ "@fireemu/linux-arm64": "0.1.0",
34
+ "@fireemu/win32-x64": "0.1.0"
35
+ },
36
+ "engines": {
37
+ "node": ">=20"
38
+ }
39
+ }