@expo/env 0.0.0-canary-20231122-1af9191

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,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023-present 650 Industries, Inc. (aka Expo)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @expo/env
2
+
3
+ Load environment variables from `.env` files. Supports the [standard .env formats](https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use).
package/build/env.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ type LoadOptions = {
3
+ silent?: boolean;
4
+ force?: boolean;
5
+ };
6
+ export declare function isEnabled(): boolean;
7
+ export declare function createControlledEnvironment(): {
8
+ load: (projectRoot: string, options?: LoadOptions) => NodeJS.ProcessEnv;
9
+ get: (projectRoot: string, options?: LoadOptions) => {
10
+ env: Record<string, string | undefined>;
11
+ files: string[];
12
+ };
13
+ _getForce: (projectRoot: string, options?: LoadOptions) => {
14
+ env: Record<string, string | undefined>;
15
+ files: string[];
16
+ };
17
+ };
18
+ export declare function getFiles(mode: string | undefined, { silent }?: Pick<LoadOptions, 'silent'>): string[];
19
+ export {};
package/build/env.js ADDED
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createControlledEnvironment = createControlledEnvironment;
7
+ exports.getFiles = getFiles;
8
+ exports.isEnabled = isEnabled;
9
+ function _chalk() {
10
+ const data = _interopRequireDefault(require("chalk"));
11
+ _chalk = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function dotenv() {
17
+ const data = _interopRequireWildcard(require("dotenv"));
18
+ dotenv = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ function _dotenvExpand() {
24
+ const data = require("dotenv-expand");
25
+ _dotenvExpand = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
30
+ function fs() {
31
+ const data = _interopRequireWildcard(require("fs"));
32
+ fs = function () {
33
+ return data;
34
+ };
35
+ return data;
36
+ }
37
+ function _getenv() {
38
+ const data = require("getenv");
39
+ _getenv = function () {
40
+ return data;
41
+ };
42
+ return data;
43
+ }
44
+ function path() {
45
+ const data = _interopRequireWildcard(require("path"));
46
+ path = function () {
47
+ return data;
48
+ };
49
+ return data;
50
+ }
51
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
52
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
53
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
+ /**
55
+ * Copyright © 2023 650 Industries.
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE file in the root directory of this source tree.
59
+ */
60
+
61
+ const debug = require('debug')('expo:env');
62
+ function isEnabled() {
63
+ return !(0, _getenv().boolish)('EXPO_NO_DOTENV', false);
64
+ }
65
+ function createControlledEnvironment() {
66
+ const IS_DEBUG = require('debug').enabled('expo:env');
67
+ let userDefinedEnvironment = undefined;
68
+ let memo = undefined;
69
+ function _getForce(projectRoot, options = {}) {
70
+ if (!isEnabled()) {
71
+ debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);
72
+ return {
73
+ env: {},
74
+ files: []
75
+ };
76
+ }
77
+ if (!userDefinedEnvironment) {
78
+ userDefinedEnvironment = {
79
+ ...process.env
80
+ };
81
+ }
82
+
83
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
84
+ const dotenvFiles = getFiles(process.env.NODE_ENV, options);
85
+ const loadedEnvFiles = [];
86
+ const parsed = {};
87
+
88
+ // Load environment variables from .env* files. Suppress warnings using silent
89
+ // if this file is missing. dotenv will never modify any environment variables
90
+ // that have already been set. Variable expansion is supported in .env files.
91
+ // https://github.com/motdotla/dotenv
92
+ // https://github.com/motdotla/dotenv-expand
93
+ dotenvFiles.forEach(dotenvFile => {
94
+ const absoluteDotenvFile = path().resolve(projectRoot, dotenvFile);
95
+ if (!fs().existsSync(absoluteDotenvFile)) {
96
+ return;
97
+ }
98
+ try {
99
+ const results = (0, _dotenvExpand().expand)(dotenv().config({
100
+ debug: IS_DEBUG,
101
+ path: absoluteDotenvFile,
102
+ // We will handle overriding ourselves to allow for HMR.
103
+ override: true
104
+ }));
105
+ if (results.parsed) {
106
+ loadedEnvFiles.push(absoluteDotenvFile);
107
+ debug(`Loaded environment variables from: ${absoluteDotenvFile}`);
108
+ for (const key of Object.keys(results.parsed || {})) {
109
+ var _userDefinedEnvironme;
110
+ if (typeof parsed[key] === 'undefined' &&
111
+ // Custom override logic to prevent overriding variables that
112
+ // were set before the CLI process began.
113
+ typeof ((_userDefinedEnvironme = userDefinedEnvironment) === null || _userDefinedEnvironme === void 0 ? void 0 : _userDefinedEnvironme[key]) === 'undefined') {
114
+ parsed[key] = results.parsed[key];
115
+ }
116
+ }
117
+ } else {
118
+ debug(`Failed to load environment variables from: ${absoluteDotenvFile}`);
119
+ }
120
+ } catch (error) {
121
+ if (error instanceof Error) {
122
+ console.error(`Failed to load environment variables from ${absoluteDotenvFile}: ${error.message}`);
123
+ } else {
124
+ throw error;
125
+ }
126
+ }
127
+ });
128
+ if (!loadedEnvFiles.length) {
129
+ debug(`No environment variables loaded from .env files.`);
130
+ }
131
+ return {
132
+ env: parsed,
133
+ files: loadedEnvFiles
134
+ };
135
+ }
136
+
137
+ /** Get the environment variables without mutating the environment. This returns memoized values unless the `force` property is provided. */
138
+ function get(projectRoot, options = {}) {
139
+ if (!isEnabled()) {
140
+ debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);
141
+ return {
142
+ env: {},
143
+ files: []
144
+ };
145
+ }
146
+ if (!options.force && memo) {
147
+ return memo;
148
+ }
149
+ memo = _getForce(projectRoot, options);
150
+ return memo;
151
+ }
152
+
153
+ /** Load environment variables from .env files and mutate the current `process.env` with the results. */
154
+ function load(projectRoot, options = {}) {
155
+ if (!isEnabled()) {
156
+ debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);
157
+ return process.env;
158
+ }
159
+ const envInfo = get(projectRoot, options);
160
+ if (!options.force) {
161
+ const keys = Object.keys(envInfo.env);
162
+ if (keys.length) {
163
+ console.log(_chalk().default.gray('env: load', envInfo.files.map(file => path().basename(file)).join(' ')));
164
+ console.log(_chalk().default.gray('env: export', keys.join(' ')));
165
+ }
166
+ }
167
+ process.env = {
168
+ ...process.env,
169
+ ...envInfo.env
170
+ };
171
+ return process.env;
172
+ }
173
+ return {
174
+ load,
175
+ get,
176
+ _getForce
177
+ };
178
+ }
179
+ function getFiles(mode, {
180
+ silent = false
181
+ } = {}) {
182
+ if (!isEnabled()) {
183
+ debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);
184
+ return [];
185
+ }
186
+ if (!mode) {
187
+ if (silent) {
188
+ debug('NODE_ENV is not defined, proceeding without mode-specific .env');
189
+ } else {
190
+ console.error(_chalk().default.red('The NODE_ENV environment variable is required but was not specified. Ensure the project is bundled with Expo CLI or NODE_ENV is set.'));
191
+ console.error(_chalk().default.red('Proceeding without mode-specific .env'));
192
+ }
193
+ }
194
+ if (mode && !['development', 'test', 'production'].includes(mode)) {
195
+ throw new Error(`Environment variable "NODE_ENV=${mode}" is invalid. Valid values are "development", "test", and "production`);
196
+ }
197
+ if (!mode) {
198
+ // Support environments that don't respect NODE_ENV
199
+ return [`.env.local`, '.env'];
200
+ }
201
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
202
+ const dotenvFiles = [`.env.${mode}.local`,
203
+ // Don't include `.env.local` for `test` environment
204
+ // since normally you expect tests to produce the same
205
+ // results for everyone
206
+ mode !== 'test' && `.env.local`, `.env.${mode}`, '.env'].filter(Boolean);
207
+ return dotenvFiles;
208
+ }
209
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","names":["_chalk","data","_interopRequireDefault","require","dotenv","_interopRequireWildcard","_dotenvExpand","fs","_getenv","path","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","debug","isEnabled","boolish","createControlledEnvironment","IS_DEBUG","enabled","userDefinedEnvironment","undefined","memo","_getForce","projectRoot","options","env","files","process","dotenvFiles","getFiles","NODE_ENV","loadedEnvFiles","parsed","forEach","dotenvFile","absoluteDotenvFile","resolve","existsSync","results","expand","config","override","push","keys","_userDefinedEnvironme","error","Error","console","message","length","force","load","envInfo","log","chalk","gray","map","file","basename","join","mode","silent","red","includes","filter","Boolean"],"sources":["../src/env.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport * as dotenv from 'dotenv';\nimport { expand } from 'dotenv-expand';\nimport * as fs from 'fs';\nimport { boolish } from 'getenv';\nimport * as path from 'path';\n\ntype LoadOptions = {\n silent?: boolean;\n force?: boolean;\n};\n\nconst debug = require('debug')('expo:env') as typeof console.log;\n\nexport function isEnabled(): boolean {\n return !boolish('EXPO_NO_DOTENV', false);\n}\n\nexport function createControlledEnvironment() {\n const IS_DEBUG = require('debug').enabled('expo:env');\n\n let userDefinedEnvironment: NodeJS.ProcessEnv | undefined = undefined;\n let memo: { env: NodeJS.ProcessEnv; files: string[] } | undefined = undefined;\n\n function _getForce(\n projectRoot: string,\n options: LoadOptions = {}\n ): { env: Record<string, string | undefined>; files: string[] } {\n if (!isEnabled()) {\n debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);\n return { env: {}, files: [] };\n }\n\n if (!userDefinedEnvironment) {\n userDefinedEnvironment = { ...process.env };\n }\n\n // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use\n const dotenvFiles = getFiles(process.env.NODE_ENV, options);\n\n const loadedEnvFiles: string[] = [];\n const parsed: dotenv.DotenvParseOutput = {};\n\n // Load environment variables from .env* files. Suppress warnings using silent\n // if this file is missing. dotenv will never modify any environment variables\n // that have already been set. Variable expansion is supported in .env files.\n // https://github.com/motdotla/dotenv\n // https://github.com/motdotla/dotenv-expand\n dotenvFiles.forEach((dotenvFile) => {\n const absoluteDotenvFile = path.resolve(projectRoot, dotenvFile);\n if (!fs.existsSync(absoluteDotenvFile)) {\n return;\n }\n try {\n const results = expand(\n dotenv.config({\n debug: IS_DEBUG,\n path: absoluteDotenvFile,\n // We will handle overriding ourselves to allow for HMR.\n override: true,\n })\n );\n if (results.parsed) {\n loadedEnvFiles.push(absoluteDotenvFile);\n debug(`Loaded environment variables from: ${absoluteDotenvFile}`);\n\n for (const key of Object.keys(results.parsed || {})) {\n if (\n typeof parsed[key] === 'undefined' &&\n // Custom override logic to prevent overriding variables that\n // were set before the CLI process began.\n typeof userDefinedEnvironment?.[key] === 'undefined'\n ) {\n parsed[key] = results.parsed[key];\n }\n }\n } else {\n debug(`Failed to load environment variables from: ${absoluteDotenvFile}`);\n }\n } catch (error: unknown) {\n if (error instanceof Error) {\n console.error(\n `Failed to load environment variables from ${absoluteDotenvFile}: ${error.message}`\n );\n } else {\n throw error;\n }\n }\n });\n\n if (!loadedEnvFiles.length) {\n debug(`No environment variables loaded from .env files.`);\n }\n\n return { env: parsed, files: loadedEnvFiles };\n }\n\n /** Get the environment variables without mutating the environment. This returns memoized values unless the `force` property is provided. */\n function get(\n projectRoot: string,\n options: LoadOptions = {}\n ): { env: Record<string, string | undefined>; files: string[] } {\n if (!isEnabled()) {\n debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);\n return { env: {}, files: [] };\n }\n if (!options.force && memo) {\n return memo;\n }\n memo = _getForce(projectRoot, options);\n return memo;\n }\n\n /** Load environment variables from .env files and mutate the current `process.env` with the results. */\n function load(projectRoot: string, options: LoadOptions = {}) {\n if (!isEnabled()) {\n debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);\n return process.env;\n }\n\n const envInfo = get(projectRoot, options);\n\n if (!options.force) {\n const keys = Object.keys(envInfo.env);\n if (keys.length) {\n console.log(\n chalk.gray('env: load', envInfo.files.map((file) => path.basename(file)).join(' '))\n );\n console.log(chalk.gray('env: export', keys.join(' ')));\n }\n }\n\n process.env = { ...process.env, ...envInfo.env };\n return process.env;\n }\n\n return {\n load,\n get,\n _getForce,\n };\n}\n\nexport function getFiles(\n mode: string | undefined,\n { silent = false }: Pick<LoadOptions, 'silent'> = {}\n): string[] {\n if (!isEnabled()) {\n debug(`Skipping .env files because EXPO_NO_DOTENV is defined`);\n return [];\n }\n\n if (!mode) {\n if (silent) {\n debug('NODE_ENV is not defined, proceeding without mode-specific .env');\n } else {\n console.error(\n chalk.red(\n 'The NODE_ENV environment variable is required but was not specified. Ensure the project is bundled with Expo CLI or NODE_ENV is set.'\n )\n );\n console.error(chalk.red('Proceeding without mode-specific .env'));\n }\n }\n\n if (mode && !['development', 'test', 'production'].includes(mode)) {\n throw new Error(\n `Environment variable \"NODE_ENV=${mode}\" is invalid. Valid values are \"development\", \"test\", and \"production`\n );\n }\n\n if (!mode) {\n // Support environments that don't respect NODE_ENV\n return [`.env.local`, '.env'];\n }\n // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use\n const dotenvFiles = [\n `.env.${mode}.local`,\n // Don't include `.env.local` for `test` environment\n // since normally you expect tests to produce the same\n // results for everyone\n mode !== 'test' && `.env.local`,\n `.env.${mode}`,\n '.env',\n ].filter(Boolean) as string[];\n\n return dotenvFiles;\n}\n"],"mappings":";;;;;;;;AAMA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,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AAI,KAAK,MAAM,IAAK,YAAW,EAC9B,QAAOA,IAAK,EAAC,EACd,MAAM,CACP,CAACI,MAAM,CAACC,OAAO,CAAa;EAE7B,OAAOrC,WAAW;AACpB"}
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Copyright © 2023 650 Industries.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { getFiles, isEnabled } from './env';
9
+ declare const get: (projectRoot: string, options?: {
10
+ silent?: boolean | undefined;
11
+ force?: boolean | undefined;
12
+ }) => {
13
+ env: Record<string, string | undefined>;
14
+ files: string[];
15
+ }, load: (projectRoot: string, options?: {
16
+ silent?: boolean | undefined;
17
+ force?: boolean | undefined;
18
+ }) => NodeJS.ProcessEnv;
19
+ export { getFiles, get, load, isEnabled };
package/build/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.get = void 0;
7
+ Object.defineProperty(exports, "getFiles", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _env().getFiles;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "isEnabled", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _env().isEnabled;
17
+ }
18
+ });
19
+ exports.load = void 0;
20
+ function _env() {
21
+ const data = require("./env");
22
+ _env = function () {
23
+ return data;
24
+ };
25
+ return data;
26
+ }
27
+ /**
28
+ * Copyright © 2023 650 Industries.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+
34
+ const {
35
+ get,
36
+ load
37
+ } = (0, _env().createControlledEnvironment)();
38
+ exports.load = load;
39
+ exports.get = get;
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_env","data","require","get","load","createControlledEnvironment","exports"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { createControlledEnvironment, getFiles, isEnabled } from './env';\n\nconst { get, load } = createControlledEnvironment();\n\nexport { getFiles, get, load, isEnabled };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAM;EAAEE,GAAG;EAAEC;AAAK,CAAC,GAAG,IAAAC,kCAA2B,GAAE;AAACC,OAAA,CAAAF,IAAA,GAAAA,IAAA;AAAAE,OAAA,CAAAH,GAAA,GAAAA,GAAA"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@expo/env",
3
+ "version": "0.0.0-canary-20231122-1af9191",
4
+ "description": "hydrate environment variables from .env files into process.env",
5
+ "main": "build/index.js",
6
+ "scripts": {
7
+ "build": "tsc --emitDeclarationOnly && babel src --out-dir build --extensions \".ts\" --source-maps --ignore \"src/**/__mocks__/*\",\"src/**/__tests__/*\"",
8
+ "clean": "expo-module clean",
9
+ "lint": "expo-module lint",
10
+ "prepare": "expo-module clean && yarn run build",
11
+ "prepublishOnly": "expo-module prepublishOnly",
12
+ "test": "expo-module test",
13
+ "typecheck": "expo-module typecheck"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/expo/expo.git",
18
+ "directory": "packages/@expo/env"
19
+ },
20
+ "keywords": [],
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/expo/expo/issues"
24
+ },
25
+ "homepage": "https://github.com/expo/expo/tree/main/packages/@expo/env#readme",
26
+ "files": [
27
+ "build"
28
+ ],
29
+ "dependencies": {
30
+ "dotenv": "~16.0.3",
31
+ "dotenv-expand": "~10.0.0",
32
+ "chalk": "^4.0.0",
33
+ "debug": "^4.3.4",
34
+ "getenv": "^1.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@babel/core": "^7.15.5",
38
+ "@types/getenv": "^1.0.0",
39
+ "expo-module-scripts": "0.0.0-canary-20231122-1af9191"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "gitHead": "1af91912cdf13b6f7fa0a8207dc9f024132a9a72"
45
+ }