feat(dsh-sdk): create <source> — add external plugin as native PM dependency + cordis mount

dsh-sdk create <source> adds a github (github:owner/repo#ref) or npm (pkg@version)
plugin as a package-manager-native dependency, then mounts the resolved dependency
in cordis.yml through ProjectEditSession. Adds PackageManager.add(spec) and
ProjectEditSession.addExternalPlugin(id, packageName). No giget/pacote. Per-file
100% coverage on the new/changed files.
This commit is contained in:
imccyu
2026-07-17 16:01:48 +08:00
parent 16485392e4
commit ca7533880e
9 changed files with 230 additions and 1 deletions
@@ -298,6 +298,11 @@ describe('package manager strategies', () => {
await npm.install('/tmp', runner)
await npm.build('/tmp', runner)
expect(calls).toEqual([['npm', 'install'], ['npm', 'run', 'build']])
await npm.add('some-pkg@1.0.0', '/tmp', runner)
const pnpm = createPackageManager('pnpm', '10.0.0')
await pnpm.add('github:o/r#sha', '/tmp', runner)
expect(calls).toContainEqual(['npm', 'install', 'some-pkg@1.0.0'])
expect(calls).toContainEqual(['pnpm', 'add', 'github:o/r#sha'])
const failed: CommandRunner = { run: async () => ({ exitCode: 2, signal: null }) }
await expect(npm.install('/tmp', failed)).rejects.toThrow('exited with code 2')
const killed: CommandRunner = { run: async () => ({ exitCode: null, signal: 'SIGTERM' }) }