@pmate/cli 0.12.8 → 0.13.0

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/README.md CHANGED
@@ -28,6 +28,7 @@ pmate --help
28
28
  pmate --name Bob
29
29
  pmate add-dns --type A --value 1.2.3.4 --rr api
30
30
  pmate login
31
+ pmate login --app @pmate/chat
31
32
  pmate sts
32
33
  pmate oss list
33
34
  pmate oss upload --file ./path/to/file --key assets/file.txt
@@ -147,7 +148,8 @@ pmate linear pr --account work
147
148
 
148
149
  ## Auth session
149
150
 
150
- `pmate login` stores a session token in `~/.pmate/session.json`. Commands like
151
+ `pmate login` stores a session token in `~/.pmate/session.json`. Use `--app <app-id>`
152
+ to authenticate against a specific app; the default remains `@pmate/cli`. Commands like
151
153
  `pmate sts` require this session; if it is missing, log in first.
152
154
 
153
155
  ## Notion config
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ type ListCommandArgs = {
33
33
  };
34
34
  type LoginCommandArgs = {
35
35
  type: Command.Login;
36
+ app?: string;
36
37
  };
37
38
  type AddDnsCommandArgs = {
38
39
  type: Command.AddDns;
package/dist/index.js CHANGED
@@ -12569,27 +12569,30 @@ var import_node_child_process = require("child_process");
12569
12569
  var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
12570
12570
  var AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
12571
12571
  var CALLBACK_PATH = "/pmate-login-callback";
12572
- var APP_ID = "@pmate/cli";
12572
+ var DEFAULT_APP_ID = "@pmate/cli";
12573
12573
  var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
12574
- function buildHostedLoginUrl(redirectUrl) {
12574
+ function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
12575
12575
  const url = new URL(AUTH_UI_BASE_URL);
12576
12576
  url.searchParams.set("redirect", redirectUrl);
12577
- url.searchParams.set("app", APP_ID);
12577
+ url.searchParams.set("app", appId);
12578
12578
  return url.toString();
12579
12579
  }
12580
12580
  var LoginCommandHandler = class {
12581
- async handle(_args) {
12581
+ async handle(args) {
12582
12582
  const callback = await this.startCallbackServer();
12583
- const loginUrl = buildHostedLoginUrl(callback.redirectUrl);
12583
+ const appId = args.app?.trim() || DEFAULT_APP_ID;
12584
+ const loginUrl = buildHostedLoginUrl(callback.redirectUrl, appId);
12584
12585
  ui.info("Opening browser for login.", {
12585
- url: loginUrl
12586
+ url: loginUrl,
12587
+ app: appId
12586
12588
  });
12587
12589
  if (!this.openBrowser(loginUrl)) {
12588
12590
  ui.warn("Unable to open the browser automatically.");
12589
12591
  ui.plain(loginUrl);
12590
12592
  }
12591
12593
  ui.info("Waiting for login redirect...", {
12592
- callback: callback.redirectUrl
12594
+ callback: callback.redirectUrl,
12595
+ app: appId
12593
12596
  });
12594
12597
  try {
12595
12598
  const token = await callback.waitForToken;
@@ -19444,6 +19447,7 @@ var HELP_TEXT = [
19444
19447
  import_chalk3.default.bold("Commands:"),
19445
19448
  ` ${import_chalk3.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
19446
19449
  ` ${import_chalk3.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
19450
+ ` ${import_chalk3.default.gray(" [--app <app-id>]")}`,
19447
19451
  ` ${import_chalk3.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
19448
19452
  ` ${import_chalk3.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
19449
19453
  ` ${import_chalk3.default.cyan("sts")} Request an OSS STS token from the CI server`,
@@ -19572,10 +19576,19 @@ function parseCommandArgs(args) {
19572
19576
  return { type: "list" /* List */, targetPath };
19573
19577
  }
19574
19578
  if (args.rest[0] === "login") {
19575
- if (args.rest.length > 1) {
19576
- throw new Error("Too many arguments for login command");
19579
+ const rest = args.rest.slice(1);
19580
+ let app;
19581
+ while (rest.length > 0) {
19582
+ const token = rest.shift();
19583
+ switch (token) {
19584
+ case "--app":
19585
+ app = requireValue3(rest, token);
19586
+ break;
19587
+ default:
19588
+ throw new Error(`Unknown login option: ${token}`);
19589
+ }
19577
19590
  }
19578
- return { type: "login" /* Login */ };
19591
+ return { type: "login" /* Login */, app };
19579
19592
  }
19580
19593
  if (args.rest[0] === "add-dns") {
19581
19594
  return parseAddDnsArgs(args.rest.slice(1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.12.8",
3
+ "version": "0.13.0",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {