joplin-plugin-backup 1.2.1 → 1.2.2
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Build and test
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
buildAndTest:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
steps:
|
|
7
|
+
- uses: actions/checkout@v2
|
|
8
|
+
- uses: actions/setup-node@v2
|
|
9
|
+
with:
|
|
10
|
+
node-version: "16"
|
|
11
|
+
- name: Install dependencies
|
|
12
|
+
run: npm install
|
|
13
|
+
- name: Build
|
|
14
|
+
run: npm run dist
|
|
15
|
+
- name: Run test
|
|
16
|
+
run: npm test
|
package/.husky/pre-push
CHANGED
package/__test__/backup.test.ts
CHANGED
|
@@ -528,9 +528,9 @@ describe("Backup", function () {
|
|
|
528
528
|
backupRetention: 1,
|
|
529
529
|
password: null,
|
|
530
530
|
singleJex: true,
|
|
531
|
-
result: path.join(testPath.backupBasePath
|
|
531
|
+
result: path.join(testPath.backupBasePath),
|
|
532
532
|
testFile: "testFile.txt",
|
|
533
|
-
checkFile: path.join(testPath.backupBasePath, "
|
|
533
|
+
checkFile: path.join(testPath.backupBasePath, "testFile.txt.7z"),
|
|
534
534
|
saveBackupInfoCalled: 0,
|
|
535
535
|
},
|
|
536
536
|
{
|
|
@@ -538,9 +538,13 @@ describe("Backup", function () {
|
|
|
538
538
|
backupRetention: 2,
|
|
539
539
|
password: null,
|
|
540
540
|
singleJex: true,
|
|
541
|
-
result: path.join(testPath.backupBasePath, "202101021630
|
|
541
|
+
result: path.join(testPath.backupBasePath, "202101021630"),
|
|
542
542
|
testFile: "testFile.txt",
|
|
543
|
-
checkFile: path.join(
|
|
543
|
+
checkFile: path.join(
|
|
544
|
+
testPath.backupBasePath,
|
|
545
|
+
"202101021630",
|
|
546
|
+
"testFile.txt.7z"
|
|
547
|
+
),
|
|
544
548
|
saveBackupInfoCalled: 1,
|
|
545
549
|
},
|
|
546
550
|
{
|
|
@@ -801,86 +805,104 @@ describe("Backup", function () {
|
|
|
801
805
|
expect(backup.log.transports.file.level).toBe("error");
|
|
802
806
|
});
|
|
803
807
|
|
|
804
|
-
|
|
808
|
+
describe("move logfile", function () {
|
|
805
809
|
const testCases = [
|
|
806
810
|
{
|
|
811
|
+
description: "backupBasePath",
|
|
807
812
|
zipArchive: "no",
|
|
808
813
|
password: null,
|
|
809
814
|
logDst: testPath.backupBasePath,
|
|
810
|
-
testLogFile: path.join(testPath.backupBasePath, "backup.log"),
|
|
811
815
|
},
|
|
812
816
|
{
|
|
817
|
+
description: "backupBasePath, password",
|
|
813
818
|
zipArchive: "no",
|
|
814
|
-
password:
|
|
815
|
-
logDst:
|
|
816
|
-
testLogFile: path.join(
|
|
817
|
-
testPath.backupBasePath,
|
|
818
|
-
"testDir",
|
|
819
|
-
"backup.log"
|
|
820
|
-
),
|
|
819
|
+
password: "secret",
|
|
820
|
+
logDst: testPath.backupBasePath,
|
|
821
821
|
},
|
|
822
822
|
{
|
|
823
|
+
description: "backupBasePath, zip, password",
|
|
823
824
|
zipArchive: "yes",
|
|
824
|
-
password:
|
|
825
|
-
logDst:
|
|
826
|
-
testLogFile: path.join(
|
|
827
|
-
testPath.backupBasePath,
|
|
828
|
-
"testDir",
|
|
829
|
-
"backup.log"
|
|
830
|
-
),
|
|
825
|
+
password: "secret",
|
|
826
|
+
logDst: testPath.backupBasePath,
|
|
831
827
|
},
|
|
832
828
|
{
|
|
829
|
+
description: "backupBasePath, zip one",
|
|
833
830
|
zipArchive: "yesone",
|
|
834
831
|
password: null,
|
|
835
|
-
logDst: path.join(testPath.backupBasePath, "
|
|
836
|
-
testLogFile: "backup.log",
|
|
832
|
+
logDst: path.join(testPath.backupBasePath, "retention.7z"),
|
|
837
833
|
},
|
|
838
834
|
{
|
|
835
|
+
description: "backupBasePath, zip one, password",
|
|
839
836
|
zipArchive: "yesone",
|
|
840
837
|
password: "secret",
|
|
841
|
-
logDst: path.join(testPath.backupBasePath, "
|
|
842
|
-
testLogFile: "backup.log",
|
|
838
|
+
logDst: path.join(testPath.backupBasePath, "retention.7z"),
|
|
843
839
|
},
|
|
844
840
|
{
|
|
841
|
+
description: "sub in backupBasePath",
|
|
842
|
+
zipArchive: "no",
|
|
843
|
+
password: null,
|
|
844
|
+
logDst: path.join(testPath.backupBasePath, "retentionfolder"),
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
description: "sub in backupBasePath, password",
|
|
845
848
|
zipArchive: "no",
|
|
846
849
|
password: "secret",
|
|
847
|
-
logDst: testPath.backupBasePath,
|
|
848
|
-
|
|
850
|
+
logDst: path.join(testPath.backupBasePath, "retentionfolder"),
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
description: "sub in backupBasePath, zip",
|
|
854
|
+
zipArchive: "yes",
|
|
855
|
+
password: null,
|
|
856
|
+
logDst: path.join(testPath.backupBasePath, "retentionfolder"),
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
description: "sub in backupBasePath, password, zip",
|
|
860
|
+
zipArchive: "yes",
|
|
861
|
+
password: "secret",
|
|
862
|
+
logDst: path.join(testPath.backupBasePath, "retentionfolder"),
|
|
849
863
|
},
|
|
850
864
|
];
|
|
851
865
|
|
|
852
|
-
backup.logFile = path.join(testPath.base, "test.log");
|
|
853
866
|
for (const testCase of testCases) {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
867
|
+
it(`${testCase.description}`, async () => {
|
|
868
|
+
backup.logFile = path.join(testPath.base, "test.log");
|
|
869
|
+
backup.zipArchive = testCase.zipArchive;
|
|
870
|
+
backup.password = testCase.password;
|
|
871
|
+
|
|
872
|
+
await createTestStructure();
|
|
873
|
+
|
|
874
|
+
if (testCase.zipArchive === "yesone") {
|
|
875
|
+
const dummyFile = path.join(testPath.base, "dummy");
|
|
876
|
+
fs.writeFileSync(dummyFile, "dummy");
|
|
877
|
+
expect(fs.existsSync(dummyFile)).toBe(true);
|
|
878
|
+
await sevenZip.add(testCase.logDst, dummyFile, testCase.password);
|
|
879
|
+
expect(fs.existsSync(testCase.logDst)).toBe(true);
|
|
880
|
+
} else {
|
|
881
|
+
fs.emptyDirSync(testCase.logDst);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
fs.writeFileSync(backup.logFile, "log");
|
|
885
|
+
expect(fs.existsSync(backup.logFile)).toBe(true);
|
|
886
|
+
|
|
887
|
+
expect(await backup.moveLogFile(testCase.logDst)).toBe(true);
|
|
888
|
+
expect(fs.existsSync(backup.logFile)).toBe(false);
|
|
889
|
+
|
|
890
|
+
let checkBackupLogFile = path.join(testCase.logDst, "backup.log");
|
|
891
|
+
if (testCase.zipArchive === "yesone") {
|
|
892
|
+
checkBackupLogFile = testCase.logDst;
|
|
893
|
+
} else if (testCase.password !== null) {
|
|
894
|
+
checkBackupLogFile = path.join(testCase.logDst, "backuplog.7z");
|
|
895
|
+
}
|
|
896
|
+
expect(fs.existsSync(checkBackupLogFile)).toBe(true);
|
|
897
|
+
|
|
898
|
+
if (testCase.password !== null || testCase.zipArchive === "yesone") {
|
|
899
|
+
const fileList = await sevenZip.list(
|
|
900
|
+
testCase.logDst,
|
|
901
|
+
testCase.password
|
|
902
|
+
);
|
|
903
|
+
expect(fileList.map((f) => f.file)).toContain("backup.log");
|
|
904
|
+
}
|
|
905
|
+
});
|
|
884
906
|
}
|
|
885
907
|
});
|
|
886
908
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joplin-plugin-backup",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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",
|
|
Binary file
|
|
@@ -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.2.
|
|
5
|
+
"version": "1.2.2",
|
|
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:
|
|
20
|
-
"_publish_commit": "master:
|
|
19
|
+
"_publish_hash": "sha256:ddc31c99405ef7aaa001b1dca7f52f57723975f8a7cdc2fc6f99f08c0ae0b6fb",
|
|
20
|
+
"_publish_commit": "master:84f2205b58043113c39f09d9c253bba260a11331"
|
|
21
21
|
}
|