create-liho 1.0.0
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 +26 -0
- package/index.js +97 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# create-liho
|
|
2
|
+
|
|
3
|
+
Create a new Liho app with one command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-liho my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What is Liho?
|
|
15
|
+
|
|
16
|
+
Liho is a lightweight React + Hono starter with file-based routing, inspired by SvelteKit but without the complexity of Next.js.
|
|
17
|
+
|
|
18
|
+
- **React 18** + React Router 7
|
|
19
|
+
- **Hono** - Ultra-light API backend (~14kb)
|
|
20
|
+
- **Vite** - Fast dev server with HMR
|
|
21
|
+
- **Tailwind CSS** - Utility-first styling
|
|
22
|
+
- **TypeScript** - Full type support
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'child_process'
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'fs'
|
|
5
|
+
import { join, resolve } from 'path'
|
|
6
|
+
|
|
7
|
+
const REPO = 'korohub/liho'
|
|
8
|
+
const BRANCH = 'main'
|
|
9
|
+
|
|
10
|
+
// Colors
|
|
11
|
+
const green = (text) => `\x1b[32m${text}\x1b[0m`
|
|
12
|
+
const cyan = (text) => `\x1b[36m${text}\x1b[0m`
|
|
13
|
+
const bold = (text) => `\x1b[1m${text}\x1b[0m`
|
|
14
|
+
const dim = (text) => `\x1b[2m${text}\x1b[0m`
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const args = process.argv.slice(2)
|
|
18
|
+
let projectName = args[0]
|
|
19
|
+
|
|
20
|
+
// Si pas de nom, utiliser le dossier courant
|
|
21
|
+
if (!projectName) {
|
|
22
|
+
console.log('')
|
|
23
|
+
console.log(`Usage: ${cyan('npx create-liho')} ${dim('<project-name>')}`)
|
|
24
|
+
console.log('')
|
|
25
|
+
console.log('Example:')
|
|
26
|
+
console.log(` ${cyan('npx create-liho my-app')}`)
|
|
27
|
+
console.log('')
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const targetDir = resolve(projectName)
|
|
32
|
+
const isCurrentDir = projectName === '.'
|
|
33
|
+
|
|
34
|
+
console.log('')
|
|
35
|
+
console.log(bold('Creating a new Liho app...'))
|
|
36
|
+
console.log('')
|
|
37
|
+
|
|
38
|
+
// Vérifier si le dossier existe
|
|
39
|
+
if (!isCurrentDir && existsSync(targetDir)) {
|
|
40
|
+
console.error(`Error: Directory ${cyan(projectName)} already exists.`)
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Créer le dossier
|
|
45
|
+
if (!isCurrentDir) {
|
|
46
|
+
mkdirSync(targetDir, { recursive: true })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Télécharger le template depuis GitHub
|
|
50
|
+
console.log(`Downloading template from ${dim(`github.com/${REPO}`)}...`)
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const tarballUrl = `https://github.com/${REPO}/archive/refs/heads/${BRANCH}.tar.gz`
|
|
54
|
+
|
|
55
|
+
// Télécharger et extraire
|
|
56
|
+
execSync(`curl -sL "${tarballUrl}" | tar -xz --strip-components=1 -C "${targetDir}"`, {
|
|
57
|
+
stdio: 'pipe'
|
|
58
|
+
})
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('Failed to download template. Check your internet connection.')
|
|
61
|
+
process.exit(1)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Mettre à jour package.json avec le nom du projet
|
|
65
|
+
const pkgPath = join(targetDir, 'package.json')
|
|
66
|
+
if (existsSync(pkgPath)) {
|
|
67
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
68
|
+
pkg.name = isCurrentDir ? 'liho-app' : projectName
|
|
69
|
+
pkg.version = '0.1.0'
|
|
70
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Supprimer les fichiers non nécessaires pour un nouveau projet
|
|
74
|
+
const filesToRemove = ['package-lock.json', 'llms.txt']
|
|
75
|
+
for (const file of filesToRemove) {
|
|
76
|
+
const filePath = join(targetDir, file)
|
|
77
|
+
if (existsSync(filePath)) {
|
|
78
|
+
rmSync(filePath)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log(green('✓') + ' Template downloaded')
|
|
83
|
+
console.log('')
|
|
84
|
+
console.log(bold('Next steps:'))
|
|
85
|
+
console.log('')
|
|
86
|
+
|
|
87
|
+
if (!isCurrentDir) {
|
|
88
|
+
console.log(` ${cyan('cd')} ${projectName}`)
|
|
89
|
+
}
|
|
90
|
+
console.log(` ${cyan('npm install')}`)
|
|
91
|
+
console.log(` ${cyan('npm run dev')}`)
|
|
92
|
+
console.log('')
|
|
93
|
+
console.log(dim(`Then open ${cyan('http://localhost:4010')} in your browser.`))
|
|
94
|
+
console.log('')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main().catch(console.error)
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-liho",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a new Liho app - React + Hono with file-based routing",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-liho": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"create",
|
|
11
|
+
"liho",
|
|
12
|
+
"react",
|
|
13
|
+
"hono",
|
|
14
|
+
"vite",
|
|
15
|
+
"starter",
|
|
16
|
+
"template"
|
|
17
|
+
],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/korohub/liho"
|
|
23
|
+
}
|
|
24
|
+
}
|