一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
43 行
1.4 KiB
TypeScript
43 行
1.4 KiB
TypeScript
import { execCommand } from '@joplin/utils';
|
|
import { copy } from 'fs-extra';
|
|
import { join } from 'path';
|
|
import { waitForCliInput } from '@joplin/utils/cli';
|
|
import buildDefaultPlugins from '../buildDefaultPlugins';
|
|
import getPathToPatchFileFor from '../utils/getPathToPatchFileFor';
|
|
|
|
const editPatch = async (targetPluginId: string, outputParentDir: string|null) => {
|
|
let patchedPlugin = false;
|
|
|
|
await buildDefaultPlugins({
|
|
outputParentDir: outputParentDir,
|
|
beforePatch: async () => {
|
|
// To make updating just the patch possible, a commit is created just before applying
|
|
// the patch.
|
|
await execCommand('git add .');
|
|
await execCommand(['git', 'config', 'user.name', 'Build script']);
|
|
await execCommand(['git', 'config', 'user.email', '']);
|
|
await execCommand(['git', 'commit', '-m', 'Initial commit']);
|
|
},
|
|
beforeInstall: async (buildDir, pluginId) => {
|
|
if (pluginId !== targetPluginId) {
|
|
return;
|
|
}
|
|
|
|
// eslint-disable-next-line no-console
|
|
console.log('Make changes to', buildDir, 'to create a patch.');
|
|
await waitForCliInput();
|
|
await execCommand(['sh', '-c', 'git diff -p > diff.diff']);
|
|
|
|
await copy(join(buildDir, './diff.diff'), getPathToPatchFileFor(pluginId));
|
|
|
|
patchedPlugin = true;
|
|
},
|
|
});
|
|
|
|
if (!patchedPlugin) {
|
|
throw new Error(`No patchable default plugin with ID ${targetPluginId} found! Make sure that the plugin has a "cloneUrl" and "branch" in pluginRepositories.json.`);
|
|
}
|
|
};
|
|
|
|
export default editPatch;
|