Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions scripts/fetch-sources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,30 @@
* Existing vendor clones are reused (delete vendor/ to force a refresh).
* Network failures are warnings, not errors — docs pages degrade gracefully.
*/
import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
import { existsSync, mkdirSync, readdirSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { parse as parseYaml } from 'yaml';
import { parseFrontmatter } from '../src/lib/frontmatter.mjs';
import { RNP_EXTRA_SPARSE } from '../src/lib/vendor-source.mjs';

const root = join(dirname(fileURLToPath(import.meta.url)), '..');
const vendorDir = join(root, 'vendor');
const softwareDir = join(root, 'src/content/software');

/** Extra files to check out per product, gitignore-style sparse patterns. */
const EXTRA_PATHS = {
rnp: ['/src/rnp/rnp.1.adoc', '/src/rnpkeys/rnpkeys.1.adoc', '/src/lib/librnp.3.adoc'],
rnp: RNP_EXTRA_SPARSE,
};

function frontMatter(file) {
const raw = readFileSync(file, 'utf8');
const m = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
return m ? (parseYaml(m[1]) ?? {}) : {};
}

function run(args, cwd) {
execFileSync('git', args, { cwd, stdio: 'pipe' });
}

let failures = 0;

for (const file of readdirSync(softwareDir).filter((f) => f.endsWith('.md'))) {
const fm = frontMatter(join(softwareDir, file));
const fm = parseFrontmatter(join(softwareDir, file)).frontMatter;
if (!fm.docs_repo) continue;

const name = file.replace(/\.md$/, '');
Expand Down
21 changes: 11 additions & 10 deletions src/components/vue/EasterEggs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { dispatch, RNP_EVENTS, RNP_STORAGE } from '@/lib/events';

const toastMsg = ref('');
const toastEl = ref<HTMLElement | null>(null);
Expand Down Expand Up @@ -244,11 +245,11 @@ const onKey = (e: KeyboardEvent) => {
word = (word + k).slice(-12);
if (word.endsWith('decrypt')) {
word = '';
window.dispatchEvent(new CustomEvent('rnp:replay-hero'));
dispatch(RNP_EVENTS.replayHero);
toast('Replaying decryption…');
} else if (word.endsWith('encrypt')) {
word = '';
window.dispatchEvent(new CustomEvent('rnp:encrypt-hero'));
dispatch(RNP_EVENTS.encryptHero);
toast('Encrypting…');
} else if (word.endsWith('rnp') || word.endsWith('pgp')) {
word = '';
Expand Down Expand Up @@ -408,16 +409,16 @@ const showEggHelp = () => {

onMounted(() => {
window.addEventListener('keydown', onKey);
window.addEventListener('rnp:hex-rain', onHexRainReq);
window.addEventListener('rnp:hal-scene', onHalReq);
window.addEventListener('rnp:dave-scene', onDaveReq);
window.addEventListener(RNP_EVENTS.hexRain, onHexRainReq);
window.addEventListener(RNP_EVENTS.halScene, onHalReq);
window.addEventListener(RNP_EVENTS.daveScene, onDaveReq);

window.rnp = window.rnp || {};
window.rnp.help = showEggHelp;
if (typeof window.help === 'undefined') window.help = showEggHelp;

if (!sessionStorage.getItem('rnp:help-hinted')) {
sessionStorage.setItem('rnp:help-hinted', '1');
if (!sessionStorage.getItem(RNP_STORAGE.helpHinted)) {
sessionStorage.setItem(RNP_STORAGE.helpHinted, '1');
console.log(
'%c👋 psst — type %chelp()%c to see the easter eggs',
'color:#888;font-style:italic;',
Expand All @@ -428,9 +429,9 @@ onMounted(() => {
});
onUnmounted(() => {
window.removeEventListener('keydown', onKey);
window.removeEventListener('rnp:hex-rain', onHexRainReq);
window.removeEventListener('rnp:hal-scene', onHalReq);
window.removeEventListener('rnp:dave-scene', onDaveReq);
window.removeEventListener(RNP_EVENTS.hexRain, onHexRainReq);
window.removeEventListener(RNP_EVENTS.halScene, onHalReq);
window.removeEventListener(RNP_EVENTS.daveScene, onDaveReq);
clearTimeout(toastTimer);
clearHalTimers();
clearDaveTimers();
Expand Down
Loading
Loading