cjmaybe 0.0.0-stage โ 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -2
- package/bin/cli.js +84 -0
- package/package.json +33 -4
- package/src/bubble.js +12 -0
- package/src/cat.js +27 -0
- package/src/input.js +87 -0
- package/src/profile.js +102 -0
- package/src/system.js +24 -0
- package/src/views.js +361 -0
package/README.md
CHANGED
|
@@ -1,3 +1,185 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ๐พ NPX cjmabe
|
|
4
|
+
|
|
5
|
+
**My portfolio, but it lives in your terminal.**
|
|
6
|
+
|
|
7
|
+
No installation. No sign-up. Just run it.
|
|
8
|
+
|
|
9
|
+
<br />
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
A Node.js CLI portfolio published as an npm package and launched directly with `npx`. Instead of opening a traditional website, it brings my portfolio straight into the terminal.
|
|
20
|
+
|
|
21
|
+
It has an interactive, terminal-native interface with my introduction, projects, technical skills, highlights, social profiles and contact details, all wrapped in a retro-inspired TUI design.
|
|
22
|
+
|
|
23
|
+
The experience combines braille dot art, ASCII lettering, colorful styling, keyboard navigation and clickable links, so exploring my work feels a little different from the usual portfolio.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Run this in any terminal that has Node.js 18 or newer:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx cjmaybe
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Skip the typing intro and jump straight to the card:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx cjmaybe --fast
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> Tip: if you ever see an old version, run `npx cjmaybe@latest`.
|
|
40
|
+
|
|
41
|
+
## What you will see
|
|
42
|
+
|
|
43
|
+
1. **A short typed intro.** Press any key to skip it.
|
|
44
|
+
2. **A welcome line** with the package version, like `๐พ Welcome to cj's CLI Portfolio - v1.2.3`.
|
|
45
|
+
3. **The portfolio card.** Braille dot art of the character with a speech bubble on the left, and a big `CJMAYBE` title, my details and colored link bars on the right.
|
|
46
|
+
4. **An interactive menu** to explore the rest.
|
|
47
|
+
|
|
48
|
+
### Menu
|
|
49
|
+
|
|
50
|
+
| Item | What it does |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| About me | A little context about who I am |
|
|
53
|
+
| Projects | Things I have built and ideas I am working on |
|
|
54
|
+
| Skills | Languages, web and backend, databases, tools |
|
|
55
|
+
| Highlights | Hackathons, paper presentation, certificates |
|
|
56
|
+
| Find me online | All my links in one place |
|
|
57
|
+
| GitHub / LinkedIn | Opens the profile in your browser |
|
|
58
|
+
| Portfolio website | The full version at [maybecj.web.app](https://maybecj.web.app) |
|
|
59
|
+
| Resume | Opens my resume |
|
|
60
|
+
| Say hello | Opens your mail app with a message to me |
|
|
61
|
+
| Tips | Shortcuts and little tricks |
|
|
62
|
+
| Exit | Closes the portfolio |
|
|
63
|
+
|
|
64
|
+
### Controls
|
|
65
|
+
|
|
66
|
+
| Key | Action |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `โ` `โ` or `j` `k` | Move through the menu |
|
|
69
|
+
| `Enter` | Select |
|
|
70
|
+
| Any key | Skip the intro / go back from a page |
|
|
71
|
+
| `Ctrl` + `C` | Exit any time |
|
|
72
|
+
| `Ctrl` / `Cmd` + click | Open a link from the card |
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
- **Zero install.** Works with `npx`, nothing to set up.
|
|
77
|
+
- **Retro TUI look.** Gradient ASCII title, braille dot art and a braille speech bubble.
|
|
78
|
+
- **Clickable links.** Links use terminal hyperlinks, so Ctrl/Cmd + click works in Windows Terminal, iTerm2, VS Code and similar terminals.
|
|
79
|
+
- **Responsive.** Wide terminals get the full card with art. Narrower ones get a clean centered layout.
|
|
80
|
+
- **Pipe friendly.** When the output is not an interactive terminal, it prints the card and exits without the menu.
|
|
81
|
+
- **Easy to customize.** All content lives in one file.
|
|
82
|
+
|
|
83
|
+
## Terminal requirements
|
|
84
|
+
|
|
85
|
+
- Node.js **18 or newer**
|
|
86
|
+
- A terminal at least **120 columns** wide to see the full card with the dot art
|
|
87
|
+
- A font with braille and box-drawing characters (most modern terminal fonts have them)
|
|
88
|
+
|
|
89
|
+
## Run it locally
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git clone <your-repo-url>
|
|
93
|
+
cd cli-cjmaybe
|
|
94
|
+
npm install
|
|
95
|
+
npm start # full experience
|
|
96
|
+
npm run fast # skip the intro
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Make it your own
|
|
100
|
+
|
|
101
|
+
Everything you see is plain data and a few small files:
|
|
102
|
+
|
|
103
|
+
| File | What to change |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| `src/profile.js` | Name, role, links, intro, about, skills, projects, highlights, tips, footer, speech bubble text |
|
|
106
|
+
| `src/cat.js` | The braille dot art on the left (any braille art works) |
|
|
107
|
+
| `src/bubble.js` | The shape of the speech bubble |
|
|
108
|
+
| `src/views.js` | Layout, colors and the typing speed (`TIMING` at the top) |
|
|
109
|
+
| `bin/cli.js` | Menu items and what each one does |
|
|
110
|
+
| `package.json` | Package name, version, description |
|
|
111
|
+
|
|
112
|
+
## Project structure
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
cli-cjmaybe/
|
|
116
|
+
โโโ bin/
|
|
117
|
+
โ โโโ cli.js # entry point and menu
|
|
118
|
+
โโโ src/
|
|
119
|
+
โ โโโ profile.js # all your content
|
|
120
|
+
โ โโโ views.js # welcome line, card, panels, intro
|
|
121
|
+
โ โโโ input.js # arrow-key menu and key handling
|
|
122
|
+
โ โโโ system.js # opens links and mail
|
|
123
|
+
โ โโโ cat.js # braille dot art
|
|
124
|
+
โ โโโ bubble.js # braille speech bubble
|
|
125
|
+
โโโ demo/
|
|
126
|
+
โ โโโ demo.png
|
|
127
|
+
โโโ package.json
|
|
128
|
+
โโโ README.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Built with
|
|
132
|
+
|
|
133
|
+
- [Node.js](https://nodejs.org), plain ES modules
|
|
134
|
+
- [chalk](https://github.com/chalk/chalk) for colors
|
|
135
|
+
- [boxen](https://github.com/sindresorhus/boxen) for the bordered card
|
|
136
|
+
- [figlet](https://github.com/patorjk/figlet.js) for the ASCII title
|
|
137
|
+
|
|
138
|
+
## Publish your own
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm login
|
|
142
|
+
npm pack --dry-run # check what will be published
|
|
143
|
+
npm publish --access public
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
npm needs two-factor authentication set to "Authorization and publishing" (or a granular access token that can bypass 2FA). Bump `version` in `package.json` before every new publish.
|
|
147
|
+
|
|
148
|
+
## Inspiration
|
|
149
|
+
|
|
150
|
+
This project was inspired by the creativity of terminal-based portfolios built by other developers:
|
|
151
|
+
|
|
152
|
+
- [npx-ritik](https://github.com/itzzritik/npx-ritik) by [@itzzritik](https://github.com/itzzritik)
|
|
153
|
+
- [cmd-abhijith](https://github.com/Abhxjith/cmd-abhijith) by [@Abhxjith](https://github.com/Abhxjith)
|
|
154
|
+
|
|
155
|
+
Their work motivated me to explore presenting a personal portfolio directly inside the terminal.
|
|
156
|
+
|
|
157
|
+
## Credits
|
|
158
|
+
|
|
159
|
+
Special thanks to the developers behind the projects above for sharing their work and inspiring the CLI portfolio concept.
|
|
160
|
+
|
|
161
|
+
This project is independently customized with my own branding, profile information, design choices and implementation.
|
|
162
|
+
|
|
163
|
+
## Connect
|
|
164
|
+
|
|
165
|
+
| | |
|
|
166
|
+
| --- | --- |
|
|
167
|
+
| GitHub | [github.com/cjmaybe](https://github.com/cjmaybe) |
|
|
168
|
+
| LinkedIn | [linkedin.com/in/cjmaybe](https://linkedin.com/in/cjmaybe) |
|
|
169
|
+
| Portfolio | [maybecj.web.app](https://maybecj.web.app) |
|
|
170
|
+
| Email | [cjmaybe0@gmail.com](mailto:cjmaybe0@gmail.com) |
|
|
171
|
+
| CLI | `npx cjmaybe` |
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT. Feel free to learn from it, and please keep the credits above if you build on it.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
<div align="center">
|
|
180
|
+
|
|
181
|
+
Hello World โค๏ธ made by cj
|
|
182
|
+
|
|
183
|
+
<br />
|
|
184
|
+
|
|
185
|
+
</div>
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { profile } from "../src/profile.js";
|
|
4
|
+
import { openUrl } from "../src/system.js";
|
|
5
|
+
import { pressAnyKey, select } from "../src/input.js";
|
|
6
|
+
import {
|
|
7
|
+
drawAbout, drawCard, drawHighlights, drawLinks, drawProjects, drawSkills, drawTips, drawWelcome, intro, makeSkipper
|
|
8
|
+
} from "../src/views.js";
|
|
9
|
+
|
|
10
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
11
|
+
const fast = process.argv.includes("--fast") || process.argv.includes("-f") || !interactive;
|
|
12
|
+
|
|
13
|
+
const note = (message) => console.log(`\n${chalk.greenBright(message)}\n`);
|
|
14
|
+
const pause = () => pressAnyKey("press any key to head back");
|
|
15
|
+
|
|
16
|
+
const actions = {
|
|
17
|
+
about: async () => { drawAbout(); await pause(); },
|
|
18
|
+
skills: async () => { drawSkills(); await pause(); },
|
|
19
|
+
projects: async () => { drawProjects(); await pause(); },
|
|
20
|
+
highlights: async () => { drawHighlights(); await pause(); },
|
|
21
|
+
links: async () => { drawLinks(); await pause(); },
|
|
22
|
+
tips: async () => { drawTips(); await pause(); },
|
|
23
|
+
github: () => { openUrl(profile.github); note("Opening GitHub. Have a look around!"); },
|
|
24
|
+
linkedin: () => { openUrl(profile.linkedin); note("Taking you to LinkedIn."); },
|
|
25
|
+
portfolio: () => { openUrl(profile.portfolio); note("Opening my portfolio site."); },
|
|
26
|
+
resume: () => { openUrl(profile.resume); note("Opening my resume. Thanks for taking a look!"); },
|
|
27
|
+
email: () => {
|
|
28
|
+
openUrl(`mailto:${profile.email}?subject=${encodeURIComponent("Hey cj!")}`);
|
|
29
|
+
note(`Your email app should open. You can also write to ${profile.email}`);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const choices = [
|
|
34
|
+
{ name: "About me", value: "about", description: "a little context about who I am" },
|
|
35
|
+
{ name: "Projects", value: "projects", description: "things I've made and ideas I'm working on" },
|
|
36
|
+
{ name: "Skills", value: "skills", description: "tools and tech I enjoy using" },
|
|
37
|
+
{ name: "Highlights", value: "highlights", description: "a few things I've been part of" },
|
|
38
|
+
{ name: "Find me online", value: "links", description: "my links, all in one place" },
|
|
39
|
+
{ name: "GitHub", value: "github", description: "take a look at the code" },
|
|
40
|
+
{ name: "LinkedIn", value: "linkedin", description: "let's connect" },
|
|
41
|
+
{ name: "Portfolio website", value: "portfolio", description: "the full version, in a browser" },
|
|
42
|
+
{ name: "Resume", value: "resume", description: "for the more formal stuff" },
|
|
43
|
+
{ name: "Say hello", value: "email", description: "send me a message" },
|
|
44
|
+
{ name: "Tips", value: "tips", description: "shortcuts and little tricks" },
|
|
45
|
+
{ name: "Exit", value: "exit", description: "that's all for now. see you!" },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const main = async () => {
|
|
49
|
+
if (interactive) console.clear();
|
|
50
|
+
|
|
51
|
+
const skipper = interactive && !fast ? makeSkipper() : { state: { skipped: false }, stop() {} };
|
|
52
|
+
await intro(fast, skipper.state);
|
|
53
|
+
if (interactive) console.clear();
|
|
54
|
+
drawWelcome();
|
|
55
|
+
await drawCard();
|
|
56
|
+
skipper.stop();
|
|
57
|
+
|
|
58
|
+
if (!interactive) {
|
|
59
|
+
console.log(chalk.dim("Run this in a terminal to explore the menu: npx cjmaybe"));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(chalk.dim(" and here's the actual portfolio. โ โ to move, enter to open.\n"));
|
|
64
|
+
|
|
65
|
+
while (true) {
|
|
66
|
+
const answer = await select({ message: "What would you like to see?", choices });
|
|
67
|
+
if (answer === "exit") {
|
|
68
|
+
note("Thanks for visiting my cli portfolio. Have a nice Day!");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
await actions[answer]();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
process.on("SIGINT", () => {
|
|
76
|
+
process.stdout.write("\x1B[?25h\n");
|
|
77
|
+
process.exit(0);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
main().catch((error) => {
|
|
81
|
+
process.stdout.write("\x1B[?25h");
|
|
82
|
+
console.error(chalk.red("Something went wrong:"), error);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cjmaybe",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "A small, friendly terminal portfolio by Chiranjeevi K (cj)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cjmaybe": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"start": "node bin/cli.js",
|
|
15
|
+
"fast": "node bin/cli.js --fast"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"cli",
|
|
19
|
+
"portfolio",
|
|
20
|
+
"resume",
|
|
21
|
+
"npx",
|
|
22
|
+
"terminal",
|
|
23
|
+
"cjmaybe"
|
|
24
|
+
],
|
|
25
|
+
"author": "Chiranjeevi K",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"boxen": "^9.0.0",
|
|
32
|
+
"chalk": "^6.0.1",
|
|
33
|
+
"figlet": "^1.13.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/bubble.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Braille speech bubble (oval with a tail at the bottom-left), 19 columns x 8 rows.
|
|
2
|
+
// The text from `profile.speech` is written inside the oval at run time.
|
|
3
|
+
export const bubbleArt = [
|
|
4
|
+
"โ โ โ โ โฃโฃคโฃดโ ถโ ถโ ถโ ถโขถโฃคโฃโฃโ โ โ โ ",
|
|
5
|
+
"โ โขโฃดโ โ โ โ โ โ โ โ โ โ โ โ โขทโฃโ โ ",
|
|
6
|
+
"โข โกฟโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ นโฃงโ ",
|
|
7
|
+
"โขธโฃโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โฃฟโ ",
|
|
8
|
+
"โ โ ปโฃฆโกโ โ โ โ โ โ โ โ โ โ โ โฃโฃพโ โ ",
|
|
9
|
+
"โ โ โขโฃงโ โ โ โ โขโฃโฃโฃ โฃคโฃดโ พโ โ โ โ ",
|
|
10
|
+
"โ โฃ โกฟโฃโฃ โฃคโกถโ พโ โ โ โ โ โ โ โ โ โ โ ",
|
|
11
|
+
"โ โ ฟโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ ",
|
|
12
|
+
];
|
package/src/cat.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Braille dot art shown on the left of the card (supplied by Chiranjeevi).
|
|
2
|
+
// Perfect square: 48 columns x 24 rows = 96 x 96 dots (a braille cell is 2 dots wide x 4 dots tall).
|
|
3
|
+
export const catArt = [
|
|
4
|
+
"โ โ โ โ โ โ โ โข โฃฟโฃฟโฃฆโ โ โ โ โ โ โ โ โ โขโฃดโฃฟโฃฆโกโ โ โ โ โ โ โ ",
|
|
5
|
+
"โ โ โ โ โ โ โข โฃฟโฃฟโฃฟโฃฟโฃโ โ โ โ โ โ โ โ โฃพโฃฟโฃฟโฃฟโฃทโ โ โ โ โ โ โ ",
|
|
6
|
+
"โ โ โ โ โ โขโฃพโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โฃธโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ ",
|
|
7
|
+
"โ โ โ โ โ โฃพโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โขโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโ โ โ โ โ โ ",
|
|
8
|
+
"โ โ โ โ โขธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃงโ โ โ โ โฃผโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ ",
|
|
9
|
+
"โ โ โ โ โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃ โฃคโฃคโฃผโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโ โ โ โ โ ",
|
|
10
|
+
"โ โ โ โขโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโ โ โ โ โ ",
|
|
11
|
+
"โ โ โ โขธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโ โ โ โ โ ",
|
|
12
|
+
"โ โ โ โ โฃฟโฃฟโฃฟโฃฟโ โ โ โ โ โ นโฃฟโฃฟโฃฟโฃฟโฃฟโ โ โ โ โ นโฃฟโฃฟโกฟโ โ โ โ โ ",
|
|
13
|
+
"โ โ โ โ โฃฟโฃฟโฃฟโกโ โ โ โขผโฃฟโ โขฟโฃฟโฃฟโฃฟโฃฟโ โฃพโฃทโ โ โขฟโฃฟโฃทโ โ โ โ โ ",
|
|
14
|
+
"โ โ โ โข โฃฟโฃฟโฃฟโฃทโกโ โ โ โ โขโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โขโฃพโฃฟโฃฟโ โ โ โ โ ",
|
|
15
|
+
"โขโฃโฃโฃโฃฟโฃฟโฃฟโฃฟโฃฟโฃถโฃถโฃถโฃถโฃฟโฃฟโฃฟโฃฟโฃพโฃฟโฃทโฃฆโฃคโฃดโฃฟโฃฟโฃฟโฃฟโฃคโ คโขคโฃคโก",
|
|
16
|
+
"โ โ โ โขโฃโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃโฃโฃโฃโกโ ",
|
|
17
|
+
"โ โ โ โ โขโฃฌโกฟโขฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกฟโฃฅโฃโกโ โ โ โ ",
|
|
18
|
+
"โ โ โ ดโ โ โ โ โ โ โ โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกฟโ โ โ โ โ โ โ โ โ ขโ โ ",
|
|
19
|
+
"โ โ โ โ โ โ โ โ โ โฃธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โ โ โ โ โ ",
|
|
20
|
+
"โ โ โ โ โ โ โ โ โฃฐโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃงโ โ โ โ โ โ โ โ โ โ โ ",
|
|
21
|
+
"โ โ โ โ โ โ โ โข โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โ โ โ โ ",
|
|
22
|
+
"โ โ โ โ โ โ โข โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃโ โ โ โ โ โ โ โ โ โ ",
|
|
23
|
+
"โ โ โ โ โ โข โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โ โ โ ",
|
|
24
|
+
"โ โ โ โ โข โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃงโ โ โ โ โ โ โ โ โ ",
|
|
25
|
+
"โ โ โ โ โฃพโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โ โ ",
|
|
26
|
+
"โ โ โ โขธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ โ โ โ โ โ โ โ ",
|
|
27
|
+
];
|
package/src/input.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import readline from "node:readline";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
const { stdin, stdout } = process;
|
|
5
|
+
|
|
6
|
+
const showCursor = () => stdout.write("\x1B[?25h");
|
|
7
|
+
const hideCursor = () => stdout.write("\x1B[?25l");
|
|
8
|
+
|
|
9
|
+
const startKeys = (handler) => {
|
|
10
|
+
readline.emitKeypressEvents(stdin);
|
|
11
|
+
stdin.setRawMode(true);
|
|
12
|
+
stdin.resume();
|
|
13
|
+
stdin.on("keypress", handler);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const stopKeys = (handler) => {
|
|
17
|
+
stdin.removeListener("keypress", handler);
|
|
18
|
+
stdin.setRawMode(false);
|
|
19
|
+
stdin.pause();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const select = ({ message, choices }) =>
|
|
23
|
+
new Promise((resolve) => {
|
|
24
|
+
let idx = 0;
|
|
25
|
+
let first = true;
|
|
26
|
+
const rows = choices.length + 1; // rows to move up when redrawing
|
|
27
|
+
|
|
28
|
+
const render = () => {
|
|
29
|
+
if (!first) {
|
|
30
|
+
readline.moveCursor(stdout, 0, -rows);
|
|
31
|
+
readline.cursorTo(stdout, 0);
|
|
32
|
+
readline.clearScreenDown(stdout);
|
|
33
|
+
}
|
|
34
|
+
first = false;
|
|
35
|
+
const list = choices
|
|
36
|
+
.map((c, i) => (i === idx ? `${chalk.magentaBright("โฏ")} ${chalk.magentaBright.bold(c.name)}` : ` ${chalk.white(c.name)}`))
|
|
37
|
+
.join("\n");
|
|
38
|
+
const desc = chalk.dim(` ${choices[idx].description || ""}`);
|
|
39
|
+
stdout.write(`${chalk.green("?")} ${chalk.bold(message)}\n${list}\n${desc}`);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const finish = (value) => {
|
|
43
|
+
readline.moveCursor(stdout, 0, -rows);
|
|
44
|
+
readline.cursorTo(stdout, 0);
|
|
45
|
+
readline.clearScreenDown(stdout);
|
|
46
|
+
stdout.write(`${chalk.green("๐พ")} ${chalk.bold(message)} ${chalk.gray("ยท")} ${choices[idx].name}\n`);
|
|
47
|
+
stopKeys(handle);
|
|
48
|
+
showCursor();
|
|
49
|
+
resolve(value);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handle = (_, key) => {
|
|
53
|
+
if (!key) return;
|
|
54
|
+
if (key.ctrl && key.name === "c") {
|
|
55
|
+
stopKeys(handle);
|
|
56
|
+
showCursor();
|
|
57
|
+
process.exit(0);
|
|
58
|
+
} else if (key.name === "up" || key.name === "k") {
|
|
59
|
+
idx = (idx - 1 + choices.length) % choices.length;
|
|
60
|
+
render();
|
|
61
|
+
} else if (key.name === "down" || key.name === "j") {
|
|
62
|
+
idx = (idx + 1) % choices.length;
|
|
63
|
+
render();
|
|
64
|
+
} else if (key.name === "return") {
|
|
65
|
+
finish(choices[idx].value);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
hideCursor();
|
|
70
|
+
startKeys(handle);
|
|
71
|
+
render();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const pressAnyKey = (text = "press any key to go back") =>
|
|
75
|
+
new Promise((resolve) => {
|
|
76
|
+
stdout.write(`\n${chalk.dim(text)}`);
|
|
77
|
+
const handle = (_, key) => {
|
|
78
|
+
if (key && key.ctrl && key.name === "c") {
|
|
79
|
+
stopKeys(handle);
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
stopKeys(handle);
|
|
83
|
+
stdout.write("\n");
|
|
84
|
+
resolve();
|
|
85
|
+
};
|
|
86
|
+
startKeys(handle);
|
|
87
|
+
});
|
package/src/profile.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Edit this file to update the details shown in your CLI.
|
|
2
|
+
export const profile = {
|
|
3
|
+
name: "Chiranjeevi K",
|
|
4
|
+
nickname: "cj",
|
|
5
|
+
handle: "cjmaybe",
|
|
6
|
+
role: "B.E. Computer Science & Design Student",
|
|
7
|
+
college: "Erode Sengunthar Engineering College",
|
|
8
|
+
batch: "2024โ2028",
|
|
9
|
+
year: "3rd year",
|
|
10
|
+
location: "Tirupur, Tamil Nadu, India",
|
|
11
|
+
welcome: "Welcome to cj's CLI Portfolio",
|
|
12
|
+
speech: ["meow says cj"], // text inside the speech bubble (about 12 characters fit; longer text is cut with โฆ, use [] to hide the bubble)
|
|
13
|
+
|
|
14
|
+
tagline: "I like turning random ideas into things that actually work.",
|
|
15
|
+
|
|
16
|
+
intro: [
|
|
17
|
+
"Hey, I'm cj.",
|
|
18
|
+
"I'm a Computer Science & Design student who loves building things.",
|
|
19
|
+
"Most days you'll find me coding, learning something new, or fixing a bug I created.",
|
|
20
|
+
"Have a look around. It's a small corner of the internet, but it's mine.",
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
about: [
|
|
24
|
+
"I'm Chiranjeevi, but cj is my another identity",
|
|
25
|
+
"I'm stu(dying) B.E. Computer Science & Design",
|
|
26
|
+
"I enjoy building practical apps, experimenting with ideas, and learning by making things.",
|
|
27
|
+
"Currently exploring software development, Android, web apps and AI-powered projects.",
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
skills: {
|
|
31
|
+
Languages: ["Java", "C", "C++", "Python", "JavaScript", "Kotlin"],
|
|
32
|
+
"Web & Backend": ["HTML", "CSS", "React", "Node.js", "Spring Boot"],
|
|
33
|
+
Databases: ["PostgreSQL", "MySQL", "Supabase"],
|
|
34
|
+
"Tools & Platforms": ["Git", "GitHub", "VS Code", "Linux", "AWS"],
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// url = what is shown on the card / links panel
|
|
38
|
+
links: [
|
|
39
|
+
{ label: "GitHub", url: "https://github.com/cjmaybe", color: "#6e7681" },
|
|
40
|
+
{ label: "LinkedIn", url: "https://linkedin.com/in/cjmaybe", color: "#0a66c2" },
|
|
41
|
+
{ label: "Portfolio", url: "https://maybecj.web.app", color: "#f1c40f" },
|
|
42
|
+
{ label: "Email", url: "cjmaybe0@gmail.com", href: "mailto:cjmaybe0@gmail.com", color: "#7b4fa3" },
|
|
43
|
+
{ label: "NPX", url: "npx cjmaybe", color: "#cf3636" },
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
resume: "https://drive.google.com/file/d/1wHzFyexAmcNcepAHMsHbfUH7CzaQsoM5/view?usp=drive_link",
|
|
47
|
+
portfolio: "https://maybecj.web.app",
|
|
48
|
+
github: "https://github.com/cjmaybe",
|
|
49
|
+
linkedin: "https://linkedin.com/in/cjmaybe",
|
|
50
|
+
email: "cjmaybe0@gmail.com",
|
|
51
|
+
|
|
52
|
+
highlights: [
|
|
53
|
+
"Presented projects at HackITon'26 and HACKNEXT'26.",
|
|
54
|
+
"Presented a paper at Titanium 2026.",
|
|
55
|
+
"Built an e-commerce website for Sri Harivel Crackers.",
|
|
56
|
+
"Earned NPTEL Elite certificates.",
|
|
57
|
+
],
|
|
58
|
+
|
|
59
|
+
projects: [
|
|
60
|
+
{
|
|
61
|
+
name: "Next-Pay",
|
|
62
|
+
tags: "Android โข Kotlin โข USSD",
|
|
63
|
+
desc: "An offline-first UPI assistant concept that helps users make payments with a simpler flow.",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "Yaatra AI",
|
|
67
|
+
tags: "React โข Supabase โข AI โข Maps",
|
|
68
|
+
desc: "An AI travel companion that helps plan trips and explore places.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "DockVault",
|
|
72
|
+
tags: "Web โข JavaScript โข Google Drive",
|
|
73
|
+
desc: "A personal document space to organise and find important files.",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "Numora",
|
|
77
|
+
tags: "Windows โข Productivity",
|
|
78
|
+
desc: "A small idea to turn unused numpad keys into quick shortcuts for opening apps.",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "Quiz Flow",
|
|
82
|
+
tags: "HTML โข CSS โข JavaScript",
|
|
83
|
+
desc: "A simple web app for practising NPTEL-style quizzes.",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "Sri Harivel Crackers",
|
|
87
|
+
tags: "Freelance โข E-commerce",
|
|
88
|
+
desc: "An e-commerce website built for a real client.",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
|
|
92
|
+
tips: [
|
|
93
|
+
"cmd/ctrl + click any link to open it",
|
|
94
|
+
"โ โ (or j / k) to move, enter to select",
|
|
95
|
+
"press any key during the intro to skip it",
|
|
96
|
+
"npx cjmaybe --fast skips the animation completely",
|
|
97
|
+
"ctrl + c exits any time",
|
|
98
|
+
"use a terminal at least 120 columns wide to see the art",
|
|
99
|
+
],
|
|
100
|
+
|
|
101
|
+
footer: ["Thanks for visiting my cli portfolio.", "If you want to build something together, say hello."],
|
|
102
|
+
};
|
package/src/system.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export const openUrl = (target) => {
|
|
4
|
+
const { platform } = process;
|
|
5
|
+
let cmd;
|
|
6
|
+
let args;
|
|
7
|
+
if (platform === "darwin") {
|
|
8
|
+
cmd = "open";
|
|
9
|
+
args = [target];
|
|
10
|
+
} else if (platform === "win32") {
|
|
11
|
+
cmd = "cmd";
|
|
12
|
+
args = ["/c", "start", "", target];
|
|
13
|
+
} else {
|
|
14
|
+
cmd = "xdg-open";
|
|
15
|
+
args = [target];
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
19
|
+
child.on("error", () => {});
|
|
20
|
+
child.unref();
|
|
21
|
+
} catch {
|
|
22
|
+
// if it can't open, the url is still printed in the terminal
|
|
23
|
+
}
|
|
24
|
+
};
|
package/src/views.js
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import readline from "node:readline";
|
|
3
|
+
import boxen from "boxen";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import figlet from "figlet";
|
|
6
|
+
import ansiShadow from "figlet/importable-fonts/ANSI Shadow.js";
|
|
7
|
+
import { profile } from "./profile.js";
|
|
8
|
+
import { catArt } from "./cat.js";
|
|
9
|
+
import { bubbleArt } from "./bubble.js";
|
|
10
|
+
|
|
11
|
+
const pkg = createRequire(import.meta.url)("../package.json");
|
|
12
|
+
|
|
13
|
+
// โฑ Pacing: raise these numbers to slow things down, lower to speed up.
|
|
14
|
+
export const TIMING = {
|
|
15
|
+
charMs: 34, // ms per typed character
|
|
16
|
+
lineGapMs: 900, // pause after each intro line
|
|
17
|
+
afterIntroMs: 1100 // pause before the card appears
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
figlet.parseFont("ANSI Shadow", ansiShadow);
|
|
21
|
+
|
|
22
|
+
const accent = chalk.hex("#cba6f7");
|
|
23
|
+
|
|
24
|
+
// Clickable link (OSC 8): ctrl/cmd + click works in Windows Terminal, iTerm2, VS Code...
|
|
25
|
+
export const link = (href, text) => `\u001b]8;;${href}\u0007${text}\u001b]8;;\u0007`;
|
|
26
|
+
const ANSI = /\u001b\[[0-9;]*m|\u001b\]8;;[^\u0007\u001b]*(?:\u0007|\u001b\\)/g;
|
|
27
|
+
const visibleLength = (s) => s.replace(ANSI, "").length;
|
|
28
|
+
|
|
29
|
+
// Press any key during the animation to skip it.
|
|
30
|
+
export const makeSkipper = () => {
|
|
31
|
+
const state = { skipped: false };
|
|
32
|
+
const stdin = process.stdin;
|
|
33
|
+
if (!stdin.isTTY) return { state, stop() {} };
|
|
34
|
+
readline.emitKeypressEvents(stdin);
|
|
35
|
+
stdin.setRawMode(true);
|
|
36
|
+
stdin.resume();
|
|
37
|
+
const onKey = (_, key) => {
|
|
38
|
+
if (key && key.ctrl && key.name === "c") {
|
|
39
|
+
process.stdout.write("\x1B[?25h\n");
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
state.skipped = true;
|
|
43
|
+
};
|
|
44
|
+
stdin.on("keypress", onKey);
|
|
45
|
+
return {
|
|
46
|
+
state,
|
|
47
|
+
stop() {
|
|
48
|
+
stdin.removeListener("keypress", onKey);
|
|
49
|
+
stdin.setRawMode(false);
|
|
50
|
+
stdin.pause();
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const makeClock = (fast, state) => {
|
|
56
|
+
const isFast = () => fast || state.skipped;
|
|
57
|
+
const wait = async (ms) => {
|
|
58
|
+
let left = ms;
|
|
59
|
+
while (left > 0 && !isFast()) {
|
|
60
|
+
const step = Math.min(30, left);
|
|
61
|
+
await new Promise((r) => setTimeout(r, step));
|
|
62
|
+
left -= step;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const type = async (text, color = chalk.white, speed = TIMING.charMs) => {
|
|
66
|
+
for (let i = 0; i < text.length; i++) {
|
|
67
|
+
if (isFast()) {
|
|
68
|
+
process.stdout.write(color(text.slice(i)));
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
process.stdout.write(color(text[i]));
|
|
72
|
+
await wait(speed);
|
|
73
|
+
}
|
|
74
|
+
process.stdout.write("\n");
|
|
75
|
+
};
|
|
76
|
+
return { isFast, wait, type };
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const spinner = async (text, doneText, clock, fast) => {
|
|
80
|
+
const frames = ["โ ", "โ ", "โ น", "โ ธ", "โ ผ", "โ ด", "โ ฆ", "โ ง", "โ ", "โ "];
|
|
81
|
+
if (fast || !process.stdout.isTTY) {
|
|
82
|
+
console.log(`${chalk.greenBright("๐พ")} ${doneText}`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
process.stdout.write("\x1B[?25l");
|
|
86
|
+
let i = 0;
|
|
87
|
+
const t = setInterval(() => {
|
|
88
|
+
process.stdout.write(`\r${accent(frames[i++ % frames.length])} ${text}`);
|
|
89
|
+
}, 80);
|
|
90
|
+
await clock.wait(1300);
|
|
91
|
+
clearInterval(t);
|
|
92
|
+
process.stdout.write(`\r\x1B[K${chalk.greenBright("๐พ")} ${doneText}\n`);
|
|
93
|
+
process.stdout.write("\x1B[?25h");
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const intro = async (fast, state = { skipped: false }) => {
|
|
97
|
+
const clock = makeClock(fast, state);
|
|
98
|
+
await spinner("getting things ready", "all set. welcome in!", clock, fast);
|
|
99
|
+
console.log();
|
|
100
|
+
await clock.wait(500);
|
|
101
|
+
for (const line of profile.intro) {
|
|
102
|
+
await clock.type(line, chalk.white);
|
|
103
|
+
await clock.wait(TIMING.lineGapMs);
|
|
104
|
+
}
|
|
105
|
+
console.log();
|
|
106
|
+
await clock.wait(TIMING.afterIntroMs);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// dark text on light bars (yellow), white text on dark bars
|
|
110
|
+
const textOn = (hex) => {
|
|
111
|
+
const n = parseInt(hex.slice(1), 16);
|
|
112
|
+
const lum = (0.299 * (n >> 16) + 0.587 * ((n >> 8) & 255) + 0.114 * (n & 255)) / 255;
|
|
113
|
+
return lum > 0.6 ? "#1e1e2e" : "#ffffff";
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const GRADIENT = ["#ff6ec7", "#e865d8", "#c77dff", "#a88bff", "#7aa2ff", "#5bc0ff"];
|
|
117
|
+
const MUTED = "#9399b2";
|
|
118
|
+
|
|
119
|
+
const titleLines = (big) =>
|
|
120
|
+
big
|
|
121
|
+
? figlet
|
|
122
|
+
.textSync(profile.handle.toUpperCase(), { font: "ANSI Shadow" })
|
|
123
|
+
.split("\n")
|
|
124
|
+
.filter((l) => l.trim() !== "")
|
|
125
|
+
.map((l, i) => chalk.hex(GRADIENT[i % GRADIENT.length]).bold(l))
|
|
126
|
+
: [chalk.hex("#c77dff").bold(profile.handle.toUpperCase())];
|
|
127
|
+
|
|
128
|
+
// colored link bars, every bar is clickable
|
|
129
|
+
const linkBars = () => {
|
|
130
|
+
const { links } = profile;
|
|
131
|
+
const maxLabel = Math.max(...links.map((l) => l.label.length));
|
|
132
|
+
const maxVal = Math.max(...links.map((l) => l.url.length));
|
|
133
|
+
return links.map((l) => {
|
|
134
|
+
const bar = chalk
|
|
135
|
+
.bgHex(l.color)
|
|
136
|
+
.hex(textOn(l.color))
|
|
137
|
+
.bold(` ${l.label.padEnd(maxLabel)} : ${l.url.padEnd(maxVal)} `);
|
|
138
|
+
const href = l.href ?? (/^https?:\/\//.test(l.url) ? l.url : null);
|
|
139
|
+
return href ? link(href, bar) : bar;
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const dots = () =>
|
|
144
|
+
["#45475a", "#bac2de", "#94e2d5", "#f5c2e7", "#89b4fa", "#f9e2af", "#a6e3a1", "#f38ba8"]
|
|
145
|
+
.map((c) => chalk.hex(c)("โ"))
|
|
146
|
+
.join(" ");
|
|
147
|
+
|
|
148
|
+
// layout "side": cat on the left, left-aligned details on the right
|
|
149
|
+
const sideLines = (big) => {
|
|
150
|
+
const { name, handle, role, college, year, batch, location, tagline, footer } = profile;
|
|
151
|
+
const key = (k) => accent.bold(k.padEnd(10));
|
|
152
|
+
const val = (v) => chalk.hex("#cdd6f4")(v);
|
|
153
|
+
const first = name.split(" ")[0].toUpperCase();
|
|
154
|
+
const rule = chalk.hex("#585b70")("โ".repeat(first.length + handle.length + 1));
|
|
155
|
+
return [
|
|
156
|
+
...titleLines(big),
|
|
157
|
+
rule, // line above the handle (delete this line if you only want the one below)
|
|
158
|
+
chalk.hex("#f5c2e7").bold(first) + chalk.hex("#89dceb").bold(`@${handle}`),
|
|
159
|
+
rule, // line below the handle
|
|
160
|
+
"",
|
|
161
|
+
key("Role") + val(role),
|
|
162
|
+
key("College") + val(college),
|
|
163
|
+
key("Year") + val(`${year} ยท ${batch}`),
|
|
164
|
+
key("Location") + val(location),
|
|
165
|
+
"",
|
|
166
|
+
...linkBars(),
|
|
167
|
+
"",
|
|
168
|
+
dots(),
|
|
169
|
+
"",
|
|
170
|
+
chalk.italic.hex("#f5e0dc")(tagline),
|
|
171
|
+
...footer.map((l) => chalk.hex(MUTED)(l)),
|
|
172
|
+
];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// layout "stack": everything centered, used when the terminal is too narrow for the cat
|
|
176
|
+
const stackLines = (big) => {
|
|
177
|
+
const { name, role, college, year, batch, location, tagline, footer } = profile;
|
|
178
|
+
return [
|
|
179
|
+
...titleLines(big),
|
|
180
|
+
"",
|
|
181
|
+
chalk.whiteBright(name.toUpperCase()),
|
|
182
|
+
chalk.hex("#c77dff").bold(role),
|
|
183
|
+
chalk.hex(MUTED)(college),
|
|
184
|
+
chalk.hex(MUTED)(`${year} ยท ${batch} ยท ${location}`),
|
|
185
|
+
"",
|
|
186
|
+
chalk.italic.hex("#cdd6f4")(tagline),
|
|
187
|
+
"",
|
|
188
|
+
...linkBars(),
|
|
189
|
+
"",
|
|
190
|
+
...footer.map((l) => chalk.italic.hex("#cdd6f4")(l)),
|
|
191
|
+
];
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const isBlank = (ch) => ch === "\u2800" || ch === " ";
|
|
195
|
+
const speechLines = () => (Array.isArray(profile.speech) ? profile.speech : profile.speech ? [profile.speech] : []);
|
|
196
|
+
|
|
197
|
+
// Left column: the dot art with a braille speech bubble at its upper right, tail pointing at the head.
|
|
198
|
+
const buildLeftColumn = () => {
|
|
199
|
+
const cat = chalk.hex("#f5e0dc");
|
|
200
|
+
const bub = chalk.hex("#f5c2e7");
|
|
201
|
+
const say = speechLines();
|
|
202
|
+
const artWidth = catArt[0].length;
|
|
203
|
+
if (!say.length) return catArt.map((r) => cat(r));
|
|
204
|
+
|
|
205
|
+
const bCells = bubbleArt.map((r) => [...r]);
|
|
206
|
+
const bCols = bCells[0].length;
|
|
207
|
+
const bRows = bCells.length;
|
|
208
|
+
const firstSolid = (cells) => cells.findIndex((c) => !isBlank(c));
|
|
209
|
+
const lastSolid = (cells) => {
|
|
210
|
+
for (let i = cells.length - 1; i >= 0; i--) if (!isBlank(cells[i])) return i;
|
|
211
|
+
return -1;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// bubble starts at the top of the art; shift it right until it just touches the head, never overlapping it
|
|
215
|
+
const r0 = 0;
|
|
216
|
+
let L = 0;
|
|
217
|
+
for (let r = 0; r < bRows; r++) {
|
|
218
|
+
const fb = firstSolid(bCells[r]);
|
|
219
|
+
if (fb < 0) continue;
|
|
220
|
+
L = Math.max(L, lastSolid([...catArt[r0 + r]]) + 1 - fb);
|
|
221
|
+
}
|
|
222
|
+
const width = Math.max(artWidth, L + bCols);
|
|
223
|
+
|
|
224
|
+
const grid = catArt.map((row) => {
|
|
225
|
+
const cells = [...row].map((ch) => ({ ch, st: cat }));
|
|
226
|
+
while (cells.length < width) cells.push({ ch: " ", st: (x) => x });
|
|
227
|
+
return cells;
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// draw only the bubble's dots, so blank cells never erase the art
|
|
231
|
+
bCells.forEach((row, r) =>
|
|
232
|
+
row.forEach((ch, c) => {
|
|
233
|
+
if (!isBlank(ch)) grid[r0 + r][L + c] = { ch, st: bub };
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
// text goes on the roomiest middle row of the oval, centered between its side walls
|
|
238
|
+
const interior = (r) => {
|
|
239
|
+
const cells = bCells[r];
|
|
240
|
+
const left = firstSolid(cells);
|
|
241
|
+
const right = lastSolid(cells);
|
|
242
|
+
let i0 = left;
|
|
243
|
+
while (i0 < cells.length && !isBlank(cells[i0])) i0++;
|
|
244
|
+
let i1 = right;
|
|
245
|
+
while (i1 >= 0 && !isBlank(cells[i1])) i1--;
|
|
246
|
+
return i1 > i0 ? [i0, i1] : null;
|
|
247
|
+
};
|
|
248
|
+
let bestRow = 1;
|
|
249
|
+
let bestWidth = 0;
|
|
250
|
+
for (let r = 1; r < bRows - 2; r++) {
|
|
251
|
+
const span = interior(r);
|
|
252
|
+
if (span && span[1] - span[0] + 1 > bestWidth) {
|
|
253
|
+
bestWidth = span[1] - span[0] + 1;
|
|
254
|
+
bestRow = r;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const startRow = bestRow - Math.floor((say.length - 1) / 2);
|
|
258
|
+
say.forEach((line, i) => {
|
|
259
|
+
const r = startRow + i;
|
|
260
|
+
const span = interior(r);
|
|
261
|
+
if (!span) return;
|
|
262
|
+
const room = span[1] - span[0] + 1;
|
|
263
|
+
const text = [...line].length > room - 2 ? [...line].slice(0, room - 3).join("") + "โฆ" : line;
|
|
264
|
+
const start = span[0] + Math.floor((room - [...text].length) / 2);
|
|
265
|
+
[...text].forEach((ch, k) => {
|
|
266
|
+
grid[r0 + r][L + start + k] = { ch, st: chalk.whiteBright.bold };
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return grid.map((cells) => cells.map(({ ch, st }) => st(ch)).join(""));
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const drawCard = async () => {
|
|
274
|
+
const cols = process.stdout.columns || 120;
|
|
275
|
+
const leftCol = buildLeftColumn();
|
|
276
|
+
const artWidth = visibleLength(leftCol[0]);
|
|
277
|
+
const gap = 4;
|
|
278
|
+
const PAD_X = 3;
|
|
279
|
+
const BOX_EXTRA = 2 + PAD_X * 2; // border + horizontal padding
|
|
280
|
+
|
|
281
|
+
const big = cols >= 72;
|
|
282
|
+
const side = sideLines(big);
|
|
283
|
+
const sideWidth = Math.max(...side.map(visibleLength));
|
|
284
|
+
const withCat = cols >= artWidth + gap + sideWidth + BOX_EXTRA;
|
|
285
|
+
|
|
286
|
+
let body;
|
|
287
|
+
if (withCat) {
|
|
288
|
+
const total = Math.max(leftCol.length, side.length);
|
|
289
|
+
const leftTop = Math.floor((total - leftCol.length) / 2);
|
|
290
|
+
const textTop = Math.floor((total - side.length) / 2);
|
|
291
|
+
body = Array.from({ length: total }, (_, i) => {
|
|
292
|
+
const art = leftCol[i - leftTop] ?? " ".repeat(artWidth);
|
|
293
|
+
return art + " ".repeat(gap) + (side[i - textTop] ?? "");
|
|
294
|
+
}).join("\n");
|
|
295
|
+
} else {
|
|
296
|
+
body = stackLines(big).join("\n");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const bodyWidth = Math.max(...body.split("\n").map(visibleLength));
|
|
300
|
+
const box = boxen(body, {
|
|
301
|
+
width: bodyWidth + PAD_X * 2 + 2, // text + horizontal padding + border
|
|
302
|
+
borderStyle: "round", // thin line
|
|
303
|
+
borderColor: "#f5c2e7",
|
|
304
|
+
padding: { top: 1, bottom: 1, left: PAD_X, right: PAD_X },
|
|
305
|
+
margin: { top: 1, bottom: 0, left: 0, right: 0 },
|
|
306
|
+
textAlignment: withCat ? "left" : "center",
|
|
307
|
+
float: "center",
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// the card is shown at once, no animation
|
|
311
|
+
console.log(box);
|
|
312
|
+
console.log(chalk.hex(MUTED)("\n tip: cmd/ctrl + click the links above\n"));
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const panel = (content, title) => {
|
|
316
|
+
console.log(
|
|
317
|
+
boxen(content, {
|
|
318
|
+
title,
|
|
319
|
+
titleAlignment: "left",
|
|
320
|
+
borderColor: "magenta",
|
|
321
|
+
borderStyle: "round",
|
|
322
|
+
padding: 1,
|
|
323
|
+
margin: { top: 1, bottom: 0, left: 1, right: 1 },
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export const drawAbout = () => panel(profile.about.map((l) => `โข ${l}`).join("\n"), "a little about me");
|
|
329
|
+
|
|
330
|
+
export const drawSkills = () => {
|
|
331
|
+
const content = Object.entries(profile.skills)
|
|
332
|
+
.map(([cat, items]) => `${accent.bold(cat)}\n${items.join(" ยท ")}`)
|
|
333
|
+
.join("\n\n");
|
|
334
|
+
panel(content, "things I work with");
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export const drawProjects = () => {
|
|
338
|
+
const content = profile.projects
|
|
339
|
+
.map((p) => `${accent.bold(p.name)} ${chalk.dim(p.tags)}\n${p.desc}`)
|
|
340
|
+
.join("\n\n");
|
|
341
|
+
panel(content, "some things I've built");
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export const drawHighlights = () => panel(profile.highlights.map((l) => `โข ${l}`).join("\n"), "a few highlights");
|
|
345
|
+
|
|
346
|
+
export const drawLinks = () => {
|
|
347
|
+
const content = profile.links
|
|
348
|
+
.map((l) => {
|
|
349
|
+
const href = l.href ?? (/^https?:\/\//.test(l.url) ? l.url : null);
|
|
350
|
+
const text = href ? link(href, l.url) : l.url;
|
|
351
|
+
return `${accent.bold(l.label.padEnd(10))} ${text}`;
|
|
352
|
+
})
|
|
353
|
+
.join("\n");
|
|
354
|
+
panel(content, "find me around");
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const drawTips = () => panel(profile.tips.map((t) => `${accent("โข")} ${t}`).join("\n"), "tips");
|
|
358
|
+
|
|
359
|
+
export const drawWelcome = () => {
|
|
360
|
+
console.log(`\n ${chalk.greenBright("๐พ")} ${chalk.whiteBright.bold(profile.welcome)} ${chalk.dim(`- v${pkg.version}`)}`);
|
|
361
|
+
};
|