@pplethai/cli 0.1.0 → 0.2.1

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/deps.js CHANGED
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  export const DEFAULT_CONFIG = {
5
5
  apiBase: "https://api.ppleth.ai",
6
- ssoBase: "https://sso.peoplesparty.or.th",
6
+ ssoBase: "https://id.peoplesparty.or.th",
7
7
  clientId: "382216793067947795",
8
8
  repoBase: "https://github.com",
9
9
  registryBase: "https://registry.npmjs.org",
@@ -18,17 +18,24 @@ function form(fields) {
18
18
  body: new URLSearchParams(fields).toString(),
19
19
  };
20
20
  }
21
- const UNREACHABLE = new CliError("Couldn't reach PPLE ID to sign you in.", "Check your internet connection and try `pple auth login` again.");
21
+ /**
22
+ * Name the host we failed to reach. "Check your internet connection" sends a
23
+ * Builder to their wifi when the real fault is a bad `ssoBase` — the host it
24
+ * couldn't reach is the one fact that tells the two apart.
25
+ */
26
+ function unreachable(ssoBase) {
27
+ return new CliError(`Couldn't reach PPLE ID (${ssoBase}) to sign you in.`, "Check your internet connection and try `pple auth login` again.");
28
+ }
22
29
  export async function requestDeviceCode(deps) {
23
30
  const { ssoBase, clientId } = deps.config;
24
31
  const res = await deps
25
32
  .fetch(`${ssoBase}${DEVICE_AUTHORIZATION_PATH}`, form({ client_id: clientId, scope: SCOPES }))
26
33
  .catch(() => null);
27
34
  if (!res || !res.ok)
28
- throw UNREACHABLE;
35
+ throw unreachable(ssoBase);
29
36
  const body = (await res.json().catch(() => ({})));
30
37
  if (!body.device_code || !body.user_code || !body.verification_uri) {
31
- throw UNREACHABLE;
38
+ throw unreachable(ssoBase);
32
39
  }
33
40
  return {
34
41
  deviceCode: body.device_code,
@@ -59,7 +66,7 @@ export async function awaitToken(deps, device) {
59
66
  }))
60
67
  .catch(() => null);
61
68
  if (!res)
62
- throw UNREACHABLE;
69
+ throw unreachable(ssoBase);
63
70
  const body = (await res.json().catch(() => ({})));
64
71
  if (res.ok && body.access_token)
65
72
  return toTokenSet(deps, body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pplethai/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,4 +32,4 @@
32
32
  "engines": {
33
33
  "node": ">=22"
34
34
  }
35
- }
35
+ }
@@ -2,7 +2,7 @@
2
2
  # These are the app's PPLE ID OIDC client details, used by the mini-app SDK
3
3
  # when running inside PPLE Today. They are public values, safe to ship.
4
4
  # The platform injects them at deploy time; copy to `.env` to set locally.
5
- VITE_OAUTH_URL="https://sso.peoplesparty.or.th"
5
+ VITE_OAUTH_URL="https://id.peoplesparty.or.th"
6
6
  VITE_OAUTH_CLIENT_ID=""
7
7
  # Defaults to the app's own origin if unset.
8
8
  # VITE_OAUTH_REDIRECT_URI=""
@@ -44,7 +44,9 @@ which attach the PPLE ID bearer token. Same origin, so paths are relative
44
44
  - **Mobile-first.** The app runs in a phone-sized WebView. Use the design
45
45
  system's components and the layout classes in `web/app.css`.
46
46
  - **Add a DB table** by writing a new `migrations/000N_*.sql` (never edit an
47
- applied migration) and running `npm run db:migrate:local`.
47
+ applied migration) and running `npm run db:migrate:local`. The platform
48
+ applies `migrations/` to the live database on every deploy, so shipping the
49
+ file is all a deploy needs — there is no remote migrate command to run.
48
50
 
49
51
  ## Before you finish
50
52
 
@@ -51,7 +51,8 @@ PPLE Today, it signs the real user in via the mini-app SDK.
51
51
  ## Making it yours
52
52
 
53
53
  - **Add a table:** create `migrations/0002_*.sql`, run `npm run db:migrate:local`,
54
- add queries in `src/db.ts`.
54
+ add queries in `src/db.ts`. Deploying applies it to the live database for you
55
+ — never edit a migration that has already shipped, add another one.
55
56
  - **Add an API route:** add it under `/api` in `src/index.ts`.
56
57
  - **Change the UI:** edit `web/App.tsx` using `@pplethai/components`.
57
58
  - **Send notifications:** the platform provisions `NOTIFY_API_KEY`; the helper
@@ -1,6 +1,7 @@
1
1
  -- The example table behind the D1 read/write demo. Replace it with your own
2
- -- schema: add a new file (0002_add_something.sql, …) and apply it with
3
- -- `npm run db:migrate:local` (local) or `npm run db:migrate:remote` (deployed).
2
+ -- schema: add a new file (0002_add_something.sql, …) and apply it locally with
3
+ -- `npm run db:migrate:local`. Deployed databases migrate themselves — the
4
+ -- platform applies everything in this directory on each deploy.
4
5
  CREATE TABLE notes (
5
6
  id INTEGER PRIMARY KEY AUTOINCREMENT,
6
7
  body TEXT NOT NULL,
@@ -11,7 +11,6 @@
11
11
  "test": "vitest run",
12
12
  "test:watch": "vitest",
13
13
  "db:migrate:local": "wrangler d1 migrations apply DB --local",
14
- "db:migrate:remote": "wrangler d1 migrations apply DB --remote",
15
14
  "deploy": "vite build && wrangler deploy"
16
15
  },
17
16
  "dependencies": {
@@ -39,7 +39,7 @@
39
39
 
40
40
  "vars": {
41
41
  // PPLE ID (identity). The Worker validates bearer tokens against this.
42
- "SSO_BASE_URL": "https://sso.peoplesparty.or.th",
42
+ "SSO_BASE_URL": "https://id.peoplesparty.or.th",
43
43
  // Audience-bound notification endpoint (see src/notify.ts): the base that
44
44
  // `${NOTIFY_API_BASE}/notifications` is posted to. The platform sets the
45
45
  // real value; empty locally so notify is a no-op unless you wire it up in