Skip to content

Commit 578703e

Browse files
committed
replace cleye with cac
1 parent 32f15d9 commit 578703e

File tree

8 files changed

+30
-129
lines changed

8 files changed

+30
-129
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Effortlessly bootstrap strongly-typed TypeScript npm libraries with minimal conf
55
## 🌟 Features
66

77
- **Minimal Setup & Visual Clarity**: Enjoy sensible defaults that keep your project setup clean.
8-
- **Developer-Centric**: Built with tools like `pkgroll`, `tsx`, `tsup`, `vitest`, and `clieye`.
8+
- **Developer-Centric**: Built with tools like `pkgroll`, `tsx`, `tsup`, `vitest`, and `cac`.
99
- **Comprehensive Configurations**:
1010
- Preconfigured `tsconfig`, `eslint`, `vitest`, `prettier`, `package.json`, and `.gitignore` files.
1111
- Ready-to-use GitHub Actions, pre-commit hooks, and npm scripts.
@@ -39,8 +39,4 @@ Here’s what your project structure will look like:
3939
- **Try `npx` Command Locally**: `npm run npx something`
4040
_(Modify the `npx` script in `package.json` to suit your project requirements.)_
4141

42-
Start your TypeScript library development journey with a delightful, optimized, and flexible setup. Enjoy coding! 🌸
43-
44-
## 🚧 Roadmap
45-
46-
- replace `cleye` with `cac`
42+
Enjoy coding! 🌸

npx/index.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env node
2-
import { cli } from 'cleye'
32
import { dirname, resolve } from 'path'
43
import { fileURLToPath } from 'url'
54
import { execaSync } from 'execa'
5+
import { cac } from 'cac'
6+
7+
const cli = cac('ts-hajime')
68

79
const getDirname = () => {
810
if (typeof __dirname === 'undefined') {
@@ -12,16 +14,12 @@ const getDirname = () => {
1214
}
1315
}
1416

15-
try {
16-
const argv = cli({
17-
name: 'ts-hajime',
18-
parameters: ['<app name>'],
19-
})
20-
console.log('Copying...')
21-
execaSync`cp -r ${resolve(getDirname(), '../template')} ${resolve(process.cwd(), argv._.appName)}`
22-
console.log('Copy complete! Installing node modules...')
23-
execaSync('npm', ['i'], { cwd: argv._.appName })
24-
console.log('Installation complete! Have fun!')
25-
} catch (e) {
26-
console.error(e)
27-
}
17+
cli.command('ts-hajime <app-name>', 'create a project')
18+
19+
const { args } = cli.parse()
20+
21+
console.log('Copying...')
22+
execaSync`cp -r ${resolve(getDirname(), '../template')} ${resolve(process.cwd(), args[0])}`
23+
console.log('Copy complete! Installing node modules...')
24+
execaSync('npm', ['i'], { cwd: args[0] })
25+
console.log('Installation complete! Have fun!')

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "ts-hajime",
33
"description": "Delightfully bootstraps TypeScript npm libraries.",
4-
"version": "0.0.24",
4+
"version": "0.1.0",
55
"scripts": {
66
"reset": "rm -rf node_modules && npm i",
77
"prepublishOnly": "npm run build",
88
"build": "pkgroll --clean-dist && tsup",
99
"test": "vitest",
1010
"lint": "eslint --fix",
1111
"tsc": "tsc",
12-
"npx": "tsx npx"
12+
"npx": "tsx npx abc"
1313
},
1414
"bin": {
1515
"ts-hajime": "./bin/index.cjs"
@@ -41,7 +41,7 @@
4141
"@types/eslint__js": "^8.42.3",
4242
"@types/fs-extra": "^11.0.4",
4343
"@vitest/coverage-v8": "^2.1.2",
44-
"cleye": "^1.3.2",
44+
"cac": "^6.7.14",
4545
"eslint": "^9.12.0",
4646
"eslint-config-prettier": "^9.1.0",
4747
"eslint-plugin-prettier": "^5.2.1",

template/npx/index.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { expect, it } from 'vitest'
22
import { execa } from 'execa'
33

4-
it('test cli with flag and last name', async () => {
5-
const { stdout } = await execa`npm run npx John Wick -- --time evening`
6-
expect(stdout).toContain('Good evening John Wick!')
7-
})
8-
it('test cli with first name only', async () => {
9-
const { stdout } = await execa`npm run npx Kobe`
10-
expect(stdout).toContain('Good morning Kobe!')
4+
it('test cli', async () => {
5+
const { stdout } = await execa`npm run npx John`
6+
expect(stdout).toContain('Hi John!')
117
})

template/npx/index.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
#!/usr/bin/env node
2-
import { cli } from 'cleye'
2+
import { cac } from 'cac'
33

4-
// Parse argv
5-
const argv = cli({
6-
name: 'my-app',
4+
const cli = cac()
75

8-
// Define parameters
9-
parameters: [
10-
'<first name>', // First name is required
11-
'[last name]', // Last name is optional
12-
],
6+
cli.command('GreetingAPP <name>')
137

14-
// Define flags/options
15-
flags: {
16-
// Parses `--time` as a string
17-
time: {
18-
type: String,
19-
description: 'Time of day to greet (morning or evening)',
20-
default: 'morning',
21-
},
22-
},
23-
})
8+
const { args } = cli.parse()
249

25-
const name = [argv._.firstName, argv._.lastName].filter(Boolean).join(' ')
26-
27-
if (argv.flags.time === 'morning') {
28-
console.log(`Good morning ${name}!`)
29-
} else {
30-
console.log(`Good evening ${name}!`)
31-
}
10+
console.log(`Hi ${args[0]}!`)

template/package-lock.json

Lines changed: 1 addition & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@eslint/js": "^9.12.0",
3838
"@types/eslint__js": "^8.42.3",
3939
"@vitest/coverage-v8": "^2.1.2",
40-
"cleye": "^1.3.2",
40+
"cac": "^6.7.14",
4141
"eslint": "^9.12.0",
4242
"eslint-config-prettier": "^9.1.0",
4343
"eslint-plugin-prettier": "^5.2.1",

0 commit comments

Comments
 (0)