fix(build): normalize Windows workspace package globs

This commit is contained in:
creatixchu
2026-10-12 17:46:09 +08:00
parent 30b47e05f8
commit d629b0fd9f
3 changed files with 26 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
/** Windows manifest paths still select the packages whose artifacts Desktop bundles. */
import { globSync } from 'node:fs'
import { resolve, win32 } from 'node:path'
import { expect, it } from 'vitest'
import { workspacePackageGlobs } from './workspace-package-globs.ts'
it('selects workspace packages from Windows and POSIX manifest paths', () => {
const cwd = resolve(import.meta.dirname, '..')
const manifests = ['packages\\util\\atomic-write\\package.json', 'vendor/cordis/package.json']
const selected = globSync(workspacePackageGlobs(manifests), { cwd }).map(path => path.replaceAll('\\', '/')).sort()
expect(selected).toEqual(['packages/util/atomic-write', 'vendor/cordis'])
expect(globSync(manifests.map(path => win32.dirname(path)), { cwd })).toEqual([])
})
+11
View File
@@ -0,0 +1,11 @@
/** Convert discovered package manifests into portable bundler workspace patterns. */
import { posix } from 'node:path'
/**
* Keep filesystem separators from becoming escapes in workspace globs.
* @param manifests - Repository-relative manifest paths returned by filesystem discovery.
* @returns Package directory patterns using forward slashes on every host.
*/
export function workspacePackageGlobs(manifests: readonly string[]): string[] {
return manifests.map(path => posix.dirname(path.replaceAll('\\', '/')))
}
+2 -2
View File
@@ -1,8 +1,8 @@
import { globSync } from 'node:fs'
import { dirname } from 'node:path'
import { defineConfig } from 'tsdown'
import { typertPlugin } from './packages/typert/generator/lib/types/tsdown-plugin.js'
import { WORKSPACE_TYPERT_FACES } from './scripts/typert-faces.ts'
import { workspacePackageGlobs } from './scripts/workspace-package-globs.ts'
function isBuildFaceClient(value: unknown): boolean {
if (value === undefined || value === 'host') return false
@@ -21,7 +21,7 @@ function isBuildFaceClient(value: unknown): boolean {
*/
export default defineConfig(({ env }) => {
const client = isBuildFaceClient(env?.DSH_BUILD_FACE)
const packages = globSync(['vendor/*/package.json', 'packages/*/*/package.json'], { cwd: import.meta.dirname }).map(dirname)
const packages = workspacePackageGlobs(globSync(['vendor/*/package.json', 'packages/*/*/package.json'], { cwd: import.meta.dirname }))
return {
workspace: [...packages, 'apps/cli', ...client ? [] : ['apps/desktop-host']],
entry: client ? '' : ['lib/types/{index,startup}.js'],