@pplethai/cli 0.2.2 → 0.3.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.
Files changed (37) hide show
  1. package/README.md +11 -6
  2. package/dist/api.js +62 -16
  3. package/dist/bin.js +1 -1
  4. package/dist/cli.js +64 -16
  5. package/dist/commands/auth.js +8 -8
  6. package/dist/commands/deploy.js +20 -21
  7. package/dist/commands/env.js +70 -0
  8. package/dist/commands/info.js +238 -0
  9. package/dist/commands/init.js +69 -16
  10. package/dist/commands/upgrade.js +5 -5
  11. package/dist/device-flow.js +4 -4
  12. package/dist/errors.js +2 -2
  13. package/dist/git.js +12 -12
  14. package/dist/link.js +12 -2
  15. package/dist/node-deps.js +23 -0
  16. package/dist/npm.js +1 -1
  17. package/dist/scaffold.js +1 -1
  18. package/dist/skills.js +2 -2
  19. package/dist/update.js +11 -11
  20. package/package.json +1 -1
  21. package/skills/pple-platform/SKILL.md +30 -21
  22. package/skills/pple-platform/evals/evals.json +1 -1
  23. package/skills/pple-platform/references/deployment.md +75 -7
  24. package/skills/pple-platform/references/mini-app.md +3 -2
  25. package/skills/pple-platform/references/pple-id-auth.md +32 -18
  26. package/skills/pple-platform/references/project-scaffold.md +6 -6
  27. package/templates/golden-path/.env.example +5 -3
  28. package/templates/golden-path/CLAUDE.md +6 -2
  29. package/templates/golden-path/README.md +4 -4
  30. package/templates/golden-path/package-lock.json +8 -7
  31. package/templates/golden-path/package.json +2 -1
  32. package/templates/golden-path/web/App.tsx +22 -4
  33. package/templates/golden-path/web/app.css +0 -20
  34. package/templates/golden-path/web/main.tsx +16 -5
  35. package/templates/golden-path/web/pple.ts +20 -7
  36. package/templates/golden-path/web/vite-env.d.ts +3 -3
  37. package/templates/golden-path/web/NotInApp.tsx +0 -23
@@ -5,14 +5,19 @@
5
5
  // the Worker accepts you as a fake user.
6
6
  // 2. Inside PPLE Today — the SDK captures the access token from the launch
7
7
  // URL; we attach it to every API call.
8
- // 3. A plain browser — not inside PPLE Today, so we show the NOT_IN_APP
9
- // screen instead of trying to sign in.
10
- import { isInMiniAppUserAgent } from "@pplethai/components";
8
+ // 3. A plain browser — the same SDK runs the PPLE ID OIDC sign-in (redirect
9
+ // / callback) and hands back an access token.
11
10
  import { PPLEMiniApp } from "@pplethai/pple-today-miniapp-sdk";
12
11
 
13
- // Provisioned per app, injected at build time. Only needed inside PPLE Today.
12
+ // Provisioned per app and baked into this bundle at build time by the
13
+ // platform deploy workflow's env (VITE_OAUTH_URL / VITE_OAUTH_CLIENT_ID).
14
+ // Needed for the SDK in both PPLE Today and the browser (browser login uses
15
+ // the OIDC redirect flow). Empty here means the build var was missing —
16
+ // bootstrap() below turns that into a legible error.
14
17
  const OAUTH_URL = import.meta.env.VITE_OAUTH_URL ?? "";
15
18
  const OAUTH_CLIENT_ID = import.meta.env.VITE_OAUTH_CLIENT_ID ?? "";
19
+ // Must match a redirect URI on the app's PPLE ID OAuth client. Provisioning
20
+ // registers the mini-app URL; defaulting to this origin keeps them aligned.
16
21
  const OAUTH_REDIRECT_URI =
17
22
  import.meta.env.VITE_OAUTH_REDIRECT_URI ?? window.location.origin;
18
23
 
@@ -21,7 +26,6 @@ const DEV_TOKEN = "dev-token";
21
26
 
22
27
  export type Bootstrap =
23
28
  | { kind: "signed-in" }
24
- | { kind: "not-in-app" }
25
29
  | { kind: "error"; message: string };
26
30
 
27
31
  let token: string | null = null;
@@ -34,8 +38,17 @@ export async function bootstrap(): Promise<Bootstrap> {
34
38
  return { kind: "signed-in" };
35
39
  }
36
40
 
37
- if (!isInMiniAppUserAgent(navigator.userAgent)) {
38
- return { kind: "not-in-app" };
41
+ // The OAuth config is baked in at build time by the platform deploy
42
+ // workflow (VITE_OAUTH_URL / VITE_OAUTH_CLIENT_ID). If it's missing the
43
+ // SDK throws a bare "No authority or metadataUrl configured on settings"
44
+ // from oidc-client-ts — turn that into something a Builder can act on
45
+ // instead of a stack trace they can't read (issue #115).
46
+ if (!OAUTH_URL || !OAUTH_CLIENT_ID) {
47
+ return {
48
+ kind: "error",
49
+ message:
50
+ "This app is misconfigured: its PPLE ID sign-in settings were not set when it was built. Redeploy the app from the platform to fix it.",
51
+ };
39
52
  }
40
53
 
41
54
  const sdk = new PPLEMiniApp({
@@ -1,8 +1,8 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
- // Build-time OIDC config for the mini-app SDK. These are public values (a
4
- // client id and public OAuth URLs), safe to ship in the bundle. The platform
5
- // injects them at deploy time; see .env.example.
3
+ // Build-time OIDC config for the mini-app SDK (PPLE Today + browser login).
4
+ // These are public values (a client id and public OAuth URLs), safe to ship
5
+ // in the bundle. The platform injects them at deploy time; see .env.example.
6
6
  interface ImportMetaEnv {
7
7
  readonly VITE_OAUTH_URL?: string;
8
8
  readonly VITE_OAUTH_CLIENT_ID?: string;
@@ -1,23 +0,0 @@
1
- import { Card, CardContent, Logo } from "@pplethai/components";
2
-
3
- // Shown when the app is opened outside PPLE Today (a plain browser). There is
4
- // no sign-in here on purpose: mini-apps authenticate through PPLE Today.
5
- export function NotInApp() {
6
- return (
7
- <main className="screen screen--center">
8
- <Card className="card">
9
- <CardContent>
10
- <div className="notinapp">
11
- <Logo className="notinapp__logo" title="People's Party" />
12
- <h1 className="notinapp__title">เปิดในแอป PPLE Today</h1>
13
- <p>
14
- แอปนี้ทำงานภายในแอป PPLE Today เท่านั้น
15
- กรุณาเปิดจากแอป PPLE Today เพื่อเข้าสู่ระบบ
16
- </p>
17
- <p className="muted">Please open this mini-app from inside PPLE Today to sign in.</p>
18
- </div>
19
- </CardContent>
20
- </Card>
21
- </main>
22
- );
23
- }