Download scripts/extract-project.mjs from drewgrant616/7deadlysinstest: direct link, hf CLI and curl.
- Browser
- Download file 2.76 kB
-
https://huggingface.co/datasets/drewgrant616/7deadlysinstest/resolve/main/scripts/extract-project.mjs
- Command line
-
hf download hf://datasets/drewgrant616/7deadlysinstest/scripts/extract-project.mjs
-
curl -L -o extract-project.mjs https://huggingface.co/datasets/drewgrant616/7deadlysinstest/resolve/main/scripts/extract-project.mjs
2.76 kB
| // Run inside the original project. Never reads environment files or credentials. | |
| import fs from 'node:fs/promises'; | |
| import path from 'node:path'; | |
| import {fileURLToPath, pathToFileURL} from 'node:url'; | |
| import {createHash} from 'node:crypto'; | |
| const base = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); | |
| const root = path.resolve(base, '../../..'); | |
| const ts = (await import(pathToFileURL(path.join(root, 'node_modules/typescript/lib/typescript.js')).href)).default; | |
| const names = ['quiz', 'analysis', 'full-quiz', 'characters']; | |
| const modules = {}, hashes = {}; | |
| for (const name of names) { | |
| const relative = `src/shared/quiz/${name}.ts`; | |
| const bytes = await fs.readFile(path.join(root, relative)); | |
| hashes[relative] = createHash('sha256').update(bytes).digest('hex'); | |
| let js = ts.transpileModule(bytes.toString('utf8'), {compilerOptions: {module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2022}}).outputText; | |
| for (const [dependency, uri] of Object.entries(modules)) js = js.replaceAll(`'./${dependency}'`, JSON.stringify(uri)); | |
| modules[name] = 'data:text/javascript;base64,' + Buffer.from(js).toString('base64'); | |
| } | |
| const quiz = await import(modules.quiz); | |
| const analysis = await import(modules.analysis); | |
| const full = await import(modules['full-quiz']); | |
| const characterModule = await import(modules.characters); | |
| const enrich = (q, mode, i) => ({ | |
| id: `${mode}:${q.id}`, mode, version: mode === 'quick' ? quiz.VERSION : full.FULL_VERSION, | |
| question_id: q.id, position: i + 1, dimension_id: q.sin, text: q.text, | |
| reverse: q.reverse, theme: q.theme || analysis.itemThemes[q.sin][Number(q.id.split('-')[1])], | |
| source_item_id: mode === 'quick' ? q.id : quiz.questions.find(x => x.text === q.text)?.id || q.id, | |
| }); | |
| const snapshot = { | |
| schema_version: '1.0.0', snapshot_date: '2026-11-18', origin: 'https://7deadlysinstest.xyz', | |
| source_sha256: hashes, dimensions: quiz.sins.map((s, i) => ({...s, position: i + 1})), | |
| characters: characterModule.characters, | |
| options: quiz.options.map((label, raw) => ({raw, label})), | |
| modes: [{id:'quick', version:quiz.VERSION, question_count:quiz.questions.length, minimum:quiz.MIN_ANSWERS}, | |
| {id:'full', version:full.FULL_VERSION, question_count:full.fullQuestions.length, minimum:full.FULL_MIN_ANSWERS}], | |
| questions: [...quiz.questions.map((q,i)=>enrich(q,'quick',i)), ...full.fullQuestions.map((q,i)=>enrich(q,'full',i))], | |
| sample_answers: analysis.sampleAnswers, | |
| }; | |
| await fs.mkdir(path.join(base,'source'), {recursive:true}); | |
| await fs.writeFile(path.join(base,'source/snapshot.json'), JSON.stringify(snapshot,null,2)+'\n'); | |
| console.log('Extracted original quiz content and source hashes; no template code exported.'); | |
| export {quiz, analysis, full, characterModule, base, root}; | |