@expo/env 0.0.0 → 0.0.1
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 +21 -0
- package/README.md +3 -0
- package/build/env.d.ts +17 -0
- package/build/env.js +154 -0
- package/build/env.js.map +1 -0
- package/build/index.d.ts +14 -0
- package/build/index.js +34 -0
- package/build/index.js.map +1 -0
- package/package.json +33 -6
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
package/build/env.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2023 650 Industries.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
export declare function createControlledEnvironment(): {
|
|
9
|
+
load: (projectRoot: string, { force }?: {
|
|
10
|
+
force?: boolean | undefined;
|
|
11
|
+
}) => NodeJS.ProcessEnv;
|
|
12
|
+
get: (projectRoot: string, { force }?: {
|
|
13
|
+
force?: boolean | undefined;
|
|
14
|
+
}) => Record<string, string | undefined>;
|
|
15
|
+
_getForce: (projectRoot: string) => Record<string, string | undefined>;
|
|
16
|
+
};
|
|
17
|
+
export declare function getFiles(mode: string | undefined): string[];
|
package/build/env.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createControlledEnvironment = createControlledEnvironment;
|
|
7
|
+
exports.getFiles = getFiles;
|
|
8
|
+
function dotenv() {
|
|
9
|
+
const data = _interopRequireWildcard(require("dotenv"));
|
|
10
|
+
dotenv = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _dotenvExpand() {
|
|
16
|
+
const data = require("dotenv-expand");
|
|
17
|
+
_dotenvExpand = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function fs() {
|
|
23
|
+
const data = _interopRequireWildcard(require("fs"));
|
|
24
|
+
fs = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function path() {
|
|
30
|
+
const data = _interopRequireWildcard(require("path"));
|
|
31
|
+
path = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
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); }
|
|
37
|
+
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; }
|
|
38
|
+
/**
|
|
39
|
+
* Copyright © 2023 650 Industries.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const debug = require('debug')('expo:env');
|
|
46
|
+
function createControlledEnvironment() {
|
|
47
|
+
const IS_DEBUG = require('debug').enabled('expo:env');
|
|
48
|
+
let userDefinedEnvironment = undefined;
|
|
49
|
+
let memoEnvironment = undefined;
|
|
50
|
+
function _getForce(projectRoot) {
|
|
51
|
+
if (!userDefinedEnvironment) {
|
|
52
|
+
userDefinedEnvironment = {
|
|
53
|
+
...process.env
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
58
|
+
const dotenvFiles = getFiles(process.env.NODE_ENV);
|
|
59
|
+
const loadedEnvFiles = [];
|
|
60
|
+
const parsed = {};
|
|
61
|
+
|
|
62
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
63
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
64
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
65
|
+
// https://github.com/motdotla/dotenv
|
|
66
|
+
// https://github.com/motdotla/dotenv-expand
|
|
67
|
+
dotenvFiles.forEach(dotenvFile => {
|
|
68
|
+
const absoluteDotenvFile = path().resolve(projectRoot, dotenvFile);
|
|
69
|
+
if (!fs().existsSync(absoluteDotenvFile)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const results = (0, _dotenvExpand().expand)(dotenv().config({
|
|
74
|
+
debug: IS_DEBUG,
|
|
75
|
+
path: absoluteDotenvFile,
|
|
76
|
+
// We will handle overriding ourselves to allow for HMR.
|
|
77
|
+
override: true
|
|
78
|
+
}));
|
|
79
|
+
if (results.parsed) {
|
|
80
|
+
loadedEnvFiles.push(absoluteDotenvFile);
|
|
81
|
+
debug(`Loaded environment variables from: ${absoluteDotenvFile}`);
|
|
82
|
+
for (const key of Object.keys(results.parsed || {})) {
|
|
83
|
+
var _userDefinedEnvironme;
|
|
84
|
+
if (typeof parsed[key] === 'undefined' &&
|
|
85
|
+
// Custom override logic to prevent overriding variables that
|
|
86
|
+
// were set before the CLI process began.
|
|
87
|
+
typeof ((_userDefinedEnvironme = userDefinedEnvironment) === null || _userDefinedEnvironme === void 0 ? void 0 : _userDefinedEnvironme[key]) === 'undefined') {
|
|
88
|
+
parsed[key] = results.parsed[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
debug(`Failed to load environment variables from: ${absoluteDotenvFile}`);
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
console.error(`Failed to load environment variables from ${absoluteDotenvFile}: ${error.message}`);
|
|
97
|
+
} else {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
if (!loadedEnvFiles.length) {
|
|
103
|
+
debug(`No environment variables loaded from .env files.`);
|
|
104
|
+
}
|
|
105
|
+
return parsed;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Get the environment variables without mutating the environment. This returns memoized values unless the `force` property is provided. */
|
|
109
|
+
function get(projectRoot, {
|
|
110
|
+
force
|
|
111
|
+
} = {}) {
|
|
112
|
+
if (!force && memoEnvironment) {
|
|
113
|
+
return memoEnvironment;
|
|
114
|
+
}
|
|
115
|
+
memoEnvironment = _getForce(projectRoot);
|
|
116
|
+
return memoEnvironment;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Load environment variables from .env files and mutate the current `process.env` with the results. */
|
|
120
|
+
function load(projectRoot, {
|
|
121
|
+
force
|
|
122
|
+
} = {}) {
|
|
123
|
+
const env = get(projectRoot, {
|
|
124
|
+
force
|
|
125
|
+
});
|
|
126
|
+
process.env = {
|
|
127
|
+
...process.env,
|
|
128
|
+
...env
|
|
129
|
+
};
|
|
130
|
+
return process.env;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
load,
|
|
134
|
+
get,
|
|
135
|
+
_getForce
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function getFiles(mode) {
|
|
139
|
+
if (!mode) {
|
|
140
|
+
throw new Error('The NODE_ENV environment variable is required but was not specified. Ensure the project is bundled with Expo CLI.');
|
|
141
|
+
}
|
|
142
|
+
if (!mode || !['development', 'test', 'production'].includes(mode)) {
|
|
143
|
+
throw new Error(`Environment variable "NODE_ENV=${mode}" is invalid. Valid values are "development", "test", and "production`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
147
|
+
const dotenvFiles = [`.env.${mode}.local`,
|
|
148
|
+
// Don't include `.env.local` for `test` environment
|
|
149
|
+
// since normally you expect tests to produce the same
|
|
150
|
+
// results for everyone
|
|
151
|
+
mode !== 'test' && `.env.local`, `.env.${mode}`, '.env'].filter(Boolean);
|
|
152
|
+
return dotenvFiles;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=env.js.map
|
package/build/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","names":["dotenv","data","_interopRequireWildcard","require","_dotenvExpand","fs","path","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","debug","createControlledEnvironment","IS_DEBUG","enabled","userDefinedEnvironment","undefined","memoEnvironment","_getForce","projectRoot","process","env","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","mode","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 */\n\nimport * as dotenv from 'dotenv';\nimport { expand } from 'dotenv-expand';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nconst debug = require('debug')('expo:env') as typeof console.log;\n\nexport function createControlledEnvironment() {\n const IS_DEBUG = require('debug').enabled('expo:env');\n\n let userDefinedEnvironment: NodeJS.ProcessEnv | undefined = undefined;\n let memoEnvironment: NodeJS.ProcessEnv | undefined = undefined;\n\n function _getForce(projectRoot: string): Record<string, string | undefined> {\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);\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 parsed;\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 { force }: { force?: boolean } = {}\n ): Record<string, string | undefined> {\n if (!force && memoEnvironment) {\n return memoEnvironment;\n }\n memoEnvironment = _getForce(projectRoot);\n return memoEnvironment;\n }\n\n /** Load environment variables from .env files and mutate the current `process.env` with the results. */\n function load(projectRoot: string, { force }: { force?: boolean } = {}) {\n const env = get(projectRoot, { force });\n process.env = { ...process.env, ...env };\n return process.env;\n }\n\n return {\n load,\n get,\n _getForce,\n };\n}\n\nexport function getFiles(mode: string | undefined): string[] {\n if (!mode) {\n throw new Error(\n 'The NODE_ENV environment variable is required but was not specified. Ensure the project is bundled with Expo CLI.'\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 // 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":";;;;;;;AAOA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,GAAA;EAAA,MAAAJ,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAE,EAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6B,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAA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AAO;EACpB;EACA;EACA;EACAA,IAAI,KAAK,MAAM,IAAK,YAAW,EAC9B,QAAOA,IAAK,EAAC,EACd,MAAM,CACP,CAACE,MAAM,CAACC,OAAO,CAAa;EAE7B,OAAO3B,WAAW;AACpB"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 } from './env';
|
|
9
|
+
declare const get: (projectRoot: string, { force }?: {
|
|
10
|
+
force?: boolean | undefined;
|
|
11
|
+
}) => Record<string, string | undefined>, load: (projectRoot: string, { force }?: {
|
|
12
|
+
force?: boolean | undefined;
|
|
13
|
+
}) => NodeJS.ProcessEnv;
|
|
14
|
+
export { getFiles, get, load };
|
package/build/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
exports.load = void 0;
|
|
14
|
+
function _env() {
|
|
15
|
+
const data = require("./env");
|
|
16
|
+
_env = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Copyright © 2023 650 Industries.
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the MIT license found in the
|
|
25
|
+
* LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
get,
|
|
30
|
+
load
|
|
31
|
+
} = (0, _env().createControlledEnvironment)();
|
|
32
|
+
exports.load = load;
|
|
33
|
+
exports.get = get;
|
|
34
|
+
//# 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 } from './env';\n\nconst { get, load } = createControlledEnvironment();\n\nexport { getFiles, get, load };\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
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/env",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "hydrate environment variables from .env files into process.env",
|
|
5
|
+
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"watch": "tsc --watch --preserveWatchOutput",
|
|
8
|
+
"build": "tsc --emitDeclarationOnly && babel src --out-dir build --extensions \".ts\" --source-maps --ignore \"src/**/__mocks__/*\",\"src/**/__tests__/*\"",
|
|
9
|
+
"prepare": "yarn run clean && yarn build",
|
|
10
|
+
"clean": "rimraf build ./tsconfig.tsbuildinfo",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"test": "jest"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/expo/expo.git",
|
|
17
|
+
"directory": "packages/@expo/env"
|
|
8
18
|
},
|
|
9
19
|
"keywords": [],
|
|
10
|
-
"
|
|
11
|
-
"
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/expo/expo/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/env#readme",
|
|
25
|
+
"files": [
|
|
26
|
+
"build"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"dotenv": "~16.0.3",
|
|
30
|
+
"dotenv-expand": "~10.0.0",
|
|
31
|
+
"debug": "^4.3.4"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.15.5"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
12
39
|
}
|