@mono-labs/cli 0.0.102 → 0.0.106

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.
@@ -25,7 +25,7 @@ function selectProfile(dev, preview, prod, profile) {
25
25
  }
26
26
 
27
27
  program
28
- .command('build')
28
+ .command('build2')
29
29
  .description('Execute eas build command')
30
30
  .option('-d', 'Build to target development profile')
31
31
  .option('-p', 'Build to target preview profile')
@@ -121,6 +121,7 @@ export function buildCommands(files) {
121
121
  Object.keys(optionVals).forEach((k) => {
122
122
  optionVals[k] = verifyOptionValue(k, optionVals[k], optionsData);
123
123
  });
124
+ optionVals['prod'] = optionVals[config.prodFlag] || false;
124
125
  console.log('optionVals after verify:', optionVals);
125
126
 
126
127
  console.log('envDefaults', envDefaults);
@@ -0,0 +1,38 @@
1
+ // scripts/read-env.mjs
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ export function parseEnvFile(filePath) {
6
+ if (!fs.existsSync(filePath)) {
7
+ throw new Error(`.env file not found at: ${filePath}`);
8
+ }
9
+
10
+ const content = fs.readFileSync(filePath, 'utf8');
11
+
12
+ const keymap = {};
13
+ for (const line of content.split(/\r?\n/)) {
14
+ const trimmed = line.trim();
15
+
16
+ // skip empty lines and comments
17
+ if (!trimmed || trimmed.startsWith('#')) continue;
18
+
19
+ // split on first "=" only
20
+ const idx = trimmed.indexOf('=');
21
+ if (idx === -1) continue;
22
+
23
+ const key = trimmed.slice(0, idx).trim();
24
+ let value = trimmed.slice(idx + 1).trim();
25
+
26
+ // strip surrounding quotes if present
27
+ if (
28
+ (value.startsWith('"') && value.endsWith('"')) ||
29
+ (value.startsWith("'") && value.endsWith("'"))
30
+ ) {
31
+ value = value.slice(1, -1);
32
+ }
33
+
34
+ keymap[key] = value;
35
+ }
36
+
37
+ return keymap;
38
+ }
@@ -14,9 +14,25 @@ export async function runHasteCommand(configObject, options = {}) {
14
14
  const { config } = getHasteConfig();
15
15
  console.log('runHasteCommand options:', options);
16
16
  const devConfig = configObject.environments?.dev ?? {};
17
- const stageConfig = configObject.environments?.stage ?? {};
17
+
18
+ // Usage:
19
+ const envPath = path.resolve(process.cwd(), '.env');
20
+ const keymap = parseEnvFile(envPath);
21
+
22
+ const prodConfig = configObject.environments?.prod ?? {};
18
23
  const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default';
19
- const envObjBase = options.stage ? { ...stageConfig } : { ...devConfig };
24
+ const envObjBase = options.prod ? { ...prodConfig } : { ...devConfig };
25
+
26
+ Object.keys(envObjBase).forEach((k) => {
27
+ if (
28
+ typeof envObjBase[k] === 'string' &&
29
+ envObjBase[k].startsWith('$') &&
30
+ !envObjBase[k].startsWith('${')
31
+ ) {
32
+ const refKey = envObjBase[k].substring(1);
33
+ envObjBase[k] = keymap[refKey] || '';
34
+ }
35
+ });
20
36
  envObjBase.AWS_PROFILE = awsProfile;
21
37
 
22
38
  const envKeys = Object.keys(process.env).filter((k) => k.startsWith('MONO_'));
@@ -34,6 +50,8 @@ export async function runHasteCommand(configObject, options = {}) {
34
50
  const preactions = configObject.preactions ?? [];
35
51
  const actions = configObject.actions ?? [];
36
52
 
53
+ console.log('envObjBase:', envObjBase);
54
+
37
55
  console.log(
38
56
  `→ Executing haste command: ${configObject.name || 'Unnamed Command'}`
39
57
  );
@@ -6,6 +6,7 @@ export function generateNewEnvList(processEnv) {
6
6
  const envKeys = Object.keys(processEnv).filter((k) => k.startsWith('MONO_'));
7
7
  let envObj = {};
8
8
  for (const key of envKeys) {
9
+ if (key.includes('SECRET')) continue; // Skip keys that include
9
10
  const mappedKey = envMapList[key] || key;
10
11
  envObj[mappedKey] = processEnv[key];
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.102",
3
+ "version": "0.0.106",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",