mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
This commit is contained in:
parent
da4d57c1db
commit
13da286b55
@ -36,7 +36,7 @@ describe('defaultPluginsUtils', () => {
|
||||
});
|
||||
|
||||
it('should load default plugins when nor previously installed', (async () => {
|
||||
const testPluginDir = `${supportDir}/pluginRepo/plugins`;
|
||||
const testPluginDir = `${supportDir}/testDefaultPlugins`;
|
||||
Setting.setValue('installedDefaultPlugins', []);
|
||||
|
||||
const service = newPluginService('2.1');
|
||||
@ -57,7 +57,7 @@ describe('defaultPluginsUtils', () => {
|
||||
}));
|
||||
|
||||
it('should keep already created default plugins disabled with previous default plugins installed', (async () => {
|
||||
const testPluginDir = `${supportDir}/pluginRepo/plugins`;
|
||||
const testPluginDir = `${supportDir}/testDefaultPlugins`;
|
||||
Setting.setValue('installedDefaultPlugins', ['org.joplinapp.plugins.ToggleSidebars']);
|
||||
Setting.setValue('plugins.states', {
|
||||
'org.joplinapp.plugins.ToggleSidebars': { ...defaultPluginSetting(), enabled: false },
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { copy, exists, remove, mkdirp, readdir, mkdtemp } from 'fs-extra';
|
||||
import { copy, exists, remove, readdir, mkdtemp } from 'fs-extra';
|
||||
import { join, resolve, basename } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { chdir, cwd } from 'process';
|
||||
@ -95,17 +95,11 @@ const buildDefaultPlugins = async (outputParentDir: string|null, beforeInstall:
|
||||
|
||||
if (outputParentDir !== null) {
|
||||
logStatus(`Checking output directory in ${outputParentDir}`);
|
||||
const outputDirectory = join(outputParentDir, pluginId);
|
||||
if (await exists(outputDirectory)) {
|
||||
await remove(outputDirectory);
|
||||
}
|
||||
await mkdirp(outputDirectory);
|
||||
const outputPath = join(outputParentDir, `${pluginId}.jpl`);
|
||||
|
||||
const sourceFile = jplFiles[0];
|
||||
const destFile = join(outputDirectory, 'plugin.jpl');
|
||||
|
||||
logStatus(`Copying built file from ${sourceFile} to ${destFile}`);
|
||||
await copy(sourceFile, destFile);
|
||||
logStatus(`Copying built file from ${sourceFile} to ${outputPath}`);
|
||||
await copy(sourceFile, outputPath);
|
||||
} else {
|
||||
console.warn('No output directory specified. Not copying built .jpl files.');
|
||||
}
|
||||
|
@ -27,15 +27,26 @@ export const getDefaultPluginPathsAndSettings = async (
|
||||
|
||||
for (const pluginStat of defaultPluginsPaths) {
|
||||
// Each plugin should be within a folder with the same ID as the plugin
|
||||
const pluginFolderName = pluginStat.path;
|
||||
const pluginId = pluginFolderName;
|
||||
const pluginFileName = pluginStat.path;
|
||||
const pluginIdMatch = pluginFileName.match(/^(.*)+\.jpl$/);
|
||||
|
||||
// Previously, default plugins were stored as
|
||||
// default-plugin-id/plugin.jpl
|
||||
// We handle this case by skipping files that don't match the format
|
||||
// default-plugin-id.jpl
|
||||
if (!pluginIdMatch) {
|
||||
logger.warn(`Default plugin filename ${pluginFileName} is not a .JPL file. Skipping.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const pluginId = pluginIdMatch[1];
|
||||
|
||||
if (!defaultPluginsInfo.hasOwnProperty(pluginId)) {
|
||||
logger.warn(`Default plugin ${pluginId} is missing in defaultPluginsInfo. Not loading.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
pluginPaths.push(join(defaultPluginsDir, pluginFolderName, 'plugin.jpl'));
|
||||
pluginPaths.push(join(defaultPluginsDir, pluginFileName));
|
||||
|
||||
pluginSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
||||
// Default plugins can be overridden but not uninstalled (as they're part of
|
||||
|
Loading…
Reference in New Issue
Block a user