create-vite-uniapp 0.1.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/dist/actions/create.js +24 -0
- package/dist/cli.js +15 -0
- package/dist/index.js +3 -0
- package/dist/prompts.js +20 -0
- package/dist/utils/logger.js +6 -0
- package/dist/utils/pkg.js +5 -0
- package/package.json +52 -0
- package/templates/vue3-ts/index.html +11 -0
- package/templates/vue3-ts/package.json +16 -0
- package/templates/vue3-ts/src/App.vue +10 -0
- package/templates/vue3-ts/src/main.ts +4 -0
- package/templates/vue3-ts/src/pages/index/index.vue +7 -0
- package/templates/vue3-ts/tsconfig.json +10 -0
- package/templates/vue3-ts/vite.config.ts +6 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { getProjectInfo } from '../prompts.js';
|
|
5
|
+
import { log } from '../utils/logger.js';
|
|
6
|
+
const templatesDir = fileURLToPath(new URL('../../templates', import.meta.url));
|
|
7
|
+
export async function createProject(name, options) {
|
|
8
|
+
const result = await getProjectInfo(name);
|
|
9
|
+
const projectName = result.name;
|
|
10
|
+
const template = options?.template || result.template;
|
|
11
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
12
|
+
const templateDir = path.resolve(templatesDir, template);
|
|
13
|
+
if (!fs.existsSync(templateDir)) {
|
|
14
|
+
log.error(`Template "${template}" not found.`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
log.info(`Creating project in ${projectName}...`);
|
|
18
|
+
fs.copySync(templateDir, targetDir);
|
|
19
|
+
const gitignore = path.join(targetDir, '_gitignore');
|
|
20
|
+
if (fs.existsSync(gitignore)) {
|
|
21
|
+
fs.renameSync(gitignore, path.join(targetDir, '.gitignore'));
|
|
22
|
+
}
|
|
23
|
+
log.success('Project created successfully 🎉');
|
|
24
|
+
}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cac } from 'cac';
|
|
2
|
+
import { version } from './utils/pkg.js';
|
|
3
|
+
import { createProject } from './actions/create.js';
|
|
4
|
+
const cli = cac('create-uniapp');
|
|
5
|
+
export function run() {
|
|
6
|
+
cli
|
|
7
|
+
.command('[project-name]', 'Create a new UniApp project')
|
|
8
|
+
.option('--template <template>', 'Template name')
|
|
9
|
+
.action((name, options) => {
|
|
10
|
+
createProject(name, options);
|
|
11
|
+
});
|
|
12
|
+
cli.version(version);
|
|
13
|
+
cli.help();
|
|
14
|
+
cli.parse();
|
|
15
|
+
}
|
package/dist/index.js
ADDED
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
export async function getProjectInfo(defaultName) {
|
|
3
|
+
return prompts([
|
|
4
|
+
{
|
|
5
|
+
type: 'text',
|
|
6
|
+
name: 'name',
|
|
7
|
+
message: 'Project name:',
|
|
8
|
+
initial: defaultName || 'uniapp-project'
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: 'select',
|
|
12
|
+
name: 'template',
|
|
13
|
+
message: 'Select a template:',
|
|
14
|
+
choices: [
|
|
15
|
+
{ title: 'Vue3 + JavaScript', value: 'vue3-js' },
|
|
16
|
+
{ title: 'Vue3 + TypeScript', value: 'vue3-ts' }
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
const pkgPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
5
|
+
export const { version } = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-vite-uniapp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A fast CLI to bootstrap production-ready Uniapp projects.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-uniapp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"templates"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "tsx src/index.ts",
|
|
21
|
+
"build": "tsc"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/zeMinng/create-uniapp.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"create-uniapp",
|
|
29
|
+
"uniapp",
|
|
30
|
+
"vue",
|
|
31
|
+
"vite",
|
|
32
|
+
"cli",
|
|
33
|
+
"scaffold",
|
|
34
|
+
"boilerplate",
|
|
35
|
+
"template"
|
|
36
|
+
],
|
|
37
|
+
"author": "zeMinng",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/fs-extra": "^11.0.4",
|
|
41
|
+
"@types/node": "^25.0.3",
|
|
42
|
+
"@types/prompts": "^2.4.9",
|
|
43
|
+
"tsx": "^4.21.0",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"cac": "^6.7.14",
|
|
48
|
+
"fs-extra": "^11.3.3",
|
|
49
|
+
"kolorist": "^1.8.0",
|
|
50
|
+
"prompts": "^2.4.2"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uniapp-project",
|
|
3
|
+
"private": true,
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "vite",
|
|
6
|
+
"build": "vite build"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"vue": "^3.4.0"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
13
|
+
"typescript": "^5.4.0",
|
|
14
|
+
"vite": "^5.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|