🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(cli): print wrapped artifact share URL after publish (#19536)
Inneifc346bc4cb2f
diff --git a/apps/cli/src/commands/artifact.test.ts b/apps/cli/src/commands/artifact.test.tsindex 95374ab910b..9d72248fd76 100644--- a/apps/cli/src/commands/artifact.test.ts+++ b/apps/cli/src/commands/artifact.test.ts@@ -23,6 +23,7 @@ const { getTrpcClient: mockGetTrpcClient } = vi.hoisted(() => ({}));vi.mock('../api/client', () => ({ getTrpcClient: mockGetTrpcClient }));+vi.mock('../settings', () => ({ resolveServerUrl: () => 'https://app.lobehub.com' }));describe('artifact publish', () => {let workingDirectory: string;@@ -158,6 +159,27 @@ describe('artifact publish', () => {expect(readManifest().artifacts['index.html']).toEqual({ deploymentId: 'dep-1' });});+ it('prints the product share URL rather than the raw hosting URL', async () => {+ await publish();++ const output = consoleSpy.mock.calls.flat().join('\n');+ expect(output).toContain('https://app.lobehub.com/share/artifact/dep-1');+ expect(output).not.toContain('https://example.com/p');+ });++ it('emits the product share URL as publicUrl in JSON output', async () => {+ await publish('--json');++ const payload = JSON.parse(+ consoleSpy.mock.calls+ .flat()+ .filter((value): value is string => typeof value === 'string')+ .join('\n'),+ );+ expect(payload.publicUrl).toBe('https://app.lobehub.com/share/artifact/dep-1');+ expect(payload.id).toBe('dep-1');+ });+it('republishes to the bound deployment instead of creating another', async () => {writeManifest({ 'index.html': { deploymentId: 'dep-existing' } });diff --git a/apps/cli/src/commands/artifact.ts b/apps/cli/src/commands/artifact.tsindex 1559ccd5742..26fc9b05d72 100644--- a/apps/cli/src/commands/artifact.ts+++ b/apps/cli/src/commands/artifact.ts@@ -5,10 +5,12 @@ import {hostedPath,packWorkspaceHtmlDocument,} from '@lobechat/html-artifact';+import { artifactShareUrl } from '@lobechat/utils/artifactShare';import type { Command } from 'commander';import pc from 'picocolors';import { getTrpcClient, type TrpcClient } from '../api/client';+import { resolveServerUrl } from '../settings';import {createIdempotencyKey,readBinding,@@ -240,14 +242,19 @@ export function registerArtifactCommand(program: Command) {writeBinding(manifest, { deploymentId: result.data.id });}+ const publicUrl = result.data.id+ ? artifactShareUrl(resolveServerUrl(), result.data.id)+ : result.data.publicUrl;+ const payload = { ...result.data, publicUrl };+if (options.json !== undefined) {const fields = typeof options.json === 'string' ? options.json : undefined;- outputJson(result.data, fields);+ outputJson(payload, fields);return;}console.log(`${pc.green('✓')} Published ${pc.bold(title)} (${entries.length} file(s))`);- if (result.data.publicUrl) console.log(` URL: ${pc.dim(result.data.publicUrl)}`);+ if (publicUrl) console.log(` URL: ${pc.dim(publicUrl)}`);console.log(` Deployment: ${pc.dim(result.data.id ?? '')}`);},);diff --git a/src/utils/artifactShare.ts b/packages/utils/src/artifactShare.tssimilarity index 100%rename from src/utils/artifactShare.tsrename to packages/utils/src/artifactShare.tsdiff --git a/src/utils/artifactShare.test.ts b/src/utils/artifactShare.test.tsdeleted file mode 100644index 75925e38094..00000000000--- a/src/utils/artifactShare.test.ts+++ /dev/null@@ -1,15 +0,0 @@-import { describe, expect, it } from 'vitest';--import { artifactSharePath, artifactShareUrl } from './artifactShare';--describe('artifactShareUrl', () => {- it('builds the product share path and URL', () => {- expect(artifactSharePath('42')).toBe('/share/artifact/42');- expect(artifactShareUrl('https://app.lobehub.com', '42')).toBe(- 'https://app.lobehub.com/share/artifact/42',- );- expect(artifactShareUrl('https://app.lobehub.com/', '42')).toBe(- 'https://app.lobehub.com/share/artifact/42',- );- });-});