Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Resolves #7934: Add Simple Backup as a default plugin #9360

Merged
merged 46 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e6a70ea
WIP: Build default plugins in CI
personalizedrefrigerator Nov 22, 2023
3ff8dae
Plugin base repo
personalizedrefrigerator Nov 22, 2023
9be4526
Bundle note tabs and simple backup with the app
personalizedrefrigerator Nov 22, 2023
af9efa8
Remove note tabs from default plugins
personalizedrefrigerator Nov 23, 2023
4514e1b
Change patch method for simple-backup
personalizedrefrigerator Nov 23, 2023
6181e22
Change @joplin/utils dependency version specifier
personalizedrefrigerator Nov 23, 2023
610b0e3
Try to fix @joplin/utils dependency
personalizedrefrigerator Nov 24, 2023
fd88f12
Fix build
personalizedrefrigerator Nov 24, 2023
7396698
Initialize submodules on build if not yet initialized
personalizedrefrigerator Nov 24, 2023
9887ed7
Fix "no commit author" in CI and try to decrease size of simple-backu…
personalizedrefrigerator Nov 24, 2023
812fd2e
Use same version of `@types/yargs` as other packages
personalizedrefrigerator Nov 24, 2023
9db257b
Try to fix build on Windows
personalizedrefrigerator Nov 24, 2023
3cbd360
Mark plugins as built-in in manifest
personalizedrefrigerator Nov 24, 2023
632f011
Improve plugin patch command
personalizedrefrigerator Nov 24, 2023
8899d8f
Fix 7zip backups
personalizedrefrigerator Nov 24, 2023
f0545d0
Significantly decrease patch size
personalizedrefrigerator Nov 26, 2023
615fbe4
Merge remote-tracking branch 'upstream/dev' into pr/default-plugins
personalizedrefrigerator Nov 28, 2023
75b8227
Clone with git, rather than use submodules & change commit used for s…
personalizedrefrigerator Nov 28, 2023
da8953b
Refactoring
personalizedrefrigerator Nov 28, 2023
b4d115e
Show UI to mark a plugin as built-in
personalizedrefrigerator Nov 28, 2023
20d30db
Prevent default plugins from being updated through settings
personalizedrefrigerator Nov 28, 2023
b6f89b4
Fix 7zip still bundled with default copy of backup plugin
personalizedrefrigerator Nov 29, 2023
ddfd3ec
Merge remote-tracking branch 'upstream/dev' into pr/default-plugins
personalizedrefrigerator Nov 29, 2023
6a4cf2f
Update @types/yargs to match recent Renovate commit
personalizedrefrigerator Nov 29, 2023
ebfc8ab
Refactor build script into multiple files
personalizedrefrigerator Dec 4, 2023
3f4f1f5
Refactor: Make default-plugins a dependency of the desktop app (and b…
personalizedrefrigerator Dec 4, 2023
c743006
Remove built gulpfile
personalizedrefrigerator Dec 4, 2023
840d2e8
tsconfig.json: Avoid compiling gulpfile.ts
personalizedrefrigerator Dec 4, 2023
5868af5
Update default_plugins.md
personalizedrefrigerator Dec 5, 2023
2ca5a7b
Update simple backup plugin
personalizedrefrigerator Dec 5, 2023
58ffb86
Update gulpfile: Build default plugins after other portions of build …
personalizedrefrigerator Dec 5, 2023
ad1cb0d
Update setupNewRelease to also increase default-plugins package version
personalizedrefrigerator Dec 6, 2023
17fa5f7
Spelling: Remove extra "e"
personalizedrefrigerator Dec 6, 2023
304db99
Merge remote-tracking branch 'upstream/dev' into pr/default-plugins
personalizedrefrigerator Dec 7, 2023
40235f7
Revert changes to webpack.config.js: By default don't give plugin aut…
personalizedrefrigerator Dec 7, 2023
c47c2d1
Include only the 7zip binary for the current platform
personalizedrefrigerator Dec 7, 2023
2bf0e2c
Copy 7za for the target platform and architecture, not the current
personalizedrefrigerator Dec 7, 2023
8509fa8
Logging
personalizedrefrigerator Dec 7, 2023
d41d3f2
Add simple default plugins test
personalizedrefrigerator Dec 7, 2023
4165edd
Remove generated .js file from version control
personalizedrefrigerator Dec 7, 2023
806c7e5
Add additional simple backup test
personalizedrefrigerator Dec 7, 2023
4954c61
Fix importing 7zip-bin, fix "read only file system" error
personalizedrefrigerator Dec 7, 2023
9c581a1
Fix importing 7zip-bin in development mode
personalizedrefrigerator Dec 7, 2023
efc9dc4
Trying to make end-to-end test more reliable
personalizedrefrigerator Dec 7, 2023
c1ccafe
Make end-to-end tests more reliable -- wait for plugins to load
personalizedrefrigerator Dec 8, 2023
6926af8
Revert part of patch change to Simple Backup -- the error message it …
personalizedrefrigerator Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ packages/app-mobile/locales
packages/app-mobile/node_modules
packages/app-mobile/pluginAssets/
packages/fork-*
packages/default-plugins/plugin-base-repo/
packages/default-plugins/plugin-sources/
packages/htmlpack/dist/
packages/lib/assets/
packages/lib/lib/lib.js
Expand Down Expand Up @@ -380,6 +382,7 @@ packages/app-desktop/gui/style/StyledTextInput.js
packages/app-desktop/gui/utils/NoteListUtils.js
packages/app-desktop/gui/utils/convertToScreenCoordinates.js
packages/app-desktop/gui/utils/loadScript.js
packages/app-desktop/gulpfile.js
packages/app-desktop/integration-tests/main.spec.js
packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
Expand Down Expand Up @@ -529,6 +532,13 @@ packages/app-mobile/utils/fs-driver/runOnDeviceTests.js
packages/app-mobile/utils/setupNotifications.js
packages/app-mobile/utils/shareHandler.js
packages/app-mobile/utils/types.js
packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.test.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.js
packages/editor/CodeMirror/CodeMirror5Emulation/Decorator.js
Expand Down Expand Up @@ -1009,8 +1019,6 @@ packages/tools/build-translation.js
packages/tools/build-welcome.js
packages/tools/buildServerDocker.test.js
packages/tools/buildServerDocker.js
packages/tools/bundleDefaultPlugins.test.js
packages/tools/bundleDefaultPlugins.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.test.js
packages/tools/checkLibPaths.js
Expand Down
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ packages/app-desktop/gui/style/StyledTextInput.js
packages/app-desktop/gui/utils/NoteListUtils.js
packages/app-desktop/gui/utils/convertToScreenCoordinates.js
packages/app-desktop/gui/utils/loadScript.js
packages/app-desktop/gulpfile.js
packages/app-desktop/integration-tests/main.spec.js
packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
Expand Down Expand Up @@ -511,6 +512,13 @@ packages/app-mobile/utils/fs-driver/runOnDeviceTests.js
packages/app-mobile/utils/setupNotifications.js
packages/app-mobile/utils/shareHandler.js
packages/app-mobile/utils/types.js
packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.test.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.js
packages/editor/CodeMirror/CodeMirror5Emulation/Decorator.js
Expand Down Expand Up @@ -991,8 +999,6 @@ packages/tools/build-translation.js
packages/tools/build-welcome.js
packages/tools/buildServerDocker.test.js
packages/tools/buildServerDocker.js
packages/tools/bundleDefaultPlugins.test.js
packages/tools/bundleDefaultPlugins.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.test.js
packages/tools/checkLibPaths.js
Expand Down
4 changes: 3 additions & 1 deletion .npmpackagejsonlintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages/app-clipper/popup/
packages/app-cli/tests/support/plugins/
packages/doc-builder/
packages/doc-builder/
packages/default-plugins/plugin-base-repo/
packages/default-plugins/plugin-sources/
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ describe('defaultPluginsUtils', () => {

const defaultPluginsInfo: DefaultPluginsInfo = {
'io.github.jackgruber.backup': {
version: '1.0.2',
settings: {
'path': `${Setting.value('profileDir')}`,
},
},
'plugin.calebjohn.rich-markdown': {
version: '0.8.3',
},
};

Expand Down Expand Up @@ -245,14 +243,12 @@ describe('defaultPluginsUtils', () => {

const defaultPluginsInfo: DefaultPluginsInfo = {
'io.github.jackgruber.backup': {
version: '1.0.2',
settings: {
'path': `${Setting.value('profileDir')}`,
'missing-key1': 'someValue',
},
},
'plugin.calebjohn.rich-markdown': {
version: '0.8.3',
settings: {
'missing-key2': 'someValue',
},
Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ test-results/
playwright-report/
playwright/.cache/
integration-tests/test-profile/
build/defaultPlugins/
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CellRoot = styled.div<{ isCompatible: boolean }>`
box-sizing: border-box;
background-color: ${props => props.theme.backgroundColor};
flex-direction: column;
align-items: flex-start;
align-items: stretch;
padding: 15px;
border: 1px solid ${props => props.theme.dividerColor};
border-radius: 6px;
Expand Down Expand Up @@ -96,12 +96,15 @@ const NeedUpgradeMessage = styled.span`
font-size: ${props => props.theme.fontSize}px;
`;

const DevModeLabel = styled.div`
const BoxedLabel = styled.div`
border: 1px solid ${props => props.theme.color};
border-radius: 4px;
padding: 4px 6px;
font-size: ${props => props.theme.fontSize * 0.75}px;
color: ${props => props.theme.color};
flex-grow: 0;
height: min-content;
margin-top: auto;
`;

const StyledNameAndVersion = styled.div<{ mb: any }>`
Expand Down Expand Up @@ -170,7 +173,7 @@ export default function(props: Props) {
if (!props.onToggle) return null;

if (item.devMode) {
return <DevModeLabel>DEV</DevModeLabel>;
return <BoxedLabel>DEV</BoxedLabel>;
}

return <ToggleButton
Expand Down Expand Up @@ -217,6 +220,17 @@ export default function(props: Props) {
/>;
}

const renderDefaultPluginLabel = () => {
// Built-in plugins can only be disabled
if (item.manifest._built_in) {
return (
<BoxedLabel>{_('Built in')}</BoxedLabel>
laurent22 marked this conversation as resolved.
Show resolved Hide resolved
);
}

return null;
};

function renderFooter() {
if (item.devMode) return null;

Expand All @@ -236,6 +250,7 @@ export default function(props: Props) {
{renderInstallButton()}
{renderUpdateButton()}
<div style={{ display: 'flex', flex: 1 }}/>
{renderDefaultPluginLabel()}
</CellFooter>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,18 @@ export default function(props: Props) {
let cancelled = false;

async function fetchPluginIds() {
const pluginIds = await repoApi().canBeUpdatedPlugins(pluginItems.map(p => p.manifest), pluginService.appVersion);
// Built-in plugins can't be updated from the main repoApi
const nonDefaultPlugins = pluginItems
.map(p => p.manifest)
.filter(manifest => !manifest._built_in);

const pluginIds = await repoApi().canBeUpdatedPlugins(nonDefaultPlugins, pluginService.appVersion);
if (cancelled) return;

const conv: Record<string, boolean> = {};
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
pluginIds.forEach(id => conv[id] = true);
for (const id of pluginIds) {
conv[id] = true;
}
setCanBeUpdatedPluginIds(conv);
}

Expand Down Expand Up @@ -281,10 +288,17 @@ export default function(props: Props) {
</UserPluginsRoot>
);
} else {
const nonDefaultPlugins = pluginItems.filter(item => !item.manifest._built_in);
const defaultPlugins = pluginItems.filter(item => item.manifest._built_in);
return (
<UserPluginsRoot>
{renderCells(pluginItems)}
</UserPluginsRoot>
<>
<UserPluginsRoot>
{renderCells(nonDefaultPlugins)}
</UserPluginsRoot>
<UserPluginsRoot>
{renderCells(defaultPlugins)}
</UserPluginsRoot>
</>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const gulp = require('gulp');
const utils = require('@joplin/tools/gulp/utils');
const compileSass = require('@joplin/tools/compileSass');
const compilePackageInfo = require('@joplin/tools/compilePackageInfo');
import buildDefaultPlugins from '@joplin/default-plugins/commands/buildAll';

const tasks = {
compileScripts: {
Expand All @@ -24,6 +25,12 @@ const tasks = {
electronBuilder: {
fn: require('./tools/electronBuilder.js'),
},
buildDefaultPlugins: {
fn: async () => {
const outputDir = `${__dirname}/build/defaultPlugins/`;
await buildDefaultPlugins(outputDir);
},
},
tsc: require('@joplin/tools/gulp/tasks/tsc'),
updateIgnoredTypeScriptBuild: require('@joplin/tools/gulp/tasks/updateIgnoredTypeScriptBuild'),
buildCommandIndex: require('@joplin/tools/gulp/tasks/buildCommandIndex'),
Expand All @@ -39,7 +46,7 @@ const tasks = {

utils.registerGulpTasks(gulp, tasks);

const buildParallel = [
const buildBeforeStartParallel = [
'compileScripts',
'compilePackageInfo',
'copyPluginAssets',
Expand All @@ -49,4 +56,11 @@ const buildParallel = [
'compileSass',
];

gulp.task('build', gulp.parallel(...buildParallel));
gulp.task('before-start', gulp.parallel(...buildBeforeStartParallel));

const buildAllSequential = [
'before-start',
'buildDefaultPlugins',
];

gulp.task('build', gulp.series(buildAllSequential));
11 changes: 4 additions & 7 deletions packages/app-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
"scripts": {
"dist": "yarn run electronRebuild && npx electron-builder",
"build": "gulp build",
"postinstall": "yarn run build",
"electronBuilder": "gulp electronBuilder",
"electronRebuild": "gulp electronRebuild",
"tsc": "tsc --project tsconfig.json",
"watch": "tsc --watch --preserveWatchOutput --project tsconfig.json",
"start": "gulp build && electron . --env dev --log-level debug --open-dev-tools",
"start": "gulp before-start && electron . --env dev --log-level debug --open-dev-tools",
"test": "jest",
"test-ui": "playwright test",
"test-ci": "yarn test && sh ./integration-tests/run-ci.sh",
Expand Down Expand Up @@ -116,6 +115,7 @@
"homepage": "https://github.com/laurent22/joplin#readme",
"devDependencies": {
"@electron/rebuild": "3.3.0",
"@joplin/default-plugins": "~2.13",
"@joplin/tools": "~2.13",
"@playwright/test": "1.39.0",
"@testing-library/react-hooks": "8.0.1",
Expand All @@ -133,14 +133,11 @@
"js-sha512": "0.8.0",
"nan": "2.18.0",
"react-test-renderer": "18.2.0",
"ts-node": "10.9.1",
"typescript": "5.2.2"
},
"optionalDependencies": {
"7zip-bin-linux": "^1.0.1",
"7zip-bin-mac": "^1.0.1",
"7zip-bin-win": "^2.1.1"
},
"dependencies": {
"7zip-bin": "5.2.0",
"@electron/notarize": "2.1.0",
"@electron/remote": "2.0.12",
"@fortawesome/fontawesome-free": "5.15.4",
Expand Down
3 changes: 2 additions & 1 deletion packages/app-desktop/services/plugins/plugin_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
return require('../../node_modules/@joplin/lib/node_modules/sqlite3/lib/sqlite3.js');
}

if (['fs-extra'].includes(modulePath)) return require(modulePath);
// 7zip-bin is required by one of the default plugins (simple-backup)
if (['fs-extra', '7zip-bin'].includes(modulePath)) return require(modulePath);

throw new Error(`Module not found: ${modulePath}`);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/app-desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
"exclude": [
"**/node_modules",
"**/dist",

// Exclude gulpfile.ts to prevent Gulp from trying to build from
// gulpfile.js.
"gulpfile.ts"
],
}
2 changes: 2 additions & 0 deletions packages/default-plugins/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugin-base-repo/
plugin-sources/*
2 changes: 2 additions & 0 deletions packages/default-plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
built-plugins/
plugin-sources/*
31 changes: 31 additions & 0 deletions packages/default-plugins/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import buildAll from './commands/buildAll';
import editPatch from './commands/editPatch';
const yargs = require('yargs');


const build = () => {
yargs
.usage('$0 <cmd> [args]')
.command('build <outputDir>', 'build all', (yargs: any) => {
yargs.positional('outputDir', {
type: 'string',
describe: 'Path to the parent directory for built output',
});
}, async (args: any) => {
await buildAll(args.outputDir);
process.exit(0);
})
.command('patch <plugin>', 'Edit the patch file for the given plugin ID', (yargs: any) => {
yargs.positional('plugin', {
type: 'string',
describe: 'ID of the plugin to patch',
});
}, async (args: any) => {
await editPatch(args.plugin, null);
process.exit(0);
})
.help()
.argv;
};

build();
Loading
Loading