diff options
author | 2019-10-20 22:23:19 +0200 | |
---|---|---|
committer | 2019-10-20 22:23:19 +0200 | |
commit | fb03fc2fb9f1a01b567210da1071ac093283e479 (patch) | |
tree | 3051c54634bc82878dd249cc728a75216ce068ae | |
parent | Create recipe_request.md (diff) | |
download | ferdium-recipes-fb03fc2fb9f1a01b567210da1071ac093283e479.tar.gz ferdium-recipes-fb03fc2fb9f1a01b567210da1071ac093283e479.tar.zst ferdium-recipes-fb03fc2fb9f1a01b567210da1071ac093283e479.zip |
Add script to verify packages
-rw-r--r-- | scripts/package.json | 4 | ||||
-rw-r--r-- | scripts/verify.js | 64 | ||||
-rw-r--r-- | scripts/yarn.lock | 69 |
3 files changed, 136 insertions, 1 deletions
diff --git a/scripts/package.json b/scripts/package.json index b491b01..d416231 100644 --- a/scripts/package.json +++ b/scripts/package.json | |||
@@ -7,10 +7,12 @@ | |||
7 | "author": "The Ferdi Team", | 7 | "author": "The Ferdi Team", |
8 | "license": "MIT", | 8 | "license": "MIT", |
9 | "dependencies": { | 9 | "dependencies": { |
10 | "dir-compare": "^1.7.3", | ||
10 | "fs-extra": "^8.1.0", | 11 | "fs-extra": "^8.1.0", |
11 | "targz": "^1.0.1" | 12 | "targz": "^1.0.1" |
12 | }, | 13 | }, |
13 | "scripts": { | 14 | "scripts": { |
14 | "package": "node package.js" | 15 | "package": "node package.js", |
16 | "verify": "node verify.js" | ||
15 | } | 17 | } |
16 | } | 18 | } |
diff --git a/scripts/verify.js b/scripts/verify.js new file mode 100644 index 0000000..59dbe61 --- /dev/null +++ b/scripts/verify.js | |||
@@ -0,0 +1,64 @@ | |||
1 | /** | ||
2 | * Verify packaged recipe to match uncompressed recipe | ||
3 | */ | ||
4 | const targz = require('targz'); | ||
5 | const fs = require('fs-extra'); | ||
6 | const dircompare = require('dir-compare'); | ||
7 | const path = require('path'); | ||
8 | |||
9 | // Helper: Compress src folder into dest file | ||
10 | const decompress = (src, dest) => new Promise((resolve, reject) => { | ||
11 | targz.decompress({ | ||
12 | src, | ||
13 | dest, | ||
14 | }, (err) => { | ||
15 | if (err) { | ||
16 | reject(err); | ||
17 | } else { | ||
18 | resolve(dest); | ||
19 | } | ||
20 | }); | ||
21 | }); | ||
22 | |||
23 | if (!process.argv[2]) { | ||
24 | console.log('Usage: yarn verify <recipe>'); | ||
25 | return; | ||
26 | } | ||
27 | |||
28 | // Let us work in an async environment | ||
29 | (async () => { | ||
30 | const recipe = process.argv[2]; | ||
31 | |||
32 | const compressedRecipe = path.join(__dirname, '../', `${recipe}.tar.gz`); | ||
33 | const uncompressedRecipe = path.join(__dirname, '../', 'uncompressed', recipe); | ||
34 | const tempUncompressed = path.join(__dirname, `uncompressed/`); | ||
35 | |||
36 | // Check that recipe exists | ||
37 | if (!await fs.pathExists(compressedRecipe) || !await fs.pathExists(uncompressedRecipe)) { | ||
38 | console.log(`Error: Recipe does not exist.`); | ||
39 | return; | ||
40 | } | ||
41 | |||
42 | if (await fs.pathExists(tempUncompressed)) { | ||
43 | await fs.remove(tempUncompressed); | ||
44 | } | ||
45 | await fs.mkdir(tempUncompressed); | ||
46 | |||
47 | // Package to uncompressed recipe to .tar.gz | ||
48 | console.log(`Decompressing...`); | ||
49 | await decompress(compressedRecipe, tempUncompressed); | ||
50 | |||
51 | // Compare directories | ||
52 | const compare = dircompare.compareSync(uncompressedRecipe, tempUncompressed, { | ||
53 | compareContent: true, | ||
54 | }); | ||
55 | |||
56 | if (compare.same) { | ||
57 | console.log('✓ Compressed and uncompressed files are equal'); | ||
58 | } else { | ||
59 | console.log('❌ Compressed and uncompressed files are NOT equal'); | ||
60 | } | ||
61 | |||
62 | // Remove temporary compressed file | ||
63 | await fs.remove(tempUncompressed); | ||
64 | })(); \ No newline at end of file | ||
diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 1fba1d2..a7b917b 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock | |||
@@ -2,6 +2,16 @@ | |||
2 | # yarn lockfile v1 | 2 | # yarn lockfile v1 |
3 | 3 | ||
4 | 4 | ||
5 | "@types/node@^10.12.18": | ||
6 | version "10.14.22" | ||
7 | resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.22.tgz#34bcdf6b6cb5fc0db33d24816ad9d3ece22feea4" | ||
8 | integrity sha512-9taxKC944BqoTVjE+UT3pQH0nHZlTvITwfsOZqyc+R3sfJuxaTtxWjfn1K2UlxyPcKHf0rnaXcVFrS9F9vf0bw== | ||
9 | |||
10 | balanced-match@^1.0.0: | ||
11 | version "1.0.0" | ||
12 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" | ||
13 | integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= | ||
14 | |||
5 | bl@^1.0.0: | 15 | bl@^1.0.0: |
6 | version "1.2.2" | 16 | version "1.2.2" |
7 | resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" | 17 | resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" |
@@ -10,6 +20,19 @@ bl@^1.0.0: | |||
10 | readable-stream "^2.3.5" | 20 | readable-stream "^2.3.5" |
11 | safe-buffer "^5.1.1" | 21 | safe-buffer "^5.1.1" |
12 | 22 | ||
23 | bluebird@3.4.1: | ||
24 | version "3.4.1" | ||
25 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.1.tgz#b731ddf48e2dd3bedac2e75e1215a11bcb91fa07" | ||
26 | integrity sha1-tzHd9I4t077awudeEhWhG8uR+gc= | ||
27 | |||
28 | brace-expansion@^1.0.0: | ||
29 | version "1.1.11" | ||
30 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" | ||
31 | integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== | ||
32 | dependencies: | ||
33 | balanced-match "^1.0.0" | ||
34 | concat-map "0.0.1" | ||
35 | |||
13 | buffer-alloc-unsafe@^1.1.0: | 36 | buffer-alloc-unsafe@^1.1.0: |
14 | version "1.1.0" | 37 | version "1.1.0" |
15 | resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" | 38 | resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" |
@@ -23,6 +46,11 @@ buffer-alloc@^1.2.0: | |||
23 | buffer-alloc-unsafe "^1.1.0" | 46 | buffer-alloc-unsafe "^1.1.0" |
24 | buffer-fill "^1.0.0" | 47 | buffer-fill "^1.0.0" |
25 | 48 | ||
49 | buffer-equal@1.0.0: | ||
50 | version "1.0.0" | ||
51 | resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" | ||
52 | integrity sha1-WWFrSYME1Var1GaWayLu2j7KX74= | ||
53 | |||
26 | buffer-fill@^1.0.0: | 54 | buffer-fill@^1.0.0: |
27 | version "1.0.0" | 55 | version "1.0.0" |
28 | resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" | 56 | resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" |
@@ -33,11 +61,40 @@ chownr@^1.0.1: | |||
33 | resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.3.tgz#42d837d5239688d55f303003a508230fa6727142" | 61 | resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.3.tgz#42d837d5239688d55f303003a508230fa6727142" |
34 | integrity sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw== | 62 | integrity sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw== |
35 | 63 | ||
64 | colors@1.0.3: | ||
65 | version "1.0.3" | ||
66 | resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" | ||
67 | integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs= | ||
68 | |||
69 | commander@2.9.0: | ||
70 | version "2.9.0" | ||
71 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" | ||
72 | integrity sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q= | ||
73 | dependencies: | ||
74 | graceful-readlink ">= 1.0.0" | ||
75 | |||
76 | concat-map@0.0.1: | ||
77 | version "0.0.1" | ||
78 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" | ||
79 | integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= | ||
80 | |||
36 | core-util-is@~1.0.0: | 81 | core-util-is@~1.0.0: |
37 | version "1.0.2" | 82 | version "1.0.2" |
38 | resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" | 83 | resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" |
39 | integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= | 84 | integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= |
40 | 85 | ||
86 | dir-compare@^1.7.3: | ||
87 | version "1.7.3" | ||
88 | resolved "https://registry.yarnpkg.com/dir-compare/-/dir-compare-1.7.3.tgz#8f25f9654de02d82b30f5c5c0dfc198ce612ed68" | ||
89 | integrity sha512-YsKGvVzy5938B9Rokol3N9jq4QcFhlgostWr+TX4omexpR0UztlbYu5UZRxZ0WTeLMFt+7TCIm7nn27byQKZHw== | ||
90 | dependencies: | ||
91 | "@types/node" "^10.12.18" | ||
92 | bluebird "3.4.1" | ||
93 | buffer-equal "1.0.0" | ||
94 | colors "1.0.3" | ||
95 | commander "2.9.0" | ||
96 | minimatch "3.0.2" | ||
97 | |||
41 | end-of-stream@^1.0.0, end-of-stream@^1.1.0: | 98 | end-of-stream@^1.0.0, end-of-stream@^1.1.0: |
42 | version "1.4.4" | 99 | version "1.4.4" |
43 | resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" | 100 | resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" |
@@ -64,6 +121,11 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0: | |||
64 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02" | 121 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02" |
65 | integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q== | 122 | integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q== |
66 | 123 | ||
124 | "graceful-readlink@>= 1.0.0": | ||
125 | version "1.0.1" | ||
126 | resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" | ||
127 | integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU= | ||
128 | |||
67 | inherits@~2.0.3: | 129 | inherits@~2.0.3: |
68 | version "2.0.4" | 130 | version "2.0.4" |
69 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" | 131 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" |
@@ -81,6 +143,13 @@ jsonfile@^4.0.0: | |||
81 | optionalDependencies: | 143 | optionalDependencies: |
82 | graceful-fs "^4.1.6" | 144 | graceful-fs "^4.1.6" |
83 | 145 | ||
146 | minimatch@3.0.2: | ||
147 | version "3.0.2" | ||
148 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.2.tgz#0f398a7300ea441e9c348c83d98ab8c9dbf9c40a" | ||
149 | integrity sha1-DzmKcwDqRB6cNIyD2Yq4ydv5xAo= | ||
150 | dependencies: | ||
151 | brace-expansion "^1.0.0" | ||
152 | |||
84 | minimist@0.0.8: | 153 | minimist@0.0.8: |
85 | version "0.0.8" | 154 | version "0.0.8" |
86 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" | 155 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" |