@@ -49,6 +49,7 @@ const potentialEnvs = {
49
49
next : "NEXT_PUBLIC_INSTANT_APP_ID" ,
50
50
svelte : "PUBLIC_INSTANT_APP_ID" ,
51
51
vite : "VITE_INSTANT_APP_ID" ,
52
+ expo : "EXPO_PUBLIC_INSTANT_APP_ID" ,
52
53
} ;
53
54
54
55
async function detectEnvType ( { pkgDir } ) {
@@ -65,6 +66,9 @@ async function detectEnvType({ pkgDir }) {
65
66
if ( packageJSON . devDependencies ?. vite ) {
66
67
return "vite" ;
67
68
}
69
+ if ( packageJSON . dependencies ?. expo ) {
70
+ return "expo" ;
71
+ }
68
72
return "catchall" ;
69
73
}
70
74
@@ -433,8 +437,8 @@ function printDotEnvInfo(envType, appId) {
433
437
const otherEnvs = Object . values ( rest ) ;
434
438
otherEnvs . sort ( ) ;
435
439
const otherEnvStr = otherEnvs . map ( ( x ) => " " + chalk . green ( x ) ) . join ( "\n" ) ;
436
- console . log ( `Alternative names: \n${ otherEnvStr } ` ) ;
437
- console . log ( terminalLink ( "Dashboard" , appDashUrl ( appId ) ) ) ;
440
+ console . log ( `Alternative names: \n${ otherEnvStr } \n ` ) ;
441
+ console . log ( terminalLink ( "Dashboard" , appDashUrl ( appId ) ) + '\n' ) ;
438
442
}
439
443
440
444
async function handleEnvFile ( pkgAndAuthInfo , appId ) {
@@ -759,7 +763,7 @@ async function pullSchema(appId, { pkgDir, instantModuleName }) {
759
763
"utf-8" ,
760
764
) ;
761
765
762
- console . log ( "Wrote schema to instant.schema.ts" ) ;
766
+ console . log ( "✅ Wrote schema to instant.schema.ts" ) ;
763
767
764
768
return { ok : true } ;
765
769
}
@@ -777,7 +781,7 @@ async function pullPerms(appId, { pkgDir, instantModuleName }) {
777
781
778
782
if ( await pathExists ( join ( pkgDir , "instant.perms.ts" ) ) ) {
779
783
const ok = await promptOk (
780
- "This will ovwerwrite your local instant.perms file, OK to proceed?" ,
784
+ "This will overwrite your local instant.perms file, OK to proceed?" ,
781
785
) ;
782
786
783
787
if ( ! ok ) return ;
@@ -790,7 +794,7 @@ async function pullPerms(appId, { pkgDir, instantModuleName }) {
790
794
"utf-8" ,
791
795
) ;
792
796
793
- console . log ( "Wrote permissions to instant.perms.ts" ) ;
797
+ console . log ( "✅ Wrote permissions to instant.perms.ts" ) ;
794
798
795
799
return true ;
796
800
}
@@ -1125,7 +1129,7 @@ async function pushPerms(appId) {
1125
1129
1126
1130
if ( ! prodPerms . ok ) return ;
1127
1131
1128
- const diffedStr = jsonDiff . diffString ( prodPerms . data . perms , perms ) ;
1132
+ const diffedStr = jsonDiff . diffString ( prodPerms . data . perms || { } , perms || { } ) ;
1129
1133
if ( ! diffedStr . length ) {
1130
1134
console . log ( "No perms changes detected. Exiting." ) ;
1131
1135
return ;
@@ -1288,13 +1292,33 @@ async function promptOk(message) {
1288
1292
} ) . catch ( ( ) => false ) ;
1289
1293
}
1290
1294
1295
+ /**
1296
+ * We need to do a bit of a hack of `@instantdb/react-native`.
1297
+ *
1298
+ * If a user writes import { i } from '@instantdb/react-native'
1299
+ *
1300
+ * We will fail to evaluate the file. This is because
1301
+ * `@instantdb/react-native` brings in `react-native`, which
1302
+ * does not run in a node context.
1303
+ *
1304
+ * To bypass this, we have a 'cli' module inside `react-native`, which
1305
+ * has all the necessary imports
1306
+ */
1307
+ function transformImports ( code ) {
1308
+ return code . replace (
1309
+ / " @ i n s t a n t d b \/ r e a c t - n a t i v e " / g,
1310
+ '"@instantdb/react-native/dist/cli"'
1311
+ ) ;
1312
+ }
1313
+
1291
1314
async function readLocalPermsFile ( ) {
1292
1315
const { config, sources } = await loadConfig ( {
1293
1316
sources : [
1294
1317
// load from `instant.perms.xx`
1295
1318
{
1296
1319
files : "instant.perms" ,
1297
1320
extensions : [ "ts" , "mts" , "cts" , "js" , "mjs" , "cjs" , "json" ] ,
1321
+ transform : transformImports ,
1298
1322
} ,
1299
1323
] ,
1300
1324
// if false, the only the first matched will be loaded
@@ -1326,6 +1350,7 @@ async function readLocalSchemaFile() {
1326
1350
{
1327
1351
files : "instant.schema" ,
1328
1352
extensions : [ "ts" , "mts" , "cts" , "js" , "mjs" , "cjs" ] ,
1353
+ transform : transformImports ,
1329
1354
} ,
1330
1355
] ,
1331
1356
// if false, the only the first matched will be loaded
@@ -1519,9 +1544,10 @@ function appDashUrl(id) {
1519
1544
}
1520
1545
1521
1546
function generatePermsTypescriptFile ( perms , instantModuleName ) {
1522
- const rulesTxt = Object . keys ( perms ) . length
1523
- ? JSON . stringify ( perms , null , 2 )
1524
- : `
1547
+ const rulesTxt =
1548
+ perms && Object . keys ( perms ) . length
1549
+ ? JSON . stringify ( perms , null , 2 )
1550
+ : `
1525
1551
{
1526
1552
/**
1527
1553
* Welcome to Instant's permission system!
@@ -1539,12 +1565,12 @@ function generatePermsTypescriptFile(perms, instantModuleName) {
1539
1565
* bind: ["isOwner", "data.creator == auth.uid"],
1540
1566
* },
1541
1567
*/
1542
- };
1568
+ }
1543
1569
` . trim ( ) ;
1544
1570
return `
1545
1571
// Docs: https://www.instantdb.com/docs/permissions
1546
1572
1547
- import { type InstantRules } from "${ instantModuleName ?? "@instantdb/core" } ";
1573
+ import type { InstantRules } from "${ instantModuleName ?? "@instantdb/core" } ";
1548
1574
1549
1575
const rules = ${ rulesTxt } satisfies InstantRules;
1550
1576
@@ -1743,7 +1769,7 @@ type _AppSchema = typeof _schema;
1743
1769
interface AppSchema extends _AppSchema {}
1744
1770
const schema: AppSchema = _schema;
1745
1771
1746
- export { type AppSchema }
1772
+ export type { AppSchema }
1747
1773
export default schema;
1748
1774
` ;
1749
1775
}
0 commit comments