diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index e9d13d2..22eb7e3 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -96,7 +96,7 @@ export function buildAppCreateCommand(): Command { c = await JnpfClient.login({ account: opts.account || 'admin', password: opts.password || '123456', - appCode: 'developSystem', // 平台占位, 拿 system=developSystem 的 token + appCode: 'testspace', // 平台占位, 拿 system=testspace 的 token (统一测试场, 默认已存在; 备选 developSystem 也是 JNPF baseline 占位但首选 testspace) // 跳过 base_system 检测 (这步就是创建 system 本身) // ClientOptions 没有 checkSystem 字段, 用 any cast 透传给 JnpfClient (login.ts v0.11f+ 内部已读) } as any) diff --git a/src/commands/app/login.ts b/src/commands/app/login.ts index 0322835..45ed849 100644 --- a/src/commands/app/login.ts +++ b/src/commands/app/login.ts @@ -20,10 +20,10 @@ import { checkSystemExists } from './_check_system.ts' export function buildAppLoginCommand(): Command { const cmd = new Command('login') - .description('登录 JNPF (默认 admin/123456@developSystem), 持久化 token 到 .dacli-token/token.json') + .description('登录 JNPF (默认 admin/123456@testspace, 统一测试场; developSystem/workSystem 是 JNPF 只读 baseline), 持久化 token 到 .dacli-token/token.json') .option('--account ', '账号', DEFAULT_ACCOUNT) .option('--password

', '密码 (明文; 96 字符 hex 视为已加密)', DEFAULT_PASSWORD) - .option('--appCode ', '应用代码 (developSystem | workSystem | tds)', DEFAULT_APP_CODE) + .option('--appCode ', '应用代码 (testspace 推荐=测试场 | jxcj=业务 | developSystem/workSystem=只读 baseline)', DEFAULT_APP_CODE) .option('--baseUrl ', 'JNPF API 根地址 (含 /api)') .option('--no-check-system', '跳过 base_system 存在性检测 (默认 ON, v0.11e+ Phase E)') .action(async (opts: { @@ -87,7 +87,7 @@ export function buildAppLoginCommand(): Command { optional: { '--account': '账号 (默认 admin)', '--password': '密码 (默认 123456; 已是 96 字符 hex 时跳过加密)', - '--appCode': '应用代码 (默认 developSystem)', + '--appCode': '应用代码 (默认 testspace=统一测试场, 禁止用 developSystem/workSystem 改 baseline)', '--baseUrl': '强制指定 baseUrl, 否则按 [env JNPF_BASE_URL → http://nginx/api → http://127.0.0.1:30000/api] 依次尝试', '--no-check-system': '跳过 base_system 存在性检测 (默认 ON)', }, diff --git a/src/commands/app/logout.ts b/src/commands/app/logout.ts index 327b5f8..7f6384c 100644 --- a/src/commands/app/logout.ts +++ b/src/commands/app/logout.ts @@ -93,7 +93,7 @@ export function buildAppLogoutCommand(): Command { ) } else { log.info(` 下一步: dacli app login --account=admin --password=123456 --appCode=`) - log.info(` 或: dacli app login (默认 admin/123456@developSystem)`) + log.info(` 或: dacli app login (默认 admin/123456@testspace, 统一测试场)`) } }) diff --git a/src/commands/app/switch.ts b/src/commands/app/switch.ts index f7a4d06..d45b5bd 100644 --- a/src/commands/app/switch.ts +++ b/src/commands/app/switch.ts @@ -28,8 +28,8 @@ export function buildAppSwitchCommand(): Command { installAiHelpHook(cmd, { purpose: '切换当前应用, 重新登录并覆盖本地 token. baseline 复刻常用', - required: { '--appCode': '目标应用 (developSystem | workSystem | tds)' }, - example: ['dacli app switch --appCode=developSystem', 'dacli app switch --appCode=tds'], + required: { '--appCode': '目标应用 (testspace=测试场 | jxcj=业务 | developSystem/workSystem=只读 baseline, 禁止改)' }, + example: ['dacli app switch --appCode=testspace', 'dacli app switch --appCode=jxcj'], }) return cmd diff --git a/src/commands/app/use.ts b/src/commands/app/use.ts index f9e6586..ac826d1 100644 --- a/src/commands/app/use.ts +++ b/src/commands/app/use.ts @@ -41,7 +41,7 @@ interface UseOpts { export function buildAppUseCommand(): Command { const cmd = new Command('use') .description('一体化命令: switch + context + CurrentUser (v3.0+ 新增, AI 工作流一步到位)') - .argument('', '目标应用代码 (如 developSystem/workSystem/jxcj/tds)') + .argument('', '目标应用代码 (testspace=测试场 | jxcj=业务 | developSystem/workSystem=只读 baseline, 禁止改)') .option('--account ', '账号 (默认从当前 token 读, 否则 admin)') .option('--password

', '密码 (默认 123456)') .option('--no-current-user', '跳过 CurrentUser 验证 (默认走, 服务器端确认 token+appCode+用户)') @@ -179,7 +179,7 @@ export function buildAppUseCommand(): Command { 'dacli app use jxcj # 切到 jxcj, 拉 context, 验证 CurrentUser', 'dacli app use jxcj --json # 同上, 输出完整 JSON (供 AI)', 'dacli app use jxcj --no-current-user # 跳过 CurrentUser (快但弱验证)', - 'dacli app use developSystem # 切到 developSystem', + 'dacli app use testspace # 切到 testspace 统一测试场 (新会话默认)', ].join('\n'), source: { web: 'web/api/core/user.ts:10-15 getUserInfoApi + web/api/system/system.ts + web/api/visualdev/Base', diff --git a/src/core/config.ts b/src/core/config.ts index 875b2e5..083f026 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -55,7 +55,7 @@ export function currentBaseUrl(): string { /** 默认凭据 (供 login 默认值用) */ export const DEFAULT_ACCOUNT = process.env.JNPF_ACCOUNT || 'admin' export const DEFAULT_PASSWORD = process.env.JNPF_PASSWORD || '123456' -export const DEFAULT_APP_CODE = process.env.JNPF_APP_CODE || 'developSystem' +export const DEFAULT_APP_CODE = process.env.JNPF_APP_CODE || 'testspace' // 统一测试场 (developSystem/workSystem 是 JNPF 只读 baseline, 禁止当默认/测试场) /** baseUrl 兜底列表 (按优先级) */ export function baseUrlCandidates(): string[] { diff --git a/tests/e2e/auth.setup.ts b/tests/e2e/auth.setup.ts index 4446cc2..8c00e97 100644 --- a/tests/e2e/auth.setup.ts +++ b/tests/e2e/auth.setup.ts @@ -20,7 +20,7 @@ import { isAuthFresh, loginAsAdmin, AUTH_FILE, APP_HOME_PATH } from './_helpers/ import { mkdirSync } from 'node:fs' import { dirname } from 'node:path' -setup('authenticate as admin/123456 @ workSystem (v17 verify)', async ({ page }) => { +setup('authenticate as admin/123456 @ testspace (统一测试场)', async ({ page }) => { // 新鲜则跳过 — Playwright 仍会写 storageState 给后续 project 用, 我们手动保留旧文件 if (isAuthFresh()) { setup.info().annotations.push({ type: 'note', description: 'auth fresh, skip UI login' }) @@ -33,8 +33,9 @@ setup('authenticate as admin/123456 @ workSystem (v17 verify)', async ({ page }) mkdirSync(dirname(AUTH_FILE), { recursive: true }) - // v17: 改 workSystem (tds DB 已重置, 2026-06-15 用户清空其他应用) - const ok = await loginAsAdmin(page, { appCode: 'developSystem' }) + // 默认 testspace 测试场; developSystem/workSystem 是 JNPF 只读 baseline, 禁止用 + const loginAppCode = process.env.PLAYWRIGHT_AUTH_APP_CODE || 'testspace' + const ok = await loginAsAdmin(page, { appCode: loginAppCode }) expect(ok, 'UI 登录应跳到 /home').toBe(true) // 健壮性: 验证 storage 有 access token diff --git a/tests/e2e/baseline/template.spec.ts b/tests/e2e/baseline/template.spec.ts index f8ae105..3e63923 100644 --- a/tests/e2e/baseline/template.spec.ts +++ b/tests/e2e/baseline/template.spec.ts @@ -11,15 +11,16 @@ import { test, expect } from '@playwright/test' import { execSync } from 'node:child_process' // ========== 配置 ========== -const APP_CODE = 'developSystem' // 源 app +const APP_CODE = 'developSystem' // 源 app = JNPF 只读 baseline (仅 form info / export 用, 不要写) const ENCODE = 'leaveApply' // 源表单 enCode const CLONE_ENCODE = `${ENCODE}_clone` // 克隆 enCode +const TARGET_APP = process.env.TARGET_APP || 'testspace' // 目标 app = 统一测试场 (默认; 改 tds 也行, 但别用 developSystem/workSystem) const TARGET_URL = `http://127.0.0.1:13880/web/#/${CLONE_ENCODE}` // 实际访问 URL // 注: TARGET_URL 取决于 nginx 配置, 调整时改这里 // ========== 1. 拉克隆 id ========== function getCloneId(): string { - const out = execSync(`npx tsx src/cli.ts form list --appCode=tds`, { + const out = execSync(`npx tsx src/cli.ts form list --appCode=${TARGET_APP}`, { cwd: process.cwd(), encoding: 'utf-8', }) diff --git a/tests/e2e/smoke.spec.ts b/tests/e2e/smoke.spec.ts index 7946d1c..cd7ec41 100644 --- a/tests/e2e/smoke.spec.ts +++ b/tests/e2e/smoke.spec.ts @@ -13,7 +13,7 @@ import { test, expect } from '@playwright/test' import { execSync } from 'node:child_process' -const APP_CODE = 'developSystem' +const APP_CODE = process.env.SMOKE_APP_CODE || 'testspace' // 默认测试场; developSystem/workSystem 是 JNPF 只读 baseline test('JNPF web UI 加载 (nginx)', async ({ page }) => { const res = await page.goto('/') @@ -29,7 +29,7 @@ test('dacli app login + form list 端到端 (v0.9 命名规范化: login → app { encoding: 'utf-8', cwd: process.cwd() }, ) // 至少返回一些 form - expect(out).toMatch(/developSystem|"enCode"|"id"/i) + expect(out).toMatch(/testspace|"enCode"|"id"/i) }) test('JNPF 登录页能渲染', async ({ browser }) => {