plotlink-ows 1.0.0 → 1.0.5

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/app/lib/paths.ts CHANGED
@@ -5,5 +5,12 @@ import fs from "fs";
5
5
  /** All user state lives in ~/.plotlink-ows/ — survives npx reinstalls */
6
6
  export const CONFIG_DIR = path.join(os.homedir(), ".plotlink-ows");
7
7
  export const ENV_FILE = path.join(CONFIG_DIR, ".env");
8
- // Ensure config dir exists on import
8
+ export const STORIES_DIR = path.join(CONFIG_DIR, "stories");
9
+ export const DATA_DIR = path.join(CONFIG_DIR, "data");
10
+ export const DB_PATH = path.join(DATA_DIR, "local.db");
11
+ export const DATABASE_URL = `file:${DB_PATH}`;
12
+
13
+ // Ensure persistent directories exist on import
9
14
  fs.mkdirSync(CONFIG_DIR, { recursive: true });
15
+ fs.mkdirSync(STORIES_DIR, { recursive: true });
16
+ fs.mkdirSync(DATA_DIR, { recursive: true });
@@ -5,7 +5,7 @@ generator client {
5
5
 
6
6
  datasource db {
7
7
  provider = "sqlite"
8
- url = "file:../../data/local.db"
8
+ url = env("DATABASE_URL")
9
9
  }
10
10
 
11
11
  model Session {
@@ -1,10 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
- import { fileURLToPath } from "url";
5
-
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- const STORIES_DIR = path.join(__dirname, "..", "..", "stories");
4
+ import { STORIES_DIR } from "../lib/paths";
8
5
 
9
6
  const stories = new Hono();
10
7
 
@@ -2,13 +2,11 @@ import { Hono } from "hono";
2
2
  import * as pty from "node-pty";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
- import { fileURLToPath } from "url";
6
5
  import { randomUUID } from "crypto";
6
+ import { STORIES_DIR, DATA_DIR } from "../lib/paths";
7
7
 
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
- const STORIES_DIR = path.join(__dirname, "..", "..", "stories");
10
8
  const MAX_SESSIONS = 5;
11
- const SESSION_FILE = path.join(__dirname, "..", "..", "data", "terminal-sessions.json");
9
+ const SESSION_FILE = path.join(DATA_DIR, "terminal-sessions.json");
12
10
 
13
11
  const terminal = new Hono();
14
12
 
package/app/server.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import dotenv from "dotenv";
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
- import { ENV_FILE } from "./lib/paths";
4
+ import { ENV_FILE, DATA_DIR, STORIES_DIR, DATABASE_URL } from "./lib/paths";
5
+
6
+ // Set DATABASE_URL before any Prisma imports
7
+ process.env.DATABASE_URL = DATABASE_URL;
5
8
 
6
9
  // Load .env from ~/.plotlink-ows/ before anything else
7
10
  const __dirnamePre = path.dirname(fileURLToPath(import.meta.url));
@@ -57,25 +60,61 @@ if (fs.existsSync(distPath)) {
57
60
  });
58
61
  }
59
62
 
63
+ /** Migrate stories/data from old package-relative paths to ~/.plotlink-ows/ */
64
+ function migrateOldData() {
65
+ const oldStoriesDir = path.join(__dirname, "..", "stories");
66
+ const oldDataDir = path.join(__dirname, "..", "data");
67
+
68
+ // Migrate stories
69
+ if (fs.existsSync(oldStoriesDir) && oldStoriesDir !== STORIES_DIR) {
70
+ const oldEntries = fs.readdirSync(oldStoriesDir, { withFileTypes: true })
71
+ .filter((d) => d.isDirectory() && !d.name.startsWith(".") && d.name !== "_example");
72
+ for (const entry of oldEntries) {
73
+ const src = path.join(oldStoriesDir, entry.name);
74
+ const dest = path.join(STORIES_DIR, entry.name);
75
+ if (!fs.existsSync(dest)) {
76
+ try {
77
+ fs.renameSync(src, dest);
78
+ } catch {
79
+ // EXDEV: cross-device move — fall back to copy
80
+ fs.cpSync(src, dest, { recursive: true });
81
+ }
82
+ console.log(` Migrated story "${entry.name}" → ${STORIES_DIR}`);
83
+ }
84
+ }
85
+ }
86
+
87
+ // Migrate database
88
+ const oldDb = path.join(oldDataDir, "local.db");
89
+ const newDb = path.join(DATA_DIR, "local.db");
90
+ if (fs.existsSync(oldDb) && !fs.existsSync(newDb)) {
91
+ fs.copyFileSync(oldDb, newDb);
92
+ console.log(` Migrated database → ${DATA_DIR}`);
93
+ }
94
+
95
+ // Migrate terminal sessions
96
+ const oldSessions = path.join(oldDataDir, "terminal-sessions.json");
97
+ const newSessions = path.join(DATA_DIR, "terminal-sessions.json");
98
+ if (fs.existsSync(oldSessions) && !fs.existsSync(newSessions)) {
99
+ fs.copyFileSync(oldSessions, newSessions);
100
+ console.log(` Migrated terminal sessions → ${DATA_DIR}`);
101
+ }
102
+ }
103
+
60
104
  async function start() {
61
- // Ensure data directory exists
62
- const dataDir = path.join(__dirname, "..", "data");
63
- if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true });
105
+ // Auto-migrate from old package-relative paths
106
+ migrateOldData();
64
107
 
65
108
  // Run Prisma db push to ensure schema is up to date
66
109
  const schemaPath = path.join(__dirname, "prisma", "schema.prisma");
67
110
  execSync(`npx prisma db push --schema ${schemaPath} --skip-generate`, {
68
111
  stdio: "inherit",
69
- env: { ...process.env, DATABASE_URL: `file:${path.join(dataDir, "local.db")}` },
112
+ env: { ...process.env, DATABASE_URL },
70
113
  });
71
114
 
72
115
  // Initialize database connection
73
116
  await initDb();
74
117
 
75
- // Ensure stories directory exists
76
- const storiesDir = path.join(__dirname, "..", "stories");
77
- if (!fs.existsSync(storiesDir)) fs.mkdirSync(storiesDir, { recursive: true });
78
-
79
118
  const port = Number(process.env.APP_PORT) || 7777;
80
119
  const server = serve({ fetch: app.fetch, port }, (info) => {
81
120
  console.log(`\n PlotLink OWS running at http://localhost:${info.port}\n`);
@@ -291,6 +291,11 @@ switch (cmd) {
291
291
  case "status":
292
292
  cmdStatus();
293
293
  break;
294
+ case "stop":
295
+ log('The "stop" command has been removed.');
296
+ log("The server now runs in the foreground — press Ctrl+C to stop it.");
297
+ process.exit(0);
298
+ break;
294
299
  default:
295
300
  cmdStart();
296
301
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotlink-ows",
3
- "version": "1.0.0",
3
+ "version": "1.0.5",
4
4
  "bin": {
5
5
  "plotlink-ows": "./bin/plotlink-ows.js"
6
6
  },
@@ -26,6 +26,7 @@
26
26
  "app:dev": "concurrently \"tsx watch app/server.ts\" \"vite --config app/vite.config.ts\"",
27
27
  "app:build": "vite build --config app/vite.config.ts",
28
28
  "app:start": "tsx app/server.ts",
29
+ "postinstall": "prisma generate --schema app/prisma/schema.prisma",
29
30
  "prisma:local": "prisma generate --schema app/prisma/schema.prisma && prisma db push --schema app/prisma/schema.prisma",
30
31
  "release:patch": "npm version patch && git push origin main --follow-tags && VERSION=$(node -p 'require(\"./package.json\").version') && gh release create \"v$VERSION\" --generate-notes --latest && npm publish",
31
32
  "release:minor": "npm version minor && git push origin main --follow-tags && VERSION=$(node -p 'require(\"./package.json\").version') && gh release create \"v$VERSION\" --generate-notes --latest && npm publish",
@@ -33,28 +34,16 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "@aws-sdk/client-s3": "^3.1009.0",
36
- "@farcaster/miniapp-node": "^0.1.13",
37
- "@farcaster/miniapp-sdk": "^0.3.0",
38
- "@farcaster/miniapp-wagmi-connector": "^2.0.0",
39
37
  "@hono/node-server": "^1.19.12",
40
38
  "@open-wallet-standard/core": "^1.2.4",
41
39
  "@prisma/client": "^6.19.3",
42
- "@rainbow-me/rainbowkit": "^2.2.10",
43
40
  "@supabase/supabase-js": "^2.99.1",
44
- "@tailwindcss/typography": "^0.5.19",
45
- "@tailwindcss/vite": "^4.2.2",
46
- "@tanstack/react-query": "^5.90.21",
47
- "@types/ws": "^8.18.1",
48
- "@vercel/analytics": "^2.0.1",
49
- "@vitejs/plugin-react": "^4.7.0",
50
41
  "@xterm/addon-fit": "^0.11.0",
51
42
  "@xterm/addon-serialize": "^0.14.0",
52
43
  "@xterm/xterm": "^6.0.0",
53
44
  "dotenv": "^17.4.0",
54
45
  "hono": "^4.12.10",
55
- "next": "16.1.6",
56
46
  "node-pty": "^1.2.0-beta.12",
57
- "ox": "^0.14.8",
58
47
  "prisma": "^6.19.3",
59
48
  "react": "19.2.3",
60
49
  "react-dom": "19.2.3",
@@ -66,23 +55,35 @@
66
55
  "tsx": "^4.21.0",
67
56
  "viem": "^2.47.2",
68
57
  "vite": "^6.4.1",
69
- "wagmi": "^2.19.5",
70
58
  "ws": "^8.20.0"
71
59
  },
72
60
  "devDependencies": {
61
+ "@farcaster/miniapp-node": "^0.1.13",
62
+ "@farcaster/miniapp-sdk": "^0.3.0",
63
+ "@farcaster/miniapp-wagmi-connector": "^2.0.0",
73
64
  "@playwright/test": "^1.58.2",
65
+ "@rainbow-me/rainbowkit": "^2.2.10",
74
66
  "@tailwindcss/postcss": "^4",
67
+ "@tailwindcss/typography": "^0.5.19",
68
+ "@tailwindcss/vite": "^4.2.2",
69
+ "@tanstack/react-query": "^5.90.21",
75
70
  "@testing-library/jest-dom": "^6.9.1",
76
71
  "@testing-library/react": "^16.3.2",
77
72
  "@testing-library/user-event": "^14.6.1",
78
73
  "@types/node": "^20",
79
74
  "@types/react": "^19",
80
75
  "@types/react-dom": "^19",
76
+ "@types/ws": "^8.18.1",
77
+ "@vercel/analytics": "^2.0.1",
78
+ "@vitejs/plugin-react": "^4.7.0",
81
79
  "concurrently": "^9.2.1",
82
80
  "eslint": "^9",
83
81
  "eslint-config-next": "16.1.6",
84
82
  "jsdom": "^27.0.1",
83
+ "next": "16.1.6",
84
+ "ox": "^0.14.8",
85
85
  "typescript": "^5",
86
- "vitest": "^3.2.4"
86
+ "vitest": "^3.2.4",
87
+ "wagmi": "^2.19.5"
87
88
  }
88
89
  }
@@ -10,10 +10,7 @@
10
10
  */
11
11
  import fs from "fs";
12
12
  import path from "path";
13
- import { fileURLToPath } from "url";
14
-
15
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
- const STORIES_DIR = path.join(__dirname, "..", "stories");
13
+ import { STORIES_DIR } from "../app/lib/paths";
17
14
 
18
15
  interface FileStatus {
19
16
  file: string;