create-uni-app-tailwindcss 0.1.4 → 0.1.5
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/cli.js
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import path from "path";
|
|
7
|
-
import process from "process";
|
|
2
|
+
import { cp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
8
6
|
import prompts from "prompts";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
//#region src/cli.ts
|
|
8
|
+
const templatesRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "templates");
|
|
9
|
+
const options = parseArgs(process.argv.slice(2));
|
|
10
|
+
const targetArg = options.target;
|
|
11
|
+
const targetDir = path.resolve(process.cwd(), targetArg ?? "uni-app-tailwindcss-app");
|
|
12
|
+
const projectName = path.basename(targetDir);
|
|
14
13
|
async function main() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
const template = await resolveTemplate(await loadTemplateRegistry(), options.template);
|
|
15
|
+
const packageManager = await resolvePackageManager(options.packageManager);
|
|
16
|
+
if (await exists(targetDir)) {
|
|
17
|
+
if (!(await prompts({
|
|
18
|
+
type: "confirm",
|
|
19
|
+
name: "overwrite",
|
|
20
|
+
message: `Directory ${projectName} exists. Overwrite it?`,
|
|
21
|
+
initial: false
|
|
22
|
+
})).overwrite) return;
|
|
23
|
+
await rm(targetDir, {
|
|
24
|
+
recursive: true,
|
|
25
|
+
force: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
await mkdir(targetDir, { recursive: true });
|
|
29
|
+
await copyTemplate(path.join(templatesRoot, template.id), targetDir);
|
|
30
|
+
await renamePackage(targetDir, projectName);
|
|
31
|
+
console.log(`Created ${projectName}`);
|
|
32
|
+
console.log(`Template: ${template.id}`);
|
|
33
|
+
console.log(`cd ${projectName}`);
|
|
34
|
+
console.log(`${packageManager} install`);
|
|
35
|
+
console.log(`${packageManager} dev:h5`);
|
|
36
36
|
}
|
|
37
37
|
async function loadTemplateRegistry() {
|
|
38
|
-
|
|
38
|
+
return JSON.parse(await readFile(path.join(templatesRoot, "registry.json"), "utf8"));
|
|
39
39
|
}
|
|
40
40
|
async function copyTemplate(source, target) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const entries = await readdir(source, { withFileTypes: true });
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const sourcePath = path.join(source, entry.name);
|
|
44
|
+
const targetName = entry.name === "_npmrc" ? ".npmrc" : entry.name;
|
|
45
|
+
const targetPath = path.join(target, targetName);
|
|
46
|
+
if (entry.isDirectory()) {
|
|
47
|
+
await mkdir(targetPath, { recursive: true });
|
|
48
|
+
await copyTemplate(sourcePath, targetPath);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
await cp(sourcePath, targetPath);
|
|
52
|
+
}
|
|
53
53
|
}
|
|
54
|
-
async function renamePackage(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`);
|
|
54
|
+
async function renamePackage(targetDir, name) {
|
|
55
|
+
const pkgPath = path.join(targetDir, "package.json");
|
|
56
|
+
const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
57
|
+
pkg.name = name;
|
|
58
|
+
await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
60
59
|
}
|
|
61
60
|
async function exists(filePath) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
try {
|
|
62
|
+
await readdir(filePath);
|
|
63
|
+
return true;
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
68
67
|
}
|
|
69
68
|
function parseArgs(args) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
69
|
+
let packageManager;
|
|
70
|
+
let template;
|
|
71
|
+
let target;
|
|
72
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
73
|
+
const arg = args[index];
|
|
74
|
+
if (arg === "--") continue;
|
|
75
|
+
if (arg === "--pm" || arg === "--package-manager") {
|
|
76
|
+
packageManager = args[index + 1];
|
|
77
|
+
index += 1;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (arg.startsWith("--pm=")) {
|
|
81
|
+
packageManager = arg.slice(5);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (arg.startsWith("--package-manager=")) {
|
|
85
|
+
packageManager = arg.slice(18);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (arg === "--template") {
|
|
89
|
+
template = args[index + 1];
|
|
90
|
+
index += 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (arg.startsWith("--template=")) {
|
|
94
|
+
template = arg.slice(11);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (!arg.startsWith("-") && !target) target = arg;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
packageManager,
|
|
101
|
+
target,
|
|
102
|
+
template
|
|
103
|
+
};
|
|
105
104
|
}
|
|
106
105
|
async function resolveTemplate(registry, templateId) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
})),
|
|
126
|
-
initial: Math.max(0, registry.templates.findIndex((item) => item.id === registry.defaultTemplate))
|
|
127
|
-
});
|
|
128
|
-
return registry.templates.find((item) => item.id === response.template) ?? registry.templates.find((item) => item.id === registry.defaultTemplate) ?? registry.templates[0];
|
|
106
|
+
if (templateId) {
|
|
107
|
+
const template = registry.templates.find((item) => item.id === templateId);
|
|
108
|
+
if (!template) throw new Error(`Unknown template "${templateId}". Available templates: ${registry.templates.map((item) => item.id).join(", ")}`);
|
|
109
|
+
return template;
|
|
110
|
+
}
|
|
111
|
+
if (!process.stdin.isTTY || registry.templates.length === 1) return registry.templates.find((item) => item.id === registry.defaultTemplate) ?? registry.templates[0];
|
|
112
|
+
const response = await prompts({
|
|
113
|
+
type: "select",
|
|
114
|
+
name: "template",
|
|
115
|
+
message: "Template",
|
|
116
|
+
choices: registry.templates.map((template) => ({
|
|
117
|
+
description: template.description,
|
|
118
|
+
title: template.name,
|
|
119
|
+
value: template.id
|
|
120
|
+
})),
|
|
121
|
+
initial: Math.max(0, registry.templates.findIndex((item) => item.id === registry.defaultTemplate))
|
|
122
|
+
});
|
|
123
|
+
return registry.templates.find((item) => item.id === response.template) ?? registry.templates.find((item) => item.id === registry.defaultTemplate) ?? registry.templates[0];
|
|
129
124
|
}
|
|
130
125
|
async function resolvePackageManager(packageManager) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
const managers = [
|
|
127
|
+
"pnpm",
|
|
128
|
+
"npm",
|
|
129
|
+
"yarn",
|
|
130
|
+
"bun"
|
|
131
|
+
];
|
|
132
|
+
if (packageManager && managers.includes(packageManager)) return packageManager;
|
|
133
|
+
if (!process.stdin.isTTY) return "pnpm";
|
|
134
|
+
return (await prompts({
|
|
135
|
+
type: "select",
|
|
136
|
+
name: "packageManager",
|
|
137
|
+
message: "Package manager",
|
|
138
|
+
choices: managers.map((manager) => ({
|
|
139
|
+
title: manager,
|
|
140
|
+
value: manager
|
|
141
|
+
})),
|
|
142
|
+
initial: 0
|
|
143
|
+
})).packageManager ?? "pnpm";
|
|
146
144
|
}
|
|
147
145
|
main().catch((error) => {
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
147
|
+
process.exitCode = 1;
|
|
150
148
|
});
|
|
149
|
+
//#endregion
|
|
150
|
+
export {};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
- `Vue 3`
|
|
16
16
|
- `Tailwind CSS v4`
|
|
17
17
|
- `weapp-tailwindcss`
|
|
18
|
-
- `pnpm 12.
|
|
18
|
+
- `pnpm 12.14.0`
|
|
19
19
|
|
|
20
20
|
> 当前主分支是 `tailwindcss@4` 版本;如果需要 `tailwindcss@3` 版本,请切换到 `tailwindcss@3` 分支。
|
|
21
21
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
## 使用前提
|
|
34
34
|
|
|
35
35
|
- Node.js `^22.18.0 || >=24.11.0`
|
|
36
|
-
- `pnpm 12.
|
|
36
|
+
- `pnpm 12.14.0`
|
|
37
37
|
- 微信开发者工具,用于微信小程序
|
|
38
38
|
- HBuilderX `5.0+`,用于 Android 和 iOS App 调试
|
|
39
39
|
- Android SDK、模拟器或已开启调试的 Android 设备
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "uni-app-tailwindcss-template-default",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
|
-
"packageManager": "pnpm@12.
|
|
5
|
+
"packageManager": "pnpm@12.14.0",
|
|
6
6
|
"imports": {
|
|
7
7
|
"#tailwind.css": "./src/tailwind.css"
|
|
8
8
|
},
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"@vue/shared": "3.4.21",
|
|
73
73
|
"@weapp-tailwindcss/merge": "^2.2.6",
|
|
74
74
|
"pinia": "2.2.4",
|
|
75
|
-
"vue": "3.4.21",
|
|
75
|
+
"vue": "^3.4.21",
|
|
76
76
|
"vue-i18n": "^9.14.5"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@dcloudio/hbuilderx-cli": "^1.2.0",
|
|
80
|
-
"@dcloudio/types": "3.4.31",
|
|
80
|
+
"@dcloudio/types": "^3.4.31",
|
|
81
81
|
"@dcloudio/uni-cli-shared": "3.0.0-5020620260917001",
|
|
82
82
|
"@dcloudio/uni-stacktracey": "3.0.0-5020620260917001",
|
|
83
83
|
"@dcloudio/vite-plugin-uni": "3.0.0-5020620260917001",
|
|
@@ -86,19 +86,19 @@
|
|
|
86
86
|
"@iconify-json/mdi": "^1.2.3",
|
|
87
87
|
"@iconify-json/svg-spinners": "^1.2.4",
|
|
88
88
|
"@iconify/tailwind4": "^1.2.3",
|
|
89
|
-
"@types/node": "^26.6.
|
|
90
|
-
"@vue/runtime-core": "3.4.21",
|
|
89
|
+
"@types/node": "^26.6.5",
|
|
90
|
+
"@vue/runtime-core": "^3.4.21",
|
|
91
91
|
"autoprefixer": "^10.6.1",
|
|
92
|
-
"eslint": "^10.
|
|
93
|
-
"postcss": "^8.5.
|
|
92
|
+
"eslint": "^10.13.0",
|
|
93
|
+
"postcss": "^8.5.30",
|
|
94
94
|
"rollup": "4.14.3",
|
|
95
|
-
"sass": "^1.105.
|
|
96
|
-
"stylelint": "^17.
|
|
95
|
+
"sass": "^1.105.2",
|
|
96
|
+
"stylelint": "^17.16.0",
|
|
97
97
|
"tailwindcss": "^4.3.3",
|
|
98
98
|
"typescript": "^6.0.3",
|
|
99
99
|
"unplugin-auto-import": "^21.1.0",
|
|
100
100
|
"vite": "5.2.8",
|
|
101
|
-
"weapp-ide-cli": "^6.
|
|
102
|
-
"weapp-tailwindcss": "^5.
|
|
101
|
+
"weapp-ide-cli": "^6.2.0",
|
|
102
|
+
"weapp-tailwindcss": "^5.6.3"
|
|
103
103
|
}
|
|
104
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-uni-app-tailwindcss",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Create a uni-app project with Vite, Vue 3, Tailwind CSS, and weapp-tailwindcss.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"prompts": "^2.4.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@playwright/test": "^1.
|
|
45
|
-
"@types/node": "^26.6.
|
|
44
|
+
"@playwright/test": "^1.64.1",
|
|
45
|
+
"@types/node": "^26.6.5",
|
|
46
46
|
"@types/prompts": "^2.4.9",
|
|
47
|
-
"
|
|
47
|
+
"tsdown": "^0.23.1",
|
|
48
48
|
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|