98b3221eec
CI / python runtime / release-shaped Linux x64 (push) Has been skipped
CI / node 24 / static (push) Has been cancelled
CI / node 24 / coverage (push) Has been cancelled
CI / node 24 / snapshots and artifacts (push) Has been cancelled
CI / node 22.19 (push) Has been cancelled
CI / node 26 (push) Has been cancelled
CI / python 3.10 / keyless SDK (push) Has been cancelled
CI / windows node 24 / wine blocking (push) Has been cancelled
CI / wine apt cache (push) Has been cancelled
CI / windows node 24 / native complete (push) Has been cancelled
CI / serial / linux (push) Has been cancelled
CI / serial / linux (self-hosted standby) (push) Has been cancelled
CI / serial / macos (push) Has been cancelled
CI / serial / windows (self-hosted standby) (push) Has been cancelled
CI / larger-runner-benchmark (16, linux, dsh-ubuntu-24-04-16core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (16, windows, dsh-windows-2025-16core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (32, linux, dsh-ubuntu-24-04-32core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (32, windows, dsh-windows-2025-32core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (4, linux, dsh-ubuntu-24-04-4core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (4, windows, dsh-windows-2025-4core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (64, linux, dsh-ubuntu-24-04-64core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (64, windows, dsh-windows-2025-64core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (8, linux, dsh-ubuntu-24-04-8core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (8, windows, dsh-windows-2025-8core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (96, linux, dsh-ubuntu-24-04-96core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (96, windows, dsh-windows-2025-96core, production-site) (push) Has been cancelled
CI / consolidated-runner-benchmark (16, linux, dsh-ubuntu-24-04-16core, 16) (push) Has been cancelled
CI / consolidated-runner-benchmark (16, windows, dsh-windows-2025-16core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (32, linux, dsh-ubuntu-24-04-32core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (32, windows, dsh-windows-2025-32core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (4, linux, dsh-ubuntu-24-04-4core, 4) (push) Has been cancelled
CI / consolidated-runner-benchmark (4, windows, dsh-windows-2025-4core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (64, linux, dsh-ubuntu-24-04-64core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (64, windows, dsh-windows-2025-64core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (8, linux, dsh-ubuntu-24-04-8core, 8) (push) Has been cancelled
CI / consolidated-runner-benchmark (8, windows, dsh-windows-2025-8core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (96, linux, dsh-ubuntu-24-04-96core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (96, windows, dsh-windows-2025-96core, 2) (push) Has been cancelled
E2E (real DeepSeek API) / e2e (push) Has been cancelled
Release (vendor) / Pack npm tarballs (push) Has been cancelled
Release (dsh) / Pack npm tarballs (push) Has been cancelled
Sandbox / sandbox e2e (seatbelt, macos-latest) (push) Has been cancelled
Sandbox / sandbox e2e (landlock, ubuntu-24.04) (push) Has been cancelled
Sandbox / sandbox e2e (landlock, ubuntu-24.04-arm) (push) Has been cancelled
Sandbox / sandbox e2e (bwrap, ubuntu-latest) (push) Has been cancelled
CI / all checks passed (push) Has been cancelled
Release (vendor) / Publish to npm (push) Has been cancelled
Release (dsh) / Publish to npm (push) Has been cancelled
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { load } from 'js-yaml'
|
|
import { registryNameOf, writeReleaseAgeExclude } from '../src/plugin.ts'
|
|
|
|
const dirs: string[] = []
|
|
function tempDir(): string {
|
|
const dir = mkdtempSync(join(tmpdir(), 'dsh-cli-plugin-'))
|
|
dirs.push(dir)
|
|
return dir
|
|
}
|
|
afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }) })
|
|
|
|
describe('registryNameOf', () => {
|
|
it('returns the bare name for a registry specifier', () => {
|
|
expect(registryNameOf('dsh-theme-plugin')).toBe('dsh-theme-plugin')
|
|
expect(registryNameOf('dsh-theme-plugin@latest')).toBe('dsh-theme-plugin')
|
|
expect(registryNameOf('@scope/pkg@1.2.0')).toBe('@scope/pkg')
|
|
})
|
|
|
|
it('returns undefined for non-registry sources', () => {
|
|
expect(registryNameOf('github:user/repo')).toBeUndefined()
|
|
expect(registryNameOf('git+https://github.com/user/repo.git')).toBeUndefined()
|
|
expect(registryNameOf('file:../plugin')).toBeUndefined()
|
|
expect(registryNameOf('./plugin')).toBeUndefined()
|
|
expect(registryNameOf('https://example.com/p.tgz')).toBeUndefined()
|
|
})
|
|
})
|
|
|
|
describe('writeReleaseAgeExclude', () => {
|
|
it('writes the exclusion into pnpm-workspace.yaml, preserving existing settings', () => {
|
|
const dir = tempDir()
|
|
writeFileSync(join(dir, 'pnpm-workspace.yaml'), 'packages:\n - .\nallowBuilds:\n node-pty: true\n')
|
|
writeReleaseAgeExclude(dir, ['dsh-theme-plugin'])
|
|
writeReleaseAgeExclude(dir, ['@scope/pkg'])
|
|
const doc = load(readFileSync(join(dir, 'pnpm-workspace.yaml'), 'utf8')) as Record<string, unknown>
|
|
expect(doc.minimumReleaseAgeExclude).toEqual(['dsh-theme-plugin', '@scope/pkg'])
|
|
expect((doc.allowBuilds as Record<string, unknown>)['node-pty']).toBe(true)
|
|
})
|
|
|
|
it('creates the file when absent', () => {
|
|
const dir = tempDir()
|
|
writeReleaseAgeExclude(dir, ['x'])
|
|
const doc = load(readFileSync(join(dir, 'pnpm-workspace.yaml'), 'utf8')) as Record<string, unknown>
|
|
expect(doc.minimumReleaseAgeExclude).toEqual(['x'])
|
|
})
|
|
})
|