station-kit 1.0.6 → 1.0.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.
Files changed (87) hide show
  1. package/.next/standalone/node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js +72 -0
  2. package/.next/standalone/node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/package.json +19 -0
  3. package/.next/standalone/node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/package.json +31 -0
  4. package/.next/standalone/node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js +625 -0
  5. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/array-set.js +121 -0
  6. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64-vlq.js +140 -0
  7. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/base64.js +67 -0
  8. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/binary-search.js +111 -0
  9. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/mapping-list.js +79 -0
  10. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/quick-sort.js +114 -0
  11. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js +1145 -0
  12. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-generator.js +425 -0
  13. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js +413 -0
  14. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js +488 -0
  15. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/package.json +73 -0
  16. package/.next/standalone/node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js +8 -0
  17. package/.next/standalone/package.json +2 -1
  18. package/.next/standalone/packages/station-kit/.next/BUILD_ID +1 -1
  19. package/.next/standalone/packages/station-kit/.next/app-build-manifest.json +13 -13
  20. package/.next/standalone/packages/station-kit/.next/app-path-routes-manifest.json +4 -4
  21. package/.next/standalone/packages/station-kit/.next/build-manifest.json +2 -2
  22. package/.next/standalone/packages/station-kit/.next/prerender-manifest.json +13 -13
  23. package/.next/standalone/packages/station-kit/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  24. package/.next/standalone/packages/station-kit/.next/server/app/_not-found.html +1 -1
  25. package/.next/standalone/packages/station-kit/.next/server/app/_not-found.rsc +1 -1
  26. package/.next/standalone/packages/station-kit/.next/server/app/broadcasts/[id]/page_client-reference-manifest.js +1 -1
  27. package/.next/standalone/packages/station-kit/.next/server/app/broadcasts/page_client-reference-manifest.js +1 -1
  28. package/.next/standalone/packages/station-kit/.next/server/app/broadcasts.html +1 -1
  29. package/.next/standalone/packages/station-kit/.next/server/app/broadcasts.rsc +1 -1
  30. package/.next/standalone/packages/station-kit/.next/server/app/index.html +1 -1
  31. package/.next/standalone/packages/station-kit/.next/server/app/index.rsc +1 -1
  32. package/.next/standalone/packages/station-kit/.next/server/app/page_client-reference-manifest.js +1 -1
  33. package/.next/standalone/packages/station-kit/.next/server/app/runs/[id]/page.js +2 -2
  34. package/.next/standalone/packages/station-kit/.next/server/app/runs/[id]/page_client-reference-manifest.js +1 -1
  35. package/.next/standalone/packages/station-kit/.next/server/app/settings/page.js +2 -2
  36. package/.next/standalone/packages/station-kit/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  37. package/.next/standalone/packages/station-kit/.next/server/app/settings.html +1 -1
  38. package/.next/standalone/packages/station-kit/.next/server/app/settings.rsc +1 -1
  39. package/.next/standalone/packages/station-kit/.next/server/app/signals/[name]/page_client-reference-manifest.js +1 -1
  40. package/.next/standalone/packages/station-kit/.next/server/app/signals/page_client-reference-manifest.js +1 -1
  41. package/.next/standalone/packages/station-kit/.next/server/app/signals.html +1 -1
  42. package/.next/standalone/packages/station-kit/.next/server/app/signals.rsc +1 -1
  43. package/.next/standalone/packages/station-kit/.next/server/app-paths-manifest.json +4 -4
  44. package/.next/standalone/packages/station-kit/.next/server/pages/404.html +1 -1
  45. package/.next/standalone/packages/station-kit/.next/server/pages/500.html +1 -1
  46. package/.next/standalone/packages/station-kit/package.json +12 -11
  47. package/dist/cli/deploy.d.ts +2 -0
  48. package/dist/cli/deploy.d.ts.map +1 -0
  49. package/dist/cli/deploy.js +287 -0
  50. package/dist/cli/deploy.js.map +1 -0
  51. package/dist/cli/parse-args.d.ts +13 -0
  52. package/dist/cli/parse-args.d.ts.map +1 -0
  53. package/dist/cli/parse-args.js +77 -0
  54. package/dist/cli/parse-args.js.map +1 -0
  55. package/dist/cli-main.js +28 -1
  56. package/dist/cli-main.js.map +1 -1
  57. package/dist/cli.js +1 -1
  58. package/dist/cli.js.map +1 -1
  59. package/dist/config/loader.d.ts +1 -1
  60. package/dist/config/loader.d.ts.map +1 -1
  61. package/dist/config/loader.js +7 -3
  62. package/dist/config/loader.js.map +1 -1
  63. package/dist/config/schema.d.ts +5 -0
  64. package/dist/config/schema.d.ts.map +1 -1
  65. package/dist/config/schema.js +22 -3
  66. package/dist/config/schema.js.map +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/server/index.d.ts.map +1 -1
  70. package/dist/server/index.js +4 -2
  71. package/dist/server/index.js.map +1 -1
  72. package/dist/station-dir.d.ts +7 -0
  73. package/dist/station-dir.d.ts.map +1 -0
  74. package/dist/station-dir.js +15 -0
  75. package/dist/station-dir.js.map +1 -0
  76. package/package.json +9 -8
  77. package/src/cli/deploy.ts +334 -0
  78. package/src/cli/parse-args.ts +99 -0
  79. package/src/cli-main.ts +28 -1
  80. package/src/cli.ts +1 -1
  81. package/src/config/loader.ts +7 -3
  82. package/src/config/schema.ts +29 -3
  83. package/src/index.ts +1 -1
  84. package/src/server/index.ts +5 -2
  85. package/src/station-dir.ts +24 -0
  86. /package/.next/standalone/packages/station-kit/.next/static/{kqMlNlRLox_FLRK-2GwrJ → pHHaxeGaet0VW1dhcIcuY}/_buildManifest.js +0 -0
  87. /package/.next/standalone/packages/station-kit/.next/static/{kqMlNlRLox_FLRK-2GwrJ → pHHaxeGaet0VW1dhcIcuY}/_ssgManifest.js +0 -0
@@ -0,0 +1,99 @@
1
+ export interface CliArgs {
2
+ port?: number;
3
+ host?: string;
4
+ dir?: string;
5
+ noOpen?: boolean;
6
+ noRunners?: boolean;
7
+ config?: string;
8
+ subcommand?: string;
9
+ help?: boolean;
10
+ }
11
+
12
+ const FLAGS_WITH_VALUE = new Set(["--port", "--host", "--dir", "--config"]);
13
+
14
+ export function parseArgs(argv: string[]): CliArgs {
15
+ const args: CliArgs = {};
16
+ let i = 0;
17
+
18
+ while (i < argv.length) {
19
+ const arg = argv[i];
20
+
21
+ if (arg === "--help" || arg === "-h") {
22
+ args.help = true;
23
+ i++;
24
+ continue;
25
+ }
26
+
27
+ if (arg === "--no-open") {
28
+ args.noOpen = true;
29
+ i++;
30
+ continue;
31
+ }
32
+
33
+ if (arg === "--no-runners" || arg === "--read-only") {
34
+ args.noRunners = true;
35
+ i++;
36
+ continue;
37
+ }
38
+
39
+ if (FLAGS_WITH_VALUE.has(arg)) {
40
+ const value = argv[i + 1];
41
+ if (value === undefined || value.startsWith("--")) {
42
+ throw new Error(`Missing value for ${arg}`);
43
+ }
44
+
45
+ switch (arg) {
46
+ case "--port": {
47
+ const n = parseInt(value, 10);
48
+ if (isNaN(n) || n < 1 || n > 65535) {
49
+ throw new Error(`Invalid port: ${value}`);
50
+ }
51
+ args.port = n;
52
+ break;
53
+ }
54
+ case "--host":
55
+ args.host = value;
56
+ break;
57
+ case "--dir":
58
+ args.dir = value;
59
+ break;
60
+ case "--config":
61
+ args.config = value;
62
+ break;
63
+ }
64
+
65
+ i += 2;
66
+ continue;
67
+ }
68
+
69
+ // First positional arg that doesn't start with -- is a subcommand
70
+ if (!arg.startsWith("-")) {
71
+ args.subcommand = arg;
72
+ i++;
73
+ continue;
74
+ }
75
+
76
+ throw new Error(`Unknown flag: ${arg}`);
77
+ }
78
+
79
+ return args;
80
+ }
81
+
82
+ export function printUsage(): void {
83
+ console.log(`
84
+ Usage: station [command] [options]
85
+
86
+ Commands:
87
+ deploy Generate deployment files (Dockerfile, nixpacks.toml)
88
+
89
+ Options:
90
+ --port <n> Override server port (default: 4400)
91
+ --host <s> Override server host (default: localhost)
92
+ --dir <path> Set station directory for generated files (default: .station)
93
+ --config <path> Path to config file (default: station.config.ts)
94
+ --no-open Don't open browser on start
95
+ --no-runners Don't execute signal/broadcast runners (read-only mode)
96
+ --read-only Alias for --no-runners
97
+ -h, --help Show this help message
98
+ `.trim());
99
+ }
package/src/cli-main.ts CHANGED
@@ -1,11 +1,38 @@
1
1
  import { loadConfig } from "./config/loader.js";
2
2
  import { createStation } from "./server/index.js";
3
+ import { parseArgs, printUsage } from "./cli/parse-args.js";
3
4
  import { spawn, type ChildProcess } from "node:child_process";
4
5
  import { resolve } from "node:path";
5
6
  import { existsSync } from "node:fs";
6
7
 
8
+ // Parse CLI arguments
9
+ const cliArgs = parseArgs(process.argv.slice(2));
10
+
11
+ if (cliArgs.help) {
12
+ printUsage();
13
+ process.exit(0);
14
+ }
15
+
16
+ if (cliArgs.subcommand === "deploy") {
17
+ await import("./cli/deploy.js");
18
+ process.exit(0);
19
+ }
20
+
21
+ if (cliArgs.subcommand) {
22
+ console.error(`[station] Unknown command: ${cliArgs.subcommand}`);
23
+ printUsage();
24
+ process.exit(1);
25
+ }
26
+
7
27
  const cwd = process.cwd();
8
- const config = await loadConfig(cwd);
28
+ const config = await loadConfig(cwd, cliArgs.config);
29
+
30
+ // Apply CLI overrides
31
+ if (cliArgs.port !== undefined) config.port = cliArgs.port;
32
+ if (cliArgs.host !== undefined) config.host = cliArgs.host;
33
+ if (cliArgs.dir !== undefined) config.stationDir = cliArgs.dir;
34
+ if (cliArgs.noOpen) config.open = false;
35
+ if (cliArgs.noRunners) config.runRunners = false;
9
36
 
10
37
  // Spawn Next.js standalone server for the dashboard
11
38
  const pkgRoot = resolve(import.meta.dirname, "..");
package/src/cli.ts CHANGED
@@ -23,7 +23,7 @@ if (!process.env[MARKER]) {
23
23
  }
24
24
 
25
25
  const main = fileURLToPath(new URL("./cli-main.js", import.meta.url));
26
- const child = spawn(execPath, ["--import", tsxSpecifier, main], {
26
+ const child = spawn(execPath, ["--import", tsxSpecifier, main, ...process.argv.slice(2)], {
27
27
  stdio: "inherit",
28
28
  env: { ...process.env, [MARKER]: "1", __STATION_TSX: tsxSpecifier },
29
29
  });
@@ -9,10 +9,14 @@ const CONFIG_NAMES = [
9
9
  "station.config.mjs",
10
10
  ];
11
11
 
12
- export async function loadConfig(cwd: string): Promise<StationConfig> {
13
- const configPath = findConfigFile(cwd);
12
+ export async function loadConfig(cwd: string, configFile?: string): Promise<StationConfig> {
13
+ const configPath = configFile ? resolve(cwd, configFile) : findConfigFile(cwd);
14
14
 
15
- if (!configPath) {
15
+ if (!configPath || !existsSync(configPath)) {
16
+ if (configFile) {
17
+ console.error(`[station] Config file not found: ${configFile}`);
18
+ process.exit(1);
19
+ }
16
20
  console.log("[station] No config file found. Using defaults.");
17
21
  return resolveConfig({});
18
22
  }
@@ -18,6 +18,10 @@ export interface BroadcastRunnerConfig {
18
18
  pollIntervalMs: number;
19
19
  }
20
20
 
21
+ export interface DeployConfig {
22
+ include?: string[];
23
+ }
24
+
21
25
  export interface StationConfig {
22
26
  port: number;
23
27
  host: string;
@@ -25,12 +29,14 @@ export interface StationConfig {
25
29
  broadcastAdapter?: BroadcastQueueAdapter;
26
30
  signalsDir?: string;
27
31
  broadcastsDir?: string;
32
+ stationDir: string;
28
33
  runner: RunnerConfig;
29
34
  broadcastRunner: BroadcastRunnerConfig;
30
35
  runRunners: boolean;
31
36
  open: boolean;
32
37
  logLevel: "debug" | "info" | "warn" | "error";
33
38
  auth?: AuthConfig;
39
+ deploy?: DeployConfig;
34
40
  }
35
41
 
36
42
  export type StationUserConfig = Partial<Omit<StationConfig, "runner" | "broadcastRunner">> & {
@@ -41,6 +47,7 @@ export type StationUserConfig = Partial<Omit<StationConfig, "runner" | "broadcas
41
47
  const DEFAULTS: StationConfig = {
42
48
  port: 4400,
43
49
  host: "localhost",
50
+ stationDir: ".station",
44
51
  runner: {
45
52
  pollIntervalMs: 1000,
46
53
  maxConcurrent: 5,
@@ -56,13 +63,31 @@ const DEFAULTS: StationConfig = {
56
63
  };
57
64
 
58
65
  export function resolveConfig(input: StationUserConfig): StationConfig {
66
+ const envPort = process.env.PORT ? parseInt(process.env.PORT, 10) : undefined;
67
+ const envHost = process.env.HOST;
68
+ const envAuthUser = process.env.STATION_AUTH_USERNAME;
69
+ const envAuthPass = process.env.STATION_AUTH_PASSWORD;
70
+
71
+ // Env vars for auth: override config values, or create auth if both are set
72
+ let auth = input.auth;
73
+ if (auth) {
74
+ auth = {
75
+ ...auth,
76
+ username: envAuthUser ?? auth.username,
77
+ password: envAuthPass ?? auth.password,
78
+ };
79
+ } else if (envAuthUser && envAuthPass) {
80
+ auth = { username: envAuthUser, password: envAuthPass };
81
+ }
82
+
59
83
  return {
60
- port: input.port ?? DEFAULTS.port,
61
- host: input.host ?? DEFAULTS.host,
84
+ port: input.port ?? envPort ?? DEFAULTS.port,
85
+ host: input.host ?? envHost ?? DEFAULTS.host,
62
86
  adapter: input.adapter,
63
87
  broadcastAdapter: input.broadcastAdapter,
64
88
  signalsDir: input.signalsDir,
65
89
  broadcastsDir: input.broadcastsDir,
90
+ stationDir: input.stationDir ?? DEFAULTS.stationDir,
66
91
  runner: {
67
92
  pollIntervalMs: input.runner?.pollIntervalMs ?? DEFAULTS.runner.pollIntervalMs,
68
93
  maxConcurrent: input.runner?.maxConcurrent ?? DEFAULTS.runner.maxConcurrent,
@@ -75,6 +100,7 @@ export function resolveConfig(input: StationUserConfig): StationConfig {
75
100
  runRunners: input.runRunners ?? DEFAULTS.runRunners,
76
101
  open: input.open ?? DEFAULTS.open,
77
102
  logLevel: input.logLevel ?? DEFAULTS.logLevel,
78
- auth: input.auth,
103
+ auth,
104
+ deploy: input.deploy,
79
105
  };
80
106
  }
package/src/index.ts CHANGED
@@ -4,4 +4,4 @@ export function defineConfig(config: StationUserConfig): StationUserConfig {
4
4
  return config;
5
5
  }
6
6
 
7
- export type { StationConfig, StationUserConfig, AuthConfig } from "./config/schema.js";
7
+ export type { StationConfig, StationUserConfig, AuthConfig, DeployConfig } from "./config/schema.js";
@@ -9,6 +9,7 @@ import { BroadcastRunner, BroadcastMemoryAdapter } from "station-broadcast";
9
9
  import type { SignalQueueAdapter } from "station-signal";
10
10
  import type { BroadcastQueueAdapter } from "station-broadcast";
11
11
  import type { StationConfig } from "../config/schema.js";
12
+ import { ensureStationDir } from "../station-dir.js";
12
13
  import { WebSocketHub } from "./ws.js";
13
14
  import { SSEHub } from "./sse.js";
14
15
  import { LogBuffer } from "./log-buffer.js";
@@ -42,17 +43,19 @@ export async function createStation(config: StationConfig, cwd: string, nextPort
42
43
  const broadcastAdapter: BroadcastQueueAdapter | undefined =
43
44
  config.broadcastAdapter ?? (config.broadcastsDir ? new BroadcastMemoryAdapter() : undefined);
44
45
 
46
+ const { dataDir } = ensureStationDir(cwd, config.stationDir);
47
+
45
48
  const wsHub = new WebSocketHub();
46
49
  const sseHub = new SSEHub();
47
50
  const logBuffer = new LogBuffer();
48
- const logStore = new LogStore(resolve(cwd, "station-logs.db"));
51
+ const logStore = new LogStore(resolve(dataDir, "station-logs.db"));
49
52
 
50
53
  // Auth: create KeyStore and SessionConfig if auth is configured
51
54
  let keyStore: KeyStore | undefined;
52
55
  let sessionConfig: SessionConfig | undefined;
53
56
 
54
57
  if (config.auth) {
55
- keyStore = new KeyStore(resolve(cwd, "station-keys.db"));
58
+ keyStore = new KeyStore(resolve(dataDir, "station-keys.db"));
56
59
  sessionConfig = {
57
60
  username: config.auth.username,
58
61
  password: config.auth.password,
@@ -0,0 +1,24 @@
1
+ import { mkdirSync, writeFileSync, existsSync } from "node:fs";
2
+ import { resolve, join } from "node:path";
3
+
4
+ export interface StationDirs {
5
+ baseDir: string;
6
+ dataDir: string;
7
+ outDir: string;
8
+ }
9
+
10
+ export function ensureStationDir(cwd: string, stationDir: string): StationDirs {
11
+ const baseDir = resolve(cwd, stationDir);
12
+ const dataDir = join(baseDir, "data");
13
+ const outDir = join(baseDir, "out");
14
+
15
+ mkdirSync(dataDir, { recursive: true });
16
+ mkdirSync(outDir, { recursive: true });
17
+
18
+ const gitignorePath = join(baseDir, ".gitignore");
19
+ if (!existsSync(gitignorePath)) {
20
+ writeFileSync(gitignorePath, "data/\n");
21
+ }
22
+
23
+ return { baseDir, dataDir, outDir };
24
+ }