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
@@ -1,4 +1,2 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
-
4
- npm test
@@ -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, "JoplinBackup.7z"),
531
+ result: path.join(testPath.backupBasePath),
532
532
  testFile: "testFile.txt",
533
- checkFile: path.join(testPath.backupBasePath, "JoplinBackup.7z"),
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.7z"),
541
+ result: path.join(testPath.backupBasePath, "202101021630"),
542
542
  testFile: "testFile.txt",
543
- checkFile: path.join(testPath.backupBasePath, "202101021630.7z"),
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
- it(`move logfile`, async () => {
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: null,
815
- logDst: path.join(testPath.backupBasePath, "testDir"),
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: null,
825
- logDst: path.join(testPath.backupBasePath, "testDir"),
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, "Backup.7z"),
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, "Backup.7z"),
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
- testLogFile: "backup.log",
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
- await createTestStructure();
855
- if (testCase.zipArchive !== "yesone") {
856
- fs.emptyDirSync(testCase.logDst);
857
- }
858
- if (testCase.zipArchive === "yesone") {
859
- const dummyFile = path.join(testPath.base, "dummy");
860
- fs.writeFileSync(dummyFile, "dummy");
861
- await sevenZip.add(testCase.logDst, dummyFile, testCase.password);
862
- expect(fs.existsSync(dummyFile)).toBe(true);
863
- expect(fs.existsSync(testCase.logDst)).toBe(true);
864
- }
865
-
866
- fs.writeFileSync(backup.logFile, "log");
867
-
868
- backup.zipArchive = testCase.zipArchive;
869
- backup.password = testCase.password;
870
-
871
- expect(fs.existsSync(backup.logFile)).toBe(true);
872
- expect(await backup.moveLogFile(testCase.logDst)).toBe(true);
873
- expect(fs.existsSync(backup.logFile)).toBe(false);
874
-
875
- if (testCase.password !== null || testCase.zipArchive === "yesone") {
876
- const fileList = await sevenZip.list(
877
- testCase.logDst,
878
- testCase.password
879
- );
880
- expect(fileList.map((f) => f.file)).toContain(testCase.testLogFile);
881
- } else {
882
- expect(fs.existsSync(testCase.testLogFile)).toBe(true);
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.1",
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",
@@ -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.1",
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:ee3fee3a90fe21a1c656240f9e3506fd6651a7318f398a484c6c31bef425dec8",
20
- "_publish_commit": "master:e4e8e6cff708bc7f181d2c18122084b7aeb4fb32"
19
+ "_publish_hash": "sha256:ddc31c99405ef7aaa001b1dca7f52f57723975f8a7cdc2fc6f99f08c0ae0b6fb",
20
+ "_publish_commit": "master:84f2205b58043113c39f09d9c253bba260a11331"
21
21
  }