|
|
@@ -46,11 +46,14 @@ describe('config-io', () => {
|
|
|
mock.restore();
|
|
|
});
|
|
|
|
|
|
- function writePackageJson(dir: string): void {
|
|
|
+ function writePackageJson(dir: string, version?: string): void {
|
|
|
mkdirSync(dir, { recursive: true });
|
|
|
writeFileSync(
|
|
|
join(dir, 'package.json'),
|
|
|
- JSON.stringify({ name: 'oh-my-opencode-slim' }),
|
|
|
+ JSON.stringify({
|
|
|
+ name: 'oh-my-opencode-slim',
|
|
|
+ ...(version ? { version } : {}),
|
|
|
+ }),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -181,6 +184,26 @@ describe('config-io', () => {
|
|
|
expect(saved.plugin).toEqual(['oh-my-opencode-slim']);
|
|
|
});
|
|
|
|
|
|
+ test('addPluginToOpenCodeConfig pins version for bunx temp paths', async () => {
|
|
|
+ const configPath = join(tmpDir, 'opencode', 'opencode.json');
|
|
|
+ const packageRoot = join(
|
|
|
+ tmpDir,
|
|
|
+ 'bunx-1000-oh-my-opencode-slim@latest',
|
|
|
+ 'node_modules',
|
|
|
+ 'oh-my-opencode-slim',
|
|
|
+ );
|
|
|
+ paths.ensureConfigDir();
|
|
|
+ writeFileSync(configPath, JSON.stringify({ plugin: [] }));
|
|
|
+ writePackageJson(packageRoot, '1.2.3');
|
|
|
+ process.argv[1] = join(packageRoot, 'dist', 'cli', 'index.js');
|
|
|
+
|
|
|
+ const result = await addPluginToOpenCodeConfig();
|
|
|
+
|
|
|
+ expect(result.success).toBe(true);
|
|
|
+ const saved = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
|
+ expect(saved.plugin).toEqual(['oh-my-opencode-slim@1.2.3']);
|
|
|
+ });
|
|
|
+
|
|
|
test('addPluginToOpenCodeConfig stores local repo path for local dev paths', async () => {
|
|
|
const configPath = join(tmpDir, 'opencode', 'opencode.json');
|
|
|
const packageRoot = join(tmpDir, 'repo');
|