Refine desktop setup and remove bundled app center apps
This commit is contained in:
@@ -134,7 +134,10 @@ describe('plugin installer diagnostics', () => {
|
||||
const sourceDir = 'C:\\Program Files\\ClawX\\resources\\openclaw-plugins\\wecom';
|
||||
const sourceManifestSuffix = 'Program Files\\ClawX\\resources\\openclaw-plugins\\wecom\\openclaw.plugin.json';
|
||||
|
||||
mockExistsSync.mockImplementation((input: string) => String(input).includes(sourceManifestSuffix));
|
||||
mockExistsSync.mockImplementation((input: string) => {
|
||||
const p = String(input);
|
||||
return p.includes(sourceManifestSuffix) || p.includes('openclaw-plugins\\wecom\\index.js');
|
||||
});
|
||||
// On win32, cpSyncSafe uses _copyDirSyncRecursive (readdirSync) instead of cpSync.
|
||||
// Simulate copy failure by making readdirSync throw during directory traversal.
|
||||
mockReaddirSync.mockImplementation((_path: string, opts?: unknown) => {
|
||||
@@ -187,7 +190,10 @@ describe('plugin installer diagnostics', () => {
|
||||
const sourceDir = 'C:\\Program Files\\ClawX\\resources\\openclaw-plugins\\wecom';
|
||||
const sourceManifestSuffix = 'Program Files\\ClawX\\resources\\openclaw-plugins\\wecom\\openclaw.plugin.json';
|
||||
|
||||
mockExistsSync.mockImplementation((input: string) => String(input).includes(sourceManifestSuffix));
|
||||
mockExistsSync.mockImplementation((input: string) => {
|
||||
const p = String(input);
|
||||
return p.includes(sourceManifestSuffix) || p.includes('openclaw-plugins\\wecom\\index.js');
|
||||
});
|
||||
// On win32, cpSyncSafe uses _copyDirSyncRecursive (readdirSync) instead of cpSync.
|
||||
mockReaddirSync.mockImplementation((_path: string, opts?: unknown) => {
|
||||
if (opts && typeof opts === 'object' && 'withFileTypes' in (opts as Record<string, unknown>)) {
|
||||
@@ -217,4 +223,77 @@ describe('plugin installer diagnostics', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('recognizes openclaw.extensions JavaScript entries as loadable runtime entries', async () => {
|
||||
const pluginDir = '/bundle/openclaw-lark';
|
||||
|
||||
mockReadFileSync.mockImplementation((input: string) => {
|
||||
if (String(input).endsWith('/package.json')) {
|
||||
return JSON.stringify({
|
||||
main: './dist/index.js',
|
||||
openclaw: { extensions: ['./index.js'] },
|
||||
});
|
||||
}
|
||||
return '{}';
|
||||
});
|
||||
mockExistsSync.mockImplementation((input: string) => String(input) === `${pluginDir}/index.js`);
|
||||
|
||||
const { hasPluginRuntimeEntry } = await import('@electron/utils/plugin-install');
|
||||
|
||||
expect(hasPluginRuntimeEntry(pluginDir)).toBe(true);
|
||||
});
|
||||
|
||||
it('reinstalls a same-version plugin when the installed copy is missing JS runtime output', async () => {
|
||||
const sourceDir = '/bundle/openclaw-weixin';
|
||||
const targetDir = '/home/test/.openclaw/extensions/openclaw-weixin';
|
||||
let copied = false;
|
||||
|
||||
mockExistsSync.mockImplementation((input: string) => {
|
||||
const p = String(input);
|
||||
if (p === `${sourceDir}/openclaw.plugin.json`) return true;
|
||||
if (p === `${targetDir}/openclaw.plugin.json`) return true;
|
||||
if (p === `${sourceDir}/dist/index.js`) return true;
|
||||
if (p === `${targetDir}/dist/index.js`) return copied;
|
||||
return false;
|
||||
});
|
||||
mockReadFileSync.mockImplementation((input: string) => {
|
||||
const p = String(input);
|
||||
if (p === `${sourceDir}/package.json`) {
|
||||
return JSON.stringify({
|
||||
version: '2.1.10',
|
||||
main: './dist/index.js',
|
||||
openclaw: { extensions: ['./dist/index.js'] },
|
||||
});
|
||||
}
|
||||
if (p === `${targetDir}/package.json`) {
|
||||
return copied
|
||||
? JSON.stringify({
|
||||
version: '2.1.10',
|
||||
main: './dist/index.js',
|
||||
openclaw: { extensions: ['./dist/index.js'] },
|
||||
})
|
||||
: JSON.stringify({
|
||||
version: '2.1.10',
|
||||
openclaw: { extensions: ['./index.ts'] },
|
||||
});
|
||||
}
|
||||
if (p === `${targetDir}/openclaw.plugin.json`) {
|
||||
return JSON.stringify({ id: 'openclaw-weixin' });
|
||||
}
|
||||
return '{}';
|
||||
});
|
||||
mockCpSync.mockImplementation(() => {
|
||||
copied = true;
|
||||
});
|
||||
|
||||
const { ensurePluginInstalled } = await import('@electron/utils/plugin-install');
|
||||
const result = ensurePluginInstalled('openclaw-weixin', [sourceDir], 'WeChat');
|
||||
|
||||
expect(result).toEqual({ installed: true });
|
||||
expect(mockRmSync).toHaveBeenCalledWith(targetDir, { recursive: true, force: true });
|
||||
expect(mockCpSync).toHaveBeenCalledWith(sourceDir, targetDir, { recursive: true, dereference: true });
|
||||
expect(mockLoggerInfo).toHaveBeenCalledWith(
|
||||
'[plugin] Reinstalling WeChat plugin: installed copy is missing a loadable runtime entry',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user