joplin-plugin-backup 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.ENV ADDED
@@ -0,0 +1 @@
1
+ GITHUB_TOKEN=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
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Gruber Alexander
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Gruber Alexander
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -53,7 +53,7 @@ Under `Options > Keyboard Shortcuts` you can assign a keyboard shortcut for the
53
53
 
54
54
  ## What is backed up
55
55
 
56
- - Notebooks as JEX export (Empty notbooks are not backed up)
56
+ - Notebooks as JEX export (Empty notebooks are not backed up)
57
57
  - The `settings.json` (Joplin settings)
58
58
  - The `keymap-desktop.json` (Keyboard shortcuts)
59
59
  - The `userchrome.css` (Your Joplin customization)
@@ -1,9 +1,9 @@
1
1
  import { Backup } from "../src/Backup";
2
2
  import * as fs from "fs-extra";
3
3
  import * as path from "path";
4
- import { joplinWrapper } from "../src/joplinWrapper";
5
4
  import { when } from "jest-when";
6
5
  import { sevenZip } from "../src/sevenZip";
6
+ import joplin from "api";
7
7
 
8
8
  function getTestPaths(): any {
9
9
  const testPath: any = {};
@@ -26,10 +26,10 @@ let spyOnLogWarn = null;
26
26
  let spyOnLogError = null;
27
27
  let spyOnSaveBackupInfo = null;
28
28
 
29
- const spyOnsSettingsValue = jest.spyOn(joplinWrapper, "settingsValue");
30
- const spyOnGlobalValue = jest.spyOn(joplinWrapper, "settingsGlobalValue");
29
+ const spyOnsSettingsValue = jest.spyOn(joplin.settings, "value");
30
+ const spyOnGlobalValue = jest.spyOn(joplin.settings, "globalValue");
31
31
  const spyOnSettingsSetValue = jest
32
- .spyOn(joplinWrapper, "settingsSetValue")
32
+ .spyOn(joplin.settings, "setValue")
33
33
  .mockImplementation();
34
34
 
35
35
  async function createTestStructure() {
@@ -0,0 +1,74 @@
1
+ import { helper } from "../src/helper";
2
+
3
+ describe("Test helper", function () {
4
+ it(`validFileName`, async () => {
5
+ const testCases = [
6
+ {
7
+ fileName: "some test file.txt",
8
+ expected: true,
9
+ },
10
+ {
11
+ fileName: "some ^test file.txt",
12
+ expected: true,
13
+ },
14
+ {
15
+ fileName: "some :test file.txt",
16
+ expected: false,
17
+ },
18
+ {
19
+ fileName: "some \\test file.txt",
20
+ expected: false,
21
+ },
22
+ {
23
+ fileName: "some |test file.txt",
24
+ expected: false,
25
+ },
26
+ {
27
+ fileName: "some /test file.txt",
28
+ expected: false,
29
+ },
30
+ {
31
+ fileName: "some *test file.txt",
32
+ expected: false,
33
+ },
34
+ {
35
+ fileName: "some ?test file.txt",
36
+ expected: false,
37
+ },
38
+ {
39
+ fileName: "some <test file.txt",
40
+ expected: false,
41
+ },
42
+ {
43
+ fileName: "some >test file.txt",
44
+ expected: false,
45
+ },
46
+ {
47
+ fileName: "com9.txt",
48
+ expected: false,
49
+ },
50
+ {
51
+ fileName: "nul.txt",
52
+ expected: false,
53
+ },
54
+ {
55
+ fileName: "prn.txt",
56
+ expected: false,
57
+ },
58
+ {
59
+ fileName: "con.txt",
60
+ expected: false,
61
+ },
62
+ {
63
+ fileName: "lpt5.txt",
64
+ expected: false,
65
+ },
66
+ ];
67
+
68
+ for (const testCase of testCases) {
69
+ expect(await helper.validFileName(testCase.fileName)).toBe(
70
+ testCase.expected
71
+ );
72
+ }
73
+ });
74
+ });
@@ -0,0 +1,82 @@
1
+ import { Backup } from "../src/Backup";
2
+ import joplin from "api";
3
+ import { when } from "jest-when";
4
+
5
+ let backup = null;
6
+
7
+ describe("Password", function () {
8
+ beforeEach(async () => {
9
+ backup = new Backup() as any;
10
+ });
11
+
12
+ it(`Check`, async () => {
13
+ const spyOnsSettingsValue = jest.spyOn(joplin.settings, "value");
14
+ const spyOnsSettingsSetValue = jest.spyOn(joplin.settings, "setValue");
15
+
16
+ const testCases = [
17
+ {
18
+ usePassword: false,
19
+ password: "",
20
+ passwordRepeat: "",
21
+ expected: 0,
22
+ called: 2,
23
+ },
24
+ {
25
+ usePassword: false,
26
+ password: "test",
27
+ passwordRepeat: "test",
28
+ expected: 0,
29
+ called: 2,
30
+ },
31
+ {
32
+ usePassword: false,
33
+ password: "testA",
34
+ passwordRepeat: "testB",
35
+ expected: 0,
36
+ called: 2,
37
+ },
38
+ {
39
+ usePassword: true,
40
+ password: "test",
41
+ passwordRepeat: "test",
42
+ expected: 1,
43
+ called: 0,
44
+ },
45
+ {
46
+ usePassword: true,
47
+ password: "testA",
48
+ passwordRepeat: "testB",
49
+ expected: -1,
50
+ called: 2,
51
+ },
52
+ {
53
+ usePassword: true,
54
+ password: " ",
55
+ passwordRepeat: " ",
56
+ expected: -1,
57
+ called: 2,
58
+ },
59
+ {
60
+ usePassword: true,
61
+ password: "",
62
+ passwordRepeat: " ",
63
+ expected: -1,
64
+ called: 2,
65
+ },
66
+ ];
67
+
68
+ for (const testCase of testCases) {
69
+ /* prettier-ignore */
70
+ when(spyOnsSettingsValue)
71
+ .mockImplementation(() => Promise.resolve("no mockImplementation"))
72
+ .calledWith("usePassword").mockImplementation(() => Promise.resolve(testCase.usePassword))
73
+ .calledWith("password").mockImplementation(() => Promise.resolve(testCase.password))
74
+ .calledWith("passwordRepeat").mockImplementation(() => Promise.resolve(testCase.passwordRepeat));
75
+ expect(await backup.checkPassword()).toBe(testCase.expected);
76
+
77
+ await backup.enablePassword();
78
+ expect(spyOnsSettingsSetValue).toBeCalledTimes(testCase.called);
79
+ spyOnsSettingsSetValue.mockReset();
80
+ }
81
+ });
82
+ });
@@ -0,0 +1,16 @@
1
+ import { sevenZip, pathTo7zip } from "../src/sevenZip";
2
+ import * as path from "path";
3
+ import joplin from "api";
4
+
5
+ it(`Set bin from joplin`, async () => {
6
+ const pathBevor = pathTo7zip;
7
+ const pathAdd = "addJoplinPath";
8
+ const pathAfter = path.join(pathAdd, "7zip-bin", pathTo7zip);
9
+
10
+ jest.spyOn(joplin.plugins, "installationDir").mockImplementation(async () => {
11
+ return pathAdd;
12
+ });
13
+
14
+ await sevenZip.updateBinPath();
15
+ expect(pathTo7zip).toBe(pathAfter);
16
+ });
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "joplin-plugin-backup",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "scripts": {
5
5
  "dist": "webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive",
6
6
  "prepare": "npm run dist && husky install",
7
7
  "update": "npm install -g generator-joplin && yo joplin --update",
8
+ "release": "npm test && node ./node_modules/joplinplugindevtools/dist/createRelease.js",
9
+ "preRelease": "npm test && node ./node_modules/joplinplugindevtools/dist/createRelease.js --prerelease",
10
+ "gitRelease": "node ./node_modules/joplinplugindevtools/dist/createRelease.js --upload",
11
+ "gitPreRelease": "node ./node_modules/joplinplugindevtools/dist/createRelease.js --upload --prerelease",
8
12
  "test": "jest"
9
13
  },
10
14
  "license": "MIT",
@@ -14,14 +18,18 @@
14
18
  "devDependencies": {
15
19
  "@types/jest": "^26.0.23",
16
20
  "@types/node": "^14.0.14",
21
+ "axios": "^0.21.1",
17
22
  "chalk": "^4.1.0",
18
23
  "copy-webpack-plugin": "^6.1.0",
24
+ "dotenv": "^10.0.0",
19
25
  "fs-extra": "^9.0.1",
20
26
  "glob": "^7.1.6",
21
27
  "husky": "^6.0.0",
22
28
  "jest": "^27.0.4",
23
29
  "jest-when": "^3.3.1",
30
+ "joplinplugindevtools": "^1.0.14",
24
31
  "lint-staged": "^11.0.0",
32
+ "mime": "^2.5.2",
25
33
  "on-build-webpack": "^0.1.0",
26
34
  "prettier": "2.3.0",
27
35
  "tar": "^6.0.5",
@@ -56,11 +64,8 @@
56
64
  "js"
57
65
  ],
58
66
  "moduleNameMapper": {
59
- "^api$": "<rootDir>/api",
67
+ "^api$": "<rootDir>/node_modules/joplinplugindevtools/dist/apiMock.js",
60
68
  "^api/types$": "<rootDir>/api/types"
61
- },
62
- "globals": {
63
- "joplin": true
64
69
  }
65
70
  }
66
71
  }
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 1,
3
3
  "id": "io.github.jackgruber.backup",
4
4
  "app_min_version": "2.1.3",
5
- "version": "1.0.3",
5
+ "version": "1.0.5",
6
6
  "name": "Simple Backup",
7
7
  "description": "Plugin to create manual and automatic backups.",
8
8
  "author": "JackGruber",
@@ -16,6 +16,6 @@
16
16
  "7zip",
17
17
  "encrypted"
18
18
  ],
19
- "_publish_hash": "sha256:99f57ce2e8c6fb3b86c825f99493239f643590730356b2a981667586a3ca2b2e",
20
- "_publish_commit": "master:ebf47d68156e58af11997df87c7073345785ea83"
19
+ "_publish_hash": "sha256:afa40d7e0ed66a962aab6cbb7a01401cced7e165c4eddec4f1bbbe13ea96187e",
20
+ "_publish_commit": "master:2c035a3d426785deeaacc1948a2469d0824e0c25"
21
21
  }
package/CHANGELOG.md DELETED
@@ -1,84 +0,0 @@
1
- # Changelog
2
-
3
- ## not released
4
-
5
- ## v1.0.3 (2021-08-11)
6
-
7
- - Fix: #19 Backups failed from Joplin version v2.2.5 and higher, due to the removed template function
8
-
9
- ## v1.0.2 (2021-07-19)
10
-
11
- - Improved: Use of moments token
12
- - Fix: #16 Prevent multiple simultaneous backup runs
13
- - Add: #11 Make zip compression level selectable
14
- - Fix: Delete old backup set information, if the backup set no longer exists
15
-
16
- ## v1.0.1 (2021-07-03)
17
-
18
- Release for Joplin plugin manager
19
-
20
- ## v1.0.0 [pre-release] (2021-06-20)
21
-
22
- - Add: Option for encrypted backups
23
-
24
- > ❗️ Requires at least Joplin `2.1.3` ❗️
25
-
26
- ## v0.9.0 [pre-release] (2021-06-19)
27
-
28
- - Add: Relative path could be used for `Backup Path`
29
- - Fix: An error with `Only on change`, which was not working properly
30
- - Add: Option to create zip archive
31
- - Add: Option to specify the `Backup set name` if multiple backups are to be keep.
32
-
33
- ## v0.5.3 (2021-04-03)
34
-
35
- - Add: Backup settings.json
36
- - Optimize: #7 Better error message when a backup is created twice in a row in the same minute
37
-
38
- ## v0.5.2 (2021-02-13)
39
-
40
- - Only internal changes
41
-
42
- ## v0.5.1 (2021-02-07)
43
-
44
- - Fix: Incomplete backup.log with only one backup set
45
-
46
- ## v0.5.0 (2021-02-07)
47
-
48
- - Add: Option for Backuplogfile
49
- - Add: Option to create a backup only if something has changed #3
50
-
51
- ## v0.4.1 (2021-01-23)
52
-
53
- - Optimize: Store profile data in `profile` folder
54
-
55
- ## v0.4.0 (2021-01-21)
56
-
57
- - Add `templates` to backup
58
- - Optimize: Delete old backups at the end of the backup job
59
-
60
- ## v0.3.1 (2021-01-21)
61
-
62
- - Fix #1: Unsupported characters in filename
63
-
64
- ## v0.3.0 (2021-01-17)
65
-
66
- - Fix: Backup not only the last 50 notebooks
67
- - Add: Backup userchrome.css and userstyle.css
68
- - Add: Option to create single file JEX for all notebooks
69
-
70
- ## v0.2.2 (2021-01-17)
71
-
72
- - Fix: Check if keymap-desktop.json exists
73
-
74
- ## v0.2.1 (2021-01-16)
75
-
76
- - remove seconds from folder
77
-
78
- ## v0.2.0 (2021-01-14)
79
-
80
- - Add: Automatic backups every X hours
81
-
82
- ## v0.1.0 (2021-01-14)
83
-
84
- - First version