Skip to content

Commit 8055ac0

Browse files
feat: add CLI project structure (#9)
* feat(cli): add basic project structure * fix: cli commands location resolution * feat(cli): migrated to commander * chore: add empty changeset
1 parent 0202065 commit 8055ac0

File tree

7 files changed

+161
-8
lines changed

7 files changed

+161
-8
lines changed

.changeset/healthy-emus-own.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/cli/bin/cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
await import('../build/index.js');

packages/cli/package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
"version": "0.0.0",
44
"description": "Replexica CLI",
55
"private": true,
6+
"type": "module",
67
"main": "build/index.js",
78
"types": "build/index.d.ts",
9+
"bin": {
10+
"replexica": "./bin/cli.js"
11+
},
812
"files": [
9-
"build"
13+
"build",
14+
"bin"
1015
],
1116
"scripts": {
17+
"replexica": "./bin/cli.js",
1218
"dev": "tsc -w",
1319
"build": "tsc",
1420
"test": "vitest run"
@@ -17,7 +23,12 @@
1723
"author": "",
1824
"license": "ISC",
1925
"dependencies": {
26+
"commander": "^12.0.0",
27+
"ora": "^8.0.1",
2028
"typescript": "^5.4.3",
2129
"vitest": "^1.4.0"
30+
},
31+
"devDependencies": {
32+
"@types/node": "^20"
2233
}
23-
}
34+
}

packages/cli/src/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
export {};
1+
import { Command } from 'commander';
2+
import Ora from 'ora';
3+
import { setTimeout } from 'timers/promises';
4+
5+
import loginCmd from './login.js';
6+
7+
export default new Command()
8+
.name('replexica')
9+
.description('Replexica CLI')
10+
.helpOption('-h, --help', 'Show help')
11+
.addCommand(loginCmd)
12+
.action(async (options) => {
13+
const spinner = Ora();
14+
spinner.start('Loading...');
15+
await setTimeout(2000);
16+
spinner.succeed('Welcome to Replexica CLI!');
17+
})
18+
.parse(process.argv);

packages/cli/src/login.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Command } from 'commander';
2+
import Ora from 'ora';
3+
import { setTimeout } from 'timers/promises';
4+
5+
export default new Command()
6+
.command('login')
7+
.description('Authenticate with Replexica Platform')
8+
.helpOption('-h, --help', 'Show help')
9+
.argument('<email>', 'Email address')
10+
.action(async () => {
11+
const spinner = Ora();
12+
spinner.start('Logging in...');
13+
await setTimeout(2000);
14+
spinner.succeed('Logged in');
15+
});

packages/cli/tsconfig.base.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"allowSyntheticDefaultImports": true,
1111
"skipLibCheck": true,
1212
"jsx": "react-jsx",
13-
"moduleResolution": "Node",
14-
"module": "ESNext",
13+
"moduleResolution": "NodeNext",
14+
"module": "NodeNext",
1515
"target": "ESNext"
1616
}
1717
}

pnpm-lock.yaml

Lines changed: 108 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)