vue-kaspa-cli 0.1.0 → 0.1.2
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/bin/index.mjs +30 -28
- package/package.json +14 -4
- package/templates/nuxt/_package.json +3 -2
- package/templates/nuxt/app/app.vue +3 -0
- package/templates/nuxt/{components → app/components}/KaspaStatus.vue +1 -1
- package/templates/nuxt/app/pages/index.vue +7 -0
- package/templates/nuxt/nuxt.config.ts +1 -1
- package/templates/vue/src/components/KaspaStatus.vue +1 -1
package/bin/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { stdin as input, stdout as output } from 'node:process'
|
|
2
|
+
import { createPromptModule } from 'inquirer'
|
|
4
3
|
import { existsSync, mkdirSync, readdirSync, statSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
4
|
import { join, dirname } from 'node:path'
|
|
6
5
|
import { fileURLToPath } from 'node:url'
|
|
@@ -15,22 +14,6 @@ const RENAMES = {
|
|
|
15
14
|
'_package.json': 'package.json',
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
const rl = createInterface({ input, output })
|
|
19
|
-
|
|
20
|
-
async function ask(question, fallback) {
|
|
21
|
-
const answer = (await rl.question(question)).trim()
|
|
22
|
-
return answer || fallback
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function choose(question, choices) {
|
|
26
|
-
output.write(`${question}\n${choices.map((c, i) => ` ${i + 1}) ${c}`).join('\n')}\n`)
|
|
27
|
-
while (true) {
|
|
28
|
-
const n = parseInt((await rl.question(' Enter number: ')).trim(), 10) - 1
|
|
29
|
-
if (n >= 0 && n < choices.length) return choices[n]
|
|
30
|
-
output.write(` Please enter 1–${choices.length}.\n`)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
17
|
function copyDir(src, dest) {
|
|
35
18
|
mkdirSync(dest, { recursive: true })
|
|
36
19
|
for (const entry of readdirSync(src)) {
|
|
@@ -42,17 +25,32 @@ function copyDir(src, dest) {
|
|
|
42
25
|
}
|
|
43
26
|
}
|
|
44
27
|
|
|
45
|
-
|
|
46
|
-
output.write('\n vue-kaspa-cli — scaffold a Kaspa-connected Vue/Nuxt app\n\n')
|
|
47
|
-
|
|
48
|
-
const name = await ask(' Project name (kaspa-app): ', 'kaspa-app')
|
|
49
|
-
const framework = await choose('\n Framework:', ['Vue', 'Nuxt'])
|
|
50
|
-
rl.close()
|
|
28
|
+
const prompt = createPromptModule()
|
|
51
29
|
|
|
30
|
+
async function main() {
|
|
31
|
+
console.log('\n vue-kaspa-cli — scaffold a Kaspa-connected Vue/Nuxt app\n')
|
|
32
|
+
|
|
33
|
+
const answers = await prompt([
|
|
34
|
+
{
|
|
35
|
+
type: 'input',
|
|
36
|
+
name: 'projectName',
|
|
37
|
+
message: 'Project name:',
|
|
38
|
+
default: 'kaspa-app',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'list',
|
|
42
|
+
name: 'framework',
|
|
43
|
+
message: 'Framework:',
|
|
44
|
+
choices: ['Vue', 'Nuxt'],
|
|
45
|
+
},
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
const { projectName, framework } = answers
|
|
49
|
+
const name = projectName.trim() || 'kaspa-app'
|
|
52
50
|
const targetDir = join(process.cwd(), name)
|
|
53
51
|
|
|
54
52
|
if (existsSync(targetDir) && readdirSync(targetDir).length > 0) {
|
|
55
|
-
|
|
53
|
+
console.error(`\n "${name}" already exists and is not empty.\n`)
|
|
56
54
|
process.exit(1)
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -63,15 +61,19 @@ async function main() {
|
|
|
63
61
|
pkg.name = name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '')
|
|
64
62
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
const editHint = framework === 'Nuxt'
|
|
65
|
+
? 'app/components/KaspaStatus.vue'
|
|
66
|
+
: 'src/components/KaspaStatus.vue'
|
|
67
|
+
|
|
68
|
+
console.log(`
|
|
67
69
|
Done!
|
|
68
70
|
|
|
69
71
|
cd ${name}
|
|
70
72
|
npm install
|
|
71
73
|
npm run dev
|
|
72
74
|
|
|
73
|
-
Edit
|
|
74
|
-
Docs → https://
|
|
75
|
+
Edit ${editHint} to start building.
|
|
76
|
+
Docs → https://vue-kaspa.vercel.app
|
|
75
77
|
|
|
76
78
|
`)
|
|
77
79
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-kaspa-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Scaffold a Vue 3 or Nuxt app wired to the Kaspa blockchain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,17 @@
|
|
|
9
9
|
"url": "https://github.com/furatamasensei/vue-kaspa.git",
|
|
10
10
|
"directory": "packages/vue-kaspa-cli"
|
|
11
11
|
},
|
|
12
|
-
"bin": {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"bin": {
|
|
13
|
+
"vue-kaspa-cli": "bin/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin",
|
|
17
|
+
"templates"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"inquirer": "^12.0.0"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
}
|
|
15
25
|
}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "nuxt dev",
|
|
7
7
|
"build": "nuxt build",
|
|
8
|
-
"preview": "nuxt preview"
|
|
8
|
+
"preview": "nuxt preview",
|
|
9
|
+
"generate": "nuxt generate"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"@vue-kaspa/kaspa-wasm": "^1.2.0",
|
|
12
|
-
"nuxt": "^
|
|
13
|
+
"nuxt": "^4.4.2",
|
|
13
14
|
"vue-kaspa": "^0.1.0"
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -61,7 +61,7 @@ const daaScore = computed(() =>
|
|
|
61
61
|
</div>
|
|
62
62
|
|
|
63
63
|
<footer style="display:flex;align-items:center;gap:.5rem;font-size:.85rem;border-top:1px solid #e2e8f0;padding-top:1rem;">
|
|
64
|
-
<a href="https://
|
|
64
|
+
<a href="https://vue-kaspa.vercel.app" target="_blank" rel="noopener" style="color:#374151;text-decoration:none;">Docs</a>
|
|
65
65
|
<span>·</span>
|
|
66
66
|
<a href="https://github.com/furatamasensei/vue-kaspa" target="_blank" rel="noopener" style="color:#374151;text-decoration:none;">GitHub</a>
|
|
67
67
|
</footer>
|
|
@@ -59,7 +59,7 @@ const daaScore = computed(() =>
|
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
<footer class="card__footer">
|
|
62
|
-
<a href="https://
|
|
62
|
+
<a href="https://vue-kaspa.vercel.app" target="_blank" rel="noopener">Docs</a>
|
|
63
63
|
<span>·</span>
|
|
64
64
|
<a href="https://github.com/furatamasensei/vue-kaspa" target="_blank" rel="noopener">GitHub</a>
|
|
65
65
|
</footer>
|