* feat(release): publish package source, declaration maps, and documentation Every release member publishes its TypeScript source and the declaration maps that resolve into it, and @deepseek-ai/dsh publishes the repository Markdown documentation staged from docs/ at prepack time. The ./src/* export most members already declared now resolves for an installed consumer, and a consumer editor follows a declaration to the implementation. Bundled JavaScript maps stay unpublished; the vendored family and the Desktop runtime file policy are unchanged. Rationale: .agents/notes/implemented/process/2026-10-08-published-source-and-docs.md * feat(release): publish JavaScript maps and compress bundles Every emitted JavaScript map ships beside the bundle it describes, and the workspace build and the client preset compress bundles without mangling identifiers. The documentation payload now mirrors the website publication manifest and is removed again by `postpack`; Desktop and the Python executable exclude the published source, documentation, and maps; `clean` removes a staged copy. Typert's publication contract gains the Remote declaration map. * fix(release): keep node bundles readable for the worker image The browser worker image lowers `yield*` only as a whole statement and rewrites `for await` loops by their source layout, so compressed node-side entries either fail that lowering or lower to unparseable code. Only the browser bundles keep compression, which removes about a third of their text. The bundle-purity assertion now matches the module-loader call regardless of the quote style compression picks, and the release-pack fixture exercises the installed package's new documentation requirement. * feat(release): publish the whole documentation tree `@deepseek-ai/dsh` copies `docs/` in full instead of the website's page set: the maintainer documents, the generated migration records, the translation guidelines, and the `*.i18n.yaml` consistency records ship with the installed package, so the documentation's own links resolve without a checkout. * feat(release): publish the upgrade guides with the documentation The staged documentation keeps the website's page set and adds every `docs/upgrade-guide/` document, which is what an installed reader consults when a released change breaks something. The rest of the maintainer tree stays out. * test(release): expect source and maps in master's new payload cases * feat(release): keep installed docs and source readable in Desktop Desktop keeps the published src/ and docs/ trees inside app.asar, and every model shell call receives DSH_INSTALL_DIR and DSH_NODE_EXECUTABLE so an agent can read them through Electron's Node mode. Staging also generates docs/upgrade-guide/README.md, an index of the upgrade guides grouped by the release they upgrade from. Minified client bundles print string literals with backticks: the worker image packer now recognizes those chunk requests, client license banners are prepended after minification so their text survives, and the affected artifact tests accept either quote. * test(desktop): read archived docs through the Windows PowerShell form Regenerate the config catalog for the shifted shell-env source line. * test(desktop): wait for the GUI-subsystem Electron process from PowerShell * build(release): publish source and maps from the message-quotes package * build(release): publish source and maps from packages new on master * build(release): publish source and maps from the tool-office package
118 lines
6.3 KiB
TypeScript
118 lines
6.3 KiB
TypeScript
/** Published PDF and spreadsheet chunks retain their bundled license notices. */
|
|
import { spawnSync } from 'node:child_process'
|
|
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { dirname, join, resolve } from 'node:path'
|
|
import { createRequire } from 'node:module'
|
|
import { runInNewContext } from 'node:vm'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const packageRoot = resolve(import.meta.dirname, '..')
|
|
const bundlePath = join(packageRoot, 'lib/client.js')
|
|
const pdfChunkPath = join(packageRoot, 'lib/client.pdf.js')
|
|
const require = createRequire(import.meta.url)
|
|
const licenseNames = [
|
|
'LICENSE',
|
|
'cmaps/LICENSE',
|
|
'standard_fonts/LICENSE_FOXIT',
|
|
'standard_fonts/LICENSE_LIBERATION',
|
|
'wasm/LICENSE_JBIG2',
|
|
'wasm/LICENSE_OPENJPEG',
|
|
'wasm/LICENSE_PDFJS_JBIG2',
|
|
'wasm/LICENSE_PDFJS_OPENJPEG',
|
|
'wasm/LICENSE_PDFJS_QCMS',
|
|
'wasm/LICENSE_QCMS',
|
|
] as const
|
|
|
|
function run(command: string, args: string[], cwd: string, timeout: number): string {
|
|
const result = spawnSync(command, args, { cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout })
|
|
expect(result.error).toBeUndefined()
|
|
expect(result.signal, result.stderr).toBeNull()
|
|
expect(result.status, result.stderr).toBe(0)
|
|
return result.stdout
|
|
}
|
|
|
|
function runPnpm(args: string[], cwd: string, timeout: number): string {
|
|
const entrypoint = process.env.npm_execpath
|
|
if (entrypoint === undefined || entrypoint === '') {
|
|
if (process.platform === 'win32') throw new Error('npm_execpath is required to run pnpm on Windows')
|
|
return run('pnpm', args, cwd, timeout)
|
|
}
|
|
return /\.[cm]?js$/iu.test(entrypoint)
|
|
? run(process.execPath, [entrypoint, ...args], cwd, timeout)
|
|
: run(entrypoint, args, cwd, timeout)
|
|
}
|
|
|
|
describe('published document preview licenses', () => {
|
|
it.skipIf(!existsSync(bundlePath))('keeps bundled licenses in the packed lazy chunks', ({ task }) => {
|
|
expect(existsSync(pdfChunkPath)).toBe(true)
|
|
const output = mkdtempSync(join(tmpdir(), 'dsh-document-preview-pack-'))
|
|
try {
|
|
const packed = JSON.parse(runPnpm([
|
|
'pack', '--json', '--pack-destination', output,
|
|
], packageRoot, task.timeout)) as { filename: string; files: { path: string }[] }
|
|
expect(packed.files.map(file => file.path)).toContain('lib/client.js')
|
|
expect(packed.files.map(file => file.path)).toContain('lib/client.pdf.js')
|
|
expect(packed.files.map(file => file.path)).toContain('lib/client.frontmatter-fields.js')
|
|
expect(packed.files.some(file => file.path.endsWith('pdfjs-NOTICES.txt'))).toBe(false)
|
|
|
|
const client = run('tar', ['-xOf', resolve(packageRoot, packed.filename), 'package/lib/client.js'], packageRoot, task.timeout)
|
|
const pdf = run('tar', ['-xOf', resolve(packageRoot, packed.filename), 'package/lib/client.pdf.js'], packageRoot, task.timeout)
|
|
expect([...client.matchAll(/require\.async\((["'`])(\.\/client[^"'`/]*\.js)\1\)/gu)].map(match => match[2]))
|
|
.toEqual(['./client.frontmatter-fields.js', './client.pdf.js', './client.excel.js'])
|
|
expect(client).not.toMatch(/\brequire\((["'`])\.\/client[^"'`/]*\.js\1\)/u)
|
|
expect([...pdf.matchAll(/require\((["'`])(\.\/client[^"'`/]*\.js)\1\)/gu)].map(match => match[2]))
|
|
.toEqual([])
|
|
expect(client).not.toContain('//! Bundled PDF.js license notices')
|
|
expect(client).not.toContain('/pdfjs-dist/')
|
|
expect(pdf).toContain('//! Bundled PDF.js license notices')
|
|
const excel = run('tar', ['-xOf', resolve(packageRoot, packed.filename), 'package/lib/client.excel.js'], packageRoot, task.timeout)
|
|
expect(excel).not.toMatch(/\brequire\((["'`])\.\/client[^"'`/]*\.js\1\)/u)
|
|
expect(client).not.toContain('FortuneSheet')
|
|
expect(excel).toContain('//! Bundled spreadsheet license notices')
|
|
expect(excel).toContain('Copyright (c) 2022 Suzhou Ruilisi Technology Co., Ltd')
|
|
expect(excel).toContain('Permission is hereby granted, free of charge')
|
|
for (const dependency of ['xlsx', 'papaparse']) {
|
|
const root = dirname(require.resolve(dependency === 'xlsx' ? dependency : `${dependency}/package.json`))
|
|
const license = readFileSync(join(root, 'LICENSE'), 'utf8').trimEnd()
|
|
expect(excel).toContain(license.split('\n').map(line => `// ${line}`).join('\n'))
|
|
}
|
|
const frontmatter = run('tar', ['-xOf', resolve(packageRoot, packed.filename), 'package/lib/client.frontmatter-fields.js'], packageRoot, task.timeout)
|
|
expect(frontmatter).not.toMatch(/\brequire\((["'`])\.\/client[^"'`/]*\.js\1\)/u)
|
|
let frontmatterInitialized = false
|
|
runInNewContext(frontmatter, { window: { __ModuleLoader__: { load: (registration: {
|
|
factory: (resolve: (specifier: string) => unknown) => { FrontmatterFields: unknown }
|
|
}) => {
|
|
const loaded = registration.factory((specifier) => {
|
|
if (specifier === 'react' || specifier === 'react/jsx-runtime') return require(specifier)
|
|
throw new Error(`Unexpected browser dependency: ${specifier}`)
|
|
})
|
|
expect(typeof loaded.FrontmatterFields).toBe('function')
|
|
frontmatterInitialized = true
|
|
} } } })
|
|
expect(frontmatterInitialized).toBe(true)
|
|
let initialized = false
|
|
runInNewContext(excel, { window: { __ModuleLoader__: { load: (registration: {
|
|
factory: (resolve: (specifier: string) => unknown) => { ExcelBody: unknown }
|
|
}) => {
|
|
const loaded = registration.factory((specifier) => {
|
|
if (specifier === '@deepseek-ai/dsh-client-ui-primitives') return {}
|
|
if (specifier === 'react' || specifier === 'react/jsx-runtime' || specifier === 'react-dom') return require(specifier)
|
|
throw new Error(`Unexpected browser dependency: ${specifier}`)
|
|
})
|
|
expect(typeof loaded.ExcelBody).toBe('function')
|
|
initialized = true
|
|
} } } })
|
|
expect(initialized).toBe(true)
|
|
const pdfRoot = dirname(require.resolve('pdfjs-dist/package.json'))
|
|
for (const name of licenseNames) {
|
|
const source = readFileSync(join(pdfRoot, name), 'utf8').trimEnd()
|
|
const commented = [`// ${name}`, '// ', ...source.split('\n').map(line => `// ${line}`)].join('\n')
|
|
expect(pdf, `${name} must be visible in package/lib/client.pdf.js`).toContain(commented)
|
|
}
|
|
} finally {
|
|
rmSync(output, { recursive: true, force: true })
|
|
}
|
|
})
|
|
})
|