Skip to content

Commit

Permalink
Check for failed hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian committed Jul 23, 2018
1 parent fb41e47 commit f738c4d
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 7 deletions.
150 changes: 150 additions & 0 deletions json-schemas.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"ansible-stable-2.0.json": "667125eee35a622e96f3c9898e7fa1df7000d825fa7f1d171121fec277f0371f",
"ansible-stable-2.1.json": "3ccef0d4a58a4c1ca0179ca823c453420a979761dde5626d170e3a176a82bca2",
"ansible-stable-2.2.json": "519cf66c4b7fd900ba63dcd49f7d79d28eb95c52146539ae36aebfe914840b30",
"ansible-stable-2.3.json": "baec65caab8aa37266fcb6024b7309f2aa3575d69ff3cbaa49ab42681115eb92",
"ansible-stable-2.4.json": "6f412b1c4ad2dd11b9bfd27bdd5de194f3d4d74a408fe69a94cc315422555cb0",
"ansible-stable-2.5.json": "b7122515d67cc9b8ba4458b6c8953ae8ba4b4c4601b7731aaf38f65586845de9",
"apple-app-site-association.json": "d1da9db0aee3fe4654cea271ab950d2de3d46b0d9e6fb6866738abfefc7fc601",
"appsettings.json": "6c8f46ced6ba7bbe1b409ce0820d1efa07ac470cda85e0499e3d91731b718295",
"appveyor.json": "b2c6292f225b8f188775275e3763536dfd8cc8368327a97c4f9d37be93db9826",
"asmdef.json": "be3b413b9eefc1238b171cf4edfd007788cda38e9505cce9d48128a828f5eb05",
"avro-avsc.json": "8984e4500c2b709e7613b56905214782b4ed8bc21909646560422e219aa1df03",
"babelrc.json": "4badf1a06015822bacf5cd2dc2436399418966af5b04aff88a631a1cc0324455",
"band-manifest.json": "8bf40d13d08df73a4961cdcada0adb356af4ef43d3a8368d829ab262379e0b77",
"bootstraprc.json": "bb109d6051629d0351b97a20cf9f5856a8788ab6597a3ba6fa9d8b1f5129c62e",
"bower.json": "b4135f9f8dee2354b01e18cf5bd41f642dd497f13757278691a8787ea8178687",
"bowerrc.json": "2f7d10495534462e0dd85886d6aec87183dac0b71ecf5d7a9a5cab2adca4711a",
"bundleconfig.json": "ffcb7b8e2b5767e4e0c24549ddfd95387739d1d0ed6c4fc1f4d9ff54833fa7d4",
"chrome-manifest.json": "ac77c94a56bb3f7ad4b6918206bdbd0fd99a70253f6eb184e9b58131619d3626",
"chutzpah.json": "a4b9a3a1a52c22b903911a950a3fdb7b34ba54190c3415e369b1e73448e2862f",
"circleciconfig.json": "47e439dcb2ac50f57a8e6b0ea627581e66c5a93f6671e43b88b86fd76208228f",
"cirrus.json": "d776eac704764ad16392dc7f34bb6742ff5a58465f62cdbf14b1723660764135",
"coffeelint.json": "d5e5e50d25bf207a8f6e4496868a5439312b8636f4882342de72421b70d7e8e6",
"commands.json": "2eb3effcf1c8f0f27457e000053688580cedd7519f9c01a37348b8585fc9a369",
"compilerconfig.json": "53b03e57efcf43f9571de2a2d43d98a4ad21651ec0cc4444ef1d34afd3b6a98e",
"compilerdefaults.json": "b400c5764e21695d23dea02f2ae0033d7f7f2b754bc4b24e6c1c65f359f2be9f",
"component.json": "51a6892f81a36f145f385bf6e589324976ba80a77eb7ff175334719f80bd0e39",
"composer.json": "4f8837738853f9815f378e90bdb272d52b955aec43180c58576f446ae241b96f",
"config.json": "4f1355753e0437db08baca6a00ffbc9dac70fd59e6b6e1ea3a071504d03112bc",
"content-security-policy-report-2.json": "f0a2450f31d215e50ed36a6b609fd13ebc81e172585eab3ce2a93918d7341881",
"contribute.json": "a6b38c35b223e3477ce2616e5864f6b20a586ef1560ef4d7110d2eb72779c50f",
"creatomic.json": "80ce6ad83e9f2816eaaaa3cd55c619484c0af9ff75f61b7734067ef65767ae0d",
"cryproj.52.schema.json": "7d67a2b09aca4bd931a756e26d7403ca45738a2c2944e4c0a2b70be1a9453180",
"cryproj.53.schema.json": "3eb4a08caba9cd73dfda91e6c737d50690b1b0c6c827a8bcf8c857c45bbd22d3",
"cryproj.54.schema.json": "a14d11a77b99448c3436e124f60cda54d805ae8ac4580caaab15c2da64bfbd5e",
"cryproj.55.schema.json": "e175f04803886ed55313556dd49606bb4d76e31d8e115b56747bb966e699e700",
"cryproj.dev.schema.json": "df369f19917345c422b6ce14d49b662ccaa8afd439a2c87972fcf7e73d0ce16e",
"cryproj.json": "a9ddd43cf59b4a50fcbf5445754cccbe4f5210b289fad8c9139e55dd504147ae",
"csscomb.json": "0bbd4d8c761c47a1e2047c18e36db88d911d62f73a628561682b991700e57408",
"csslintrc.json": "11d1c8b64294a22c7da23b7fa83880d313f70e19624b01f9c01ad3c2915985fc",
"debugsettings.json": "78cd337254d9dc8505c2369cef53df23312013d20721b5d940c382318f7d0ea3",
"docfx.json": "e15deea54af1687064b3eb429c52ae1368c8f77c34c01b7bc515c5b19d28af7e",
"dotnetcli.host.json": "7ebbaaebfde9e9e6248e7384a74aba84407cdace898693d0118f21788f721300",
"epr-manifest.json": "65a5fa96b9f2165f3b094f2affc7f7b7102df40ed09a1cb66c64eb0563c0b064",
"eslintrc.json": "1feeefc3873ede9b28e5b553c5752ff1139928fc2412d1d381ff130fdaac9b2d",
"feed.json": "a389782e8583e8d91e99848441b3febb930716b851c0b157f8dcb1095de0122f",
"foxx-manifest.json": "2ae59f64f7b5d8563a8f010a3722d2d6507985847ff2a2f6cad47a00820bad61",
"function.json": "fc7403ded84c3417fcf3c12dd2542b0435232edd07ab9289b226a799ddfef7e6",
"geojson.json": "f3dda50f235e2dcde73f3c165c0001f17a52d26d63b27eb8f86e10152ea0dbb9",
"global.json": "64cf7c6371614299da78997dc013cb399a45ea3ac54a9170ecb8cf421db9bc24",
"grunt-clean-task.json": "37afe5dcf7a3ca70e0eb22105711ea27eed4ef95de49e26d0faa1896edaee70a",
"grunt-copy-task.json": "356171b6258327a59e7637f27108dc40267e9d312c3a93d05dbdbf8d76fbbcb1",
"grunt-cssmin-task.json": "384ff3a803ee681c607ff7473c9eed0a3d84fb35c7749fb8420d25f23060dd63",
"grunt-jshint-task.json": "fec7f4acff2b231f230b95c5cb9def5f88491301f2b61134b2758a8d4fe7be11",
"grunt-task.json": "1f7b2aa1b5efd6d393a6aba27e1081fdf9eb47644e2239b8e23538bd69537ab6",
"grunt-watch-task.json": "7153813cb4386ebe95c2318f2f4eed402e6682ecf8f7e4e758bc35625354e42e",
"haxelib.json": "f9b41c3e5055c523de781de41c3487c3f653853dbcb4b9a0ada759c1f04309af",
"host-meta.json": "716762792e3a5e3f3d68f50eb7829b06979582e262c3a34617f5c9422d95315f",
"host.json": "0df70a026eae88c174db9b0e88944bd0a6f9356f05702f50204f6e99f25d3cbd",
"htmlhint.json": "82ac4bf61b8ff463fec534fc35df0f0bde2f6bf1adcd297452a70b28655b04dd",
"imageoptimizer.json": "3d41f3e503b9567585d38ee28cfaf0c61f94299c3006fe381dcfc2712a43e27a",
"install.json": "864cefa378c32665fc7ab92fd6810a27e7b5d5f5fefeb960856ee75e0bbcaea3",
"jasonette.json": "c341e4a5c10a9e56b66cb4538bae085b3450cb7c0d3d4475b1e98a7debccbf63",
"jdt.json": "814d7459bcda4346e1f8e2804f2297d20bf4278414e1a363b2c40a16b14e0351",
"jsbeautifyrc-nested.json": "6f666ec1e506bbaad432254284cbad7f3c887ff0d4064fc802048246712eea86",
"jsbeautifyrc.json": "aaec6f96a21849f226e40c28ca30ae69084e1ef1b2e874d253ac75494160ea99",
"jsconfig.json": "6d0caf76aa69eb3403e0e5544a4b785b0ac3293697c507e672702adba194ba5d",
"jscsrc.json": "587855da664fed0ce8d52087da3f42a815911575edfe31c5b711856929042d07",
"jshintrc.json": "f05726025676857cd2ac17ca26a1d20eb227c96152b5baf6ea85ba6f1b3cb965",
"jsinspectrc.json": "7f5e226b76b71a3f11cd1bee1b92f7cd9d9e354ffa700aab7cd942d7ca7f6bd7",
"json-api-1.0.json": "f0e55377dde5efc3c236c9c79d72ea4f59d120096ac4b5f0aeceda5a069d596c",
"json-patch.json": "4abe3f9e2f5d3484e95fc2655fe1726ccc2bcc9cfc49e9dd686e76831c917b9a",
"jsonld.json": "08460786d5403df9f125de2fdf41feeb7c3836ce5462e940e6b76d7d9c5b37e0",
"ksp-ckan-1.16.json": "e69b582c10222e6b117e7ba801f5baa43382848fc295bec8c35efec3a86eac96",
"launchsettings.json": "e5417eb29559164a9a6233b761efc3d97ee370d11fd80fa519bad5dac201e82b",
"libman.json": "1230675101f80184c044c162eecfa6af1e83517cc80c03b53fcb6f92afaf90c8",
"licenses.1.json": "0a0652cea53b76df324f0b916c9b57770b312e90d3b338785e654ed9bddcaa14",
"lsdlschema.json": "d960698f0f3df95b61adbe2e9302001cdf81df42b1fbb26059eb3735f1a29a96",
"mimetypes.json": "9c382b6b856eb1410a7be9fd9f7ec54b9ecb61656c6e8f5a9b6f7e1c1013c368",
"modernizrrc.json": "9b21068b376810d4c09d05e66e7d0fa27e9a62e9ba13d965956bc7c2ddcbb7cf",
"mycode.json": "5b0590053500046ce46c1ab6ddb300e5c38a934024b177c2222d737dea304c9d",
"ninjs.json": "15d10200cce962a8b7db907d80c016a4da3f353790ee3dbc94bad9ae411bebb1",
"npm-link-up.json": "b4c7f5fdc3919556efe9ac45ae0d2d2cf2d1eb98c4d509e46c23d76367cdad59",
"nuget-project-3.3.0.json": "2900e400cac9f005a760bab30049043a351b8cc7755e916cfad629b69e5df621",
"nuget-project.json": "1703b54f4f54c3266457191842ad77b3b126cc6b38eae3e7b5e502fff6a409ce",
"omnisharp.json": "3dca75b20347a784f9e1d67aab73449ddf4bd9ea5a0a9a36d13a8d0b36cc867e",
"openfin.json": "f9781c1ee738f718d8244c2c13f04abb924eaea9b36450d15d360fecf555606b",
"package.json": "9afdf5b83e66833d7bc082b271d5acf55408482a47a09bc829d88e424bab96f8",
"package.manifest.json": "891fc499ee35e047cf264a989515ad1024cafa48e65a6dbda2c68ec37728daae",
"pattern.json": "e88d724a4c9eb90d4d5a9d5a4cdb613841f045f3f1b83f46124a64c5beeed502",
"phraseapp.json": "ee4bd185e2e73e999d992bcb89c3a1344f8db20af5cb6d4948784966c531fd7e",
"prettierrc-1.8.2.json": "3752212c2514117b36737748b21e7210538acd3adf7623b7500db1b968648432",
"prettierrc.json": "7bd47b4dd95754ecf3b26986c1e020714cdf783816478ebc2b810f1ccf9b9191",
"prisma.json": "46ab941fd4b110604e905b38bcae9dfff48aaed5437fe091f8641aa5018b3fa0",
"project-1.0.0-beta3.json": "a23a61bb548ab86b9ee0b8f894cf42b90403e798e491fab68b65a2774673d2e2",
"project-1.0.0-beta4.json": "64285c3df73272047bf6d7386cf4d87ad671aacff305fa89ae1ae5663b14f123",
"project-1.0.0-beta5.json": "8f5180caf21f275428c6dedacc37262110470305e26ff6f25c88d48ab4490261",
"project-1.0.0-beta6.json": "b3f289799d54cb31db1f32183b7c2be92e109c00109cf5ff71ff562334ebb0cf",
"project-1.0.0-beta8.json": "dbf565576df0608e68e2d0838401802b5d62a9ee5fdda597c07bb3b1dfd584b3",
"project-1.0.0-rc1.json": "d6bfe69cc18fca2a9f74c0b20d18ea7f4232ad4248417cc94e8aceed02a3ffb6",
"project-1.0.0-rc2.json": "6f2585e6f8303bafd90f6c93bed9c2b35ea142dac408761830e24e0a06f8367d",
"project.json": "a7e5136894f6a3f352aad341d332c82f30beb31d9de04b94bc92980fec8be079",
"proxies.json": "be3fd3279da487008e3f36a90dc7acbc181bb9ea364e4a5689f8fe19d8282190",
"renovate.json": "0d101a938bfe5b02a182d77d982aada0f848e61164b77166b5b312f9f1db581f",
"resjson.json": "f268c7820133f09c68c0599a1adce555255aa93e27f0ddb8c54c69da1e254f3f",
"resume.json": "eb8a83b073f722118788c1f631d82e0adb5207268475582c340469be71e5e395",
"sarif-1.0.0-beta.4.json": "51d6126ec481cf6928036d239c44289cc7de78b592d6e8ae05c1bdc1cad6d42a",
"sarif-1.0.0-beta.5.json": "9f9bcdbfcc83d160b3e16a7c030b5418bd88d481bf08097916fd6c1c765bf9a0",
"sarif-1.0.0.json": "3d381606211e14da54498868bce849356d45f52b3fbb2495e49c24477d8f735c",
"sarif.json": "3d381606211e14da54498868bce849356d45f52b3fbb2495e49c24477d8f735c",
"schema-catalog.json": "b7ba9aea97d38e0dbf9a52153627d4339c73efd1e8865749fadf4eb236c9c321",
"schema-draft-v4.json": "4ac3fdcf0206cb602f566289543696bd37655c6596b07677d139d9475583a8d5",
"schema-org-action.json": "3d724ac446abd13c22804d9fa3d00725ce3f7464309a1527423f917c3e7e6e47",
"schema-org-contact-point.json": "4b75c0056f94a760fc181cdc783bd482bbe4c1d641ddc48ce820f1cc9d0a18c1",
"schema-org-place.json": "fc8eee9c99a70e88830545cdf98dccc45f443d06d6495ab64348771f00327dde",
"schema-org-thing.json": "67a1a7c5349feac1e8e1bb6853b2b93914c4ea6eb7d1aa9de8343fc2bc8eac98",
"settings.job.json": "df461dc130e39b4d20cde2db0a279966afa6820e7d05eb855acfb6d53de8e6d2",
"solidaritySchema.json": "d74654c0d9064385d1b177c1760f38afc92b868e8133a704d9da1b46c299f1da",
"sourcemap-v3.json": "8ae4ec4563d4677ac65e41995c96230d2adafe88c766da72cf3861ee892581e5",
"sprite.json": "a22ebebea849e00852bfec870d79208d0399ccbf94c13f44557e9aff04217f0a",
"stylelintrc.json": "cfb6f6e7f3d99b37c9f4fb9b0e498b9166ebda4a59ffb21d91a8dfd417369458",
"stylintrc.json": "e5459f17ae0adb3e72dfd542c199b01e8a90acb2dde678399e5f7278839f0bd1",
"swagger-2.0.json": "b36871c8016292c5e66dd3b203e69aeff98bfef97e0b3c67c1909036095586a5",
"template.json": "ab60804fb68e7e1c9d2120dd82e21c6d7ff3ed9aec73df6efeb9dc617912a9ed",
"templatesources.json": "67d9444da899b52138b8491f871ee5f513eede337a3aaf964d2fac3ad68a5e22",
"toolinfo.1.1.0.json": "2ac8092b86a5a4a11b00b04fad8df9e037d8e077a6a5a8be9494574085bfe55a",
"travis.json": "70fcefb4308f7f0ce6e448ad8aab5e2f2468c4ddfe4c233d784ea4e8be09770b",
"tsconfig.json": "85a35207c2d5748450a9cddf91215bae3fc995fe8c51737715b4129e288f326c",
"tsd.json": "c34d6febcf996c2462470c24aa7279637c3f9f3280ebf6e6791aff1e04732540",
"tsdrc.json": "e7fb85d7bceeeaf481f3fad0c950fda6cc54ad007391c6c9f776e846ff910765",
"tslint.json": "80792be00ca3d8a831ce349ada70f2edc1ac6b769d2234f329091ceac04a5e2e",
"typewiz.json": "747458f24c4d9146c57de79f971705164b22eaeefc3642ba364b3c6c770492e1",
"typings.json": "0f32f8d1be86efb73afa8ee5bb936884bcabe9f2411a06a87aa26995b25c4143",
"typingsrc.json": "776174b3533248323c84af0df8b2b3a951d1c8a01a204eeea3b5470ab3db3175",
"ui5-manifest.json": "137540bae419736bacffb02510de34525fc841411105576a99d405633578a169",
"up.json": "36c215b32cba171aa92736ac6dbd23125e7b67709b19fb22dfa575ad1499c4f7",
"vega-lite.json": "0bd3b729358da93d8a6849612cf8c9e97dce453039ef53d2a0f96f2518bc3c4c",
"vega.json": "802f5f75daf5b97e7d517c80b5f5239b1cdc766fe4edb30509257d134a7e8318",
"vs-2017.3.host.json": "e46bdf556074586d3b0a39871f3456e24a29805709c60805739d7f5a3a4a411b",
"vs-nesting.json": "508fceb7731ee7da7a10ef603a3134406bbf181c542a43440b052baab1bc2180",
"vsext.json": "a061f0e1a0c621885e2873f09d3b3ff39ea9221d6aa492f93e188ef388e0e040",
"vsix-manifestinjection.json": "0997e027cf3b0296d3514a09d2b7010604057fe42dfd8abb5e46ac9fd5e2166f",
"vsix-publish.json": "b8758bc2f2f1ec00967c2ee284f33b1ef30688767f6b7a6fe9cc989ce27ce824",
"vsls.json": "959a45e7276a7f1c1cd777a679b75d9096a79e7268a22a4aa248f922338f4d50",
"web-manifest.json": "3e4bc091b889574b5ba8224de5dcaab1ac1ab5b25064b659cb0f36185896ce2e",
"webextension.json": "8e72346d0416eb3073fb11a751c5ac906971db89e1bf65292852d609c751d0ae",
"webjob-publish-settings.json": "b1a803ddfc598699588f9b03f40be08d8949989164e7b6879d83b32baa9c8c02",
"webjobs-list.json": "f898c9e3de948ebbde435dbf8d3d2971f680c3fd234e5046bb0ea215cc909d8a",
"xunit.runner.schema.json": "45a531de2248d20309cb355c689f26e6a3e96e79f8c85dc06452ef60ae25f99b"
}
47 changes: 41 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,55 @@ import * as rimraf from 'rimraf';
import {promisify} from 'util';
import * as simpleGit from 'simple-git/promise';
import * as fs from 'fs';
import * as crypto from 'crypto';

interface SchemaHashes {
[fileName: string]: string;
}

const git = simpleGit('.');
const readDirPromise = promisify(fs.readdir);
const readFilePromise = promisify(fs.readFile);
const rimrafPromise = promisify(rimraf);
const {lockFile, schemaStoreDir, schemaStoreRepo}: {lockFile: string, schemaStoreDir: string, schemaStoreRepo: string} = require('../settings.json');

const {schemaStoreDir, schemastoreRepo}: {schemaStoreDir: string, schemastoreRepo: string} = require('../settings.json');
const schemaStoreDirResolved = path.resolve(schemaStoreDir);
const jsonSchemasDir = path.join(schemaStoreDir, 'src', 'schemas', 'json');
function generateLockFile(data: SchemaHashes, fileName: string) {
return fs.writeFileSync(path.resolve(fileName), JSON.stringify(data, null, 2), {encoding: 'utf8'})
}

async function start() {
await rimrafPromise(schemaStoreDirResolved);
await git.clone(schemastoreRepo, schemaStoreDirResolved, ['--depth=1']);
const schemaStoreDirResolved = path.resolve(schemaStoreDir);
const jsonSchemasDir = path.join(schemaStoreDir, 'src', 'schemas', 'json');
const lockFileResolved = path.resolve(lockFile);

//await rimrafPromise(schemaStoreDirResolved);
//await git.clone(schemaStoreRepo, schemaStoreDirResolved, ['--depth=1']);

const jsonFiles = await readDirPromise(jsonSchemasDir);
console.log({jsonFiles});
const jsonData: SchemaHashes = {};
for (const fileName of jsonFiles) {
const fileNameResolved = path.resolve(jsonSchemasDir, fileName);
const fileContent = await readFilePromise(fileNameResolved, {encoding: 'utf8'});
const sha256 = crypto.createHash('sha256')
.update(fileContent)
.digest('hex');

jsonData[fileName] = sha256;
}

if (fs.existsSync(lockFileResolved)) {
const lockFile = await readFilePromise(lockFileResolved, {encoding: 'utf8'});
const lockFileData = JSON.parse(lockFile);
const failedHashes: SchemaHashes = {};
for (const fileName in jsonData) {
if (jsonData[fileName] !== lockFileData[fileName]) {
failedHashes[fileName] = jsonData[fileName];
}
}
console.log({failedHashes})
} else {
await generateLockFile(jsonData, lockFileResolved);
}
}

start();
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "dist",
"removeComments": true,
Expand Down

0 comments on commit f738c4d

Please sign in to comment.