perlsky is a Perl 5 implementation of an AT Protocol Personal Data Server.
1#!/usr/bin/env perl
2use v5.34;
3use warnings;
4
5use File::Basename qw(dirname);
6use File::Path qw(make_path);
7use File::Spec;
8
9my $root = File::Spec->rel2abs(File::Spec->catdir(dirname(__FILE__), '..'));
10my $runtime_dir = File::Spec->catdir($root, '.tools', 'reference-runtime');
11my $module_path = File::Spec->catdir($runtime_dir, 'node_modules', '@atproto', 'pds');
12
13if (-d $module_path) {
14 print "$module_path\n";
15 exit 0;
16}
17
18make_path($runtime_dir);
19
20chdir $runtime_dir or die "unable to chdir to $runtime_dir: $!";
21
22if (!-f File::Spec->catfile($runtime_dir, 'package.json')) {
23 system('npm', 'init', '-y') == 0
24 or die "npm init failed\n";
25}
26
27my @fnm_check = ('fnm', 'exec', '--using=20', '--', 'node', '--version');
28if (system(@fnm_check) != 0) {
29 system('fnm', 'install', '20') == 0
30 or die "unable to install Node 20 with fnm\n";
31}
32
33system(
34 'fnm', 'exec', '--using=20', '--',
35 'npm', 'install', '--no-save', '@atproto/pds@0.4.214',
36) == 0 or die "npm install for \@atproto/pds failed\n";
37
38print "$module_path\n";