@playcraft/cli 0.0.37 → 0.0.39

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.
@@ -2,6 +2,8 @@ import http from 'http';
2
2
  import { exec } from 'child_process';
3
3
  import crypto from 'crypto';
4
4
  import { saveGlobalConfig, loadGlobalConfig } from '../config.js';
5
+ /** 默认云端 Portal(Next.js `/cli-auth` 与 API 同源时的基址;可通过 --url 或 PLAYCRAFT_URL 覆盖) */
6
+ export const DEFAULT_PLAYCRAFT_CLOUD_BASE = 'https://playcraft.aix.intlgame.com';
5
7
  const CALLBACK_PORT = 3456;
6
8
  const TIMEOUT_MS = 5 * 60 * 1000;
7
9
  function escapeHtml(text) {
@@ -34,11 +36,17 @@ function openBrowser(url) {
34
36
  console.error('Please use the URL printed above to complete login.');
35
37
  }
36
38
  }
37
- export async function loginCommand(options) {
39
+ function resolveLoginBaseUrl(options) {
38
40
  const globalConfig = loadGlobalConfig();
39
- const backendUrl = options.url ||
41
+ const raw = options.url ||
42
+ process.env.PLAYCRAFT_URL ||
43
+ globalConfig.url ||
40
44
  globalConfig.backendUrl ||
41
- 'https://playcraft.woa.com';
45
+ DEFAULT_PLAYCRAFT_CLOUD_BASE;
46
+ return raw.replace(/\/+$/, '');
47
+ }
48
+ export async function loginCommand(options) {
49
+ const backendUrl = resolveLoginBaseUrl(options);
42
50
  const state = crypto.randomBytes(16).toString('hex');
43
51
  return new Promise((resolve, reject) => {
44
52
  const server = http.createServer((req, res) => {
@@ -64,7 +72,11 @@ export async function loginCommand(options) {
64
72
  });
65
73
  return;
66
74
  }
67
- saveGlobalConfig({ token: data.token, backendUrl });
75
+ saveGlobalConfig({
76
+ token: data.token,
77
+ url: backendUrl,
78
+ backendUrl,
79
+ });
68
80
  res.writeHead(200, { 'Content-Type': 'text/html' });
69
81
  res.end('<html>' +
70
82
  '<head><meta charset="utf-8"><title>Login Success</title></head>' +
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ program
47
47
  program
48
48
  .command('login')
49
49
  .description('登录 PlayCraft 账号并获取 CLI token')
50
- .option('--url <url>', '后端地址', 'https://playcraft.woa.com')
50
+ .option('--url <url>', 'Portal / API 基址(默认 https://playcraft.aix.intlgame.com,可用环境变量 PLAYCRAFT_URL 覆盖)')
51
51
  .action(async (options) => {
52
52
  const { loginCommand } = await import('./commands/login.js');
53
53
  await loginCommand(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcraft/cli",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,8 +23,8 @@
23
23
  "release": "node scripts/release.js"
24
24
  },
25
25
  "dependencies": {
26
- "@playcraft/build": "^0.0.37",
27
- "@playcraft/common": "^0.0.25",
26
+ "@playcraft/build": "^0.0.39",
27
+ "@playcraft/common": "^0.0.27",
28
28
  "chokidar": "^4.0.3",
29
29
  "commander": "^13.1.0",
30
30
  "cors": "^2.8.6",