Skip to content

Commit

Permalink
Add peeve script
Browse files Browse the repository at this point in the history
  • Loading branch information
lxchurbakov committed Feb 2, 2024
1 parent 66fbb11 commit 99c6d16
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
tmp
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const promisify = (predicate) => (...args) => new Promise((resolve, reject) => p
const readFile = promisify(fs.readFile.bind(fs));
const writeFile = promisify(fs.writeFile.bind(fs));
const makeDir = promisify(fs.mkdir.bind(fs));
const readDir = promisify(fs.readdir.bind(fs));
const copyFile = promisify(fs.copyFile.bind(fs));

const beautify = (name) => name.charAt(0).toUpperCase() + name.substr(1);

Expand Down Expand Up @@ -51,7 +53,15 @@ const fetchLichessRating = async (keys = ['blitz', 'rapid', 'puzzle']) => {
await makeDir(dirname).catch(() => null);
await writeFile(outputPath, content);

// await writeFile(dirname + '/peeve.js', 'console.log("it works")')
// Also I want to build a peeve script
// For users to check my page out

const peevedir = path.resolve(process.cwd(), './peeve');

await Promise.all((await readDir(peevedir)).map((async (filename) => {
// Copy file
await copyFile(peevedir + '/' + filename, dirname + '/' + filename);
})));
})().catch((err) => {
console.log(err);
process.exit(-1);
Expand Down
5 changes: 5 additions & 0 deletions peeve/.peeve,json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files": ["package.json"],
"entrypoint": "index.js",
"installDependencies": true
}
82 changes: 82 additions & 0 deletions peeve/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import open from 'open';
import axios from 'axios';
import tkit from 'terminal-kit';

const term = tkit.terminal;

const GITHUB_USERNAME = 'lxchurbakov';
const GITHUB_REPOS_COUNT = 3;

const WEBSITE_LINK = 'https://lxch.io';
const CALENDLY_LINK = 'https://calendly.com/lxch/job-interview';

term.white('👋 Hello fellow dev!\n\n');

term.white('I am');
term.cyan(' Alexander')
term.white(' aka')
term.cyan(' @lxchurbakov')
term.white(', a JS/TS dev \nwith more than 8 years of productioin experience\n');
term.white('and I am looking for a job right now!\n');

const select = (items) => {
return new Promise((resolve, reject) => {
term.singleColumnMenu( items , (error, response) => {
if (error) {
reject(error);
} else {
resolve(response.selectedIndex);
}
});
});
};

;(async () => {

await (async () => {
const repos = await axios
.get(`http://api.github.com/users/${GITHUB_USERNAME}/repos?per_page=${GITHUB_REPOS_COUNT}&sort=updated`)
.then(({ data }) => data);

term.white('\n🛠️ in the meantime I build useless stuff like:\n\n');

repos.forEach((repo) => {
term.white( `○ ${repo.full_name} - ${repo.stargazers_count} ⭐\n`);
term.italic(` ${repo.description}\n `);
term.underline.dim(`${repo.url}\n`);
});
})().catch((err) => {
// Can't fetch repos
});

// Here we fetch game status
const { playing } = await axios.get('https://lichess.org/api/user/lxchurbakov').then(({ data }) => data)

if (playing) {
term.white('\n♖ Looks like I play chess now!\n');
term.white(' Visit this link to watch: ');
term.underline.dim(playing);
}

// Here we proceed to the options
// of what to do with this peeve page

term.white('\n👀 What do you want to do now?\n');

const action = await select([
'Book an interview meeting on calendly',
'Visit my website',
]);

if (action === 0) {
open(CALENDLY_LINK);
}

if (action === 1) {
open(WEBSITE_LINK);
}

process.exit();
})().catch((err) => {
process.exit(-1);
});
1 change: 1 addition & 0 deletions peeve/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"dependencies":{"axios":"^1.6.7","open":"^10.0.3","terminal-kit":"^3.0.1"},"type":"module"}

0 comments on commit 99c6d16

Please sign in to comment.