nstantpage-agent 0.5.16 → 0.5.18

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/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ const program = new Command();
25
25
  program
26
26
  .name('nstantpage')
27
27
  .description('Local development agent for nstantpage.com — run projects on your machine, preview in the cloud')
28
- .version('0.5.11');
28
+ .version('0.5.18');
29
29
  program
30
30
  .command('login')
31
31
  .description('Authenticate with nstantpage.com')
@@ -25,7 +25,7 @@ import { TunnelClient } from '../tunnel.js';
25
25
  import { LocalServer } from '../localServer.js';
26
26
  import { PackageInstaller } from '../packageInstaller.js';
27
27
  import { probeLocalPostgres, ensureLocalProjectDb, closeAdminPool, writeDatabaseUrlToEnv } from '../projectDb.js';
28
- const VERSION = '0.5.16';
28
+ const VERSION = '0.5.18';
29
29
  /**
30
30
  * Resolve the backend API base URL.
31
31
  * - If --backend is passed, use it
@@ -631,7 +631,6 @@ async function startAdditionalProject(projectId, opts) {
631
631
  databaseUrl = await ensureLocalProjectDb(projectId);
632
632
  if (databaseUrl) {
633
633
  console.log(chalk.green(` ✓ Database ready: project_${projectId}`));
634
- writeDatabaseUrlToEnv(projectDir, databaseUrl);
635
634
  }
636
635
  }
637
636
  }
@@ -677,6 +676,10 @@ async function startAdditionalProject(projectId, opts) {
677
676
  console.log(chalk.yellow(` ⚠ Could not fetch files: ${err.message}`));
678
677
  progress('fetching-files', `Warning: ${err.message}`);
679
678
  }
679
+ // Write DATABASE_URL to .env AFTER file fetch (so it doesn't get overwritten)
680
+ if (databaseUrl) {
681
+ writeDatabaseUrlToEnv(projectDir, databaseUrl);
682
+ }
680
683
  // Wait for API server before proceeding (tunnel can keep connecting in background)
681
684
  await apiServerPromise;
682
685
  progress('starting-server', `API server ready`);
package/dist/devServer.js CHANGED
@@ -9,6 +9,32 @@ import path from 'path';
9
9
  import fs from 'fs';
10
10
  import http from 'http';
11
11
  import os from 'os';
12
+ /**
13
+ * Parse a .env file into a key-value map.
14
+ * Handles KEY=VALUE, KEY="VALUE", KEY='VALUE', comments (#), and empty lines.
15
+ */
16
+ function parseDotenv(filePath) {
17
+ if (!fs.existsSync(filePath))
18
+ return {};
19
+ const result = {};
20
+ const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
21
+ for (const line of lines) {
22
+ const trimmed = line.trim();
23
+ if (!trimmed || trimmed.startsWith('#'))
24
+ continue;
25
+ const eqIdx = trimmed.indexOf('=');
26
+ if (eqIdx === -1)
27
+ continue;
28
+ const key = trimmed.slice(0, eqIdx).trim();
29
+ let val = trimmed.slice(eqIdx + 1).trim();
30
+ // Strip surrounding quotes
31
+ if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
32
+ val = val.slice(1, -1);
33
+ }
34
+ result[key] = val;
35
+ }
36
+ return result;
37
+ }
12
38
  export class DevServer {
13
39
  options;
14
40
  process = null;
@@ -39,6 +65,8 @@ export class DevServer {
39
65
  }
40
66
  const { projectDir, port } = this.options;
41
67
  const extraEnv = this.options.env || {};
68
+ // Load .env file from project root (lower priority than explicit env vars)
69
+ const dotenvVars = parseDotenv(path.join(projectDir, '.env'));
42
70
  // Detect project type
43
71
  const pkgPath = path.join(projectDir, 'package.json');
44
72
  if (!fs.existsSync(pkgPath)) {
@@ -63,6 +91,7 @@ export class DevServer {
63
91
  cwd: projectDir,
64
92
  env: {
65
93
  ...process.env,
94
+ ...dotenvVars,
66
95
  ...extraEnv,
67
96
  PORT: String(backendPort),
68
97
  SERVER_PORT: String(backendPort),
@@ -97,6 +126,7 @@ export class DevServer {
97
126
  }
98
127
  const frontendEnv = {
99
128
  ...process.env,
129
+ ...dotenvVars,
100
130
  ...extraEnv,
101
131
  PORT: String(port),
102
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstantpage-agent",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "description": "Local development agent for nstantpage.com — run your projects locally, preview in the cloud. Replaces cloud containers for faster builds.",
5
5
  "type": "module",
6
6
  "bin": {