nstantpage-agent 0.8.1 → 0.8.2

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
@@ -62,15 +62,12 @@ program
62
62
  .action(runCommand);
63
63
  program
64
64
  .command('sync')
65
- .description('Sync local directory to nstantpage and start agent')
65
+ .description('Sync local directory files to nstantpage database')
66
66
  .argument('[directory]', 'Project directory to sync (defaults to current directory)', '.')
67
- .option('-p, --port <port>', 'Local dev server port', '3000')
68
- .option('-a, --api-port <port>', 'Local API server port', '18924')
69
67
  .option('--local [port]', 'Sync to local backend (default: localhost:5001)')
70
68
  .option('--gateway <url>', 'Gateway URL (default: from login)')
71
69
  .option('--backend <url>', 'Backend API URL (auto-detected from gateway)')
72
70
  .option('--token <token>', 'Auth token (skip login flow)')
73
- .option('--no-start', 'Only sync files, do not start the agent')
74
71
  .action(syncCommand);
75
72
  program
76
73
  .command('stop')
@@ -129,5 +126,14 @@ program
129
126
  .command('update')
130
127
  .description('Update CLI to the latest version')
131
128
  .action(updateCommand);
129
+ program
130
+ .command('logs')
131
+ .description('Show agent log output')
132
+ .option('-f, --follow', 'Follow log output (like tail -f)')
133
+ .option('-n, --lines <count>', 'Number of lines to show', '50')
134
+ .action(async (options) => {
135
+ const { logsCommand } = await import('./commands/logs.js');
136
+ await logsCommand(options);
137
+ });
132
138
  program.parse();
133
139
  //# sourceMappingURL=cli.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Logs command — show agent log output.
3
+ *
4
+ * Usage:
5
+ * nstantpage logs — Show last 50 lines
6
+ * nstantpage logs -f — Follow log output (tail -f)
7
+ * nstantpage logs -n 100 — Show last 100 lines
8
+ */
9
+ interface LogsOptions {
10
+ follow?: boolean;
11
+ lines: string;
12
+ }
13
+ export declare function logsCommand(options: LogsOptions): Promise<void>;
14
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Logs command — show agent log output.
3
+ *
4
+ * Usage:
5
+ * nstantpage logs — Show last 50 lines
6
+ * nstantpage logs -f — Follow log output (tail -f)
7
+ * nstantpage logs -n 100 — Show last 100 lines
8
+ */
9
+ import chalk from 'chalk';
10
+ import fs from 'fs';
11
+ import path from 'path';
12
+ import os from 'os';
13
+ import { execSync } from 'child_process';
14
+ export async function logsCommand(options) {
15
+ const logPath = path.join(os.homedir(), '.nstantpage', 'agent.log');
16
+ if (!fs.existsSync(logPath)) {
17
+ console.log(chalk.yellow(' No log file found.'));
18
+ console.log(chalk.gray(` Expected: ${logPath}`));
19
+ console.log(chalk.gray(' Run "nstantpage run" to start the agent service first.'));
20
+ return;
21
+ }
22
+ const lines = parseInt(options.lines, 10) || 50;
23
+ if (options.follow) {
24
+ console.log(chalk.gray(` Following ${logPath} (Ctrl+C to stop)\n`));
25
+ try {
26
+ execSync(`tail -n ${lines} -f "${logPath}"`, { stdio: 'inherit' });
27
+ }
28
+ catch {
29
+ // User pressed Ctrl+C
30
+ }
31
+ }
32
+ else {
33
+ try {
34
+ const output = execSync(`tail -n ${lines} "${logPath}"`, { encoding: 'utf-8' });
35
+ console.log(output);
36
+ }
37
+ catch {
38
+ console.log(chalk.red(' Failed to read log file.'));
39
+ }
40
+ }
41
+ }
42
+ //# sourceMappingURL=logs.js.map
@@ -1,14 +1,10 @@
1
1
  /**
2
- * Run command — install the background service and start the agent.
2
+ * Run command — install the background service so the agent starts on boot.
3
3
  *
4
4
  * Usage:
5
- * nstantpage run — Install service + start agent (connects to nstantpage.com)
6
- * nstantpage run --local — Same but targeting localhost:5001
7
- * nstantpage run --local 3000 — Same but targeting localhost:3000
8
- *
9
- * This is the main entry point for users. It:
10
- * 1. Installs the agent as a background service (auto-start on boot)
11
- * 2. Starts the agent immediately in standby mode
5
+ * nstantpage run — Install service (connects to nstantpage.com)
6
+ * nstantpage run --local — Install service targeting localhost:5001
7
+ * nstantpage run --local 3000 — Install service targeting localhost:3000
12
8
  */
13
9
  interface RunOptions {
14
10
  local?: string | boolean;
@@ -1,19 +1,14 @@
1
1
  /**
2
- * Run command — install the background service and start the agent.
2
+ * Run command — install the background service so the agent starts on boot.
3
3
  *
4
4
  * Usage:
5
- * nstantpage run — Install service + start agent (connects to nstantpage.com)
6
- * nstantpage run --local — Same but targeting localhost:5001
7
- * nstantpage run --local 3000 — Same but targeting localhost:3000
8
- *
9
- * This is the main entry point for users. It:
10
- * 1. Installs the agent as a background service (auto-start on boot)
11
- * 2. Starts the agent immediately in standby mode
5
+ * nstantpage run — Install service (connects to nstantpage.com)
6
+ * nstantpage run --local — Install service targeting localhost:5001
7
+ * nstantpage run --local 3000 — Install service targeting localhost:3000
12
8
  */
13
9
  import chalk from 'chalk';
14
10
  import { getConfig } from '../config.js';
15
11
  import { serviceInstallCommand } from './service.js';
16
- import { startCommand } from './start.js';
17
12
  export async function runCommand(options = {}) {
18
13
  const conf = getConfig();
19
14
  // Resolve gateway based on --local flag
@@ -21,7 +16,6 @@ export async function runCommand(options = {}) {
21
16
  if (options.local !== undefined && options.local !== false) {
22
17
  const port = (typeof options.local === 'string') ? options.local : '5001';
23
18
  gateway = `ws://localhost:4000`;
24
- // Store backend override for the start command
25
19
  conf.set('localBackendUrl', `http://localhost:${port}`);
26
20
  }
27
21
  else {
@@ -35,25 +29,16 @@ export async function runCommand(options = {}) {
35
29
  }
36
30
  console.log(chalk.blue(`\n 🚀 nstantpage run\n`));
37
31
  console.log(chalk.gray(` Server: ${isLocal ? 'localhost (dev)' : 'nstantpage.com'}`));
38
- // 1. Install background service (auto-start on boot)
39
- console.log(chalk.gray(' Installing background service...'));
32
+ // Install background service (auto-start on boot + starts immediately)
40
33
  try {
41
34
  await serviceInstallCommand({ gateway });
42
35
  }
43
36
  catch (err) {
44
- console.log(chalk.yellow(` Service install skipped: ${err.message}`));
37
+ console.log(chalk.red(` Service install failed: ${err.message}`));
38
+ process.exit(1);
45
39
  }
46
- // 2. Start agent in standby mode
47
- console.log(chalk.gray('\n Starting agent...\n'));
48
- const backendUrl = isLocal
49
- ? (conf.get('localBackendUrl') || 'http://localhost:5001')
50
- : undefined;
51
- await startCommand('.', {
52
- port: '3000',
53
- apiPort: '18924',
54
- gateway,
55
- token: token || 'local-dev',
56
- backend: backendUrl,
57
- });
40
+ console.log(chalk.green('\n ✓ Agent is running as a background service.'));
41
+ console.log(chalk.gray(' Use "nstantpage logs" to view agent output.'));
42
+ console.log(chalk.gray(' Use "nstantpage service stop" to stop.\n'));
58
43
  }
59
44
  //# sourceMappingURL=run.js.map
@@ -12,13 +12,10 @@
12
12
  * 4. Starts the agent (equivalent to `nstantpage start`)
13
13
  */
14
14
  interface SyncOptions {
15
- port: string;
16
- apiPort: string;
17
15
  local?: boolean | string;
18
16
  gateway?: string;
19
17
  backend?: string;
20
18
  token?: string;
21
- noStart?: boolean;
22
19
  }
23
20
  export declare function syncCommand(directory: string, options: SyncOptions): Promise<void>;
24
21
  export {};
@@ -15,7 +15,6 @@ import chalk from 'chalk';
15
15
  import path from 'path';
16
16
  import fs from 'fs';
17
17
  import { getConfig, getDeviceId } from '../config.js';
18
- import { startCommand } from './start.js';
19
18
  const SKIP_DIRS = new Set([
20
19
  'node_modules', 'dist', '.git', '.vite-cache', '.next',
21
20
  '__pycache__', '.turbo', '.cache', 'build', 'out',
@@ -214,21 +213,8 @@ export async function syncCommand(directory, options) {
214
213
  if (files.length > BATCH_SIZE)
215
214
  process.stdout.write('\n');
216
215
  console.log(chalk.green(` ✓ ${totalPushed} files synced to database`));
217
- // 5. Start the agent unless --no-start
218
- if (options.noStart) {
219
- console.log(chalk.blue(`\n Sync complete! Project ID: ${projectId}\n`));
220
- console.log(chalk.gray(` To start the agent: nstantpage start --project-id ${projectId} --dir "${projectDir}"`));
221
- return;
222
- }
223
- console.log(chalk.gray('\n Starting agent...\n'));
224
- await startCommand(projectDir, {
225
- port: options.port,
226
- apiPort: options.apiPort,
227
- projectId,
228
- gateway,
229
- backend: options.backend,
230
- token,
231
- dir: projectDir,
232
- });
216
+ console.log(chalk.blue(`\n ✓ Sync complete! Project ID: ${projectId}`));
217
+ console.log(chalk.gray(`\n View on web: https://nstantpage.com/project/${projectId}`));
218
+ console.log(chalk.gray(` Start agent: nstantpage start --project-id ${projectId} --dir "${projectDir}"\n`));
233
219
  }
234
220
  //# sourceMappingURL=sync.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstantpage-agent",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
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": {