@mono-labs/cli 0.0.222 → 0.0.226

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.
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterUnwantedEnvVars = filterUnwantedEnvVars;
4
+ exports.filterUnwantedEnvVarsEAS = filterUnwantedEnvVarsEAS;
5
+ exports.generateNewEnvList = generateNewEnvList;
6
+ const loadFromRoot_1 = require("../loadFromRoot");
7
+ function filterUnwantedEnvVars(env) {
8
+ const unwantedPrefixes = [
9
+ // 'EFC_',
10
+ // 'FPS_',
11
+ // 'GIT_',
12
+ // 'NVM_',
13
+ // 'VSCODE_',
14
+ // 'LOGONSERVER',
15
+ // 'NUMBER_OF_PROCESSORS',
16
+ // 'OS',
17
+ // 'COREPACK',
18
+ // 'PROCESSOR',
19
+ // 'USERDOMAIN',
20
+ // 'USERDOMAIN_ROAMINGPROFILE',
21
+ // 'USERNAME',
22
+ // 'CUDA',
23
+ // 'SESSIONNAME',
24
+ // 'ZES',
25
+ // '3DVPATH',
26
+ // 'APP_NAME',
27
+ // 'asl.log',
28
+ // 'BERRY_BIN_FOLDER',
29
+ // 'CHROME_CRASHPAD_PIPE_NAME',
30
+ // 'COLORTERM',
31
+ // 'COMPUTERNAME',
32
+ // 'CUDNN',
33
+ // 'EAS_BUILD_PROFILE',
34
+ // 'EAS_PROJECT_ID',
35
+ // 'EXPO_UNSTABLE_ATLAS',
36
+ // 'INIT_CWD',
37
+ // 'JAVA_HOME',
38
+ // 'LANG',
39
+ // 'OneDrive',
40
+ // 'ORIGINAL_XDG_CURRENT_DESKTOP',
41
+ // 'PROJECT_CWD',
42
+ // 'PROMPT',
43
+ // 'PWD',
44
+ // 'TERM_PROGRAM',
45
+ // 'TERM_PROGRAM_VERSION',
46
+ // '__PSLockDownPolicy',
47
+ 'npm_config_force',
48
+ ];
49
+ return Object.keys(env).reduce((obj, key) => {
50
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
51
+ obj[key] = env[key];
52
+ }
53
+ return obj;
54
+ }, {});
55
+ }
56
+ function filterUnwantedEnvVarsEAS(env) {
57
+ const unwantedPrefixes = [
58
+ 'ProgramData',
59
+ 'ProgramFiles',
60
+ 'ProgramFiles(x86)',
61
+ 'ProgramW6432',
62
+ 'PSModulePath',
63
+ 'PUBLIC',
64
+ 'TEMP',
65
+ 'TMP',
66
+ 'EFC_',
67
+ 'FPS_',
68
+ 'GIT_',
69
+ 'NVM_',
70
+ 'VSCODE_',
71
+ 'windir',
72
+ 'Chocolatey',
73
+ 'ALLUSERSPROFILE',
74
+ 'APPDATA',
75
+ 'CommonProgramFiles',
76
+ 'CommonProgramW6432',
77
+ 'ComSpec',
78
+ 'Driver',
79
+ 'HOME',
80
+ 'npm',
81
+ 'HOME',
82
+ 'LOCALAPPDATA',
83
+ 'LOGONSERVER',
84
+ 'NUMBER_OF_PROCESSORS',
85
+ 'OS',
86
+ 'COREPACK',
87
+ 'PROCESSOR',
88
+ 'USERDOMAIN',
89
+ 'USERDOMAIN_ROAMINGPROFILE',
90
+ 'USERNAME',
91
+ 'USERPROFILE',
92
+ 'CUDA',
93
+ 'SESSIONNAME',
94
+ 'ZES',
95
+ '3DVPATH',
96
+ 'APP_NAME',
97
+ 'asl.log',
98
+ 'BERRY_BIN_FOLDER',
99
+ 'CHROME_CRASHPAD_PIPE_NAME',
100
+ 'COLORTERM',
101
+ 'COMPUTERNAME',
102
+ 'CUDNN',
103
+ 'EAS_BUILD_PROFILE',
104
+ 'EAS_PROJECT_ID',
105
+ 'EXPO_UNSTABLE_ATLAS',
106
+ 'INIT_CWD',
107
+ 'JAVA_HOME',
108
+ 'LANG',
109
+ 'OneDrive',
110
+ 'ORIGINAL_XDG_CURRENT_DESKTOP',
111
+ 'PROJECT_CWD',
112
+ 'PROMPT',
113
+ 'PWD',
114
+ 'TERM_PROGRAM',
115
+ 'TERM_PROGRAM_VERSION',
116
+ '__PSLockDownPolicy',
117
+ 'PATH',
118
+ 'SystemRoot',
119
+ 'SystemDrive',
120
+ 'npm_',
121
+ ];
122
+ return Object.keys(env).reduce((obj, key) => {
123
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
124
+ obj[key] = env[key];
125
+ }
126
+ return obj;
127
+ }, {});
128
+ }
129
+ function generateNewEnvList(processEnv) {
130
+ const { config } = (0, loadFromRoot_1.getMonoConfig)();
131
+ const envPrefixes = Array.isArray(config.envMap) ? config.envMap : [];
132
+ const result = { ...processEnv };
133
+ for (const [key, value] of Object.entries(processEnv)) {
134
+ // Only clone MONO_ variables
135
+ if (!key.startsWith('MONO_'))
136
+ continue;
137
+ // Skip secrets
138
+ if (key.includes('SECRET'))
139
+ continue;
140
+ const suffix = key.slice('MONO_'.length);
141
+ for (const prefix of envPrefixes) {
142
+ const mappedKey = `${prefix}_${suffix}`;
143
+ result[mappedKey] = value;
144
+ }
145
+ }
146
+ return result;
147
+ }
package/dist/expo.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replaceTokens = replaceTokens;
4
4
  exports.setUpConfig = setUpConfig;
5
+ exports.filterUnwantedEnvVarsEAS = filterUnwantedEnvVarsEAS;
5
6
  function replaceTokens(str, env) {
6
7
  if (typeof str !== 'string')
7
8
  return str;
@@ -53,3 +54,76 @@ function setUpConfig(config) {
53
54
  };
54
55
  return appConfig;
55
56
  }
57
+ function filterUnwantedEnvVarsEAS(env) {
58
+ const unwantedPrefixes = [
59
+ 'ProgramData',
60
+ 'ProgramFiles',
61
+ 'ProgramFiles(x86)',
62
+ 'ProgramW6432',
63
+ 'PSModulePath',
64
+ 'PUBLIC',
65
+ 'TEMP',
66
+ 'TMP',
67
+ 'EFC_',
68
+ 'FPS_',
69
+ 'GIT_',
70
+ 'NVM_',
71
+ 'VSCODE_',
72
+ 'windir',
73
+ 'Chocolatey',
74
+ 'ALLUSERSPROFILE',
75
+ 'APPDATA',
76
+ 'CommonProgramFiles',
77
+ 'CommonProgramW6432',
78
+ 'ComSpec',
79
+ 'Driver',
80
+ 'HOME',
81
+ 'npm',
82
+ 'HOME',
83
+ 'LOCALAPPDATA',
84
+ 'LOGONSERVER',
85
+ 'NUMBER_OF_PROCESSORS',
86
+ 'OS',
87
+ 'COREPACK',
88
+ 'PROCESSOR',
89
+ 'USERDOMAIN',
90
+ 'USERDOMAIN_ROAMINGPROFILE',
91
+ 'USERNAME',
92
+ 'USERPROFILE',
93
+ 'CUDA',
94
+ 'SESSIONNAME',
95
+ 'ZES',
96
+ '3DVPATH',
97
+ 'APP_NAME',
98
+ 'asl.log',
99
+ 'BERRY_BIN_FOLDER',
100
+ 'CHROME_CRASHPAD_PIPE_NAME',
101
+ 'COLORTERM',
102
+ 'COMPUTERNAME',
103
+ 'CUDNN',
104
+ 'EAS_BUILD_PROFILE',
105
+ 'EAS_PROJECT_ID',
106
+ 'EXPO_UNSTABLE_ATLAS',
107
+ 'INIT_CWD',
108
+ 'JAVA_HOME',
109
+ 'LANG',
110
+ 'OneDrive',
111
+ 'ORIGINAL_XDG_CURRENT_DESKTOP',
112
+ 'PROJECT_CWD',
113
+ 'PROMPT',
114
+ 'PWD',
115
+ 'TERM_PROGRAM',
116
+ 'TERM_PROGRAM_VERSION',
117
+ '__PSLockDownPolicy',
118
+ 'PATH',
119
+ 'SystemRoot',
120
+ 'SystemDrive',
121
+ 'npm_',
122
+ ];
123
+ return Object.keys(env).reduce((obj, key) => {
124
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
125
+ obj[key] = env[key];
126
+ }
127
+ return obj;
128
+ }, {});
129
+ }
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // Main entry point for @mono-labs/cli package
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.filterUnwantedEnvVarsEAS = exports.filterUnwantedEnvVars = exports.generateNewEnvList = void 0;
5
+ exports.setData = setData;
6
+ exports.mergeData = mergeData;
7
+ exports.getData = getData;
8
+ exports.hasData = hasData;
9
+ exports.replaceTokens = replaceTokens;
10
+ const filterUnwantedEnvVars_js_1 = require("./expo-files/filterUnwantedEnvVars.js");
11
+ Object.defineProperty(exports, "filterUnwantedEnvVars", { enumerable: true, get: function () { return filterUnwantedEnvVars_js_1.filterUnwantedEnvVars; } });
12
+ Object.defineProperty(exports, "filterUnwantedEnvVarsEAS", { enumerable: true, get: function () { return filterUnwantedEnvVars_js_1.filterUnwantedEnvVarsEAS; } });
13
+ Object.defineProperty(exports, "generateNewEnvList", { enumerable: true, get: function () { return filterUnwantedEnvVars_js_1.generateNewEnvList; } });
14
+ const dataLayer = Object.create(null);
15
+ function setData(key, value) {
16
+ if (value !== undefined) {
17
+ dataLayer[key] = value;
18
+ }
19
+ }
20
+ function mergeData(obj = {}) {
21
+ Object.entries(obj).forEach(([k, v]) => setData(k, v));
22
+ return dataLayer;
23
+ }
24
+ function getData(key) {
25
+ return key ? dataLayer[key] : dataLayer;
26
+ }
27
+ function hasData(key) {
28
+ return Object.prototype.hasOwnProperty.call(dataLayer, key);
29
+ }
30
+ /* ------------------------------------------------------------------
31
+ * Token replacement
32
+ * ------------------------------------------------------------------ */
33
+ function replaceTokens(str, env) {
34
+ if (typeof str !== 'string')
35
+ return str;
36
+ return str.replace(/\$\{([^}]+)\}|\$([A-Z0-9_]+)/g, (_match, k1, k2) => {
37
+ const key = k1 || k2;
38
+ // data layer takes priority
39
+ if (hasData(key)) {
40
+ const val = getData(key);
41
+ return val == null ? '' : String(val);
42
+ }
43
+ // environment variables
44
+ if (env && Object.prototype.hasOwnProperty.call(env, key)) {
45
+ const val = env[key];
46
+ return val == null ? '' : String(val);
47
+ }
48
+ return '';
49
+ });
50
+ }
51
+ exports.default = {
52
+ generateNewEnvList: filterUnwantedEnvVars_js_1.generateNewEnvList,
53
+ replaceTokens,
54
+ filterUnwantedEnvVars: filterUnwantedEnvVars_js_1.filterUnwantedEnvVars,
55
+ filterUnwantedEnvVarsEAS: filterUnwantedEnvVars_js_1.filterUnwantedEnvVarsEAS,
56
+ };
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findProjectRoot = findProjectRoot;
7
+ exports.getRootDirectory = getRootDirectory;
8
+ exports.getRootJson = getRootJson;
9
+ exports.resolveMonoDirectory = resolveMonoDirectory;
10
+ exports.getMonoFiles = getMonoFiles;
11
+ exports.getMonoConfig = getMonoConfig;
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ /* ------------------------------------------------------------------
15
+ * Helpers
16
+ * ------------------------------------------------------------------ */
17
+ /**
18
+ * Walk up from cwd until we find a directory containing package.json.
19
+ * This is treated as the project root.
20
+ */
21
+ function findProjectRoot(startDir = process.cwd()) {
22
+ let current = startDir;
23
+ while (true) {
24
+ const pkg = path_1.default.join(current, 'package.json');
25
+ if (fs_1.default.existsSync(pkg))
26
+ return current;
27
+ const parent = path_1.default.dirname(current);
28
+ if (parent === current)
29
+ break;
30
+ current = parent;
31
+ }
32
+ // Fallback: use cwd
33
+ return startDir;
34
+ }
35
+ function getRootDirectory() {
36
+ return findProjectRoot();
37
+ }
38
+ function getRootJson() {
39
+ const root = getRootDirectory();
40
+ const jsonPath = path_1.default.join(root, 'package.json');
41
+ if (!fs_1.default.existsSync(jsonPath)) {
42
+ throw new Error(`package.json not found in ${root}`);
43
+ }
44
+ return JSON.parse(fs_1.default.readFileSync(jsonPath, 'utf-8'));
45
+ }
46
+ /* ------------------------------------------------------------------
47
+ * Mono (.mono) handling
48
+ * ------------------------------------------------------------------ */
49
+ const DISALLOWED_FILES = new Set(['tools']);
50
+ function readJsonFile(filePath) {
51
+ return JSON.parse(fs_1.default.readFileSync(filePath, 'utf-8'));
52
+ }
53
+ /**
54
+ * Resolve the .mono directory.
55
+ * Priority:
56
+ * 1. project root/.mono
57
+ * 2. cwd/.mono
58
+ */
59
+ function resolveMonoDirectory() {
60
+ const root = getRootDirectory();
61
+ const rootMono = path_1.default.join(root, '.mono');
62
+ if (fs_1.default.existsSync(rootMono))
63
+ return rootMono;
64
+ const cwdMono = path_1.default.join(process.cwd(), '.mono');
65
+ if (fs_1.default.existsSync(cwdMono))
66
+ return cwdMono;
67
+ return null;
68
+ }
69
+ function getMonoFiles() {
70
+ const dir = resolveMonoDirectory();
71
+ if (!dir)
72
+ return [];
73
+ return fs_1.default
74
+ .readdirSync(dir)
75
+ .filter((f) => f.endsWith('.json'))
76
+ .map((f) => path_1.default.join(dir, f));
77
+ }
78
+ /**
79
+ * Load and validate mono configuration.
80
+ */
81
+ function getMonoConfig() {
82
+ const monoDir = resolveMonoDirectory();
83
+ if (!monoDir) {
84
+ return {
85
+ files: {},
86
+ config: {
87
+ envMap: [],
88
+ workspace: { packageMaps: {} },
89
+ prodFlag: 'live',
90
+ },
91
+ };
92
+ }
93
+ const files = {};
94
+ let config = {
95
+ envMap: [],
96
+ workspace: { packageMaps: {} },
97
+ prodFlag: 'live',
98
+ };
99
+ for (const filePath of getMonoFiles()) {
100
+ const fileName = path_1.default.basename(filePath, '.json');
101
+ if (DISALLOWED_FILES.has(fileName)) {
102
+ throw new Error(`Disallowed file name in .mono directory: ${fileName}`);
103
+ }
104
+ const data = readJsonFile(filePath);
105
+ if (fileName === 'config') {
106
+ if (typeof data === 'object' && data !== null) {
107
+ config = data;
108
+ }
109
+ }
110
+ else {
111
+ files[fileName] = data;
112
+ }
113
+ }
114
+ return { files, config };
115
+ }
@@ -11,6 +11,8 @@ const requiredSystemDefaults = {
11
11
  ec2User: 'ec2-user',
12
12
  regions: ['us-east-1'],
13
13
  warehouseRegion: 'us-east-1',
14
+ dbInstanceType: 't3.micro',
15
+ appInstanceType: 't3.micro',
14
16
  };
15
17
  /* ──────────────────────────────────────────────────────────
16
18
  * Environment helpers
@@ -0,0 +1,3 @@
1
+ export declare function filterUnwantedEnvVars(env: Record<string, string>): Record<string, string>;
2
+ export declare function filterUnwantedEnvVarsEAS(env: Record<string, string>): Record<string, string>;
3
+ export declare function generateNewEnvList(processEnv: Record<string, string>): Record<string, string>;
@@ -1,2 +1,3 @@
1
1
  export function replaceTokens(str: any, env: any): any;
2
2
  export function setUpConfig(config: any): any;
3
+ export function filterUnwantedEnvVarsEAS(env: any): {};
@@ -0,0 +1,15 @@
1
+ import { filterUnwantedEnvVars, filterUnwantedEnvVarsEAS, generateNewEnvList } from './expo-files/filterUnwantedEnvVars.js';
2
+ type DataLayer = Record<string, unknown>;
3
+ export declare function setData(key: string, value: unknown): void;
4
+ export declare function mergeData(obj?: Record<string, unknown>): DataLayer;
5
+ export declare function getData(key?: string): unknown;
6
+ export declare function hasData(key: string): boolean;
7
+ export declare function replaceTokens(str: unknown, env?: Record<string, string | undefined>): unknown;
8
+ export { generateNewEnvList, filterUnwantedEnvVars, filterUnwantedEnvVarsEAS };
9
+ declare const _default: {
10
+ generateNewEnvList: typeof generateNewEnvList;
11
+ replaceTokens: typeof replaceTokens;
12
+ filterUnwantedEnvVars: typeof filterUnwantedEnvVars;
13
+ filterUnwantedEnvVarsEAS: typeof filterUnwantedEnvVarsEAS;
14
+ };
15
+ export default _default;
@@ -0,0 +1,32 @@
1
+ export interface MonoWorkspaceConfig {
2
+ packageMaps: Record<string, string>;
3
+ }
4
+ export interface MonoProjectConfig {
5
+ envMap: string[];
6
+ workspace: MonoWorkspaceConfig;
7
+ prodFlag: string;
8
+ }
9
+ export type MonoFiles = Record<string, unknown>;
10
+ export interface MonoConfig {
11
+ config: MonoProjectConfig;
12
+ files: MonoFiles;
13
+ }
14
+ /**
15
+ * Walk up from cwd until we find a directory containing package.json.
16
+ * This is treated as the project root.
17
+ */
18
+ export declare function findProjectRoot(startDir?: string): string;
19
+ export declare function getRootDirectory(): string;
20
+ export declare function getRootJson(): Record<string, unknown>;
21
+ /**
22
+ * Resolve the .mono directory.
23
+ * Priority:
24
+ * 1. project root/.mono
25
+ * 2. cwd/.mono
26
+ */
27
+ export declare function resolveMonoDirectory(): string | null;
28
+ export declare function getMonoFiles(): string[];
29
+ /**
30
+ * Load and validate mono configuration.
31
+ */
32
+ export declare function getMonoConfig(): MonoConfig;
@@ -20,6 +20,8 @@ type DefaultDeployConfig = {
20
20
  regions: string[];
21
21
  ec2User: string;
22
22
  warehouseRegion: string;
23
+ dbInstanceType: string;
24
+ appInstanceType: string;
23
25
  };
24
26
  type ConfigTypeMap = {
25
27
  app: DefaultAppConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.222",
3
+ "version": "0.0.226",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types.d.ts",
@@ -0,0 +1,158 @@
1
+ import { getMonoConfig } from '../loadFromRoot';
2
+
3
+ export function filterUnwantedEnvVars(env: Record<string, string>) {
4
+ const unwantedPrefixes = [
5
+ // 'EFC_',
6
+ // 'FPS_',
7
+ // 'GIT_',
8
+ // 'NVM_',
9
+ // 'VSCODE_',
10
+ // 'LOGONSERVER',
11
+ // 'NUMBER_OF_PROCESSORS',
12
+ // 'OS',
13
+ // 'COREPACK',
14
+ // 'PROCESSOR',
15
+ // 'USERDOMAIN',
16
+ // 'USERDOMAIN_ROAMINGPROFILE',
17
+ // 'USERNAME',
18
+ // 'CUDA',
19
+ // 'SESSIONNAME',
20
+ // 'ZES',
21
+ // '3DVPATH',
22
+ // 'APP_NAME',
23
+ // 'asl.log',
24
+ // 'BERRY_BIN_FOLDER',
25
+ // 'CHROME_CRASHPAD_PIPE_NAME',
26
+ // 'COLORTERM',
27
+ // 'COMPUTERNAME',
28
+ // 'CUDNN',
29
+ // 'EAS_BUILD_PROFILE',
30
+ // 'EAS_PROJECT_ID',
31
+ // 'EXPO_UNSTABLE_ATLAS',
32
+ // 'INIT_CWD',
33
+ // 'JAVA_HOME',
34
+ // 'LANG',
35
+ // 'OneDrive',
36
+ // 'ORIGINAL_XDG_CURRENT_DESKTOP',
37
+ // 'PROJECT_CWD',
38
+ // 'PROMPT',
39
+ // 'PWD',
40
+ // 'TERM_PROGRAM',
41
+ // 'TERM_PROGRAM_VERSION',
42
+ // '__PSLockDownPolicy',
43
+ 'npm_config_force',
44
+ ];
45
+ return Object.keys(env).reduce(
46
+ (obj, key) => {
47
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
48
+ obj[key] = env[key];
49
+ }
50
+ return obj;
51
+ },
52
+ {} as Record<string, string>
53
+ );
54
+ }
55
+
56
+ export function filterUnwantedEnvVarsEAS(env: Record<string, string>) {
57
+ const unwantedPrefixes = [
58
+ 'ProgramData',
59
+ 'ProgramFiles',
60
+ 'ProgramFiles(x86)',
61
+ 'ProgramW6432',
62
+ 'PSModulePath',
63
+ 'PUBLIC',
64
+ 'TEMP',
65
+ 'TMP',
66
+ 'EFC_',
67
+ 'FPS_',
68
+ 'GIT_',
69
+ 'NVM_',
70
+ 'VSCODE_',
71
+ 'windir',
72
+ 'Chocolatey',
73
+ 'ALLUSERSPROFILE',
74
+ 'APPDATA',
75
+ 'CommonProgramFiles',
76
+ 'CommonProgramW6432',
77
+ 'ComSpec',
78
+ 'Driver',
79
+ 'HOME',
80
+ 'npm',
81
+ 'HOME',
82
+ 'LOCALAPPDATA',
83
+ 'LOGONSERVER',
84
+ 'NUMBER_OF_PROCESSORS',
85
+ 'OS',
86
+ 'COREPACK',
87
+ 'PROCESSOR',
88
+ 'USERDOMAIN',
89
+ 'USERDOMAIN_ROAMINGPROFILE',
90
+ 'USERNAME',
91
+ 'USERPROFILE',
92
+ 'CUDA',
93
+ 'SESSIONNAME',
94
+ 'ZES',
95
+ '3DVPATH',
96
+ 'APP_NAME',
97
+ 'asl.log',
98
+ 'BERRY_BIN_FOLDER',
99
+ 'CHROME_CRASHPAD_PIPE_NAME',
100
+ 'COLORTERM',
101
+ 'COMPUTERNAME',
102
+ 'CUDNN',
103
+ 'EAS_BUILD_PROFILE',
104
+ 'EAS_PROJECT_ID',
105
+ 'EXPO_UNSTABLE_ATLAS',
106
+ 'INIT_CWD',
107
+ 'JAVA_HOME',
108
+ 'LANG',
109
+ 'OneDrive',
110
+ 'ORIGINAL_XDG_CURRENT_DESKTOP',
111
+ 'PROJECT_CWD',
112
+ 'PROMPT',
113
+ 'PWD',
114
+ 'TERM_PROGRAM',
115
+ 'TERM_PROGRAM_VERSION',
116
+ '__PSLockDownPolicy',
117
+ 'PATH',
118
+ 'SystemRoot',
119
+ 'SystemDrive',
120
+ 'npm_',
121
+ ];
122
+ return Object.keys(env).reduce(
123
+ (obj: Record<string, string>, key) => {
124
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
125
+ obj[key] = env[key];
126
+ }
127
+ return obj;
128
+ },
129
+ {} as Record<string, string>
130
+ );
131
+ }
132
+
133
+ export function generateNewEnvList(
134
+ processEnv: Record<string, string>
135
+ ): Record<string, string> {
136
+ const { config } = getMonoConfig();
137
+
138
+ const envPrefixes: string[] =
139
+ Array.isArray(config.envMap) ? config.envMap : [];
140
+
141
+ const result: Record<string, string> = { ...processEnv };
142
+
143
+ for (const [key, value] of Object.entries(processEnv)) {
144
+ // Only clone MONO_ variables
145
+ if (!key.startsWith('MONO_')) continue;
146
+
147
+ // Skip secrets
148
+ if (key.includes('SECRET')) continue;
149
+
150
+ const suffix = key.slice('MONO_'.length);
151
+
152
+ for (const prefix of envPrefixes) {
153
+ const mappedKey = `${prefix}_${suffix}`;
154
+ result[mappedKey] = value;
155
+ }
156
+ }
157
+ return result;
158
+ }
package/src/expo.d.ts CHANGED
@@ -5,3 +5,7 @@ export declare function replaceTokens(
5
5
  input: string,
6
6
  tokens: Record<string, string>
7
7
  ): string;
8
+
9
+ export declare function filterUnwantedEnvVarsEAS(
10
+ envVars: Record<string, string>
11
+ ): Record<string, string>;
package/src/expo.js CHANGED
@@ -57,3 +57,77 @@ export function setUpConfig(config) {
57
57
 
58
58
  return appConfig;
59
59
  }
60
+
61
+ export function filterUnwantedEnvVarsEAS(env) {
62
+ const unwantedPrefixes = [
63
+ 'ProgramData',
64
+ 'ProgramFiles',
65
+ 'ProgramFiles(x86)',
66
+ 'ProgramW6432',
67
+ 'PSModulePath',
68
+ 'PUBLIC',
69
+ 'TEMP',
70
+ 'TMP',
71
+ 'EFC_',
72
+ 'FPS_',
73
+ 'GIT_',
74
+ 'NVM_',
75
+ 'VSCODE_',
76
+ 'windir',
77
+ 'Chocolatey',
78
+ 'ALLUSERSPROFILE',
79
+ 'APPDATA',
80
+ 'CommonProgramFiles',
81
+ 'CommonProgramW6432',
82
+ 'ComSpec',
83
+ 'Driver',
84
+ 'HOME',
85
+ 'npm',
86
+ 'HOME',
87
+ 'LOCALAPPDATA',
88
+ 'LOGONSERVER',
89
+ 'NUMBER_OF_PROCESSORS',
90
+ 'OS',
91
+ 'COREPACK',
92
+ 'PROCESSOR',
93
+ 'USERDOMAIN',
94
+ 'USERDOMAIN_ROAMINGPROFILE',
95
+ 'USERNAME',
96
+ 'USERPROFILE',
97
+ 'CUDA',
98
+ 'SESSIONNAME',
99
+ 'ZES',
100
+ '3DVPATH',
101
+ 'APP_NAME',
102
+ 'asl.log',
103
+ 'BERRY_BIN_FOLDER',
104
+ 'CHROME_CRASHPAD_PIPE_NAME',
105
+ 'COLORTERM',
106
+ 'COMPUTERNAME',
107
+ 'CUDNN',
108
+ 'EAS_BUILD_PROFILE',
109
+ 'EAS_PROJECT_ID',
110
+ 'EXPO_UNSTABLE_ATLAS',
111
+ 'INIT_CWD',
112
+ 'JAVA_HOME',
113
+ 'LANG',
114
+ 'OneDrive',
115
+ 'ORIGINAL_XDG_CURRENT_DESKTOP',
116
+ 'PROJECT_CWD',
117
+ 'PROMPT',
118
+ 'PWD',
119
+ 'TERM_PROGRAM',
120
+ 'TERM_PROGRAM_VERSION',
121
+ '__PSLockDownPolicy',
122
+ 'PATH',
123
+ 'SystemRoot',
124
+ 'SystemDrive',
125
+ 'npm_',
126
+ ];
127
+ return Object.keys(env).reduce((obj, key) => {
128
+ if (!unwantedPrefixes.some((prefix) => key.startsWith(prefix))) {
129
+ obj[key] = env[key];
130
+ }
131
+ return obj;
132
+ }, {});
133
+ }
package/src/index.ts ADDED
@@ -0,0 +1,76 @@
1
+ // Main entry point for @mono-labs/cli package
2
+
3
+ import {
4
+ filterUnwantedEnvVars,
5
+ filterUnwantedEnvVarsEAS,
6
+ generateNewEnvList,
7
+ } from './expo-files/filterUnwantedEnvVars.js';
8
+
9
+ /* ------------------------------------------------------------------
10
+ * Internal data layer
11
+ * ------------------------------------------------------------------ */
12
+
13
+ type DataLayer = Record<string, unknown>;
14
+
15
+ const dataLayer: DataLayer = Object.create(null);
16
+
17
+ export function setData(key: string, value: unknown): void {
18
+ if (value !== undefined) {
19
+ dataLayer[key] = value;
20
+ }
21
+ }
22
+
23
+ export function mergeData(obj: Record<string, unknown> = {}): DataLayer {
24
+ Object.entries(obj).forEach(([k, v]) => setData(k, v));
25
+ return dataLayer;
26
+ }
27
+
28
+ export function getData(key?: string): unknown {
29
+ return key ? dataLayer[key] : dataLayer;
30
+ }
31
+
32
+ export function hasData(key: string): boolean {
33
+ return Object.prototype.hasOwnProperty.call(dataLayer, key);
34
+ }
35
+
36
+ /* ------------------------------------------------------------------
37
+ * Token replacement
38
+ * ------------------------------------------------------------------ */
39
+
40
+ export function replaceTokens(
41
+ str: unknown,
42
+ env?: Record<string, string | undefined>
43
+ ): unknown {
44
+ if (typeof str !== 'string') return str;
45
+
46
+ return str.replace(/\$\{([^}]+)\}|\$([A-Z0-9_]+)/g, (_match, k1, k2) => {
47
+ const key = k1 || k2;
48
+
49
+ // data layer takes priority
50
+ if (hasData(key)) {
51
+ const val = getData(key);
52
+ return val == null ? '' : String(val);
53
+ }
54
+
55
+ // environment variables
56
+ if (env && Object.prototype.hasOwnProperty.call(env, key)) {
57
+ const val = env[key];
58
+ return val == null ? '' : String(val);
59
+ }
60
+
61
+ return '';
62
+ });
63
+ }
64
+
65
+ /* ------------------------------------------------------------------
66
+ * Exports
67
+ * ------------------------------------------------------------------ */
68
+
69
+ export { generateNewEnvList, filterUnwantedEnvVars, filterUnwantedEnvVarsEAS };
70
+
71
+ export default {
72
+ generateNewEnvList,
73
+ replaceTokens,
74
+ filterUnwantedEnvVars,
75
+ filterUnwantedEnvVarsEAS,
76
+ };
@@ -0,0 +1,145 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ /* ------------------------------------------------------------------
5
+ * Types
6
+ * ------------------------------------------------------------------ */
7
+
8
+ export interface MonoWorkspaceConfig {
9
+ packageMaps: Record<string, string>;
10
+ }
11
+
12
+ export interface MonoProjectConfig {
13
+ envMap: string[];
14
+ workspace: MonoWorkspaceConfig;
15
+ prodFlag: string;
16
+ }
17
+
18
+ export type MonoFiles = Record<string, unknown>;
19
+
20
+ export interface MonoConfig {
21
+ config: MonoProjectConfig;
22
+ files: MonoFiles;
23
+ }
24
+
25
+ /* ------------------------------------------------------------------
26
+ * Helpers
27
+ * ------------------------------------------------------------------ */
28
+
29
+ /**
30
+ * Walk up from cwd until we find a directory containing package.json.
31
+ * This is treated as the project root.
32
+ */
33
+ export function findProjectRoot(startDir: string = process.cwd()): string {
34
+ let current = startDir;
35
+
36
+ while (true) {
37
+ const pkg = path.join(current, 'package.json');
38
+ if (fs.existsSync(pkg)) return current;
39
+
40
+ const parent = path.dirname(current);
41
+ if (parent === current) break;
42
+
43
+ current = parent;
44
+ }
45
+
46
+ // Fallback: use cwd
47
+ return startDir;
48
+ }
49
+
50
+ export function getRootDirectory(): string {
51
+ return findProjectRoot();
52
+ }
53
+
54
+ export function getRootJson(): Record<string, unknown> {
55
+ const root = getRootDirectory();
56
+ const jsonPath = path.join(root, 'package.json');
57
+
58
+ if (!fs.existsSync(jsonPath)) {
59
+ throw new Error(`package.json not found in ${root}`);
60
+ }
61
+
62
+ return JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
63
+ }
64
+
65
+ /* ------------------------------------------------------------------
66
+ * Mono (.mono) handling
67
+ * ------------------------------------------------------------------ */
68
+
69
+ const DISALLOWED_FILES = new Set(['tools']);
70
+
71
+ function readJsonFile(filePath: string): unknown {
72
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
73
+ }
74
+
75
+ /**
76
+ * Resolve the .mono directory.
77
+ * Priority:
78
+ * 1. project root/.mono
79
+ * 2. cwd/.mono
80
+ */
81
+ export function resolveMonoDirectory(): string | null {
82
+ const root = getRootDirectory();
83
+ const rootMono = path.join(root, '.mono');
84
+ if (fs.existsSync(rootMono)) return rootMono;
85
+
86
+ const cwdMono = path.join(process.cwd(), '.mono');
87
+ if (fs.existsSync(cwdMono)) return cwdMono;
88
+
89
+ return null;
90
+ }
91
+
92
+ export function getMonoFiles(): string[] {
93
+ const dir = resolveMonoDirectory();
94
+ if (!dir) return [];
95
+
96
+ return fs
97
+ .readdirSync(dir)
98
+ .filter((f) => f.endsWith('.json'))
99
+ .map((f) => path.join(dir, f));
100
+ }
101
+
102
+ /**
103
+ * Load and validate mono configuration.
104
+ */
105
+ export function getMonoConfig(): MonoConfig {
106
+ const monoDir = resolveMonoDirectory();
107
+
108
+ if (!monoDir) {
109
+ return {
110
+ files: {},
111
+ config: {
112
+ envMap: [],
113
+ workspace: { packageMaps: {} },
114
+ prodFlag: 'live',
115
+ },
116
+ };
117
+ }
118
+
119
+ const files: MonoFiles = {};
120
+ let config: MonoProjectConfig = {
121
+ envMap: [],
122
+ workspace: { packageMaps: {} },
123
+ prodFlag: 'live',
124
+ };
125
+
126
+ for (const filePath of getMonoFiles()) {
127
+ const fileName = path.basename(filePath, '.json');
128
+
129
+ if (DISALLOWED_FILES.has(fileName)) {
130
+ throw new Error(`Disallowed file name in .mono directory: ${fileName}`);
131
+ }
132
+
133
+ const data = readJsonFile(filePath);
134
+
135
+ if (fileName === 'config') {
136
+ if (typeof data === 'object' && data !== null) {
137
+ config = data as MonoProjectConfig;
138
+ }
139
+ } else {
140
+ files[fileName] = data;
141
+ }
142
+ }
143
+
144
+ return { files, config };
145
+ }
@@ -29,12 +29,16 @@ type DefaultDeployConfig = {
29
29
  regions: string[];
30
30
  ec2User: string;
31
31
  warehouseRegion: string;
32
+ dbInstanceType: string;
33
+ appInstanceType: string;
32
34
  };
33
35
 
34
36
  const requiredSystemDefaults = {
35
37
  ec2User: 'ec2-user',
36
38
  regions: ['us-east-1'],
37
39
  warehouseRegion: 'us-east-1',
40
+ dbInstanceType: 't3.micro',
41
+ appInstanceType: 't3.micro',
38
42
  };
39
43
 
40
44
  type ConfigTypeMap = {