mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-10-26 16:55:08 +00:00
test(release): cover baseline package discovery
This commit is contained in:
1 parent
6e30e1a300
commit
251210d517
3 files changed
+101
-11
No files matched your search
@@ -0,0 +1,73 @@
|
||||
/** Baseline package selection through Node's real filesystem glob implementation. */
|
||||
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { describe, expect, it, onTestFinished } from 'vitest'
|
||||
import { PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES } from './experimental-package-policy.ts'
|
||||
import { discoverNpmBaselineManifests } from './npm-baseline-packages.ts'
|
||||
|
||||
function fixture(manifests: readonly string[]): string {
|
||||
const root = mkdtempSync(join(tmpdir(), 'dsh-baseline-discovery-'))
|
||||
onTestFinished(() => { rmSync(root, { recursive: true, force: true }) })
|
||||
for (const manifest of manifests) {
|
||||
const file = join(root, manifest)
|
||||
mkdirSync(dirname(file), { recursive: true })
|
||||
writeFileSync(file, '{}\n')
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
describe('npm baseline package discovery', () => {
|
||||
it('discovers ordinary package roots and unlisted experimental packages', () => {
|
||||
const expected = [
|
||||
'apps/cli/package.json',
|
||||
'packages/core/session/package.json',
|
||||
'packages/experimental/agent-team/package.json',
|
||||
'packages/experimental/new-prototype/package.json',
|
||||
'vendor/cordis/package.json',
|
||||
]
|
||||
const root = fixture([
|
||||
...expected,
|
||||
'package.json',
|
||||
'packages/experimental/new-prototype/nested/package.json',
|
||||
'website/package.json',
|
||||
])
|
||||
|
||||
expect(discoverNpmBaselineManifests(root)).toEqual(expected)
|
||||
})
|
||||
|
||||
it('excludes every directory in the current publication denylist', () => {
|
||||
const allowed = 'packages/experimental/new-prototype/package.json'
|
||||
const root = fixture([
|
||||
allowed,
|
||||
...PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES.map(directory => `${directory}/package.json`),
|
||||
])
|
||||
|
||||
expect(discoverNpmBaselineManifests(root)).toEqual([allowed])
|
||||
})
|
||||
|
||||
it('excludes an exact configured directory without excluding nearby names', () => {
|
||||
const root = fixture([
|
||||
'packages/experimental/internal/package.json',
|
||||
'packages/experimental/internal-tools/package.json',
|
||||
'packages/experimental/other/package.json',
|
||||
])
|
||||
expect(discoverNpmBaselineManifests(root, ['packages/experimental/internal'])).toEqual([
|
||||
'packages/experimental/internal-tools/package.json',
|
||||
'packages/experimental/other/package.json',
|
||||
])
|
||||
})
|
||||
|
||||
it('retains experimental packages when the configured denylist is empty', () => {
|
||||
const manifests = [
|
||||
'packages/experimental/inspector/package.json',
|
||||
'packages/experimental/new-prototype/package.json',
|
||||
]
|
||||
expect(discoverNpmBaselineManifests(fixture(manifests), [])).toEqual(manifests)
|
||||
})
|
||||
|
||||
it('leaves an empty package set for the baseline caller to reject', () => {
|
||||
expect(discoverNpmBaselineManifests(fixture([]))).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
/** Manifest discovery for the npm baseline's vendor, harness, and application packages. */
|
||||
|
||||
import { globSync } from 'node:fs'
|
||||
import { PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES } from './experimental-package-policy.ts'
|
||||
|
||||
const PACKAGE_PATTERNS = [
|
||||
'vendor/*/package.json',
|
||||
'packages/*/*/package.json',
|
||||
'apps/*/package.json',
|
||||
] as const
|
||||
|
||||
/**
|
||||
* Discover baseline manifests while excluding the configured private experimental directories.
|
||||
* @param root - repository root to scan.
|
||||
* @param privateDirectories - repository-relative experimental directories excluded from publication.
|
||||
* @returns Sorted repository-relative manifest paths with forward slashes.
|
||||
*/
|
||||
export function discoverNpmBaselineManifests(
|
||||
root: string,
|
||||
privateDirectories: readonly string[] = PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES,
|
||||
): string[] {
|
||||
return globSync(PACKAGE_PATTERNS, {
|
||||
cwd: root,
|
||||
exclude: privateDirectories.map(directory => `${directory}/package.json`),
|
||||
}).map(path => path.replaceAll('\\', '/')).sort()
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { spawnSync, type SpawnSyncReturns } from 'node:child_process'
|
||||
import { createHash } from 'node:crypto'
|
||||
import {
|
||||
existsSync,
|
||||
globSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
@@ -18,16 +17,11 @@ import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep
|
||||
import { createInterface } from 'node:readline/promises'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { parseArgs } from 'node:util'
|
||||
import { PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES } from './experimental-package-policy.ts'
|
||||
import { discoverNpmBaselineManifests } from './npm-baseline-packages.ts'
|
||||
import { validateTarballPayload } from './publication-payload.ts'
|
||||
|
||||
const DEFAULT_REGISTRY = 'https://registry.npm.harnessment.com'
|
||||
const DEFAULT_OUTPUT_DIRECTORY = '.artifacts/npm-baseline'
|
||||
const PACKAGE_PATTERNS = [
|
||||
'vendor/*/package.json',
|
||||
'packages/*/*/package.json',
|
||||
'apps/*/package.json',
|
||||
] as const
|
||||
const DEPENDENCY_SECTIONS = [
|
||||
'dependencies',
|
||||
'devDependencies',
|
||||
@@ -243,10 +237,7 @@ class WorkspacePackageSet {
|
||||
) {}
|
||||
|
||||
static discover(root: string): WorkspacePackageSet {
|
||||
const manifestPaths = globSync(PACKAGE_PATTERNS, {
|
||||
cwd: root,
|
||||
exclude: PRIVATE_EXPERIMENTAL_PACKAGE_DIRECTORIES.map(directory => `${directory}/package.json`),
|
||||
}).sort()
|
||||
const manifestPaths = discoverNpmBaselineManifests(root)
|
||||
if (manifestPaths.length === 0) {
|
||||
throw new Error('no package manifests found under vendor/, packages/, or apps/')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user