@tomorrowos/sdk 0.7.5 → 0.7.6

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/REPLIT_SETUP.md CHANGED
@@ -30,6 +30,98 @@ Alternate triggers that also activate this protocol:
30
30
  - HTTP Control Panel loads
31
31
  - `GET /brand.json` returns 200
32
32
  - WebSocket upgrade on `wss://<repl-host>/` succeeds (critical for TV pairing)
33
+ 7. **Follow the Runtime & Replit publish rules below exactly.** A project that cannot Deploy / Publish on Replit is incomplete.
34
+
35
+ ---
36
+
37
+ ## Runtime & Replit publish rules (mandatory)
38
+
39
+ These rules exist so the CMS can be **Run** and **Published/Deployed** on Replit without custom build steps.
40
+
41
+ ### Runtime
42
+
43
+ - The server **must** run directly from source using `tsx server.ts`.
44
+ - **Do not** compile to `dist/` as the production entrypoint.
45
+ - **Do not** replace `@tomorrowos/sdk` with a hand-rolled server, Express wrapper that drops WebSocket upgrades, or a different package name.
46
+ - Always depend on **`@tomorrowos/sdk`**.
47
+ - **`tsx` must be available at runtime.** Prefer putting `tsx` in **`dependencies`** (not only `devDependencies`) so Replit Deploy / production installs still include it.
48
+ - Use **Node.js 20 or newer** (set in `.replit` / Nix / package engines if the workspace asks).
49
+
50
+ ### Expected `package.json` scripts
51
+
52
+ ```json
53
+ {
54
+ "scripts": {
55
+ "dev": "tsx watch server.ts",
56
+ "start": "tsx server.ts"
57
+ }
58
+ }
59
+ ```
60
+
61
+ Allowed extras (optional): `"build-player": "tomorrowos build --platform tizen"`.
62
+ **Forbidden as the Deploy entrypoint:** `node dist/server.js`, `next start`, static-only hosts, or any command that does not start `TomorrowOS.listen(...)`.
63
+
64
+ ### Minimal dependency expectations
65
+
66
+ ```json
67
+ {
68
+ "type": "module",
69
+ "engines": {
70
+ "node": ">=20"
71
+ },
72
+ "dependencies": {
73
+ "@tomorrowos/sdk": "^0.7.6",
74
+ "dotenv": "^17.2.3",
75
+ "tsx": "^4.19.0"
76
+ },
77
+ "devDependencies": {
78
+ "@types/node": "^20.0.0",
79
+ "typescript": "^5.5.0"
80
+ },
81
+ "scripts": {
82
+ "dev": "tsx watch server.ts",
83
+ "start": "tsx server.ts"
84
+ }
85
+ }
86
+ ```
87
+
88
+ Bump `@tomorrowos/sdk` to the latest published version when scaffolding.
89
+
90
+ ### Replit Run command
91
+
92
+ ```text
93
+ npm run start
94
+ ```
95
+
96
+ ### Replit deployment / publish command
97
+
98
+ ```text
99
+ npm run start
100
+ ```
101
+
102
+ ### `.replit` (create or edit)
103
+
104
+ ```toml
105
+ run = "npm run start"
106
+
107
+ [deployment]
108
+ run = ["sh", "-c", "npm run start"]
109
+ ```
110
+
111
+ If the workspace already has a `.replit`, **merge** these keys — do not wipe unrelated Nix/modules config. Ensure the effective Run and Deployment commands remain `npm run start`.
112
+
113
+ ### Publish readiness checklist (before telling the user “done”)
114
+
115
+ 1. `package.json` has `scripts.start` = `tsx server.ts`
116
+ 2. `tsx` is listed under `dependencies` (runtime-safe for Deploy)
117
+ 3. Dependency is `@tomorrowos/sdk` (not a fork or vendored rewrite)
118
+ 4. `.replit` Run + `[deployment].run` use `npm run start`
119
+ 5. Node is **20+**
120
+ 6. `npm run start` prints `[TomorrowOS] listening on http://0.0.0.0:...`
121
+ 7. Browser WebSocket test to `wss://<host>/` succeeds
122
+ 8. Secrets required by the Q&A answers are set (`SUPABASE_URL`, Cloudinary, etc.)
123
+
124
+ If any item fails, fix it before finishing.
33
125
 
34
126
  ---
35
127
 
@@ -251,20 +343,42 @@ CLOUDINARY_API_SECRET=...
251
343
  - Supabase path: pass `databaseUrl: process.env.SUPABASE_URL || process.env.DATABASE_URL` into `createTomorrowOSStore`
252
344
  - Keep TomorrowOS event handlers from the starter (paired / online policy push)
253
345
 
254
- ### D. Install and run
346
+ ### D. Runtime files for Replit publish
347
+
348
+ 1. Ensure `package.json` scripts are exactly:
349
+
350
+ ```json
351
+ "dev": "tsx watch server.ts",
352
+ "start": "tsx server.ts"
353
+ ```
354
+
355
+ 2. Move / keep `tsx` in **`dependencies`** so Deploy works.
356
+ 3. Set `engines.node` to `>=20`.
357
+ 4. Create or update `.replit`:
358
+
359
+ ```toml
360
+ run = "npm run start"
361
+
362
+ [deployment]
363
+ run = ["sh", "-c", "npm run start"]
364
+ ```
365
+
366
+ ### E. Install and run
255
367
 
256
368
  ```bash
257
369
  npm install
258
- npm run dev
370
+ npm run start
259
371
  ```
260
372
 
373
+ (Use `npm run dev` only for local edit/watch. **Publish / Deploy / Replit Run must use `npm run start`.**)
374
+
261
375
  Confirm logs contain something like:
262
376
 
263
377
  ```text
264
378
  [TomorrowOS] listening on http://0.0.0.0:<PORT>
265
379
  ```
266
380
 
267
- ### E. Verify before telling the user “done”
381
+ ### F. Verify before telling the user “done”
268
382
 
269
383
  1. Open the Control Panel URL.
270
384
  2. `GET /brand.json` → 200 and correct `name` / colours.
@@ -276,9 +390,11 @@ ws.onopen = () => console.log("WS OK");
276
390
  ws.onerror = (e) => console.log("WS ERR", e);
277
391
  ```
278
392
 
393
+ 4. Confirm the **Publish readiness checklist** in **Runtime & Replit publish rules**.
394
+
279
395
  If WebSocket fails, fix Run command / process crash / sleep **before** asking the user to pair a TV.
280
396
 
281
- ### F. Tell the user next steps (no code)
397
+ ### G. Tell the user next steps (no code)
282
398
 
283
399
  1. Keep this Repl **running** (Always On if available).
284
400
  2. On the TomorrowOS player, enter the CMS URL: `https://<your-repl>.replit.app/`
@@ -300,9 +416,11 @@ Do **not** ask the user how to implement:
300
416
  Do **not**:
301
417
 
302
418
  - Replace `@tomorrowos/sdk` with a hand-rolled server
419
+ - Change the production start command away from `tsx server.ts` / `npm run start`
303
420
  - Point Supabase at Replit’s reserved `DATABASE_URL` when `SUPABASE_URL` should be used
304
421
  - Skip Cloudinary recommendation without stating the persistence tradeoff
305
422
  - Claim uploads are “permanent” on Replit local disk without Object Storage or Cloudinary
423
+ - Leave `tsx` only in `devDependencies` if the Deploy pipeline installs production deps only
306
424
 
307
425
  ---
308
426
 
@@ -328,7 +446,9 @@ TOMORROWOS_STORE=sqlite
328
446
 
329
447
  | Symptom | Likely cause | Fix |
330
448
  |---------|--------------|-----|
331
- | TV / browser: WebSocket handshake timeout | Node CMS not running or crash-loop | Fix Run → `npm start` / `npm run dev`; check logs for `listening` |
449
+ | TV / browser: WebSocket handshake timeout | Node CMS not running or crash-loop | Fix Run → `npm run start`; check logs for `listening` |
450
+ | Deploy/Publish fails / `tsx: not found` | `tsx` only in devDependencies | Move `tsx` to `dependencies`, reinstall, keep `start`: `tsx server.ts` |
451
+ | Deploy runs wrong process | `.replit` / Deployment not `npm run start` | Set `run = "npm run start"` and `[deployment] run = ["sh", "-c", "npm run start"]` |
332
452
  | Upload: `storage.objects.create` denied | Replit Object Storage IAM | Fix Object Storage permissions **or** switch to Cloudinary |
333
453
  | Upload OK then thumbnails vanish later | Non-persistent `public/uploads` | Object Storage or Cloudinary |
334
454
  | Supabase connection errors | Wrong URL or using reserved `DATABASE_URL` | Use `SUPABASE_URL` + `TOMORROWOS_STORE=supabase` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomorrowos/sdk",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "TomorrowOS CMS server SDK - WebSocket transport, pairing, device commands, optional static CMS UI. Includes CLI (tomorrowos init / build) and starter templates.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,4 @@
1
+ run = "npm run start"
2
+
3
+ [deployment]
4
+ run = ["sh", "-c", "npm run start"]
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "name": "my-cms",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "CMS server on @tomorrowos/sdk. Add your UI (React, static files, etc.) alongside this server.",
5
5
  "private": true,
6
6
  "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
7
10
  "scripts": {
8
11
  "dev": "tsx watch server.ts",
9
12
  "start": "tsx server.ts",
10
13
  "build-player": "tomorrowos build --platform tizen"
11
14
  },
12
15
  "dependencies": {
13
- "@tomorrowos/sdk": "^0.7.5",
14
- "dotenv": "^17.2.3"
16
+ "@tomorrowos/sdk": "^0.7.6",
17
+ "dotenv": "^17.2.3",
18
+ "tsx": "^4.19.0"
15
19
  },
16
20
  "devDependencies": {
17
21
  "@types/node": "^20.0.0",
18
- "tsx": "^4.19.0",
19
22
  "typescript": "^5.5.0"
20
23
  }
21
24
  }