I have an app.json file in my Expo project. In this file I have two API keys (labeled API_KEY below) that I'd like to hide via environment variables.
How can I go about using environment variables instead of hard coding the API keys?
app.json
{
"expo": {
"name": "Closeout",
"slug": "Closeout",
"version": "1.0.0",
"orientation": "portrait",
"privacy": "hidden",
"notification": {
"icon": "./assets/images/notification-icon.png",
"color": "#000000",
"iosDisplayInForeground": true
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"icon": "./assets/images/icon.png",
"buildNumber": "2",
"config": {
"googleMapsApiKey": "API_KEY"
}
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/icon.png",
"backgroundColor": "#000"
},
"versionCode": 5,
"useNextNotificationsApi": true,
"config": {
"googleMaps": {
"apiKey": "API_KEY"
}
},
"googleServicesFile": "./google-services.json"
}
}
}
I'm guessing you may have figured out a solution or tried something else by now. However, here is a solution to this issue, I hope it helps anyone facing the same challenge. This is from a typescript environment I'm implementing.
Create an app.config.ts file that overrides the content of the app.json file
import { ExpoConfig, ConfigContext } from '#expo/config';
import * as dotenv from 'dotenv';
// initialize dotenv
dotenv.config();
export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
slug: 'my-app',
name: 'My App',
ios: {
supportsTablet: true,
bundleIdentifier: 'com.croon',
config: {
googleMapsApiKey: process.env.GOOGLE_CLOUD_API_KEY,
},
},
android: {
adaptiveIcon: {
foregroundImage: './assets/adaptive-icon.png',
backgroundColor: '#FFFFFF',
},
package: 'com.croon',
config: {
googleMaps: {
apiKey: process.env.GOOGLE_CLOUD_API_KEY,
},
},
},
});
Then you could leave the API entry blank on the app.json file.
{
"expo": {
"name": "Closeout",
"slug": "Closeout",
"version": "1.0.0",
"orientation": "portrait",
"privacy": "hidden",
"notification": {
"icon": "./assets/images/notification-icon.png",
"color": "#000000",
"iosDisplayInForeground": true
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"icon": "./assets/images/icon.png",
"buildNumber": "2",
"config": {
"googleMapsApiKey": ""
}
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/icon.png",
"backgroundColor": "#000"
},
"versionCode": 5,
"useNextNotificationsApi": true,
"config": {
"googleMaps": {
"apiKey": ""
}
},
"googleServicesFile": "./google-services.json"
}
}
}
Remember to install the required dependencies
Cheers!
Related
Because public IPFS gateway is too slow, I set up own ipfs cluster using kubernetes on AWS.
However, when I tried to get files from the cluster, I succeeded for some files but failed for others consistently(failed one kept failing).
How do I debug this? Did I make mistake on configuration? Here's the configuration I used.
{
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Methods": [
"PUT",
"POST"
],
"Access-Control-Allow-Origin": [
"http://localhost:3000",
"http://127.0.0.1:5001",
"https://webui.ipfs.io"
]
}
},
"Addresses": {
"API": "/ip4/0.0.0.0/tcp/5001",
"Announce": [],
"AppendAnnounce": [],
"Gateway": "/ip4/0.0.0.0/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic"
]
},
"AutoNAT": {},
"Bootstrap": [
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
],
"DNS": {
"Resolvers": {}
},
"Datastore": {
"BloomFilterSize": 0,
"GCPeriod": "1h",
"HashOnRead": false,
"Spec": {
"mounts": [
{
"child": {
"path": "blocks",
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
"sync": true,
"type": "flatfs"
},
"mountpoint": "/blocks",
"prefix": "flatfs.datastore",
"type": "measure"
},
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
}
],
"type": "mount"
},
"StorageGCWatermark": 90,
"StorageMax": "10GB"
},
"Discovery": {
"MDNS": {
"Enabled": true,
"Interval": 10
}
},
"Experimental": {
"AcceleratedDHTClient": false,
"FilestoreEnabled": false,
"GraphsyncEnabled": false,
"Libp2pStreamMounting": false,
"P2pHttpProxy": false,
"StrategicProviding": false,
"UrlstoreEnabled": false
},
"Gateway": {
"APICommands": [],
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Range",
"User-Agent"
],
"Access-Control-Allow-Methods": [
"GET"
],
"Access-Control-Allow-Origin": [
"*"
]
},
"NoDNSLink": false,
"NoFetch": false,
"PathPrefixes": [],
"PublicGateways": null,
"RootRedirect": "",
"Writable": false
},
"Identity": {
"PeerID": "<intentionally hide>"
},
"Internal": {},
"Ipns": {
"RecordLifetime": "",
"RepublishPeriod": "",
"ResolveCacheSize": 128
},
"Migration": {
"DownloadSources": [],
"Keep": ""
},
"Mounts": {
"FuseAllowOther": false,
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"Peering": {
"Peers": null
},
"Pinning": {
"RemoteServices": {}
},
"Plugins": {
"Plugins": null
},
"Provider": {
"Strategy": ""
},
"Pubsub": {
"DisableSigning": false,
"Router": ""
},
"Reprovider": {
"Interval": "12h",
"Strategy": "all"
},
"Routing": {
"Type": "dht"
},
"Swarm": {
"AddrFilters": null,
"ConnMgr": {
"GracePeriod": "20s",
"HighWater": 900,
"LowWater": 600,
"Type": "basic"
},
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"RelayClient": {
"Enabled": true
},
"RelayService": {
"Enabled": true
},
"Transports": {
"Multiplexers": {},
"Network": {},
"Security": {}
}
}
}
I have the following in .vscode/launch.json :
{
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "vuejs: firefox",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"firefoxExecutable": "C:/Users/Geoffrey Swenson/AppData/Local/Mozilla Firefox/firefox.exe",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
},
"preLaunchTask": "serve"
},
{
"type": "chrome",
"request": "launch",
"reAttach": true,
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
},
"preLaunchTask": "serve"
}]
}
I have the following in .vscode/tasks.json :
{
"version": "2.0.0",
"tasks": [
{
"label": "start",
"type": "npm",
"script": "serve",
"isBackground": true
},
{
"label": "serve",
"type": "npm",
"script": "serve",
"isBackground": true,
"problemMatcher": [{
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "Starting development server",
"endsPattern": "Compiled successfully"
}
}],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
I also have vue.config.ts :
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
Breakpoints work in Firefox, though I have to press F5 the first time I load it. They never work in Chrome. Firefox involves installing a debugger extension, but there is supposedly no need for this for Chrome.
first you need to set launch.json and then set your config file as you need:
hereafter an example which works with vite running as bundler in front and server in back
{
"debug": {
"javascript": {
"terminalOptions": {
"skipFiles": [
"<node_internals>/**"
],
"trace": true
}
}
},
"configurations": [
{
"name": "Run bundler",
"request": "launch",
"type": "node-terminal",
"command": "npm run <your-command-to-run-app>",
"cwd": "${workspaceFolder}"
}
]
}
Then forget webpack and use vite, thus you need to install vite and a vite config file
import { defineConfig } from 'vite';
import vue from '#vitejs/plugin-vue';
// cf. https://vitejs.dev/config/
export default defineConfig(async ({ command, mode }) => {
return {
plugins: [vue()],
server: {
proxy: {
'/api/': {
target: 'http://localhost:3080',
changeOrigin: true,
secure: false
}
},
port: 3080,
strictPort: true
},
build: {
outDir: './server/public'
}
};
});
I use typescript and in my ts.config.json, I setted
...
"sourceMap": true,
"types": ["vite/server"],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
...
hope that's will help folk's !
I have been trying to get this Minecraft bedrock behavior pack working for a while now. I used a guide, so I could learn how to make behavior packs but no matter how many times I look back through it, I still can't figure out what the problem is. The referenced texture pack works fine, but the behavior does not work.
Minecraft bedrock v1.17.34.
in file : development_resource_packs > RP cow
This is the manifest.json for the resource pack.
// development_resource_packs > RP cow > manifest.json
{
"format_version": 2,
"header": {
"description": "My First Add-On!",
"name": "Hello WorldRP",
"uuid":"9b0e1712-ba26-4d3c-be42-2b6c4d160305",
"version": [1, 0, 0],
"min_engine_version": [1, 16, 0]
},
"modules": [
{
"description": "My First Add-On!",
"type": "resources",
"uuid": "f2ccdadd-c9ac-4d53-8daf-a3520537ea7e",
"version": [1, 0, 0]
}
]
}
// development_behavior_packs > HelloWorldBP > manifest.json
{
"format_version": 2,
"header": {
"description": "My First Add-On!",
"name": "Hello WorldBP",
"uuid":"c3fac618-a713-4516-b1eb-1b9c7c75b1db",
"version": [1, 0, 0],
"min_engine_version": [1, 16, 0]
},
"modules":
[
{
"description": "My First Add-On!",
"type": "data",
"uuid": "e34d68ac-72f2-44c2-a514-b83673f919c0",
"version": [1, 0, 0]
}
],
"dependencies": [
{
"uuid":"9b0e1712-ba26-4d3c-be42-2b6c4d160305",
"version":[1,0,0]
}
]
}
// HelloWorldBP > entities > cow.json
{
"format_version": "1.16.0",
"minecraft:entity": {
"description": {
"identifier": "minecraft:cow",
"is_spawnable": true,
"is_summonable": true,
"is_experimental": false
},
"component_groups": {
"minecraft:cow_baby": {
"minecraft:is_baby": {
},
"minecraft:scale": {
"value":0.5
},
"minecraft:ageable": {
"duration": 1200,
"feed_items": "wheat",
"grow_up": {
"event": "minecraft:ageable_grow_up",
"target": "self"
}
},
"minecraft:behavior.follow_parent": {
"priority": 6,
"speed_multiplier": 1.1
}
},
"minecraft:cow_adult": {
"minecraft:experience_reward": {
"on_bred": "Math.Random(1,7)",
"on_death": "query.last_hit_by_player ? Math.Random(1,3) : 0"
},
"minecraft:loot": {
"table": "loot_tables/entities/cow.json"
},
"minecraft:behavior.breed": {
"priority": 3,
"speed_multiplier": 1.0
},
"minecraft:breedable": {
"require_tame": false,
"breed_items": "wheat",
"breeds_with": {
"mate_type": "minecraft:cow",
"baby_type": "minecraft:cow",
"breed_event": {
"event": "minecraft:entity_born",
"target": "baby"
}
}
},
"minecraft:interact": {
"interactions": [
{
"on_interact": {
"filters": {
"all_of": [
{ "test": "is_family", "subject" : "other", "value" : "player"},
{ "test": "has_equipment", "domain": "hand", "subject": "other", "value": "bucket:0"}
]
}
},
"use_item": true,
"transform_to_item": "bucket:1",
"play_sounds": "milk",
"interact_text": "action.interact.milk"
}
]
}
}
},
"components": {
"minecraft:type_family": {
"family": [ "cow", "mob" ]
},
"minecraft:breathable": {
"total_supply": 15,
"suffocate_time": 0
},
"minecraft:navigation.walk": {
"can_path_over_water": true,
"avoid_water": true,
"avoid_damage_blocks": true
},
"minecraft:movement.basic": {
},
"minecraft:jump.static": {
},
"minecraft:can_climb": {
},
"minecraft:collision_box": {
"width": 0.9,
"height": 1.3
},
"minecraft:nameable": {
},
"minecraft:health": {
"value": 10,
"max": 10
},
"minecraft:hurt_on_condition": {
"damage_conditions": [
{
"filters": { "test": "in_lava", "subject": "self", "operator": "==", "value": true },
"cause": "lava",
"damage_per_tick": 4
}
]
},
"minecraft:movement": {
"value": 0.25
},
"minecraft:despawn": {
"despawn_from_distance": {}
},
"minecraft:behavior.float": {
"priority": 0
},
"minecraft:behavior.panic": {
"priority": 1,
"speed_multiplier": 1.25
},
"minecraft:behavior.mount_pathing": {
"priority": 2,
"speed_multiplier": 1.5,
"target_dist": 0.0,
"track_target": true
},
"minecraft:behavior.breed": {
"priority": 3,
"speed_multiplier": 1.0
},
"minecraft:behavior.tempt": {
"priority": 4,
"speed_multiplier": 1.25,
"items": [
"wheat"
]
},
"minecraft:behavior.follow_parent": {
"priority": 5,
"speed_multiplier": 1.1
},
"minecraft:behavior.random_stroll": {
"priority": 6,
"speed_multiplier": 0.8
},
"minecraft:behavior.look_at_player": {
"priority": 7,
"look_distance": 6.0,
"probability": 0.02
},
"minecraft:behavior.random_look_around": {
"priority": 9
},
"minecraft:leashable": {
"soft_distance": 4.0,
"hard_distance": 6.0,
"max_distance": 10.0
},
"minecraft:balloonable": {
},
"minecraft:rideable": {
"seat_count": 1,
"family_types": [
"zombie"
],
"seats": {
"position": [ 0.0, 1.105, 0.0 ]
}
},
"minecraft:physics": {
},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
},
"minecraft:conditional_bandwidth_optimization": {
},
"minecraft:behavior.nearest_attackable_target":{
"priority": 2,
"must_see":true,
"reselect_targets": true,
"within_radius": 25.0,
"entity_types":[
{
"filters":{
"test": "is_family", "subject": "other", "value": "player"
},
"max_dist":32
}
]
},
"minecraft:behavior.melee_attack": {
"priority": 3
},
"minecraft:attack":{
"damage": 3
}
},
"events": {
"minecraft:entity_spawned": {
"randomize": [
{
"weight": 95,
"trigger": "minecraft:spawn_adult"
},
{
"weight": 5,
"add": {
"component_groups": [
"minecraft:cow_baby"
]
}
}
]
},
"minecraft:entity_born": {
"add": {
"component_groups": [
"minecraft:cow_baby"
]
}
},
"minecraft:entity_transformed": {
"remove": {
},
"add": {
"component_groups": [
"minecraft:cow_adult"
]
}
},
"minecraft:ageable_grow_up": {
"remove": {
"component_groups": [
"minecraft:cow_baby"
]
},
"add": {
"component_groups": [
"minecraft:cow_adult"
]
}
},
"minecraft:spawn_adult": {
"add": {
"component_groups": [
"minecraft:cow_adult"
]
}
}
}
}
}
enable experimental featurs. to think after a day I would not realize that was all I had to do.
Problem:
This pack is missing one or more dependencies. Would you like to apply it anyway?
I was also following Microsoft's Introduction to Behavior Packs tutorial. This was the error the game provided when I tried to load my behavior pack into a new world. Sure enough, my cows did not attack me :-(
Solution #1:
I needed to do 2 things to resolve this error.
1. Correct the typo in the name of the entities folder.
As the Troubleshooting section suggests, check the spelling of this and other folders!
2. Remove the entry in invalid_known_packs for my behavior pack.
// com.Mojang > minecraftpe > invalid_known_packs.json
// This was part of the file.
{
"file_system" : "RawPath",
"from_disk" : true,
"hashes" : [ "gc9MQR+ZUuk6kivtMInudDFbammayhdk5vdSMVUzFP4=" ],
"path" : "C:/Users/<my user>/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/MadCows",
"uuid" : "<my uuid>",
"version" : "1.0.0"
},
It appears that Minecraft will remember previously bad behavior packs, and it will not attempt to load them again! Once I removed the above entry, the cows attacked me as expected. :-)
Solution #2:
Sometimes this error is an error, and when I play the game anyway, my mod works as expected.
I have ~2000 JSON files that have duplicate representations like:
{
"vulnerabilities": [],
"ok": true,
"dependencyCount": 2,
"org": "org",
"isPrivate": true,
"licensesPolicy": {
"severities": {},
"orgLicenseRules": {
"AGPL-1.0": {
"licenseType": "AGPL-1.0",
"severity": "high",
"instructions": ""
}
}
}
}
{
"vulnerabilities": [],
"ok": true,
"dependencyCount": 2,
"org": "org",
"isPrivate": true,
"licensesPolicy": {
"severities": {},
"orgLicenseRules": {
"AGPL-1.0": {
"licenseType": "AGPL-1.0",
"severity": "high",
"instructions": ""
}
}
}
}
I want to essentially remove duplicate entries for vulnerabilities in a directory of JSON files.
How might I do that?
As many have before me, I am building an event app using Firebase as the database.
After watching this https://www.youtube.com/watch?v=i1n9Kw3AORw I think that my current data structure is wrong so I want to change it.
This is something that I hope will keep track of which events users have been to, their responses, check ins and help update user information like in the video.
{
"events": {
"event1": {
"title": "Event 1",
"venue": {
"venue1": true
},
"guests": {
"user1": true,
"user2": true
}
},
"event2": {}
},
"locationHistory": {
"location1": {
"user1": true,
"user2": true
},
"location2": {
"user3": true
}
},
"userCheckIns": {
"event1": {
"user1": true
}
},
"userResponses": { // not sure about these responses
"event1": {
"user1": true,
"user2": false,
"user3": "maybe"
},
"event2": {}
},
"eventGuests": {
"event1": {
"user1": {
"name": "user name 1"
},
"user2": {
"name": "user name 2"
}
},
"event2": {}
},
"userEvents": {
"user1": {
"event1": true
},
"user2": {
"event1": true
}
},
"venues": {
"venue1": {
"name": "Venue name",
"location": "location1"
},
"users": {
"user1": {
"name": "user name 1",
"events": {
"event1": true
}
},
"user2": {
"name": "user name 2",
"events": {
"event1": true
}
}
}
}
}