Suite of cli and perms bugfixes #627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Made a series of tweaks to CLI, from what I noticed from the user session with Zack.
Small changes
npx instant-cli init
now detects expo, and shares the env var for expo (EXPO_PUBLIC...)$default
an allowed key in InstantRules.ts, and in Perms Editor$default
is no longer a reserved name on the backendControversial Change: replace imports for
@instantdb/react-native
I realized that CLI has been broken for react-native. The main reason, was that when we ran
loadConfig
, we would evaluateinstant.schema.ts
andinstant.perms.ts
in a node environment.Inside the file, we would improve from our library like so:
The problem is,
@instantdb/react-native
imports react-native libraries, which fail in node.There were a few options I thought of for getting around this:
A) Make
@instantdb/core
a peerWe could make
@instantdb/core
a peer library, instead of a dependency. We could thenimport { i } from '@instantdb/core'
. This works great, but it would now force the user to install two libraries to get going. i.m.o that's a bit of a sadder experience. Perhaps it's worth it down the line, but I didn't want support for CLI to be the reason we switch.B) Conditional entry points
We could have detected whether we were in a CLI environment, and had
@instantdb/react-native
run different entry points. I thought this would be changing the library too much though, just for CLIC) Have a separate entry point for CLI
We could have a cli.ts file, which doesn't import react-native code. We could either tell the user to use it explicitly, or to just replace calls of
@instantdb/react-native
with@instantdb/react-native/dist/cli
. I ended up doing thisreplace
approach.@dwwoelfel @nezaj @tonsky