nstantpage-agent 0.8.6 → 0.8.7

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.
@@ -268,13 +268,16 @@ export async function startCommand(directory, options) {
268
268
  console.log(chalk.gray(` API server: port ${apiPort}`));
269
269
  console.log(chalk.gray(` Gateway: ${options.gateway}`));
270
270
  console.log(chalk.gray(` Backend: ${backendUrl}\n`));
271
- // 1. Fetch project files from the backend
271
+ // Determine if this is a user-managed local directory (--dir flag or explicit path)
272
+ // For local projects: disk is truth, NEVER overwrite disk from DB
273
+ const isLocalDir = !!(options.dir) || directory !== '.';
274
+ // 1. Fetch or sync project files
272
275
  const installer = new PackageInstaller({ projectDir });
273
276
  let fetchedVersionId;
274
- try {
275
- const { fileCount, isNew, versionId } = await fetchProjectFiles(backendUrl, projectId, projectDir, token);
276
- fetchedVersionId = versionId;
277
- // 2. Install dependencies if needed (verifies actual packages, not just folder)
277
+ if (isLocalDir) {
278
+ // Local project SKIP DB→disk fetch. Disk is truth.
279
+ console.log(chalk.gray(` Local project — using files from disk (not fetching from DB)`));
280
+ // Install dependencies if needed
278
281
  if (!installer.areDependenciesInstalled()) {
279
282
  if (fs.existsSync(path.join(projectDir, 'package.json'))) {
280
283
  console.log(chalk.gray(' Installing dependencies...'));
@@ -292,13 +295,37 @@ export async function startCommand(directory, options) {
292
295
  console.log(chalk.gray(` Dependencies already installed`));
293
296
  }
294
297
  }
295
- catch (err) {
296
- console.log(chalk.yellow(` ⚠ Could not fetch project files: ${err.message}`));
297
- console.log(chalk.gray(' Continuing with existing local files (if any)...'));
298
- if (!fs.existsSync(path.join(projectDir, 'package.json'))) {
299
- console.log(chalk.red(`\n✗ No package.json found and cannot fetch files from backend.`));
300
- console.log(chalk.gray(' Check your project ID and authentication.'));
301
- process.exit(1);
298
+ else {
299
+ // Cloud/managed project fetch files from DB to disk
300
+ try {
301
+ const { fileCount, isNew, versionId } = await fetchProjectFiles(backendUrl, projectId, projectDir, token);
302
+ fetchedVersionId = versionId;
303
+ // 2. Install dependencies if needed (verifies actual packages, not just folder)
304
+ if (!installer.areDependenciesInstalled()) {
305
+ if (fs.existsSync(path.join(projectDir, 'package.json'))) {
306
+ console.log(chalk.gray(' Installing dependencies...'));
307
+ try {
308
+ await installer.ensureDependencies();
309
+ console.log(chalk.green(` ✓ Dependencies installed`));
310
+ }
311
+ catch (err) {
312
+ console.log(chalk.yellow(` ⚠ Install failed: ${err.message?.slice(0, 200)}`));
313
+ console.log(chalk.gray(` Will retry when dev server starts`));
314
+ }
315
+ }
316
+ }
317
+ else {
318
+ console.log(chalk.gray(` Dependencies already installed`));
319
+ }
320
+ }
321
+ catch (err) {
322
+ console.log(chalk.yellow(` ⚠ Could not fetch project files: ${err.message}`));
323
+ console.log(chalk.gray(' Continuing with existing local files (if any)...'));
324
+ if (!fs.existsSync(path.join(projectDir, 'package.json'))) {
325
+ console.log(chalk.red(`\n✗ No package.json found and cannot fetch files from backend.`));
326
+ console.log(chalk.gray(' Check your project ID and authentication.'));
327
+ process.exit(1);
328
+ }
302
329
  }
303
330
  }
304
331
  // Save .nstantpage.json for future runs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstantpage-agent",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
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": {