create-vuexir 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/bin/create.mjs +52 -0
- package/package.json +30 -4
- package/templates/app/package.json +14 -0
- package/templates/app/src/pages/About.vue +19 -0
- package/templates/app/src/pages/Home.vue +19 -0
- package/templates/app/src/router.ts +11 -0
- package/templates/app/vrn.config.ts +7 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 panvu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/create.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create-vuexir —— 脚手架:npx create-vuexir my-app
|
|
4
|
+
* 生成最小可跑工程:src/router.ts + src/pages/Home.vue + About.vue + vrn.config.ts + package.json
|
|
5
|
+
* 之后:npm i && npx vuexir gen ios|android
|
|
6
|
+
*/
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { dirname, join, resolve } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const target = resolve(process.argv[2] ?? 'my-vuexir-app');
|
|
12
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const tpl = join(here, '..', 'templates', 'app');
|
|
14
|
+
|
|
15
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
16
|
+
console.log('用法:npx create-vuexir [目录名]\n生成 Vue SFC 工程骨架(含 router.ts 与 vrn.config.ts),随后 npx vuexir gen ios|android');
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
if (existsSync(target)) {
|
|
20
|
+
console.error(`✗ 目标已存在:${target}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
mkdirSync(target, { recursive: true });
|
|
24
|
+
cpSync(tpl, target, { recursive: true });
|
|
25
|
+
|
|
26
|
+
const name = target.split('/').pop().replace(/[^A-Za-z0-9-]/g, '-');
|
|
27
|
+
const pkgPath = join(target, 'package.json');
|
|
28
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
29
|
+
pkg.name = name;
|
|
30
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
31
|
+
// 工程名按分段 PascalCase 推导:my-vuexir-app → MyVuexirApp(bundleId 同步)
|
|
32
|
+
const pascal = name
|
|
33
|
+
.split(/[-_.]+/)
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1))
|
|
36
|
+
.join('') || 'MyApp';
|
|
37
|
+
const cfgPath = join(target, 'vrn.config.ts');
|
|
38
|
+
writeFileSync(
|
|
39
|
+
cfgPath,
|
|
40
|
+
readFileSync(cfgPath, 'utf-8')
|
|
41
|
+
.replace(/projectName: '[^']*'/, `projectName: '${pascal}'`)
|
|
42
|
+
.replace(/bundleId: '[^']*'/, `bundleId: 'com.example.${name.replace(/[^a-z0-9]/g, '')}'`),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
console.log(`✓ 已创建 ${target}
|
|
46
|
+
|
|
47
|
+
下一步:
|
|
48
|
+
cd ${target}
|
|
49
|
+
npm install
|
|
50
|
+
npx vuexir gen ios # 或 gen android
|
|
51
|
+
npx vuexir build ios --run
|
|
52
|
+
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vuexir",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "脚手架:npx create-vrn-app my-app(Vue SFC + router.ts + vrn.config.ts)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-vuexir": "./bin/create.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"templates",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/dongmingzhixiu/vuexir.git",
|
|
25
|
+
"directory": "packages/create-vrn-app"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/dongmingzhixiu/vuexir#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/dongmingzhixiu/vuexir/issues"
|
|
30
|
+
},
|
|
31
|
+
"author": "panvu"
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"native:gen": "vuexir gen ios",
|
|
7
|
+
"native:build": "vuexir build ios --run",
|
|
8
|
+
"native:gen:android": "vuexir gen android",
|
|
9
|
+
"native:build:android": "vuexir build android --run"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"vue": "^3.5.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const items = ref(['写 Vue SFC', '编译成原生源码', '双端 SwiftUI / Compose'])
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div class="screen">
|
|
7
|
+
<p class="title">关于</p>
|
|
8
|
+
<div class="card" v-for="(item, i) in items" :key="i">
|
|
9
|
+
<p class="line">{{ item }}</p>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
.screen { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #0a0f1e; }
|
|
16
|
+
.title { font-size: 18px; font-weight: bold; color: #f5e9c8; }
|
|
17
|
+
.card { padding: 14px; border-radius: 12px; background: #0f1832; }
|
|
18
|
+
.line { font-size: 14px; color: #e9e6dd; }
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const count = ref(0)
|
|
3
|
+
function inc() { count.value = count.value + 1 }
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<div class="screen">
|
|
8
|
+
<p class="title">Hello vuexir</p>
|
|
9
|
+
<p class="line">计数:{{ count }} 次</p>
|
|
10
|
+
<button class="btn" @click="inc">点我 +1</button>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
.screen { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: #0a0f1e; }
|
|
16
|
+
.title { font-size: 18px; font-weight: bold; color: #f5e9c8; }
|
|
17
|
+
.line { font-size: 14px; color: #a8aec2; }
|
|
18
|
+
.btn { padding: 12px; border-radius: 10px; background: #d9b36c; color: #0a0f1e; font-size: 15px; }
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// 多页路由:meta.tab=true → 底部 tab;其余为 push 二级页
|
|
2
|
+
import HomeView from './pages/Home.vue'
|
|
3
|
+
import AboutView from './pages/About.vue'
|
|
4
|
+
|
|
5
|
+
const routes = [
|
|
6
|
+
{ path: '/', name: 'home', component: HomeView, meta: { title: '首页', tab: true, icon: 'home.fill' } },
|
|
7
|
+
{ path: '/me', name: 'me', component: AboutView, meta: { title: '我的', tab: true, icon: 'person.fill' } },
|
|
8
|
+
{ path: '/detail', name: 'detail', component: AboutView, meta: { title: '详情' } },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
export default routes
|
package/README.md
DELETED