You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DateKeys-App/scripts/locator-ts-samples.mjs

31 lines
1.4 KiB

#!/usr/bin/env node
// Writes the samples of the interoperability of the locator, TypeScript to
// Go: the files of the recipes of src/lib/dkc/testing/locator-interop.ts,
// sealed locators with their envelopes, which this library writes from a
// seed, and samples.json, the recipes, into a directory.
// scripts/locator-go-verdicts.go then opens them with Go and writes
// src/lib/dkc/testing/locator-interop.json; locator.interop.test.ts writes
// the files again from the recipes and compares them with what Go read.
// Node runs the TypeScript sources directly (type stripping, Node 22.6+):
//
// node scripts/locator-ts-samples.mjs <directory>
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { interopFiles, interopRecipes } from '../src/lib/dkc/testing/locator-interop.ts';
const dir = process.argv[2];
if (dir === undefined) {
console.error('usage: node scripts/locator-ts-samples.mjs <directory>');
process.exit(2);
}
mkdirSync(dir, { recursive: true });
const recipes = interopRecipes();
for (const [i, r] of recipes.entries()) {
const files = interopFiles(r);
for (const [suffix, b] of Object.entries(files)) writeFileSync(join(dir, `${i}.${suffix}`), b);
console.log(`${r.name}: ${Object.keys(files).join(', ')}`);
}
writeFileSync(join(dir, 'samples.json'), `${JSON.stringify({ samples: recipes }, null, 1)}\n`);
console.log(`wrote ${recipes.length} samples to ${dir}`);

Powered by TurnKey Linux.